Handle non-power-of-two tab sizes in expand(1)
This commit is contained in:
parent
1150a5cbc9
commit
5214191155
4
expand.c
4
expand.c
|
@ -28,6 +28,8 @@ main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
tabstop = estrtol(EARGF(usage()), 0);
|
tabstop = estrtol(EARGF(usage()), 0);
|
||||||
|
if (!tabstop)
|
||||||
|
eprintf("tab size cannot be zero\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
@ -66,7 +68,7 @@ expand(const char *file, FILE *fp, int tabstop)
|
||||||
do {
|
do {
|
||||||
col++;
|
col++;
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
} while (col & (tabstop - 1));
|
} while (col % tabstop);
|
||||||
} else {
|
} else {
|
||||||
putchar('\t');
|
putchar('\t');
|
||||||
col += tabstop - col % tabstop;
|
col += tabstop - col % tabstop;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user