Replace vim_isspace() with ascii_isspace() defined in ascii.h

This commit is contained in:
Felipe Oliveira Carvalho
2015-04-22 19:50:52 -03:00
parent 2ca8afc74e
commit bcfc37ea98
12 changed files with 26 additions and 28 deletions

View File

@@ -185,7 +185,7 @@ malloc() lalloc() Like alloc(), but has long argument
strcpy() STRCPY() Includes cast to (char *), for char_u * args strcpy() STRCPY() Includes cast to (char *), for char_u * args
strchr() vim_strchr() Accepts special characters strchr() vim_strchr() Accepts special characters
strrchr() vim_strrchr() Accepts special characters strrchr() vim_strrchr() Accepts special characters
isspace() vim_isspace() Can handle characters > 128 isspace() ascii_isspace() Can handle characters > 128
iswhite() ascii_iswhite() Only TRUE for tab and space iswhite() ascii_iswhite() Only TRUE for tab and space
memcpy() mch_memmove() Handles overlapped copies memcpy() mch_memmove() Handles overlapped copies
bcopy() mch_memmove() Handles overlapped copies bcopy() mch_memmove() Handles overlapped copies

View File

@@ -93,6 +93,7 @@
static inline bool ascii_iswhite(int c) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST; 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_isdigit(int c) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST;
static inline bool ascii_isxdigit(int c) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST; static inline bool ascii_isxdigit(int c) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST;
static inline bool ascii_isspace(int x) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST;
/// ascii_iswhite() is used for "^" and the like. It differs from isspace() /// ascii_iswhite() is used for "^" and the like. It differs from isspace()
/// because it doesn't include <CR> and <LF> and the like. /// because it doesn't include <CR> and <LF> and the like.
@@ -122,5 +123,12 @@ static inline bool ascii_isxdigit(int c)
|| (c >= 'A' && c <= 'F'); || (c >= 'A' && c <= 'F');
} }
/// Vim has its own isspace() function, because on some machines isspace()
/// can't handle characters above 128.
static inline bool ascii_isspace(int x)
{
return (x >= 9 && x <= 13) || x == ' ';
}
#endif /* NVIM_ASCII_H */ #endif /* NVIM_ASCII_H */

View File

@@ -4075,7 +4075,7 @@ chk_modeline (
prev = -1; prev = -1;
for (s = ml_get(lnum); *s != NUL; ++s) { 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) if ((prev != -1 && STRNCMP(s, "ex:", (size_t)3) == 0)
|| STRNCMP(s, "vi:", (size_t)3) == 0) || STRNCMP(s, "vi:", (size_t)3) == 0)
break; break;

View File

