--- hatari/src/debug/evaluate.c 2019/04/09 08:53:04 1.1.1.3 +++ hatari/src/debug/evaluate.c 2019/04/09 08:54:22 1.1.1.4 @@ -1,7 +1,7 @@ /* - Hatari - calculate.c + Hatari - evaluate.c - Copyright (C) 1994, 2009-2010 by Eero Tamminen + Copyright (C) 1994, 2009-2014 by Eero Tamminen This file is distributed under the GNU General Public License, version 2 or at your option any later version. Read the file gpl.txt for details. @@ -158,7 +158,7 @@ static int getNumber(const char *str, Ui } str += 2; } - else if (!isxdigit(str[0])) { + else if (!isxdigit((unsigned char)str[0])) { /* doesn't start with (hex) number -> is it prefix? */ switch (*str++) { @@ -206,8 +206,8 @@ static int getValue(const char *str, Uin Uint32 mask, *addr; int len; - for (end = str; *end == '_' || isalnum(*end); end++); - + for (end = str; *end == '_' || isalnum((unsigned char)*end); end++); + len = end-str; if (len >= (int)sizeof(name)) { fprintf(stderr, "ERROR: symbol name at '%s' too long (%d chars)\n", str, len); @@ -314,7 +314,10 @@ bool Eval_Number(const char *str, Uint32 * addition to numbers. */ offset = getNumber(str, number, &base); - return isNumberOK(str, offset, base); + if (!offset) + return false; + else + return isNumberOK(str, offset, base); } @@ -343,7 +346,7 @@ int Eval_Range(char *str1, Uint32 *lower } offset = getValue(str1, lower, &base, fordsp); - if (!isNumberOK(str1, offset, base)) { + if (offset == 0 || !isNumberOK(str1, offset, base)) { /* first number not OK */ fprintf(stderr,"Invalid address value '%s'!\n", str1); ret = -1; @@ -353,7 +356,7 @@ int Eval_Range(char *str1, Uint32 *lower } if (fDash) { offset = getValue(str2, upper, &base, fordsp); - if (!isNumberOK(str2, offset, base)) { + if (offset == 0 || !isNumberOK(str2, offset, base)) { /* second number not OK */ fprintf(stderr, "Invalid address value '%s'!\n", str2); ret = -1; @@ -689,7 +692,7 @@ static long long apply_op (char opcode, /* ==================================================================== */ /** - * open prenthesis, push values & operators to stack + * open parenthesis, push values & operators to stack */ static void open_bracket (void) { @@ -706,7 +709,7 @@ static void open_bracket (void) /* -------------------------------------------------------------------- */ /** - * close prenthesis, and evaluate / pop stacks + * close parenthesis, and evaluate / pop stacks */ /* last parsed value, last param. flag, trigonometric mode */ static long long close_bracket (long long value) @@ -714,7 +717,7 @@ static long long close_bracket (long lon /* returns the value of the parenthesised expression */ if (id.valid) { /* preceded by an operator */ - if (par.idx > 0) { /* prenthesis has a pair */ + if (par.idx > 0) { /* parenthesis has a pair */ Uint32 addr; /* calculate the value of parenthesised exp. */