diff options
-rw-r--r-- | src/nvim/ascii.h | 14 | ||||
-rw-r--r-- | src/nvim/charset.c | 22 | ||||
-rw-r--r-- | src/nvim/edit.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 4 | ||||
-rw-r--r-- | src/nvim/ops.c | 4 | ||||
-rw-r--r-- | src/nvim/regexp.c | 4 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 2 |
7 files changed, 26 insertions, 26 deletions
diff --git a/src/nvim/ascii.h b/src/nvim/ascii.h index 8e51d50426..014cd00706 100644 --- a/src/nvim/ascii.h +++ b/src/nvim/ascii.h @@ -92,6 +92,7 @@ static inline bool ascii_iswhite(int c) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST; static inline bool ascii_isdigit(int c) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST; +static inline bool ascii_isxdigit(int c) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST; /// ascii_iswhite() is used for "^" and the like. It differs from isspace() /// because it doesn't include <CR> and <LF> and the like. @@ -108,5 +109,18 @@ static inline bool ascii_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 hexadecimal digit. +static inline bool ascii_isxdigit(int c) +{ + return (c >= '0' && c <= '9') + || (c >= 'a' && c <= 'f') + || (c >= 'A' && c <= 'F'); +} + #endif /* NVIM_ASCII_H */ diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 37e7e6516b..da65839353 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -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++; } @@ -1468,27 +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 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. @@ -1751,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 { @@ -1785,7 +1771,7 @@ 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++; } diff --git a/src/nvim/edit.c b/src/nvim/edit.c index b90ed61b45..89970f5965 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -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) { diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 29c412ed68..7d9dc9ab51 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -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); } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 17183bd350..bcdc79be72 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4241,14 +4241,14 @@ int do_addsub(int command, linenr_T Prenum1) */ col = curwin->w_cursor.col; if (dohex) - while (col > 0 && vim_isxdigit(ptr[col])) + while (col > 0 && ascii_isxdigit(ptr[col])) --col; if ( dohex && col > 0 && (ptr[col] == 'X' || ptr[col] == 'x') && ptr[col - 1] == '0' - && vim_isxdigit(ptr[col + 1])) { + && ascii_isxdigit(ptr[col + 1])) { /* * Found hexadecimal number, move to its start. */ diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index b07da08e23..d9031ab78a 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2359,7 +2359,7 @@ collection: break; case CLASS_XDIGIT: for (cu = 1; cu <= 255; cu++) - if (vim_isxdigit(cu)) + if (ascii_isxdigit(cu)) regc(cu); break; case CLASS_TAB: @@ -2978,7 +2978,7 @@ static int gethexchrs(int maxinputlen) for (i = 0; i < maxinputlen; ++i) { c = regparse[0]; - if (!vim_isxdigit(c)) + if (!ascii_isxdigit(c)) break; nr <<= 4; nr |= hex2nr(c); diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 05a3c51182..3daf6a8544 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -4263,7 +4263,7 @@ static int check_char_class(int class, int c) return OK; break; case NFA_CLASS_XDIGIT: - if (vim_isxdigit(c)) + if (ascii_isxdigit(c)) return OK; break; case NFA_CLASS_TAB: |