From 7898b8297ee65439e86e880e2273117faba49e6c Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 2 Dec 2015 12:50:04 +0100 Subject: [PATCH] Correctly cast ctypes function input to unsigned int This fixes issues found by building on NetBSD which is more pedantic about thoses cases. Reported by: Thomas Klausner (wiz at NetBSD) --- libpkgconf/argvsplit.c | 2 +- libpkgconf/pkg.c | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libpkgconf/argvsplit.c b/libpkgconf/argvsplit.c index d3ef07b..f1262c2 100644 --- a/libpkgconf/argvsplit.c +++ b/libpkgconf/argvsplit.c @@ -61,7 +61,7 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv) } *dst_iter++ = *src_iter; } - else if (isspace(*src_iter)) + else if (isspace((unsigned int)*src_iter)) { if ((*argv)[argc_count] != NULL) { diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index 48bf76b..e7e39a4 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -226,14 +226,14 @@ pkgconf_pkg_new_from_file(const char *filename, FILE *f, unsigned int flags) char op, *p, *key, *value; p = readbuf; - while (*p && (isalpha(*p) || isdigit(*p) || *p == '_' || *p == '.')) + while (*p && (isalpha((unsigned int)*p) || isdigit((unsigned int)*p) || *p == '_' || *p == '.')) p++; key = readbuf; - if (!isalpha(*key) && !isdigit(*p)) + if (!isalpha((unsigned int)*key) && !isdigit((unsigned int)*p)) continue; - while (*p && isspace(*p)) { + while (*p && isspace((unsigned int)*p)) { /* set to null to avoid trailing spaces in key */ *p = '\0'; p++; @@ -243,7 +243,7 @@ pkgconf_pkg_new_from_file(const char *filename, FILE *f, unsigned int flags) *p = '\0'; p++; - while (*p && isspace(*p)) + while (*p && isspace((unsigned int)*p)) p++; value = p; @@ -539,9 +539,9 @@ pkgconf_compare_version(const char *a, const char *b) while (*one || *two) { - while (*one && !isalnum(*one) && *one != '~') + while (*one && !isalnum((unsigned int)*one) && *one != '~') one++; - while (*two && !isalnum(*two) && *two != '~') + while (*two && !isalnum((unsigned int)*two) && *two != '~') two++; if (*one == '~' || *two == '~') @@ -562,22 +562,22 @@ pkgconf_compare_version(const char *a, const char *b) str1 = one; str2 = two; - if (isdigit(*str1)) + if (isdigit((unsigned int)*str1)) { - while (*str1 && isdigit(*str1)) + while (*str1 && isdigit((unsigned int)*str1)) str1++; - while (*str2 && isdigit(*str2)) + while (*str2 && isdigit((unsigned int)*str2)) str2++; isnum = true; } else { - while (*str1 && isalpha(*str1)) + while (*str1 && isalpha((unsigned int)*str1)) str1++; - while (*str2 && isalpha(*str2)) + while (*str2 && isalpha((unsigned int)*str2)) str2++; isnum = false;