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 <gary@lyranthe.org>
MFC after:	1 week
This commit is contained in:
dwmalone 2006-02-13 22:09:26 +00:00
parent 279b470f55
commit 50b0e0be2c

View File

@ -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;
}