The NetBSD Project

CVS log for src/usr.bin/indent/indent.c

[BACK] Up to [cvs.NetBSD.org] / src / usr.bin / indent

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.390 / (download) - annotate - [select for diffs], Sun Dec 3 21:44:42 2023 UTC (4 months, 1 week ago) by rillig
Branch: MAIN
CVS Tags: HEAD
Changes since 1.389: +21 -21 lines
Diff to previous 1.389 (colored) to selected 1.128 (colored)

indent: inline input-related macros

No binary change.

Revision 1.389 / (download) - annotate - [select for diffs], Sun Dec 3 21:40:44 2023 UTC (4 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.388: +2 -3 lines
Diff to previous 1.388 (colored) to selected 1.128 (colored)

indent: group input-related variables into a struct

No functional change.

Revision 1.388 / (download) - annotate - [select for diffs], Sun Dec 3 21:03:58 2023 UTC (4 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.387: +6 -6 lines
Diff to previous 1.387 (colored) to selected 1.128 (colored)

indent: use line number of the token start in diagnostics

Previously, the line number of the end of the token was used, which was
confusing in debug mode.

Revision 1.387 / (download) - annotate - [select for diffs], Tue Jun 27 04:41:23 2023 UTC (9 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.386: +3 -3 lines
Diff to previous 1.386 (colored) to selected 1.128 (colored)

indent: fix 'blank line above first statement in function body'

Revision 1.386 / (download) - annotate - [select for diffs], Mon Jun 26 20:03:09 2023 UTC (9 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.385: +20 -2 lines
Diff to previous 1.385 (colored) to selected 1.128 (colored)

indent: implement 'blank line above first statement in function body'

Revision 1.385 / (download) - annotate - [select for diffs], Mon Jun 26 14:54:40 2023 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.384: +4 -2 lines
Diff to previous 1.384 (colored) to selected 1.128 (colored)

indent: in -bad mode, don't add a blank line above a comment or '}'

Revision 1.384 / (download) - annotate - [select for diffs], Sun Jun 25 19:35:45 2023 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.383: +6 -2 lines
Diff to previous 1.383 (colored) to selected 1.128 (colored)

indent: move cast detection from the lexer to the main processor

It is not the job of the lexer to modify the parser state.

Revision 1.383 / (download) - annotate - [select for diffs], Sun Jun 25 19:19:42 2023 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.382: +4 -3 lines
Diff to previous 1.382 (colored) to selected 1.128 (colored)

indent: fix formatting of parenthesized name in function definition

Revision 1.382 / (download) - annotate - [select for diffs], Fri Jun 23 20:43:21 2023 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.381: +4 -4 lines
Diff to previous 1.381 (colored) to selected 1.128 (colored)

indent: properly store parser state in debug mode

The stacks in the parser state are allocated now and need to be copied
individually.

The test whether two paren stacks are equal was broken since 2023-06-14
14:11:28.

Revision 1.381 / (download) - annotate - [select for diffs], Sun Jun 18 07:10:24 2023 UTC (9 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.380: +2 -4 lines
Diff to previous 1.380 (colored) to selected 1.128 (colored)

indent: remove support for backspace in code and comments

The C code in the whole tree does not contain a single literal
backspace.

Revision 1.380 / (download) - annotate - [select for diffs], Sat Jun 17 22:28:49 2023 UTC (9 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.379: +7 -7 lines
Diff to previous 1.379 (colored) to selected 1.128 (colored)

indent: miscellaneous cleanups

No binary change.

Revision 1.379 / (download) - annotate - [select for diffs], Fri Jun 16 23:51:32 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.378: +9 -8 lines
Diff to previous 1.378 (colored) to selected 1.128 (colored)

indent: merge lexer symbols for type in/outside parentheses

Revision 1.378 / (download) - annotate - [select for diffs], Fri Jun 16 23:07:52 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.377: +8 -7 lines
Diff to previous 1.377 (colored) to selected 1.128 (colored)

indent: fix spacing between postfix operator and left parenthesis

Revision 1.377 / (download) - annotate - [select for diffs], Fri Jun 16 14:26:26 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.376: +6 -4 lines
Diff to previous 1.376 (colored) to selected 1.128 (colored)

indent: improve heuristics for cast expressions

Revision 1.376 / (download) - annotate - [select for diffs], Fri Jun 16 14:12:10 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.375: +17 -8 lines
Diff to previous 1.375 (colored) to selected 1.128 (colored)

indent: improve heuristics for cast expressions

Revision 1.375 / (download) - annotate - [select for diffs], Fri Jun 16 12:55:57 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.374: +4 -2 lines
Diff to previous 1.374 (colored) to selected 1.128 (colored)

indent: improve heuristics for casts

Revision 1.374 / (download) - annotate - [select for diffs], Fri Jun 16 12:30:45 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.373: +10 -6 lines
Diff to previous 1.373 (colored) to selected 1.128 (colored)

indent: fix indentation and linebreaks in typedef declarations

Revision 1.373 / (download) - annotate - [select for diffs], Fri Jun 16 11:48:32 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.372: +7 -5 lines
Diff to previous 1.372 (colored) to selected 1.128 (colored)

indent: don't force a blank line between '}' and preprocessing line

Revision 1.372 / (download) - annotate - [select for diffs], Thu Jun 15 11:27:36 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.371: +2 -8 lines
Diff to previous 1.371 (colored) to selected 1.128 (colored)

indent: consolidate handling of statement continuations

Revision 1.371 / (download) - annotate - [select for diffs], Thu Jun 15 10:59:06 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.370: +6 -7 lines
Diff to previous 1.370 (colored) to selected 1.128 (colored)

indent: rename state variable to be more accurate

No binary change.

Revision 1.370 / (download) - annotate - [select for diffs], Thu Jun 15 10:34:12 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.369: +8 -2 lines
Diff to previous 1.369 (colored) to selected 1.128 (colored)

indent: fix indentation of multi-line enum constant initializers

Revision 1.369 / (download) - annotate - [select for diffs], Thu Jun 15 09:19:06 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.368: +23 -26 lines
Diff to previous 1.368 (colored) to selected 1.128 (colored)

indent: miscellaneous cleanups, more tests for edge cases

Revision 1.368 / (download) - annotate - [select for diffs], Thu Jun 15 08:40:20 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.367: +4 -3 lines
Diff to previous 1.367 (colored) to selected 1.128 (colored)

indent: fix alignment of multi-line declarations

Revision 1.367 / (download) - annotate - [select for diffs], Wed Jun 14 20:46:08 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.366: +45 -50 lines
Diff to previous 1.366 (colored) to selected 1.128 (colored)

indent: clean up the code, add a few tests

Revision 1.366 / (download) - annotate - [select for diffs], Wed Jun 14 19:05:40 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.365: +36 -17 lines
Diff to previous 1.365 (colored) to selected 1.128 (colored)

indent: allow more than 128 brace levels

Revision 1.365 / (download) - annotate - [select for diffs], Wed Jun 14 16:14:30 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.364: +10 -10 lines
Diff to previous 1.364 (colored) to selected 1.128 (colored)

indent: clean up array indexing for parser symbols

With 'top' pointing to the actual top element, the array was indexed in
the closed range from 0 to top. All other arrays are indexed by the
usual half-open interval from 0 to len.

No functional change.

Revision 1.364 / (download) - annotate - [select for diffs], Wed Jun 14 14:11:28 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.363: +69 -46 lines
Diff to previous 1.363 (colored) to selected 1.128 (colored)

indent: allow more than 20 nested parentheses or brackets

Revision 1.363 / (download) - annotate - [select for diffs], Wed Jun 14 13:15:30 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.362: +13 -15 lines
Diff to previous 1.362 (colored) to selected 1.128 (colored)

indent: merge duplicate code

Revision 1.362 / (download) - annotate - [select for diffs], Wed Jun 14 11:18:09 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.361: +4 -3 lines
Diff to previous 1.361 (colored) to selected 1.128 (colored)

indent: fix formatting of comment after 'switch (expr)'

Revision 1.361 / (download) - annotate - [select for diffs], Wed Jun 14 10:29:52 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.360: +3 -4 lines
Diff to previous 1.360 (colored) to selected 1.128 (colored)

indent: use correct preprocessing directive in error message

Revision 1.360 / (download) - annotate - [select for diffs], Wed Jun 14 10:26:00 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.359: +17 -12 lines
Diff to previous 1.359 (colored) to selected 1.128 (colored)

indent: allow more than 5 levels of #if/#endif

Revision 1.359 / (download) - annotate - [select for diffs], Wed Jun 14 08:36:51 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.358: +2 -3 lines
Diff to previous 1.358 (colored) to selected 1.128 (colored)

indent: remove another flag from parser state

When processing a comment, the flag ps.next_col_1 was not used for the
next token, but for a line within a comment.  As its scope was limited
to a single comment, there is no need to store it any longer than that

No functional change.

Revision 1.358 / (download) - annotate - [select for diffs], Wed Jun 14 07:20:55 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.357: +3 -3 lines
Diff to previous 1.357 (colored) to selected 1.128 (colored)

indent: merge parser symbols for stmt and stmt_list

They were handled in exactly the same way.

Revision 1.357 / (download) - annotate - [select for diffs], Sat Jun 10 21:36:38 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.356: +8 -8 lines
Diff to previous 1.356 (colored) to selected 1.128 (colored)

indent: rename misleading variable

The name started with 'line_start', but the value is not always the
value from the beginning of the line.

No functional change.

Revision 1.356 / (download) - annotate - [select for diffs], Sat Jun 10 20:37:12 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.355: +4 -4 lines
Diff to previous 1.355 (colored) to selected 1.128 (colored)

indent: fix debug output

When the parser state was first printed, there were unintended diff
markers.  Treat the previous lexer symbol like the other parts of the
parser state, as omitting it from the diff output is confusing.

Revision 1.355 / (download) - annotate - [select for diffs], Sat Jun 10 18:46:42 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.354: +14 -14 lines
Diff to previous 1.354 (colored) to selected 1.128 (colored)

indent: fix line break between semicolon and brace

Revision 1.354 / (download) - annotate - [select for diffs], Sat Jun 10 16:43:55 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.353: +41 -44 lines
Diff to previous 1.353 (colored) to selected 1.128 (colored)

indent: miscellaneous cleanups

Revision 1.353 / (download) - annotate - [select for diffs], Sat Jun 10 12:59:31 2023 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.352: +17 -4 lines
Diff to previous 1.352 (colored) to selected 1.128 (colored)

indent: in debug mode, null-terminate buffers

Revision 1.352 / (download) - annotate - [select for diffs], Sat Jun 10 08:17:04 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.351: +4 -19 lines
Diff to previous 1.351 (colored) to selected 1.128 (colored)

indent: fix indentation of continuation lines in initializers

Revision 1.351 / (download) - annotate - [select for diffs], Sat Jun 10 07:42:41 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.350: +14 -20 lines
Diff to previous 1.350 (colored) to selected 1.128 (colored)

indent: clean up function and variable names

Revision 1.350 / (download) - annotate - [select for diffs], Sat Jun 10 06:52:35 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.349: +5 -6 lines
Diff to previous 1.349 (colored) to selected 1.128 (colored)

indent: fix token classification in declarations

As a side effect, indent handles _Generic from C11 properly now, at
least in -nlp mode.

Revision 1.349 / (download) - annotate - [select for diffs], Sat Jun 10 06:38:21 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.348: +35 -35 lines
Diff to previous 1.348 (colored) to selected 1.128 (colored)

indent: rename and sort variables in parser state

No functional change.

Revision 1.348 / (download) - annotate - [select for diffs], Fri Jun 9 22:01:26 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.347: +3 -10 lines
Diff to previous 1.347 (colored) to selected 1.128 (colored)

indent: trim trailing blank lines

Revision 1.347 / (download) - annotate - [select for diffs], Fri Jun 9 16:23:43 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.346: +320 -320 lines
Diff to previous 1.346 (colored) to selected 1.128 (colored)

indent: group lexer symbols by topic, sort processing functions

No functional change.

Revision 1.346 / (download) - annotate - [select for diffs], Fri Jun 9 11:22:31 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.345: +4 -4 lines
Diff to previous 1.345 (colored) to selected 1.128 (colored)

indent: support C99 compound literals

Revision 1.345 / (download) - annotate - [select for diffs], Fri Jun 9 10:24:55 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.344: +5 -8 lines
Diff to previous 1.344 (colored) to selected 1.128 (colored)

indent: don't treat function call expressions as cast expressions

Revision 1.344 / (download) - annotate - [select for diffs], Fri Jun 9 08:16:06 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.343: +6 -10 lines
Diff to previous 1.343 (colored) to selected 1.128 (colored)

indent: eliminate unused variable

No functional change.

Revision 1.343 / (download) - annotate - [select for diffs], Fri Jun 9 08:10:58 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.342: +5 -10 lines
Diff to previous 1.342 (colored) to selected 1.128 (colored)

indent: when an indentation is ambiguous, indent one level further

The '-eei' mode now applies whenever the indentation from a multi-line
expression could be confused with a following statement.

Revision 1.342 / (download) - annotate - [select for diffs], Fri Jun 9 07:20:30 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.341: +6 -6 lines
Diff to previous 1.341 (colored) to selected 1.128 (colored)

indent: format its own code

Revision 1.341 / (download) - annotate - [select for diffs], Thu Jun 8 21:18:54 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.340: +2 -22 lines
Diff to previous 1.340 (colored) to selected 1.128 (colored)

indent: remove fragile heuristic for detecting cast expressions

The assumption that in an expression of the form '(a * anything)', the
'*' marks a pointer type was too simple-minded.

For now, fix the obvious cases and leave the others for later.  If
needed, they can be worked around using the '-T' option.

Revision 1.340 / (download) - annotate - [select for diffs], Thu Jun 8 20:55:22 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.339: +4 -3 lines
Diff to previous 1.339 (colored) to selected 1.128 (colored)

indent: fix indentation of initializer lists with designators

Revision 1.339 / (download) - annotate - [select for diffs], Thu Jun 8 06:47:13 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.338: +61 -191 lines
Diff to previous 1.338 (colored) to selected 1.128 (colored)

indent: clean up and condense code

No functional change.

Revision 1.338 / (download) - annotate - [select for diffs], Wed Jun 7 15:46:11 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.337: +13 -12 lines
Diff to previous 1.337 (colored) to selected 1.128 (colored)

indent: extract the stack of parser symbols to a separate struct

No functional change.

Revision 1.337 / (download) - annotate - [select for diffs], Tue Jun 6 04:37:26 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.336: +2 -3 lines
Diff to previous 1.336 (colored) to selected 1.128 (colored)

indent: compute indentation of 'case' labels on-demand

One less moving part to keep track of.

No functional change.

Revision 1.336 / (download) - annotate - [select for diffs], Mon Jun 5 20:56:18 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.335: +8 -3 lines
Diff to previous 1.335 (colored) to selected 1.128 (colored)

indent: in 'if (expr)', the parentheses do not form a cast expression

No functional change.  When stepping through the code in debug mode, it
was just too confusing that indent would log an 'unknown cast' in this
situation.

Revision 1.335 / (download) - annotate - [select for diffs], Mon Jun 5 12:05:01 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.334: +4 -4 lines
Diff to previous 1.334 (colored) to selected 1.128 (colored)

indent: format own source code

Revision 1.334 / (download) - annotate - [select for diffs], Mon Jun 5 12:01:33 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.333: +7 -2 lines
Diff to previous 1.333 (colored) to selected 1.128 (colored)

indent: don't remove blank line after 'if (expr) {'

Revision 1.333 / (download) - annotate - [select for diffs], Mon Jun 5 10:12:21 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.332: +5 -16 lines
Diff to previous 1.332 (colored) to selected 1.128 (colored)

indent: do not report broken lines, report configuration on stderr

Revision 1.332 / (download) - annotate - [select for diffs], Mon Jun 5 09:41:40 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.331: +3 -2 lines
Diff to previous 1.331 (colored) to selected 1.128 (colored)

indent: fix formatting of 'do' statements

Revision 1.331 / (download) - annotate - [select for diffs], Mon Jun 5 09:10:31 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.330: +16 -34 lines
Diff to previous 1.330 (colored) to selected 1.128 (colored)

indent: make heuristics for '*' pointer types simpler

Previously, a '}' token did not reset the state machine, but it should.

Revision 1.330 / (download) - annotate - [select for diffs], Mon Jun 5 08:22:00 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.329: +3 -5 lines
Diff to previous 1.329 (colored) to selected 1.128 (colored)

indent: fix trailing whitespace after comment

Revision 1.329 / (download) - annotate - [select for diffs], Mon Jun 5 07:35:05 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.328: +6 -8 lines
Diff to previous 1.328 (colored) to selected 1.128 (colored)

indent: rename variables, clean up comments

No binary change.

Revision 1.328 / (download) - annotate - [select for diffs], Mon Jun 5 07:23:03 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.327: +2 -5 lines
Diff to previous 1.327 (colored) to selected 1.128 (colored)

indent: clean up handling of whitespace

No functional change.

Revision 1.327 / (download) - annotate - [select for diffs], Sun Jun 4 20:51:19 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.326: +38 -39 lines
Diff to previous 1.326 (colored) to selected 1.128 (colored)

indent: remove read pointer from buffers that don't need it

The only buffer that needs a read pointer is the current input line in
'inp'.

No functional change.

Revision 1.326 / (download) - annotate - [select for diffs], Sun Jun 4 17:54:11 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.325: +14 -30 lines
Diff to previous 1.325 (colored) to selected 1.128 (colored)

indent: track the kind of '{' on the parser stack

Revision 1.325 / (download) - annotate - [select for diffs], Sun Jun 4 14:38:15 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.324: +5 -6 lines
Diff to previous 1.324 (colored) to selected 1.128 (colored)

indent: ensure that the 'block init level' never goes negative

No functional change.

Revision 1.324 / (download) - annotate - [select for diffs], Sun Jun 4 14:20:00 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.323: +19 -19 lines
Diff to previous 1.323 (colored) to selected 1.128 (colored)

indent: rename struct field, for better symmetry

No binary change outside debug mode.

Revision 1.323 / (download) - annotate - [select for diffs], Sun Jun 4 13:26:06 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.322: +11 -2 lines
Diff to previous 1.322 (colored) to selected 1.128 (colored)

indent: fix formatting of compound expressions, at least partially

Revision 1.322 / (download) - annotate - [select for diffs], Sun Jun 4 12:46:57 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.321: +4 -3 lines
Diff to previous 1.321 (colored) to selected 1.128 (colored)

lint: use separate lexer symbols for 'case' and 'default'

It's not strictly necessary since these tokens behave in the same way,
still, the code is more straight-forward when there are separate tokens.

Revision 1.321 / (download) - annotate - [select for diffs], Sun Jun 4 11:45:00 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.320: +4 -4 lines
Diff to previous 1.320 (colored) to selected 1.128 (colored)

indent: classify 'inline' as a modifier rather than a word

Revision 1.320 / (download) - annotate - [select for diffs], Sun Jun 4 11:33:36 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.319: +33 -25 lines
Diff to previous 1.319 (colored) to selected 1.128 (colored)

indent: use separate lexer symbols for the different kinds of ':'

Revision 1.319 / (download) - annotate - [select for diffs], Sun Jun 4 11:09:18 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.318: +4 -5 lines
Diff to previous 1.318 (colored) to selected 1.128 (colored)

indent: handle the indentation of 'case' in a simpler way

Revision 1.318 / (download) - annotate - [select for diffs], Sun Jun 4 10:23:36 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.317: +76 -33 lines
Diff to previous 1.317 (colored) to selected 1.128 (colored)

indent: separate code for handling parentheses and brackets

Handling parentheses is more complicated than for brackets.

Revision 1.317 / (download) - annotate - [select for diffs], Sat Jun 3 21:44:08 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.316: +4 -3 lines
Diff to previous 1.316 (colored) to selected 1.128 (colored)

indent: fix indentation of adjacent '{'

Revision 1.316 / (download) - annotate - [select for diffs], Sat Jun 3 21:24:26 2023 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.315: +4 -4 lines
Diff to previous 1.315 (colored) to selected 1.128 (colored)

indent: clean up handling of brace indentation

No functional change.

Revision 1.315 / (download) - annotate - [select for diffs], Fri Jun 2 15:07:46 2023 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.314: +7 -2 lines
Diff to previous 1.314 (colored) to selected 1.128 (colored)

indent: force each statement on a new line

Previously, '{} while (cond)' was kept on a single line, even though the
'while' was independent of the '{}'.

Revision 1.314 / (download) - annotate - [select for diffs], Fri Jun 2 14:34:14 2023 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.313: +6 -2 lines
Diff to previous 1.313 (colored) to selected 1.128 (colored)

indent: remove newline between 'switch' and '{'

Revision 1.313 / (download) - annotate - [select for diffs], Fri Jun 2 14:21:55 2023 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.312: +4 -4 lines
Diff to previous 1.312 (colored) to selected 1.128 (colored)

indent: improve heuristics of classifying '*' as pointer or operator

Revision 1.312 / (download) - annotate - [select for diffs], Fri Jun 2 13:59:33 2023 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.311: +9 -9 lines
Diff to previous 1.311 (colored) to selected 1.128 (colored)

indent: clean up

Only print the 'token' buffer in debug mode if it is interesting, group
the blocks in handling of '(' tokens by topic, remove obsolete comment
from test.

Revision 1.311 / (download) - annotate - [select for diffs], Fri Jun 2 11:43:07 2023 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.310: +8 -7 lines
Diff to previous 1.310 (colored) to selected 1.128 (colored)

indent: fix formatting of declarations with preprocessing lines

Revision 1.310 / (download) - annotate - [select for diffs], Tue May 23 18:16:28 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.309: +37 -5 lines
Diff to previous 1.309 (colored) to selected 1.128 (colored)

indent: separate code for handling enums from the lexer

The lexer's responsibility is to generate tokens, it's not supposed to
update the parser state.  Centralize the state transitions that control
indentation of enum constants to keep the lexer code clean.

Skip comments, newlines and preprocessing lines when updating the parser
state for enum constants and for '*' in declarations.

Revision 1.309 / (download) - annotate - [select for diffs], Tue May 23 16:53:57 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.308: +3 -2 lines
Diff to previous 1.308 (colored) to selected 1.128 (colored)

indent: fix indentation of struct declarations

Revision 1.308 / (download) - annotate - [select for diffs], Tue May 23 12:12:29 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.307: +11 -2 lines
Diff to previous 1.307 (colored) to selected 1.128 (colored)

indent: split debug output into paragraphs

The paragraphs separate the different processing steps: getting a token
from the lexer, processing the token, updating the parser state, sending
a finished line to the output.

Revision 1.307 / (download) - annotate - [select for diffs], Tue May 23 11:37:23 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.306: +128 -122 lines
Diff to previous 1.306 (colored) to selected 1.128 (colored)

indent: extract processing of a single token to separate function

No functional change.

Revision 1.306 / (download) - annotate - [select for diffs], Tue May 23 06:43:19 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.305: +4 -2 lines
Diff to previous 1.305 (colored) to selected 1.128 (colored)

indent: fix spacing around '*' in declarations

Revision 1.305 / (download) - annotate - [select for diffs], Tue May 23 06:35:01 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.304: +40 -2 lines
Diff to previous 1.304 (colored) to selected 1.128 (colored)

indent: fix spacing in declarations in for loops

Revision 1.304 / (download) - annotate - [select for diffs], Mon May 22 23:03:16 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.303: +4 -3 lines
Diff to previous 1.303 (colored) to selected 1.128 (colored)

indent: fix spacing between block braces

Revision 1.303 / (download) - annotate - [select for diffs], Mon May 22 10:28:59 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.302: +3 -2 lines
Diff to previous 1.302 (colored) to selected 1.128 (colored)

indent: implement suppressing optional blank lines

Revision 1.302 / (download) - annotate - [select for diffs], Sun May 21 10:05:20 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.301: +8 -8 lines
Diff to previous 1.301 (colored) to selected 1.128 (colored)

indent: don't read out-of-bounds memory in preprocessing lines

(Since a few minutes.)

If a line '#if 0' was followed by an unlikely line '#', the second line
was interpreted as '#if' as well.

To detect this bug automatically, a dynamic analysis tool would need to
know that only the memory between lab.mem and lab.mem + lab.len has
defined content.  This constraint, in turn, would throw up at the bottom
of copy_comment_wrap, which for a brief moment intentionally violates
this constraint.

Revision 1.301 / (download) - annotate - [select for diffs], Sun May 21 09:48:22 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.300: +12 -45 lines
Diff to previous 1.300 (colored) to selected 1.128 (colored)

indent: don't error out on unrecognized preprocessor directives

This allows indent to be used on the GCC preprocessor output.

Revision 1.300 / (download) - annotate - [select for diffs], Sat May 20 16:31:31 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.299: +3 -3 lines
Diff to previous 1.299 (colored) to selected 1.128 (colored)

indent: remove redundant checks in processing of '}'

No functional change.

Revision 1.299 / (download) - annotate - [select for diffs], Sat May 20 11:53:53 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.298: +5 -5 lines
Diff to previous 1.298 (colored) to selected 1.128 (colored)

indent: extract the output state from the parser state

The parser state depends on the preprocessing lines, the output state
shouldn't.

Revision 1.298 / (download) - annotate - [select for diffs], Sat May 20 10:46:21 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.297: +5 -2 lines
Diff to previous 1.297 (colored) to selected 1.128 (colored)

indent: implement blank line after function body

Revision 1.297 / (download) - annotate - [select for diffs], Sat May 20 10:09:02 2023 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.296: +4 -2 lines
Diff to previous 1.296 (colored) to selected 1.128 (colored)

indent: implement blank lines around conditional compilation

Revision 1.296 / (download) - annotate - [select for diffs], Sat May 20 02:47:35 2023 UTC (10 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.295: +2 -5 lines
Diff to previous 1.295 (colored) to selected 1.128 (colored)

indent: add debug logging for brace indentation

No functional change outside debug mode, as the initialization of
di_stack[0] was redundant.

Revision 1.295 / (download) - annotate - [select for diffs], Thu May 18 07:13:05 2023 UTC (10 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.294: +3 -13 lines
Diff to previous 1.294 (colored) to selected 1.128 (colored)

indent: remove detailed rules for blank before comment

Revision 1.294 / (download) - annotate - [select for diffs], Thu May 18 06:01:39 2023 UTC (10 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.293: +22 -21 lines
Diff to previous 1.293 (colored) to selected 1.128 (colored)

indent: rename a few functions

No functional change.

Revision 1.293 / (download) - annotate - [select for diffs], Thu May 18 05:33:27 2023 UTC (10 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.292: +24 -17 lines
Diff to previous 1.292 (colored) to selected 1.128 (colored)

indent: manually wrap overly long lines

No functional change.

Revision 1.292 / (download) - annotate - [select for diffs], Thu May 18 04:23:03 2023 UTC (10 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.291: +782 -781 lines
Diff to previous 1.291 (colored) to selected 1.128 (colored)

indent: switch to standard code style

Taken from share/misc/indent.pro.

Indent does not wrap code to fit into the line width, it only does so
for comments.  The 'INDENT OFF' sections and too long lines will be
addressed in a follow-up commit.

No functional change.

Revision 1.291 / (download) - annotate - [select for diffs], Thu May 18 03:38:34 2023 UTC (10 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.290: +3 -3 lines
Diff to previous 1.290 (colored) to selected 1.128 (colored)

indent: remove unnecessary variable size optimization

Due to the enum that follows in the struct, the short variable was
padded to 4 bytes anyway.

No functional change.

Revision 1.290 / (download) - annotate - [select for diffs], Tue May 16 13:26:26 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.289: +10 -10 lines
Diff to previous 1.289 (colored) to selected 1.128 (colored)

indent: directly access the input buffer

No functional change.

Revision 1.289 / (download) - annotate - [select for diffs], Tue May 16 11:32:01 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.288: +4 -16 lines
Diff to previous 1.288 (colored) to selected 1.128 (colored)

indent: remove support for form feed characters inside a line

Form feeds are occasionally used to split code into pages, and this use
is still supported.  Having a form feed in the middle of a line is
exotic.

Revision 1.288 / (download) - annotate - [select for diffs], Tue May 16 08:22:11 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.287: +17 -6 lines
Diff to previous 1.287 (colored) to selected 1.128 (colored)

indent: remove blank between comment and parentheses or brackets

Finally, indent formats its own source code without messing up the
layout.

Revision 1.287 / (download) - annotate - [select for diffs], Tue May 16 08:04:03 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.286: +9 -3 lines
Diff to previous 1.286 (colored) to selected 1.128 (colored)

indent: fix handling of INDENT OFF/ON comments

Previously, the 'INDENT OFF' comments were interpreted when the newline
token from the line above the comment was processed, which was earlier
than could be reasonably expected.

The 'INDENT ON' comments were interpreted equally early, which led to
the situation that the 'INDENT OFF' comments were preserved literally
but the 'INDENT ON' comments weren't.

Revision 1.286 / (download) - annotate - [select for diffs], Mon May 15 22:52:21 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.285: +9 -12 lines
Diff to previous 1.285 (colored) to selected 1.128 (colored)

indent: clean up detection of whether parentheses form a cast

No functional change.

Revision 1.285 / (download) - annotate - [select for diffs], Mon May 15 22:35:41 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.284: +20 -21 lines
Diff to previous 1.284 (colored) to selected 1.128 (colored)

indent: fix cast detection

In process_lparen_or_lbracket, ps.paren[...].maybe_cast was not
initialized, which may have been the cause for seemingly random spacing
around binary operators.

While here, clean up the code by reducing the number of accesses to the
parser state.

Revision 1.284 / (download) - annotate - [select for diffs], Mon May 15 21:51:45 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.283: +3 -2 lines
Diff to previous 1.283 (colored) to selected 1.128 (colored)

indent: fix detection of casts

A word followed by a '(' does not start a cast expression.

Revision 1.283 / (download) - annotate - [select for diffs], Mon May 15 20:50:37 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.282: +4 -3 lines
Diff to previous 1.282 (colored) to selected 1.128 (colored)

indent: fix type cast in function definition

Revision 1.282 / (download) - annotate - [select for diffs], Mon May 15 20:30:20 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.281: +3 -3 lines
Diff to previous 1.281 (colored) to selected 1.128 (colored)

indent: fix duplicate space between comment and binary operator

Revision 1.281 / (download) - annotate - [select for diffs], Mon May 15 20:12:28 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.280: +7 -6 lines
Diff to previous 1.280 (colored) to selected 1.128 (colored)

indent: format its own code, extend some comments

With manual corrections, as there are still some bugs left.

No functional change.

Revision 1.280 / (download) - annotate - [select for diffs], Mon May 15 18:22:40 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.279: +16 -3 lines
Diff to previous 1.279 (colored) to selected 1.128 (colored)

indent: improve type guessing, fix formatting of declarations

Revision 1.279 / (download) - annotate - [select for diffs], Mon May 15 14:55:47 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.278: +5 -2 lines
Diff to previous 1.278 (colored) to selected 1.128 (colored)

indent: fix spacing between function prototype and attributes

Revision 1.278 / (download) - annotate - [select for diffs], Mon May 15 14:12:03 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.277: +5 -2 lines
Diff to previous 1.277 (colored) to selected 1.128 (colored)

indent: fix indentation of struct member names

Revision 1.277 / (download) - annotate - [select for diffs], Mon May 15 13:37:16 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.276: +12 -12 lines
Diff to previous 1.276 (colored) to selected 1.128 (colored)

indent: indent multi-line conditions

No functional change.

Revision 1.276 / (download) - annotate - [select for diffs], Mon May 15 13:33:19 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.275: +5 -4 lines
Diff to previous 1.275 (colored) to selected 1.128 (colored)

indent: fix indentation of statements after controlling expression

Revision 1.275 / (download) - annotate - [select for diffs], Mon May 15 12:59:43 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.274: +8 -2 lines
Diff to previous 1.274 (colored) to selected 1.128 (colored)

indent: fix indentation of expressions in -nlp -eei mode

Revision 1.274 / (download) - annotate - [select for diffs], Mon May 15 10:13:40 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.273: +12 -2 lines
Diff to previous 1.273 (colored) to selected 1.128 (colored)

indent: fix indentation of multi-line '?:' expressions in functions

Revision 1.273 / (download) - annotate - [select for diffs], Mon May 15 09:22:53 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.272: +6 -6 lines
Diff to previous 1.272 (colored) to selected 1.128 (colored)

indent: let indent format its own code

With manual corrections, as indent does not properly indent multi-line
'?:' expressions nor multi-line controlling expressions.

Revision 1.272 / (download) - annotate - [select for diffs], Mon May 15 08:56:39 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.271: +3 -2 lines
Diff to previous 1.271 (colored) to selected 1.128 (colored)

indent: fix spacing in for loop with declaration (since 2022-02-13)

Revision 1.271 / (download) - annotate - [select for diffs], Mon May 15 08:11:27 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.270: +2 -3 lines
Diff to previous 1.270 (colored) to selected 1.128 (colored)

indent: remove redundant include lines

Revision 1.270 / (download) - annotate - [select for diffs], Mon May 15 08:02:01 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.269: +4 -16 lines
Diff to previous 1.269 (colored) to selected 1.128 (colored)

indent: clean up memory allocation

No functional change.

Revision 1.269 / (download) - annotate - [select for diffs], Mon May 15 07:57:22 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.268: +2 -48 lines
Diff to previous 1.268 (colored) to selected 1.128 (colored)

indent: move debugging code to separate file

No functional change.

Revision 1.268 / (download) - annotate - [select for diffs], Mon May 15 07:28:45 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.267: +81 -130 lines
Diff to previous 1.267 (colored) to selected 1.128 (colored)

indent: clean up memory and buffer management

Remove the need to explicitly initialize the buffers.  To avoid
subtracting null pointers or comparing them using '<', migrate the
buffers from the (start, end) form to the (start, len) form.  This form
also avoids inconsistencies in whether 'buf.e == buf.s' or 'buf.s ==
buf.e' is used.

Make buffer.st const, to avoid accidental modification of the buffer's
content.

Replace '*buf.e++ = ch' with buf_add_char, to avoid having to keep track
how much unwritten space is left in the buffer.  Remove all safety
margins, that is, no more unchecked access to buf.st[-1] or appending
using '*buf.e++'.

Fix line number counting in lex_word for words that contain line breaks.

No functional change.

Revision 1.267 / (download) - annotate - [select for diffs], Sun May 14 22:26:37 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.266: +5 -20 lines
Diff to previous 1.266 (colored) to selected 1.128 (colored)

indent: only null-terminate the buffers if necessary

The only case where a buffer is used as a C-style string is when looking
up a keyword.

No functional change.

Revision 1.266 / (download) - annotate - [select for diffs], Sun May 14 12:12:02 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.265: +2 -10 lines
Diff to previous 1.265 (colored) to selected 1.128 (colored)

indent: remove foreign RCS IDs

Revision 1.265 / (download) - annotate - [select for diffs], Sun May 14 11:29:23 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.264: +26 -29 lines
Diff to previous 1.264 (colored) to selected 1.128 (colored)

indent: miscellaneous cleanups

Revision 1.264 / (download) - annotate - [select for diffs], Sat May 13 17:54:34 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.263: +8 -4 lines
Diff to previous 1.263 (colored) to selected 1.128 (colored)

indent: prevent undefined behavior on unbalanced parentheses

Revision 1.263 / (download) - annotate - [select for diffs], Sat May 13 17:20:41 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.262: +8 -17 lines
Diff to previous 1.262 (colored) to selected 1.128 (colored)

indent: do not add a blank at the beginning of a line

Most calls to output_line did already reset the variable.  There may be
some untested edge cases in or after comments, but these should be fine
as well.

Revision 1.262 / (download) - annotate - [select for diffs], Sat May 13 16:40:18 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.261: +4 -3 lines
Diff to previous 1.261 (colored) to selected 1.128 (colored)

indent: do not add a space before a comment that starts a line

Revision 1.261 / (download) - annotate - [select for diffs], Sat May 13 16:19:37 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.260: +8 -10 lines
Diff to previous 1.260 (colored) to selected 1.128 (colored)

indent: replace __dead functions with return statements

No functional change.

Revision 1.260 / (download) - annotate - [select for diffs], Sat May 13 14:30:48 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.259: +7 -7 lines
Diff to previous 1.259 (colored) to selected 1.128 (colored)

indent: use enum instead of magic numbers for tracking declarations

No functional change.

Revision 1.259 / (download) - annotate - [select for diffs], Sat May 13 12:31:02 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.258: +12 -12 lines
Diff to previous 1.258 (colored) to selected 1.128 (colored)

indent: rename struct fields for buffers

No binary change except for assertion line numbers.

Revision 1.258 / (download) - annotate - [select for diffs], Sat May 13 09:40:47 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.257: +4 -5 lines
Diff to previous 1.257 (colored) to selected 1.128 (colored)

indent: clean up a condition, add comments

No functional change.

Revision 1.257 / (download) - annotate - [select for diffs], Sat May 13 08:33:39 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.256: +43 -14 lines
Diff to previous 1.256 (colored) to selected 1.128 (colored)

indent: preserve indentation of preprocessor directives

Revision 1.256 / (download) - annotate - [select for diffs], Fri May 12 22:38:47 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.255: +15 -15 lines
Diff to previous 1.255 (colored) to selected 1.128 (colored)

indent: rename placeholder symbol for parser stack

No functional change outside debug mode.

Revision 1.255 / (download) - annotate - [select for diffs], Fri May 12 15:36:02 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.254: +2 -7 lines
Diff to previous 1.254 (colored) to selected 1.128 (colored)

indent: remove code for parsing declarations without semicolon

The statement from the comment that declarations do not need semicolons
is wrong. A possible input that matched this rule is 'void f(void) { int
a }'.

Revision 1.254 / (download) - annotate - [select for diffs], Fri May 12 10:53:33 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.253: +2 -9 lines
Diff to previous 1.253 (colored) to selected 1.128 (colored)

indent: remove statistics

The numbers from the statistics were wrong.

Revision 1.253 / (download) - annotate - [select for diffs], Fri May 12 08:40:54 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.252: +24 -30 lines
Diff to previous 1.252 (colored) to selected 1.128 (colored)

indent: condense code for handling spaced expressions

No functional change outside debug mode.

Revision 1.252 / (download) - annotate - [select for diffs], Thu May 11 19:01:35 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.251: +2 -15 lines
Diff to previous 1.251 (colored) to selected 1.128 (colored)

indent: don't touch comments in preprocessing lines

The indentation of multi-line comments was wrong, and the code for
handling them was too complicated.

Revision 1.251 / (download) - annotate - [select for diffs], Thu May 11 18:13:55 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.250: +2 -23 lines
Diff to previous 1.250 (colored) to selected 1.128 (colored)

indent: remove broken code for handling blank lines

This fixes several bugs where blank lines were erroneously added or
removed, treating these old bugs for new bugs in different places.
These new bugs are expected to be easier to fix, as the old bugs will
not interfere anymore.

Revision 1.250 / (download) - annotate - [select for diffs], Thu May 11 11:25:47 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.249: +72 -91 lines
Diff to previous 1.249 (colored) to selected 1.128 (colored)

indent: move parser state variables to the parser_state struct

Include the variables in the debug output.

Revision 1.249 / (download) - annotate - [select for diffs], Thu May 11 10:54:14 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.248: +3 -6 lines
Diff to previous 1.248 (colored) to selected 1.128 (colored)

indent: eliminate a local variable for else-if handling

No functional change intended.

Revision 1.248 / (download) - annotate - [select for diffs], Thu May 11 10:51:33 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.247: +32 -36 lines
Diff to previous 1.247 (colored) to selected 1.128 (colored)

indent: move force_nl into the parser state

This way, it is included in the debug output.

No functional change.

Revision 1.247 / (download) - annotate - [select for diffs], Thu May 11 10:39:25 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.246: +8 -9 lines
Diff to previous 1.246 (colored) to selected 1.128 (colored)

indent: remove unnecessary assignments to last_else

No functional change intended.

Revision 1.246 / (download) - annotate - [select for diffs], Thu May 11 09:28:53 2023 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.245: +5 -199 lines
Diff to previous 1.245 (colored) to selected 1.128 (colored)

indent: remove buggy code for swapping tokens

It is not the job of an indenter to swap tokens, even if it's only about
placing comments elsewhere.  The code that swapped the tokens was
complicated, buggy and impossible to understand.

In -br (brace right) mode, indent no longer moves a '{' from the
beginning of a line to the end of the previous line, as that was handled
by the token swapping code as well.  This change is unintended, but it
will be easier to re-add that now that the code is simpler.

Revision 1.245 / (download) - annotate - [select for diffs], Mon May 9 21:41:49 2022 UTC (23 months, 1 week ago) by rillig
Branch: MAIN
CVS Tags: netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10
Changes since 1.244: +2 -5 lines
Diff to previous 1.244 (colored) to selected 1.128 (colored)

indent: clean up control flow, remove Capsicum

No functional change.

Revision 1.244 / (download) - annotate - [select for diffs], Sat Apr 23 06:43:22 2022 UTC (23 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.243: +13 -15 lines
Diff to previous 1.243 (colored) to selected 1.128 (colored)

indent: group global variables related to output control

No functional change.

Revision 1.243 / (download) - annotate - [select for diffs], Sat Apr 23 06:32:20 2022 UTC (23 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.242: +2 -23 lines
Diff to previous 1.242 (colored) to selected 1.128 (colored)

indent: remove Capsicum support

NetBSD doesn't have Capsicum.

Revision 1.242 / (download) - annotate - [select for diffs], Sun Feb 13 12:43:26 2022 UTC (2 years, 2 months ago) by rillig
Branch: MAIN
Changes since 1.241: +32 -32 lines
Diff to previous 1.241 (colored) to selected 1.128 (colored)

indent: rename parser_state.p_l_follow and paren_level

The previous variable names were misleading.

Paren_level is not the current level of parentheses but the one from the
beginning of the current output line.  For better accuracy, rename it to
line_start_paren_level.

P_l_follow is not the level of parentheses that will be active at some
point in the future, as the previous name suggested.  Instead, it is the
level of parentheses right now.  For better accuracy, rename it to
nparen.  This nicely matches its main usage, which is as index to the
parser_state.paren array.

No binary change.

Revision 1.241 / (download) - annotate - [select for diffs], Sun Feb 13 12:20:09 2022 UTC (2 years, 2 months ago) by rillig
Branch: MAIN
Changes since 1.240: +14 -15 lines
Diff to previous 1.240 (colored) to selected 1.128 (colored)

indent: replace bitmasking code with struct

The struct directly represents the properties of a pair of parentheses,
without forcing the human reader to decode any bitset.  This makes it
easier to find the remaining bugs in the heuristic for determining the
kind of parentheses.

No functional change outside debug mode.

Revision 1.240 / (download) - annotate - [select for diffs], Sun Feb 13 12:09:19 2022 UTC (2 years, 2 months ago) by rillig
Branch: MAIN
Changes since 1.239: +8 -8 lines
Diff to previous 1.239 (colored) to selected 1.128 (colored)

indent: change parser_state.cast_mask to 0-based indexing

Having 1-based indexing was completely unexpected, and it didn't match
the 0-based indexing of parser_state.paren_indents.

No functional change.

Revision 1.239 / (download) - annotate - [select for diffs], Sun Nov 28 14:29:03 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.238: +2 -13 lines
Diff to previous 1.238 (colored) to selected 1.128 (colored)

indent: treat L"string" as a single token

There is never whitespace between the 'L' and the string literal or the
character constant. There might be a backslash-newline between them, but
that case was not handled before either.

No functional change.

Revision 1.238 / (download) - annotate - [select for diffs], Sun Nov 28 11:49:10 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.237: +3 -3 lines
Diff to previous 1.237 (colored) to selected 1.128 (colored)

indent: clean up and document input handling

The transformation of moving comments from after an 'if (expr)' after
the following brace has a large implementation cost (about 300 lines of
code) and makes input handling quite complicated. Document the overall
idea to save future readers some time.

No functional change.

Revision 1.237 / (download) - annotate - [select for diffs], Sat Nov 27 21:15:58 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.236: +4 -4 lines
Diff to previous 1.236 (colored) to selected 1.128 (colored)

indent: accept a few formatting suggestions from indent

The remaining issues are still that the conditions look ambiguous even
with -eei, and that __attribute__ is broken into a separate line.

No functional change.

Revision 1.236 / (download) - annotate - [select for diffs], Sat Nov 27 18:37:17 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.235: +14 -14 lines
Diff to previous 1.235 (colored) to selected 1.128 (colored)

indent: rename dump functions to output

No functional change.

Revision 1.235 / (download) - annotate - [select for diffs], Sat Nov 27 18:29:29 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.234: +9 -15 lines
Diff to previous 1.234 (colored) to selected 1.128 (colored)

indent: inline switch_buffer

The function name was not accurate all the time. Now that
inp_from_comment is a separate function, it doesn't make sense anymore
to offload the 3 simple statements to a separate function.

No functional change.

Revision 1.234 / (download) - annotate - [select for diffs], Fri Nov 26 15:18:18 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.233: +17 -11 lines
Diff to previous 1.233 (colored) to selected 1.128 (colored)

indent: add buf_add_range for adding characters to a buffer

No functional change.

Revision 1.233 / (download) - annotate - [select for diffs], Fri Nov 26 14:17:01 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.232: +22 -2 lines
Diff to previous 1.232 (colored) to selected 1.128 (colored)

indent: move ind_add from io.c to indent.c

It's a general-purpose function that is not directly related to input or
output.

Revision 1.232 / (download) - annotate - [select for diffs], Thu Nov 25 18:48:37 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.231: +9 -9 lines
Diff to previous 1.231 (colored) to selected 1.128 (colored)

indent: rename ps.in_function_parameters to match reality

This flag is only set while parsing the parameters of a function
definition, but not for a function declaration. See buffer_add in the
test fmt_decl.

No functional change.

Revision 1.231 / (download) - annotate - [select for diffs], Thu Nov 25 07:45:32 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.230: +13 -12 lines
Diff to previous 1.230 (colored) to selected 1.128 (colored)

indent: rename ps.in_stmt to in_stmt_or_decl

The previous name didn't match reality.

No functional change.

Revision 1.230 / (download) - annotate - [select for diffs], Thu Nov 25 07:41:13 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.229: +5 -5 lines
Diff to previous 1.229 (colored) to selected 1.128 (colored)

indent: rename ps.ind_stmt to in_stmt_cont

This makes a comment redundant.

No functional change.

Revision 1.229 / (download) - annotate - [select for diffs], Thu Nov 25 07:30:54 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.228: +5 -4 lines
Diff to previous 1.228 (colored) to selected 1.128 (colored)

indent: clean up style

No functional change.

Revision 1.228 / (download) - annotate - [select for diffs], Fri Nov 19 20:23:17 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.227: +3 -4 lines
Diff to previous 1.227 (colored) to selected 1.128 (colored)

indent: reduce casts to unsigned char for character classification

No functional change.

Revision 1.227 / (download) - annotate - [select for diffs], Fri Nov 19 20:04:02 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.226: +3 -2 lines
Diff to previous 1.226 (colored) to selected 1.128 (colored)

indent: fix included headers

Revision 1.226 / (download) - annotate - [select for diffs], Fri Nov 19 19:55:15 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.225: +5 -5 lines
Diff to previous 1.225 (colored) to selected 1.128 (colored)

indent: replace ps.procname with ps.is_function_definition

Omly the first character of ps.procname was ever read, and it was only
compared to '\0'.  Using a bool for this means simpler code, less
memory and fewer wasted CPU cycles due to the removed strncpy.

No functional change.

Revision 1.225 / (download) - annotate - [select for diffs], Fri Nov 19 18:14:18 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.224: +13 -35 lines
Diff to previous 1.224 (colored) to selected 1.128 (colored)

indent: remove all references to inbuf from indent.c

No functional change.

Revision 1.224 / (download) - annotate - [select for diffs], Fri Nov 19 17:59:16 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.223: +7 -36 lines
Diff to previous 1.223 (colored) to selected 1.128 (colored)

indent: move character input handling from indent.c to io.c

No functional change.

Revision 1.223 / (download) - annotate - [select for diffs], Fri Nov 19 17:42:45 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.222: +25 -82 lines
Diff to previous 1.222 (colored) to selected 1.128 (colored)

indent: move character input from indent.c to io.c

No functional change.

Revision 1.222 / (download) - annotate - [select for diffs], Fri Nov 19 17:11:46 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.221: +11 -11 lines
Diff to previous 1.221 (colored) to selected 1.128 (colored)

indent: replace direct access to the input buffer

This is a preparation for abstracting away all the low-level details of
handling the input.  The goal is to fix the current bugs regarding line
number counting, out of bounds memory access, and generally unreadable
code.

No functional change.

Revision 1.221 / (download) - annotate - [select for diffs], Fri Nov 19 15:34:25 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.220: +23 -16 lines
Diff to previous 1.220 (colored) to selected 1.128 (colored)

indent: add debug logging for input buffer handling

Revision 1.220 / (download) - annotate - [select for diffs], Fri Nov 19 15:32:13 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.219: +59 -58 lines
Diff to previous 1.219 (colored) to selected 1.128 (colored)

indent: rename input buffer variables

From reading the names 'save_com' and 'sc_end', it was not obvious
enough that these two variables are the limits of the same buffer, the
names were just too unrelated.

No functional change.

Revision 1.219 / (download) - annotate - [select for diffs], Fri Nov 19 15:28:32 2021 UTC (2 years, 4 months ago) by rillig
Branch: MAIN
Changes since 1.218: +61 -68 lines
Diff to previous 1.218 (colored) to selected 1.128 (colored)

indent: group variables for input handling

No functional change.

Revision 1.218 / (download) - annotate - [select for diffs], Sun Nov 7 19:18:56 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.217: +10 -11 lines
Diff to previous 1.217 (colored) to selected 1.128 (colored)

indent: fix handling of C99 comments after 'if (expr)'

Revision 1.217 / (download) - annotate - [select for diffs], Sun Nov 7 18:49:02 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.216: +3 -2 lines
Diff to previous 1.216 (colored) to selected 1.128 (colored)

indent: demonstrate disappearing form feed

Revision 1.216 / (download) - annotate - [select for diffs], Sun Nov 7 18:26:17 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.215: +8 -8 lines
Diff to previous 1.215 (colored) to selected 1.128 (colored)

indent: various cleanups

Make several comments more precise.

Rename process_end_of_file to process_eof to match the token name.

Change the order of assignments in analyze_comment to keep the com_ind
computations closer together.

In copy_comment_wrap, use pointer difference instead of pointer addition
to stay away from undefined behavior.

No functional change.

Revision 1.215 / (download) - annotate - [select for diffs], Sun Nov 7 15:18:25 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.214: +15 -15 lines
Diff to previous 1.214 (colored) to selected 1.128 (colored)

indent: rename ps.decl_nest to decl_level

This better matches the comment.

No functional change.

Revision 1.214 / (download) - annotate - [select for diffs], Sun Nov 7 14:00:35 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.213: +4 -4 lines
Diff to previous 1.213 (colored) to selected 1.128 (colored)

indent: reduce negations in process_else, clean up comments

No functional change.

Revision 1.213 / (download) - annotate - [select for diffs], Sun Nov 7 13:30:15 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.212: +5 -5 lines
Diff to previous 1.212 (colored) to selected 1.128 (colored)

indent: only access buffer data in the range [buf.s, buf.e)

No functional change.

Revision 1.212 / (download) - annotate - [select for diffs], Sun Nov 7 07:44:59 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.211: +3 -3 lines
Diff to previous 1.211 (colored) to selected 1.128 (colored)

indent: rename type_at_paren_level_0 to type_outside_parentheses

For symmetry with type_in_parentheses.

No functional change.

Revision 1.211 / (download) - annotate - [select for diffs], Sun Nov 7 07:35:06 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.210: +6 -5 lines
Diff to previous 1.210 (colored) to selected 1.128 (colored)

indent: distinguish between typename in parentheses and other words

This gets rid of two members of parser_state. No functional change for
well-formed programs. The sequence of '++int' or '--size_t' may be
formatted differently than before, but no program is expected to contain
that sequence.

Rename lsym_ident to lsym_word since 'ident' was too specific. This
token type is used for constants and string literals as well. Strictly
speaking, a string literal is not a word, but at least it's better than
before.

Revision 1.210 / (download) - annotate - [select for diffs], Sun Nov 7 07:06:00 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.209: +10 -10 lines
Diff to previous 1.209 (colored) to selected 1.128 (colored)

indent: rename 'inbuf' functions to 'inp'

The variable 'inp' used to be named 'inbuf'. Make the function names
correspond to the variable name again.

No functional change.

Revision 1.209 / (download) - annotate - [select for diffs], Fri Nov 5 19:42:48 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.208: +6 -6 lines
Diff to previous 1.208 (colored) to selected 1.128 (colored)

indent: rename process_keyword_do to process_do, same for 'else'

Before the symbols from the tokenizer had the prefix 'lsym', the symbols
could not be simply called 'else' and 'do'. The functions for processing
the tokens followed that naming scheme.

When the prefix 'lsym' was introduced, the word 'keyword' was no longer
needed, neither in the constants nor in the function names.

No functional change.

Revision 1.208 / (download) - annotate - [select for diffs], Fri Nov 5 19:33:28 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.207: +3 -3 lines
Diff to previous 1.207 (colored) to selected 1.128 (colored)

indent: rename ps.curr_newline to next_col_1

For symmetry with ps.curr_col_1.

No functional change.

Revision 1.207 / (download) - annotate - [select for diffs], Thu Nov 4 20:31:04 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.206: +31 -26 lines
Diff to previous 1.206 (colored) to selected 1.128 (colored)

indent: split process_comment_in_code into separate functions

No functional change.

Revision 1.206 / (download) - annotate - [select for diffs], Thu Nov 4 17:12:12 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.205: +13 -3 lines
Diff to previous 1.205 (colored) to selected 1.128 (colored)

indent: fix joining of adjacent unary '+' operators

Revision 1.205 / (download) - annotate - [select for diffs], Wed Nov 3 21:47:35 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.204: +4 -5 lines
Diff to previous 1.204 (colored) to selected 1.128 (colored)

indent: inline indentation_after, shorten function name to ind_add

There were only few calls to indentation_after, so inlining it spares
the need to look at yet another function definition. Another effect is
that code.s and code.e appear in the code as a pair now, instead of a
single code.s, making the scope of the function call obvious.

In ind_add, there is no need to check for '\0' anymore since none of the
buffers can ever contain a null character, these are filtered out by
inbuf_read_line.

No functional change.

Revision 1.204 / (download) - annotate - [select for diffs], Mon Nov 1 23:44:08 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.203: +3 -2 lines
Diff to previous 1.203 (colored) to selected 1.128 (colored)

indent: fix missing blank after 'return' (since 2021-10-31)

In indent.c 1.200 from 2021-10-31, the subtypes of identifier tokens
were removed since they were redundant. An unintended side effect was
that a parenthesized expression after 'return' was no longer separated
by a blank.

Before that change, 'return' was tokenized as an lsym_ident with subtype
kw_other, and want_space_before_lparen handled this case in the last
line. After the change, 'return' was treated as an ordinary identifier,
and unless the option '-pcs' (blank after function call) was given, the
blank was removed.

The other keywords that had kw_other are not affected since they do not
expect a '(' afterwards. These keywords are 'break', 'continue', 'goto',
'inline' and 'restrict'.

Curiously, there was not a single test case that covered 'return(expr)'.

While here, remove the trailing ',' from the enum lexer_symbol, which is
not allowed in standard C, it is a GNU extension. Lint doesn't complain
about this since the default LINTFLAGS include '-g' for GCC mode.

Revision 1.203 / (download) - annotate - [select for diffs], Sun Oct 31 22:38:12 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.202: +3 -3 lines
Diff to previous 1.202 (colored) to selected 1.128 (colored)

indent: clean up

Initialize buffers in reading order, make comments more expressive,
rename add_typename to register_typename, remove unused macro.

No functional change.

Revision 1.202 / (download) - annotate - [select for diffs], Sun Oct 31 21:43:43 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.201: +9 -9 lines
Diff to previous 1.201 (colored) to selected 1.128 (colored)

indent: for '-pcs', add blank between function and '('

Before indent-2021.09.30.21.48.12, the blank had always been added, even
in '-npcs' mode. Since then, the blank had never been added.

Now, add the blank in '-pcs' mode and omit it in '-npcs' mode.

Revision 1.201 / (download) - annotate - [select for diffs], Sun Oct 31 20:40:42 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.200: +3 -3 lines
Diff to previous 1.200 (colored) to selected 1.128 (colored)

indent: replace kw_tag with lsym_tag

This leaves only one special type of token, which is lsym_ident, which
in some cases represents a type name and in other cases an identifier,
constant or string literal.

No functional change.

Revision 1.200 / (download) - annotate - [select for diffs], Sun Oct 31 19:57:44 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.199: +3 -3 lines
Diff to previous 1.199 (colored) to selected 1.128 (colored)

indent: replace simple cases of keyword_kind with lexer_symbol

The remaining keyword kinds 'tag' and 'type' require a bit more thought,
so do them in a separate step.

No functional change.

Revision 1.199 / (download) - annotate - [select for diffs], Sun Oct 31 19:20:52 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.198: +3 -3 lines
Diff to previous 1.198 (colored) to selected 1.128 (colored)

indent: rename lsym_type to better reflect reality

Type names that occur in parentheses are parsed as lsym_ident having the
subtype kw_type instead.

No functional change.

Revision 1.198 / (download) - annotate - [select for diffs], Sun Oct 31 10:09:43 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.197: +6 -5 lines
Diff to previous 1.197 (colored) to selected 1.128 (colored)

indent: add separate lexer symbol for offsetof

No functional change.

Revision 1.197 / (download) - annotate - [select for diffs], Sun Oct 31 10:00:37 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.196: +6 -3 lines
Diff to previous 1.196 (colored) to selected 1.128 (colored)

indent: add separate lexer symbol for sizeof

The plan is to get rid of the type keyword_kind, which largely overlaps
with lexer_symbol.

No functional change.

Revision 1.196 / (download) - annotate - [select for diffs], Sat Oct 30 23:27:33 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.195: +13 -17 lines
Diff to previous 1.195 (colored) to selected 1.128 (colored)

indent: push down variable comment_buffered

No functional change.

Revision 1.195 / (download) - annotate - [select for diffs], Sat Oct 30 22:36:07 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.194: +4 -4 lines
Diff to previous 1.194 (colored) to selected 1.128 (colored)

indent: rename prev_newline and prev_col_1 to curr

These two flags describe the token that is currently processed.

In process_binary_op, curr_newline can never be true since newline is
not a binary operator, so remove that condition.

No functional change.

Revision 1.194 / (download) - annotate - [select for diffs], Sat Oct 30 20:01:46 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.193: +8 -7 lines
Diff to previous 1.193 (colored) to selected 1.128 (colored)

indent: reorder assignments in switch_buffer

No functional change.

Revision 1.193 / (download) - annotate - [select for diffs], Sat Oct 30 18:58:04 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.192: +68 -68 lines
Diff to previous 1.192 (colored) to selected 1.128 (colored)

indent: move buffer functions further up

No functional change.

Revision 1.192 / (download) - annotate - [select for diffs], Sat Oct 30 18:47:36 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.191: +6 -5 lines
Diff to previous 1.191 (colored) to selected 1.128 (colored)

indent: group variables by topic

No functional change.

Revision 1.191 / (download) - annotate - [select for diffs], Sat Oct 30 17:55:44 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.190: +6 -4 lines
Diff to previous 1.190 (colored) to selected 1.128 (colored)

indent: prevent buffer overflow in search_stmt_comment

printf '{ if (%010000d) /*comment*/ ; }' '0' | indent

Revision 1.190 / (download) - annotate - [select for diffs], Sat Oct 30 17:18:25 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.189: +27 -2 lines
Diff to previous 1.189 (colored) to selected 1.128 (colored)

indent: add debug logging for save_com

This will help in finding the proper fix for the assertion failure in
search_stmt_comment.

Add an assertion in search_stmt_lbrace to prevent the previous,
incomplete fix from being applied again.

Revision 1.189 / (download) - annotate - [select for diffs], Sat Oct 30 16:18:51 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.188: +48 -37 lines
Diff to previous 1.188 (colored) to selected 1.128 (colored)

indent: prevent buffer overflows in 'if (expr) ... stmt'

Revision 1.188 / (download) - annotate - [select for diffs], Sat Oct 30 15:26:58 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.187: +13 -6 lines
Diff to previous 1.187 (colored) to selected 1.128 (colored)

indent: revert previous fix of assertion failure

The strange code with the out of bounds memory access is needed to
transform 'if (expr) /* comment */ {' to 'if (expr) { /* comment */',
that is, to move the comment to the right.

Add a test that prevents "repairing" this code again.

Revision 1.187 / (download) - annotate - [select for diffs], Sat Oct 30 13:30:26 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.186: +6 -13 lines
Diff to previous 1.186 (colored) to selected 1.128 (colored)

indent: fix assertion failure in search_stmt_comment

I have no idea why the code was written in such a convoluted way before.
By removing all the code that didn't make sense, everything just works
as expected, and the existing tests all pass, especially those in
token_comment.c that mention search_stmt_comment.

Revision 1.186 / (download) - annotate - [select for diffs], Sat Oct 30 11:37:38 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.185: +5 -3 lines
Diff to previous 1.185 (colored) to selected 1.128 (colored)

indent: replace tabsize with hardcoded 8 in process_comma

On 2018-07-25, FreeBSD added the option '-ts' to make the tabulator size
configurable, replacing several constants 7, 8, 9 with tabsize. The 8 in
the expression 'max_col - 8' was not related to the tabulator size but
instead represents the typical width of a variable name. Subtracting a
tab from the right margin doesn't make sense since the right margin need
not be aligned on a tabstop.

See the test fmt_decl.c, where the declaration 'struct s0 a,b;' is split
into several lines because the estimate for the variable name following
the comma is too high. There would have been plenty of space to the
right to keep the whole declaration in a single line.

No functional change.

Revision 1.185 / (download) - annotate - [select for diffs], Sat Oct 30 11:10:36 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.184: +3 -3 lines
Diff to previous 1.184 (colored) to selected 1.128 (colored)

indent: don't risk a buffer overflow in code_add_decl_indent

The buffers have a safety margin of 5 characters, so the bounds check is
not strictly necessary. It makes the code more uniform though.

No functional change.

Revision 1.184 / (download) - annotate - [select for diffs], Sat Oct 30 11:05:26 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.183: +9 -17 lines
Diff to previous 1.183 (colored) to selected 1.128 (colored)

indent: clean up code_add_decl_indent

In layout computations, it is helpful for human readers to list the
summands in logical order. In this case, the expression 'code_len +
base_ind' was rather confusing, so replace it with 'base_ind +
code_len'. This makes the code straight-forward enough that it doesn't
need any comments anymore.

No functional change.

Revision 1.183 / (download) - annotate - [select for diffs], Sat Oct 30 10:59:07 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.182: +5 -5 lines
Diff to previous 1.182 (colored) to selected 1.128 (colored)

indent: remove confusing modulo from code_add_decl_indent

The only effects of the modulo operation was to make indent slower and
to confuse human readers.

During the computation of the indentation, the main focus is on the
difference between the current indentation, as computed from the base
indentation and the current code, and the target indentation. All these
computations take opt.tabsize into account. When looking only at the
difference, whether or not a multiple of opt.tabsize is added does not
matter.

No functional change.

Revision 1.182 / (download) - annotate - [select for diffs], Sat Oct 30 10:01:31 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.181: +3 -5 lines
Diff to previous 1.181 (colored) to selected 1.128 (colored)

indent: inline bloated call to 'parse' during initialization

No functional change.

Revision 1.181 / (download) - annotate - [select for diffs], Sat Oct 30 09:51:22 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.180: +9 -14 lines
Diff to previous 1.180 (colored) to selected 1.128 (colored)

indent: condense code for parsing command line arguments

Previously, the cascade of 'if' statements suggested that there were 6
different cases to be handled when in reality there are only 3: no
arguments, 1 argument, 2 arguments. Let the code express this directly.

No functional change.

Revision 1.180 / (download) - annotate - [select for diffs], Sat Oct 30 09:42:31 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.179: +26 -18 lines
Diff to previous 1.179 (colored) to selected 1.128 (colored)

indent: extract main_load_profiles from main_parse_command_line

No functional change.

Revision 1.179 / (download) - annotate - [select for diffs], Fri Oct 29 23:48:50 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.178: +3 -2 lines
Diff to previous 1.178 (colored) to selected 1.128 (colored)

indent: remove redundant comments, remove punctuation from debug log

The comment about 'null stmt' between braces probably meant 'no
statements between braces'.

The comments at psym_switch_expr only repeated what the code says or had
been outdated 29 years ago already since opt.case_indent does not have
to be 'one level down'.

In the debug log, the quotes around the symbol names are not necessary
after a ':'. The parse stack also does not need this much punctuation.

Reducing a do-while loop to nothing instead of a statement saves a few
CPU cycles. It works because after each lbrace, a stmt is pushed to the
parser stack. This stmt can only ever be reduced to a stmt_list but
never be removed.

Revision 1.178 / (download) - annotate - [select for diffs], Fri Oct 29 21:56:36 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.177: +3 -3 lines
Diff to previous 1.177 (colored) to selected 1.128 (colored)

indent: fix missing blank before binary operator

Revision 1.177 / (download) - annotate - [select for diffs], Fri Oct 29 20:27:42 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.176: +7 -7 lines
Diff to previous 1.176 (colored) to selected 1.128 (colored)

indent: merge isblank and is_hspace into ch_isblank

No functional change.

Revision 1.176 / (download) - annotate - [select for diffs], Fri Oct 29 20:05:58 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.175: +4 -2 lines
Diff to previous 1.175 (colored) to selected 1.128 (colored)

indent: replace segmentation fault with assertion

Revision 1.175 / (download) - annotate - [select for diffs], Fri Oct 29 19:31:24 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.174: +7 -7 lines
Diff to previous 1.174 (colored) to selected 1.128 (colored)

indent: initialize 'ps' via code

This saves 3 kB of binary size since the parser state is rather large
and only very few members are initialized to non-zero values.

No functional change.

Revision 1.174 / (download) - annotate - [select for diffs], Fri Oct 29 19:22:55 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.173: +12 -27 lines
Diff to previous 1.173 (colored) to selected 1.128 (colored)

indent: clean up main_init_globals

No functional change.

Revision 1.173 / (download) - annotate - [select for diffs], Fri Oct 29 19:12:48 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.172: +16 -13 lines
Diff to previous 1.172 (colored) to selected 1.128 (colored)

indent: fix undefined behavior in buffer handling

Adding an arbitrary integer to a pointer may result in an out of bounds
pointer, so replace the addition with a pointer subtraction.

In the buffer handling functions, handle 'buf' and 'l' before 's' and
'e', since they are pairs.

In inbuf_read_line, use 's' instead of 'buf' to make the code easier to
understand for human readers.

No functional change.

Revision 1.172 / (download) - annotate - [select for diffs], Fri Oct 29 18:50:52 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.171: +8 -2 lines
Diff to previous 1.171 (colored) to selected 1.128 (colored)

indent: mark obviously broken code

Revision 1.171 / (download) - annotate - [select for diffs], Fri Oct 29 17:50:37 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.170: +11 -11 lines
Diff to previous 1.170 (colored) to selected 1.128 (colored)

indent: use prev/curr/next to refer to the current token

The word 'last' just didn't match with 'next'.

No functional change.

Revision 1.170 / (download) - annotate - [select for diffs], Fri Oct 29 17:32:22 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.169: +19 -20 lines
Diff to previous 1.169 (colored) to selected 1.128 (colored)

indent: rename ps.dumped_decl_indent and indent_declaration

The word 'dump' in 'ps.dumped_decl_indent' was too close to dump_line,
which led to confusion since the variable controls whether the
indentation has been added to the code buffer, which happens way before
actually dumping the current line to the output file.

The function name 'indent_declaration' was too unspecific, it did not
reveal where the indentation of the declaration actually happened.

No functional change.

Revision 1.169 / (download) - annotate - [select for diffs], Fri Oct 29 16:59:35 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.168: +7 -8 lines
Diff to previous 1.168 (colored) to selected 1.128 (colored)

indent: keep p_l_follow nonnegative, use consistent comparison

No functional change.

Revision 1.168 / (download) - annotate - [select for diffs], Fri Oct 29 16:54:51 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.167: +9 -9 lines
Diff to previous 1.167 (colored) to selected 1.128 (colored)

indent: spell 'parentheses' properly in messages and comments

Revision 1.167 / (download) - annotate - [select for diffs], Thu Oct 28 22:20:08 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.166: +7 -8 lines
Diff to previous 1.166 (colored) to selected 1.128 (colored)

indent: clean up indentation, comments, reduce

No functional change.

Revision 1.166 / (download) - annotate - [select for diffs], Thu Oct 28 22:06:23 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.165: +5 -3 lines
Diff to previous 1.165 (colored) to selected 1.128 (colored)

indent: remove unused local variable in lexi

Since the previous commit, lexi is always called with the same argument,
so remove that parameter.

The previous commit broke the debug logging by not printing "transient
state" anymore. Replace this with "rolled back parser state" at the
caller's site.

No functional change.

Revision 1.165 / (download) - annotate - [select for diffs], Thu Oct 28 21:56:26 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.164: +8 -9 lines
Diff to previous 1.164 (colored) to selected 1.128 (colored)

indent: reduce negations in search_stmt_lookahead

No functional change.

Revision 1.164 / (download) - annotate - [select for diffs], Thu Oct 28 21:51:43 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.163: +15 -15 lines
Diff to previous 1.163 (colored) to selected 1.128 (colored)

indent: clean up comments and function names

Having accurate names for the lexer symbols and the parser symbols makes
most of the comments redundant. Remove these.

Rename process_decl to process_type, to match the name of the
corresponding lexer symbol. In this phase, it's just a single type
token, not a whole declaration.

No functional change.

Revision 1.163 / (download) - annotate - [select for diffs], Thu Oct 28 21:32:49 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.162: +3 -3 lines
Diff to previous 1.162 (colored) to selected 1.128 (colored)

indent: make error messages for option parsing more precise

Revision 1.162 / (download) - annotate - [select for diffs], Tue Oct 26 21:37:27 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.161: +3 -3 lines
Diff to previous 1.161 (colored) to selected 1.128 (colored)

indent: clean up process_comment

There is no undefined behavior since the compared characters are always
from the basic execution character set. All other cases are covered by
the condition above for now_len.

Fix debug logging for non-ASCII characters, previously a character was
output as \xffffffc3.

Revision 1.161 / (download) - annotate - [select for diffs], Tue Oct 26 20:43:35 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.160: +6 -7 lines
Diff to previous 1.160 (colored) to selected 1.128 (colored)

indent: make ps.keyword easier to understand

Previously, ps.keyword did not have any documentation and was not
straight-forward. In some cases it was reset to kw_0, in others it was
set to an interesting value. The idea behind it was to remember the kind
of word of the previous token, to decide whether to have a space between
sizeof or offsetof and a following '('.

No functional change.

Revision 1.160 / (download) - annotate - [select for diffs], Tue Oct 26 19:36:30 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.159: +8 -8 lines
Diff to previous 1.159 (colored) to selected 1.128 (colored)

indent: run indent on its own source code

With manual corrections afterwards, to compensate for the remaining bugs
in indent.

Without the type definitions in .indent.pro, the opening braces of the
functions kw_name and lexi_alnum would not be at the beginning of the
line.

Revision 1.159 / (download) - annotate - [select for diffs], Mon Oct 25 21:33:24 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.158: +5 -3 lines
Diff to previous 1.158 (colored) to selected 1.128 (colored)

indent: improve debug logging

Output the various details in chronological order.

Revision 1.158 / (download) - annotate - [select for diffs], Mon Oct 25 19:56:03 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.157: +20 -20 lines
Diff to previous 1.157 (colored) to selected 1.128 (colored)

indent: rename search_brace to search_stmt

No functional change.

Revision 1.157 / (download) - annotate - [select for diffs], Mon Oct 25 01:06:13 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.156: +37 -36 lines
Diff to previous 1.156 (colored) to selected 1.128 (colored)

indent: rename local variable sp_sw to spaced_expr

The 'sp' probably meant 'space-enclosed'; no idea what 'sw' was meant to
mean. Maybe 'switch', but that would have been rather ambiguous when
talking about control flow statements.

No functional change.

Revision 1.156 / (download) - annotate - [select for diffs], Mon Oct 25 00:54:37 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.155: +108 -112 lines
Diff to previous 1.155 (colored) to selected 1.128 (colored)

indent: split type token_type into 3 separate types

Previously, token_type was used for 3 different purposes:

1. symbol types from the lexer
2. symbol types on the parser stack
3. kind of control statement for 'if (expr)' and similar statements

Splitting the 41 constants into separate types makes it immediately
clear that the parser stack never handles comments, preprocessing lines,
newlines, form feeds, the inner structure of expressions.

Previously, the constant switch_expr was especially confusing since it
was used for 3 different purposes: when returned from lexi, it
represented the keyword 'switch', in the parser stack it represented
'switch (expr)', and it was used for a statement head as well.

The only overlap between the lexer symbols and the parser symbols are
'{' and '}', and the keywords 'do' and 'else'. To increase confusion,
the constants of the previous token_type were in apparently random
order and before 2021, they had cryptic, highly abbreviated names.

No functional change.

Revision 1.155 / (download) - annotate - [select for diffs], Sun Oct 24 22:44:13 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.154: +7 -6 lines
Diff to previous 1.154 (colored) to selected 1.128 (colored)

indent: rename form_feed to tt_lex_form_feed

No functional change.

Revision 1.154 / (download) - annotate - [select for diffs], Sun Oct 24 22:38:20 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.153: +16 -9 lines
Diff to previous 1.153 (colored) to selected 1.128 (colored)

indent: split kw_for_or_if_or_while into separate constants

No functional change.

Revision 1.153 / (download) - annotate - [select for diffs], Sun Oct 24 22:28:06 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.152: +11 -11 lines
Diff to previous 1.152 (colored) to selected 1.128 (colored)

indent: split kw_do_or_else into separate constants

It was unnecessarily confusing to have the token types keyword_do_else,
keyword_do and keyword_else at the same time, without any hint in what
they differed.

Some of the token types seem to be used by the lexer while others are
used in the parse stack. Maybe all token types can be partitioned into
these groups, which would suggest to use two different types for them.
And if not, it's still clearer to have this distinction in the names of
the constants.

No functional change.

Revision 1.152 / (download) - annotate - [select for diffs], Sun Oct 24 20:57:11 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.151: +15 -15 lines
Diff to previous 1.151 (colored) to selected 1.128 (colored)

indent: rename seen_quest to quest_level

The new name aligns with other similar variables like ind_level,
case_ind_level and ifdef_level. The old name 'seen' is mainly used for
bool variables.

No functional change.

Revision 1.151 / (download) - annotate - [select for diffs], Sun Oct 24 20:43:27 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.150: +6 -3 lines
Diff to previous 1.150 (colored) to selected 1.128 (colored)

indent: fix indentation of ad-hoc tagged variables

Seen among others in usr.bin/indent/lexi.c, variable 'keywords'.

Revision 1.150 / (download) - annotate - [select for diffs], Sun Oct 24 19:33:26 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.149: +11 -16 lines
Diff to previous 1.149 (colored) to selected 1.128 (colored)

indent: initialize variables in main_loop in declaration

No functional change.

Revision 1.149 / (download) - annotate - [select for diffs], Sun Oct 24 19:14:33 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.148: +19 -21 lines
Diff to previous 1.148 (colored) to selected 1.128 (colored)

indent: run indent on its own source code

With manual corrections afterwards. Indent still does not get
extra_expr_indent correctly, it also indents global variables after
tagged declarations too deep.

No functional change.

Revision 1.148 / (download) - annotate - [select for diffs], Sun Oct 24 17:19:48 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.147: +18 -2 lines
Diff to previous 1.147 (colored) to selected 1.128 (colored)

indent: clean up format of warnings and errors

Previously, warnings and errors had the form of C block comments. Before
NetBSD io.c 1.20 from 2019-10-19, this format made sense because the
diagnostics could end up in the same output stream as the formatted
output.

Since NetBSD io.c 1.20 from 2019-10-19, all diagnostics are redirected
to stderr. This change was not mentioned in the commit message back
then, it makes sense nevertheless. Since stdout and stderr now are
properly separated, there is no need anymore to keep the weird format
for warnings and errors. Switch to the standard 'error: file:line'
format.

Move the function 'diag' to indent.c to have access to the name of the
current input file.

Revision 1.147 / (download) - annotate - [select for diffs], Sun Oct 24 16:51:44 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.146: +4 -2 lines
Diff to previous 1.146 (colored) to selected 1.128 (colored)

indent: fix line number counting at beginning of function body

Revision 1.146 / (download) - annotate - [select for diffs], Sun Oct 24 11:19:25 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.145: +6 -6 lines
Diff to previous 1.145 (colored) to selected 1.128 (colored)

indent: rename nitems to array_length

Revision 1.145 / (download) - annotate - [select for diffs], Sun Oct 24 11:17:05 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.144: +3 -4 lines
Diff to previous 1.144 (colored) to selected 1.128 (colored)

indent: replace global variable use_ff with function parameter

Revision 1.144 / (download) - annotate - [select for diffs], Wed Oct 20 05:37:21 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.143: +5 -6 lines
Diff to previous 1.143 (colored) to selected 1.128 (colored)

indent: rename ps.last_u_d to match its comment

No functional change.

Revision 1.143 / (download) - annotate - [select for diffs], Wed Oct 20 05:26:46 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.142: +6 -6 lines
Diff to previous 1.142 (colored) to selected 1.128 (colored)

indent: rename parser stack variables

No functional change.

Revision 1.142 / (download) - annotate - [select for diffs], Wed Oct 20 05:14:21 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.141: +13 -13 lines
Diff to previous 1.141 (colored) to selected 1.128 (colored)

indent: rename blankline_requested variables

The words 'prefix' and 'postfix' sounded too much like horizontal
concepts, like in operators. The actual purpose of these variables is to
add blank lines before and after the current line, so use the same
wording as in the command line options.

No functional change.

Revision 1.141 / (download) - annotate - [select for diffs], Wed Oct 20 05:07:08 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.140: +11 -7 lines
Diff to previous 1.140 (colored) to selected 1.128 (colored)

indent: invert condition in process_newline

It's hard to follow a condition that combines many negated terms with
'||'. Group the conditions by their origin.

The condition '!opt.break_after_comma && break_comma' still sounds like
a contradition, more investigations to follow.

No functional change.

Revision 1.140 / (download) - annotate - [select for diffs], Wed Oct 20 05:00:37 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.139: +4 -4 lines
Diff to previous 1.139 (colored) to selected 1.128 (colored)

indent: rename next_blank_lines to blank_lines_to_output

The previous name was already an improvement over the name before that
(n_real_blanklines), but didn't express the intended purpose clearly
enough, so try another name.

No functional change.

Revision 1.139 / (download) - annotate - [select for diffs], Tue Oct 19 18:29:59 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.138: +3 -3 lines
Diff to previous 1.138 (colored) to selected 1.128 (colored)

indent: if a file ends with indent off, don't add space-newline

Revision 1.138 / (download) - annotate - [select for diffs], Sun Oct 17 18:13:00 2021 UTC (2 years, 5 months ago) by rillig
Branch: MAIN
Changes since 1.137: +2 -6 lines
Diff to previous 1.137 (colored) to selected 1.128 (colored)

indent: parse int command line options strictly

On i386 and other platforms where LONG_MAX == INT_MAX, the test
t_errors/option_tabsize_very_large failed since the behavior on integer
overflow differs between ILP32 and LP64 platforms. Noticed by gson@.

Avoid this unintended difference by adding reasonable limits for each of
the integer options and by replacing atoi with strtol.

Revision 1.137 / (download) - annotate - [select for diffs], Sat Oct 9 11:13:25 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.136: +8 -16 lines
Diff to previous 1.136 (colored) to selected 1.128 (colored)

indent: condense code for calculating indentations

No functional change.

Revision 1.136 / (download) - annotate - [select for diffs], Sat Oct 9 11:00:27 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.135: +4 -4 lines
Diff to previous 1.135 (colored) to selected 1.128 (colored)

indent: extract common code for advancing a single tab

No functional change.

Revision 1.135 / (download) - annotate - [select for diffs], Fri Oct 8 23:47:40 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.134: +17 -20 lines
Diff to previous 1.134 (colored) to selected 1.128 (colored)

indent: clean up comments, parentheses, debug messages, boolean operator

No functional change.

Revision 1.134 / (download) - annotate - [select for diffs], Fri Oct 8 23:43:33 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.133: +12 -15 lines
Diff to previous 1.133 (colored) to selected 1.128 (colored)

indent: rename in_or_st to init_or_struct

This makes a few comments redundant.

No functional change.

Revision 1.133 / (download) - annotate - [select for diffs], Fri Oct 8 21:13:58 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.132: +4 -4 lines
Diff to previous 1.132 (colored) to selected 1.128 (colored)

indent: rename fill_buffer to inbuf_read_line

No functional change.

Revision 1.132 / (download) - annotate - [select for diffs], Fri Oct 8 20:45:22 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.131: +7 -7 lines
Diff to previous 1.131 (colored) to selected 1.128 (colored)

indent: clean up process_decl, replace unnecessary strlen

No functional change.

Revision 1.131 / (download) - annotate - [select for diffs], Fri Oct 8 20:33:18 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.130: +78 -81 lines
Diff to previous 1.130 (colored) to selected 1.128 (colored)

indent: remove unnecessary forward declarations

No functional change.

Revision 1.130 / (download) - annotate - [select for diffs], Fri Oct 8 20:28:56 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.129: +5 -11 lines
Diff to previous 1.129 (colored) to selected 1.128 (colored)

indent: reduce negations in main_loop

No functional change.

Revision 1.129 / (download) - annotate - [select for diffs], Fri Oct 8 20:14:52 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.128: +21 -18 lines
Diff to previous 1.128 (colored)

indent: fix parsing of preprocessor lines with comments and strings

Revision 1.128 / (download) - annotate - [selected], Fri Oct 8 19:03:34 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.127: +4 -5 lines
Diff to previous 1.127 (colored)

indent: run indent on indent.h

The formatting looks mostly OK.

Some struct members had excessively long names, leaving no space for
their corresponding comments. Renamed some of them using well-known
abbreviations.

The formatting for debug_vis_range is messed up, no idea why. It is
clearly a function declaration, not a function definition, so there is
no need to place the function name in column 1.

No functional change.

Revision 1.127 / (download) - annotate - [select for diffs], Fri Oct 8 16:47:42 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.126: +30 -24 lines
Diff to previous 1.126 (colored) to selected 1.128 (colored)

indent: split process_keyword_do_else into separate functions

No functional change.

Revision 1.126 / (download) - annotate - [select for diffs], Fri Oct 8 16:20:33 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.125: +7 -7 lines
Diff to previous 1.125 (colored) to selected 1.128 (colored)

indent: rename tokens lparen and rparen to be more precise

No functional change.

Revision 1.125 / (download) - annotate - [select for diffs], Thu Oct 7 23:18:47 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.124: +11 -11 lines
Diff to previous 1.124 (colored) to selected 1.128 (colored)

indent: rename bp_save to saved_inp_s, be_save to saved_inp_e

Using the same naming convention makes it easier to relate the
variables.

No functional change.

Revision 1.124 / (download) - annotate - [select for diffs], Thu Oct 7 23:15:15 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.123: +31 -34 lines
Diff to previous 1.123 (colored) to selected 1.128 (colored)

indent: group variables for the input buffer

The input buffer follows the same concept as the intermediate buffers
for label, code, comment and token, so use the same type for it.

No functional change.

Revision 1.123 / (download) - annotate - [select for diffs], Thu Oct 7 23:01:32 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.122: +5 -4 lines
Diff to previous 1.122 (colored) to selected 1.128 (colored)

indent: move definition of bufsize from header to implementation

No functional change.

Revision 1.122 / (download) - annotate - [select for diffs], Thu Oct 7 22:56:49 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.121: +12 -10 lines
Diff to previous 1.121 (colored) to selected 1.128 (colored)

indent: rename opt.btype_2 to brace_same_line

No functional change.

Revision 1.121 / (download) - annotate - [select for diffs], Thu Oct 7 22:52:13 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.120: +3 -3 lines
Diff to previous 1.120 (colored) to selected 1.128 (colored)

indent: clean up code, remove outdated wrong comments

No functional change.

Revision 1.120 / (download) - annotate - [select for diffs], Thu Oct 7 21:57:21 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.119: +4 -7 lines
Diff to previous 1.119 (colored) to selected 1.128 (colored)

indent: use braces around multi-line statements

No functional change.

Revision 1.119 / (download) - annotate - [select for diffs], Thu Oct 7 21:52:54 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.118: +47 -3 lines
Diff to previous 1.118 (colored) to selected 1.128 (colored)

indent: let the code breathe a bit by inserting empty lines

No functional change.

Revision 1.118 / (download) - annotate - [select for diffs], Thu Oct 7 21:43:20 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.117: +13 -15 lines
Diff to previous 1.117 (colored) to selected 1.128 (colored)

indent: clean up comments

No functional change.

Revision 1.117 / (download) - annotate - [select for diffs], Thu Oct 7 21:41:59 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.116: +6 -8 lines
Diff to previous 1.116 (colored) to selected 1.128 (colored)

indent: fix wrong or outdated comments

No functional change.

Revision 1.116 / (download) - annotate - [select for diffs], Thu Oct 7 21:38:25 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.115: +17 -19 lines
Diff to previous 1.115 (colored) to selected 1.128 (colored)

indent: remove redundant comments

No functional change.

Revision 1.115 / (download) - annotate - [select for diffs], Thu Oct 7 21:16:36 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.114: +116 -115 lines
Diff to previous 1.114 (colored) to selected 1.128 (colored)

indent: reduce indentation

No functional change.

Revision 1.114 / (download) - annotate - [select for diffs], Thu Oct 7 19:42:41 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.113: +3 -3 lines
Diff to previous 1.113 (colored) to selected 1.128 (colored)

indent: remove global variable option_source

It is only needed at startup, while parsing the options. The string "?"
was not needed at all.

No functional change.

Revision 1.113 / (download) - annotate - [select for diffs], Thu Oct 7 19:35:50 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.112: +11 -14 lines
Diff to previous 1.112 (colored) to selected 1.128 (colored)

indent: clean up colon handling

No functional change.

Revision 1.112 / (download) - annotate - [select for diffs], Thu Oct 7 19:17:07 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.111: +68 -84 lines
Diff to previous 1.111 (colored) to selected 1.128 (colored)

indent: add high-level API for working with buffers

This makes the code more boring to read, which is actually good. Less
fiddling with memcpy and pointer arithmetics.

Since indent is not a high-performance tool used for bulk operations on
terabytes of source code, there is no need to squeeze out every possible
CPU cycle.

No functional change.

Revision 1.111 / (download) - annotate - [select for diffs], Thu Oct 7 18:48:31 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.110: +12 -12 lines
Diff to previous 1.110 (colored) to selected 1.128 (colored)

indent: rename copy_id to copy_token

No functional change.

Revision 1.110 / (download) - annotate - [select for diffs], Thu Oct 7 18:32:09 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.109: +17 -11 lines
Diff to previous 1.109 (colored) to selected 1.128 (colored)

indent: raise WARNS from the default 5 up to 6

Revision 1.109 / (download) - annotate - [select for diffs], Thu Oct 7 18:19:07 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.108: +6 -2 lines
Diff to previous 1.108 (colored) to selected 1.128 (colored)

indent: prevent division by zero

Revision 1.108 / (download) - annotate - [select for diffs], Tue Oct 5 18:50:42 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.107: +4 -4 lines
Diff to previous 1.107 (colored) to selected 1.128 (colored)

indent: rename n_real_blanklines

The word 'n' was not as helpful as possible, the word 'real' did not
give any clue at all about the variable's purpose.

No functional change.

Revision 1.107 / (download) - annotate - [select for diffs], Tue Oct 5 17:14:45 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.106: +3 -3 lines
Diff to previous 1.106 (colored) to selected 1.128 (colored)

indent: fix off-by-one error for indented first line

Revision 1.106 / (download) - annotate - [select for diffs], Tue Oct 5 17:12:20 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.105: +7 -7 lines
Diff to previous 1.105 (colored) to selected 1.128 (colored)

indent: make off-by-one error in main_prepare_parsing more visible

No functional change.

Revision 1.105 / (download) - annotate - [select for diffs], Tue Oct 5 16:33:25 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.104: +53 -54 lines
Diff to previous 1.104 (colored) to selected 1.128 (colored)

indent: make variable names more expressive

The abbreviation 'dec' looked too much like 'decimal' instead of the
intended 'declaration'.

No functional change.

Revision 1.104 / (download) - annotate - [select for diffs], Tue Oct 5 07:05:51 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.103: +72 -72 lines
Diff to previous 1.103 (colored) to selected 1.128 (colored)

indent: remove variable name prefix 'inout_'

This makes the variable names more readable. The prefix is not actually
needed to understand the code, it is rather distracting.

The compiler and lint will guard against any accidental mismatch between
pointer, integer and bool.

No functional change.

Revision 1.103 / (download) - annotate - [select for diffs], Tue Oct 5 06:55:24 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.102: +17 -24 lines
Diff to previous 1.102 (colored) to selected 1.128 (colored)

indent: fix Clang-Tidy warnings, clean up bakcopy

The comment above and inside bakcopy had been outdated for at least the
last 28 years, the backup file is named "%s.BAK", not ".B%s".

Prevent buffer overflow for very long filenames (sprintf -> snprintf).

Revision 1.102 / (download) - annotate - [select for diffs], Tue Oct 5 06:49:19 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.101: +11 -11 lines
Diff to previous 1.101 (colored) to selected 1.128 (colored)

indent: fix spelling in comments

Revision 1.101 / (download) - annotate - [select for diffs], Tue Oct 5 06:09:42 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.100: +6 -6 lines
Diff to previous 1.100 (colored) to selected 1.128 (colored)

indent: merge duplicate code into is_hspace

No functional change.

Revision 1.100 / (download) - annotate - [select for diffs], Tue Oct 5 05:56:49 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.99: +12 -13 lines
Diff to previous 1.99 (colored) to selected 1.128 (colored)

indent: clean up code for appending to buffers

Use *e++ for appending and e[-1] for testing the previously appended
character, like in other places in the code.

No functional change.

Revision 1.99 / (download) - annotate - [select for diffs], Tue Oct 5 05:39:14 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.98: +12 -24 lines
Diff to previous 1.98 (colored) to selected 1.128 (colored)

indent: merge duplicate code for reading from input buffer

No functional change.

Revision 1.98 / (download) - annotate - [select for diffs], Sun Oct 3 18:44:51 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.97: +3 -3 lines
Diff to previous 1.97 (colored) to selected 1.128 (colored)

indent: rename functions

There was no good reason for using the different verbs 'scan' and 'set'
for two functions that essentially do the same.

No functional change.

Revision 1.97 / (download) - annotate - [select for diffs], Sun Oct 3 18:41:36 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.96: +3 -3 lines
Diff to previous 1.96 (colored) to selected 1.128 (colored)

indent: fix content of profile_name

Previously, profile_name included the leading "-P", which was confusing.

Revision 1.96 / (download) - annotate - [select for diffs], Thu Sep 30 21:48:12 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.95: +4 -2 lines
Diff to previous 1.95 (colored) to selected 1.128 (colored)

indent: remove space between ')' and '(' in declarations

Revision 1.95 / (download) - annotate - [select for diffs], Thu Sep 30 21:38:43 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.94: +11 -7 lines
Diff to previous 1.94 (colored) to selected 1.128 (colored)

indent: untangle want_blank_before_lparen

No functional change.

Revision 1.94 / (download) - annotate - [select for diffs], Thu Sep 30 21:33:55 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.93: +13 -7 lines
Diff to previous 1.93 (colored) to selected 1.128 (colored)

indent: extract want_blank_before_lparen

No functional change.

Revision 1.93 / (download) - annotate - [select for diffs], Thu Sep 30 20:58:26 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.92: +4 -5 lines
Diff to previous 1.92 (colored) to selected 1.128 (colored)

indent: add space between ',' and '[' in C99 initializations

Revision 1.92 / (download) - annotate - [select for diffs], Mon Sep 27 20:09:55 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.91: +19 -21 lines
Diff to previous 1.91 (colored) to selected 1.128 (colored)

indent: let indent format the comments after previous refactoring

Before this refactoring, I had skipped this section of the code from
formatting since the 'default:' branch was enclosed in a block of its
own, and that block would have been indented one more level to the
right. Extracting that code into a separate function got rid of the
extra braces.

No functional change.

Revision 1.91 / (download) - annotate - [select for diffs], Mon Sep 27 20:00:41 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.90: +201 -163 lines
Diff to previous 1.90 (colored) to selected 1.128 (colored)

indent: split search_brace into smaller functions

No functional change.

Revision 1.90 / (download) - annotate - [select for diffs], Mon Sep 27 18:21:47 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.89: +2 -3 lines
Diff to previous 1.89 (colored) to selected 1.128 (colored)

indent: use binary instead of linear search when adding types

No functional change.

Revision 1.89 / (download) - annotate - [select for diffs], Mon Sep 27 16:56:35 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.88: +5 -5 lines
Diff to previous 1.88 (colored) to selected 1.128 (colored)

indent: rename rwcode to keyword_kind, various cleanup

No idea what the 'rw' in 'rwcode' meant, it had been imported that way
28 years ago. Since rwcode specifies the kind of a keyword, the prefix
'kw_' makes sense.

No functional change.

Revision 1.88 / (download) - annotate - [select for diffs], Sun Sep 26 21:23:31 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.87: +14 -22 lines
Diff to previous 1.87 (colored) to selected 1.128 (colored)

indent: unexport global variables

The variable match_state was write-only and was thus removed.

No functional change.

Revision 1.87 / (download) - annotate - [select for diffs], Sun Sep 26 19:57:23 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.86: +5 -6 lines
Diff to previous 1.86 (colored) to selected 1.128 (colored)

indent: negate and rename option.leave_comma

The old name did not mirror the description in the manual page, and it
was the only option that is negated. Inverting it allows the options
table to be compressed.

Revision 1.86 / (download) - annotate - [select for diffs], Sun Sep 26 19:37:11 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.85: +144 -146 lines
Diff to previous 1.85 (colored) to selected 1.128 (colored)

indent: let indent format its own code -- in supervised mode

After running indent on the code, I manually selected each change that
now looks better than before. The remaining changes are left for later.
All in all, indent did a pretty good job, except for syntactic additions
from after 1990, but that was to be expected. Examples for such
additions are GCC's __attribute__ and C99 designated initializers.

Indent has only few knobs to tune the indentation. The knob for the
continuation indentation applies to function declarations as well as to
expressions. The knob for indentation of local variable declarations
applies to struct members as well, even if these are members of a
top-level struct.

Several code comments crossed the right margin in column 78. Several
other code comments were correctly broken though. The cause for this
difference was not obvious.

No functional change.

Revision 1.85 / (download) - annotate - [select for diffs], Sun Sep 26 18:52:16 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.84: +4 -2 lines
Diff to previous 1.84 (colored) to selected 1.128 (colored)

indent: fix missing space between comma and ellipsis

According to lint's C grammar, in standard C an ellipsis only occurs
after a comma. There are GCC extensions that allow an ellipsis as the
only function parameter, as well as in 'case a ... b', but these are
rare.

Revision 1.84 / (download) - annotate - [select for diffs], Sat Sep 25 22:57:04 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.83: +4 -4 lines
Diff to previous 1.83 (colored) to selected 1.128 (colored)

indent: misc cleanup

No functional change.

Revision 1.83 / (download) - annotate - [select for diffs], Sat Sep 25 22:54:32 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.82: +5 -5 lines
Diff to previous 1.82 (colored) to selected 1.128 (colored)

indent: convert found_err to bool

That variable had slipped through the migration since it consequently
used int for the declaration, the definition and all assignments.

No functional change.

Revision 1.82 / (download) - annotate - [select for diffs], Sat Sep 25 22:24:35 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.81: +11 -24 lines
Diff to previous 1.81 (colored) to selected 1.128 (colored)

indent: use strlen instead of own implementation

The two loops looks similar but differ in a crucial detail that makes up
for a '+ 1'.

No functional change.

Revision 1.81 / (download) - annotate - [select for diffs], Sat Sep 25 22:14:21 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.80: +17 -20 lines
Diff to previous 1.80 (colored) to selected 1.128 (colored)

indent: merge duplicate code for token buffers

No functional change.

Revision 1.80 / (download) - annotate - [select for diffs], Sat Sep 25 21:42:43 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.79: +21 -26 lines
Diff to previous 1.79 (colored) to selected 1.128 (colored)

indent: clean up argument handling

No functional change.

Revision 1.79 / (download) - annotate - [select for diffs], Sat Sep 25 20:56:53 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.78: +20 -19 lines
Diff to previous 1.78 (colored) to selected 1.128 (colored)

indent: un-abbreviate a few parser_state members, clean up comments

No functional change.

Revision 1.78 / (download) - annotate - [select for diffs], Sat Sep 25 20:23:42 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.77: +2 -3 lines
Diff to previous 1.77 (colored) to selected 1.128 (colored)

indent: remove dead code for printing comments after empty lines

This code has been commented out for at least 29 years.

No functional change.

Revision 1.77 / (download) - annotate - [select for diffs], Sat Sep 25 19:49:13 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.76: +2 -3 lines
Diff to previous 1.76 (colored) to selected 1.128 (colored)

indent: reduce code and data size for lexing of numbers

Instead of having a table of strings (121 pointers + 121 data
relocations), reduce that table to the actual character data and use a
secondary table for looking up the correct row in the main table.

No functional change.

Revision 1.76 / (download) - annotate - [select for diffs], Sat Sep 25 18:49:03 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.75: +3 -3 lines
Diff to previous 1.75 (colored) to selected 1.128 (colored)

indent: rename option variable to be more expressive

No functional change.

Revision 1.75 / (download) - annotate - [select for diffs], Sat Sep 25 17:36:51 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.74: +35 -39 lines
Diff to previous 1.74 (colored) to selected 1.128 (colored)

indent: convert remaining ibool to bool

No functional change intended.

Revision 1.74 / (download) - annotate - [select for diffs], Sat Sep 25 17:29:13 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.73: +3 -3 lines
Diff to previous 1.73 (colored) to selected 1.128 (colored)

indent: convert parser_state from ibool to bool

indent.c:400:5: error: suggest parentheses around assignment used as
    truth value
io.c:271:32: error: ãàÏßãàon a boolean expression

No functional change intended.

Revision 1.73 / (download) - annotate - [select for diffs], Sat Sep 25 17:11:23 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.72: +70 -66 lines
Diff to previous 1.72 (colored) to selected 1.128 (colored)

indent: prepare for lint's strict bool mode

Before C99, C had no boolean type. Instead, indent used int for that,
just like many other programs. Even with C99, bool and int can be used
interchangeably in many situations, such as querying '!i' or '!ptr' or
'cond == 0'.

Since January 2021, lint provides the strict bool mode, which makes bool
a non-arithmetic type that is incompatible with any other type. Having
clearly separate types helps in understanding the code.

To migrate indent to strict bool mode, the first step is to apply all
changes that keep the resulting binary the same. Since sizeof(bool) is
1 and sizeof(int) is 4, the type ibool serves as an intermediate type.
For now it is defined to int, later it will become bool.

The current code compiles cleanly in C99 and C11 mode, as well as in
lint's strict bool mode. There are a few tricky places:

In args.c in 'struct pro', there are two types of options: boolean and
integer. Boolean options point to a bool variable, integer options
point to an int variable. To keep the current structure of the code,
the pointer has been changed to 'void *'. To ensure type safety, the
definition of the options is done via preprocessor magic, which in C11
mode ensures the correct pointer types. (Add CFLAGS+=-std=gnu11 at the
very bottom of the Makefile.)

In indent.c in process_preprocessing, a boolean variable is
post-incremented. That variable is only assigned to another variable,
and that variable is only used in a boolean context. To provoke a
different behavior between the '++' and the '= true', the source code
to be indented would need 1 << 32 preprocessing directives, which is
unlikely to happen in practice.

In io.c in dump_line, the variables ps.in_stmt and ps.in_decl only ever
get the values 0 and 1. For these values, the expressions 'a & ~b' and
'a && !b' are equivalent, in all versions of C. The compiler may
generate different code for them, though.

In io.c in parse_indent_comment, the assignment to inhibit_formatting
takes place in integer context. If the compiler is smart enough to
detect the possible values of on_off, it may generate the same code
before and after the change, but that is rather unlikely.

The second step of the migration will be to replace ibool with bool,
step by step, just in case there are any hidden gotchas in the code,
such as sizeof or pointer casts.

No change to the resulting binary.

Revision 1.72 / (download) - annotate - [select for diffs], Sat Sep 25 14:26:05 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.71: +17 -17 lines
Diff to previous 1.71 (colored) to selected 1.128 (colored)

indent: merge duplicate code for initializing buffers

No functional change.

Revision 1.71 / (download) - annotate - [select for diffs], Sat Sep 25 14:16:06 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.70: +24 -33 lines
Diff to previous 1.70 (colored) to selected 1.128 (colored)

indent: clean up initialization of options

The default values in 'struct pro' were redundant but all consistent,
even with the commented defaults in main_parse_command_line.

No functional change.

Revision 1.70 / (download) - annotate - [select for diffs], Sat Sep 25 13:38:32 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.69: +2 -6 lines
Diff to previous 1.69 (colored) to selected 1.128 (colored)

indent: remove ifdef for lint

NetBSD lint does not need them anymore, FreeBSD does not have lint.

Revision 1.69 / (download) - annotate - [select for diffs], Sat Sep 25 10:41:03 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.68: +4 -5 lines
Diff to previous 1.68 (colored) to selected 1.128 (colored)

indent: move statistical values into a separate struct

No functional change.

Revision 1.68 / (download) - annotate - [select for diffs], Sat Sep 25 08:23:31 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.67: +35 -23 lines
Diff to previous 1.67 (colored) to selected 1.128 (colored)

indent: add nonnull memory allocation functions

The only functional change is a single error message.

Revision 1.67 / (download) - annotate - [select for diffs], Sat Sep 25 08:04:13 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.66: +31 -35 lines
Diff to previous 1.66 (colored) to selected 1.128 (colored)

indent: group global variables for token buffer

No functional change.

Revision 1.66 / (download) - annotate - [select for diffs], Sat Sep 25 07:59:52 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.65: +20 -20 lines
Diff to previous 1.65 (colored) to selected 1.128 (colored)

indent: inline macro 'token'

No functional change.

Revision 1.65 / (download) - annotate - [select for diffs], Sat Sep 25 07:55:24 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.64: +78 -83 lines
Diff to previous 1.64 (colored) to selected 1.128 (colored)

indent: group global variables for code buffer

No functional change.

Revision 1.64 / (download) - annotate - [select for diffs], Sat Sep 25 07:46:41 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.63: +38 -39 lines
Diff to previous 1.63 (colored) to selected 1.128 (colored)

indent: rename variables of type token_type

The previous variable name 'code' conflicts with the buffer of the same
name.

No functional change.

Revision 1.63 / (download) - annotate - [select for diffs], Fri Sep 24 18:47:29 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.62: +50 -53 lines
Diff to previous 1.62 (colored) to selected 1.128 (colored)

indent: group global variables for label buffer into struct

No functional change.

Revision 1.62 / (download) - annotate - [select for diffs], Fri Sep 24 18:14:06 2021 UTC (2 years, 6 months ago) by rillig
Branch: MAIN
Changes since 1.61: +16 -19 lines
Diff to previous 1.61 (colored) to selected 1.128 (colored)

indent: group global variables for the comment buffer

No functional change.

Revision 1.61 / (download) - annotate - [select for diffs], Wed Aug 25 22:26:30 2021 UTC (2 years, 7 months ago) by rillig
Branch: MAIN
Changes since 1.60: +11 -21 lines
Diff to previous 1.60 (colored) to selected 1.128 (colored)

indent: fix lint warnings about type conversions on ilp32

No functional change.

Revision 1.60 / (download) - annotate - [select for diffs], Fri Mar 26 22:02:00 2021 UTC (3 years ago) by rillig
Branch: MAIN
CVS Tags: cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Changes since 1.59: +5 -5 lines
Diff to previous 1.59 (colored) to selected 1.128 (colored)

indent: fix Clang build everywhere but on amd64

No idea why Clang didn't complain about this on amd64, only on all other
platforms.

Revision 1.59 / (download) - annotate - [select for diffs], Sun Mar 14 00:22:16 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.58: +20 -19 lines
Diff to previous 1.58 (colored) to selected 1.128 (colored)

indent: fix lint warnings

No functional change.

Revision 1.58 / (download) - annotate - [select for diffs], Sat Mar 13 18:46:39 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.57: +13 -6 lines
Diff to previous 1.57 (colored) to selected 1.128 (colored)

indent: add debug logging for switching the input buffer

No functional change outside debug mode.

Revision 1.57 / (download) - annotate - [select for diffs], Sat Mar 13 13:51:08 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.56: +16 -14 lines
Diff to previous 1.56 (colored) to selected 1.128 (colored)

indent: distinguish between 'column' and 'indentation'

column == 1 + indentation.

In addition, indentation is a relative distance while column is an
absolute position.  Therefore, don't confuse these two concepts, to
prevent off-by-one errors.

No functional change.

Revision 1.56 / (download) - annotate - [select for diffs], Sat Mar 13 13:25:23 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.55: +5 -5 lines
Diff to previous 1.55 (colored) to selected 1.128 (colored)

indent: rename pr_comment to process_comment, clean up documentation

No functional change.

Revision 1.55 / (download) - annotate - [select for diffs], Sat Mar 13 13:14:14 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.54: +10 -6 lines
Diff to previous 1.54 (colored) to selected 1.128 (colored)

indent: fix handling of '/*' in string literal in preprocessing line

Previously, the '/*' in the string literal had been interpreted as the
beginning of a comment, which was wrong.  Because of that, the variable
declaration in the following line was still interpreted as part of the
comment.  The comment even continued until the end of the file.

Due to indent's forgiving nature, it neither complained nor even
mentioned that anything had gone wrong.  The decision of rather
producing wrong output than failing early is a dangerous one.

At least, there should have been an error message that at the end of the
file, the parser was still in a a comment, expecting the closing '*/'.

Revision 1.54 / (download) - annotate - [select for diffs], Sat Mar 13 12:52:24 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.53: +748 -608 lines
Diff to previous 1.53 (colored) to selected 1.128 (colored)

indent: split 'main_loop' into several functions

No functional change.

Revision 1.53 / (download) - annotate - [select for diffs], Sat Mar 13 11:47:22 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.52: +76 -65 lines
Diff to previous 1.52 (colored) to selected 1.128 (colored)

indent: split 'main' into manageable parts

Since several years (maybe even decades) compilers know how to inline
static functions that are only used once.  Therefore there is no need to
have overly long functions anymore, especially not 'main', which is only
called a single time and thus does not add any noticeable performance
degradation.

No functional change.

Revision 1.52 / (download) - annotate - [select for diffs], Sat Mar 13 11:27:01 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.51: +8 -10 lines
Diff to previous 1.51 (colored) to selected 1.128 (colored)

indent: remove redundant parentheses

No functional change.

Revision 1.51 / (download) - annotate - [select for diffs], Sat Mar 13 11:19:43 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.50: +8 -8 lines
Diff to previous 1.50 (colored) to selected 1.128 (colored)

indent: fix confusing variable names

The word 'col' should only be used for the 1-based column number.  This
name is completely inappropriate for a line length since that provokes
off-by-one errors.  The name 'cols' would be acceptable although
confusing since it sounds so similar to 'col'.

Therefore, rename variables that are related to the maximum line length
to 'line_length' since that makes for obvious code and nicely relates to
the description of the option in the manual page.

No functional change.

Revision 1.50 / (download) - annotate - [select for diffs], Sat Mar 13 10:32:25 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.49: +7 -5 lines
Diff to previous 1.49 (colored) to selected 1.128 (colored)

indent: inline calls to count_spaces and count_spaces_until

These two functions operated on column numbers instead of indentation,
which required adjustments of '+ 1' and '- 1'.  Their names were
completely wrong since these functions did not count anything, instead
they computed the column.

No functional change.

Revision 1.49 / (download) - annotate - [select for diffs], Sat Mar 13 10:06:47 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.48: +3 -3 lines
Diff to previous 1.48 (colored) to selected 1.128 (colored)

indent: replace compute_code_column with compute_code_indent

The goal is to only ever be concerned about the _indentation_ of a
token, never the _column_ it appears in.  Having only one of these
avoids off-by-one errors.

No functional change.

Revision 1.48 / (download) - annotate - [select for diffs], Sat Mar 13 09:21:57 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.47: +45 -2 lines
Diff to previous 1.47 (colored) to selected 1.128 (colored)

indent: add debug logging for actually writing to the output file

Together with the results of the tokenizer and the 4 buffers for token,
label, code and comment, the debug log now provides a good high-level
view on how the indentation happens and where to look for the many
remaining bugs.

Revision 1.47 / (download) - annotate - [select for diffs], Sat Mar 13 00:26:56 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.46: +3 -3 lines
Diff to previous 1.46 (colored) to selected 1.128 (colored)

indent: replace pad_output with output_indent

Calculating the indentation is simpler than calculating the column,
since that saves the constant addition and subtraction of the 1.

No functional change.

Revision 1.46 / (download) - annotate - [select for diffs], Fri Mar 12 23:16:00 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.45: +3 -3 lines
Diff to previous 1.45 (colored) to selected 1.128 (colored)

indent: replace 'target' with 'indent' in function names

The word 'target' was not as specific as possible.

No functional change.

Revision 1.45 / (download) - annotate - [select for diffs], Fri Mar 12 23:10:18 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.44: +18 -34 lines
Diff to previous 1.44 (colored) to selected 1.128 (colored)

indent: use consistent indentation for 'else'

Half of the code used -ce, the other half the opposite -nce.

No functional change.

Revision 1.44 / (download) - annotate - [select for diffs], Fri Mar 12 00:15:34 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.43: +3 -3 lines
Diff to previous 1.43 (colored) to selected 1.128 (colored)

indent: manually fix indentation

No functional change.

Revision 1.43 / (download) - annotate - [select for diffs], Thu Mar 11 22:32:06 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.42: +24 -22 lines
Diff to previous 1.42 (colored) to selected 1.128 (colored)

indent: reduce indentation of check_size functions

No functional change.

Revision 1.42 / (download) - annotate - [select for diffs], Thu Mar 11 22:28:30 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.41: +9 -9 lines
Diff to previous 1.41 (colored) to selected 1.128 (colored)

indent: remove redundant cast after allocation functions

No functional change.

Revision 1.41 / (download) - annotate - [select for diffs], Tue Mar 9 19:46:28 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.40: +186 -182 lines
Diff to previous 1.40 (colored) to selected 1.128 (colored)

indent: extract search_brace from main

No functional change.

Revision 1.40 / (download) - annotate - [select for diffs], Tue Mar 9 19:32:41 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.39: +21 -14 lines
Diff to previous 1.39 (colored) to selected 1.128 (colored)

indent: extract capsicum code out of the main function

No functional change.

Revision 1.39 / (download) - annotate - [select for diffs], Tue Mar 9 19:23:08 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.38: +11 -9 lines
Diff to previous 1.38 (colored) to selected 1.128 (colored)

indent: rename a few more token types

The previous names were either too short or ambiguous.

No functional change.

Revision 1.38 / (download) - annotate - [select for diffs], Tue Mar 9 19:14:39 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.37: +12 -11 lines
Diff to previous 1.37 (colored) to selected 1.128 (colored)

indent: make token names more precise

The previous 'casestmt' was wrong since a case label is not a statement
at all.

The previous 'swstmt' was overly short, and wrong as well, since it
represents only the 'switch (expr)' part, which is not a complete switch
statement.  Same for 'ifstmt', 'whilestmt', 'forstmt'.

The previous word 'head' was not precise enough since it didn't specify
exactly where the head ends and the body starts.  Especially for
handling the dangling else, this distinction is important.

No functional change.

Revision 1.37 / (download) - annotate - [select for diffs], Tue Mar 9 18:28:10 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.36: +7 -7 lines
Diff to previous 1.36 (colored) to selected 1.128 (colored)

indent: rename a few tokens to be more obvious

For casual readers it is not obvious whether the 'sp' meant 'special' or
'space' or something entirely different.

Revision 1.36 / (download) - annotate - [select for diffs], Tue Mar 9 16:48:28 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.35: +10 -10 lines
Diff to previous 1.35 (colored) to selected 1.128 (colored)

indent: manually indent comments

It's strange that indent's own code is not formatted by indent itself,
which would be a good demonstration of its capabilities.

In its current state, I don't trust indent to get even the tokenization
correct, therefore the only safe way is to format the code manually.

Revision 1.35 / (download) - annotate - [select for diffs], Mon Mar 8 20:20:11 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.34: +3 -3 lines
Diff to previous 1.34 (colored) to selected 1.128 (colored)

indent: inline macro for backslash

No functional change.

Revision 1.34 / (download) - annotate - [select for diffs], Mon Mar 8 20:15:42 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.33: +45 -15 lines
Diff to previous 1.33 (colored) to selected 1.128 (colored)

indent: convert big macros to functions

Each of these buffers is only modified in a single file.  This makes it
unnecessary to declare the macros in the global header.

Revision 1.33 / (download) - annotate - [select for diffs], Mon Mar 8 19:06:48 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.32: +3 -3 lines
Diff to previous 1.32 (colored) to selected 1.128 (colored)

indent: fix printing of uninitialized 'token' in debug output

Revision 1.32 / (download) - annotate - [select for diffs], Sun Mar 7 20:52:11 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.31: +4 -5 lines
Diff to previous 1.31 (colored) to selected 1.128 (colored)

indent: sprinkle a few const

No functional change.

Revision 1.31 / (download) - annotate - [select for diffs], Sun Mar 7 20:30:48 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.30: +5 -7 lines
Diff to previous 1.30 (colored) to selected 1.128 (colored)

indent: use named constants for the different types of keywords

This reduces the magic numbers in the code.  Most of these had their
designated constant name written in a nearby comment anyway.

The one instance where arithmetic was performed on this new enum type
(in indent.c) was a bit tricky to understand.

The combination rw_continue_or_inline_or_restrict looks strange, the
'continue' should intuitively belong to the other control flow keywords
in rw_break_or_goto_or_return.

No functional change.

Revision 1.30 / (download) - annotate - [select for diffs], Sun Mar 7 10:56:18 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.29: +10 -7 lines
Diff to previous 1.29 (colored) to selected 1.128 (colored)

indent: for the token types, use enum instead of #define

This makes it easier to step through the code in a debugger.

No functional change.

Revision 1.29 / (download) - annotate - [select for diffs], Sun Mar 7 10:42:48 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.28: +3 -4 lines
Diff to previous 1.28 (colored) to selected 1.128 (colored)

indent: use all headers in all files

This is a prerequisite for converting the token types to an enum instead
of a preprocessor define, since the return type of lexi will become
token_type.  Having the enum will make debugging easier.

There was a single naming collision, which forced the variable in
scan_profile to be renamed.  All other token names are used nowhere
else.

No change to the resulting binary.

Revision 1.28 / (download) - annotate - [select for diffs], Sat Mar 6 20:30:06 2021 UTC (3 years, 1 month ago) by rillig
Branch: MAIN
Changes since 1.27: +3 -3 lines
Diff to previous 1.27 (colored) to selected 1.128 (colored)

indent: fix space-tab alignment in indent's own code

These parts are not fixed automatically by indent since they are in box
comments.

No functional change.

Revision 1.27 / (download) - annotate - [select for diffs], Thu Apr 23 00:17:34 2020 UTC (3 years, 11 months ago) by joerg
Branch: MAIN
Changes since 1.26: +56 -2 lines
Diff to previous 1.26 (colored) to selected 1.128 (colored)

Avoid common symbol declarations

Revision 1.23.14.2 / (download) - annotate - [select for diffs], Mon Apr 13 08:05:42 2020 UTC (4 years ago) by martin
Branch: phil-wifi
Changes since 1.23.14.1: +19 -19 lines
Diff to previous 1.23.14.1 (colored) to branchpoint 1.23 (colored) next main 1.24 (colored) to selected 1.128 (colored)

Mostly merge changes from HEAD upto 20200411

Revision 1.26 / (download) - annotate - [select for diffs], Sat Oct 19 15:44:31 2019 UTC (4 years, 5 months ago) by christos
Branch: MAIN
CVS Tags: phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, is-mlppp-base, is-mlppp
Changes since 1.25: +19 -19 lines
Diff to previous 1.25 (colored) to selected 1.128 (colored)

use stdarg, annotate function as __printflike and fix broken formats.

Revision 1.23.14.1 / (download) - annotate - [select for diffs], Mon Jun 10 22:10:20 2019 UTC (4 years, 10 months ago) by christos
Branch: phil-wifi
Changes since 1.23: +1194 -1198 lines
Diff to previous 1.23 (colored) to selected 1.128 (colored)

Sync with HEAD

Revision 1.1.1.2 / (download) - annotate - [select for diffs] (vendor branch), Thu Apr 4 20:39:17 2019 UTC (5 years ago) by kamil
Branch: FREEBSD, CSRG
CVS Tags: r340138
Changes since 1.1.1.1: +569 -457 lines
Diff to previous 1.1.1.1 (colored) to selected 1.128 (colored)

FreeBSD indent r340138

Revision 1.25 / (download) - annotate - [select for diffs], Thu Apr 4 15:22:13 2019 UTC (5 years ago) by kamil
Branch: MAIN
CVS Tags: phil-wifi-20190609, netbsd-9-base, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9
Changes since 1.24: +1194 -1201 lines
Diff to previous 1.24 (colored) to selected 1.128 (colored)

Upgrade indent(1)

Merge all the changes from the recent FreeBSD HEAD snapshot
into our local copy.

FreeBSD actively maintains this program in their sources and their
repository contains over 100 commits with changes.

Keep the delta between the FreeBSD and NetBSD versions to absolute
minimum, mostly RCS Id and compatiblity fixes.

Major chages in this import:

 - Added an option -ldi<N> to control indentation of local variable names.
 - Added option -P for loading user-provided files as profiles
 - Added -tsn for setting tabsize
 - Rename -nsac/-sac ("space after cast") to -ncs/-cs
 - Added option -fbs Enables (disables) splitting the function declaration and opening brace across two lines.
 - Respect SIMPLE_BACKUP_SUFFIX environment variable in indent(1)
 - Group global option variables into an options structure
 - Use bsearch() for looking up type keywords.
 - Don't produce unneeded space character in function declarators
 - Don't unnecessarily add a blank before a comment ends.
 - Don't ignore newlines after comments that follow braces.

Merge the FreeBSD intend(1) tests with our ATF framework.
All tests pass.

Upgrade prepared by Manikishan Ghantasala.
Final polishing by myself.

Revision 1.24 / (download) - annotate - [select for diffs], Sun Feb 3 03:19:29 2019 UTC (5 years, 2 months ago) by mrg
Branch: MAIN
Changes since 1.23: +5 -2 lines
Diff to previous 1.23 (colored) to selected 1.128 (colored)

- add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
  this case, and thus can't be marked __dead easily

Revision 1.23 / (download) - annotate - [select for diffs], Mon Sep 5 00:40:29 2016 UTC (7 years, 7 months ago) by sevan
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan
Branch point for: phil-wifi
Changes since 1.22: +2 -4 lines
Diff to previous 1.22 (colored) to selected 1.128 (colored)

Drop main() prototype.

Revision 1.22 / (download) - annotate - [select for diffs], Thu Feb 25 13:23:27 2016 UTC (8 years, 1 month ago) by ginsbach
Branch: MAIN
CVS Tags: pgoyette-localcount-base, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount
Changes since 1.21: +17 -17 lines
Diff to previous 1.21 (colored) to selected 1.128 (colored)

Fix obvious contraction spelling mistakes by adding missing apostrophes.

Revision 1.21 / (download) - annotate - [select for diffs], Mon Feb 22 22:01:48 2016 UTC (8 years, 1 month ago) by ginsbach
Branch: MAIN
Changes since 1.20: +3 -3 lines
Diff to previous 1.20 (colored) to selected 1.128 (colored)

Use warnx(3).

Revision 1.20 / (download) - annotate - [select for diffs], Mon Feb 22 19:04:18 2016 UTC (8 years, 1 month ago) by ginsbach
Branch: MAIN
Changes since 1.19: +4 -6 lines
Diff to previous 1.19 (colored) to selected 1.128 (colored)

Use errx(3).

Revision 1.18.24.1 / (download) - annotate - [select for diffs], Sun Sep 21 18:58:56 2014 UTC (9 years, 6 months ago) by snj
Branch: netbsd-7
CVS Tags: netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0
Changes since 1.18: +39 -4 lines
Diff to previous 1.18 (colored) next main 1.19 (colored) to selected 1.128 (colored)

Pull up following revision(s) (requested by mrg in ticket #110):
	usr.bin/indent/io.c: revision 1.15
	usr.bin/indent/indent_globs.h: revision 1.10
	usr.bin/indent/args.c: revision 1.11
	usr.bin/indent/indent.1: revision 1.23
	usr.bin/indent/indent.c: revision 1.19
port the -ut / -nut options from freebsd.  -ut (default) enables tabs
in output, the -nut uses spaces.

Revision 1.19 / (download) - annotate - [select for diffs], Thu Sep 4 04:06:07 2014 UTC (9 years, 7 months ago) by mrg
Branch: MAIN
Changes since 1.18: +39 -4 lines
Diff to previous 1.18 (colored) to selected 1.128 (colored)

port the -ut / -nut options from freebsd.  -ut (default) enables tabs
in output, the -nut uses spaces.

Revision 1.17.6.1 / (download) - annotate - [select for diffs], Wed May 13 19:19:52 2009 UTC (14 years, 11 months ago) by jym
Branch: jym-xensuspend
Changes since 1.17: +12 -12 lines
Diff to previous 1.17 (colored) next main 1.18 (colored) to selected 1.128 (colored)

Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html

Revision 1.18 / (download) - annotate - [select for diffs], Sun Apr 12 11:09:49 2009 UTC (15 years ago) by lukem
Branch: MAIN
CVS Tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, netbsd-7-base, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-premerge-20091211, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, jym-xensuspend-nbase, jym-xensuspend-base, cherry-xenmp-base, cherry-xenmp, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver
Branch point for: netbsd-7
Changes since 1.17: +12 -12 lines
Diff to previous 1.17 (colored) to selected 1.128 (colored)

Fix WARNS=4 issues (-Wshadow -Wcast-qual -Wsign-compare)

Revision 1.16.28.1 / (download) - annotate - [select for diffs], Thu Sep 18 04:29:13 2008 UTC (15 years, 7 months ago) by wrstuden
Branch: wrstuden-revivesa
Changes since 1.16: +6 -6 lines
Diff to previous 1.16 (colored) next main 1.17 (colored) to selected 1.128 (colored)

Sync with wrstuden-revivesa-base-2.

Revision 1.17 / (download) - annotate - [select for diffs], Mon Jul 21 14:19:23 2008 UTC (15 years, 8 months ago) by lukem
Branch: MAIN
CVS Tags: wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-base2
Branch point for: jym-xensuspend
Changes since 1.16: +6 -6 lines
Diff to previous 1.16 (colored) to selected 1.128 (colored)

Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.

Revision 1.16 / (download) - annotate - [select for diffs], Sat Oct 30 17:45:34 2004 UTC (19 years, 5 months ago) by dsl
Branch: MAIN
CVS Tags: yamt-pf42-baseX, yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, yamt-pf42-base, yamt-pf42, wrstuden-revivesa-base-1, wrstuden-revivesa-base, wrstuden-fixsa-newbase, wrstuden-fixsa-base-1, wrstuden-fixsa-base, wrstuden-fixsa, netbsd-4-base, netbsd-4-0-RELEASE, netbsd-4-0-RC5, netbsd-4-0-RC4, netbsd-4-0-RC3, netbsd-4-0-RC2, netbsd-4-0-RC1, netbsd-4-0-1-RELEASE, netbsd-4-0, netbsd-4, netbsd-3-base, netbsd-3-1-RELEASE, netbsd-3-1-RC4, netbsd-3-1-RC3, netbsd-3-1-RC2, netbsd-3-1-RC1, netbsd-3-1-1-RELEASE, netbsd-3-1, netbsd-3-0-RELEASE, netbsd-3-0-RC6, netbsd-3-0-RC5, netbsd-3-0-RC4, netbsd-3-0-RC3, netbsd-3-0-RC2, netbsd-3-0-RC1, netbsd-3-0-3-RELEASE, netbsd-3-0-2-RELEASE, netbsd-3-0-1-RELEASE, netbsd-3-0, netbsd-3, matt-mips64-base, matt-mips64, matt-armv6-prevmlocking, matt-armv6-nbase, matt-armv6-base, matt-armv6, keiichi-mipv6-nbase, keiichi-mipv6-base, keiichi-mipv6, hpcarm-cleanup-nbase, hpcarm-cleanup-base, hpcarm-cleanup, cube-autoconf-base, cube-autoconf, chap-midi-nbase, chap-midi-base, chap-midi, abandoned-netbsd-4-base, abandoned-netbsd-4
Branch point for: wrstuden-revivesa
Changes since 1.15: +5 -4 lines
Diff to previous 1.15 (colored) to selected 1.128 (colored)

Add (unsigned char) cast to ctype functions

Revision 1.15 / (download) - annotate - [select for diffs], Thu Aug 7 11:14:08 2003 UTC (20 years, 8 months ago) by agc
Branch: MAIN
CVS Tags: netbsd-2-base, netbsd-2-1-RELEASE, netbsd-2-1-RC6, netbsd-2-1-RC5, netbsd-2-1-RC4, netbsd-2-1-RC3, netbsd-2-1-RC2, netbsd-2-1-RC1, netbsd-2-1, netbsd-2-0-base, netbsd-2-0-RELEASE, netbsd-2-0-RC5, netbsd-2-0-RC4, netbsd-2-0-RC3, netbsd-2-0-RC2, netbsd-2-0-RC1, netbsd-2-0-3-RELEASE, netbsd-2-0-2-RELEASE, netbsd-2-0-1-RELEASE, netbsd-2-0, netbsd-2
Changes since 1.14: +29 -2 lines
Diff to previous 1.14 (colored) to selected 1.128 (colored)

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.

Revision 1.14 / (download) - annotate - [select for diffs], Thu Jun 19 15:45:22 2003 UTC (20 years, 10 months ago) by christos
Branch: MAIN
Changes since 1.13: +5 -2 lines
Diff to previous 1.13 (colored) to selected 1.128 (colored)

PR/21645: Mishka: Localized comments don't work with indent.

Revision 1.13 / (download) - annotate - [select for diffs], Sun May 26 22:53:38 2002 UTC (21 years, 10 months ago) by wiz
Branch: MAIN
CVS Tags: fvdl_fs64_base
Changes since 1.12: +5 -7 lines
Diff to previous 1.12 (colored) to selected 1.128 (colored)

Remove #ifndef'd __STDC__ code. ANSIfy.

Revision 1.12 / (download) - annotate - [select for diffs], Mon Aug 20 12:00:55 2001 UTC (22 years, 8 months ago) by wiz
Branch: MAIN
CVS Tags: netbsd-1-6-base, netbsd-1-6-RELEASE, netbsd-1-6-RC3, netbsd-1-6-RC2, netbsd-1-6-RC1, netbsd-1-6-PATCH002-RELEASE, netbsd-1-6-PATCH002-RC4, netbsd-1-6-PATCH002-RC3, netbsd-1-6-PATCH002-RC2, netbsd-1-6-PATCH002-RC1, netbsd-1-6-PATCH002, netbsd-1-6-PATCH001-RELEASE, netbsd-1-6-PATCH001-RC3, netbsd-1-6-PATCH001-RC2, netbsd-1-6-PATCH001-RC1, netbsd-1-6-PATCH001, netbsd-1-6
Changes since 1.11: +3 -3 lines
Diff to previous 1.11 (colored) to selected 1.128 (colored)

precede, not preceed.

Revision 1.11 / (download) - annotate - [select for diffs], Sat Jun 16 21:47:42 2001 UTC (22 years, 10 months ago) by kleink
Branch: MAIN
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored) to selected 1.128 (colored)

Handle a labeled statement at the beginning of a function correctly;
from Nagae Hidetake <nagae@tk.airnet.ne.jp> in PR bin/12781.

Revision 1.10 / (download) - annotate - [select for diffs], Sat Dec 19 17:00:08 1998 UTC (25 years, 4 months ago) by christos
Branch: MAIN
CVS Tags: wrstuden-devbsize-base, wrstuden-devbsize-19991221, wrstuden-devbsize, netbsd-1-5-base, netbsd-1-5-RELEASE, netbsd-1-5-PATCH003, netbsd-1-5-PATCH002, netbsd-1-5-PATCH001, netbsd-1-5-BETA2, netbsd-1-5-BETA, netbsd-1-5-ALPHA2, netbsd-1-5, netbsd-1-4-base, netbsd-1-4-RELEASE, netbsd-1-4-PATCH003, netbsd-1-4-PATCH002, netbsd-1-4-PATCH001, netbsd-1-4, minoura-xpg4dl-base, minoura-xpg4dl, comdex-fall-1999-base, comdex-fall-1999
Changes since 1.9: +7 -7 lines
Diff to previous 1.9 (colored) to selected 1.128 (colored)

char -> unsigned char, braces for gcc-2.8.1

Revision 1.9 / (download) - annotate - [select for diffs], Thu Oct 8 01:30:27 1998 UTC (25 years, 6 months ago) by wsanchez
Branch: MAIN
Changes since 1.8: +4 -2 lines
Diff to previous 1.8 (colored) to selected 1.128 (colored)

Get rid of multiply defined common symbols

Revision 1.8 / (download) - annotate - [select for diffs], Sun Sep 6 20:17:30 1998 UTC (25 years, 7 months ago) by mellon
Branch: MAIN
Changes since 1.7: +4 -5 lines
Diff to previous 1.7 (colored) to selected 1.128 (colored)

Support indenting standard input.   When indenting standard input, write output to standard output.

Revision 1.7 / (download) - annotate - [select for diffs], Tue Aug 25 20:59:37 1998 UTC (25 years, 7 months ago) by ross
Branch: MAIN
Changes since 1.6: +6 -4 lines
Diff to previous 1.6 (colored) to selected 1.128 (colored)

Add { and } to shut up egcs. Reformat the more questionable code.

Revision 1.6 / (download) - annotate - [select for diffs], Sun Oct 19 03:17:17 1997 UTC (26 years, 6 months ago) by lukem
Branch: MAIN
CVS Tags: netbsd-1-3-base, netbsd-1-3-RELEASE, netbsd-1-3-PATCH003-CANDIDATE2, netbsd-1-3-PATCH003-CANDIDATE1, netbsd-1-3-PATCH003-CANDIDATE0, netbsd-1-3-PATCH003, netbsd-1-3-PATCH002, netbsd-1-3-PATCH001, netbsd-1-3-BETA, netbsd-1-3
Changes since 1.5: +1118 -1055 lines
Diff to previous 1.5 (colored) to selected 1.128 (colored)

WARNSify, fix .Nm usage, deprecate register, use <err.h>, KNFify (with indent!;)

Revision 1.5 / (download) - annotate - [select for diffs], Sat Oct 18 16:04:33 1997 UTC (26 years, 6 months ago) by mrg
Branch: MAIN
Changes since 1.4: +12 -8 lines
Diff to previous 1.4 (colored) to selected 1.128 (colored)

merge lite-2.

Revision 1.4 / (download) - annotate - [select for diffs], Thu Jan 9 20:20:11 1997 UTC (27 years, 3 months ago) by tls
Branch: MAIN
Changes since 1.3: +3 -1 lines
Diff to previous 1.3 (colored) to selected 1.128 (colored)

RCS ID police

Revision 1.3 / (download) - annotate - [select for diffs], Tue May 7 18:32:28 1996 UTC (27 years, 11 months ago) by jtc
Branch: MAIN
CVS Tags: netbsd-1-2-base, netbsd-1-2-RELEASE, netbsd-1-2-PATCH001, netbsd-1-2-BETA, netbsd-1-2
Changes since 1.2: +2 -4 lines
Diff to previous 1.2 (colored) to selected 1.128 (colored)

Include appropriate header files to bring prototypes into scope.
Removed explicit errno declarations.

Revision 1.2 / (download) - annotate - [select for diffs], Sun Aug 1 18:14:33 1993 UTC (30 years, 8 months ago) by mycroft
Branch: MAIN
CVS Tags: netbsd-1-1-base, netbsd-1-1-RELEASE, netbsd-1-1-PATCH001, netbsd-1-1, netbsd-1-0-base, netbsd-1-0-RELEASE, netbsd-1-0-PATCH1, netbsd-1-0-PATCH06, netbsd-1-0-PATCH05, netbsd-1-0-PATCH04, netbsd-1-0-PATCH03, netbsd-1-0-PATCH02, netbsd-1-0-PATCH0, netbsd-1-0
Changes since 1.1: +2 -1 lines
Diff to previous 1.1 (colored) to selected 1.128 (colored)

Add RCS identifiers.

Revision 1.1.1.1 / (download) - annotate - [select for diffs] (vendor branch), Tue Jun 8 03:22:08 1993 UTC (30 years, 10 months ago) by mrg
Branch: FREEBSD, CSRG
CVS Tags: lite-2
Changes since 1.1: +6 -6 lines
Diff to previous 1.1 (colored) to selected 1.128 (colored)

4.4BSD-Lite2

Revision 1.1 / (download) - annotate - [select for diffs], Fri Apr 9 12:59:10 1993 UTC (31 years ago) by cgd
Branch: MAIN
CVS Tags: netbsd-alpha-1, netbsd-0-9-base, netbsd-0-9-RELEASE, netbsd-0-9-BETA, netbsd-0-9-ALPHA2, netbsd-0-9-ALPHA, netbsd-0-9, netbsd-0-8
Diff to selected 1.128 (colored)

added, from net/2 (patch 124).

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.




CVSweb <webmaster@jp.NetBSD.org>