@@ -7403,13 +7403,13 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
dec_cursor(); dec_cursor();
/* start of word? */ /* start of word? */
if (mode == BACKSPACE_WORD && !vim_isspace(gchar_cursor())) { if (mode == BACKSPACE_WORD && !ascii_isspace(gchar_cursor())) {
mode = BACKSPACE_WORD_NOT_SPACE; mode = BACKSPACE_WORD_NOT_SPACE;
temp = vim_iswordc(gchar_cursor()); temp = vim_iswordc(gchar_cursor());
} }
/* end of word? */ /* end of word? */
else if (mode == BACKSPACE_WORD_NOT_SPACE else if (mode == BACKSPACE_WORD_NOT_SPACE
&& (vim_isspace(cc = gchar_cursor()) && (ascii_isspace(cc = gchar_cursor())
|| vim_iswordc(cc) != temp)) { || vim_iswordc(cc) != temp)) {
if (!revins_on) if (!revins_on)
inc_cursor(); inc_cursor();

View File

@@ -1371,7 +1371,7 @@ static char_u *do_one_arg(char_u *str)
*p++ = *str; *p++ = *str;
} else { } else {
/* An item ends at a space not in backticks */ /* An item ends at a space not in backticks */
if (!inbacktick && vim_isspace(*str)) if (!inbacktick && ascii_isspace(*str))
break; break;
if (*str == '`') if (*str == '`')
inbacktick ^= TRUE; inbacktick ^= TRUE;

View File

@@ -3718,7 +3718,7 @@ static char_u *getargcmd(char_u **argp)
if (*arg == '+') { /* +[command] */ if (*arg == '+') { /* +[command] */
++arg; ++arg;
if (vim_isspace(*arg) || *arg == '\0') if (ascii_isspace(*arg) || *arg == '\0')
command = dollar_command; command = dollar_command;
else { else {
command = arg; command = arg;
@@ -3742,7 +3742,7 @@ skip_cmd_arg (
int rembs /* TRUE to halve the number of backslashes */ int rembs /* TRUE to halve the number of backslashes */
) )
{ {
while (*p && !vim_isspace(*p)) { while (*p && !ascii_isspace(*p)) {
if (*p == '\\' && p[1] != NUL) { if (*p == '\\' && p[1] != NUL) {
if (rembs) if (rembs)
STRMOVE(p, p + 1); STRMOVE(p, p + 1);

View File

@@ -792,7 +792,7 @@ getcmdline (
if (has_mbyte) { if (has_mbyte) {
p = mb_prevptr(ccline.cmdbuff, p); p = mb_prevptr(ccline.cmdbuff, p);
if (c == Ctrl_W) { if (c == Ctrl_W) {
while (p > ccline.cmdbuff && vim_isspace(*p)) while (p > ccline.cmdbuff && ascii_isspace(*p))
p = mb_prevptr(ccline.cmdbuff, p); p = mb_prevptr(ccline.cmdbuff, p);
i = mb_get_class(p); i = mb_get_class(p);
while (p > ccline.cmdbuff && mb_get_class(p) == i) while (p > ccline.cmdbuff && mb_get_class(p) == i)
@@ -801,10 +801,10 @@ getcmdline (
p += (*mb_ptr2len)(p); p += (*mb_ptr2len)(p);
} }
} else if (c == Ctrl_W) { } else if (c == Ctrl_W) {
while (p > ccline.cmdbuff && vim_isspace(p[-1])) while (p > ccline.cmdbuff && ascii_isspace(p[-1]))
--p; --p;
i = vim_iswordc(p[-1]); i = vim_iswordc(p[-1]);
while (p > ccline.cmdbuff && !vim_isspace(p[-1]) while (p > ccline.cmdbuff && !ascii_isspace(p[-1])
&& vim_iswordc(p[-1]) == i) && vim_iswordc(p[-1]) == i)
--p; --p;
} else } else

View File

@@ -3568,7 +3568,7 @@ int check_abbr(int c, char_u *ptr, int col, int mincol)
clen = 1; clen = 1;
while (p > ptr + mincol) { while (p > ptr + mincol) {
p = mb_prevptr(ptr, p); p = mb_prevptr(ptr, p);
if (vim_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p))) { if (ascii_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p))) {
p += (*mb_ptr2len)(p); p += (*mb_ptr2len)(p);
break; break;
} }
@@ -3583,7 +3583,7 @@ int check_abbr(int c, char_u *ptr, int col, int mincol)
if (col > 1) if (col > 1)
is_id = vim_iswordc(ptr[col - 2]); is_id = vim_iswordc(ptr[col - 2]);
} }
for (scol = col - 1; scol > 0 && !vim_isspace(ptr[scol - 1]) for (scol = col - 1; scol > 0 && !ascii_isspace(ptr[scol - 1])
&& (vim_abbr || is_id == vim_iswordc(ptr[scol - 1])); --scol) && (vim_abbr || is_id == vim_iswordc(ptr[scol - 1])); --scol)
; ;
} }

View File

@@ -1430,7 +1430,7 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags
str = skipwhite(line + 1); str = skipwhite(line + 1);
str = viminfo_readstring(virp, (int)(str - virp->vir_line), FALSE); str = viminfo_readstring(virp, (int)(str - virp->vir_line), FALSE);
p = str + STRLEN(str); p = str + STRLEN(str);
while (p != str && (*p == NUL || vim_isspace(*p))) while (p != str && (*p == NUL || ascii_isspace(*p)))
p--; p--;
if (*p) if (*p)
p++; p++;

View File

@@ -3901,7 +3901,7 @@ format_lines (
/* put cursor on last non-space */ /* put cursor on last non-space */
State = NORMAL; /* don't go past end-of-line */ State = NORMAL; /* don't go past end-of-line */
coladvance((colnr_T)MAXCOL); coladvance((colnr_T)MAXCOL);
while (curwin->w_cursor.col && vim_isspace(gchar_cursor())) while (curwin->w_cursor.col && ascii_isspace(gchar_cursor()))
dec_cursor(); dec_cursor();
/* do the formatting, without 'showmode' */ /* do the formatting, without 'showmode' */
@@ -5007,11 +5007,11 @@ static long line_count_info(char_u *line, long *wc, long *cc, long limit, int eo
for (i = 0; i < limit && line[i] != NUL; ) { for (i = 0; i < limit && line[i] != NUL; ) {
if (is_word) { if (is_word) {
if (vim_isspace(line[i])) { if (ascii_isspace(line[i])) {
words++; words++;
is_word = 0; is_word = 0;
} }
} else if (!vim_isspace(line[i])) } else if (!ascii_isspace(line[i]))
is_word = 1; is_word = 1;
++chars; ++chars;
i += (*mb_ptr2len)(line + i); i += (*mb_ptr2len)(line + i);

View File

@@ -449,16 +449,6 @@ char_u *vim_strrchr(const char_u *string, int c)
return (char_u *) retval; return (char_u *) retval;
} }
/*
* Vim has its own isspace() function, because on some machines isspace()
* can't handle characters above 128.
*/
bool vim_isspace(int x)
FUNC_ATTR_CONST
{
return (x >= 9 && x <= 13) || x == ' ';
}
/* /*
* Sort an array of strings. * Sort an array of strings.
*/ */

View File

@@ -587,7 +587,7 @@ do_tag (
/* skip "file:" without a value (static tag) */ /* skip "file:" without a value (static tag) */
if (STRNCMP(p, "file:", 5) == 0 if (STRNCMP(p, "file:", 5) == 0
&& vim_isspace(p[5])) { && ascii_isspace(p[5])) {
p += 5; p += 5;
continue; continue;
} }
@@ -640,7 +640,7 @@ do_tag (
++p; ++p;
} }
/* Remove leading whitespace from pattern */ /* Remove leading whitespace from pattern */
while (p != command_end && vim_isspace(*p)) while (p != command_end && ascii_isspace(*p))
++p; ++p;
while (p != command_end) { while (p != command_end) {