diff options
| author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2015-04-25 13:34:30 -0300 |
|---|---|---|
| committer | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2015-04-25 13:37:44 -0300 |
| commit | 0bce4dc54427d05ab320a88f6269a9c1b05ea899 (patch) | |
| tree | 4a3aff2749eb0b70b7947ecfc7cd56d56ad4e29d | |
| parent | d350d12a00518aa0d9e3a1d49c6815c3398d882f (diff) | |
| parent | c96b933acc4d9ec7382d451055e44c85959772b9 (diff) | |
| download | rneovim-0bce4dc54427d05ab320a88f6269a9c1b05ea899.tar.gz rneovim-0bce4dc54427d05ab320a88f6269a9c1b05ea899.tar.bz2 rneovim-0bce4dc54427d05ab320a88f6269a9c1b05ea899.zip | |
Merge #2486: Replacements for vim_iswhite, VIM_ISDIGIT, vim_isdigit, vim_isxdigit, and vim_isspace
Reviewed-by: Michael Reed <m.reed@mykolab.com>
44 files changed, 426 insertions, 424 deletions
diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index 493517f908..2f96c4c6dc 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -185,8 +185,8 @@ malloc() lalloc() Like alloc(), but has long argument strcpy() STRCPY() Includes cast to (char *), for char_u * args strchr() vim_strchr() Accepts special characters strrchr() vim_strrchr() Accepts special characters -isspace() vim_isspace() Can handle characters > 128 -iswhite() vim_iswhite() Only TRUE for tab and space +isspace() ascii_isspace() Can handle characters > 128 +iswhite() ascii_iswhite() Only true for tab and space memcpy() mch_memmove() Handles overlapped copies bcopy() mch_memmove() Handles overlapped copies memset() vim_memset() Uniform for all systems diff --git a/src/nvim/ascii.h b/src/nvim/ascii.h index d9d9eac04d..cc9d1202c2 100644 --- a/src/nvim/ascii.h +++ b/src/nvim/ascii.h @@ -8,6 +8,10 @@ #ifndef NVIM_ASCII_H #define NVIM_ASCII_H +#include <stdbool.h> + +#include "nvim/func_attr.h" + // Definitions of various common control characters. #define CharOrd(x) ((x) < 'a' ? (x) - 'A' : (x) - 'a') @@ -87,4 +91,50 @@ # define PATHSEPSTR "/" #endif +static inline bool ascii_iswhite(int) REAL_FATTR_ALWAYS_INLINE REAL_FATTR_CONST; +static inline bool ascii_isdigit(int) REAL_FATTR_ALWAYS_INLINE REAL_FATTR_CONST; +static inline bool ascii_isxdigit(int) REAL_FATTR_ALWAYS_INLINE REAL_FATTR_CONST; +static inline bool ascii_isspace(int) REAL_FATTR_ALWAYS_INLINE REAL_FATTR_CONST; + +/// Checks if `c` is a space or tab character. +/// +/// @see {ascii_isdigit} +static inline bool ascii_iswhite(int c) +{ + return c == ' ' || c == '\t'; +} + +/// Check whether character is a decimal digit. +/// +/// Library isdigit() function is officially locale-dependent and, for +/// example, returns true for superscript 1 (ยน) in locales where encoding +/// contains it in lower 8 bits. Also avoids crashes in case c is below +/// 0 or above 255: library functions are officially defined as accepting +/// only EOF and unsigned char values (otherwise it is undefined behaviour) +/// what may be used for some optimizations (e.g. simple `return +/// isdigit_table[c];`). +static inline bool ascii_isdigit(int c) +{ + return c >= '0' && c <= '9'; +} + +/// Checks if `c` is a hexadecimal digit, that is, one of 0-9, a-f, A-F. +/// +/// @see {ascii_isdigit} +static inline bool ascii_isxdigit(int c) +{ + return (c >= '0' && c <= '9') + || (c >= 'a' && c <= 'f') + || (c >= 'A' && c <= 'F'); +} + +/// Checks if `c` is a white-space character, that is, +/// one of \f, \n, \r, \t, \v. +/// +/// @see {ascii_isdigit} +static inline bool ascii_isspace(int c) +{ + return (c >= 9 && c <= 13) || c == ' '; +} + #endif /* NVIM_ASCII_H */ diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 4585278714..1465b13c00 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -752,7 +752,7 @@ do_bufdel ( arg = skipwhite(arg); if (*arg == NUL) break; - if (!VIM_ISDIGIT(*arg)) { + if (!ascii_isdigit(*arg)) { p = skiptowhite_esc(arg); bnr = buflist_findpat(arg, p, command == DOBUF_WIPE, FALSE, FALSE); @@ -3012,7 +3012,7 @@ build_stl_str_hl ( s++; l = -1; } - if (VIM_ISDIGIT(*s)) { + if (ascii_isdigit(*s)) { minwid = getdigits_int(&s); if (minwid < 0) /* overflow */ minwid = 0; @@ -3048,7 +3048,7 @@ build_stl_str_hl ( } if (*s == '.') { s++; - if (VIM_ISDIGIT(*s)) { + if (ascii_isdigit(*s)) { maxwid = getdigits_int(&s); if (maxwid <= 0) /* overflow */ maxwid = 50; @@ -3321,7 +3321,7 @@ build_stl_str_hl ( if (minwid > 0) { for (; l < minwid && p + 1 < out + outlen; l++) { /* Don't put a "-" in front of a digit. */ - if (l + 1 == minwid && fillchar == '-' && VIM_ISDIGIT(*t)) + if (l + 1 == minwid && fillchar == '-' && ascii_isdigit(*t)) *p++ = ' '; else *p++ = fillchar; @@ -3334,7 +3334,7 @@ build_stl_str_hl ( /* Change a space by fillchar, unless fillchar is '-' and a * digit follows. */ if (fillable && p[-1] == ' ' - && (!VIM_ISDIGIT(*t) || fillchar != '-')) + && (!ascii_isdigit(*t) || fillchar != '-')) p[-1] = fillchar; } for (; l < minwid && p + 1 < out + outlen; l++) @@ -4075,7 +4075,7 @@ chk_modeline ( prev = -1; for (s = ml_get(lnum); *s != NUL; ++s) { - if (prev == -1 || vim_isspace(prev)) { + if (prev == -1 || ascii_isspace(prev)) { if ((prev != -1 && STRNCMP(s, "ex:", (size_t)3) == 0) || STRNCMP(s, "vi:", (size_t)3) == 0) break; diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 4633bacb78..da65839353 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -177,7 +177,7 @@ int buf_init_chartab(buf_T *buf, int global) ++p; } - if (VIM_ISDIGIT(*p)) { + if (ascii_isdigit(*p)) { c = getdigits_int(&p); } else if (has_mbyte) { c = mb_ptr2char_adv(&p); @@ -189,7 +189,7 @@ int buf_init_chartab(buf_T *buf, int global) if ((*p == '-') && (p[1] != NUL)) { ++p; - if (VIM_ISDIGIT(*p)) { + if (ascii_isdigit(*p)) { c2 = getdigits_int(&p); } else if (has_mbyte) { c2 = mb_ptr2char_adv(&p); @@ -1407,7 +1407,7 @@ void getvcols(win_T *wp, pos_T *pos1, pos_T *pos2, colnr_T *left, char_u* skipwhite(char_u *q) { char_u *p = q; - while (vim_iswhite(*p)) { + while (ascii_iswhite(*p)) { // skip to next non-white p++; } @@ -1422,7 +1422,7 @@ char_u* skipwhite(char_u *q) char_u* skipdigits(char_u *q) { char_u *p = q; - while (VIM_ISDIGIT(*p)) { + while (ascii_isdigit(*p)) { // skip to next non-digit p++; } @@ -1438,7 +1438,7 @@ char_u* skipdigits(char_u *q) char_u* skiphex(char_u *q) { char_u *p = q; - while (vim_isxdigit(*p)) { + while (ascii_isxdigit(*p)) { // skip to next non-digit p++; } @@ -1453,7 +1453,7 @@ char_u* skiphex(char_u *q) char_u* skiptodigit(char_u *q) { char_u *p = q; - while (*p != NUL && !VIM_ISDIGIT(*p)) { + while (*p != NUL && !ascii_isdigit(*p)) { // skip to next digit p++; } @@ -1468,40 +1468,13 @@ char_u* skiptodigit(char_u *q) char_u* skiptohex(char_u *q) { char_u *p = q; - while (*p != NUL && !vim_isxdigit(*p)) { + while (*p != NUL && !ascii_isxdigit(*p)) { // skip to next digit p++; } return p; } -/// Variant of isdigit() that can handle characters > 0x100. -/// We don't use isdigit() here, because on some systems it also considers -/// superscript 1 to be a digit. -/// Use the VIM_ISDIGIT() macro for simple arguments. -/// -/// @param c -/// -/// @return TRUE if the character is a digit. -int vim_isdigit(int c) -{ - return c >= '0' && c <= '9'; -} - -/// Variant of isxdigit() that can handle characters > 0x100. -/// We don't use isxdigit() here, because on some systems it also considers -/// superscript 1 to be a digit. -/// -/// @param c -/// -/// @return TRUE if the character is a digit. -int vim_isxdigit(int c) -{ - return (c >= '0' && c <= '9') - || (c >= 'a' && c <= 'f') - || (c >= 'A' && c <= 'F'); -} - // Vim's own character class functions. These exist because many library // islower()/toupper() etc. do not work properly: they crash when used with // invalid values or can't handle latin1 when the locale is C. @@ -1764,7 +1737,7 @@ void vim_str2nr(char_u *start, int *hexp, int *len, int dooct, int dohex, if (dohex && ((hex == 'X') || (hex == 'x')) - && vim_isxdigit(ptr[2])) { + && ascii_isxdigit(ptr[2])) { // hexadecimal ptr += 2; } else { @@ -1773,7 +1746,7 @@ void vim_str2nr(char_u *start, int *hexp, int *len, int dooct, int dohex, if (dooct) { // Don't interpret "0", "08" or "0129" as octal. - for (n = 1; VIM_ISDIGIT(ptr[n]); ++n) { + for (n = 1; ascii_isdigit(ptr[n]); ++n) { if (ptr[n] > '7') { // can't be octal hex = 0; @@ -1798,13 +1771,13 @@ void vim_str2nr(char_u *start, int *hexp, int *len, int dooct, int dohex, } } else if ((hex != 0) || (dohex > 1)) { // hex - while (vim_isxdigit(*ptr)) { + while (ascii_isxdigit(*ptr)) { un = 16 * un + (unsigned long)hex2nr(*ptr); ptr++; } } else { // decimal - while (VIM_ISDIGIT(*ptr)) { + while (ascii_isdigit(*ptr)) { un = 10 * un + (unsigned long)(*ptr - '0'); ptr++; } diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 2e98b8f512..2fbab13e56 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -133,7 +133,7 @@ char_u *parse_shape_opt(int what) len = 8; if (len != 0) { p += len; - if (!VIM_ISDIGIT(*p)) + if (!ascii_isdigit(*p)) return (char_u *)N_("E548: digit expected"); int n = getdigits_int(&p); if (len == 3) { /* "ver" or "hor" */ diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 88d63b3383..d4fbb290c1 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1590,7 +1590,7 @@ static int diff_cmp(char_u *s1, char_u *s2) char_u *p2 = s2; while (*p1 != NUL && *p2 != NUL) { - if (vim_iswhite(*p1) && vim_iswhite(*p2)) { + if (ascii_iswhite(*p1) && ascii_iswhite(*p2)) { p1 = skipwhite(p1); p2 = skipwhite(p2); } else { @@ -1781,7 +1781,7 @@ int diffopt_changed(void) if (STRNCMP(p, "filler", 6) == 0) { p += 6; diff_flags_new |= DIFF_FILLER; - } else if ((STRNCMP(p, "context:", 8) == 0) && VIM_ISDIGIT(p[8])) { + } else if ((STRNCMP(p, "context:", 8) == 0) && ascii_isdigit(p[8])) { p += 8; diff_context_new = getdigits_int(&p); } else if (STRNCMP(p, "icase", 5) == 0) { @@ -1796,7 +1796,7 @@ int diffopt_changed(void) } else if (STRNCMP(p, "vertical", 8) == 0) { p += 8; diff_flags_new |= DIFF_VERTICAL; - } else if ((STRNCMP(p, "foldcolumn:", 11) == 0) && VIM_ISDIGIT(p[11])) { + } else if ((STRNCMP(p, "foldcolumn:", 11) == 0) && ascii_isdigit(p[11])) { p += 11; diff_foldcolumn_new = getdigits_int(&p); } @@ -1897,8 +1897,8 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp) while (line_org[si_org] != NUL) { if ((diff_flags & DIFF_IWHITE) - && vim_iswhite(line_org[si_org]) - && vim_iswhite(line_new[si_new])) { + && ascii_iswhite(line_org[si_org]) + && ascii_iswhite(line_new[si_new])) { si_org = (int)(skipwhite(line_org + si_org) - line_org); si_new = (int)(skipwhite(line_new + si_new) - line_new); } else { @@ -1931,13 +1931,13 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp) && ei_org >= 0 && ei_new >= 0) { if ((diff_flags & DIFF_IWHITE) - && vim_iswhite(line_org[ei_org]) - && vim_iswhite(line_new[ei_new])) { - while (ei_org >= *startp && vim_iswhite(line_org[ei_org])) { + && ascii_iswhite(line_org[ei_org]) + && ascii_iswhite(line_new[ei_new])) { + while (ei_org >= *startp && ascii_iswhite(line_org[ei_org])) { ei_org--; } - while (ei_new >= si_new && vim_iswhite(line_new[ei_new])) { + while (ei_new >= si_new && ascii_iswhite(line_new[ei_new])) { ei_new--; } } else { @@ -2108,11 +2108,11 @@ void ex_diffgetput(exarg_T *eap) } else { // Buffer number or pattern given. Ignore trailing white space. p = eap->arg + STRLEN(eap->arg); - while (p > eap->arg && vim_iswhite(p[-1])) { + while (p > eap->arg && ascii_iswhite(p[-1])) { p--; } - for (i = 0; vim_isdigit(eap->arg[i]) && eap->arg + i < p; ++i) { + for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; ++i) { } if (eap->arg + i == p) { diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index cf998c041d..63329c878c 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1609,7 +1609,7 @@ void putdigraph(char_u *str) } str = skipwhite(str); - if (!VIM_ISDIGIT(*str)) { + if (!ascii_isdigit(*str)) { EMSG(_(e_number_exp)); return; } diff --git a/src/nvim/edit.c b/src/nvim/edit.c index a04f393825..d19f10f47f 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1662,7 +1662,7 @@ void truncate_spaces(char_u *line) int i; /* find start of trailing white space */ - for (i = (int)STRLEN(line) - 1; i >= 0 && vim_iswhite(line[i]); i--) { + for (i = (int)STRLEN(line) - 1; i >= 0 && ascii_iswhite(line[i]); i--) { if (State & REPLACE_FLAG) replace_join(0); /* remove a NUL from the replace stack */ } @@ -1838,7 +1838,7 @@ static int ins_compl_accept_char(int c) case CTRL_X_OMNI: /* Command line and Omni completion can work with just about any * printable character, but do stop at white space. */ - return vim_isprintc(c) && !vim_iswhite(c); + return vim_isprintc(c) && !ascii_iswhite(c); case CTRL_X_WHOLE_LINE: /* For while line completion a space can be part of the line. */ @@ -4722,7 +4722,7 @@ int get_literal(void) if (hex || unicode != 0 ) { - if (!vim_isxdigit(nc)) + if (!ascii_isxdigit(nc)) break; cc = cc * 16 + hex2nr(nc); } else if (octal) { @@ -4730,7 +4730,7 @@ int get_literal(void) break; cc = cc * 8 + nc - '0'; } else { - if (!VIM_ISDIGIT(nc)) + if (!ascii_isdigit(nc)) break; cc = cc * 10 + nc - '0'; } @@ -4824,7 +4824,7 @@ insert_special ( */ # define ISSPECIAL(c) ((c) < ' ' || (c) >= DEL || (c) == '0' || (c) == '^') -# define WHITECHAR(cc) (vim_iswhite(cc) && \ +# define WHITECHAR(cc) (ascii_iswhite(cc) && \ (!enc_utf8 || \ !utf_iscomposing( \ utf_ptr2char(get_cursor_pos_ptr() + 1)))) @@ -4870,7 +4870,7 @@ insertchar ( */ if (textwidth > 0 && ((flags & INSCHAR_FORMAT) - || (!vim_iswhite(c) + || (!ascii_iswhite(c) && !((State & REPLACE_FLAG) && !(State & VREPLACE_FLAG) && *get_cursor_pos_ptr() != NUL) @@ -4915,7 +4915,7 @@ insertchar ( ++p; middle_len = copy_option_part(&p, lead_end, COM_MAX_LEN, ","); /* Don't count trailing white space for middle_len */ - while (middle_len > 0 && vim_iswhite(lead_end[middle_len - 1])) + while (middle_len > 0 && ascii_iswhite(lead_end[middle_len - 1])) --middle_len; /* Find the end-comment string */ @@ -4925,7 +4925,7 @@ insertchar ( /* Skip white space before the cursor */ i = curwin->w_cursor.col; - while (--i >= 0 && vim_iswhite(line[i])) + while (--i >= 0 && ascii_iswhite(line[i])) ; i++; @@ -5071,7 +5071,7 @@ internal_format ( && !(State & VREPLACE_FLAG) ) { cc = gchar_cursor(); - if (vim_iswhite(cc)) { + if (ascii_iswhite(cc)) { save_char = cc; pchar_cursor('x'); } @@ -5545,7 +5545,7 @@ static void redo_literal(int c) /* Only digits need special treatment. Translate them into a string of * three digits. */ - if (VIM_ISDIGIT(c)) { + if (ascii_isdigit(c)) { vim_snprintf((char *)buf, sizeof(buf), "%03d", c); AppendToRedobuff(buf); } else @@ -5682,13 +5682,13 @@ stop_insert ( if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL) { dec_cursor(); cc = gchar_cursor(); - if (!vim_iswhite(cc)) + if (!ascii_iswhite(cc)) curwin->w_cursor = tpos; } auto_format(TRUE, FALSE); - if (vim_iswhite(cc)) { + if (ascii_iswhite(cc)) { if (gchar_cursor() != NUL) inc_cursor(); /* If the cursor is still at the same character, also keep @@ -5720,7 +5720,7 @@ stop_insert ( if (gchar_cursor() == NUL && curwin->w_cursor.col > 0) --curwin->w_cursor.col; cc = gchar_cursor(); - if (!vim_iswhite(cc)) + if (!ascii_iswhite(cc)) break; if (del_char(TRUE) == FAIL) break; /* should not happen */ @@ -5836,7 +5836,7 @@ void beginline(int flags) if (flags & (BL_WHITE | BL_SOL)) { char_u *ptr; - for (ptr = get_cursor_line_ptr(); vim_iswhite(*ptr) + for (ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr) && !((flags & BL_FIX) && ptr[1] == NUL); ++ptr) ++curwin->w_cursor.col; } @@ -7369,7 +7369,7 @@ static int ins_bs(int c, int mode, int *inserted_space_p) /* delete characters until we are at or before want_vcol */ while (vcol > want_vcol - && (cc = *(get_cursor_pos_ptr() - 1), vim_iswhite(cc))) + && (cc = *(get_cursor_pos_ptr() - 1), ascii_iswhite(cc))) ins_bs_one(&vcol); /* insert extra spaces until we are at want_vcol */ @@ -7403,13 +7403,13 @@ static int ins_bs(int c, int mode, int *inserted_space_p) dec_cursor(); /* start of word? */ - if (mode == BACKSPACE_WORD && !vim_isspace(gchar_cursor())) { + if (mode == BACKSPACE_WORD && !ascii_isspace(gchar_cursor())) { mode = BACKSPACE_WORD_NOT_SPACE; temp = vim_iswordc(gchar_cursor()); } /* end of word? */ else if (mode == BACKSPACE_WORD_NOT_SPACE - && (vim_isspace(cc = gchar_cursor()) + && (ascii_isspace(cc = gchar_cursor()) || vim_iswordc(cc) != temp)) { if (!revins_on) inc_cursor(); @@ -7882,7 +7882,7 @@ static int ins_tab(void) /* Find first white before the cursor */ fpos = curwin->w_cursor; - while (fpos.col > 0 && vim_iswhite(ptr[-1])) { + while (fpos.col > 0 && ascii_iswhite(ptr[-1])) { --fpos.col; --ptr; } @@ -7901,7 +7901,7 @@ static int ins_tab(void) /* Use as many TABs as possible. Beware of 'breakindent', 'showbreak' and 'linebreak' adding extra virtual columns. */ - while (vim_iswhite(*ptr)) { + while (ascii_iswhite(*ptr)) { i = lbr_chartabsize(NULL, (char_u *)"\t", vcol); if (vcol + i > want_vcol) break; @@ -8201,7 +8201,7 @@ static void ins_try_si(int c) ptr = ml_get(pos->lnum); i = pos->col; if (i > 0) /* skip blanks before '{' */ - while (--i > 0 && vim_iswhite(ptr[i])) + while (--i > 0 && ascii_iswhite(ptr[i])) ; curwin->w_cursor.lnum = pos->lnum; curwin->w_cursor.col = i; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 24502116f3..7d9dc9ab51 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1299,7 +1299,7 @@ int eval_foldexpr(char_u *arg, int *cp) /* If the result is a string, check if there is a non-digit before * the number. */ s = tv.vval.v_string; - if (!VIM_ISDIGIT(*s) && *s != '-') + if (!ascii_isdigit(*s) && *s != '-') *cp = *s++; retval = atol((char *)s); } @@ -1636,7 +1636,7 @@ static char_u *list_arg_vars(exarg_T *eap, char_u *arg, int *first) while (!ends_excmd(*arg) && !got_int) { if (error || eap->skip) { arg = find_name_end(arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START); - if (!vim_iswhite(*arg) && !ends_excmd(*arg)) { + if (!ascii_iswhite(*arg) && !ends_excmd(*arg)) { emsg_severe = TRUE; EMSG(_(e_trailing)); break; @@ -1943,7 +1943,7 @@ get_lval ( p = find_name_end(name, &expr_start, &expr_end, fne_flags); if (expr_start != NULL) { /* Don't expand the name when we already know there is an error. */ - if (unlet && !vim_iswhite(*p) && !ends_excmd(*p) + if (unlet && !ascii_iswhite(*p) && !ends_excmd(*p) && *p != '[' && *p != '.') { EMSG(_(e_trailing)); return NULL; @@ -2476,7 +2476,7 @@ void *eval_for_line(char_u *arg, int *errp, char_u **nextcmdp, int skip) return fi; expr = skipwhite(expr); - if (expr[0] != 'i' || expr[1] != 'n' || !vim_iswhite(expr[2])) { + if (expr[0] != 'i' || expr[1] != 'n' || !ascii_iswhite(expr[2])) { EMSG(_("E690: Missing \"in\" after :for")); return fi; } @@ -2556,7 +2556,7 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) for (p = arg + STRLEN(arg); p >= arg; ) { xp->xp_pattern = p; mb_ptr_back(arg, p); - if (vim_iswhite(*p)) + if (ascii_iswhite(*p)) break; } return; @@ -2754,7 +2754,7 @@ void ex_lockvar(exarg_T *eap) if (eap->forceit) deep = -1; - else if (vim_isdigit(*arg)) { + else if (ascii_isdigit(*arg)) { deep = getdigits_int(&arg); arg = skipwhite(arg); } @@ -2778,7 +2778,7 @@ static void ex_unletlock(exarg_T *eap, char_u *argstart, int deep) FNE_CHECK_START); if (lv.ll_name == NULL) error = TRUE; /* error but continue parsing */ - if (name_end == NULL || (!vim_iswhite(*name_end) + if (name_end == NULL || (!ascii_iswhite(*name_end) && !ends_excmd(*name_end))) { if (name_end != NULL) { emsg_severe = TRUE; @@ -4005,14 +4005,14 @@ eval7 ( * strict to avoid backwards compatibility problems. * Don't look for a float after the "." operator, so that * ":let vers = 1.2.3" doesn't fail. */ - if (!want_string && p[0] == '.' && vim_isdigit(p[1])) { + if (!want_string && p[0] == '.' && ascii_isdigit(p[1])) { get_float = TRUE; p = skipdigits(p + 2); if (*p == 'e' || *p == 'E') { ++p; if (*p == '-' || *p == '+') ++p; - if (!vim_isdigit(*p)) + if (!ascii_isdigit(*p)) get_float = FALSE; else p = skipdigits(p + 1); @@ -4551,7 +4551,7 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) case 'x': case 'u': /* Unicode: "\u0023" */ case 'U': - if (vim_isxdigit(p[1])) { + if (ascii_isxdigit(p[1])) { int n, nr; int c = toupper(*p); @@ -4560,7 +4560,7 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) else n = 4; nr = 0; - while (--n >= 0 && vim_isxdigit(p[1])) { + while (--n >= 0 && ascii_isxdigit(p[1])) { ++p; nr = (nr << 4) + hex2nr(*p); } @@ -8940,7 +8940,7 @@ static void f_function(typval_T *argvars, typval_T *rettv) char_u *s; s = get_tv_string(&argvars[0]); - if (s == NULL || *s == NUL || VIM_ISDIGIT(*s)) + if (s == NULL || *s == NUL || ascii_isdigit(*s)) EMSG2(_(e_invarg2), s); /* Don't check an autoload name for existence here. */ else if (vim_strchr(s, AUTOLOAD_CHAR) == NULL && !function_exists(s)) @@ -10020,9 +10020,9 @@ static void f_has(typval_T *argvars, typval_T *rettv) if (STRNICMP(name, "patch", 5) == 0) { if (name[5] == '-' && STRLEN(name) > 11 - && vim_isdigit(name[6]) - && vim_isdigit(name[8])< |