Handle non-power-of-two tab sizes in expand(1)

This commit is contained in:
Brandon Mulcahy 2014-12-04 17:04:48 -05:00 committed by sin
parent 1150a5cbc9
commit 5214191155

View File

@ -28,6 +28,8 @@ main(int argc, char *argv[])
break;
case 't':
tabstop = estrtol(EARGF(usage()), 0);
if (!tabstop)
eprintf("tab size cannot be zero\n");
break;
default:
usage();
@ -66,7 +68,7 @@ expand(const char *file, FILE *fp, int tabstop)
do {
col++;
putchar(' ');
} while (col & (tabstop - 1));
} while (col % tabstop);
} else {
putchar('\t');
col += tabstop - col % tabstop;