rillig
97817c96ae
indent: be strict about options from profile files
...
Previously, the "option" 'xdi0' was treated the same as '-xdi0'.
2023-12-10 17:45:35 +00:00
rillig
dd8677cc23
indent: inline input-related macros
...
No binary change.
2023-12-03 21:44:42 +00:00
rillig
0d9586f97c
indent: group input-related variables into a struct
...
No functional change.
2023-12-03 21:40:44 +00:00
rillig
1cdfe3a93c
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.
2023-12-03 21:03:58 +00:00
rillig
18692033dc
indent: fix line number counting in function definition
...
In a function definition that is split on two lines, if the first line
ends with a '*', the following line break didn't include the line
number.
2023-12-03 20:42:31 +00:00
rillig
f6c6195c8b
indent: fix 'blank line above first statement in function body'
2023-06-27 04:41:23 +00:00
rillig
45e235d0ba
indent: improve heuristics for '*' as pointer in for loops
2023-06-26 20:23:40 +00:00
rillig
0982504e1c
indent: improve heuristics for '*' as a pointer type
2023-06-26 20:10:23 +00:00
rillig
f73b959d75
indent: implement 'blank line above first statement in function body'
2023-06-26 20:03:09 +00:00
rillig
b54a4db2fc
indent: in -bad mode, don't add a blank line above a comment or '}'
2023-06-26 14:54:40 +00:00
rillig
25ae258068
indent: clean up indentation
2023-06-26 10:23:59 +00:00
rillig
8cbb631b73
indent: move cast detection from the lexer to the main processor
...
It is not the job of the lexer to modify the parser state.
2023-06-25 19:35:45 +00:00
rillig
ac483ee881
indent: treat 'complex' and 'imaginary' as type modifiers, not as types
2023-06-25 19:29:57 +00:00
rillig
9745d1edfa
indent: fix formatting of parenthesized name in function definition
2023-06-25 19:19:42 +00:00
rillig
4c65208bc4
indent: don't use strspn on inp_p, as it is not null-terminated
...
No functional change.
2023-06-25 18:41:03 +00:00
rillig
12dc98af47
indent: fix scanning of no-wrap comments (since 2021.11.07.10.34.03)
...
The "refactoring" back then tried to be too clever.
2023-06-23 20:59:04 +00:00
rillig
1fe8cbaafa
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.
2023-06-23 20:43:21 +00:00
rillig
c4d462617d
indent: only add blank lines before actual block comments
2023-06-18 07:32:33 +00:00
rillig
926f8bd544
indent: remove support for backspace in code and comments
...
The C code in the whole tree does not contain a single literal
backspace.
2023-06-18 07:10:24 +00:00
rillig
5af61aec35
indent: untangle code for handling the statement indentation
...
The expression 'psyms.level-- - 2' did too much in a single line, so
extract the '--' to a separate statement, to highlight the symmetry
between the 'sym' and 'ind_level' code.
No functional change.
2023-06-18 06:56:32 +00:00
rillig
519ec34df3
indent: clean up
...
Extract duplicate code for handling line continuations.
Prevent theoretic undefined behavior in strspn, as inp.s is not
null-terminated.
Remove adding extra space characters when processing comments, as these
are not necessary to force a line of output.
No functional change.
2023-06-17 23:03:20 +00:00
rillig
8e0980dcd7
indent: miscellaneous cleanups
...
No binary change.
2023-06-17 22:28:49 +00:00
rillig
abc3274d3a
indent: merge lexer symbols for type in/outside parentheses
2023-06-16 23:51:31 +00:00
rillig
c4d54aec81
indent: add debug output for typedef declarations
2023-06-16 23:17:22 +00:00
rillig
398514d353
indent: fix spacing between postfix operator and left parenthesis
2023-06-16 23:07:52 +00:00
rillig
2fbaf64cd1
indent: improve heuristics for cast expressions
2023-06-16 14:26:26 +00:00
rillig
12ea422e44
indent: improve heuristics for cast expressions
2023-06-16 14:12:10 +00:00
rillig
44e3c9f8ad
indent: improve heuristics for casts
2023-06-16 12:55:57 +00:00
rillig
7983032213
indent: fix indentation and linebreaks in typedef declarations
2023-06-16 12:30:45 +00:00
rillig
8535e877f0
indent: don't force a blank line between '}' and preprocessing line
2023-06-16 11:48:32 +00:00
rillig
37a177106a
indent: rename a field of the parser state
...
The previous name 'comment_in_first_line' was misleading, as it could
mean that there was a comment in the first line of the file.
No functional change.
2023-06-16 11:27:49 +00:00
rillig
fd97c19dff
indent: consolidate handling of statement continuations
2023-06-15 11:27:36 +00:00
rillig
5a6a9cd4c2
indent: rename state variable to be more accurate
...
No binary change.
2023-06-15 10:59:06 +00:00
rillig
14063fa4b7
indent: fix indentation of multi-line enum constant initializers
2023-06-15 10:34:12 +00:00
rillig
0982fd88d1
indent: miscellaneous cleanups, more tests for edge cases
2023-06-15 09:19:06 +00:00
rillig
f0cb29371b
indent: fix alignment of multi-line declarations
2023-06-15 08:40:20 +00:00
rillig
398feb82dc
indent: reduce number of relocations
...
Since all command line options modify a member of struct options, there
is no need to encode that relocation 38 times.
No functional change.
2023-06-14 21:35:01 +00:00
rillig
940b85009c
indent: clean up the code, add a few tests
2023-06-14 20:46:08 +00:00
rillig
cdfe968337
indent: allow more than 128 brace levels
2023-06-14 19:05:40 +00:00
rillig
856f35def8
indent: fix out-of-bounds read when reducing a statement
...
Since parse.c 1.73 from today. The parser symbol psym_stmt_list that was
removed in that commit acted as a stop symbol, so that psyms_reduce_stmt
would save a memory access.
2023-06-14 17:52:45 +00:00
rillig
d0e2347d25
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.
2023-06-14 16:14:30 +00:00
rillig
641fe74526
indent: allow more than 20 nested parentheses or brackets
2023-06-14 14:11:28 +00:00
rillig
300c5f7f19
indent: merge duplicate code
2023-06-14 13:15:30 +00:00
rillig
ddbd65a192
indent: fix formatting of comment after 'switch (expr)'
2023-06-14 11:18:09 +00:00
rillig
557ed6ed5d
indent: use correct preprocessing directive in error message
2023-06-14 10:29:52 +00:00
rillig
d2103f1c62
indent: allow more than 5 levels of #if/#endif
2023-06-14 10:26:00 +00:00
rillig
b520fe89c4
indent: clean up debugging code
2023-06-14 09:57:02 +00:00
rillig
ed7b435925
indent: clean up handling of comments
...
One less moving part in the parser state.
No functional change.
2023-06-14 09:31:05 +00:00
rillig
bf8496de58
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.
2023-06-14 08:36:51 +00:00
rillig
61c5d6b6d0
indent: remove a redundant flag from the parser state
...
No functional change.
2023-06-14 08:25:15 +00:00