glsl/glcpp: Drop extra, final newline from most output
authorCarl Worth <cworth@cworth.org>
Fri, 20 Jun 2014 21:58:48 +0000 (14:58 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 29 Jul 2014 22:11:49 +0000 (15:11 -0700)
commit828686d4ebe055d1c6583192bc57742e101ff931
treefe6825369bfd1e755dd8b4f83e7121bc8e3744dc
parent5dbdc341e8e8502ab5d98784a24b54c6f3907472
glsl/glcpp: Drop extra, final newline from most output

The glcpp parser is line-based, so it needs to see a NEWLINE token at the end
of each line. This causes a trick for files that end without a final newline.

Previously, the lexer for glcpp punted in this case by unconditionally
returning a NEWLINE token at end-of-file, (causing most files to have an extra
blank line at the end). Here, we refine this by lexing end-of-file as a
NEWLINE token only if the immediately preceding token was not a NEWLINE token.

The patch is a minor change that only looks huge for two reasons:

1. Almost all glcpp test result ".expected" files are updated to drop
   the extra newline.

2. All return statements from the lexer are adjusted to use a new
   RETURN_TOKEN macro that tracks the last-token-was-a-newline state.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
130 files changed:
src/glsl/glcpp/glcpp-lex.l
src/glsl/glcpp/glcpp-parse.y
src/glsl/glcpp/glcpp.h
src/glsl/glcpp/tests/000-content-with-spaces.c.expected
src/glsl/glcpp/tests/001-define.c.expected
src/glsl/glcpp/tests/002-define-chain.c.expected
src/glsl/glcpp/tests/003-define-chain-reverse.c.expected
src/glsl/glcpp/tests/004-define-recursive.c.expected
src/glsl/glcpp/tests/005-define-composite-chain.c.expected
src/glsl/glcpp/tests/006-define-composite-chain-reverse.c.expected
src/glsl/glcpp/tests/007-define-composite-recursive.c.expected
src/glsl/glcpp/tests/008-define-empty.c.expected
src/glsl/glcpp/tests/009-undef.c.expected
src/glsl/glcpp/tests/010-undef-re-define.c.expected
src/glsl/glcpp/tests/011-define-func-empty.c.expected
src/glsl/glcpp/tests/012-define-func-no-args.c.expected
src/glsl/glcpp/tests/013-define-func-1-arg-unused.c.expected
src/glsl/glcpp/tests/014-define-func-2-arg-unused.c.expected
src/glsl/glcpp/tests/015-define-object-with-parens.c.expected
src/glsl/glcpp/tests/016-define-func-1-arg.c.expected
src/glsl/glcpp/tests/017-define-func-2-args.c.expected
src/glsl/glcpp/tests/018-define-func-macro-as-parameter.c.expected
src/glsl/glcpp/tests/019-define-func-1-arg-multi.c.expected
src/glsl/glcpp/tests/020-define-func-2-arg-multi.c.expected
src/glsl/glcpp/tests/021-define-func-compose.c.expected
src/glsl/glcpp/tests/022-define-func-arg-with-parens.c.expected
src/glsl/glcpp/tests/023-define-extra-whitespace.c.expected
src/glsl/glcpp/tests/024-define-chain-to-self-recursion.c.expected
src/glsl/glcpp/tests/025-func-macro-as-non-macro.c.expected
src/glsl/glcpp/tests/026-define-func-extra-newlines.c.expected
src/glsl/glcpp/tests/027-define-chain-obj-to-func.c.expected
src/glsl/glcpp/tests/028-define-chain-obj-to-non-func.c.expected
src/glsl/glcpp/tests/029-define-chain-obj-to-func-with-args.c.expected
src/glsl/glcpp/tests/030-define-chain-obj-to-func-compose.c.expected
src/glsl/glcpp/tests/031-define-chain-func-to-func-compose.c.expected
src/glsl/glcpp/tests/032-define-func-self-recurse.c.expected
src/glsl/glcpp/tests/033-define-func-self-compose.c.expected
src/glsl/glcpp/tests/034-define-func-self-compose-non-func.c.expected
src/glsl/glcpp/tests/035-define-func-self-compose-non-func-multi-token-argument.c.expected
src/glsl/glcpp/tests/036-define-func-non-macro-multi-token-argument.c.expected
src/glsl/glcpp/tests/037-finalize-unexpanded-macro.c.expected
src/glsl/glcpp/tests/038-func-arg-with-commas.c.expected
src/glsl/glcpp/tests/039-func-arg-obj-macro-with-comma.c.expected
src/glsl/glcpp/tests/040-token-pasting.c.expected
src/glsl/glcpp/tests/041-if-0.c.expected
src/glsl/glcpp/tests/042-if-1.c.expected
src/glsl/glcpp/tests/043-if-0-else.c.expected
src/glsl/glcpp/tests/044-if-1-else.c.expected
src/glsl/glcpp/tests/045-if-0-elif.c.expected
src/glsl/glcpp/tests/046-if-1-elsif.c.expected
src/glsl/glcpp/tests/047-if-elif-else.c.expected
src/glsl/glcpp/tests/048-if-nested.c.expected
src/glsl/glcpp/tests/049-if-expression-precedence.c.expected
src/glsl/glcpp/tests/050-if-defined.c.expected
src/glsl/glcpp/tests/051-if-relational.c.expected
src/glsl/glcpp/tests/052-if-bitwise.c.expected
src/glsl/glcpp/tests/053-if-divide-and-shift.c.expected
src/glsl/glcpp/tests/054-if-with-macros.c.expected
src/glsl/glcpp/tests/055-define-chain-obj-to-func-parens-in-text.c.expected
src/glsl/glcpp/tests/056-macro-argument-with-comma.c.expected
src/glsl/glcpp/tests/057-empty-arguments.c.expected
src/glsl/glcpp/tests/058-token-pasting-empty-arguments.c.expected
src/glsl/glcpp/tests/059-token-pasting-integer.c.expected
src/glsl/glcpp/tests/060-left-paren-in-macro-right-paren-in-text.c.expected
src/glsl/glcpp/tests/061-define-chain-obj-to-func-multi.c.expected
src/glsl/glcpp/tests/062-if-0-skips-garbage.c.expected
src/glsl/glcpp/tests/063-comments.c.expected
src/glsl/glcpp/tests/064-version.c.expected
src/glsl/glcpp/tests/065-if-defined-parens.c.expected
src/glsl/glcpp/tests/066-if-nospace-expression.c.expected
src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected
src/glsl/glcpp/tests/068-accidental-pasting.c.expected
src/glsl/glcpp/tests/069-repeated-argument.c.expected
src/glsl/glcpp/tests/070-undefined-macro-in-expression.c.expected
src/glsl/glcpp/tests/071-punctuator.c.expected
src/glsl/glcpp/tests/072-token-pasting-same-line.c.expected
src/glsl/glcpp/tests/073-if-in-ifdef.c.expected
src/glsl/glcpp/tests/074-elif-undef.c.expected
src/glsl/glcpp/tests/075-elif-elif-undef.c.expected
src/glsl/glcpp/tests/076-elif-undef-nested.c.expected
src/glsl/glcpp/tests/077-else-without-if.c.expected
src/glsl/glcpp/tests/078-elif-without-if.c.expected
src/glsl/glcpp/tests/079-endif-without-if.c.expected
src/glsl/glcpp/tests/080-if-without-expression.c.expected
src/glsl/glcpp/tests/081-elif-without-expression.c.expected
src/glsl/glcpp/tests/082-invalid-paste.c.expected
src/glsl/glcpp/tests/083-unterminated-if.c.expected
src/glsl/glcpp/tests/085-incorrect-argument-count.c.expected
src/glsl/glcpp/tests/086-reserved-macro-names.c.expected
src/glsl/glcpp/tests/087-if-comments.c.expected
src/glsl/glcpp/tests/088-redefine-macro-legitimate.c.expected
src/glsl/glcpp/tests/089-redefine-macro-error.c.expected
src/glsl/glcpp/tests/090-hash-error.c.expected
src/glsl/glcpp/tests/091-hash-line.c.expected
src/glsl/glcpp/tests/092-redefine-macro-error-2.c.expected
src/glsl/glcpp/tests/093-divide-by-zero.c.expected
src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected
src/glsl/glcpp/tests/095-recursive-define.c.expected
src/glsl/glcpp/tests/096-paste-twice.c.expected
src/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected
src/glsl/glcpp/tests/098-elif-undefined.c.expected
src/glsl/glcpp/tests/099-c99-example.c.expected
src/glsl/glcpp/tests/100-macro-with-colon.c.expected
src/glsl/glcpp/tests/101-macros-used-twice.c.expected
src/glsl/glcpp/tests/104-hash-line-followed-by-code.c.expected
src/glsl/glcpp/tests/105-multiline-hash-line.c.expected
src/glsl/glcpp/tests/106-multiline-hash-if.c.expected
src/glsl/glcpp/tests/107-multiline-hash-elif.c.expected
src/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected
src/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected
src/glsl/glcpp/tests/110-no-space-digits-after-hash-elif.c.expected
src/glsl/glcpp/tests/111-no-space-operator-after-hash-if.c.expected
src/glsl/glcpp/tests/112-no-space-operator-after-hash-elif.c.expected
src/glsl/glcpp/tests/113-line-and-file-macros.c.expected
src/glsl/glcpp/tests/114-paste-integer-tokens.c.expected
src/glsl/glcpp/tests/115-line-continuations.c.expected
src/glsl/glcpp/tests/116-disable-line-continuations.c.expected
src/glsl/glcpp/tests/117-line-continuation-and-non-continuation-backslash.c.expected
src/glsl/glcpp/tests/118-comment-becomes-space.c.expected
src/glsl/glcpp/tests/118-multiple-else.c.expected
src/glsl/glcpp/tests/119-elif-after-else.c.expected
src/glsl/glcpp/tests/120-undef-builtin.c.expected
src/glsl/glcpp/tests/121-comment-bug-72686.c.expected
src/glsl/glcpp/tests/122-redefine-whitespace.c.expected
src/glsl/glcpp/tests/124-preprocessing-numbers.c.expected
src/glsl/glcpp/tests/125-es-short-circuit-undefined.c.expected
src/glsl/glcpp/tests/126-garbage-after-directive.c.expected
src/glsl/glcpp/tests/127-pragma-empty.c.expected
src/glsl/glcpp/tests/128-space-before-hash.c.expected
src/glsl/glcpp/tests/130-define-comment.c.expected