do not call isdigit with a negative value.

http://bugs.eressea.de/view.php?id=1987#c6941
This commit is contained in:
Enno Rehling 2017-02-03 21:19:39 +01:00
parent bb37e423e1
commit 644a6019a6
5 changed files with 7 additions and 7 deletions

View File

@ -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)) {

View File

@ -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;

View File

@ -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 == ')'

View File

@ -6,7 +6,6 @@
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <wctype.h>
#include <memory.h>
@ -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;

View File

@ -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