From 2ee20ca604a8e32c6595dc142df4aeefa05fa101 Mon Sep 17 00:00:00 2001 From: riastradh Date: Thu, 11 Jul 2024 21:17:06 +0000 Subject: [PATCH] Avoid ctype.h abuse: cast char to unsigned char first. fix #3151 --- src/builtin.c | 2 +- src/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builtin.c b/src/builtin.c index 7d21bfb1..e39975b0 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -1474,7 +1474,7 @@ static jv f_strptime(jq_state *jq, jv a, jv b) { } #endif const char *end = strptime(input, fmt, &tm); - if (end == NULL || (*end != '\0' && !isspace(*end))) { + if (end == NULL || (*end != '\0' && !isspace((unsigned char)*end))) { return ret_error2(a, b, jv_string_fmt("date \"%s\" does not match format \"%s\"", input, fmt)); } jv_free(b); diff --git a/src/main.c b/src/main.c index 2f26ff2b..a8c217fc 100644 --- a/src/main.c +++ b/src/main.c @@ -126,7 +126,7 @@ static void die() { } static int isoptish(const char* text) { - return text[0] == '-' && (text[1] == '-' || isalpha(text[1])); + return text[0] == '-' && (text[1] == '-' || isalpha((unsigned char)text[1])); } static int isoption(const char* text, char shortopt, const char* longopt, size_t *short_opts) {