Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/usr.bin/indent



Module Name:    src
Committed By:   rillig
Date:           Sun Mar  7 11:32:06 UTC 2021

Modified Files:
        src/usr.bin/indent: indent.h lexi.c parse.c

Log Message:
indent: in debug mode, output detailed token information

The main ingredient for understanding how indent works is the tokenizer
and the 4 buffers in which the text is collected.

Inspecting this debug log for the test comment-line-end makes it obvious
why indent messes up code that contains '//' comments.  The cause is
that indent interprets '//' as an operator, just like '&&' or '||'.  The
sequence '/////' is interpreted as a single operator as well, by the
way.

Since '//' is interpreted as an ordinary operator, any words following
it are plain identifiers, usually several of them in a row, which is a
syntax error.  Depending on the context, the operator '//' is either a
unary operator (no space around) or a binary operator (space around).
This explains why the word 'line-end' is expanded to 'line - end'.

No functional change outside of debug mode.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/indent/parse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index