From 90f037c76ed944baedbe01f0be443b7d99803b1a Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Thu, 4 Aug 2022 09:21:19 -0700 Subject: wip: change ISSPACE to use ascii whitespace check. Add check_sec.sh test for isspace. The only place that seems to want the locale-dependent is in mbyte.c. --- browser.c | 4 ++-- check_sec.sh | 1 + crypt.c | 4 ++-- edit.c | 4 ++-- from.c | 10 +++++----- handler.c | 4 ++-- headers.c | 2 +- help.c | 2 +- hook.c | 4 ++-- imap/command.c | 16 ++++++++-------- imap/imap.c | 12 ++++++------ imap/message.c | 16 ++++++++-------- imap/util.c | 6 +++--- init.c | 26 +++++++++++++------------- keymap.c | 2 +- lib.c | 8 ++++---- lib.h | 41 ++++++++++++++++++++++++++++------------- mbyte.c | 4 ++-- mutt_lisp.c | 10 +++++----- muttlib.c | 2 +- pager.c | 2 +- parse.c | 6 +++--- pattern.c | 16 ++++++++-------- pgp.c | 2 +- pgpmicalg.c | 2 +- pop_lib.c | 2 +- rfc1524.c | 6 +++--- sendlib.c | 6 +++--- 28 files changed, 118 insertions(+), 102 deletions(-) diff --git a/browser.c b/browser.c index 4f365ebd..15bbac72 100644 --- a/browser.c +++ b/browser.c @@ -1333,11 +1333,11 @@ void _mutt_buffer_select_file (BUFFER *f, int flags, char ***files, int *numfile /* assume that the user wants to see everything */ if (!(mutt_buffer_len (buf))) mutt_buffer_strcpy (buf, "."); - SKIPWS (s); + SKIP_LOCALE_WS (s); if (*s == '!') { s++; - SKIPWS (s); + SKIP_LOCALE_WS (s); not = 1; } diff --git a/check_sec.sh b/check_sec.sh index 3655aecb..8b1b7a51 100755 --- a/check_sec.sh +++ b/check_sec.sh @@ -38,6 +38,7 @@ do_check '\= tmp && ISSPACE (*p)) + while (p >= tmp && IS_LOCALE_WS (*p)) *p-- = 0; p = tmp + 2; - SKIPWS (p); + SKIP_LOCALE_WS (p); switch (tmp[1]) { diff --git a/from.c b/from.c index 47f5c76d..0cda59a5 100644 --- a/from.c +++ b/from.c @@ -28,9 +28,9 @@ static const char *next_word (const char *s) { - while (*s && !ISSPACE (*s)) + while (*s && !IS_ASCII_WS (*s)) s++; - SKIPWS (s); + SKIP_ASCII_WS (s); return s; } @@ -48,7 +48,7 @@ static int is_day_name (const char *s) { int i; - if ((strlen (s) < 3) || !*(s + 3) || !ISSPACE (*(s+3))) + if ((strlen (s) < 3) || !*(s + 3) || !IS_ASCII_WS (*(s+3))) return 0; for (i=0; i<7; i++) if (mutt_strncasecmp (s, Weekdays[i], 3) == 0) @@ -85,7 +85,7 @@ int is_from (const char *s, char *path, size_t pathlen, time_t *tp) size_t len; short q = 0; - for (p = s; *p && (q || !ISSPACE (*p)); p++) + for (p = s; *p && (q || !IS_ASCII_WS (*p)); p++) { if (*p == '\\') { @@ -122,7 +122,7 @@ int is_from (const char *s, char *path, size_t pathlen, time_t *tp) } s = p + 1; - SKIPWS (s); + SKIP_ASCII_WS (s); if (!*s) return 0; diff --git a/handler.c b/handler.c index 697c87e2..3d0ac72f 100644 --- a/handler.c +++ b/handler.c @@ -269,7 +269,7 @@ static void mutt_decode_quoted (STATE *s, LOFF_T len, int istext, iconv_t cd) /* chop trailing whitespace if we got the full line */ if (last == '\n') { - while (linelen > 0 && ISSPACE (line[linelen-1])) + while (linelen > 0 && IS_ASCII_WS (line[linelen-1])) linelen--; line[linelen]=0; } @@ -391,7 +391,7 @@ static void mutt_decode_uuencoded (STATE *s, LOFF_T len, int istext, iconv_t cd) if ((fgets(tmps, sizeof(tmps), s->fpin)) == NULL) goto cleanup; len -= mutt_strlen(tmps); - if ((!mutt_strncmp (tmps, "begin", 5)) && ISSPACE (tmps[5])) + if ((!mutt_strncmp (tmps, "begin", 5)) && IS_ASCII_WS (tmps[5])) break; } while (len > 0) diff --git a/headers.c b/headers.c index 063525ea..bf5803e8 100644 --- a/headers.c +++ b/headers.c @@ -325,7 +325,7 @@ int mutt_label_message(HEADER *hdr) return 0; new = buf; - SKIPWS(new); + SKIP_LOCALE_WS(new); if (*new == '\0') new = NULL; diff --git a/help.c b/help.c index 29dda797..83e13904 100644 --- a/help.c +++ b/help.c @@ -256,7 +256,7 @@ static void format_line (FILE *f, int ismacro, if (ismacro >= 0) { - SKIPWS(t3); + SKIP_ASCII_WS(t3); n = get_wrapped_width (t3, n); } diff --git a/hook.c b/hook.c index a0a6cab6..97e0d193 100644 --- a/hook.c +++ b/hook.c @@ -63,7 +63,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER if (*s->dptr == '!') { s->dptr++; - SKIPWS (s->dptr); + SKIP_ASCII_WS (s->dptr); not = 1; } @@ -346,7 +346,7 @@ int mutt_parse_idxfmt_hook (BUFFER *buf, BUFFER *s, union pointer_long_t udata, if (*s->dptr == '!') { s->dptr++; - SKIPWS (s->dptr); + SKIP_ASCII_WS (s->dptr); not = 1; } mutt_extract_token (pattern, s, 0); diff --git a/imap/command.c b/imap/command.c index c05ee459..05537436 100644 --- a/imap/command.c +++ b/imap/command.c @@ -595,7 +595,7 @@ static int cmd_handle_untagged (IMAP_DATA* idata) /* server shut down our connection */ s += 3; - SKIPWS (s); + SKIP_ASCII_WS (s); mutt_error ("%s", s); mutt_sleep (2); cmd_handle_fatal (idata); @@ -822,7 +822,7 @@ static void cmd_parse_fetch (IMAP_DATA* idata, char* s) while (*s) { - SKIPWS (s); + SKIP_ASCII_WS (s); if (ascii_strncasecmp ("FLAGS", s, 5) == 0) { @@ -831,7 +831,7 @@ static void cmd_parse_fetch (IMAP_DATA* idata, char* s) break; s += 5; - SKIPWS(s); + SKIP_ASCII_WS(s); if (*s != '(') { dprint (1, (debugfile, "cmd_parse_fetch: bogus FLAGS response: %s\n", @@ -853,7 +853,7 @@ static void cmd_parse_fetch (IMAP_DATA* idata, char* s) else if (ascii_strncasecmp ("UID", s, 3) == 0) { s += 3; - SKIPWS (s); + SKIP_ASCII_WS (s); if (mutt_atoui (s, &uid, MUTT_ATOI_ALLOW_TRAILING) < 0) { dprint (1, (debugfile, "cmd_parse_fetch: Illegal UID. Skipping update.\n")); @@ -872,7 +872,7 @@ static void cmd_parse_fetch (IMAP_DATA* idata, char* s) else if (ascii_strncasecmp ("MODSEQ", s, 6) == 0) { s += 6; - SKIPWS(s); + SKIP_ASCII_WS(s); if (*s != '(') { dprint (1, (debugfile, "cmd_parse_fetch: bogus MODSEQ response: %s\n", @@ -984,7 +984,7 @@ static void cmd_parse_list (IMAP_DATA* idata, char* s) { *s = '\0'; s++; - SKIPWS(s); + SKIP_ASCII_WS(s); } } else @@ -1055,7 +1055,7 @@ static void cmd_parse_myrights (IMAP_DATA* idata, const char* s) /* zero out current rights set */ memset (idata->ctx->rights, 0, sizeof (idata->ctx->rights)); - while (*s && !isspace((unsigned char) *s)) + while (*s && !IS_ASCII_WS((unsigned char) *s)) { switch (*s) { @@ -1164,7 +1164,7 @@ static void cmd_parse_status (IMAP_DATA* idata, char* s) s = mailbox + litlen; *s = '\0'; s++; - SKIPWS(s); + SKIP_ASCII_WS(s); } else { diff --git a/imap/imap.c b/imap/imap.c index 445cff2e..da5797ed 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -729,7 +729,7 @@ static char* imap_get_flags (LIST** hflags, char* s) return NULL; } s += 5; - SKIPWS(s); + SKIP_ASCII_WS(s); if (*s != '(') { dprint (1, (debugfile, "imap_get_flags: bogus FLAGS response: %s\n", @@ -744,9 +744,9 @@ static char* imap_get_flags (LIST** hflags, char* s) while (*s && *s != ')') { s++; - SKIPWS(s); + SKIP_ASCII_WS(s); flag_word = s; - while (*s && (*s != ')') && !ISSPACE (*s)) + while (*s && (*s != ')') && !IS_ASCII_WS (*s)) s++; ctmp = *s; *s = '\0'; @@ -1372,7 +1372,7 @@ int imap_sync_message_for_copy (IMAP_DATA *idata, HEADER *hdr, BUFFER *cmd, if (mutt_bit_isset (idata->ctx->rights, MUTT_ACL_WRITE)) imap_add_keywords (flags, hdr, idata->flags, sizeof (flags)); - mutt_remove_trailing_ws (flags); + mutt_remove_trailing_ascii_ws (flags); /* UW-IMAP is OK with null flags, Cyrus isn't. The only solution is to * explicitly revoke all system flags (if we have permission) */ @@ -1385,7 +1385,7 @@ int imap_sync_message_for_copy (IMAP_DATA *idata, HEADER *hdr, BUFFER *cmd, imap_set_flag (idata, MUTT_ACL_DELETE, !HEADER_DATA(hdr)->deleted, "\\Deleted ", flags, sizeof (flags)); - mutt_remove_trailing_ws (flags); + mutt_remove_trailing_ascii_ws (flags); mutt_buffer_addstr (cmd, " -FLAGS.SILENT ("); } @@ -2220,7 +2220,7 @@ static int imap_compile_search (const pattern_t* pat, BUFFER* buf) /* and field */ *delim = ':'; delim++; - SKIPWS(delim); + SKIP_ASCII_WS(delim); imap_quote_string (term, sizeof (term), delim); mutt_buffer_addstr (buf, term); break; diff --git a/imap/message.c b/imap/message.c index 376b91dc..3ecfd001 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1924,7 +1924,7 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s) while (*s) { - SKIPWS (s); + SKIP_ASCII_WS (s); if (ascii_strncasecmp ("FLAGS", s, 5) == 0) { @@ -1934,7 +1934,7 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s) else if (ascii_strncasecmp ("UID", s, 3) == 0) { s += 3; - SKIPWS (s); + SKIP_ASCII_WS (s); if (mutt_atoui (s, &h->data->uid, MUTT_ATOI_ALLOW_TRAILING) < 0) return -1; @@ -1943,7 +1943,7 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s) else if (ascii_strncasecmp ("INTERNALDATE", s, 12) == 0) { s += 12; - SKIPWS (s); + SKIP_ASCII_WS (s); if (*s != '\"') { dprint (1, (debugfile, "msg_parse_fetch(): bogus INTERNALDATE entry: %s\n", s)); @@ -1966,7 +1966,7 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s) else if (ascii_strncasecmp ("RFC822.SIZE", s, 11) == 0) { s += 11; - SKIPWS (s); + SKIP_ASCII_WS (s); ptmp = tmp; dlen = sizeof(tmp) - 1; while (isdigit ((unsigned char) *s) && dlen) @@ -1987,7 +1987,7 @@ static int msg_parse_fetch (IMAP_HEADER *h, char *s) else if (ascii_strncasecmp ("MODSEQ", s, 6) == 0) { s += 6; - SKIPWS(s); + SKIP_ASCII_WS(s); if (*s != '(') { dprint (1, (debugfile, "msg_parse_flags: bogus MODSEQ response: %s\n", @@ -2032,7 +2032,7 @@ static char* msg_parse_flags (IMAP_HEADER* h, char* s) return NULL; } s += 5; - SKIPWS(s); + SKIP_ASCII_WS(s); if (*s != '(') { dprint (1, (debugfile, "msg_parse_flags: bogus FLAGS response: %s\n", @@ -2083,14 +2083,14 @@ static char* msg_parse_flags (IMAP_HEADER* h, char* s) if (!hd->keywords) hd->keywords = mutt_new_list (); - while (*s && !ISSPACE (*s) && *s != ')') + while (*s && !IS_ASCII_WS (*s) && *s != ')') s++; ctmp = *s; *s = '\0'; mutt_add_list (hd->keywords, flag_word); *s = ctmp; } - SKIPWS(s); + SKIP_ASCII_WS(s); } /* wrap up, or note bad flags response */ diff --git a/imap/util.c b/imap/util.c index 2eb2edba..31a02000 100644 --- a/imap/util.c +++ b/imap/util.c @@ -656,12 +656,12 @@ char *imap_next_word (char *s) } if (*s == '\"') quoted = quoted ? 0 : 1; - if (!quoted && ISSPACE (*s)) + if (!quoted && IS_ASCII_WS (*s)) break; s++; } - SKIPWS (s); + SKIP_ASCII_WS (s); return s; } @@ -889,7 +889,7 @@ int imap_wordcasecmp(const char *a, const char *b) tmp[SHORT_STRING-1] = 0; for (i=0;i < SHORT_STRING-2;i++,s++) { - if (!*s || ISSPACE(*s)) + if (!*s || IS_ASCII_WS(*s)) { tmp[i] = 0; break; diff --git a/init.c b/init.c index c84815c2..2d7fd611 100644 --- a/init.c +++ b/init.c @@ -184,13 +184,13 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags) mutt_buffer_increase_size (dest, STRING); mutt_buffer_clear (dest); - SKIPWS (tok->dptr); + SKIP_ASCII_WS (tok->dptr); if ((*tok->dptr == '(') && !(flags & MUTT_TOKEN_NOLISP) && ((flags & MUTT_TOKEN_LISP) || option (OPTMUTTLISPINLINEEVAL))) { int rc = mutt_lisp_eval_list (dest, tok); - SKIPWS (tok->dptr); + SKIP_ASCII_WS (tok->dptr); return rc; } @@ -198,7 +198,7 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags) { if (!qc) { - if ((ISSPACE (ch) && !(flags & MUTT_TOKEN_SPACE)) || + if ((IS_ASCII_WS (ch) && !(flags & MUTT_TOKEN_SPACE)) || (ch == '#' && !(flags & MUTT_TOKEN_COMMENT)) || (ch == '=' && (flags & MUTT_TOKEN_EQUAL)) || (ch == ';' && !(flags & MUTT_TOKEN_SEMICOLON)) || @@ -391,7 +391,7 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags) else mutt_buffer_addch (dest, ch); } - SKIPWS (tok->dptr); + SKIP_ASCII_WS (tok->dptr); return 0; } @@ -2231,7 +2231,7 @@ static int parse_setenv(BUFFER *tmp, BUFFER *s, union pointer_long_t udata, BUFF if (*s->dptr == '=') { s->dptr++; - SKIPWS (s->dptr); + SKIP_ASCII_WS (s->dptr); } if (!MoreArgs (s)) @@ -2298,7 +2298,7 @@ static int parse_set (BUFFER *tmp, BUFFER *s, union pointer_long_t udata, BUFFER snprintf (err->data, err->dsize, _("%s: unknown variable"), tmp->data); return (-1); } - SKIPWS (s->dptr); + SKIP_ASCII_WS (s->dptr); if (reset) { @@ -3073,7 +3073,7 @@ int mutt_parse_rc_buffer (BUFFER *line, BUFFER *token, BUFFER *err) /* Read from the beginning of line->data */ mutt_buffer_rewind (line); - SKIPWS (line->dptr); + SKIP_ASCII_WS (line->dptr); while (*line->dptr) { if (*line->dptr == '#') @@ -3171,11 +3171,11 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs) int spaces; /* keep track of the number of leading spaces on the line */ myvar_t *myv; - SKIPWS (buffer); + SKIP_ASCII_WS (buffer); spaces = buffer - pt; pt = buffer + pos - spaces; - while ((pt > buffer) && !isspace ((unsigned char) *pt)) + while ((pt > buffer) && !IS_ASCII_WS ((unsigned char) *pt)) pt--; if (pt == buffer) /* complete cmd */ @@ -3318,7 +3318,7 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs) else if (!mutt_strncmp (buffer, "cd", 2)) { pt = buffer + 2; - SKIPWS (pt); + SKIP_ASCII_WS (pt); if (numtabs == 1) { if (mutt_complete (pt, buffer + len - pt - spaces)) @@ -3370,11 +3370,11 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos) if (buffer[0] == 0) return 0; - SKIPWS (buffer); + SKIP_ASCII_WS (buffer); spaces = buffer - pt; pt = buffer + pos - spaces; - while ((pt > buffer) && !isspace ((unsigned char) *pt)) + while ((pt > buffer) && !IS_ASCII_WS ((unsigned char) *pt)) pt--; pt++; /* move past the space */ if (*pt == '=') /* abort if no var before the '=' */ @@ -4143,7 +4143,7 @@ int mutt_label_complete (char *buffer, size_t len, int numtabs) if (!Context || !Context->label_hash) return 0; - SKIPWS (buffer); + SKIP_ASCII_WS (buffer); spaces = buffer - pt; /* first TAB. Collect all the matches */ diff --git a/keymap.c b/keymap.c index a4a89088..e5a8ec33 100644 --- a/keymap.c +++ b/keymap.c @@ -177,7 +177,7 @@ static int parse_keycode (const char *s) char *endChar; long int result = strtol(s+1, &endChar, 8); /* allow trailing whitespace, eg. < 1001 > */ - while (ISSPACE(*endChar)) + while (IS_ASCII_WS(*endChar)) ++endChar; /* negative keycodes don't make sense, also detect overflow */ if (*endChar != '>' || result < 0 || result == LONG_MAX) diff --git a/lib.c b/lib.c index 9a66c697..d4f13e9a 100644 --- a/lib.c +++ b/lib.c @@ -741,17 +741,17 @@ const char *mutt_stristr (const char *haystack, const char *needle) return NULL; } -char *mutt_skip_whitespace (char *p) +char *mutt_skip_ascii_ws (char *p) { - SKIPWS (p); + SKIP_ASCII_WS (p); return p; } -void mutt_remove_trailing_ws (char *s) +void mutt_remove_trailing_ascii_ws (char *s) { char *p; - for (p = s + mutt_strlen (s) - 1 ; p >= s && ISSPACE (*p) ; p--) + for (p = s + mutt_strlen (s) - 1 ; p >= s && IS_ASCII_WS (*p) ; p--) *p = 0; } diff --git a/lib.h b/lib.h index 47f0d833..61aa51a2 100644 --- a/lib.h +++ b/lib.h @@ -74,7 +74,6 @@ # define FREE(x) safe_free(x) # define NONULL(x) x?x:"" -# define ISSPACE(c) isspace((unsigned char)c) #ifdef HAVE_MEMCCPY # define strfcpy(A,B,C) memccpy(A,B,0,(C)-1), *((A)+(C)-1)=0 @@ -106,27 +105,43 @@ #define FOREVER while (1) -/* this macro must check for *c == 0 since isspace(0) has unreliable behavior - on some systems */ -# define SKIPWS(c) while (*(c) && isspace ((unsigned char) *(c))) c++; +/* + * ASCII Whitespace + * 0x09-0x0d (\t \n \v \f \r) + * 0x20 (space) + */ +#define IS_ASCII_WS(c) ((9 <= (c) && (c) <= 13) || (c) == 32) + +#define SKIP_ASCII_WS(c) while (IS_ASCII_WS (*(c))) c++; +/* + * WSP as defined by RFC5322. + * This is used primarily for parsing header fields. + */ #define EMAIL_WSP " \t\r\n" -/* skip over WSP as defined by RFC5322. This is used primarily for parsing - * header fields. */ +static inline int is_email_wsp (char c) +{ + return c && (strchr(EMAIL_WSP, c) != NULL); +} -static inline char *skip_email_wsp(const char *s) +static inline char *skip_email_wsp (const char *s) { if (s) return (char *)(s + strspn(s, EMAIL_WSP)); return (char *)s; } -static inline int is_email_wsp(char c) -{ - return c && (strchr(EMAIL_WSP, c) != NULL); -} +/* + * Locale-defined whitespace. + * This should only be used when dealing with user input, because + * some platforms return unexpected results with 8-bit values. + */ +#define IS_LOCALE_WS(c) isspace((unsigned char)c) +/* this macro must check for *c == 0 since isspace(0) has unreliable behavior + on some systems */ +#define SKIP_LOCALE_WS(c) while (*(c) && IS_LOCALE_WS (*(c))) c++; /* * These functions aren't defined in lib.c, but @@ -188,7 +203,7 @@ void mutt_debug_f (const char *, const int, const char *, const char *, ...); char *mutt_concat_path (char *, const char *, const char *, size_t); char *mutt_read_line (char *, size_t *, FILE *, int *, int); -char *mutt_skip_whitespace (char *); +char *mutt_skip_ascii_ws (char *); char *mutt_strlower (char *); char *mutt_substrcpy (char *, const char *, const char *, size_t); char *mutt_substrdup (const char *, const char *); @@ -238,7 +253,7 @@ size_t mutt_strlen (const char *); void *safe_calloc (size_t, size_t); void *safe_malloc (size_t); void mutt_nocurses_error (const char *, ...); -void mutt_remove_trailing_ws (char *); +void mutt_remove_trailing_ascii_ws (char *); void mutt_sanitize_filename (char *, int flags); void mutt_str_replace (char **p, const char *s); int mutt_mkdir (char *path, mode_t mode); diff --git a/mbyte.c b/mbyte.c index 16645feb..2397f6b2 100644 --- a/mbyte.c +++ b/mbyte.c @@ -265,9 +265,9 @@ int iswprint (wint_t wc) int iswspace (wint_t wc) { if (Charset_is_utf8 || charset_is_ja) - return (9 <= wc && wc <= 13) || wc == 32; + return IS_ASCII_WS (wc); else - return (0 <= wc && wc < 256) ? isspace (wc) : 0; + return (0 <= wc && wc < 256) ? isspace (wc) : 0; /* __SAFE_ISSPACE_CHECKED__ */ } static wint_t towupper_ucs (wint_t x) diff --git a/mutt_lisp.c b/mutt_lisp.c index 6707f772..152a0662 100644 --- a/mutt_lisp.c +++ b/mutt_lisp.c @@ -74,7 +74,7 @@ static int read_list (BUFFER *list, BUFFER *line) if (!line->dptr || !*line->dptr) return 0; - SKIPWS (line->dptr); + SKIP_ASCII_WS (line->dptr); if (*line->dptr != '(') return -1; @@ -135,7 +135,7 @@ static int read_atom (BUFFER *atom, BUFFER *line) if (!line->dptr || !*line->dptr) return 0; - SKIPWS (line->dptr); + SKIP_ASCII_WS (line->dptr); while (*line->dptr) { @@ -156,7 +156,7 @@ static int read_atom (BUFFER *atom, BUFFER *line) } else if (!quotechar) { - if (ISSPACE (ch) || ch == '(' || ch == ')') + if (IS_ASCII_WS (ch) || ch == '(' || ch == ')') break; if (ch == '"' || ch == '\'') quotechar = ch; @@ -180,7 +180,7 @@ static int read_sexp (BUFFER *sexp, BUFFER *line) if (!line->dptr || !*line->dptr) return 0; - SKIPWS (line->dptr); + SKIP_ASCII_WS (line->dptr); if (*line->dptr == '(') rc = read_list (sexp, line); @@ -472,7 +472,7 @@ int mutt_lisp_eval_list (BUFFER *result, BUFFER *line) function = mutt_buffer_new (); if (read_sexp (function, list) <= 0) goto cleanup; - SKIPWS (list->dptr); + SKIP_ASCII_WS (list->dptr); if (eval_function (result, mutt_b2s (function), list) < 0) goto cleanup; diff --git a/muttlib.c b/muttlib.c index 5e2080fe..c3c580ef 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1400,7 +1400,7 @@ void mutt_safe_path (BUFFER *dest, ADDRESS *a) mutt_buffer_save_path (dest, a); for (p = dest->data; *p; p++) - if (*p == '/' || ISSPACE (*p) || !IsPrint ((unsigned char) *p)) + if (*p == '/' || IS_ASCII_WS (*p) || !IsPrint ((unsigned char) *p)) *p = '_'; } diff --git a/pager.c b/pager.c index e9255cc7..f37bf48f 100644 --- a/pager.c +++ b/pager.c @@ -174,7 +174,7 @@ static int check_sig (const char *s, struct line_t *info, int n) /* check for a blank line */ while (*s) { - if (!ISSPACE (*s)) + if (!IS_ASCII_WS (*s)) return 0; s++; } diff --git a/parse.c b/parse.c index 897281a4..72d61f8a 100644 --- a/parse.c +++ b/parse.c @@ -335,7 +335,7 @@ void mutt_parse_content_type (char *s, BODY *ct) if ((pc = strchr(s, ';')) != NULL) { *pc++ = 0; - while (*pc && ISSPACE (*pc)) + while (*pc && IS_ASCII_WS (*pc)) pc++; ct->parameter = parse_parameters(pc, 0); @@ -357,7 +357,7 @@ void mutt_parse_content_type (char *s, BODY *ct) if ((subtype = strchr(s, '/'))) { *subtype++ = '\0'; - for (pc = subtype; *pc && !ISSPACE(*pc) && *pc != ';'; pc++) + for (pc = subtype; *pc && !IS_ASCII_WS(*pc) && *pc != ';'; pc++) ; *pc = '\0'; ct->subtype = safe_strdup (subtype); @@ -737,7 +737,7 @@ static BODY *_parse_multipart (FILE *fp, const char *boundary, LOFF_T end_off, } /* Remove any trailing whitespace, up to the length of the boundary */ - for (i = len - 1; ISSPACE (buffer[i]) && i >= blen + 2; i--) + for (i = len - 1; IS_ASCII_WS (buffer[i]) && i >= blen + 2; i--) buffer[i] = 0; /* Check for the end boundary */ diff --git a/pattern.c b/pattern.c index 28a33d81..b45a50a6 100644 --- a/pattern.c +++ b/pattern.c @@ -653,7 +653,7 @@ static int eat_range (pattern_t *pat, int flags, BUFFER *s, BUFFER *err) if (skip_quote && *tmp == '"') tmp++; - SKIPWS (tmp); + SKIP_ASCII_WS (tmp); s->dptr = tmp; return 0; } @@ -814,7 +814,7 @@ static const char * parse_date_range (const char* pc, struct tm *min, { const char *pt; char ch = *pc++; - SKIPWS (pc); + SKIP_ASCII_WS (pc); switch (ch) { case '-': @@ -878,7 +878,7 @@ static const char * parse_date_range (const char* pc, struct tm *min, default: flag |= MUTT_PDR_ERRORDONE; } - SKIPWS (pc); + SKIP_ASCII_WS (pc); } if ((flag & MUTT_PDR_ERROR) && !(flag & MUTT_PDR_ABSOLUTE)) { /* getDate has its own error message, don't overwrite it here */ @@ -968,11 +968,11 @@ static int eval_date_minmax (pattern_t *pat, const char *s, BUFFER *err) return (-1); } haveMin = TRUE; - SKIPWS (pc); + SKIP_ASCII_WS (pc); if (*pc == '-') { const char *pt = pc + 1; - SKIPWS (pt); + SKIP_ASCII_WS (pt); untilNow = (*pt == '\0'); } } @@ -1172,7 +1172,7 @@ pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err) ps.dptr = s; ps.dsize = mutt_strlen (s); - SKIPWS (ps.dptr); + SKIP_ASCII_WS (ps.dptr); while (*ps.dptr) { switch (*ps.dptr) @@ -1316,7 +1316,7 @@ pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err) tmp->op = entry->op; ps.dptr++; /* eat the operator and any optional whitespace */ - SKIPWS (ps.dptr); + SKIP_ASCII_WS (ps.dptr); if (entry->eat_arg) { @@ -1382,7 +1382,7 @@ pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err) mutt_pattern_free (&curlist); return NULL; } - SKIPWS (ps.dptr); + SKIP_ASCII_WS (ps.dptr); } if (!curlist) { diff --git a/pgp.c b/pgp.c index 86358775..ebad638e 100644 --- a/pgp.c +++ b/pgp.c @@ -376,7 +376,7 @@ static void pgp_copy_clearsigned (FILE *fpin, STATE *s, char *charset) if (armor_header) { - char *p = mutt_skip_whitespace (buf); + char *p = mutt_skip_ascii_ws (buf); if (*p == '\0') armor_header = 0; continue; diff --git a/pgpmicalg.c b/pgpmicalg.c index 07c9db5a..e3beb58f 100644 --- a/pgpmicalg.c +++ b/pgpmicalg.c @@ -95,7 +95,7 @@ static void pgp_dearmor (FILE *in, FILE *out) while ((r = fgets (line, sizeof (line), in)) != NULL) { - SKIPWS (r); + SKIP_ASCII_WS (r); if (!*r) break; } if (r == NULL) diff --git a/pop_lib.c b/pop_lib.c index 7fcca009..61cebba1 100644 --- a/pop_lib.c +++ b/pop_lib.c @@ -92,7 +92,7 @@ void pop_error (POP_DATA *pop_data, char *msg) } strfcpy (t, c, sizeof (pop_data->err_msg) - strlen (pop_data->err_msg)); - mutt_remove_trailing_ws (pop_data->err_msg); + mutt_remove_trailing_ascii_ws (pop_data->err_msg); } /* Parse CAPA output */ diff --git a/rfc1524.c b/rfc1524.c index f518b341..ba9ab934 100644 --- a/rfc1524.c +++ b/rfc1524.c @@ -173,20 +173,20 @@ static char *get_field (char *s) break; } } - mutt_remove_trailing_ws (s); + mutt_remove_trailing_ascii_ws (s); return ch; } static int get_field_text (char *field, char **entry, const char *type, const char *filename, int line) { - field = mutt_skip_whitespace (field); + field = mutt_skip_ascii_ws (field); if (*field == '=') { if (entry) { field++; - field = mutt_skip_whitespace (field); + field = mutt_skip_ascii_ws (field); mutt_str_replace (entry, field); } return 1; diff --git a/sendlib.c b/sendlib.c index d9429c2e..30b7f90a 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1018,13 +1018,13 @@ int mutt_lookup_mime_type (BODY *att, const char *path) /* remove any leading space. */ ct = buf; - SKIPWS (ct); + SKIP_ASCII_WS (ct); /* position on the next field in this line */ if ((p = strpbrk (ct, " \t")) == NULL) continue; *p++ = 0; - SKIPWS (p); + SKIP_ASCII_WS (p); /* cycle through the file extensions */ while ((p = strtok (p, " \t\n"))) @@ -1043,7 +1043,7 @@ int mutt_lookup_mime_type (BODY *att, const char *path) } *p++ = 0; - for (q = p; *q && !ISSPACE (*q); q++) + for (q = p; *q && !IS_ASCII_WS (*q); q++) ; mutt_substrcpy (subtype, p, q, sizeof (subtype)); -- cgit v1.2.3