aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c77
1 files changed, 62 insertions, 15 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index a1c5f958d1..a9af7d94c1 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1147,7 +1147,7 @@ int call_vim_function(
len = 0;
} else {
// Recognize a number argument, the others must be strings.
- vim_str2nr(argv[i], NULL, &len, true, true, true, &n, NULL);
+ vim_str2nr(argv[i], NULL, &len, STR2NR_ALL, &n, NULL, 0);
}
if (len != 0 && len == (int)STRLEN(argv[i])) {
argvars[i].v_type = VAR_NUMBER;
@@ -4138,7 +4138,7 @@ static int eval7(
rettv->vval.v_float = f;
}
} else {
- vim_str2nr(*arg, NULL, &len, true, true, true, &n, NULL);
+ vim_str2nr(*arg, NULL, &len, STR2NR_ALL, &n, NULL, 0);
*arg += len;
if (evaluate) {
rettv->v_type = VAR_NUMBER;
@@ -10930,6 +10930,7 @@ static void f_has(typval_T *argvars, typval_T *rettv)
#if !defined(UNIX)
"system", // TODO(SplinterOfChaos): This IS defined for UNIX!
#endif
+ "tablineat",
"tag_binary",
"tag_old_static",
"termresponse",
@@ -10987,8 +10988,6 @@ static void f_has(typval_T *argvars, typval_T *rettv)
#endif
} else if (STRICMP(name, "syntax_items") == 0) {
n = syntax_present(curwin);
- } else if (STRICMP(name, "gui_running") == 0) {
- n = ui_rgb_attached();
}
}
@@ -15209,6 +15208,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv)
list_T *l;
listitem_T *li;
dict_T *d;
+ list_T *s = NULL;
rettv->vval.v_number = -1;
if (argvars[0].v_type != VAR_LIST) {
@@ -15227,7 +15227,8 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv)
return;
}
if (!(dict_find(d, (char_u *)"group", -1) != NULL
- && dict_find(d, (char_u *)"pattern", -1) != NULL
+ && (dict_find(d, (char_u *)"pattern", -1) != NULL
+ || dict_find(d, (char_u *)"pos1", -1) != NULL)
&& dict_find(d, (char_u *)"priority", -1) != NULL
&& dict_find(d, (char_u *)"id", -1) != NULL)) {
EMSG(_(e_invarg));
@@ -15239,11 +15240,47 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv)
clear_matches(curwin);
li = l->lv_first;
while (li != NULL) {
+ int i = 0;
+ char_u buf[5];
+ dictitem_T *di;
d = li->li_tv.vval.v_dict;
- match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
- get_dict_string(d, (char_u *)"pattern", FALSE),
- (int)get_dict_number(d, (char_u *)"priority"),
- (int)get_dict_number(d, (char_u *)"id"), NULL);
+
+ if (dict_find(d, (char_u *)"pattern", -1) == NULL) {
+ if (s == NULL) {
+ s = list_alloc();
+ if (s == NULL) {
+ return;
+ }
+ }
+
+ // match from matchaddpos()
+ for (i = 1; i < 9; ++i) {
+ snprintf((char *)buf, sizeof(buf), (char *)"pos%d", i);
+ if ((di = dict_find(d, (char_u *)buf, -1)) != NULL) {
+ if (di->di_tv.v_type != VAR_LIST) {
+ return;
+ }
+
+ list_append_tv(s, &di->di_tv);
+ s->lv_refcount++;
+ } else {
+ break;
+ }
+ }
+ }
+
+ if (i == 0) {
+ match_add(curwin, get_dict_string(d, (char_u *)"group", false),
+ get_dict_string(d, (char_u *)"pattern", false),
+ (int)get_dict_number(d, (char_u *)"priority"),
+ (int)get_dict_number(d, (char_u *)"id"), NULL);
+ } else {
+ match_add(curwin, get_dict_string(d, (char_u *)"group", false),
+ NULL, (int)get_dict_number(d, (char_u *)"priority"),
+ (int)get_dict_number(d, (char_u *)"id"), s);
+ list_unref(s);
+ s = NULL;
+ }
li = li->li_next;
}
rettv->vval.v_number = 0;
@@ -16037,6 +16074,7 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv)
int base = 10;
char_u *p;
long n;
+ int what;
if (argvars[1].v_type != VAR_UNKNOWN) {
base = get_tv_number(&argvars[1]);
@@ -16050,11 +16088,20 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv)
if (*p == '+') {
p = skipwhite(p + 1);
}
- vim_str2nr(p, NULL, NULL,
- base == 2 ? 2 : 0,
- base == 8 ? 2 : 0,
- base == 16 ? 2 : 0,
- &n, NULL);
+ switch (base) {
+ case 2:
+ what = STR2NR_BIN + STR2NR_FORCE;
+ break;
+ case 8:
+ what = STR2NR_OCT + STR2NR_FORCE;
+ break;
+ case 16:
+ what = STR2NR_HEX + STR2NR_FORCE;
+ break;
+ default:
+ what = 0;
+ }
+ vim_str2nr(p, NULL, NULL, what, &n, NULL, 0);
rettv->vval.v_number = n;
}
@@ -18336,7 +18383,7 @@ long get_tv_number_chk(typval_T *varp, int *denote)
case VAR_STRING:
if (varp->vval.v_string != NULL) {
vim_str2nr(varp->vval.v_string, NULL, NULL,
- true, true, true, &n, NULL);
+ STR2NR_ALL, &n, NULL, 0);
}
return n;
case VAR_LIST: