]> git.draconx.ca Git - cdecl99.git/commitdiff
cdecl99: Drop locale-sensitive isblank usage.
authorNick Bowler <nbowler@draconx.ca>
Tue, 24 Jan 2023 04:58:55 +0000 (23:58 -0500)
committerNick Bowler <nbowler@draconx.ca>
Tue, 24 Jan 2023 05:18:23 +0000 (00:18 -0500)
The intention of this function is to avoid recording no-op command lines
in the history.  This is exactly the set of commands containing just
regular tabs and spaces.

It is inappropriate to use the locale-sensitive isblank for this, as
this may be a little bit different.  In practice there is probably no
meaningful difference, but as isblank is a C99 feature losing this call
also helps when building against older C libraries that lack it.

src/cdecl99.c

index fc9d3b2593ebba80e101f9121055007dff01e659..485fe86df5d0528892441fa54003c93e1dad8118 100644 (file)
@@ -122,14 +122,9 @@ static void print_help(void)
        printf(_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
 }
 
-static bool is_blank_line(const char *line)
+static int is_blank_line(const char *line)
 {
-       for (size_t i = 0; line[i]; i++) {
-               if (!isblank((unsigned char)line[i]))
-                       return false;
-       }
-
-       return true;
+       return !line[strspn(line, " \t")];
 }
 
 static int repl(void)