Mercurial > ~dholland > hg > tradcpp > index.cgi
changeset 175:ffdb0b73856f
Suppress blank lines later.
Fixes the rest of the bizarre spacing behavior described in changeset
82cc6fa54b01.
Expand t39 to cover more cases, too.
author | David A. Holland |
---|---|
date | Fri, 12 Jun 2015 02:38:04 -0400 |
parents | 09cfad6772de |
children | a2f047301c15 |
files | directive.c files.c macro.c tests/t39.c tests/t39.good |
diffstat | 5 files changed, 43 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/directive.c Fri Jun 12 02:21:28 2015 -0400 +++ b/directive.c Fri Jun 12 02:38:04 2015 -0400 @@ -638,7 +638,7 @@ } /* check if we have a directive line (# exactly in column 0) */ - if (line[0] == '#') { + if (len > 0 && line[0] == '#') { skip = 1 + strspn(line + 1, ws); assert(skip <= len); lp->current.column += skip;
--- a/files.c Fri Jun 12 02:21:28 2015 -0400 +++ b/files.c Fri Jun 12 02:38:04 2015 -0400 @@ -274,11 +274,8 @@ /* count how many commented-out newlines we swallowed */ places.nextline.line += countnls(buf, linestart, lineend); - /* if the line isn't empty, process it */ - if (lineend > linestart) { - directive_gotline(&places, - buf+linestart, lineend-linestart); - } + /* process the line (even if it's empty) */ + directive_gotline(&places, buf+linestart, lineend-linestart); linestart = nextlinestart; lineend = findeol(buf, linestart, bufend);
--- a/macro.c Fri Jun 12 02:21:28 2015 -0400 +++ b/macro.c Fri Jun 12 02:38:04 2015 -0400 @@ -1246,11 +1246,22 @@ doexpand(&mainstate, p, buf, len); switch (mainstate.state) { case ES_NORMAL: - output(p, "\n", 1); + /* + * If we were sent a blank line, don't emit a newline + * for it. This matches the prior behavior of tradcpp. + */ + if (len > 0) { + output(p, "\n", 1); + } break; case ES_WANTLPAREN: case ES_NOARG: case ES_HAVEARG: + /* + * Apparently to match gcc's -traditional behavior we + * need to emit a space for each newline that appears + * while processing macro args. + */ expand_got_ws(&mainstate, p, " ", 1); break; }