diff options
author | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2013-11-22 00:10:46 +0100 |
---|---|---|
committer | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2013-11-22 00:10:46 +0100 |
commit | 5bc22db14b6ffd4cb39722a415d4cd176bb7fc0d (patch) | |
tree | ffe438dcf5f52c8e1148e1da3ca6b9fa64d9dc32 /src/main.c | |
parent | 407dc8b5e6a4db430381000256c87ba313bbed5e (diff) | |
download | ratpoison-5bc22db14b6ffd4cb39722a415d4cd176bb7fc0d.zip |
Cast char arguments to to*/is* ctype calls to unsigned char
* those functions expect an int whose value is between -1 and 255.
Cast to unsigned char so that sign extension when promoting to int
doesn't bite us.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -180,7 +180,8 @@ strtok_ws (char *s) } /* skip to first non-whitespace char. */ - while (*last && isspace (*last)) last++; + while (*last && isspace ((unsigned char)*last)) + last++; /* If we reached the end of the string here then there is no more data. */ @@ -189,7 +190,8 @@ strtok_ws (char *s) /* Now skip to the end of the data. */ nonws = last; - while (*last && !isspace (*last)) last++; + while (*last && !isspace ((unsigned char)*last)) + last++; if (*last) { *last = '\0'; @@ -204,8 +206,9 @@ str_comp (char *s1, char *s2, int len) { int i; - for (i=0; i<len; i++) - if (toupper (s1[i]) != toupper (s2[i])) return 0; + for (i = 0; i < len; i++) + if (toupper ((unsigned char)s1[i]) != toupper ((unsigned char)s2[i])) + return 0; return 1; } |