Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/spss/readstat_sav_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ static readstat_error_t sav_validate_name_chars(const char *name, int unicode) {
if (name[j] == ' ')
return READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER;

if ((name[j] > 0 || !unicode) && name[j] != '@' &&
if (((unsigned char)name[j] < 0x80 || !unicode) && name[j] != '@' &&
name[j] != '.' && name[j] != '_' &&
name[j] != '$' && name[j] != '#' &&
!(name[j] >= 'a' && name[j] <= 'z') &&
Expand All @@ -1246,7 +1246,7 @@ static readstat_error_t sav_validate_name_chars(const char *name, int unicode) {
}
}
char first_char = name[0];
if ((first_char > 0 || !unicode) && first_char != '@' &&
if (((unsigned char)first_char < 0x80 || !unicode) && first_char != '@' &&
!(first_char >= 'a' && first_char <= 'z') &&
!(first_char >= 'A' && first_char <= 'Z')) {
return READSTAT_ERROR_NAME_BEGINS_WITH_ILLEGAL_CHARACTER;
Expand Down
4 changes: 2 additions & 2 deletions src/stata/readstat_dta_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,15 @@ static readstat_error_t dta_validate_name_chars(const char *name, int unicode) {
/* TODO check Unicode class */
int j;
for (j=0; name[j]; j++) {
if ((name[j] > 0 || !unicode) && name[j] != '_' &&
if (((unsigned char)name[j] < 0x80 || !unicode) && name[j] != '_' &&
!(name[j] >= 'a' && name[j] <= 'z') &&
!(name[j] >= 'A' && name[j] <= 'Z') &&
!(name[j] >= '0' && name[j] <= '9')) {
return READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER;
}
}
char first_char = name[0];
if ((first_char > 0 || !unicode) && first_char != '_' &&
if (((unsigned char)first_char < 0x80 || !unicode) && first_char != '_' &&
!(first_char >= 'a' && first_char <= 'z') &&
!(first_char >= 'A' && first_char <= 'Z')) {
return READSTAT_ERROR_NAME_BEGINS_WITH_ILLEGAL_CHARACTER;
Expand Down