diff options
Diffstat (limited to 'awkgram.c')
-rw-r--r-- | awkgram.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -5602,10 +5602,14 @@ get_comment(int flag) tok = tokstart; tokadd('#'); sl = sourceline; + char *p1; + char *p2; while (true) { while ((c = nextc(false)) != '\n' && c != END_FILE) { - tokadd(c); + /* ignore \r characters */ + if (c != '\r') + tokadd(c); } if (flag == EOL_COMMENT) { /* comment at end of line. */ @@ -5638,6 +5642,15 @@ get_comment(int flag) if (comment != NULL) prior_comment = comment; + /* remove any trailing blank lines (consecutive \n) from comment */ + p1 = tok - 1; + p2 = tok - 2; + while (*p1 == '\n' && *p2 == '\n') { + p1--; + p2--; + tok--; + } + comment = bcalloc(Op_comment, 1, sl); comment->source_file = source; comment->memory = make_str_node(tokstart, tok - tokstart, 0); |