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:
parent
1c71a2c535
commit
59643a2120
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=155621
@ -141,7 +141,7 @@ main(int argc, char **argv)
|
|||||||
if (!entries)
|
if (!entries)
|
||||||
exit(eval);
|
exit(eval);
|
||||||
|
|
||||||
maxlength = roundup(maxlength, TAB);
|
maxlength = roundup(maxlength + TAB, TAB);
|
||||||
if (tflag)
|
if (tflag)
|
||||||
maketbl();
|
maketbl();
|
||||||
else if (maxlength >= termwidth)
|
else if (maxlength >= termwidth)
|
||||||
@ -171,7 +171,7 @@ c_columnate(void)
|
|||||||
endcol = maxlength;
|
endcol = maxlength;
|
||||||
putwchar('\n');
|
putwchar('\n');
|
||||||
} else {
|
} else {
|
||||||
while ((cnt = roundup(chcnt, TAB)) <= endcol) {
|
while ((cnt = roundup(chcnt + TAB, TAB)) <= endcol) {
|
||||||
(void)putwchar('\t');
|
(void)putwchar('\t');
|
||||||
chcnt = cnt;
|
chcnt = cnt;
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ r_columnate(void)
|
|||||||
chcnt += width(list[base]);
|
chcnt += width(list[base]);
|
||||||
if ((base += numrows) >= entries)
|
if ((base += numrows) >= entries)
|
||||||
break;
|
break;
|
||||||
while ((cnt = roundup(chcnt, TAB)) <= endcol) {
|
while ((cnt = roundup(chcnt + TAB, TAB)) <= endcol) {
|
||||||
(void)putwchar('\t');
|
(void)putwchar('\t');
|
||||||
chcnt = cnt;
|
chcnt = cnt;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user