chiark / gitweb /
space.c: Fix trailing-newline misreporting in `-c' mode.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 11 Aug 2013 01:08:00 +0000 (02:08 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 11 Aug 2013 01:10:37 +0000 (02:10 +0100)
Reduction of the recent-newlines counter was being done only in the
output case.

space.c

diff --git a/space.c b/space.c
index fe4c35d23ca0f94726ecb9329e1498a8b93c74a7..07ea82acb5eadb4e981e49af7e377575c23c3ee9 100644 (file)
--- a/space.c
+++ b/space.c
@@ -220,7 +220,7 @@ static int space(const char *name)
              nnl = 1;
            }
          }
-         if (fout) while (nnl--) putc('\n', fout);
+         if (fout) while (nnl--) putc('\n', fout); else nnl = 0;
        }
        goto end;
       case '\n':
@@ -237,7 +237,8 @@ static int space(const char *name)
        else if (fout) {
          while (nnl) { putc('\n', fout); nnl--; }
          putc(ch, fout);
-       }
+       } else
+         nnl = 0;
        f |= f_newline;
        f &= ~(f_tab | f_warnspacetab | f_warntabs | f_warnspaces);
        if (flags & F_TABIFY)
@@ -247,7 +248,7 @@ static int space(const char *name)
        last = '\n';
        break;
       default:
-       if (fout) while (nnl) { putc('\n', fout); nnl--; }
+       if (fout) while (nnl) { putc('\n', fout); nnl--; } else nnl = 0;
        if (nwsp) {
          if (flags & F_UNTABIFY) {
            if (fout) for (; ohpos < hpos; ohpos++) putc(' ', fout);