]> granicus.if.org Git - vim/commitdiff
patch 8.2.1111: inconsistent naming of get_list_tv() and eval_dict() v8.2.1111
authorBram Moolenaar <Bram@vim.org>
Wed, 1 Jul 2020 16:29:55 +0000 (18:29 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 1 Jul 2020 16:29:55 +0000 (18:29 +0200)
Problem:    Inconsistent naming of get_list_tv() and eval_dict().
Solution:   Rename get_list_tv() to eval_list().  Similarly for eval_number(),
            eval_string(), eval_lit_string() and a few others.

12 files changed:
src/eval.c
src/evalfunc.c
src/evalvars.c
src/list.c
src/proto/evalvars.pro
src/proto/list.pro
src/proto/typval.pro
src/typval.c
src/version.c
src/vim9compile.c
src/vim9execute.c
src/vim9script.c

index ce255e2b967bf66f4658884c738266d1ef13364d..9a2fdf65403dc922822939fd06b0781397c24844 100644 (file)
@@ -1224,7 +1224,7 @@ set_var_lval(
 
            // handle +=, -=, *=, /=, %= and .=
            di = NULL;
-           if (get_var_tv(lp->ll_name, (int)STRLEN(lp->ll_name),
+           if (eval_variable(lp->ll_name, (int)STRLEN(lp->ll_name),
                                             &tv, &di, TRUE, FALSE) == OK)
            {
                if ((di == NULL
@@ -2901,7 +2901,7 @@ eval7(
     case '7':
     case '8':
     case '9':
-    case '.':  ret = get_number_tv(arg, rettv, evaluate, want_string);
+    case '.':  ret = eval_number(arg, rettv, evaluate, want_string);
 
                // Apply prefixed "-" and "+" now.  Matters especially when
                // "->" follows.
@@ -2912,19 +2912,19 @@ eval7(
     /*
      * String constant: "string".
      */
-    case '"':  ret = get_string_tv(arg, rettv, evaluate);
+    case '"':  ret = eval_string(arg, rettv, evaluate);
                break;
 
     /*
      * Literal string constant: 'str''ing'.
      */
-    case '\'': ret = get_lit_string_tv(arg, rettv, evaluate);
+    case '\'': ret = eval_lit_string(arg, rettv, evaluate);
                break;
 
     /*
      * List: [expr, expr]
      */
-    case '[':  ret = get_list_tv(arg, rettv, evalarg, TRUE);
+    case '[':  ret = eval_list(arg, rettv, evalarg, TRUE);
                break;
 
     /*
@@ -2951,13 +2951,13 @@ eval7(
     /*
      * Option value: &name
      */
-    case '&':  ret = get_option_tv(arg, rettv, evaluate);
+    case '&':  ret = eval_option(arg, rettv, evaluate);
                break;
 
     /*
      * Environment variable: $VAR.
      */
-    case '$':  ret = get_env_tv(arg, rettv, evaluate);
+    case '$':  ret = eval_env_var(arg, rettv, evaluate);
                break;
 
     /*
@@ -3012,14 +3012,17 @@ eval7(
            ret = FAIL;
        else
        {
-           if (**arg == '(')           // recursive!
+           if (**arg == '(')
+               // "name(..."  recursive!
                ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);
            else if (flags & EVAL_CONSTANT)
                ret = FAIL;
            else if (evaluate)
-               ret = get_var_tv(s, len, rettv, NULL, TRUE, FALSE);
+               // get value of variable
+               ret = eval_variable(s, len, rettv, NULL, TRUE, FALSE);
            else
            {
+               // skip the name
                check_vars(s, len);
                ret = OK;
            }
index b8f1c2c38e05f76a677d4163a315d4677eb5c070..8d81f151236b29296b28c6a6961f46e1e655c9c9 100644 (file)
@@ -2324,7 +2324,7 @@ f_exists(typval_T *argvars, typval_T *rettv)
     }
     else if (*p == '&' || *p == '+')                   // option
     {
-       n = (get_option_tv(&p, NULL, TRUE) == OK);
+       n = (eval_option(&p, NULL, TRUE) == OK);
        if (*skipwhite(p) != NUL)
            n = FALSE;                  // trailing garbage
     }
index 901d406a00c55708e577e55001bf6fedca64c3ae..131486750c5409418d36aee6bc0f01f64571031a 100644 (file)
@@ -1124,7 +1124,7 @@ list_arg_vars(exarg_T *eap, char_u *arg, int *first)
            {
                if (tofree != NULL)
                    name = tofree;
-               if (get_var_tv(name, len, &tv, NULL, TRUE, FALSE) == FAIL)
+               if (eval_variable(name, len, &tv, NULL, TRUE, FALSE) == FAIL)
                    error = TRUE;
                else
                {
@@ -2365,7 +2365,7 @@ set_cmdarg(exarg_T *eap, char_u *oldarg)
  * Return OK or FAIL.  If OK is returned "rettv" must be cleared.
  */
     int
-get_var_tv(
+eval_variable(
     char_u     *name,
     int                len,            // length of "name"
     typval_T   *rettv,         // NULL when only checking existence
@@ -3206,7 +3206,7 @@ getwinvar(
                        done = TRUE;
                    }
                }
-               else if (get_option_tv(&varname, rettv, 1) == OK)
+               else if (eval_option(&varname, rettv, 1) == OK)
                    // window-local-option
                    done = TRUE;
            }
@@ -3342,7 +3342,7 @@ var_exists(char_u *var)
     {
        if (tofree != NULL)
            name = tofree;
-       n = (get_var_tv(name, len, &tv, NULL, FALSE, TRUE) == OK);
+       n = (eval_variable(name, len, &tv, NULL, FALSE, TRUE) == OK);
        if (n)
        {
            // handle d.key, l[idx], f(expr)
@@ -3609,7 +3609,7 @@ f_getbufvar(typval_T *argvars, typval_T *rettv)
                    done = TRUE;
                }
            }
-           else if (get_option_tv(&varname, rettv, TRUE) == OK)
+           else if (eval_option(&varname, rettv, TRUE) == OK)
                // buffer-local-option
                done = TRUE;
 
index 2bea55e02fea8eabcb42fe65941e1b8213a3604e..9475ef99e207889fb2d2c75a191024c62264143d 100644 (file)
@@ -1160,7 +1160,7 @@ f_join(typval_T *argvars, typval_T *rettv)
  * Return OK or FAIL.
  */
     int
-get_list_tv(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
+eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
 {
     int                evaluate = evalarg == NULL ? FALSE
                                         : evalarg->eval_flags & EVAL_EVALUATE;
index eab82c8cfaddb2e01a7edd004185ad4ac6841f0d..a1083100dcb52a9701af74bc31b23ad51712f6f1 100644 (file)
@@ -52,7 +52,7 @@ void set_reg_var(int c);
 char_u *v_exception(char_u *oldval);
 char_u *v_throwpoint(char_u *oldval);
 char_u *set_cmdarg(exarg_T *eap, char_u *oldarg);
-int get_var_tv(char_u *name, int len, typval_T *rettv, dictitem_T **dip, int verbose, int no_autoload);
+int eval_variable(char_u *name, int len, typval_T *rettv, dictitem_T **dip, int verbose, int no_autoload);
 void check_vars(char_u *name, int len);
 dictitem_T *find_var(char_u *name, hashtab_T **htp, int no_autoload);
 dictitem_T *find_var_in_ht(hashtab_T *ht, int htname, char_u *varname, int no_autoload);
index ddf26a5dd6896d6c4f89f99bf46129d83223e98b..53502ae72398951f7ecf2f0775f7204fbc6be909 100644 (file)
@@ -39,7 +39,7 @@ void vimlist_remove(list_T *l, listitem_T *item, listitem_T *item2);
 char_u *list2string(typval_T *tv, int copyID, int restore_copyID);
 int list_join(garray_T *gap, list_T *l, char_u *sep, int echo_style, int restore_copyID, int copyID);
 void f_join(typval_T *argvars, typval_T *rettv);
-int get_list_tv(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error);
+int eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error);
 int write_list(FILE *fd, list_T *list, int binary);
 void init_static_list(staticList10_T *sl);
 void f_list2str(typval_T *argvars, typval_T *rettv);
index 6eebde26e064cd1574b90398d45ceb48b73ed26e..3bc2f2c5e5da92f23b96f9c86d313fe35af90f30 100644 (file)
@@ -4,18 +4,6 @@ typval_T *alloc_string_tv(char_u *s);
 void free_tv(typval_T *varp);
 void clear_tv(typval_T *varp);
 void init_tv(typval_T *varp);
-int tv_check_lock(typval_T *tv, char_u *name, int use_gettext);
-void copy_tv(typval_T *from, typval_T *to);
-int typval_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int ic);
-char_u *typval_tostring(typval_T *arg);
-int tv_islocked(typval_T *tv);
-int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
-int get_option_tv(char_u **arg, typval_T *rettv, int evaluate);
-int get_number_tv(char_u **arg, typval_T *rettv, int evaluate, int want_string);
-int get_string_tv(char_u **arg, typval_T *rettv, int evaluate);
-int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate);
-char_u *tv2string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID);
-int get_env_tv(char_u **arg, typval_T *rettv, int evaluate);
 varnumber_T tv_get_number(typval_T *varp);
 varnumber_T tv_get_number_chk(typval_T *varp, int *denote);
 float_T tv_get_float(typval_T *varp);
@@ -23,8 +11,20 @@ char_u *tv_get_string(typval_T *varp);
 char_u *tv_get_string_buf(typval_T *varp, char_u *buf);
 char_u *tv_get_string_chk(typval_T *varp);
 char_u *tv_get_string_buf_chk(typval_T *varp, char_u *buf);
+char_u *tv_stringify(typval_T *varp, char_u *buf);
+int tv_check_lock(typval_T *tv, char_u *name, int use_gettext);
+void copy_tv(typval_T *from, typval_T *to);
+int typval_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int ic);
+char_u *typval_tostring(typval_T *arg);
+int tv_islocked(typval_T *tv);
+int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
+int eval_option(char_u **arg, typval_T *rettv, int evaluate);
+int eval_number(char_u **arg, typval_T *rettv, int evaluate, int want_string);
+int eval_string(char_u **arg, typval_T *rettv, int evaluate);
+int eval_lit_string(char_u **arg, typval_T *rettv, int evaluate);
+char_u *tv2string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID);
+int eval_env_var(char_u **arg, typval_T *rettv, int evaluate);
 linenr_T tv_get_lnum(typval_T *argvars);
 linenr_T tv_get_lnum_buf(typval_T *argvars, buf_T *buf);
 buf_T *tv_get_buf(typval_T *tv, int curtab_only);
-char_u *tv_stringify(typval_T *varp, char_u *buf);
 /* vim: set ft=c : */
index ebc51c6af32aa75cb46bbadde48bdb8d2a3f891f..9d0c6acd40ee309ce643d541532b2062ff2f51f6 100644 (file)
@@ -992,7 +992,7 @@ tv_equal(
  * Return OK or FAIL.
  */
     int
-get_option_tv(
+eval_option(
     char_u     **arg,
     typval_T   *rettv, // when NULL, only check if option exists
     int                evaluate)
@@ -1069,7 +1069,7 @@ get_option_tv(
  * Return OK or FAIL.
  */
     int
-get_number_tv(
+eval_number(
        char_u      **arg,
        typval_T    *rettv,
        int         evaluate,
@@ -1179,7 +1179,7 @@ get_number_tv(
  * Return OK or FAIL.
  */
     int
-get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
+eval_string(char_u **arg, typval_T *rettv, int evaluate)
 {
     char_u     *p;
     char_u     *end;
@@ -1297,7 +1297,7 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
                              {
                                  end += extra;
                                  if (end >= rettv->vval.v_string + len)
-                                     iemsg("get_string_tv() used more space than allocated");
+                                     iemsg("eval_string() used more space than allocated");
                                  break;
                              }
                          }
@@ -1323,7 +1323,7 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
  * Return OK or FAIL.
  */
     int
-get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate)
+eval_lit_string(char_u **arg, typval_T *rettv, int evaluate)
 {
     char_u     *p;
     char_u     *str;
@@ -1401,7 +1401,7 @@ tv2string(
  * Return FAIL if the name is invalid.
  */
     int
-get_env_tv(char_u **arg, typval_T *rettv, int evaluate)
+eval_env_var(char_u **arg, typval_T *rettv, int evaluate)
 {
     char_u     *string = NULL;
     int                len;
index e7dc813ce2fd4be7ef7d9ce3d6ba8a2a9973a622..7817a4442e5692b49f0b858e9c2cb490d0f6020d 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1111,
 /**/
     1110,
 /**/
index b3ed77d75d7edb7f021052f37333970159e4b07f..bb3122f40d5499c63f4071a7e1abb21a3d4ae9b1 100644 (file)
@@ -2868,9 +2868,9 @@ compile_call(
 
        argvars[0].v_type = VAR_UNKNOWN;
        if (*s == '"')
-           (void)get_string_tv(&s, &argvars[0], TRUE);
+           (void)eval_string(&s, &argvars[0], TRUE);
        else if (*s == '\'')
-           (void)get_lit_string_tv(&s, &argvars[0], TRUE);
+           (void)eval_lit_string(&s, &argvars[0], TRUE);
        s = skipwhite(s);
        if (*s == ')' && argvars[0].v_type == VAR_STRING)
        {
@@ -2992,7 +2992,7 @@ to_name_const_end(char_u *arg)
     {
 
        // Can be "[1, 2, 3]->Func()".
-       if (get_list_tv(&p, &rettv, NULL, FALSE) == FAIL)
+       if (eval_list(&p, &rettv, NULL, FALSE) == FAIL)
            p = arg;
     }
     else if (p == arg && *arg == '#' && arg[1] == '{')
@@ -3270,10 +3270,10 @@ compile_get_option(char_u **arg, cctx_T *cctx)
 
     // parse the option and get the current value to get the type.
     rettv.v_type = VAR_UNKNOWN;
-    ret = get_option_tv(arg, &rettv, TRUE);
+    ret = eval_option(arg, &rettv, TRUE);
     if (ret == OK)
     {
-       // include the '&' in the name, get_option_tv() expects it.
+       // include the '&' in the name, eval_option() expects it.
        char_u *name = vim_strnsave(start, *arg - start);
        type_T  *type = rettv.v_type == VAR_NUMBER ? &t_number : &t_string;
 
@@ -3304,7 +3304,7 @@ compile_get_env(char_u **arg, cctx_T *cctx)
        return FAIL;
     }
 
-    // include the '$' in the name, get_env_tv() expects it.
+    // include the '$' in the name, eval_env_var() expects it.
     name = vim_strnsave(start, len + 1);
     ret = generate_LOAD(cctx, ISN_LOADENV, 0, name, &t_string);
     vim_free(name);
@@ -3761,21 +3761,21 @@ compile_expr7(
        case '7':
        case '8':
        case '9':
-       case '.':   if (get_number_tv(arg, rettv, TRUE, FALSE) == FAIL)
+       case '.':   if (eval_number(arg, rettv, TRUE, FALSE) == FAIL)
                        return FAIL;
                    break;
 
        /*
         * String constant: "string".
         */
-       case '"':   if (get_string_tv(arg, rettv, TRUE) == FAIL)
+       case '"':   if (eval_string(arg, rettv, TRUE) == FAIL)
                        return FAIL;
                    break;
 
        /*
         * Literal string constant: 'str''ing'.
         */
-       case '\'':  if (get_lit_string_tv(arg, rettv, TRUE) == FAIL)
+       case '\'':  if (eval_lit_string(arg, rettv, TRUE) == FAIL)
                        return FAIL;
                    break;
 
index fda44ec08e05a2a193b55462a37dfdc6d186d28f..b4acb35c10453bcd7631284ada2e88ae1210713c 100644 (file)
@@ -1089,7 +1089,7 @@ call_def_function(
                    // compilation: don't set SOURCING_LNUM.
                    if (GA_GROW(&ectx.ec_stack, 1) == FAIL)
                        goto failed;
-                   if (get_option_tv(&name, &optval, TRUE) == FAIL)
+                   if (eval_option(&name, &optval, TRUE) == FAIL)
                        goto failed;
                    *STACK_TV_BOT(0) = optval;
                    ++ectx.ec_stack.ga_len;
@@ -1105,7 +1105,7 @@ call_def_function(
                    if (GA_GROW(&ectx.ec_stack, 1) == FAIL)
                        goto failed;
                    // name is always valid, checked when compiling
-                   (void)get_env_tv(&name, &optval, TRUE);
+                   (void)eval_env_var(&name, &optval, TRUE);
                    *STACK_TV_BOT(0) = optval;
                    ++ectx.ec_stack.ga_len;
                }
index 30c269af834806b534afb94257490ef6e6efa11c..aa6b92cddc4f5541f3f587c48e518ce6a2c8865b 100644 (file)
@@ -302,9 +302,9 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx)
     tv.v_type = VAR_UNKNOWN;
     // TODO: should we accept any expression?
     if (*arg == '\'')
-       ret = get_lit_string_tv(&arg, &tv, TRUE);
+       ret = eval_lit_string(&arg, &tv, TRUE);
     else if (*arg == '"')
-       ret = get_string_tv(&arg, &tv, TRUE);
+       ret = eval_string(&arg, &tv, TRUE);
     if (ret == FAIL || tv.vval.v_string == NULL || *tv.vval.v_string == NUL)
     {
        emsg(_("E1071: Invalid string after \"from\""));