mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 09:48:19 +00:00
vim-patch:8.2.0502: Vim9: some code is not tested
Problem: Vim9: some code is not tested.
Solution: Add more tests. Fix uncovered problems.
e8c4abbbd7
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -1246,7 +1246,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, cons
|
|||||||
arg = (const char *)skipwhite(skiptowhite(arg));
|
arg = (const char *)skipwhite(skiptowhite(arg));
|
||||||
if (*arg != NUL) {
|
if (*arg != NUL) {
|
||||||
xp->xp_context = EXPAND_NOTHING;
|
xp->xp_context = EXPAND_NOTHING;
|
||||||
arg = (const char *)skip_regexp((char *)arg + 1, (uint8_t)(*arg), p_magic, NULL);
|
arg = (const char *)skip_regexp((char *)arg + 1, (uint8_t)(*arg), p_magic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (const char *)find_nextcmd(arg);
|
return (const char *)find_nextcmd(arg);
|
||||||
@@ -1285,7 +1285,7 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, cons
|
|||||||
if (delim) {
|
if (delim) {
|
||||||
// Skip "from" part.
|
// Skip "from" part.
|
||||||
arg++;
|
arg++;
|
||||||
arg = (const char *)skip_regexp((char *)arg, delim, p_magic, NULL);
|
arg = (const char *)skip_regexp((char *)arg, delim, p_magic);
|
||||||
}
|
}
|
||||||
// Skip "to" part.
|
// Skip "to" part.
|
||||||
while (arg[0] != NUL && (uint8_t)arg[0] != delim) {
|
while (arg[0] != NUL && (uint8_t)arg[0] != delim) {
|
||||||
|
@@ -1964,7 +1964,7 @@ void ex_function(exarg_T *eap)
|
|||||||
|
|
||||||
// ":function /pat": list functions matching pattern.
|
// ":function /pat": list functions matching pattern.
|
||||||
if (*eap->arg == '/') {
|
if (*eap->arg == '/') {
|
||||||
p = skip_regexp(eap->arg + 1, '/', true, NULL);
|
p = skip_regexp(eap->arg + 1, '/', true);
|
||||||
if (!eap->skip) {
|
if (!eap->skip) {
|
||||||
regmatch_T regmatch;
|
regmatch_T regmatch;
|
||||||
|
|
||||||
|
@@ -504,7 +504,7 @@ void ex_sort(exarg_T *eap)
|
|||||||
eap->nextcmd = check_nextcmd(p);
|
eap->nextcmd = check_nextcmd(p);
|
||||||
break;
|
break;
|
||||||
} else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) {
|
} else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) {
|
||||||
s = skip_regexp(p + 1, *p, true, NULL);
|
s = skip_regexp(p + 1, *p, true);
|
||||||
if (*s != *p) {
|
if (*s != *p) {
|
||||||
emsg(_(e_invalpat));
|
emsg(_(e_invalpat));
|
||||||
goto sortend;
|
goto sortend;
|
||||||
@@ -3503,7 +3503,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
|
|||||||
which_pat = RE_LAST; // use last used regexp
|
which_pat = RE_LAST; // use last used regexp
|
||||||
delimiter = (char_u)(*cmd++); // remember delimiter character
|
delimiter = (char_u)(*cmd++); // remember delimiter character
|
||||||
pat = cmd; // remember start of search pat
|
pat = cmd; // remember start of search pat
|
||||||
cmd = skip_regexp(cmd, delimiter, p_magic, &eap->arg);
|
cmd = skip_regexp_ex(cmd, delimiter, p_magic, &eap->arg, NULL);
|
||||||
if (cmd[0] == delimiter) { // end delimiter found
|
if (cmd[0] == delimiter) { // end delimiter found
|
||||||
*cmd++ = NUL; // replace it with a NUL
|
*cmd++ = NUL; // replace it with a NUL
|
||||||
has_second_delim = true;
|
has_second_delim = true;
|
||||||
@@ -4536,7 +4536,7 @@ void ex_global(exarg_T *eap)
|
|||||||
delim = *cmd; // get the delimiter
|
delim = *cmd; // get the delimiter
|
||||||
cmd++; // skip delimiter if there is one
|
cmd++; // skip delimiter if there is one
|
||||||
pat = cmd; // remember start of pattern
|
pat = cmd; // remember start of pattern
|
||||||
cmd = skip_regexp(cmd, delim, p_magic, &eap->arg);
|
cmd = skip_regexp_ex(cmd, delim, p_magic, &eap->arg, NULL);
|
||||||
if (cmd[0] == delim) { // end delimiter found
|
if (cmd[0] == delim) { // end delimiter found
|
||||||
*cmd++ = NUL; // replace it with a NUL
|
*cmd++ = NUL; // replace it with a NUL
|
||||||
}
|
}
|
||||||
@@ -4849,7 +4849,7 @@ char *skip_vimgrep_pat(char *p, char **s, int *flags)
|
|||||||
*s = p + 1;
|
*s = p + 1;
|
||||||
}
|
}
|
||||||
c = (char_u)(*p);
|
c = (char_u)(*p);
|
||||||
p = skip_regexp(p + 1, c, true, NULL);
|
p = skip_regexp(p + 1, c, true);
|
||||||
if (*p != c) {
|
if (*p != c) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -3351,7 +3351,7 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (skip) { // skip "/pat/"
|
if (skip) { // skip "/pat/"
|
||||||
cmd = skip_regexp(cmd, c, p_magic, NULL);
|
cmd = skip_regexp(cmd, c, p_magic);
|
||||||
if (*cmd == c) {
|
if (*cmd == c) {
|
||||||
cmd++;
|
cmd++;
|
||||||
}
|
}
|
||||||
@@ -6494,7 +6494,7 @@ static void ex_findpat(exarg_T *eap)
|
|||||||
if (*eap->arg == '/') { // Match regexp, not just whole words
|
if (*eap->arg == '/') { // Match regexp, not just whole words
|
||||||
whole = false;
|
whole = false;
|
||||||
eap->arg++;
|
eap->arg++;
|
||||||
char *p = skip_regexp(eap->arg, '/', p_magic, NULL);
|
char *p = skip_regexp(eap->arg, '/', p_magic);
|
||||||
if (*p) {
|
if (*p) {
|
||||||
*p++ = NUL;
|
*p++ = NUL;
|
||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
|
@@ -1296,7 +1296,7 @@ void ex_catch(exarg_T *eap)
|
|||||||
eap->nextcmd = find_nextcmd(eap->arg);
|
eap->nextcmd = find_nextcmd(eap->arg);
|
||||||
} else {
|
} else {
|
||||||
pat = eap->arg + 1;
|
pat = eap->arg + 1;
|
||||||
end = skip_regexp(pat, *eap->arg, true, NULL);
|
end = skip_regexp(pat, *eap->arg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!give_up) {
|
if (!give_up) {
|
||||||
|
@@ -314,7 +314,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
|||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++;
|
delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++;
|
||||||
*search_delim = delim;
|
*search_delim = delim;
|
||||||
end = skip_regexp(p, delim, p_magic, NULL);
|
end = skip_regexp(p, delim, p_magic);
|
||||||
|
|
||||||
use_last_pat = end == p && *end == delim;
|
use_last_pat = end == p && *end == delim;
|
||||||
if (end == p && !use_last_pat) {
|
if (end == p && !use_last_pat) {
|
||||||
|
@@ -1206,7 +1206,7 @@ void ex_match(exarg_T *eap)
|
|||||||
semsg(_(e_invarg2), eap->arg);
|
semsg(_(e_invarg2), eap->arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
end = skip_regexp(p + 1, *p, true, NULL);
|
end = skip_regexp(p + 1, *p, true);
|
||||||
if (!eap->skip) {
|
if (!eap->skip) {
|
||||||
if (*end != NUL && !ends_excmd(*skipwhite(end + 1))) {
|
if (*end != NUL && !ends_excmd(*skipwhite(end + 1))) {
|
||||||
xfree(g);
|
xfree(g);
|
||||||
|
@@ -484,10 +484,17 @@ static char_u *skip_anyof(char *p)
|
|||||||
/// Stop at end of "startp" or where "dirc" is found ('/', '?', etc).
|
/// Stop at end of "startp" or where "dirc" is found ('/', '?', etc).
|
||||||
/// Take care of characters with a backslash in front of it.
|
/// Take care of characters with a backslash in front of it.
|
||||||
/// Skip strings inside [ and ].
|
/// Skip strings inside [ and ].
|
||||||
|
char *skip_regexp(char *startp, int dirc, int magic)
|
||||||
|
{
|
||||||
|
return skip_regexp_ex(startp, dirc, magic, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// skip_regexp() with extra arguments:
|
||||||
/// When "newp" is not NULL and "dirc" is '?', make an allocated copy of the
|
/// When "newp" is not NULL and "dirc" is '?', make an allocated copy of the
|
||||||
/// expression and change "\?" to "?". If "*newp" is not NULL the expression
|
/// expression and change "\?" to "?". If "*newp" is not NULL the expression
|
||||||
/// is changed in-place.
|
/// is changed in-place.
|
||||||
char *skip_regexp(char *startp, int dirc, int magic, char **newp)
|
/// If a "\?" is changed to "?" then "dropped" is incremented, unless NULL.
|
||||||
|
char *skip_regexp_ex(char *startp, int dirc, int magic, char **newp, int *dropped)
|
||||||
{
|
{
|
||||||
int mymagic;
|
int mymagic;
|
||||||
char *p = startp;
|
char *p = startp;
|
||||||
@@ -516,6 +523,9 @@ char *skip_regexp(char *startp, int dirc, int magic, char **newp)
|
|||||||
*newp = xstrdup(startp);
|
*newp = xstrdup(startp);
|
||||||
p = *newp + (p - startp);
|
p = *newp + (p - startp);
|
||||||
}
|
}
|
||||||
|
if (dropped != NULL) {
|
||||||
|
(*dropped)++;
|
||||||
|
}
|
||||||
STRMOVE(p, p + 1);
|
STRMOVE(p, p + 1);
|
||||||
} else {
|
} else {
|
||||||
p++; // skip next character
|
p++; // skip next character
|
||||||
|
@@ -1080,7 +1080,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,
|
|||||||
// Find end of regular expression.
|
// Find end of regular expression.
|
||||||
// If there is a matching '/' or '?', toss it.
|
// If there is a matching '/' or '?', toss it.
|
||||||
ps = (char_u *)strcopy;
|
ps = (char_u *)strcopy;
|
||||||
p = (char_u *)skip_regexp((char *)pat, search_delim, p_magic, &strcopy);
|
p = (char_u *)skip_regexp_ex((char *)pat, search_delim, p_magic, &strcopy, NULL);
|
||||||
if (strcopy != (char *)ps) {
|
if (strcopy != (char *)ps) {
|
||||||
// made a copy of "pat" to change "\?" to "?"
|
// made a copy of "pat" to change "\?" to "?"
|
||||||
searchcmdlen += (int)(STRLEN(pat) - strlen(strcopy));
|
searchcmdlen += (int)(STRLEN(pat) - strlen(strcopy));
|
||||||
|
@@ -4749,7 +4749,7 @@ static char *get_syn_pattern(char *arg, synpat_T *ci)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
end = skip_regexp(arg + 1, *arg, true, NULL);
|
end = skip_regexp(arg + 1, *arg, true);
|
||||||
if (*end != *arg) { // end delimiter not found
|
if (*end != *arg) { // end delimiter not found
|
||||||
semsg(_("E401: Pattern delimiter not found: %s"), arg);
|
semsg(_("E401: Pattern delimiter not found: %s"), arg);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -4902,7 +4902,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
|
|||||||
finished = true;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
arg_end = skip_regexp(next_arg + 1, *next_arg, true, NULL);
|
arg_end = skip_regexp(next_arg + 1, *next_arg, true);
|
||||||
if (*arg_end != *next_arg) { // end delimiter not found
|
if (*arg_end != *next_arg) { // end delimiter not found
|
||||||
illegal = true;
|
illegal = true;
|
||||||
break;
|
break;
|
||||||
|
@@ -2670,7 +2670,7 @@ static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
|
|||||||
// anything following.
|
// anything following.
|
||||||
str = pbuf;
|
str = pbuf;
|
||||||
if (pbuf[0] == '/' || pbuf[0] == '?') {
|
if (pbuf[0] == '/' || pbuf[0] == '?') {
|
||||||
str = (char_u *)skip_regexp((char *)pbuf + 1, pbuf[0], false, NULL) + 1;
|
str = (char_u *)skip_regexp((char *)pbuf + 1, pbuf[0], false) + 1;
|
||||||
}
|
}
|
||||||
if (str > pbuf_end - 1) { // search command with nothing following
|
if (str > pbuf_end - 1) { // search command with nothing following
|
||||||
save_p_ws = p_ws;
|
save_p_ws = p_ws;
|
||||||
@@ -2883,7 +2883,7 @@ static int find_extra(char_u **pp)
|
|||||||
if (ascii_isdigit(*str)) {
|
if (ascii_isdigit(*str)) {
|
||||||
str = (char_u *)skipdigits((char *)str + 1);
|
str = (char_u *)skipdigits((char *)str + 1);
|
||||||
} else if (*str == '/' || *str == '?') {
|
} else if (*str == '/' || *str == '?') {
|
||||||
str = (char_u *)skip_regexp((char *)str + 1, *str, false, NULL);
|
str = (char_u *)skip_regexp((char *)str + 1, *str, false);
|
||||||
if (*str != first_char) {
|
if (*str != first_char) {
|
||||||
str = NULL;
|
str = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user