Take a swing at using roundup().

This commit is contained in:
Juli Mallett 2005-01-25 01:35:02 +00:00
parent 729fcf7efb
commit e2816c1489
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=140784

View File

@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/param.h>
#include <err.h>
#include <limits.h>
@ -140,7 +141,7 @@ main(int argc, char **argv)
if (!entries)
exit(eval);
maxlength = (maxlength + TAB) & ~(TAB - 1);
maxlength = roundup(maxlength, TAB);
if (tflag)
maketbl();
else if (maxlength >= termwidth)
@ -170,7 +171,7 @@ c_columnate(void)
endcol = maxlength;
putwchar('\n');
} else {
while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol) {
while ((cnt = roundup(chcnt, TAB)) <= endcol) {
(void)putwchar('\t');
chcnt = cnt;
}
@ -198,7 +199,7 @@ r_columnate(void)
chcnt += width(list[base]);
if ((base += numrows) >= entries)
break;
while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol) {
while ((cnt = roundup(chcnt, TAB)) <= endcol) {
(void)putwchar('\t');
chcnt = cnt;
}