summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-06-25 08:04:39 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-06-25 08:04:39 +0000
commite692918b34b127e3be7ef00fd470c90ff8adb3ca (patch)
tree392424f5045e66e50a96a5f7e4b217da870dcf69
parentf7ce2a786aaa4ac5e9f82daa4b78ee89ca5ef46c (diff)
Added casts to ensure proper values are passed to the ctype.h functions.
[Juergen Buchmueller]
-rw-r--r--src/build/verinfo.c8
-rw-r--r--src/emu/cheat.c2
-rw-r--r--src/emu/cpu/alph8201/8201dasm.c2
-rw-r--r--src/emu/cpu/pic16c5x/16c5xdsm.c2
-rw-r--r--src/emu/cpu/tms32010/32010dsm.c2
-rw-r--r--src/emu/cpu/tms32025/32025dsm.c2
-rw-r--r--src/emu/debug/debugcmd.c8
-rw-r--r--src/emu/debug/debugcon.c10
-rw-r--r--src/emu/debug/debugcpu.c6
-rw-r--r--src/emu/debug/debughlp.c2
-rw-r--r--src/emu/debug/debugvw.c8
-rw-r--r--src/emu/debug/express.c12
-rw-r--r--src/emu/driver.c2
-rw-r--r--src/emu/hash.c10
-rw-r--r--src/emu/inputseq.c6
-rw-r--r--src/emu/uimenu.c8
-rw-r--r--src/emu/validity.c6
-rw-r--r--src/lib/util/astring.c16
-rw-r--r--src/lib/util/corefile.c2
-rw-r--r--src/lib/util/corestr.c9
-rw-r--r--src/lib/util/options.c8
-rw-r--r--src/lib/util/xmlfile.c6
-rw-r--r--src/tools/chdcd.c10
-rw-r--r--src/tools/chdman.c2
-rw-r--r--src/tools/jedutil.c12
-rw-r--r--src/tools/ldverify.c4
-rw-r--r--src/tools/regrep.c8
27 files changed, 88 insertions, 85 deletions
diff --git a/src/build/verinfo.c b/src/build/verinfo.c
index 2cbf41a3ac7..d95df33dc86 100644
--- a/src/build/verinfo.c
+++ b/src/build/verinfo.c
@@ -13,6 +13,8 @@
#include <string.h>
#include <stdlib.h>
+typedef unsigned char UINT8;
+
#define ARRAY_LENGTH(x) (sizeof(x) / sizeof(x[0]))
#define BUILD_WINDOWS (0)
#define BUILD_WINUI (1)
@@ -123,13 +125,13 @@ static int parse_version_digit(const char *str, int *position)
{
int value = 0;
- while (str[*position] != 0 && !isspace(str[*position]) && !isdigit(str[*position]))
+ while (str[*position] != 0 && !isspace((UINT8)str[*position]) && !isdigit((UINT8)str[*position]))
(*position)++;
- if (str[*position] != 0 && isdigit(str[*position]))
+ if (str[*position] != 0 && isdigit((UINT8)str[*position]))
{
sscanf(&str[*position], "%d", &value);
- while (isdigit(str[*position]))
+ while (isdigit((UINT8)str[*position]))
(*position)++;
}
return value;
diff --git a/src/emu/cheat.c b/src/emu/cheat.c
index e6ffd5d0741..3e978661b5d 100644
--- a/src/emu/cheat.c
+++ b/src/emu/cheat.c
@@ -465,7 +465,7 @@ void *cheat_get_next_menu_entry(running_machine *machine, void *previous, const
{
if (description != NULL)
{
- while (isspace(**description))
+ while (isspace((UINT8)**description))
*description += 1;
if (**description == 0)
*description = MENU_SEPARATOR_ITEM;
diff --git a/src/emu/cpu/alph8201/8201dasm.c b/src/emu/cpu/alph8201/8201dasm.c
index 2e645a8c227..e2990a73d37 100644
--- a/src/emu/cpu/alph8201/8201dasm.c
+++ b/src/emu/cpu/alph8201/8201dasm.c
@@ -321,7 +321,7 @@ static void InitDasm8201(void)
Op[i].type = type;
/* 2 byte code ? */
- while (isspace(*p)) p++;
+ while (isspace((UINT8)*p)) p++;
if( (*p) )
Op[i].type |= 0x10;
/* number of param */
diff --git a/src/emu/cpu/pic16c5x/16c5xdsm.c b/src/emu/cpu/pic16c5x/16c5xdsm.c
index 66fccc9e327..35b3e2a900c 100644
--- a/src/emu/cpu/pic16c5x/16c5xdsm.c
+++ b/src/emu/cpu/pic16c5x/16c5xdsm.c
@@ -137,7 +137,7 @@ static void InitDasm16C5x(void)
fatalerror("not enough bits in encoding '%s %s' %d",
ops[0],ops[1],bit);
}
- while (isspace(*p)) p++;
+ while (isspace((UINT8)*p)) p++;
if (*p) Op[i].extcode = *p;
Op[i].bits = bits;
Op[i].mask = mask;
diff --git a/src/emu/cpu/tms32010/32010dsm.c b/src/emu/cpu/tms32010/32010dsm.c
index 722685fa078..ed8e488aa14 100644
--- a/src/emu/cpu/tms32010/32010dsm.c
+++ b/src/emu/cpu/tms32010/32010dsm.c
@@ -211,7 +211,7 @@ static void InitDasm32010(void)
fatalerror("not enough bits in encoding '%s %s' %d",
ops[0],ops[1],bit);
}
- while (isspace(*p)) p++;
+ while (isspace((UINT8)*p)) p++;
if (*p) Op[i].extcode = *p;
Op[i].bits = bits;
Op[i].mask = mask;
diff --git a/src/emu/cpu/tms32025/32025dsm.c b/src/emu/cpu/tms32025/32025dsm.c
index a93e2cd800b..028eaf5e8c1 100644
--- a/src/emu/cpu/tms32025/32025dsm.c
+++ b/src/emu/cpu/tms32025/32025dsm.c
@@ -373,7 +373,7 @@ static void InitDasm32025(void)
fatalerror("not enough bits in encoding '%s %s' %d",
ops[0],ops[1],bit);
}
- while (isspace(*p)) p++;
+ while (isspace((UINT8)*p)) p++;
if (*p) Op[i].extcode = *p;
Op[i].bits = bits;
Op[i].mask = mask;
diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c
index f08f5fa105c..628d07d9d72 100644
--- a/src/emu/debug/debugcmd.c
+++ b/src/emu/debug/debugcmd.c
@@ -1705,10 +1705,10 @@ static void execute_find(running_machine *machine, int ref, int params, const ch
{
/* check for a 'b','w','d',or 'q' prefix */
data_size[data_count] = cur_data_size;
- if (tolower(pdata[0]) == 'b' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 1; pdata += 2; }
- if (tolower(pdata[0]) == 'w' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 2; pdata += 2; }
- if (tolower(pdata[0]) == 'd' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 4; pdata += 2; }
- if (tolower(pdata[0]) == 'q' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 8; pdata += 2; }
+ if (tolower((UINT8)pdata[0]) == 'b' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 1; pdata += 2; }
+ if (tolower((UINT8)pdata[0]) == 'w' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 2; pdata += 2; }
+ if (tolower((UINT8)pdata[0]) == 'd' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 4; pdata += 2; }
+ if (tolower((UINT8)pdata[0]) == 'q' && pdata[1] == '.') { data_size[data_count] = cur_data_size = 8; pdata += 2; }
/* look for a wildcard */
if (!strcmp(pdata, "?"))
diff --git a/src/emu/debug/debugcon.c b/src/emu/debug/debugcon.c
index c56efb8f5ef..0bbf6ba476b 100644
--- a/src/emu/debug/debugcon.c
+++ b/src/emu/debug/debugcon.c
@@ -197,12 +197,12 @@ static CMDERR internal_execute_command(running_machine *machine, int execute, in
return CMDERR_NONE;
/* the first parameter has the command and the real first parameter; separate them */
- for (p = param[0]; *p && isspace(*p); p++) { }
- for (command = p; *p && !isspace(*p); p++) { }
+ for (p = param[0]; *p && isspace((UINT8)*p); p++) { }
+ for (command = p; *p && !isspace((UINT8)*p); p++) { }
if (*p != 0)
{
*p++ = 0;
- for ( ; *p && isspace(*p); p++) { }
+ for ( ; *p && isspace((UINT8)*p); p++) { }
if (*p != 0)
param[0] = p;
else
@@ -302,7 +302,7 @@ static CMDERR internal_parse_command(running_machine *machine, const char *origi
case '+': if (parendex == 0 && paramcount == 1 && p[1] == '+') isexpr = TRUE; *p = c; break;
case '=': if (parendex == 0 && paramcount == 1) isexpr = TRUE; *p = c; break;
case 0: foundend = TRUE; break;
- default: *p = tolower(c); break;
+ default: *p = tolower((UINT8)c); break;
}
}
}
@@ -321,7 +321,7 @@ static CMDERR internal_parse_command(running_machine *machine, const char *origi
command_start = params[0];
/* allow for "do" commands */
- if (tolower(command_start[0] == 'd') && tolower(command_start[1] == 'o') && isspace(command_start[2]))
+ if (tolower((UINT8)command_start[0] == 'd') && tolower((UINT8)command_start[1] == 'o') && isspace((UINT8)command_start[2]))
{
isexpr = TRUE;
command_start += 3;
diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c
index 911b9bbe72b..d1cfd348e55 100644
--- a/src/emu/debug/debugcpu.c
+++ b/src/emu/debug/debugcpu.c
@@ -235,8 +235,8 @@ void debug_cpu_init(running_machine *machine)
/* strip all spaces from the name and convert to lowercase */
for (charnum = 0; charnum < sizeof(symname) - 1 && str < colon; str++)
- if (!isspace(*str))
- symname[charnum++] = tolower(*str);
+ if (!isspace((UINT8)*str))
+ symname[charnum++] = tolower((UINT8)*str);
symname[charnum] = 0;
/* add the symbol to the table */
@@ -2133,7 +2133,7 @@ static void process_source_file(running_machine *machine)
/* strip whitespace */
i = (int)strlen(buf);
- while((i > 0) && (isspace(buf[i-1])))
+ while((i > 0) && (isspace((UINT8)buf[i-1])))
buf[--i] = '\0';
/* execute the command */
diff --git a/src/emu/debug/debughlp.c b/src/emu/debug/debughlp.c
index 9b3638f822a..8a975c90ff3 100644
--- a/src/emu/debug/debughlp.c
+++ b/src/emu/debug/debughlp.c
@@ -1048,7 +1048,7 @@ const char *debug_get_help(const char *tag)
/* make a lowercase copy of the tag */
for (i = 0; i <= taglen; i++)
- tagcopy[i] = tolower(tag[i]);
+ tagcopy[i] = tolower((UINT8)tag[i]);
/* find a match */
for (i = 0; i < sizeof(static_help_list) / sizeof(static_help_list[0]); i++)
diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c
index 765990a985d..fa1dcff71e1 100644
--- a/src/emu/debug/debugvw.c
+++ b/src/emu/debug/debugvw.c
@@ -1147,13 +1147,13 @@ static void registers_view_add_register(debug_view *view, int regnum, const char
}
/* now trim spaces */
- while (isspace(str[tagstart]) && taglen > 0)
+ while (isspace((UINT8)str[tagstart]) && taglen > 0)
tagstart++, taglen--;
- while (isspace(str[tagstart + taglen - 1]) && taglen > 0)
+ while (isspace((UINT8)str[tagstart + taglen - 1]) && taglen > 0)
taglen--;
- while (isspace(str[valstart]) && vallen > 0)
+ while (isspace((UINT8)str[valstart]) && vallen > 0)
valstart++, vallen--;
- while (isspace(str[valstart + vallen - 1]) && vallen > 0)
+ while (isspace((UINT8)str[valstart + vallen - 1]) && vallen > 0)
vallen--;
if (str[valstart] == '!')
valstart++, vallen--;
diff --git a/src/emu/debug/express.c b/src/emu/debug/express.c
index 906017bf0a7..c81a65311b5 100644
--- a/src/emu/debug/express.c
+++ b/src/emu/debug/express.c
@@ -627,7 +627,7 @@ static EXPRERR parse_string_into_tokens(const char *stringstart, parsed_expressi
while (string[0] != 0 && token - expr->token < MAX_TOKENS)
{
/* ignore any whitespace */
- while (string[0] != 0 && isspace(string[0]))
+ while (string[0] != 0 && isspace((UINT8)string[0]))
string++;
if (string[0] == 0)
break;
@@ -637,7 +637,7 @@ static EXPRERR parse_string_into_tokens(const char *stringstart, parsed_expressi
token->offset = string - stringstart;
/* switch off the first character */
- switch (tolower(string[0]))
+ switch (tolower((UINT8)string[0]))
{
case '(':
SET_TOKEN_INFO(1, TOK_OPERATOR, TVL_LPAREN, TIN_PRECEDENCE_0);
@@ -827,7 +827,7 @@ static EXPRERR parse_string_into_tokens(const char *stringstart, parsed_expressi
/* accumulate a lower-case version of the symbol */
while (1)
{
- char val = tolower(string[0]);
+ char val = tolower((UINT8)string[0]);
if (val == 0 || strchr(valid, val) == NULL)
break;
buffer[bufindex++] = val;
@@ -925,7 +925,7 @@ static EXPRERR parse_string_into_tokens(const char *stringstart, parsed_expressi
value = 0;
while (buffer[bufindex] != 0)
{
- const char *ptr = strchr(numbers, tolower(buffer[bufindex]));
+ const char *ptr = strchr(numbers, tolower((UINT8)buffer[bufindex]));
int digit;
if (ptr == NULL)
@@ -1967,7 +1967,7 @@ int symtable_add(symbol_table *table, const char *name, const symbol_entry *entr
all_digits = TRUE;
for (i = 0; name[i]; i++)
{
- if (!isdigit(name[i]))
+ if (!isdigit((UINT8)name[i]))
{
all_digits = FALSE;
break;
@@ -1999,7 +1999,7 @@ int symtable_add(symbol_table *table, const char *name, const symbol_entry *entr
/* copy the string, converting to lowercase */
for (strindex = 0; name[strindex] != 0; strindex++)
- newstring[strindex] = tolower(name[strindex]);
+ newstring[strindex] = tolower((UINT8)name[strindex]);
newstring[strindex] = 0;
/* fill in the details */
diff --git a/src/emu/driver.c b/src/emu/driver.c
index bcd2e7610dd..522c270fef3 100644
--- a/src/emu/driver.c
+++ b/src/emu/driver.c
@@ -205,7 +205,7 @@ static int penalty_compare(const char *source, const char *target)
for ( ; *source && *target; target++)
{
/* do a case insensitive match */
- int match = (tolower(*source) == tolower(*target));
+ int match = (tolower((UINT8)*source) == tolower((UINT8)*target));
/* if we matched, advance the source */
if (match)
diff --git a/src/emu/hash.c b/src/emu/hash.c
index bdf8fbb519e..00e227034ec 100644
--- a/src/emu/hash.c
+++ b/src/emu/hash.c
@@ -278,7 +278,7 @@ static int hash_compare_checksum(const char* chk1, const char* chk2, int length)
c1 = *chk1++;
c2 = *chk2++;
- if (tolower(c1) != tolower(c2))
+ if (tolower((UINT8)c1) != tolower((UINT8)c2))
return 0;
if (!c1)
return 0;
@@ -381,7 +381,7 @@ int hash_data_extract_printable_checksum(const char* data, unsigned int function
// Copy the checksum (and make it lowercase)
for (i=0;i<info->size*2;i++)
- checksum[i] = tolower(data[i]);
+ checksum[i] = tolower((UINT8)data[i]);
checksum[info->size*2] = '\0';
@@ -395,7 +395,7 @@ static int hex_string_to_binary(unsigned char* binary, const char* data, int siz
for (i = 0; i < size * 2; i++)
{
- c = tolower(*data++);
+ c = tolower((UINT8)*data++);
if (c >= '0' && c <= '9')
c -= '0';
@@ -590,7 +590,7 @@ void hash_data_print(const char* data, unsigned int functions, char* buffer)
strcpy(temp, hash_function_name(func));
for (j = 0; temp[j]; j++)
- temp[j] = toupper(temp[j]);
+ temp[j] = toupper((UINT8)temp[j]);
strcat(buffer, temp);
strcat(buffer, "(");
@@ -637,7 +637,7 @@ int hash_verify_string(const char *hash)
for (i = 0; (hash[i] != '#') && (i < len); i++)
{
- if (!isxdigit(hash[i]))
+ if (!isxdigit((UINT8)hash[i]))
return FALSE;
}
if (hash[i] != '#')
diff --git a/src/emu/inputseq.c b/src/emu/inputseq.c
index e2f481bfaa2..ea3a3b5829c 100644
--- a/src/emu/inputseq.c
+++ b/src/emu/inputseq.c
@@ -527,7 +527,7 @@ int input_seq_from_tokens(const char *string, input_seq *seq)
char *strtemp;
/* trim any leading spaces */
- while (*str != 0 && isspace(*str))
+ while (*str != 0 && isspace((UINT8)*str))
str++;
/* bail if we're done */
@@ -538,8 +538,8 @@ int input_seq_from_tokens(const char *string, input_seq *seq)
}
/* find the end of the token and make it upper-case along the way */
- for (strtemp = str; *strtemp != 0 && !isspace(*strtemp); strtemp++)
- *strtemp = toupper(*strtemp);
+ for (strtemp = str; *strtemp != 0 && !isspace((UINT8)*strtemp); strtemp++)
+ *strtemp = toupper((UINT8)*strtemp);
origspace = *strtemp;
*strtemp = 0;
diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c
index 2e54be3741d..772177856e6 100644
--- a/src/emu/uimenu.c
+++ b/src/emu/uimenu.c
@@ -3244,9 +3244,9 @@ static void menu_crosshair_populate(running_machine *machine, ui_menu *menu)
/* look for files ending in .png with a name not larger then 9 chars*/
if ((length > 4) && (length <= CROSSHAIR_PIC_NAME_LENGTH + 4) &&
dir->name[length - 4] == '.' &&
- tolower(dir->name[length - 3]) == 'p' &&
- tolower(dir->name[length - 2]) == 'n' &&
- tolower(dir->name[length - 1]) == 'g')
+ tolower((UINT8)dir->name[length - 3]) == 'p' &&
+ tolower((UINT8)dir->name[length - 2]) == 'n' &&
+ tolower((UINT8)dir->name[length - 1]) == 'g')
{
/* remove .png from length */
@@ -3557,7 +3557,7 @@ static void menu_select_game_build_driver_list(ui_menu *menu, select_game_state
/* build a name for it */
for (src = dir->name; *src != 0 && *src != '.' && dst < &drivername[ARRAY_LENGTH(drivername) - 1]; src++)
- *dst++ = tolower(*src);
+ *dst++ = tolower((UINT8)*src);
*dst = 0;
/* find it in the array */
diff --git a/src/emu/validity.c b/src/emu/validity.c
index f790755a30f..83517646af8 100644
--- a/src/emu/validity.c
+++ b/src/emu/validity.c
@@ -176,7 +176,7 @@ INLINE int validate_tag(const game_driver *driver, const char *object, const cha
for (p = tag; *p != 0; p++)
{
- if (*p != tolower(*p))
+ if (*p != tolower((UINT8)*p))
{
mame_printf_error("%s: %s has %s with tag '%s' containing upper-case characters\n", driver->source_file, driver->name, object, tag);
error = TRUE;
@@ -532,7 +532,7 @@ static int validate_driver(int drivnum, const machine_config *config)
/* make sure the year is only digits, '?' or '+' */
for (s = driver->year; *s; s++)
- if (!isdigit(*s) && *s != '?' && *s != '+')
+ if (!isdigit((UINT8)*s) && *s != '?' && *s != '+')
{
mame_printf_error("%s: %s has an invalid year '%s'\n", driver->source_file, driver->name, driver->year);
error = TRUE;
@@ -702,7 +702,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_info
/* make sure it's all lowercase */
for (s = last_name; *s; s++)
- if (tolower(*s) != *s)
+ if (tolower((UINT8)*s) != *s)
{
mame_printf_error("%s: %s has upper case ROM name %s\n", driver->source_file, driver->name, last_name);
error = TRUE;
diff --git a/src/lib/util/astring.c b/src/lib/util/astring.c
index cb5d23098a3..48f30fa83d4 100644
--- a/src/lib/util/astring.c
+++ b/src/lib/util/astring.c
@@ -498,9 +498,9 @@ int astring_icmpc(const astring *str1, const char *str2)
const char *s1 = str1->text;
/* loop while equal until we hit the end of strings */
- while (*s1 != 0 && *str2 != 0 && tolower(*s1) == tolower(*str2))
+ while (*s1 != 0 && *str2 != 0 && tolower((UINT8)*s1) == tolower((UINT8)*str2))
s1++, str2++;
- return tolower(*s1) - tolower(*str2);
+ return tolower((UINT8)*s1) - tolower((UINT8)*str2);
}
@@ -515,9 +515,9 @@ int astring_icmpch(const astring *str1, const char *str2, int count)
int result;
/* loop while equal until we hit the end of strings */
- while (count-- > 0 && *s1 != 0 && *str2 != 0 && tolower(*s1) == tolower(*str2))
+ while (count-- > 0 && *s1 != 0 && *str2 != 0 && tolower((UINT8)*s1) == tolower((UINT8)*str2))
s1++, str2++;
- result = (count == -1) ? 0 : tolower(*s1) - tolower(*str2);
+ result = (count == -1) ? 0 : tolower((UINT8)*s1) - tolower((UINT8)*str2);
if (result == 0 && *s1 != 0)
result = 1;
return result;
@@ -669,7 +669,7 @@ astring *astring_toupper(astring *str)
/* just toupper() on all characters */
for (text = str->text; *text != 0; text++)
- *text = toupper(*text);
+ *text = toupper((UINT8)*text);
return str;
}
@@ -686,7 +686,7 @@ astring *astring_tolower(astring *str)
/* just tolower() on all characters */
for (text = str->text; *text != 0; text++)
- *text = tolower(*text);
+ *text = tolower((UINT8)*text);
return str;
}
@@ -702,11 +702,11 @@ astring *astring_trimspace(astring *str)
char *ptr;
/* first remove stuff from the end */
- for (ptr = str->text + strlen(str->text) - 1; ptr >= str->text && (!(*ptr & 0x80) && isspace(*ptr)); ptr--)
+ for (ptr = str->text + strlen(str->text) - 1; ptr >= str->text && (!(*ptr & 0x80) && isspace((UINT8)*ptr)); ptr--)
*ptr = 0;
/* then count how much to remove from the beginning */
- for (ptr = str->text; *ptr != 0 && (!(*ptr & 0x80) && isspace(*ptr)); ptr++) ;
+ for (ptr = str->text; *ptr != 0 && (!(*ptr & 0x80) && isspace((UINT8)*ptr)); ptr++) ;
if (ptr > str->text)
astring_substr(str, ptr - str->text, -1);
diff --git a/src/lib/util/corefile.c b/src/lib/util/corefile.c
index c8ba2b1e0fb..a84451e5d3e 100644
--- a/src/lib/util/corefile.c
+++ b/src/lib/util/corefile.c
@@ -884,7 +884,7 @@ int core_filename_ends_with(const char *filename, const char *extension)
/* work backwards checking for a match */
while (extlen > 0)
- if (tolower(filename[--namelen]) != tolower(extension[--extlen]))
+ if (tolower((UINT8)filename[--namelen]) != tolower((UINT8)extension[--extlen]))
{
matches = FALSE;
break;
diff --git a/src/lib/util/corestr.c b/src/lib/util/corestr.c
index c30c7b453ce..2a8c502163e 100644
--- a/src/lib/util/corestr.c
+++ b/src/lib/util/corestr.c
@@ -10,6 +10,7 @@
****************************************************************************/
#include "corestr.h"
+#include "osdcore.h"
#include <ctype.h>
#include <stdlib.h>
@@ -22,8 +23,8 @@ int core_stricmp(const char *s1, const char *s2)
{
for (;;)
{
- int c1 = tolower(*s1++);
- int c2 = tolower(*s2++);
+ int c1 = tolower((UINT8)*s1++);
+ int c2 = tolower((UINT8)*s2++);
if (c1 == 0 || c1 != c2)
return c1 - c2;
}
@@ -39,8 +40,8 @@ int core_strnicmp(const char *s1, const char *s2, size_t n)
size_t i;
for (i = 0; i < n; i++)
{
- int c1 = tolower(*s1++);
- int c2 = tolower(*s2++);
+ int c1 = tolower((UINT8)*s1++);
+ int c2 = tolower((UINT8)*s2++);
if (c1 == 0 || c1 != c2)
return c1 - c2;
}
diff --git a/src/lib/util/options.c b/src/lib/util/options.c
index 3d1673fd0d2..2b6b62fbb84 100644
--- a/src/lib/util/options.c
+++ b/src/lib/util/options.c
@@ -483,7 +483,7 @@ int options_parse_ini_file(core_options *opts, core_file *inifile, int priority)
/* find the name */
for (optionname = buffer; *optionname != 0; optionname++)
- if (!isspace(*optionname))
+ if (!isspace((UINT8)*optionname))
break;
/* skip comments */
@@ -492,7 +492,7 @@ int options_parse_ini_file(core_options *opts, core_file *inifile, int priority)
/* scan forward to find the first space */
for (temp = optionname; *temp != 0; temp++)
- if (isspace(*temp))
+ if (isspace((UINT8)*temp))
break;
/* if we hit the end early, print a warning and continue */
@@ -973,9 +973,9 @@ static void update_data(core_options *opts, options_data *data, const char *newd
int i;
/* strip off leading/trailing spaces */
- while (isspace(*datastart) && datastart <= dataend)
+ while (isspace((UINT8)*datastart) && datastart <= dataend)
datastart++;
- while (isspace(*dataend) && datastart <= dataend)
+ while (isspace((UINT8)*dataend) && datastart <= dataend)
dataend--;
/* strip off quotes */
diff --git a/src/lib/util/xmlfile.c b/src/lib/util/xmlfile.c
index b400349a06d..9072c5e6a12 100644
--- a/src/lib/util/xmlfile.c
+++ b/src/lib/util/xmlfile.c
@@ -103,7 +103,7 @@ static const char *copystring_lower(const char *input)
if (newstr != NULL)
{
for (i = 0; input[i] != 0; i++)
- newstr[i] = tolower(input[i]);
+ newstr[i] = tolower((UINT8)input[i]);
newstr[i] = 0;
}
@@ -710,11 +710,11 @@ static void expat_element_end(void *data, const XML_Char *name)
char *end = start + strlen(start);
/* first strip leading spaces */
- while (*start && isspace(*start))
+ while (*start && isspace((UINT8)*start))
start++;
/* then strip trailing spaces */
- while (end > start && isspace(end[-1]))
+ while (end > start && isspace((UINT8)end[-1]))
end--;
/* if nothing left, just free it */
diff --git a/src/tools/chdcd.c b/src/tools/chdcd.c
index 5711f51ebd3..403840394cf 100644
--- a/src/tools/chdcd.c
+++ b/src/tools/chdcd.c
@@ -61,7 +61,7 @@ static int tokenize( const char *linebuffer, int i, int linebuffersize, char *to
int singlequote = 0;
int doublequote = 0;
- while ((i < linebuffersize) && isspace(linebuffer[i]))
+ while ((i < linebuffersize) && isspace((UINT8)linebuffer[i]))
{
i++;
}
@@ -76,7 +76,7 @@ static int tokenize( const char *linebuffer, int i, int linebuffersize, char *to
{
singlequote = !singlequote;
}
- else if (!singlequote && !doublequote && isspace(linebuffer[i]))
+ else if (!singlequote && !doublequote && isspace((UINT8)linebuffer[i]))
{
break;
}
@@ -298,7 +298,7 @@ chd_error chdcd_parse_toc(const char *tocfname, cdrom_toc *outtoc, chdcd_track_i
/* it's a decimal offset, use it */
f = strtoul(&token[1], NULL, 10);
}
- else if (isdigit(token[0]))
+ else if (isdigit((UINT8)token[0]))
{
/* convert the time to an offset */
f = msf_to_frames( token );
@@ -314,14 +314,14 @@ chd_error chdcd_parse_toc(const char *tocfname, cdrom_toc *outtoc, chdcd_track_i
TOKENIZE
- if (isdigit(token[0]))
+ if (isdigit((UINT8)token[0]))
{
// this could be the length or an offset from the previous field.
f = msf_to_frames( token );
TOKENIZE
- if (isdigit(token[0]))
+ if (isdigit((UINT8)token[0]))
{
// it was an offset.
f *= (outtoc->tracks[trknum].datasize + outtoc->tracks[trknum].subsize);
diff --git a/src/tools/chdman.c b/src/tools/chdman.c
index 0f2a8e8957c..8165710ab4f 100644
--- a/src/tools/chdman.c
+++ b/src/tools/chdman.c
@@ -313,7 +313,7 @@ static int do_createhd(int argc, char *argv[], int param)
/* if there are any non-digits in the 'offset', then treat it as a ident file */
for (scan = argv[4]; *scan != 0; scan++)
- if (!isdigit(*scan))
+ if (!isdigit((UINT8)*scan))
break;
if (*scan != 0)
{
diff --git a/src/tools/jedutil.c b/src/tools/jedutil.c
index 409dc55114c..7baf2d42933 100644
--- a/src/tools/jedutil.c
+++ b/src/tools/jedutil.c
@@ -191,16 +191,16 @@ int main(int argc, char *argv[])
/* does the source end in '.jed'? */
len = strlen(srcfile);
src_is_jed = (srcfile[len - 4] == '.' &&
- tolower(srcfile[len - 3]) == 'j' &&
- tolower(srcfile[len - 2]) == 'e' &&
- tolower(srcfile[len - 1]) == 'd');
+ tolower((UINT8)srcfile[len - 3]) == 'j' &&
+ tolower((UINT8)srcfile[len - 2]) == 'e' &&
+ tolower((UINT8)srcfile[len - 1]) == 'd');
/* does the destination end in '.jed'? */
len = strlen(dstfile);
dst_is_jed = (dstfile[len - 4] == '.' &&
- tolower(dstfile[len - 3]) == 'j' &&
- tolower(dstfile[len - 2]) == 'e' &&
- tolower(dstfile[len - 1]) == 'd');
+ tolower((UINT8)dstfile[len - 3]) == 'j' &&
+ tolower((UINT8)dstfile[len - 2]) == 'e' &&
+ tolower((UINT8)dstfile[len - 1]) == 'd');
/* error if neither or both are .jed */
if (!src_is_jed && !dst_is_jed)
diff --git a/src/tools/ldverify.c b/src/tools/ldverify.c
index 187bea0cefa..c51817c10b2 100644
--- a/src/tools/ldverify.c
+++ b/src/tools/ldverify.c
@@ -680,9 +680,9 @@ int main(int argc, char *argv[])
srcfilelen = strlen(srcfile);
if (srcfilelen < 4)
return usage();
- if (tolower(srcfile[srcfilelen-3]) == 'a' && tolower(srcfile[srcfilelen-2]) == 'v' && tolower(srcfile[srcfilelen-1]) == 'i')
+ if (tolower((UINT8)srcfile[srcfilelen-3]) == 'a' && tolower((UINT8)srcfile[srcfilelen-2]) == 'v' && tolower((UINT8)srcfile[srcfilelen-1]) == 'i')
isavi = TRUE;
- else if (tolower(srcfile[srcfilelen-3]) == 'c' && tolower(srcfile[srcfilelen-2]) == 'h' && tolower(srcfile[srcfilelen-1]) == 'd')
+ else if (tolower((UINT8)srcfile[srcfilelen-3]) == 'c' && tolower((UINT8)srcfile[srcfilelen-2]) == 'h' && tolower((UINT8)srcfile[srcfilelen-1]) == 'd')
isavi = FALSE;
else
return usage();
diff --git a/src/tools/regrep.c b/src/tools/regrep.c
index f5609ede11a..99346ab6d3f 100644
--- a/src/tools/regrep.c
+++ b/src/tools/regrep.c
@@ -177,12 +177,12 @@ INLINE char *trim_string(char *string)
int length;
/* trim leading spaces */
- while (*string != 0 && isspace(*string))
+ while (*string != 0 && isspace((UINT8)*string))
string++;
/* trim trailing spaces */
length = strlen(string);
- while (length > 0 && isspace(string[length - 1]))
+ while (length > 0 && isspace((UINT8)string[length - 1]))
string[--length] = 0;
return string;
@@ -400,7 +400,7 @@ static int read_summary_log(const char *filename, int index)
{
/* find the end of the line and normalize it with a CR */
for (curptr = linestart; *curptr != 0 && *curptr != '\n' && *curptr != '\r'; curptr++)
- if (!isspace(*curptr))
+ if (!isspace((UINT8)*curptr))
foundchars = 1;
*curptr++ = '\n';
*curptr = 0;
@@ -434,7 +434,7 @@ static int read_summary_log(const char *filename, int index)
char *end;
/* find the end */
- for (end = start; !isspace(*end); end++) ;
+ for (end = start; !isspace((UINT8)*end); end++) ;
*end = 0;
strcpy(lists[index].version, start);
fprintf(stderr, "Parsing results from version %s\n", lists[index].version);