mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Replace vim_isxdigit() with to ascii_isxdigit() defined in ascii.h
This commit is contained in:
parent
caabcae0b7
commit
2ca8afc74e
@ -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 */
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user