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:
David Malone 2006-02-13 22:09:26 +00:00
parent 1c71a2c535
commit 59643a2120
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=155621

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