From 7ea04c7f0fddcf36198ada66198fc65289b5dae7 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 28 Jun 2022 20:25:06 +0200 Subject: [PATCH] [isspace] Some implementations of isspace require unsigned char --- src/bfu/inpfield.c | 14 +++++----- src/bfu/text.c | 6 ++--- src/bookmarks/backend/xbel.c | 2 +- src/config/cmdline.c | 2 +- src/config/conf.c | 4 +-- src/config/options.c | 8 +++--- src/config/opttypes.c | 2 +- src/cookies/parser.c | 4 +-- src/document/dom/source.c | 4 +-- src/document/html/parser.c | 4 +-- src/document/html/parser/forms.c | 10 +++---- src/document/html/parser/parse.c | 42 +++++++++++++++--------------- src/document/html/renderer.c | 2 +- src/document/html/tables.c | 12 ++++----- src/document/plain/renderer.c | 2 +- src/document/xml/renderer2.c | 14 +++++----- src/dom/configuration.c | 2 +- src/dom/select.c | 4 +-- src/mime/backend/mailcap.c | 2 +- src/protocol/http/http_negotiate.c | 2 +- src/terminal/kbd.c | 4 +-- src/util/file.c | 2 +- src/util/string.h | 4 +-- src/viewer/text/form.c | 14 +++++----- 24 files changed, 83 insertions(+), 83 deletions(-) diff --git a/src/bfu/inpfield.c b/src/bfu/inpfield.c index d27d27c4..4133b8ba 100644 --- a/src/bfu/inpfield.c +++ b/src/bfu/inpfield.c @@ -601,9 +601,9 @@ kbd_field(struct dialog_data *dlg_data, struct widget_data *widget_data) int cdata_len = strlen(widget_data->cdata); int start = widget_data->info.field.cpos; - while (start > 0 && isspace(widget_data->cdata[start - 1])) + while (start > 0 && isspace((unsigned char)widget_data->cdata[start - 1])) --start; - while (start > 0 && !isspace(widget_data->cdata[start - 1])) + while (start > 0 && !isspace((unsigned char)widget_data->cdata[start - 1])) --start; memmove(widget_data->cdata + start, @@ -616,19 +616,19 @@ kbd_field(struct dialog_data *dlg_data, struct widget_data *widget_data) } case ACT_EDIT_MOVE_BACKWARD_WORD: - while (widget_data->info.field.cpos > 0 && isspace(widget_data->cdata[widget_data->info.field.cpos - 1])) + while (widget_data->info.field.cpos > 0 && isspace((unsigned char)widget_data->cdata[widget_data->info.field.cpos - 1])) --widget_data->info.field.cpos; - while (widget_data->info.field.cpos > 0 && !isspace(widget_data->cdata[widget_data->info.field.cpos - 1])) + while (widget_data->info.field.cpos > 0 && !isspace((unsigned char)widget_data->cdata[widget_data->info.field.cpos - 1])) --widget_data->info.field.cpos; goto display_field; case ACT_EDIT_MOVE_FORWARD_WORD: - while (isspace(widget_data->cdata[widget_data->info.field.cpos])) + while (isspace((unsigned char)widget_data->cdata[widget_data->info.field.cpos])) ++widget_data->info.field.cpos; - while (widget_data->cdata[widget_data->info.field.cpos] && !isspace(widget_data->cdata[widget_data->info.field.cpos])) + while (widget_data->cdata[widget_data->info.field.cpos] && !isspace((unsigned char)widget_data->cdata[widget_data->info.field.cpos])) ++widget_data->info.field.cpos; - while (isspace(widget_data->cdata[widget_data->info.field.cpos])) + while (isspace((unsigned char)widget_data->cdata[widget_data->info.field.cpos])) ++widget_data->info.field.cpos; goto display_field; diff --git a/src/bfu/text.c b/src/bfu/text.c index 8fba9353..bf597216 100644 --- a/src/bfu/text.c +++ b/src/bfu/text.c @@ -20,7 +20,7 @@ #include "util/color.h" /* FIXME: For UTF-8 strings we need better function than isspace. */ -#define is_unsplitable(pos) (*(pos) && *(pos) != '\n' && !isspace(*(pos))) +#define is_unsplitable(pos) (*(pos) && *(pos) != '\n' && !isspace((unsigned char)*(pos))) void add_dlg_text(struct dialog *dlg, char *text, @@ -175,7 +175,7 @@ split_lines(struct widget_data *widget_data, int max_width) int cells = 0; /* Skip first leading \n or space. */ - if (isspace(*text)) text++; + if (isspace((unsigned char)*text)) text++; if (!*text) break; #ifdef CONFIG_UTF8 @@ -230,7 +230,7 @@ dlg_format_text_do_node(struct dialog_data *dlg_data, int cells = 0; /* Skip first leading \n or space. */ - if (!firstline && isspace(*text)) + if (!firstline && isspace((unsigned char)*text)) text++; else firstline = 0; diff --git a/src/bookmarks/backend/xbel.c b/src/bookmarks/backend/xbel.c index e724da78..9d50834d 100644 --- a/src/bookmarks/backend/xbel.c +++ b/src/bookmarks/backend/xbel.c @@ -316,7 +316,7 @@ delete_whites(const char *s) * in section 2.3 of XML 1.1. U+0085 and U+2028 need * not be recognized here because section 2.11 says * the XML processor must translate them to U+000A. - * Do not use isspace() because the string is in UTF-8 + * Do not use isspace((unsigned char)) because the string is in UTF-8 * and individual bytes might not be characters at * all. */ switch (s[i]) { diff --git a/src/config/cmdline.c b/src/config/cmdline.c index ff9dff71..424bde6a 100644 --- a/src/config/cmdline.c +++ b/src/config/cmdline.c @@ -224,7 +224,7 @@ lookup_cmd(struct option *o, char ***argv, int *argc) } #define skipback_whitespace(start, S) \ - while ((start) < (S) && isspace((S)[-1])) (S)--; + while ((start) < (S) && isspace((unsigned char)(S)[-1])) (S)--; enum remote_method_enum { REMOTE_METHOD_OPENURL, diff --git a/src/config/conf.c b/src/config/conf.c index becfe499..818bafca 100644 --- a/src/config/conf.c +++ b/src/config/conf.c @@ -114,7 +114,7 @@ skip_white(struct conf_parsing_pos *pos) char *start = pos->look; while (*start) { - while (isspace(*start)) { + while (isspace((unsigned char)*start)) { if (*start == '\n') { pos->line++; } @@ -652,7 +652,7 @@ parse_config_command(struct option *options, struct conf_parsing_state *state, int cmdlen = strlen(handler->command); if (!strncmp(state->pos.look, handler->command, cmdlen) - && isspace(state->pos.look[cmdlen])) { + && isspace((unsigned char)state->pos.look[cmdlen])) { enum parse_error err; state->pos.look += cmdlen; diff --git a/src/config/options.c b/src/config/options.c index 051e5ff8..6fa69073 100644 --- a/src/config/options.c +++ b/src/config/options.c @@ -97,7 +97,7 @@ check_caption(char *caption) if (!len) return; c = caption[len - 1]; - if (isspace(c) || bad_punct(c)) + if (isspace((unsigned char)c) || bad_punct(c)) DBG("bad char at end of caption [%s]", caption); #ifdef CONFIG_NLS @@ -106,7 +106,7 @@ check_caption(char *caption) if (!len) return; c = caption[len - 1]; - if (isspace(c) || bad_punct(c)) + if (isspace((unsigned char)c) || bad_punct(c)) DBG("bad char at end of i18n caption [%s]", caption); #endif } @@ -125,7 +125,7 @@ check_description(char *desc) if (!len) return; c = desc[len - 1]; - if (isspace(c)) + if (isspace((unsigned char)c)) DBG("bad char at end of description [%s]", desc); #ifdef CONFIG_NLS @@ -137,7 +137,7 @@ check_description(char *desc) DBG("punctuation char possibly missing at end of i18n description [%s]", desc); c = desc[len - 1]; - if (isspace(c)) + if (isspace((unsigned char)c)) DBG("bad char at end of i18n description [%s]", desc); #endif } diff --git a/src/config/opttypes.c b/src/config/opttypes.c index 8340d9c4..570bbfef 100644 --- a/src/config/opttypes.c +++ b/src/config/opttypes.c @@ -213,7 +213,7 @@ num_rd(struct option *opt, char **file, int *line) /* Another trap for unwary - we need to check *end, not **file - reason * is left as an exercise to the reader. */ - if ((*end != 0 && (commandline || (!isspace(*end) && *end != '#'))) + if ((*end != 0 && (commandline || (!isspace((unsigned char)*end) && *end != '#'))) || (*value < opt->min || *value > opt->max)) { mem_free(value); return NULL; diff --git a/src/cookies/parser.c b/src/cookies/parser.c index fe075deb..006d6415 100644 --- a/src/cookies/parser.c +++ b/src/cookies/parser.c @@ -45,7 +45,7 @@ parse_cookie_str(struct cookie_str *cstr, char *str) cstr->str = str; /* Parse name token */ - while (*str != ';' && *str != '=' && !isspace(*str) && *str) + while (*str != ';' && *str != '=' && !isspace((unsigned char)*str) && *str) str++; /* Bail out if name token is empty */ @@ -83,7 +83,7 @@ parse_cookie_str(struct cookie_str *cstr, char *str) for (; *str != ';' && *str; str++) { /* Allow spaces in the value but leave out ending spaces */ - if (!isspace(*str)) + if (!isspace((unsigned char)*str)) cstr->val_end = str + 1; } diff --git a/src/document/dom/source.c b/src/document/dom/source.c index 7eba398e..d908ed07 100644 --- a/src/document/dom/source.c +++ b/src/document/dom/source.c @@ -259,7 +259,7 @@ render_dom_attribute_source(struct dom_stack *stack, struct dom_node *node, void * is at the start of the value string. */ for (skips = 0; skips < valuelen; skips++) { if ((quoted && skips == 0) - || isspace(value[skips]) + || isspace((unsigned char)value[skips]) || (unsigned char)value[skips] < ' ') continue; @@ -276,7 +276,7 @@ render_dom_attribute_source(struct dom_stack *stack, struct dom_node *node, void * link text. */ for (skips = 0; skips < valuelen; skips++) { if ((quoted && skips == 0) - || isspace(value[valuelen - skips - 1]) + || isspace((unsigned char)value[valuelen - skips - 1]) || (unsigned char)value[valuelen - skips - 1] < ' ') continue; diff --git a/src/document/html/parser.c b/src/document/html/parser.c index c581f733..c95fc54a 100644 --- a/src/document/html/parser.c +++ b/src/document/html/parser.c @@ -150,7 +150,7 @@ put_chrs(struct html_context *html_context, const char *start, int len) case HTML_SPACE_SUPPRESS: html_context->putsp = HTML_SPACE_NORMAL; - if (isspace(start[0])) { + if (isspace((unsigned char)start[0])) { start++, len--; if (!len) { @@ -162,7 +162,7 @@ put_chrs(struct html_context *html_context, const char *start, int len) break; } - if (isspace(start[len - 1]) && !html_is_preformatted()) { + if (isspace((unsigned char)start[len - 1]) && !html_is_preformatted()) { html_context->putsp = HTML_SPACE_SUPPRESS; } html_context->was_br = 0; diff --git a/src/document/html/parser/forms.c b/src/document/html/parser/forms.c index a7a7539e..5dfcc6a3 100644 --- a/src/document/html/parser/forms.c +++ b/src/document/html/parser/forms.c @@ -386,8 +386,8 @@ abort: char *q, *s = en; int l = html - en; - while (l && isspace(s[0])) s++, l--; - while (l && isspace(s[l-1])) l--; + while (l && isspace((unsigned char)s[0])) s++, l--; + while (l && isspace((unsigned char)s[l-1])) l--; q = convert_string(ct, s, l, html_context->options->cp, CSM_DEFAULT, NULL, NULL, NULL); @@ -574,8 +574,8 @@ html_option(struct html_context *html_context, char *a, } se: - while (p < html_context->eoff && isspace(*p)) p++; - while (p < html_context->eoff && !isspace(*p) && *p != '<') { + while (p < html_context->eoff && isspace((unsigned char)*p)) p++; + while (p < html_context->eoff && !isspace((unsigned char)*p) && *p != '<') { sp: add_char_to_string(&str, *p ? *p : ' '), p++; @@ -584,7 +584,7 @@ sp: r = p; val = str.source; /* Has to be before the possible 'goto end_parse' */ - while (r < html_context->eoff && isspace(*r)) r++; + while (r < html_context->eoff && isspace((unsigned char)*r)) r++; if (r >= html_context->eoff) goto end_parse; if (r - 2 <= html_context->eoff && (r[1] == '!' || r[1] == '?')) { p = skip_comment(r, html_context->eoff); diff --git a/src/document/html/parser/parse.c b/src/document/html/parser/parse.c index 3e61fef3..70fcc679 100644 --- a/src/document/html/parser/parse.c +++ b/src/document/html/parser/parse.c @@ -70,28 +70,28 @@ parse_element(char *e, char *eof, while (isident(*e)) next_char(); - if (!isspace(*e) && !end_of_tag(*e) && *e != '/' && *e != ':' && *e != '=') + if (!isspace((unsigned char)*e) && !end_of_tag(*e) && *e != '/' && *e != ':' && *e != '=') return -1; if (name && namelen) *namelen = e - *name; - while (isspace(*e) || *e == '/' || *e == ':') next_char(); + while (isspace((unsigned char)*e) || *e == '/' || *e == ':') next_char(); /* Skip bad attribute */ - while (!atchr(*e) && !end_of_tag(*e) && !isspace(*e)) next_char(); + while (!atchr(*e) && !end_of_tag(*e) && !isspace((unsigned char)*e)) next_char(); if (attr) *attr = e; next_attr: - while (isspace(*e)) next_char(); + while (isspace((unsigned char)*e)) next_char(); /* Skip bad attribute */ - while (!atchr(*e) && !end_of_tag(*e) && !isspace(*e)) next_char(); + while (!atchr(*e) && !end_of_tag(*e) && !isspace((unsigned char)*e)) next_char(); if (end_of_tag(*e)) goto end; while (atchr(*e)) next_char(); - while (isspace(*e)) next_char(); + while (isspace((unsigned char)*e)) next_char(); if (*e != '=') { if (end_of_tag(*e)) goto end; @@ -99,7 +99,7 @@ next_attr: } next_char(); - while (isspace(*e)) next_char(); + while (isspace((unsigned char)*e)) next_char(); if (isquote(*e)) { unsigned char quote = *e; @@ -115,10 +115,10 @@ next_attr: * long as this is commented out. --pasky */ /* if (*e == quote) goto quoted_value; */ } else { - while (!isspace(*e) && !end_of_tag(*e)) next_char(); + while (!isspace((unsigned char)*e) && !end_of_tag(*e)) next_char(); } - while (isspace(*e)) next_char(); + while (isspace((unsigned char)*e)) next_char(); if (!end_of_tag(*e)) goto next_attr; @@ -169,7 +169,7 @@ next_attr: if (found) { if (!isquote(*e)) { - while (!isspace(*e) && !end_of_tag(*e)) { + while (!isspace((unsigned char)*e) && !end_of_tag(*e)) { if (!*e) goto parse_error; add_chr(attr, attrlen, *e); e++; @@ -221,7 +221,7 @@ found_endattr: } else { if (!isquote(*e)) { - while (!isspace(*e) && !end_of_tag(*e)) { + while (!isspace((unsigned char)*e) && !end_of_tag(*e)) { if (!*e) goto parse_error; e++; } @@ -323,14 +323,14 @@ get_width2(char *value, int limited, struct html_context *html_context) for (len = 0; str[len] && str[len] != ','; len++); /* Go back, and skip spaces after width if any. */ - while (len && isspace(str[len - 1])) len--; + while (len && isspace((unsigned char)str[len - 1])) len--; if (!len) { return -1; } /* Nothing to parse. */ /* Is this a percentage ? */ if (str[len - 1] == '%') len--, percentage = 1; /* Skip spaces between width number and percentage if any. */ - while (len && isspace(str[len - 1])) len--; + while (len && isspace((unsigned char)str[len - 1])) len--; if (!len) { return -1; } /* Nothing to parse. */ /* Shorten the string a bit, so strtoul() will work on useful @@ -394,7 +394,7 @@ skip_comment(char *html, char *eof) if (html + 2 <= eof && html[0] == '-' && html[1] == '-') { html += 2; while (html < eof && *html == '-') html++; - while (html < eof && isspace(*html)) html++; + while (html < eof && isspace((unsigned char)*html)) html++; if (html >= eof) return eof; if (*html == '>') return html + 1; continue; @@ -693,10 +693,10 @@ main_loop: noupdate = 0; } - if (isspace(*html) && !html_is_preformatted()) { + if (isspace((unsigned char)*html) && !html_is_preformatted()) { char *h = html; - while (h < eof && isspace(*h)) + while (h < eof && isspace((unsigned char)*h)) h++; if (h + 1 < eof && h[0] == '<' && h[1] == '/') { if (!parse_element(h, eof, &name, &namelen, &attr, &end)) { @@ -709,9 +709,9 @@ main_loop: html++; if (!(html_context->position + (html - base_pos - 1))) goto skip_w; /* ??? */ - if (*(html - 1) == ' ') { /* Do not replace with isspace() ! --Zas */ + if (*(html - 1) == ' ') { /* Do not replace with isspace((unsigned char)) ! --Zas */ /* BIG performance win; not sure if it doesn't cause any bug */ - if (html < eof && !isspace(*html)) { + if (html < eof && !isspace((unsigned char)*html)) { noupdate = 1; continue; } @@ -722,7 +722,7 @@ main_loop: } skip_w: - while (html < eof && isspace(*html)) + while (html < eof && isspace((unsigned char)*html)) html++; continue; } @@ -778,7 +778,7 @@ next_break: dotcounter++; base_pos = ++html; - if (*html >= ' ' || isspace(*html) || html >= eof) { + if (*html >= ' ' || isspace((unsigned char)*html) || html >= eof) { char *dots = (char *)fmem_alloc(dotcounter); if (dots) { @@ -815,7 +815,7 @@ element: while (!parse_element(ee, eof, &nm, NULL, NULL, &ee)) if (*nm == '/') goto ng; - if (ee < eof && isspace(*ee)) { + if (ee < eof && isspace((unsigned char)*ee)) { put_chrs(html_context, " ", 1); } } diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 7d8c6559..9759766f 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -1833,7 +1833,7 @@ html_has_non_space_chars(const char *chars, int charslen) int pos = 0; while (pos < charslen) - if (!isspace(chars[pos++])) + if (!isspace((unsigned char)chars[pos++])) return 1; return 0; diff --git a/src/document/html/tables.c b/src/document/html/tables.c index 86cc6e76..aed1716f 100644 --- a/src/document/html/tables.c +++ b/src/document/html/tables.c @@ -714,10 +714,10 @@ get_table_caption_height(struct html_context *html_context, struct table *table) if (!start || !end) return 0; - while (start < end && isspace(*start)) + while (start < end && isspace((unsigned char)*start)) start++; - while (start < end && isspace(end[-1])) + while (start < end && isspace((unsigned char)end[-1])) end--; if (start >= end) return 0; @@ -1212,10 +1212,10 @@ draw_table_caption(struct html_context *html_context, struct table *table, if (!start || !end) return; - while (start < end && isspace(*start)) + while (start < end && isspace((unsigned char)*start)) start++; - while (start < end && isspace(end[-1])) + while (start < end && isspace((unsigned char)end[-1])) end--; if (start >= end) return; @@ -1252,10 +1252,10 @@ draw_table_bad_html(struct html_context *html_context, struct table *table) char *start = html->start; char *end = html->end; - while (start < end && isspace(*start)) + while (start < end && isspace((unsigned char)*start)) start++; - while (start < end && isspace(end[-1])) + while (start < end && isspace((unsigned char)end[-1])) end--; if (start >= end) continue; diff --git a/src/document/plain/renderer.c b/src/document/plain/renderer.c index 84d80d74..72191a44 100644 --- a/src/document/plain/renderer.c +++ b/src/document/plain/renderer.c @@ -760,7 +760,7 @@ add_document_lines(struct plain_renderer *renderer) step++; if (step) break; - if (isspace(source[width])) { + if (isspace((unsigned char)source[width])) { last_space = width; if (only_spaces) spaces++; diff --git a/src/document/xml/renderer2.c b/src/document/xml/renderer2.c index 221d7aea..82450d53 100644 --- a/src/document/xml/renderer2.c +++ b/src/document/xml/renderer2.c @@ -78,10 +78,10 @@ main_loop: noupdate = 0; } - if (isspace(*html) && !html_is_preformatted()) { + if (isspace((unsigned char)*html) && !html_is_preformatted()) { char *h = html; - while (h < eof && isspace(*h)) + while (h < eof && isspace((unsigned char)*h)) h++; if (h + 1 < eof && h[0] == '<' && h[1] == '/') { if (!parse_element(h, eof, &name, &namelen, &attr, &end)) { @@ -94,9 +94,9 @@ main_loop: html++; if (!(html_context->position + (html - base_pos - 1))) goto skip_w; /* ??? */ - if (*(html - 1) == ' ') { /* Do not replace with isspace() ! --Zas */ + if (*(html - 1) == ' ') { /* Do not replace with isspace((unsigned char)) ! --Zas */ /* BIG performance win; not sure if it doesn't cause any bug */ - if (html < eof && !isspace(*html)) { + if (html < eof && !isspace((unsigned char)*html)) { noupdate = 1; continue; } @@ -107,7 +107,7 @@ main_loop: } skip_w: - while (html < eof && isspace(*html)) + while (html < eof && isspace((unsigned char)*html)) html++; continue; } @@ -163,7 +163,7 @@ next_break: dotcounter++; base_pos = ++html; - if (*html >= ' ' || isspace(*html) || html >= eof) { + if (*html >= ' ' || isspace((unsigned char)*html) || html >= eof) { char *dots = (char *)fmem_alloc(dotcounter); if (dots) { @@ -200,7 +200,7 @@ element: /// while (!parse_element(ee, eof, &nm, NULL, NULL, &ee)) /// if (*nm == '/') /// goto ng; - if (ee < eof && isspace(*ee)) { + if (ee < eof && isspace((unsigned char)*ee)) { put_chrs(html_context, " ", 1); } } diff --git a/src/dom/configuration.c b/src/dom/configuration.c index ad4d5709..264716e4 100644 --- a/src/dom/configuration.c +++ b/src/dom/configuration.c @@ -28,7 +28,7 @@ normalize_text_node_whitespace(struct dom_node *node) for (j = 0; j < sizeof(buf) && i < node->string.length; i++) { char data = text[i]; - if (isspace(data)) { + if (isspace((unsigned char)data)) { if (count == 1) continue; diff --git a/src/dom/select.c b/src/dom/select.c index 50edf8df..e88f889d 100644 --- a/src/dom/select.c +++ b/src/dom/select.c @@ -689,7 +689,7 @@ match_attribute_value(struct dom_select_node *selector, struct dom_node *node) break; default: - if (isspace(str.string[str.length])) + if (isspace((unsigned char)str.string[str.length])) return 1; } } @@ -704,7 +704,7 @@ match_attribute_value(struct dom_select_node *selector, struct dom_node *node) break; default: - do_compare = isspace(str.string[0]); + do_compare = isspace((unsigned char)str.string[0]); } str.length--, str.string++; diff --git a/src/mime/backend/mailcap.c b/src/mime/backend/mailcap.c index f6ad5b15..75af4d7a 100644 --- a/src/mime/backend/mailcap.c +++ b/src/mime/backend/mailcap.c @@ -247,7 +247,7 @@ get_mailcap_field(char **next) } /* Remove trailing whitespace */ - while (field <= fieldend && isspace(*fieldend)) + while (field <= fieldend && isspace((unsigned char)*fieldend)) *fieldend-- = '\0'; return field; diff --git a/src/protocol/http/http_negotiate.c b/src/protocol/http/http_negotiate.c index 5adaa479..49272108 100644 --- a/src/protocol/http/http_negotiate.c +++ b/src/protocol/http/http_negotiate.c @@ -152,7 +152,7 @@ http_negotiate_parse_data(char *data, int type, else data += HTTPNEG_NEG_STRLEN; - while (*data && isspace((int) *data)) + while (*data && isspace((unsigned char)(int) *data)) data++; if (*data == '\0' || *data == ASCII_CR || *data == ASCII_LF) diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c index 6fe21760..9431b65a 100644 --- a/src/terminal/kbd.c +++ b/src/terminal/kbd.c @@ -801,7 +801,7 @@ get_esc_code(unsigned char *str, int len, char *final_byte, #ifdef DEBUG_ITRM_QUEUE #include -#include /* isprint() isspace() */ +#include /* isprint() isspace((unsigned char)) */ #endif int ui_double_esc; @@ -1144,7 +1144,7 @@ process_queue(struct itrm *itrm) for (i = 0; i < itrm->in.queue.len; i++) if (itrm->in.queue.data[i] == ASCII_ESC) fprintf(stderr, "ESC "); - else if (isprint(itrm->in.queue.data[i]) && !isspace(itrm->in.queue.data[i])) + else if (isprint(itrm->in.queue.data[i]) && !isspace((unsigned char)itrm->in.queue.data[i])) fprintf(stderr, "%c ", itrm->in.queue.data[i]); else fprintf(stderr, "0x%02x ", itrm->in.queue.data[i]); diff --git a/src/util/file.c b/src/util/file.c index 73b22ab2..4d45cd66 100644 --- a/src/util/file.c +++ b/src/util/file.c @@ -225,7 +225,7 @@ file_read_line(char *line, size_t *size, FILE *file, int *lineno) * the line is 'continued'. */ (*lineno)++; - while (line < linepos && isspace(*linepos)) + while (line < linepos && isspace((unsigned char)*linepos)) linepos--; if (*linepos != '\\') { diff --git a/src/util/string.h b/src/util/string.h index 306db6bc..34940bbe 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -126,10 +126,10 @@ char * c_strcasestr(const char *haystack, const char *needle); #define skip_space(S) \ - do { while (isspace(*(S))) (S)++; } while (0) + do { while (isspace((unsigned char)*(S))) (S)++; } while (0) #define skip_nonspace(S) \ - do { while (*(S) && !isspace(*(S))) (S)++; } while (0) + do { while (*(S) && !isspace((unsigned char)*(S))) (S)++; } while (0) #undef isdigit #define isdigit(c) ((c) >= '0' && (c) <= '9') diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index f0ef83fd..80962484 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -1816,9 +1816,9 @@ field_op(struct session *ses, struct document_view *doc_view, } text = &fs->value[fs->state]; - while (text > fs->value && isspace(*(text - 1))) + while (text > fs->value && isspace((unsigned char)*(text - 1))) --text; - while (text > fs->value && !isspace(*(text - 1))) + while (text > fs->value && !isspace((unsigned char)*(text - 1))) --text; if (*text == ASCII_LF && text != &fs->value[fs->state - 1]) @@ -1832,20 +1832,20 @@ field_op(struct session *ses, struct document_view *doc_view, case ACT_EDIT_MOVE_BACKWARD_WORD: while (fs->state > 0 - && isspace(fs->value[fs->state - 1])) + && isspace((unsigned char)fs->value[fs->state - 1])) --fs->state; while (fs->state > 0 - && !isspace(fs->value[fs->state - 1])) + && !isspace((unsigned char)fs->value[fs->state - 1])) --fs->state; break; case ACT_EDIT_MOVE_FORWARD_WORD: - while (isspace(fs->value[fs->state])) + while (isspace((unsigned char)fs->value[fs->state])) ++fs->state; while (fs->value[fs->state] - && !isspace(fs->value[fs->state])) + && !isspace((unsigned char)fs->value[fs->state])) ++fs->state; - while (isspace(fs->value[fs->state])) + while (isspace((unsigned char)fs->value[fs->state])) ++fs->state; break;