mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
parent
19044a15f9
commit
171baaee93
@ -5087,14 +5087,13 @@ static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname,
|
||||
}
|
||||
p1 = vim_strchr(IObuff, '*'); /* find first '*' */
|
||||
while (p1 != NULL) {
|
||||
/* Use vim_strbyte() instead of vim_strchr() so that when
|
||||
* 'encoding' is dbcs it still works, don't find '*' in the
|
||||
* second byte. */
|
||||
p2 = vim_strbyte(p1 + 1, '*'); /* find second '*' */
|
||||
if (p2 != NULL && p2 > p1 + 1) { /* skip "*" and "**" */
|
||||
for (s = p1 + 1; s < p2; ++s)
|
||||
if (*s == ' ' || *s == '\t' || *s == '|')
|
||||
p2 = (char_u *)strchr((const char *)p1 + 1, '*'); // Find second '*'.
|
||||
if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**".
|
||||
for (s = p1 + 1; s < p2; s++) {
|
||||
if (*s == ' ' || *s == '\t' || *s == '|') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Only accept a *tag* when it consists of valid
|
||||
|
@ -3588,8 +3588,8 @@ int check_abbr(int c, char_u *ptr, int col, int mincol)
|
||||
char_u *q = mp->m_keys;
|
||||
int match;
|
||||
|
||||
if (vim_strbyte(mp->m_keys, K_SPECIAL) != NULL) {
|
||||
/* might have CSI escaped mp->m_keys */
|
||||
if (strchr((const char *)mp->m_keys, K_SPECIAL) != NULL) {
|
||||
// Might have CSI escaped mp->m_keys.
|
||||
q = vim_strsave(mp->m_keys);
|
||||
vim_unescape_csi(q);
|
||||
qlen = (int)STRLEN(q);
|
||||
|
@ -356,10 +356,10 @@ int bomb_size(void)
|
||||
*/
|
||||
void remove_bom(char_u *s)
|
||||
{
|
||||
char_u *p = s;
|
||||
char *p = (char *)s;
|
||||
|
||||
while ((p = vim_strbyte(p, 0xef)) != NULL) {
|
||||
if (p[1] == 0xbb && p[2] == 0xbf) {
|
||||
while ((p = strchr(p, 0xef)) != NULL) {
|
||||
if ((uint8_t)p[1] == 0xbb && (uint8_t)p[2] == 0xbf) {
|
||||
STRMOVE(p, p + 3);
|
||||
} else {
|
||||
p++;
|
||||
|
@ -3429,32 +3429,26 @@ static long bt_regexec_both(char_u *line,
|
||||
c = *prog->regmust;
|
||||
s = line + col;
|
||||
|
||||
/*
|
||||
* This is used very often, esp. for ":global". Use three versions of
|
||||
* the loop to avoid overhead of conditions.
|
||||
*/
|
||||
if (!ireg_ic
|
||||
&& !has_mbyte
|
||||
)
|
||||
while ((s = vim_strbyte(s, c)) != NULL) {
|
||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
|
||||
break; /* Found it. */
|
||||
++s;
|
||||
}
|
||||
else if (!ireg_ic || (!enc_utf8 && mb_char2len(c) > 1))
|
||||
// This is used very often, esp. for ":global". Use two versions of
|
||||
// the loop to avoid overhead of conditions.
|
||||
if (!ireg_ic) {
|
||||
while ((s = vim_strchr(s, c)) != NULL) {
|
||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
|
||||
break; /* Found it. */
|
||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) {
|
||||
break; // Found it.
|
||||
}
|
||||
mb_ptr_adv(s);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
while ((s = cstrchr(s, c)) != NULL) {
|
||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
|
||||
break; /* Found it. */
|
||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) {
|
||||
break; // Found it.
|
||||
}
|
||||
mb_ptr_adv(s);
|
||||
}
|
||||
if (s == NULL) /* Not present. */
|
||||
}
|
||||
if (s == NULL) { // Not present.
|
||||
goto theend;
|
||||
}
|
||||
}
|
||||
|
||||
regline = line;
|
||||
@ -3484,14 +3478,8 @@ static long bt_regexec_both(char_u *line,
|
||||
/* Messy cases: unanchored match. */
|
||||
while (!got_int) {
|
||||
if (prog->regstart != NUL) {
|
||||
/* Skip until the char we know it must start with.
|
||||
* Used often, do some work to avoid call overhead. */
|
||||
if (!ireg_ic
|
||||
&& !has_mbyte
|
||||
)
|
||||
s = vim_strbyte(regline + col, prog->regstart);
|
||||
else
|
||||
s = cstrchr(regline + col, prog->regstart);
|
||||
// Skip until the char we know it must start with.
|
||||
s = cstrchr(regline + col, prog->regstart);
|
||||
if (s == NULL) {
|
||||
retval = 0;
|
||||
break;
|
||||
|
@ -4855,17 +4855,10 @@ static int failure_chance(nfa_state_T *state, int depth)
|
||||
*/
|
||||
static int skip_to_start(int c, colnr_T *colp)
|
||||
{
|
||||
char_u *s;
|
||||
|
||||
/* Used often, do some work to avoid call overhead. */
|
||||
if (!ireg_ic
|
||||
&& !has_mbyte
|
||||
)
|
||||
s = vim_strbyte(regline + *colp, c);
|
||||
else
|
||||
s = cstrchr(regline + *colp, c);
|
||||
if (s == NULL)
|
||||
const char_u *const s = cstrchr(regline + *colp, c);
|
||||
if (s == NULL) {
|
||||
return FAIL;
|
||||
}
|
||||
*colp = (int)(s - regline);
|
||||
return OK;
|
||||
}
|
||||
|
@ -425,24 +425,6 @@ char_u *vim_strchr(const char_u *const string, const int c)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Version of strchr() that only works for bytes and handles unsigned char
|
||||
* strings with characters above 128 correctly. It also doesn't return a
|
||||
* pointer to the NUL at the end of the string.
|
||||
*/
|
||||
char_u *vim_strbyte(const char_u *string, int c)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE
|
||||
{
|
||||
const char_u *p = string;
|
||||
|
||||
while (*p != NUL) {
|
||||
if (*p == c)
|
||||
return (char_u *) p;
|
||||
++p;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for last occurrence of "c" in "string".
|
||||
* Return NULL if not found.
|
||||
|
Loading…
Reference in New Issue
Block a user