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;
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user