Home | History | Annotate | Download | only in indent
History log of /src/usr.bin/indent/debug.c
RevisionDateAuthorComments
 1.74  04-Jan-2025  rillig indent: make debug log more uniform
 1.73  04-Jan-2025  rillig indent: make debug output easier readable

The previous format had the values of the parser state on the left side
and the corresponding names on the right side. While it looked nicely
aligned, it was not suitable for focusing on the actual data. Replace
this format with the more common "key: value" format.

Use the names of the enum constants in the debug log, instead of the
previous "nice" names that needed one more level of mental translation
and in some cases contained unbalanced punctuation such as '{'.
 1.72  03-Jan-2025  rillig indent: fix line breaks in else-if sequences

The flag ps.want_newline did not adequately model the conditions under
which a line break should be inserted, thus the redesign.

A welcome side effect is that in statements like 'if (cond);', the
semicolon is now placed on a separate line, thus becoming more visible.
 1.71  12-Dec-2024  rillig indent: add error handling for I/O errors

Suggested by lint2.
 1.70  27-Jun-2023  rillig indent: fix 'blank line above first statement in function body'
 1.69  26-Jun-2023  rillig indent: implement 'blank line above first statement in function body'
 1.68  23-Jun-2023  rillig 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.
 1.67  17-Jun-2023  rillig indent: miscellaneous cleanups

No binary change.
 1.66  16-Jun-2023  rillig indent: merge lexer symbols for type in/outside parentheses
 1.65  16-Jun-2023  rillig indent: add debug output for typedef declarations
 1.64  16-Jun-2023  rillig indent: don't force a blank line between '}' and preprocessing line
 1.63  16-Jun-2023  rillig 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.
 1.62  15-Jun-2023  rillig indent: rename state variable to be more accurate

No binary change.
 1.61  14-Jun-2023  rillig indent: clean up the code, add a few tests
 1.60  14-Jun-2023  rillig 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.
 1.59  14-Jun-2023  rillig indent: allow more than 20 nested parentheses or brackets
 1.58  14-Jun-2023  rillig indent: clean up debugging code
 1.57  14-Jun-2023  rillig indent: clean up handling of comments

One less moving part in the parser state.

No functional change.
 1.56  14-Jun-2023  rillig 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.
 1.55  14-Jun-2023  rillig indent: remove a redundant flag from the parser state

No functional change.
 1.54  14-Jun-2023  rillig indent: merge parser symbols for stmt and stmt_list

They were handled in exactly the same way.
 1.53  10-Jun-2023  rillig 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.
 1.52  10-Jun-2023  rillig 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.
 1.51  10-Jun-2023  rillig indent: fix line break between semicolon and brace
 1.50  10-Jun-2023  rillig indent: miscellaneous cleanups
 1.49  10-Jun-2023  rillig indent: clean up function names, fix blank lines in debug output
 1.48  10-Jun-2023  rillig indent: distinguish blank lines from newline characters
 1.47  10-Jun-2023  rillig indent: clean up debug output

In diff mode, don't print a diff of the very first parser state, instead
print its full state.

Don't print headings for empty sections of the parser state.
 1.46  10-Jun-2023  rillig indent: clean up function and variable names
 1.45  10-Jun-2023  rillig indent: explain right-aligned code
 1.44  10-Jun-2023  rillig indent: rename and sort variables in parser state

No functional change.
 1.43  09-Jun-2023  rillig indent: sync debug information for lexer symbols
 1.42  09-Jun-2023  rillig indent: don't treat function call expressions as cast expressions
 1.41  09-Jun-2023  rillig 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.
 1.40  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.39  07-Jun-2023  rillig indent: extract the stack of parser symbols to a separate struct

No functional change.
 1.38  07-Jun-2023  rillig indent: send all debug output to the same stream
 1.37  06-Jun-2023  rillig indent: sort functions in call order

No functional change.
 1.36  05-Jun-2023  rillig indent: improve layout of debug output
 1.35  05-Jun-2023  rillig indent: sync debug output with parser state
 1.34  04-Jun-2023  rillig 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.
 1.33  04-Jun-2023  rillig indent: track the kind of '{' on the parser stack
 1.32  04-Jun-2023  rillig indent: fix debug output of the parser symbol stack

Even though the stack always contains a stmt_list as first element,
print it nevertheless to avoid confusion about starting at index 1, and
to provide the full picture.
 1.31  04-Jun-2023  rillig indent: rename struct field, for better symmetry

No binary change outside debug mode.
 1.30  04-Jun-2023  rillig 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.
 1.29  04-Jun-2023  rillig indent: classify 'inline' as a modifier rather than a word
 1.28  04-Jun-2023  rillig indent: use separate lexer symbols for the different kinds of ':'
 1.27  04-Jun-2023  rillig indent: handle the indentation of 'case' in a simpler way
 1.26  04-Jun-2023  rillig indent: separate code for handling parentheses and brackets

Handling parentheses is more complicated than for brackets.
 1.25  02-Jun-2023  rillig 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.
 1.24  02-Jun-2023  rillig indent: fix formatting of declarations with preprocessing lines
 1.23  23-May-2023  rillig indent: fix indentation of struct declarations
 1.22  23-May-2023  rillig 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.
 1.21  23-May-2023  rillig indent: fix spacing in declarations in for loops
 1.20  22-May-2023  rillig indent: implement suppressing optional blank lines
 1.19  20-May-2023  rillig indent: extract the output state from the parser state

The parser state depends on the preprocessing lines, the output state
shouldn't.
 1.18  20-May-2023  rillig indent: implement blank line above block comment
 1.17  20-May-2023  rillig indent: implement blank line after function body
 1.16  20-May-2023  rillig indent: implement blank lines around conditional compilation
 1.15  20-May-2023  rillig indent: add debug logging for brace indentation

No functional change outside debug mode, as the initialization of
di_stack[0] was redundant.
 1.14  18-May-2023  rillig indent: manually wrap overly long lines

No functional change.
 1.13  18-May-2023  rillig 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.
 1.12  17-May-2023  rillig indent: fix indentation in preprocessor line

No binary change.
 1.11  16-May-2023  rillig indent: allow comments in column 1 to be formatted
 1.10  16-May-2023  rillig 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.
 1.9  15-May-2023  rillig indent: clean up detection of whether parentheses form a cast

No functional change.
 1.8  15-May-2023  rillig indent: indent multi-line conditions

No functional change.
 1.7  15-May-2023  rillig indent: document feature toggle for debugging output
 1.6  15-May-2023  rillig indent: move debugging code to separate file

No functional change.
 1.5  15-May-2023  rillig 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.
 1.4  13-May-2023  rillig indent: implement 'blank after declarations'
 1.3  13-May-2023  rillig indent: use enum instead of magic numbers for tracking declarations

No functional change.
 1.2  13-May-2023  rillig indent: add debug logging for enum token classification
 1.1  13-May-2023  rillig indent: move debugging code to separate file

No functional change.

RSS XML Feed