Merge branch 'master' of git.distorted.org.uk:~mdw/publish/public-git/misc
authorMark Wooding <mdw@distorted.org.uk>
Fri, 10 Jan 2014 14:46:06 +0000 (14:46 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 10 Jan 2014 14:46:06 +0000 (14:46 +0000)
* 'master' of git.distorted.org.uk:~mdw/publish/public-git/misc:
  space.c: Fix trailing-newline misreporting in `-c' mode.
  space.[c1]: Document the `-v' option finally.

space.1
space.c

diff --git a/space.1 b/space.1
index d1dc55a..f38793f 100644 (file)
--- a/space.1
+++ b/space.1
@@ -65,6 +65,12 @@ report if the file has trailing blank lines; without
 .BR \-c ,
 remove these trailing blank lines from the output.
 .TP
+.BR \-v
+Report detailed messages about whitespace problems encountered.  Useful
+with
+.BR \-c ,
+for example.
+.TP
 .BR \-i [ \fIbackup ]
 Modify all the
 .IR file s
diff --git a/space.c b/space.c
index e9fa0df..07ea82a 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);
@@ -365,6 +366,7 @@ int main(int argc, char *argv[])
   -m           Fix spaces followed by tabs in mid-line\n\
   -t           Tabify file completely\n\
   -u           Untabify file completely\n\
+  -v           Report verbose messages\n\
   -i[BKP]      Modify files in place; leave FILEBKP as copy of old FILE\n\
 ", stdout);
        exit(0);