Cast argument to ctype functions to unsigned char

Per POSIX, "The c argument is an int, the value of which the application
shall ensure is a character representable as an unsigned char or equal
to the value of the macro EOF. If the argument has any other value, the
behavior is undefined."

https://pubs.opengroup.org/onlinepubs/009604499/functions/isspace.html

Signed-off-by: Nia Alarie <nia@NetBSD.org>
This commit is contained in:
nia
2020-11-19 12:17:42 +01:00
parent 248bffede7
commit b14e85a6bc
4 changed files with 18 additions and 16 deletions

View File

@@ -37,7 +37,7 @@ static inline int uitostr(unsigned int n, char *buf) {
static inline const char *skip_space_const(const char *src) {
if (!src)
return NULL;
while (*src && isspace(*src))
while (*src && isspace((unsigned char)*src))
src++;
return src;
}
@@ -45,7 +45,7 @@ static inline const char *skip_space_const(const char *src) {
static inline char *skip_space_mut(char *src) {
if (!src)
return NULL;
while (*src && isspace(*src))
while (*src && isspace((unsigned char)*src))
src++;
return src;
}