This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.0'.
[unix-history] / usr.bin / col / col.c
index 375bb6c..709bfd4 100644 (file)
@@ -101,6 +101,9 @@ int no_backspaces;          /* if not to output any backspaces */
        if (putchar(ch) == EOF) \
                wrerr();
 
        if (putchar(ch) == EOF) \
                wrerr();
 
+/* next tabstop after col */
+#define TABSTOP(col,ts)  ((col) + (ts) - (col) % (ts))
+
 main(argc, argv)
        int argc;
        char **argv;
 main(argc, argv)
        int argc;
        char **argv;
@@ -424,10 +427,17 @@ flush_line(l)
                        if (compress_spaces && nspace > 1) {
                                int ntabs;
 
                        if (compress_spaces && nspace > 1) {
                                int ntabs;
 
+                               while ((ntabs = TABSTOP(last_col, 8)) <= this_col) {
+                                       PUTC('\t');
+                                       last_col = ntabs;
+                               }
+                               nspace = this_col - last_col;
+/*
                                ntabs = this_col / 8 - last_col / 8;
                                nspace -= ntabs * 8;
                                while (--ntabs >= 0)
                                        PUTC('\t');
                                ntabs = this_col / 8 - last_col / 8;
                                nspace -= ntabs * 8;
                                while (--ntabs >= 0)
                                        PUTC('\t');
+*/
                        }
                        while (--nspace >= 0)
                                PUTC(' ');
                        }
                        while (--nspace >= 0)
                                PUTC(' ');