From 158716f96adb53eed00b241745e26f88c0517fb4 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 11 Aug 2015 15:37:31 +0200 Subject: [PATCH] Fix ctype invocations with wrong domain. --- editor/modal.c++ | 10 +++++----- kernel/process.cpp | 4 ++-- mkinitrd/rules.cpp | 10 ++++++---- sh/sh.cpp | 4 ++-- tix/util.h | 10 +++++----- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/editor/modal.c++ b/editor/modal.c++ index d7d788d4..cd601686 100644 --- a/editor/modal.c++ +++ b/editor/modal.c++ @@ -111,9 +111,9 @@ void editor_modal_save(struct editor* editor, const char* path) void editor_modal_ask_quit(struct editor* editor, const char* answer) { - if ( tolower(answer[0]) == 'y' ) + if ( tolower((unsigned char) answer[0]) == 'y' ) editor->mode = MODE_QUIT; - else if ( tolower(answer[0]) == 'n' || !answer[0] ) + else if ( tolower((unsigned char) answer[0]) == 'n' || !answer[0] ) editor_type_edit(editor); else editor->modal_error = true; @@ -235,10 +235,10 @@ bool is_modal_command(const char* cmd, const char* candidate, const char** rest) { size_t candidate_len = strlen(candidate); if ( strncmp(cmd, candidate, candidate_len) == 0 && - (!cmd[candidate_len] || isspace(cmd[candidate_len])) ) + (!cmd[candidate_len] || isspace((unsigned char) cmd[candidate_len])) ) { *rest = cmd + candidate_len; - while ( **rest && isspace(**rest) ) + while ( **rest && isspace((unsigned char) **rest) ) (*rest)++; return true; } @@ -247,7 +247,7 @@ bool is_modal_command(const char* cmd, const char* candidate, const char** rest) void editor_modal_command(struct editor* editor, const char* cmd) { - while ( *cmd && isspace(*cmd) ) + while ( *cmd && isspace((unsigned char) *cmd) ) cmd++; if ( cmd[0] == ':' ) cmd++; diff --git a/kernel/process.cpp b/kernel/process.cpp index ffbc6a00..82e83761 100644 --- a/kernel/process.cpp +++ b/kernel/process.cpp @@ -1065,7 +1065,7 @@ static char* shebang_tokenize(char** saved) char* data = *saved; if ( !data ) return *saved = NULL; - while ( data[0] && isspace(data[0]) ) + while ( data[0] && isspace((unsigned char) data[0]) ) data++; if ( !data[0] ) return *saved = NULL; @@ -1077,7 +1077,7 @@ static char* shebang_tokenize(char** saved) for ( ; data[input]; input++ ) { char c = data[input]; - if ( !escaped && !singly && !doubly && isspace(c) ) + if ( !escaped && !singly && !doubly && isspace((unsigned char) c) ) break; if ( !escaped && !doubly && c == '\'' ) { diff --git a/mkinitrd/rules.cpp b/mkinitrd/rules.cpp index 80479216..9014fca5 100644 --- a/mkinitrd/rules.cpp +++ b/mkinitrd/rules.cpp @@ -167,7 +167,8 @@ bool InclusionRules::AddRule(InclusionRule* rule) static const char* SkipWhitespace(const char* line) { - while ( *line && isspace(*line) ) line++; + while ( *line && isspace((unsigned char) *line) ) + line++; return line; } @@ -183,13 +184,14 @@ static bool IsLineComment(const char* line) static const char* IsLineCommand(const char* line, const char* command) { - while ( *line && isspace(*line) ) line++; + while ( *line && isspace((unsigned char) *line) ) + line++; size_t cmdlen = strlen(command); if ( strncmp(line, command, cmdlen) != 0 ) return NULL; - if ( line[cmdlen] && !isspace(line[cmdlen]) ) + if ( line[cmdlen] && !isspace((unsigned char) line[cmdlen]) ) return NULL; - while ( line[cmdlen] && isspace(line[cmdlen]) ) + while ( line[cmdlen] && isspace((unsigned char) line[cmdlen]) ) cmdlen++; return line + cmdlen; } diff --git a/sh/sh.cpp b/sh/sh.cpp index e028ba4e..ee2c66c1 100644 --- a/sh/sh.cpp +++ b/sh/sh.cpp @@ -1718,7 +1718,7 @@ void on_trap_eof(void* edit_state_ptr) bool is_usual_char_for_completion(char c) { - return !isspace(c) && + return !isspace((unsigned char) c) && c != ';' && c != '&' && c != '|' && c != '<' && c != '>' && c != '#' && c != '$'; } @@ -1762,7 +1762,7 @@ size_t do_complete(char*** completions_ptr, else { size_t type_offset = complete_at - used_before; - while ( type_offset && isspace(partial[type_offset-1]) ) + while ( type_offset && isspace((unsigned char) partial[type_offset-1]) ) type_offset--; if ( 2 <= type_offset && diff --git a/tix/util.h b/tix/util.h index b3f1fb70..cf1dd29a 100644 --- a/tix/util.h +++ b/tix/util.h @@ -136,7 +136,7 @@ bool string_array_append_token_string(string_array_t* sa, const char* str) { while ( *str ) { - if ( isspace(*str) ) + if ( isspace((unsigned char) *str) ) { str++; continue; @@ -147,7 +147,7 @@ bool string_array_append_token_string(string_array_t* sa, const char* str) bool quoted = false; bool escaped = false; while ( str[input_length] && - (escaped || quoted || !isspace(str[input_length])) ) + (escaped || quoted || !isspace((unsigned char) str[input_length])) ) { if ( !escaped && str[input_length] == '\\' ) escaped = true; @@ -170,7 +170,7 @@ bool string_array_append_token_string(string_array_t* sa, const char* str) quoted = false; escaped = false; while ( str[input_length] && - (escaped || quoted || !isspace(str[input_length])) ) + (escaped || quoted || !isspace((unsigned char) str[input_length])) ) { if ( !escaped && str[input_length] == '\\' ) escaped = true; @@ -215,7 +215,7 @@ bool string_array_append_token_string(string_array_t* sa, const char* str) bool is_token_string_special_character(char c) { - return isspace(c) || c == '"' || c == '\\'; + return isspace((unsigned char) c) || c == '"' || c == '\\'; } char* token_string_of_string_array(const string_array_t* sa) @@ -333,7 +333,7 @@ void dictionary_normalize_entry(char* entry) size_t input_off, output_off; for ( input_off = output_off = 0; entry[input_off]; input_off++ ) { - if ( key && isspace(entry[input_off]) ) + if ( key && isspace((unsigned char) entry[input_off]) ) continue; if ( key && (entry[input_off] == '=' || entry[input_off] == '#') ) key = false;