History log of /src/tests/usr.bin/indent/fmt_decl.c |
Revision | | Date | Author | Comments |
1.60 |
| 25-Jun-2023 |
rillig | indent: fix formatting of parenthesized name in function definition
|
1.59 |
| 16-Jun-2023 |
rillig | indent: merge lexer symbols for type in/outside parentheses
|
1.58 |
| 16-Jun-2023 |
rillig | indent: fix indentation and linebreaks in typedef declarations
|
1.57 |
| 15-Jun-2023 |
rillig | indent: miscellaneous cleanups, more tests for edge cases
|
1.56 |
| 15-Jun-2023 |
rillig | indent: fix alignment of multi-line declarations
|
1.55 |
| 14-Jun-2023 |
rillig | indent: clean up the code, add a few tests
|
1.54 |
| 10-Jun-2023 |
rillig | tests/indent: add move coverage tests
|
1.53 |
| 10-Jun-2023 |
rillig | indent: rename and sort variables in parser state
No functional change.
|
1.52 |
| 09-Jun-2023 |
rillig | indent: improve heuristics for function declaration vs. definition
|
1.51 |
| 09-Jun-2023 |
rillig | tests/indent: add real-life test cases from make(1) and lint(1)
|
1.50 |
| 08-Jun-2023 |
rillig | 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.
|
1.49 |
| 05-Jun-2023 |
rillig | tests/indent: add test for left-justifying declarations
|
1.48 |
| 02-Jun-2023 |
rillig | indent: remove newline between 'switch' and '{'
|
1.47 |
| 02-Jun-2023 |
rillig | indent: improve heuristics of classifying '*' as pointer or operator
|
1.46 |
| 23-May-2023 |
rillig | indent: fix indentation of struct declarations
|
1.45 |
| 23-May-2023 |
rillig | indent: fix spacing around '*' in declarations
|
1.44 |
| 23-May-2023 |
rillig | tests/indent: add code snippets found in make and lint1
|
1.43 |
| 16-May-2023 |
rillig | indent: remove blank between comment and parentheses or brackets
Finally, indent formats its own source code without messing up the layout.
|
1.42 |
| 15-May-2023 |
rillig | indent: fix detection of casts
A word followed by a '(' does not start a cast expression.
|
1.41 |
| 15-May-2023 |
rillig | indent: fix type cast in function definition
|
1.40 |
| 15-May-2023 |
rillig | tests/indent: demonstrate wrong spacing after function prototype
|
1.39 |
| 15-May-2023 |
rillig | indent: fix spacing between function prototype and attributes
|
1.38 |
| 13-May-2023 |
rillig | tests/indent: explain, clean up and add some tests
|
1.37 |
| 11-May-2023 |
rillig | 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.
|
1.36 |
| 24-Apr-2022 |
rillig | tests/indent: migrate token tests to other tests
In indent.h 1.49 from 2021-10-25, the enumeration token_type was split into lexer_symbol and parser_symbol to more clearly express that these tokens fall into completely different classes of usage patterns.
|
1.35 |
| 24-Apr-2022 |
rillig | tests/indent: change directive from '#' to '//'
Using a '//' instead of '#' turns the directives into well-formed C code, resulting in fewer error markers in the editor.
|
1.34 |
| 24-Apr-2022 |
rillig | tests/indent: normalize amount of empty lines between test cases
|
1.33 |
| 22-Apr-2022 |
rillig | indent: remove FreeBSD IDs
Most of the IDs were empty anyway.
|
1.32 |
| 27-Nov-2021 |
rillig | indent: fix out of bounds memory access (since 2021-11-25)
|
1.31 |
| 27-Nov-2021 |
rillig | tests/indent: demonstrate strange formatting (since 2021-11-25)
|
1.30 |
| 25-Nov-2021 |
rillig | tests/indent: fix misleading typedef name
|
1.29 |
| 25-Nov-2021 |
rillig | indent: improve heuristic for spaces around '*' in declarations
|
1.28 |
| 25-Nov-2021 |
rillig | tests/indent: demonstrate more example for broken '*' in declarations
Since indent-2021.11.25.16.41.33.
|
1.27 |
| 25-Nov-2021 |
rillig | indent: fix heuristic for declaration/definition to post-1990 reality
|
1.26 |
| 25-Nov-2021 |
rillig | indent: fix spacing for unknown type names in declarations
|
1.25 |
| 25-Nov-2021 |
rillig | tests/indent: test '*' in function declarations
|
1.24 |
| 25-Nov-2021 |
rillig | indent: fix formatting of a few declarations involving unknown types
|
1.23 |
| 24-Nov-2021 |
rillig | tests/indent: demonstrate several real-life formatting bugs
Collected by indenting usr.bin/make with the default profile.
The heuristic for distinguishing between type names and other identifiers is way too primitive, it seems to have stopped evolving somewhere before function prototypes were standardized in C90, at least it handles function prototypes poorly.
indent-2014.09.04.04.06.07 added seemingly random spaces to declarations, which were fixed in indent-2019.04.04.15.27.35, which came 5 years later. The latter commit introduced many new bugs, but it also fixed this one.
The wrongly indented struct member declaration for HashTable has been there since at least indent-2000.10.11.14.46.04.
The wrongly indented initializer expression was added in indent-2019.04.04.15.27.35 (see above).
|
1.22 |
| 21-Nov-2021 |
rillig | tests/indent: demonstrate wrong formatting of type names in declarations
|
1.21 |
| 20-Nov-2021 |
rillig | tests/indent: normalize empty lines in tests
|
1.20 |
| 20-Nov-2021 |
rillig | indent: clean up lint annotation and tests
|
1.19 |
| 19-Nov-2021 |
rillig | tests/indent: refine and extend tests
|
1.18 |
| 19-Nov-2021 |
rillig | indent: fix formatting of function definitions (since 2019-04-04)
In the definition of a function with a pointer return type, the formatting depended on the name of the function. Function names matching [A-Za-z+] were formatted correctly, those containing [$0-9_] weren't.
|
1.17 |
| 19-Nov-2021 |
rillig | tests/indent: update comment for the fix from the previous commit
|
1.16 |
| 19-Nov-2021 |
rillig | indent: fix lost function name (since 2019-04-04)
When indent searched for an identifier followed by a '(', to see whether the identifier is a function name, it didn't care that the input buffer could be resized due to a long line, which had made the pointer 'tp' invalid. Fix this by stopping the search at the end of the line. A better approach would be to have an unlimited lookahead buffer for situations like these. The code that deals with character input has already been extracted to io.c, so it's possible to implement that now.
While here, fix another access to undefined memory, after the loop.
There is still the issue of overwriting procname[0] with a blank, which results in inconsistent formatting depending on the function name, probably another case of accessing undefined memory, although the results have been reproducible, but that may have been pure luck.
The formatted code looks clearly broken, but that's still better than losing a token and destroying the whole file.
|
1.15 |
| 18-Nov-2021 |
rillig | tests/indent: demonstrate disappearing function name
Since 2019-04-04, as usual.
|
1.14 |
| 18-Nov-2021 |
rillig | tests/indent: demonstrate another bug imported from FreeBSD
Side note: the newly added test crashes at least the following versions of indent with a segmentation fault on x86_64:
2000.10.11.14.46.04 2000.10.14.18.07.10 2000.10.17.02.16.44 2000.10.19.14.48.53 2000.10.19.16.31.26 2001.03.16.06.23.20 2001.03.23.20.12.41 2001.06.16.21.47.42 2001.07.20.13.43.50 2001.08.20.12.00.55 2001.12.01.19.27.33 2002.05.26.22.53.38 2003.02.25.10.35.44
|
1.13 |
| 07-Nov-2021 |
rillig | indent: rename type_at_paren_level_0 to type_outside_parentheses
For symmetry with type_in_parentheses.
No functional change.
|
1.12 |
| 31-Oct-2021 |
rillig | 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.
|
1.11 |
| 31-Oct-2021 |
rillig | indent: remove support for pre-1978 variable initialization
|
1.10 |
| 31-Oct-2021 |
rillig | tests/indent: test support for ancient initialization without '='
|
1.9 |
| 31-Oct-2021 |
rillig | indent: in debug log, print token subtype in same line
The keyword 'void' is parsed as lsym_type in some cases and lsym_ident in others. Its corresponding keyword is always kw_type though. Put the subtype into the same line as the other token information.
|
1.8 |
| 31-Oct-2021 |
rillig | tests/indent: document that 'void' is not always parsed as a type
|
1.7 |
| 30-Oct-2021 |
rillig | tests/indent: document why declaration lines are broken unnecessarily
|
1.6 |
| 27-Oct-2021 |
rillig | indent: fix indentation of local variable declarations
This had been broken since the import of FreeBSD indent in 2019.
|
1.5 |
| 26-Oct-2021 |
rillig | tests/indent: demonstrate another example of wrong formatting
|
1.4 |
| 26-Oct-2021 |
rillig | tests/indent: demonstrate wrong indentation of local declarations
Reported by RVP via private mail. Importing FreeBSD indent in 2019 fixed the trailing space in line 1, at the cost of lots of other bugs.
indent-2000.10.11.14.46.04 | int <-- trailing space | main(void) | { | char (*f1) () = NULL; | char *(*f1) () = NULL; | char *(*f2) (); | } indent-2019.02.03.03.19.29
indent-2019.04.04.15.27.35 | int | main(void) | { | char (*f1) () = NULL; | char *(* f1) () = NULL; | char *(* f2) (); | } indent-2021.09.30.21.38.43
indent-2021.09.30.21.48.12 | int | main(void) | { | char (*f1)() = NULL; | char *(* f1)() = NULL; | char *(* f2)(); | }
|
1.3 |
| 23-Oct-2021 |
rillig | tests/indent: remove redundant test list_head
The test cases are already in fmt_decl.c, in old_style_definition and LIST_HEAD.
|
1.2 |
| 23-Oct-2021 |
rillig | tests/indent: migrate f_decls to using t_options, add more tests
|
1.1 |
| 22-Oct-2021 |
rillig | tests/indent: migrate a few more tests to t_options
|