From 09c10c42ef8a767213d631bf221ac97f7a32ba2b Mon Sep 17 00:00:00 2001 From: kavyabhand Date: Sun, 2 Aug 2026 16:02:08 +0530 Subject: [PATCH] Cast lexer bytes to unsigned char before ctype calls C99 7.4 requires ctype arguments to be EOF or representable as unsigned char. Plain char may be signed; high-bit bytes then become negative ints. Addresses issue #105. --- tinyexpr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tinyexpr.c b/tinyexpr.c index 176e8d0..607c37e 100755 --- a/tinyexpr.c +++ b/tinyexpr.c @@ -252,10 +252,10 @@ void next_token(state *s) { s->type = TOK_NUMBER; } else { /* Look for a variable or builtin function call. */ - if (isalpha(s->next[0])) { + if (isalpha((unsigned char)s->next[0])) { const char *start; start = s->next; - while (isalpha(s->next[0]) || isdigit(s->next[0]) || (s->next[0] == '_')) s->next++; + while (isalpha((unsigned char)s->next[0]) || isdigit((unsigned char)s->next[0]) || (s->next[0] == '_')) s->next++; const te_variable *var = find_lookup(s, start, s->next - start); if (!var) var = find_builtin(start, s->next - start);