sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 521419115543fdb1a2f7dfd0bcb8973ef9d89059
parent 1150a5cbc9634d923fa3759b0ae8c5a98a9c417d
Author: Brandon Mulcahy <brandon@jangler.info>
Date:   Thu,  4 Dec 2014 17:04:48 -0500

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

Diffstat:
Mexpand.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/expand.c b/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;