lib: Use isspace on unsigned char
authorVolker Lendecke <vl@samba.org>
Sun, 26 Apr 2015 09:15:01 +0000 (11:15 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 27 Apr 2015 21:54:27 +0000 (23:54 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11223
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Apr 27 23:54:27 CEST 2015 on sn-devel-104

lib/util/tini.c

index 6cd301a0b1b3cb2a2de69e53d673d517b2a67d60..3bfc2d6511fa8fa22f95a80f5b2c6b5b8c7a6673 100644 (file)
 #include <string.h>
 #include "tini.h"
 
+static bool c_isspace(char c)
+{
+       unsigned char uc = c;
+       if (c != uc) {
+               return false;
+       }
+       return isspace(uc);
+}
+
 static int next_content(FILE *f)
 {
        int c;
 
        for (c = fgetc(f); c != EOF; c = fgetc(f)) {
-               if (!isspace(c)) {
+               if (!c_isspace(c)) {
                        break;
                }
                if (c == '\n') {
@@ -145,7 +154,7 @@ next_line:
                        }
 
                        if ((pos > 1) && (buf[pos-2] == '\\') &&
-                           isspace(buf[pos-1])) {
+                           c_isspace(buf[pos-1])) {
                                /*
                                 * Line ends in "\ ". Mind that we zap
                                 * multiple spaces into one. Continuation.
@@ -160,7 +169,7 @@ next_line:
                        break;
                }
 
-               if ((pos > 0) && isspace(buf[pos-1]) && isspace(c)) {
+               if ((pos > 0) && c_isspace(buf[pos-1]) && c_isspace(c)) {
                        /*
                         * Zap multiple spaces to one
                         */
@@ -203,14 +212,14 @@ static char *trim_one_space(char *buf)
 {
        size_t len;
 
-       if (isspace(buf[0])) {
+       if (c_isspace(buf[0])) {
                buf += 1;
        }
        len = strlen(buf);
        if (len == 0) {
                return buf;
        }
-       if (isspace(buf[len-1])) {
+       if (c_isspace(buf[len-1])) {
                buf[len-1] = '\0';
        }