aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-12-23 18:17:01 +0100
committerGitHub <noreply@github.com>2017-12-23 18:17:01 +0100
commitdee78a4095a27369e428572f74f7b64bcc5f670e (patch)
tree4f06de0fd7a5a80d746c2ffaf18cb0719e66cccd /src/nvim/regexp.c
parentec86f4215fc58246998c6017df84206153d0df1a (diff)
parent5cb7a709e7f60b0e7bcde70a1aa9fea5f060fe0f (diff)
downloadrneovim-dee78a4095a27369e428572f74f7b64bcc5f670e.tar.gz
rneovim-dee78a4095a27369e428572f74f7b64bcc5f670e.tar.bz2
rneovim-dee78a4095a27369e428572f74f7b64bcc5f670e.zip
Merge #7708 from ZyX-I/hide-container-impl
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r--src/nvim/regexp.c59
1 files changed, 26 insertions, 33 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index ec9916f4a2..ddc3681867 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -232,17 +232,17 @@
#define LAST_NL NUPPER + ADD_NL
#define WITH_NL(op) ((op) >= FIRST_NL && (op) <= LAST_NL)
-#define MOPEN 80 /* -89 Mark this point in input as start of
- * \( subexpr. MOPEN + 0 marks start of
- * match. */
-#define MCLOSE 90 /* -99 Analogous to MOPEN. MCLOSE + 0 marks
- * end of match. */
-#define BACKREF 100 /* -109 node Match same string again \1-\9 */
-
-# define ZOPEN 110 /* -119 Mark this point in input as start of
- * \z( subexpr. */
-# define ZCLOSE 120 /* -129 Analogous to ZOPEN. */
-# define ZREF 130 /* -139 node Match external submatch \z1-\z9 */
+#define MOPEN 80 // -89 Mark this point in input as start of
+ // \( … \) subexpr. MOPEN + 0 marks start of
+ // match.
+#define MCLOSE 90 // -99 Analogous to MOPEN. MCLOSE + 0 marks
+ // end of match.
+#define BACKREF 100 // -109 node Match same string again \1-\9.
+
+# define ZOPEN 110 // -119 Mark this point in input as start of
+ // \z( … \) subexpr.
+# define ZCLOSE 120 // -129 Analogous to ZOPEN.
+# define ZREF 130 // -139 node Match external submatch \z1-\z9
#define BRACE_COMPLEX 140 /* -149 node Match nodes between m & n times */
@@ -462,11 +462,11 @@ static int toggle_Magic(int x)
#define IEMSG_RET_NULL(m) return (IEMSG(m), rc_did_emsg = true, (void *)NULL)
#define EMSG_RET_FAIL(m) return (EMSG(m), rc_did_emsg = true, FAIL)
#define EMSG2_RET_NULL(m, c) \
- return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, (void *)NULL)
+ return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, (void *)NULL)
#define EMSG2_RET_FAIL(m, c) \
- return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, FAIL)
+ return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, FAIL)
#define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_( \
- "E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL)
+ "E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL)
#define MAX_LIMIT (32767L << 16L)
@@ -6474,41 +6474,35 @@ static regsubmatch_T rsm; // can only be used when can_f_submatch is true
/// vim_regsub_both().
static int fill_submatch_list(int argc, typval_T *argv, int argcount)
{
- listitem_T *li;
- int i;
- char_u *s;
-
if (argcount == 0) {
// called function doesn't take an argument
return 0;
}
// Relies on sl_list to be the first item in staticList10_T.
- init_static_list((staticList10_T *)(argv->vval.v_list));
+ tv_list_init_static10((staticList10_T *)argv->vval.v_list);
// There are always 10 list items in staticList10_T.
- li = argv->vval.v_list->lv_first;
- for (i = 0; i < 10; i++) {
- s = rsm.sm_match->startp[i];
+ listitem_T *li = tv_list_first(argv->vval.v_list);
+ for (int i = 0; i < 10; i++) {
+ char_u *s = rsm.sm_match->startp[i];
if (s == NULL || rsm.sm_match->endp[i] == NULL) {
s = NULL;
} else {
s = vim_strnsave(s, (int)(rsm.sm_match->endp[i] - s));
}
- li->li_tv.v_type = VAR_STRING;
- li->li_tv.vval.v_string = s;
- li = li->li_next;
+ TV_LIST_ITEM_TV(li)->v_type = VAR_STRING;
+ TV_LIST_ITEM_TV(li)->vval.v_string = s;
+ li = TV_LIST_ITEM_NEXT(argv->vval.v_list, li);
}
return 1;
}
static void clear_submatch_list(staticList10_T *sl)
{
- int i;
-
- for (i = 0; i < 10; i++) {
- xfree(sl->sl_items[i].li_tv.vval.v_string);
- }
+ TV_LIST_ITER(&sl->sl_list, li, {
+ xfree(TV_LIST_ITEM_TV(li)->vval.v_string);
+ });
}
/// vim_regsub() - perform substitutions after a vim_regexec() or
@@ -6642,13 +6636,12 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
typval_T argv[2];
int dummy;
typval_T rettv;
- staticList10_T matchList;
+ staticList10_T matchList = TV_LIST_STATIC10_INIT;
rettv.v_type = VAR_STRING;
rettv.vval.v_string = NULL;
argv[0].v_type = VAR_LIST;
argv[0].vval.v_list = &matchList.sl_list;
- matchList.sl_list.lv_len = 0;
if (expr->v_type == VAR_FUNC) {
s = expr->vval.v_string;
call_func(s, (int)STRLEN(s), &rettv, 1, argv,
@@ -6662,7 +6655,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
fill_submatch_list, 0L, 0L, &dummy,
true, partial, NULL);
}
- if (matchList.sl_list.lv_len > 0) {
+ if (tv_list_len(&matchList.sl_list) > 0) {
// fill_submatch_list() was called.
clear_submatch_list(&matchList);
}