| Age | Commit message (Collapse) | Author |
|
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.
|
|
No binary change.
|
|
|
|
|
|
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.
|
|
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.
|
|
They were handled in exactly the same way.
|
|
For several parser symbols, 2 symbols are pushed in a row, which led to
an out-of-bounds write.
|
|
|
|
|
|
No functional change.
|
|
No functional change.
|
|
One less moving part to keep track of.
No functional change.
|
|
No binary change.
|
|
|
|
No functional change.
|
|
|
|
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.
|
|
No functional change.
|
|
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.
|
|
|
|
With manual corrections, as there are still some bugs left.
No functional change.
|
|
|
|
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.
|
|
|
|
No functional change.
|
|
No functional change outside debug mode.
|
|
|
|
No functional change outside debug mode.
|
|
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.
|
|
Most of the IDs were empty anyway.
|
|
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.
|
|
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.
|
|
The comments only repeated what the constants for the parser symbols
already express in their names. In the past, the names of these
constants were inconsistent and misleading; back then, it made sense to
make the comments express the actual meaning of the constants.
|
|
No functional change.
|
|
No functional change.
|
|
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.
|
|
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.
|
|
When the parse stack is manipulated, the text of the token is not
relevant anymore and may even be confusing, for example when parsing
if_expr, the token may contain "}".
|
|
No functional change.
|
|
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.
|
|
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.
|
|
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.
|
|
No functional change.
|
|
No functional change.
|
|
No functional change.
|
|
No functional change.
|
|
No functional change.
|
|
No functional change.
|
|
No functional change.
|