1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-21 00:25:37 +00:00

[isspace] Some implementations of isspace require unsigned char

This commit is contained in:
Witold Filipczyk 2022-06-28 20:25:06 +02:00
parent d25d85d781
commit 7ea04c7f0f
24 changed files with 83 additions and 83 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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]) {

View File

@ -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,

View File

@ -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;

View File

@ -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
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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++;

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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++;

View File

@ -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;

View File

@ -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)

View File

@ -801,7 +801,7 @@ get_esc_code(unsigned char *str, int len, char *final_byte,
#ifdef DEBUG_ITRM_QUEUE
#include <stdio.h>
#include <ctype.h> /* isprint() isspace() */
#include <ctype.h> /* 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]);

View File

@ -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 != '\\') {

View File

@ -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')

View File

@ -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;