From 50b0e0be2ce1ad30bd4ac60ac5b65375f7d27180 Mon Sep 17 00:00:00 2001 From: dwmalone Date: Mon, 13 Feb 2006 22:09:26 +0000 Subject: [PATCH] The change to make column use roundup(x, TAB) rounded things to the current tab, however the code it replaced wanted to round to the next TAB. Consequently things like this: ( echo 1 ; echo 2 ) | column cause column to loop indefinitely. This patch is slightly different from the one Gary submitted, but is closer to the original code. Submitted by: Gary Cody MFC after: 1 week --- usr.bin/column/column.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.bin/column/column.c b/usr.bin/column/column.c index 4ac5b244b830..ccaa8247ca29 100644 --- a/usr.bin/column/column.c +++ b/usr.bin/column/column.c @@ -141,7 +141,7 @@ main(int argc, char **argv) if (!entries) exit(eval); - maxlength = roundup(maxlength, TAB); + maxlength = roundup(maxlength + TAB, TAB); if (tflag) maketbl(); else if (maxlength >= termwidth) @@ -171,7 +171,7 @@ c_columnate(void) endcol = maxlength; putwchar('\n'); } else { - while ((cnt = roundup(chcnt, TAB)) <= endcol) { + while ((cnt = roundup(chcnt + TAB, TAB)) <= endcol) { (void)putwchar('\t'); chcnt = cnt; } @@ -199,7 +199,7 @@ r_columnate(void) chcnt += width(list[base]); if ((base += numrows) >= entries) break; - while ((cnt = roundup(chcnt, TAB)) <= endcol) { + while ((cnt = roundup(chcnt + TAB, TAB)) <= endcol) { (void)putwchar('\t'); chcnt = cnt; }