diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-03-24 04:01:04 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-03-24 04:01:04 -0700 |
commit | 39c8fd12550671adac2a44061a5646d0102e95db (patch) | |
tree | 0e27088a2ee0f61ca9da102b27a83418a1cdf4de | |
parent | 8aacb4d5fbb4909efa1531e7883c14865387ccd5 (diff) | |
download | cppawk-39c8fd12550671adac2a44061a5646d0102e95db.tar.gz cppawk-39c8fd12550671adac2a44061a5646d0102e95db.tar.bz2 cppawk-39c8fd12550671adac2a44061a5646d0102e95db.zip |
bugfix: collapse: don't eat blank lines.
-rwxr-xr-x | cppawk | 13 | ||||
-rw-r--r-- | testcases | 13 |
2 files changed, 21 insertions, 5 deletions
@@ -78,21 +78,24 @@ collapse() awk ' $1 == "#" { if ($2 != curline || $3 != curfile) { print - if (line != "") + if (have_line) { printf("%s\n", line); - line = "" } } + line = "" + have_line = 0 } } startline = $2 curline = startline - 1 curfile = $3; next } 1 { if (++curline > startline) - { if (line != "") + { if (have_line) { printf("%s\n", line) line = "" } } else { sub(/^[ \t]+/, "") } - line = line $0 } - END { printf("%s\n", line); }' + line = line $0 + have_line = 1 } + END { if (have_line) + printf("%s\n", line); }' } prepro_opts="$prepro_opts -I$selfdir/cppawk-include" @@ -210,3 +210,16 @@ gone ./cppawk --prepro-only -f testdir/program.cwk | grep BEGIN : BEGIN { print ((42) > (73) ? (42) : (73)) } +-- +39: +./cppawk --prepro-only 'foo + +bar + +baz' | ./cppawk '/foo/,/baz/' +: +foo + +bar + +baz |