summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-01 21:11:22 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-01 21:11:22 +0100
commit5d18efecfd6c45d69f55268948a22cd0465bb955 (patch)
tree409afa09cb7fb8f4684e0399f2597ba5d16edbfa /src/eval.c
parentfa5612c7d836eb789e0f8ff4b10461b8640a14b2 (diff)
patch 8.1.2378: using old C style commentsv8.1.2378
Problem: Using old C style comments. Solution: Use // comments where appropriate.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c597
1 files changed, 298 insertions, 299 deletions
diff --git a/src/eval.c b/src/eval.c
index c37d6fdc20..178f47388e 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -36,19 +36,19 @@ static char *e_nowhitespace = N_("E274: No white space allowed before parenthesi
*/
static int current_copyID = 0;
-static int echo_attr = 0; /* attributes used for ":echo" */
+static int echo_attr = 0; // attributes used for ":echo"
/*
* Info used by a ":for" loop.
*/
typedef struct
{
- int fi_semicolon; /* TRUE if ending in '; var]' */
- int fi_varcount; /* nr of variables in the list */
- listwatch_T fi_lw; /* keep an eye on the item used. */
- list_T *fi_list; /* list being used */
- int fi_bi; /* index of blob */
- blob_T *fi_blob; /* blob being used */
+ int fi_semicolon; // TRUE if ending in '; var]'
+ int fi_varcount; // nr of variables in the list
+ listwatch_T fi_lw; // keep an eye on the item used.
+ list_T *fi_list; // list being used
+ int fi_bi; // index of blob
+ blob_T *fi_blob; // blob being used
} forinfo_T;
static int tv_op(typval_T *tv1, typval_T *tv2, char_u *op);
@@ -174,7 +174,7 @@ eval_to_bool(
char_u *arg,
int *error,
char_u **nextcmd,
- int skip) /* only parse, don't execute */
+ int skip) // only parse, don't execute
{
typval_T tv;
varnumber_T retval = FALSE;
@@ -261,7 +261,7 @@ eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv)
s = skipwhite(s);
if (eval1_emsg(&s, rettv, TRUE) == FAIL)
return FAIL;
- if (*s != NUL) /* check for trailing chars after expr */
+ if (*s != NUL) // check for trailing chars after expr
{
clear_tv(rettv);
semsg(_(e_invexpr2), s);
@@ -300,7 +300,7 @@ eval_expr_to_bool(typval_T *expr, int *error)
eval_to_string_skip(
char_u *arg,
char_u **nextcmd,
- int skip) /* only parse, don't execute */
+ int skip) // only parse, don't execute
{
typval_T tv;
char_u *retval;
@@ -467,7 +467,7 @@ call_vim_function(
int ret;
funcexe_T funcexe;
- rettv->v_type = VAR_UNKNOWN; /* clear_tv() uses this */
+ rettv->v_type = VAR_UNKNOWN; // clear_tv() uses this
vim_memset(&funcexe, 0, sizeof(funcexe));
funcexe.firstline = curwin->w_cursor.lnum;
funcexe.lastline = curwin->w_cursor.lnum;
@@ -574,15 +574,15 @@ eval_foldexpr(char_u *arg, int *cp)
retval = 0;
else
{
- /* If the result is a number, just return the number. */
+ // If the result is a number, just return the number.
if (tv.v_type == VAR_NUMBER)
retval = tv.vval.v_number;
else if (tv.v_type != VAR_STRING || tv.vval.v_string == NULL)
retval = 0;
else
{
- /* If the result is a string, check if there is a non-digit before
- * the number. */
+ // If the result is a string, check if there is a non-digit before
+ // the number.
s = tv.vval.v_string;
if (!VIM_ISDIGIT(*s) && *s != '-')
*cp = *s++;
@@ -625,8 +625,8 @@ get_lval(
lval_T *lp,
int unlet,
int skip,
- int flags, /* GLV_ values */
- int fne_flags) /* flags for find_name_end() */
+ int flags, // GLV_ values
+ int fne_flags) // flags for find_name_end()
{
char_u *p;
char_u *expr_start, *expr_end;
@@ -641,21 +641,21 @@ get_lval(
hashtab_T *ht;
int quiet = flags & GLV_QUIET;
- /* Clear everything in "lp". */
+ // Clear everything in "lp".
vim_memset(lp, 0, sizeof(lval_T));
if (skip)
{
- /* When skipping just find the end of the name. */
+ // When skipping just find the end of the name.
lp->ll_name = name;
return find_name_end(name, NULL, NULL, FNE_INCL_BR | fne_flags);
}
- /* Find the end of the name. */
+ // Find the end of the name.
p = find_name_end(name, &expr_start, &expr_end, fne_flags);
if (expr_start != NULL)
{
- /* Don't expand the name when we already know there is an error. */
+ // Don't expand the name when we already know there is an error.
if (unlet && !VIM_ISWHITE(*p) && !ends_excmd(*p)
&& *p != '[' && *p != '.')
{
@@ -666,9 +666,9 @@ get_lval(
lp->ll_exp_name = make_expanded_name(name, expr_start, expr_end, p);
if (lp->ll_exp_name == NULL)
{
- /* Report an invalid expression in braces, unless the
- * expression evaluation has been cancelled due to an
- * aborting error, an interrupt, or an exception. */
+ // Report an invalid expression in braces, unless the
+ // expression evaluation has been cancelled due to an
+ // aborting error, an interrupt, or an exception.
if (!aborting() && !quiet)
{
emsg_severe = TRUE;
@@ -681,14 +681,14 @@ get_lval(
else
lp->ll_name = name;
- /* Without [idx] or .key we are done. */
+ // Without [idx] or .key we are done.
if ((*p != '[' && *p != '.') || lp->ll_name == NULL)
return p;
cc = *p;
*p = NUL;
- /* Only pass &ht when we would write to the variable, it prevents autoload
- * as well. */
+ // Only pass &ht when we would write to the variable, it prevents autoload
+ // as well.
v = find_var(lp->ll_name, (flags & GLV_READ_ONLY) ? NULL : &ht,
flags & GLV_NO_AUTOLOAD);
if (v == NULL && !quiet)
@@ -738,24 +738,24 @@ get_lval(
}
else
{
- /* Get the index [expr] or the first index [expr: ]. */
+ // Get the index [expr] or the first index [expr: ].
p = skipwhite(p + 1);
if (*p == ':')
empty1 = TRUE;
else
{
empty1 = FALSE;
- if (eval1(&p, &var1, TRUE) == FAIL) /* recursive! */
+ if (eval1(&p, &var1, TRUE) == FAIL) // recursive!
return NULL;
if (tv_get_string_chk(&var1) == NULL)
{
- /* not a number or string */
+ // not a number or string
clear_tv(&var1);
return NULL;
}
}
- /* Optionally get the second index [ :expr]. */
+ // Optionally get the second index [ :expr].
if (*p == ':')
{
if (lp->ll_tv->v_type == VAR_DICT)
@@ -782,14 +782,14 @@ get_lval(
else
{
lp->ll_empty2 = FALSE;
- if (eval1(&p, &var2, TRUE) == FAIL) /* recursive! */
+ if (eval1(&p, &var2, TRUE) == FAIL) // recursive!
{
clear_tv(&var1);
return NULL;
}
if (tv_get_string_chk(&var2) == NULL)
{
- /* not a number or string */
+ // not a number or string
clear_tv(&var1);
clear_tv(&var2);
return NULL;
@@ -809,7 +809,7 @@ get_lval(
return NULL;
}
- /* Skip to past ']'. */
+ // Skip to past ']'.
++p;
}
@@ -817,8 +817,8 @@ get_lval(
{
if (len == -1)
{
- /* "[key]": get key from "var1" */
- key = tv_get_string_chk(&var1); /* is number or string */
+ // "[key]": get key from "var1"
+ key = tv_get_string_chk(&var1); // is number or string
if (key == NULL)
{
clear_tv(&var1);
@@ -829,9 +829,9 @@ get_lval(
lp->ll_dict = lp->ll_tv->vval.v_dict;
lp->ll_di = dict_find(lp->ll_dict, key, len);
- /* When assigning to a scope dictionary check that a function and
- * variable name is valid (only variable name unless it is l: or
- * g: dictionary). Disallow overwriting a builtin function. */
+ // When assigning to a scope dictionary check that a function and
+ // variable name is valid (only variable name unless it is l: or
+ // g: dictionary). Disallow overwriting a builtin function.
if (rettv != NULL && lp->ll_dict->dv_scope != 0)
{
int prevval;
@@ -843,7 +843,7 @@ get_lval(
key[len] = NUL;
}
else
- prevval = 0; /* avoid compiler warning */
+ prevval = 0; // avoid compiler warning
wrong = (lp->ll_dict->dv_scope == VAR_DEF_SCOPE
&& rettv->v_type == VAR_FUNC
&& var_check_func_name(key, lp->ll_di == NULL))
@@ -882,7 +882,7 @@ get_lval(
p = NULL;
break;
}
- /* existing variable, need to check if it can be changed */
+ // existing variable, need to check if it can be changed
else if ((flags & GLV_READ_ONLY) == 0
&& var_check_ro(lp->ll_di->di_flags, name, FALSE))
{
@@ -941,7 +941,7 @@ get_lval(
if (empty1)
lp->ll_n1 = 0;
else
- /* is number or string */
+ // is number or string
lp->ll_n1 = (long)tv_get_number(&var1);
clear_tv(&var1);
@@ -973,7 +973,7 @@ get_lval(
if (lp->ll_range && !lp->ll_empty2)
{
lp->ll_n2 = (long)tv_get_number(&var2);
- /* is number or string */
+ // is number or string
clear_tv(&var2);
if (lp->ll_n2 < 0)
{
@@ -987,7 +987,7 @@ get_lval(
lp->ll_n2 = list_idx_of_item(lp->ll_list, ni);
}
- /* Check that lp->ll_n2 isn't before lp->ll_n1. */
+ // Check that lp->ll_n2 isn't before lp->ll_n1.
if (lp->ll_n1 < 0)
lp->ll_n1 = list_idx_of_item(lp->ll_list, lp->ll_li);
if (lp->ll_n2 < lp->ll_n1)
@@ -1164,7 +1164,7 @@ set_var_lval(
break;
if (lp->ll_li->li_next == NULL)
{
- /* Need to add an empty item. */
+ // Need to add an empty item.
if (list_append_number(lp->ll_list, 0) == FAIL)
{
ri = NULL;
@@ -1199,7 +1199,7 @@ set_var_lval(
return;
}
- /* Need to add an item to the Dictionary. */
+ // Need to add an item to the Dictionary.
di = dictitem_alloc(lp->ll_newkey);
if (di == NULL)
return;
@@ -1244,7 +1244,7 @@ tv_op(typval_T *tv1, typval_T *tv2, char_u *op)
char_u numbuf[NUMBUFLEN];
char_u *s;
- /* Can't do anything with a Funcref, Dict, v:true on the right. */
+ // Can't do anything with a Funcref, Dict, v:true on the right.
if (tv2->v_type != VAR_FUNC && tv2->v_type != VAR_DICT
&& tv2->v_type != VAR_SPECIAL)
{
@@ -1386,7 +1386,7 @@ eval_for_line(
typval_T tv;
list_T *l;
- *errp = TRUE; /* default: there is an error */
+ *errp = TRUE; // default: there is an error
fi = ALLOC_CLEAR_ONE(forinfo_T);
if (fi == NULL)
@@ -1526,7 +1526,7 @@ set_context_for_expression(
xp->xp_context = EXPAND_USER_VARS;
if (vim_strpbrk(arg, (char_u *)"\"'+-*/%.=!?~|&$([<>,#") == NULL)
{
- /* ":let var1 var2 ...": find last space. */
+ // ":let var1 var2 ...": find last space.
for (p = arg + STRLEN(arg); p >= arg; )
{
xp->xp_pattern = p;
@@ -1563,7 +1563,7 @@ set_context_for_expression(
}
else if (c == '$')
{
- /* environment variable */
+ // environment variable
xp->xp_context = EXPAND_ENV_VARS;
}
else if (c == '=')
@@ -1574,28 +1574,28 @@ set_context_for_expression(
else if (c == '#'
&& xp->xp_context == EXPAND_EXPRESSION)
{
- /* Autoload function/variable contains '#'. */
+ // Autoload function/variable contains '#'.
break;
}
else if ((c == '<' || c == '#')
&& xp->xp_context == EXPAND_FUNCTIONS
&& vim_strchr(xp->xp_pattern, '(') == NULL)
{
- /* Function name can start with "<SNR>" and contain '#'. */
+ // Function name can start with "<SNR>" and contain '#'.
break;
}
else if (cmdidx != CMD_let || got_eq)
{
- if (c == '"') /* string */
+ if (c == '"') // string
{
while ((c = *++xp->xp_pattern) != NUL && c != '"')
if (c == '\\' && xp->xp_pattern[1] != NUL)
++xp->xp_pattern;
xp->xp_context = EXPAND_NOTHING;
}
- else if (c == '\'') /* literal string */
+ else if (c == '\'') // literal string
{
- /* Trick: '' is like stopping and starting a literal string. */
+ // Trick: '' is like stopping and starting a literal string.
while ((c = *++xp->xp_pattern) != NUL && c != '\'')
/* skip */ ;
xp->xp_context = EXPAND_NOTHING;
@@ -1614,8 +1614,8 @@ set_context_for_expression(
xp->xp_context = EXPAND_EXPRESSION;
}
else
- /* Doesn't look like something valid, expand as an expression
- * anyway. */
+ // Doesn't look like something valid, expand as an expression
+ // anyway.
xp->xp_context = EXPAND_EXPRESSION;
arg = xp->xp_pattern;
if (*arg != NUL)
@@ -1636,7 +1636,7 @@ pattern_match(char_u *pat, char_u *text, int ic)
char_u *save_cpo;
regmatch_T regmatch;
- /* avoid 'l' flag in 'cpoptions' */
+ // avoid 'l' flag in 'cpoptions'
save_cpo = p_cpo;
p_cpo = (char_u *)"";
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
@@ -1672,12 +1672,12 @@ eval_func(
if (!evaluate)
check_vars(s, len);
- /* If "s" is the name of a variable of type VAR_FUNC
- * use its contents. */
+ // If "s" is the name of a variable of type VAR_FUNC
+ // use its contents.
s = deref_func_name(s, &len, &partial, !evaluate);
- /* Need to make a copy, in case evaluating the arguments makes
- * the name invalid. */
+ // Need to make a copy, in case evaluating the arguments makes
+ // the name invalid.
s = vim_strsave(s);
if (s == NULL)
ret = FAIL;
@@ -1696,18 +1696,18 @@ eval_func(
}
vim_free(s);
- /* If evaluate is FALSE rettv->v_type was not set in
- * get_func_tv, but it's needed in handle_subscript() to parse
- * what follows. So set it here. */
+ // If evaluate is FALSE rettv->v_type was not set in
+ // get_func_tv, but it's needed in handle_subscript() to parse
+ // what follows. So set it here.
if (rettv->v_type == VAR_UNKNOWN && !evaluate && **arg == '(')
{
rettv->vval.v_string = NULL;
rettv->v_type = VAR_FUNC;
}
- /* Stop the expression evaluation when immediately
- * aborting on error, or when an interrupt occurred or
- * an exception was thrown but not caught. */
+ // Stop the expression evaluation when immediately
+ // aborting on error, or when an interrupt occurred or
+ // an exception was thrown but not caught.
if (evaluate && aborting())
{
if (ret == OK)
@@ -1806,7 +1806,7 @@ eval1(char_u **arg, typval_T *rettv, int evaluate)
* Get the second variable.
*/
*arg = skipwhite(*arg + 1);
- if (eval1(arg, rettv, evaluate && result) == FAIL) /* recursive! */
+ if (eval1(arg, rettv, evaluate && result) == FAIL) // recursive!
return FAIL;
/*
@@ -1824,7 +1824,7 @@ eval1(char_u **arg, typval_T *rettv, int evaluate)
* Get the third variable.
*/
*arg = skipwhite(*arg + 1);
- if (eval1(arg, &var2, evaluate && !result) == FAIL) /* recursive! */
+ if (eval1(arg, &var2, evaluate && !result) == FAIL) // recursive!
{
if (evaluate && result)
clear_tv(rettv);
@@ -1998,7 +1998,7 @@ eval4(char_u **arg, typval_T *rettv, int evaluate)
char_u *p;
int i;
exptype_T type = TYPE_UNKNOWN;
- int type_is = FALSE; /* TRUE for "is" and "isnot" */
+ int type_is = FALSE; // TRUE for "is" and "isnot"
int len = 2;
int ic;
@@ -2056,19 +2056,19 @@ eval4(char_u **arg, typval_T *rettv, int evaluate)
*/
if (type != TYPE_UNKNOWN)
{
- /* extra question mark appended: ignore case */
+ // extra question mark appended: ignore case
if (p[len] == '?')
{
ic = TRUE;
++len;
}
- /* extra '#' appended: match case */
+ // extra '#' appended: match case
else if (p[len] == '#')
{
ic = FALSE;
++len;
}
- /* nothing appended: use 'ignorecase' */
+ // nothing appended: use 'ignorecase'
else
ic = p_ic;
@@ -2145,13 +2145,13 @@ eval5(char_u **arg, typval_T *rettv, int evaluate)
#endif
)
{
- /* For "list + ...", an illegal use of the first operand as
- * a number cannot be determined before evaluating the 2nd
- * operand: if this is also a list, all is ok.
- * For "something . ...", "something - ..." or "non-list + ...",
- * we know that the first operand needs to be a string or number
- * without evaluating the 2nd operand. So check before to avoid
- * side effects after an error. */
+ // For "list + ...", an illegal use of the first operand as
+ // a number cannot be determined before evaluating the 2nd
+ // operand: if this is also a list, all is ok.
+ // For "something . ...", "something - ..." or "non-list + ...",
+ // we know that the first operand needs to be a string or number
+ // without evaluating the 2nd operand. So check before to avoid
+ // side effects after an error.
if (evaluate && tv_get_string_chk(rettv) == NULL)
{
clear_tv(rettv);
@@ -2178,9 +2178,9 @@ eval5(char_u **arg, typval_T *rettv, int evaluate)
*/
if (op == '.')
{
- s1 = tv_get_string_buf(rettv, buf1); /* already checked */
+ s1 = tv_get_string_buf(rettv, buf1); // already checked
s2 = tv_get_string_buf_chk(&var2, buf2);
- if (s2 == NULL) /* type error ? */
+ if (s2 == NULL) // type error ?
{
clear_tv(rettv);
clear_tv(&var2);
@@ -2213,7 +2213,7 @@ eval5(char_u **arg, typval_T *rettv, int evaluate)
else if (op == '+' && rettv->v_type == VAR_LIST
&& var2.v_type == VAR_LIST)
{
- /* concatenate Lists */
+ // concatenate Lists
if (list_concat(rettv->vval.v_list, var2.vval.v_list,
&var3) == FAIL)
{
@@ -2240,9 +2240,9 @@ eval5(char_u **arg, typval_T *rettv, int evaluate)
n1 = tv_get_number_chk(rettv, &error);
if (error)
{
- /* This can only happen for "list + non-list". For
- * "non-list + ..." or "something - ...", we returned
- * before evaluating the 2nd operand. */
+ // This can only happen for "list + non-list". For
+ // "non-list + ..." or "something - ...", we returned
+ // before evaluating the 2nd operand.
clear_tv(rettv);
return FAIL;
}
@@ -2275,7 +2275,7 @@ eval5(char_u **arg, typval_T *rettv, int evaluate)
clear_tv(rettv);
#ifdef FEAT_FLOAT
- /* If there is a float on either side the result is a float. */
+ // If there is a float on either side the result is a float.
if (rettv->v_type == VAR_FLOAT || var2.v_type == VAR_FLOAT)
{
if (op == '+')
@@ -2318,7 +2318,7 @@ eval6(
char_u **arg,
typval_T *rettv,
int evaluate,
- int want_string) /* after "." operator */
+ int want_string) // after "." operator
{
typval_T var2;
int op;
@@ -2408,11 +2408,11 @@ eval6(
else if (op == '/')
{
# ifdef VMS
- /* VMS crashes on divide by zero, work around it */
+ // VMS crashes on divide by zero, work around it
if (f2 == 0.0)
{
if (f1 == 0)
- f1 = -1 * __F_FLT_MAX - 1L; /* similar to NaN */
+ f1 = -1 * __F_FLT_MAX - 1L; // similar to NaN
else if (f1 < 0)
f1 = -1 * __F_FLT_MAX;
else
@@ -2421,8 +2421,8 @@ eval6(
else
f1 = f1 / f2;
# else
- /* We rely on the floating point library to handle divide
- * by zero to result in "inf" and not a crash. */
+ // We rely on the floating point library to handle divide
+ // by zero to result in "inf" and not a crash.
f1 = f1 / f2;
# endif
}
@@ -2487,7 +2487,7 @@ eval7(
char_u **arg,
typval_T *rettv,
int evaluate,
- int want_string UNUSED) /* after "." operator */
+ int want_string UNUSED) // after "." operator
{
varnumber_T n;
int len;
@@ -2542,13 +2542,13 @@ eval7(
char_u *p;
int get_float = FALSE;
- /* We accept a float when the format matches
- * "[0-9]\+\.[0-9]\+\([eE][+-]\?[0-9]\+\)\?". This is very
- * strict to avoid backwards compatibility problems.
- * With script version 2 and later the leading digit can be
- * omitted.
- * Don't look for a float after the "." operator, so that
- * ":let vers = 1.2.3" doesn't fail. */
+ // We accept a float when the format matches
+ // "[0-9]\+\.[0-9]\+\([eE][+-]\?[0-9]\+\)\?". This is very
+ // strict to avoid backwards compatibility problems.
+ // With script version 2 and later the leading digit can be
+ // omitted.
+ // Don't look for a float after the "." operator, so that
+ // ":let vers = 1.2.3" doesn't fail.
if (**arg == '.')
p = *arg;
else
@@ -2705,7 +2705,7 @@ eval7(
* nested expression: (expression).
*/
case '(': *arg = skipwhite(*arg + 1);
- ret = eval1(arg, rettv, evaluate); /* recursive! */
+ ret = eval1(arg, rettv, evaluate); // recursive!
if (**arg == ')')
++*arg;
else if (ret == OK)
@@ -2735,7 +2735,7 @@ eval7(
ret = FAIL;
else
{
- if (**arg == '(') /* recursive! */
+ if (**arg == '(') // recursive!
ret = eval_func(arg, s, len, rettv, evaluate, NULL);
else if (evaluate)
ret = get_var_tv(s, len, rettv, NULL, TRUE, FALSE);
@@ -2750,8 +2750,8 @@ eval7(
*arg = skipwhite(*arg);
- /* Handle following '[', '(' and '.' for expr[expr], expr.name,
- * expr(expr), expr->name(expr) */
+ // Handle following '[', '(' and '.' for expr[expr], expr.name,
+ // expr(expr), expr->name(expr)
if (ret == OK)
ret = handle_subscript(arg, rettv, evaluate, TRUE,
start_leader, &end_leader);
@@ -2853,7 +2853,7 @@ call_func_rettv(
functv = *rettv;
rettv->v_type = VAR_UNKNOWN;
- /* Invoke the function. Recursive! */
+ // Invoke the function. Recursive!
if (functv.v_type == VAR_PARTIAL)
{
pt = functv.vval.v_partial;
@@ -2874,8 +2874,8 @@ call_func_rettv(
funcexe.basetv = basetv;
ret = get_func_tv(s, -1, rettv, arg, &funcexe);
- /* Clear the funcref afterwards, so that deleting it while
- * evaluating the arguments is possible (see test55). */
+ // Clear the funcref afterwards, so that deleting it while
+ // evaluating the arguments is possible (see test55).
if (evaluate)
clear_tv(&functv);
@@ -2892,7 +2892,7 @@ eval_lambda(
char_u **arg,
typval_T *rettv,
int evaluate,
- int verbose) /* give error messages */
+ int verbose) // give error messages
{
typval_T base = *rettv;
int ret;
@@ -2937,7 +2937,7 @@ eval_method(
char_u **arg,
typval_T *rettv,
int evaluate,
- int verbose) /* give error messages */
+ int verbose) // give error messages
{
char_u *name;
long len;
@@ -2996,7 +2996,7 @@ eval_index(
char_u **arg,
typval_T *rettv,
int evaluate,
- int verbose) /* give error messages */
+ int verbose) // give error messages
{
int empty1 = FALSE, empty2 = FALSE;
typval_T var1, var2;
@@ -3029,7 +3029,7 @@ eval_index(
case VAR_UNKNOWN:
if (evaluate)
return FAIL;
- /* FALLTHROUGH */
+ // FALLTHROUGH
case VAR_STRING:
case VAR_NUMBER:
@@ -3063,11 +3063,11 @@ eval_index(
*arg = skipwhite(*arg + 1);
if (**arg == ':')
empty1 = TRUE;
- else if (eval1(arg, &var1, evaluate) == FAIL) /* recursive! */
+ else if (eval1(arg, &var1, evaluate) == FAIL) // recursive!
return FAIL;
else if (evaluate && tv_get_string_chk(&var1) == NULL)
{
- /* not a number or string */
+ // not a number or string
clear_tv(&var1);
return FAIL;
}
@@ -3081,7 +3081,7 @@ eval_index(
*arg = skipwhite(*arg + 1);
if (**arg == ']')
empty2 = TRUE;
- else if (eval1(arg, &var2, evaluate) == FAIL) /* recursive! */
+ else if (eval1(arg, &var2, evaluate) == FAIL) // recursive!
{
if (!empty1)
clear_tv(&var1);
@@ -3089,7 +3089,7 @@ eval_index(
}
else if (evaluate && tv_get_string_chk(&var2) == NULL)
{
- /* not a number or string */
+ // not a number or string
if (!empty1)
clear_tv(&var1);
clear_tv(&var2);
@@ -3097,7 +3097,7 @@ eval_index(
}
}
- /* Check for the ']'. */
+ // Check for the ']'.
if (**arg != ']')
{
if (verbose)
@@ -3107,7 +3107,7 @@ eval_index(
clear_tv(&var2);
return FAIL;
}
- *arg = skipwhite(*arg + 1); /* skip the ']' */
+ *arg = skipwhite(*arg + 1); // skip the ']'
}
if (evaluate)
@@ -3138,7 +3138,7 @@ eval_index(
case VAR_SPECIAL:
case VAR_JOB:
case VAR_CHANNEL:
- break; /* not evaluating, skipping over subscript */
+ break; // not evaluating, skipping over subscript
case VAR_NUMBER:
case VAR_STRING:
@@ -3146,8 +3146,8 @@ eval_index(
len = (long)STRLEN(s);
if (range)
{
- /* The resulting variable is a substring. If the indexes
- * are out of range the result is empty. */
+ // The resulting variable is a substring. If the indexes
+ // are out of range the result is empty.
if (n1 < 0)
{
n1 = len + n1;
@@ -3165,9 +3165,9 @@ eval_index(
}
else
{
- /* The resulting variable is a string of a single
- * character. If the index is too big or negative the
- * result is empty. */
+ // The resulting variable is a string of a single
+ // character. If the index is too big or negative the
+ // result is empty.
if (n1 >= len || n1 < 0)
s = NULL;
else
@@ -3246,8 +3246,8 @@ eval_index(
n1 = len + n1;
if (!empty1 && (n1 < 0 || n1 >= len))
{
- /* For a range we allow invalid values and return an empty
- * list. A list index out of range is an error. */
+ // For a range we allow invalid values and return an empty
+ // list. A list index out of range is an error.
if (!range)
{
if (verbose)
@@ -3342,7 +3342,7 @@ eval_index(
int
get_option_tv(
char_u **arg,
- typval_T *rettv, /* when NULL, only check if option exists */
+ typval_T *rettv, // when NULL, only check if option exists
int evaluate)
{
char_u *option_end;
@@ -3350,7 +3350,7 @@ get_option_tv(
char_u *stringval;
int opt_type;
int c;
- int working = (**arg == '+'); /* has("+option") */
+ int working = (**arg == '+'); // has("+option")
int ret = OK;
int opt_flags;
@@ -3376,7 +3376,7 @@ get_option_tv(
opt_type = get_option_value(*arg, &numval,
rettv == NULL ? NULL : &stringval, opt_flags);
- if (opt_type == -3) /* invalid name */
+ if (opt_type == -3) // invalid name
{
if (rettv != NULL)
semsg(_("E113: Unknown option: %s"), *arg);
@@ -3384,22 +3384,22 @@ get_option_tv(
}
else if (rettv != NULL)
{
- if (opt_type == -2) /* hidden string option */
+ if (opt_type == -2) // hidden string option
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
}
- else if (opt_type == -1) /* hidden number option */
+ else if (opt_type == -1) // hidden number option
{
rettv->v_type = VAR_NUMBER;
rettv->vval.v_number = 0;
}
- else if (opt_type == 1) /* number option */
+ else if (opt_type == 1) // number option
{
rettv->v_type = VAR_NUMBER;
rettv->vval.v_number = numval;
}
- else /* string option */
+ else // string option
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = stringval;
@@ -3408,7 +3408,7 @@ get_option_tv(
else if (working && (opt_type == -2 || opt_type == -1))
ret = FAIL;
- *option_end = c; /* put back for error messages */
+ *option_end = c; // put back for error messages
*arg = option_end;
return ret;
@@ -3433,8 +3433,8 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
if (*p == '\\' && p[1] != NUL)
{
++p;
- /* A "\<x>" form occupies at least 4 characters, and produces up
- * to 6 characters: reserve space for 2 extra */
+ // A "\<x>" form occupies at least 4 characters, and produces up
+ // to 6 characters: reserve space for 2 extra
if (*p == '<')
extra += 2;
}
@@ -3446,7 +3446,7 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
return FAIL;
}
- /* If only parsing, set *arg and return here */
+ // If only parsing, set *arg and return here
if (!evaluate)
{
*arg = p + 1;
@@ -3476,9 +3476,9 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
case 'r': *name++ = CAR; ++p; break;
case 't': *name++ = TAB; ++p; break;
- case 'X': /* hex: "\x1", "\x12" */
+ case 'X': // hex: "\x1", "\x12"
case 'x':
- case 'u': /* Unicode: "\u0023" */
+ case 'u': // Unicode: "\u0023"
case 'U':
if (vim_isxdigit(p[1]))
{
@@ -3498,8 +3498,8 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
nr = (nr << 4) + hex2nr(*p);
}
++p;
- /* For "\u" store the number according to
- * 'encoding'. */
+ // For "\u" store the number according to
+ // 'encoding'.
if (c != 'X')
name += (*mb_char2bytes)(nr, name);
else
@@ -3507,7 +3507,7 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
}
break;
- /* octal: "\1", "\12", "\123" */
+ // octal: "\1", "\12", "\123"
case '0':
case '1':
case '2':
@@ -3525,7 +3525,7 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
++name;
break;
- /* Special key, e.g.: "\<C-W>" */
+ // Special key, e.g.: "\<C-W>"
case '<': extra = trans_special(&p, name, TRUE, TRUE,
TRUE, NULL);
if (extra != 0)
@@ -3533,7 +3533,7 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
name += extra;
break;
}
- /* FALLTHROUGH */
+ // FALLTHROUGH
default: MB_COPY_CHAR(p, name);
break;
@@ -3544,7 +3544,7 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
}
*name = NUL;
- if (*p != NUL) /* just in case */
+ if (*p != NUL) // just in case
++p;
*arg = p;
@@ -3582,7 +3582,7 @@ get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate)
return FAIL;
}
- /* If only parsing return after setting "*arg" */
+ // If only parsing return after setting "*arg"
if (!evaluate)
{
*arg = p + 1;
@@ -3661,14 +3661,14 @@ static int tv_equal_recurse_limit;
func_equal(
typval_T *tv1,
typval_T *tv2,
- int ic) /* ignore case */
+ int ic) // ignore case
{
char_u *s1, *s2;
dict_T *d1, *d2;
int a1, a2;
int i;
- /* empty and NULL function name considered the same */
+ // empty and NULL function name considered the same
s1 = tv1->v_type == VAR_FUNC ? tv1->vval.v_string
: partial_name(tv1->vval.v_partial);
if (s1 != NULL && *s1 == NUL)
@@ -3685,7 +3685,7 @@ func_equal(
else if (STRCMP(s1, s2) != 0)
return FALSE;
- /* empty dict and NULL dict is different */
+ // empty dict and NULL dict is different
d1 = tv1->v_type == VAR_FUNC ? NULL : tv1->vval.v_partial->pt_dict;
d2 = tv2->v_type == VAR_FUNC ? NULL : tv2->vval.v_partial->pt_dict;
if (d1 == NULL || d2 == NULL)
@@ -3696,7 +3696,7 @@ func_equal(
else if (!dict_equal(d1, d2, ic, TRUE))
return FALSE;
- /* empty list and no list considered the same */
+ // empty list and no list considered the same
a1 = tv1->v_type == VAR_FUNC ? 0 : tv1->vval.v_partial->pt_argc;
a2 = tv2->v_type == VAR_FUNC ? 0 : tv2->vval.v_partial->pt_argc;
if (a1 != a2)
@@ -3718,20 +3718,20 @@ func_equal(
tv_equal(
typval_T *tv1,
typval_T *tv2,
- int ic, /* ignore case */
- int recursive) /* TRUE when used recursively */
+ int ic, // ignore case
+ int recursive) // TRUE when used recursively
{
char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN];
char_u *s1, *s2;
- static int recursive_cnt = 0; /* catch recursive loops */
+ static int recursive_cnt = 0; // catch recursive loops
int r;
- /* Catch lists and dicts that have an endless loop by limiting
- * recursiveness to a limit. We guess they are equal then.
- * A fixed limit has the problem of still taking an awful long time.
- * Reduce the limit every time running into it. That should work fine for
- * deeply linked structures that are not recursively linked and catch
- * recursiveness quickly. */
+ // Catch lists and dicts that have an endless loop by limiting
+ // recursiveness to a limit. We guess they are equal then.
+ // A fixed limit has the problem of still taking an awful long time.
+ // Reduce the limit every time running into it. That should work fine for
+ // deeply linked structures that are not recursively linked and catch
+ // recursiveness quickly.
if (!recursive)
tv_equal_recurse_limit = 1000;
if (recursive_cnt >= tv_equal_recurse_limit)
@@ -3740,8 +3740,8 @@ tv_equal(
return TRUE;
}
- /* For VAR_FUNC and VAR_PARTIAL compare the function name, bound dict and
- * arguments. */
+ // For VAR_FUNC and VAR_PARTIAL compare the function name, bound dict and
+ // arguments.
if ((tv1->v_type == VAR_FUNC
|| (tv1->v_type == VAR_PARTIAL && tv1->vval.v_partial != NULL))
&& (tv2->v_type == VAR_FUNC
@@ -3802,8 +3802,8 @@ tv_equal(
break;
}
- /* VAR_UNKNOWN can be the result of a invalid expression, let's say it
- * does not equal anything, not even itself. */
+ // VAR_UNKNOWN can be the result of a invalid expression, let's say it
+ // does not equal anything, not even itself.
return FALSE;
}
@@ -3855,14 +3855,14 @@ garbage_collect(int testing)
if (!testing)
{
- /* Only do this once. */
+ // Only do this once.
want_garbage_collect = FALSE;
may_garbage_collect = FALSE;
garbage_collect_at_exit = FALSE;
}
- /* We advance by two because we add one for items referenced through
- * previous_funccal. */
+ // We advance by two because we add one for items referenced through
+ // previous_funccal.
copyID = get_copyID();
/*
@@ -3870,20 +3870,20 @@ garbage_collect(int testing)
* with copyID.
*/
- /* Don't free variables in the previous_funccal list unless they are only
- * referenced through previous_funccal. This must be first, because if
- * the item is referenced elsewhere the funccal must not be freed. */
+ // Don't free variables in the previous_funccal list unless they are only
+ // referenced through previous_funccal. This must be first, because if
+ // the item is referenced elsewhere the funccal must not be freed.
abort = abort || set_ref_in_previous_funccal(copyID);
- /* script-local variables */
+ // script-local variables
abort = abort || garbage_collect_scriptvars(copyID);
- /* buffer-local variables */
+ // buffer-local variables
FOR_ALL_BUFFERS(buf)
abort = abort || set_ref_in_item(&buf->b_bufvar.di_tv, copyID,
NULL, NULL);
- /* window-local variables */
+ // window-local variables
FOR_ALL_TAB_WINDOWS(tp, wp)
abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID,
NULL, NULL);
@@ -3900,23 +3900,23 @@ garbage_collect(int testing)
NULL, NULL);
<