X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftabs.c;fp=progs%2Ftabs.c;h=4a6eb2415e7c973d0ce13d7eb3f93fbfa19055d1;hp=7bcbb74a310ba7fb0fe93897b76aa93411d91dda;hb=d30f99439fcc8d4bb4c38e5c4afb4f6555fc6ad4;hpb=b661daf1160a873609d70843999cd46eff25d1f0 diff --git a/progs/tabs.c b/progs/tabs.c index 7bcbb74a..4a6eb241 100644 --- a/progs/tabs.c +++ b/progs/tabs.c @@ -39,7 +39,7 @@ #include #include -MODULE_ID("$Id: tabs.c,v 1.46 2021/03/20 16:07:29 tom Exp $") +MODULE_ID("$Id: tabs.c,v 1.47 2021/04/03 23:00:00 tom Exp $") static GCC_NORETURN void usage(void); @@ -146,7 +146,6 @@ static void print_ruler(int *tab_list) { int last = 0; - int stop; int n; /* first print a readable ruler */ @@ -164,7 +163,8 @@ print_ruler(int *tab_list) /* now, print '*' for each stop */ for (n = 0, last = 0; (tab_list[n] > 0) && (last < max_cols); ++n) { - stop = tab_list[n]; + int stop = tab_list[n]; + while (++last < stop) { if (last <= max_cols) { putchar('-'); @@ -210,11 +210,11 @@ static char * trimmed_tab_list(const char *source) { char *result = strdup(source); - int ch, j, k, last; - if (result != 0) { + int j, k, last; + for (j = k = last = 0; result[j] != 0; ++j) { - ch = UChar(result[j]); + int ch = UChar(result[j]); if (isspace(ch)) { if (last == '\0') { continue; @@ -304,9 +304,11 @@ legal_tab_list(const char *tab_list) if (tab_list != 0 && *tab_list != '\0') { if (comma_is_needed(tab_list)) { - int n, ch; + int n; + for (n = 0; tab_list[n] != '\0'; ++n) { - ch = UChar(tab_list[n]); + int ch = UChar(tab_list[n]); + if (!(isdigit(ch) || ch == ',' || ch == '+')) { fprintf(stderr, "%s: unexpected character found '%c'\n",