From 644a6019a62382246aee125c15f8d702acf0f094 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Feb 2017 21:19:39 +0100 Subject: [PATCH] do not call isdigit with a negative value. http://bugs.eressea.de/view.php?id=1987#c6941 --- src/spy.c | 2 +- src/util/base36.c | 4 ++-- src/util/dice.c | 2 +- src/util/parser.c | 4 ++-- src/util/translation.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/spy.c b/src/spy.c index eb58f792a..0ca3050c2 100644 --- a/src/spy.c +++ b/src/spy.c @@ -229,7 +229,7 @@ int setstealth_cmd(unit * u, struct order *ord) return 0; } - if (isdigit(s[0])) { + if (isdigit(*(const unsigned char *)s)) { /* Tarnungslevel setzen */ level = atoi((const char *)s); if (level > effskill(u, SK_STEALTH, 0)) { diff --git a/src/util/base36.c b/src/util/base36.c index 7edb46027..285e9760e 100644 --- a/src/util/base36.c +++ b/src/util/base36.c @@ -39,9 +39,9 @@ int atoi36(const char *str) while (isalnum(*(unsigned char *)s)) { if (isupper(*(unsigned char *)s)) i = i * 36 + (*s) - 'A' + 10; - else if (islower(*(unsigned char *)s)) + else if (islower(*s)) i = i * 36 + (*s) - 'a' + 10; - else if (isdigit(*(unsigned char *)s)) + else if (isdigit(*s)) i = i * 36 + (*s) - '0'; else break; diff --git a/src/util/dice.c b/src/util/dice.c index e28a4bccd..6fa50261d 100644 --- a/src/util/dice.c +++ b/src/util/dice.c @@ -49,7 +49,7 @@ static int term_eval(const char **sptr) int state = 1; for (;;) { - if (isdigit(*(unsigned char *)c)) { + if (isdigit(*(const unsigned char *)c)) { k = k * 10 + (*c - '0'); } else if (*c == '+' || *c == '-' || *c == 0 || *c == '*' || *c == ')' diff --git a/src/util/parser.c b/src/util/parser.c index bbdb5ac7e..fca066cb1 100644 --- a/src/util/parser.c +++ b/src/util/parser.c @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -251,7 +250,8 @@ unsigned int atoip(const char *s) int n; assert(s); - n = isdigit(s[0]) ? atoi(s) : 0; + n = (s[0] >='0' && s[0]<='9'); + n = n ? atoi(s) : 0; if (n < 0) n = 0; diff --git a/src/util/translation.c b/src/util/translation.c index c733cc272..fb89a5af9 100644 --- a/src/util/translation.c +++ b/src/util/translation.c @@ -354,7 +354,7 @@ static const char *parse(opstack ** stack, const char *inn, return parse_symbol(stack, ++b, userdata); break; default: - if (isdigit(*(unsigned char *)b) || *b == '-' || *b == '+') { + if (isdigit(*(const unsigned char *)b) || *b == '-' || *b == '+') { return parse_int(stack, b); } else