From c4ed86715d3ff32eaf107d8bfce64ba010a35eeb Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Wed, 28 Jul 1993 09:45:29 +0000 Subject: [PATCH] fixed col's entab algorithm which was losing spaces --- usr.bin/col/col.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/usr.bin/col/col.c b/usr.bin/col/col.c index 375bb6cd14..709bfd4cf9 100644 --- a/usr.bin/col/col.c +++ b/usr.bin/col/col.c @@ -101,6 +101,9 @@ int no_backspaces; /* if not to output any backspaces */ if (putchar(ch) == EOF) \ wrerr(); +/* next tabstop after col */ +#define TABSTOP(col,ts) ((col) + (ts) - (col) % (ts)) + main(argc, argv) int argc; char **argv; @@ -424,10 +427,17 @@ flush_line(l) 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'); +*/ } while (--nspace >= 0) PUTC(' '); -- 2.20.1