[hackers] [sbase] Handle non-power-of-two tab sizes in expand(1) || Brandon Mulcahy

From: <git_AT_suckless.org>
Date: Thu, 04 Dec 2014 23:26:13 +0100

commit 521419115543fdb1a2f7dfd0bcb8973ef9d89059
Author: Brandon Mulcahy <brandon_AT_jangler.info>
Date: Thu Dec 4 17:04:48 2014 -0500

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

diff --git a/expand.c b/expand.c
index 2449a8e..35b7a9a 100644
--- a/expand.c
+++ b/expand.c
_AT_@ -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();
_AT_@ -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;
Received on Thu Dec 04 2014 - 23:26:13 CET

This archive was generated by hypermail 2.3.0 : Thu Dec 04 2014 - 23:36:08 CET