Merge pull request #12768 from Jamiras/cheevos_ctype_uchar

(cheevos) explicitly cast to unsigned char for ctype functions
This commit is contained in:
Autechre 2021-08-09 14:18:20 +02:00 committed by GitHub
commit 92efe48db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 21 deletions

View File

@ -75,12 +75,12 @@ static int rc_json_parse_field(const char** json_ptr, rc_json_field_t* field) {
break;
default: /* non-quoted text [true,false,null] */
if (!isalpha(**json_ptr))
if (!isalpha((unsigned char)**json_ptr))
return RC_INVALID_JSON;
do {
++(*json_ptr);
} while (isalnum(**json_ptr));
} while (isalnum((unsigned char)**json_ptr));
break;
}
@ -101,7 +101,7 @@ static int rc_json_parse_array(const char** json_ptr, rc_json_field_t* field) {
if (*json != ']') {
do
{
while (isspace(*json))
while (isspace((unsigned char)*json))
++json;
result = rc_json_parse_field(&json, &unused_field);
@ -110,7 +110,7 @@ static int rc_json_parse_array(const char** json_ptr, rc_json_field_t* field) {
++field->array_size;
while (isspace(*json))
while (isspace((unsigned char)*json))
++json;
if (*json != ',')
@ -149,7 +149,7 @@ static int rc_json_parse_object(const char** json_ptr, rc_json_field_t* fields,
do
{
while (isspace(*json))
while (isspace((unsigned char)*json))
++json;
if (*json != '"')
@ -164,7 +164,7 @@ static int rc_json_parse_object(const char** json_ptr, rc_json_field_t* fields,
key_len = json - key_start;
++json;
while (isspace(*json))
while (isspace((unsigned char)*json))
++json;
if (*json != ':')
@ -172,7 +172,7 @@ static int rc_json_parse_object(const char** json_ptr, rc_json_field_t* fields,
++json;
while (isspace(*json))
while (isspace((unsigned char)*json))
++json;
field = &non_matching_field;
@ -186,7 +186,7 @@ static int rc_json_parse_object(const char** json_ptr, rc_json_field_t* fields,
if (rc_json_parse_field(&json, field) < 0)
return RC_INVALID_JSON;
while (isspace(*json))
while (isspace((unsigned char)*json))
++json;
if (*json != ',')
@ -277,12 +277,12 @@ static int rc_json_get_array_entry_value(rc_json_field_t* field, rc_json_field_t
if (!iterator->array_size)
return 0;
while (isspace(*iterator->value_start))
while (isspace((unsigned char)*iterator->value_start))
++iterator->value_start;
rc_json_parse_field(&iterator->value_start, field);
while (isspace(*iterator->value_start))
while (isspace((unsigned char)*iterator->value_start))
++iterator->value_start;
++iterator->value_start; /* skip , or ] */
@ -338,12 +338,12 @@ int rc_json_get_array_entry_object(rc_json_field_t* fields, size_t field_count,
if (!iterator->array_size)
return 0;
while (isspace(*iterator->value_start))
while (isspace((unsigned char)*iterator->value_start))
++iterator->value_start;
rc_json_parse_object(&iterator->value_start, fields, field_count);
while (isspace(*iterator->value_start))
while (isspace((unsigned char)*iterator->value_start))
++iterator->value_start;
++iterator->value_start; /* skip , or ] */

View File

@ -29,7 +29,7 @@ static int rc_parse_operand_lua(rc_operand_t* self, const char** memaddr, rc_par
return RC_INVALID_LUA_OPERAND;
}
if (!isalpha(*aux)) {
if (!isalpha((unsigned char)*aux)) {
return RC_INVALID_LUA_OPERAND;
}
@ -37,7 +37,7 @@ static int rc_parse_operand_lua(rc_operand_t* self, const char** memaddr, rc_par
id = aux;
#endif
while (isalnum(*aux) || *aux == '_') {
while (isalnum((unsigned char)*aux) || *aux == '_') {
aux++;
}

View File

@ -78,7 +78,7 @@ void rc_parse_legacy_value(rc_value_t* self, const char** memaddr, rc_parse_stat
}
else {
/* if it looks like a floating point number, add the 'f' prefix */
while (isdigit(*(unsigned char*)buffer_ptr))
while (isdigit((unsigned char)*buffer_ptr))
++buffer_ptr;
if (*buffer_ptr == '.')
*ptr++ = 'f';

View File

@ -58,7 +58,6 @@ static void filereader_seek(void* file_handle, int64_t offset, int origin)
#elif defined(_LARGEFILE64_SOURCE)
fseeko64((FILE*)file_handle, offset, origin);
#else
#pragma message("Using generic fseek may fail for large files")
fseek((FILE*)file_handle, offset, origin);
#endif
}
@ -1034,7 +1033,7 @@ static int rc_hash_dreamcast(char hash[33], const char* path)
/* the boot filename is 96 bytes into the meta information (https://mc.pp.se/dc/ip0000.bin.html) */
/* remove whitespace from bootfile */
i = 0;
while (!isspace(buffer[96 + i]) && i < 16)
while (!isspace((unsigned char)buffer[96 + i]) && i < 16)
++i;
/* sometimes boot file isn't present on meta information.
@ -1101,13 +1100,13 @@ static int rc_hash_find_playstation_executable(void* track_handle, const char* b
if (strncmp(ptr, boot_key, boot_key_len) == 0)
{
ptr += boot_key_len;
while (isspace(*ptr))
while (isspace((unsigned char)*ptr))
++ptr;
if (*ptr == '=')
{
++ptr;
while (isspace(*ptr))
while (isspace((unsigned char)*ptr))
++ptr;
if (strncmp(ptr, cdrom_prefix, cdrom_prefix_len) == 0)
@ -1116,7 +1115,7 @@ static int rc_hash_find_playstation_executable(void* track_handle, const char* b
++ptr;
start = ptr;
while (!isspace(*ptr) && *ptr != ';')
while (!isspace((unsigned char)*ptr) && *ptr != ';')
++ptr;
size = (unsigned)(ptr - start);
@ -1525,7 +1524,7 @@ static const char* rc_hash_get_first_item_from_playlist(const char* path)
next = ptr;
/* remove trailing whitespace - especially '\r' */
while (ptr > start && isspace(ptr[-1]))
while (ptr > start && isspace((unsigned char)ptr[-1]))
--ptr;
/* if we found a non-empty line, break out of the loop to process it */