0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.0.1511: some code for the debugger watch expression is clumsy

Problem:    Some code for the debugger watch expression is clumsy.
Solution:   Clean up the code.
This commit is contained in:
Bram Moolenaar
2018-02-13 12:57:42 +01:00
parent b48e96f61c
commit 3198870137
4 changed files with 199 additions and 214 deletions

View File

@@ -3596,7 +3596,13 @@ eval4(char_u **arg, typval_T *rettv, int evaluate)
clear_tv(rettv);
return FAIL;
}
return typval_compare(rettv, &var2, type, type_is, ic, evaluate);
if (evaluate)
{
int ret = typval_compare(rettv, &var2, type, type_is, ic);
clear_tv(&var2);
return ret;
}
}
return OK;
@@ -9091,23 +9097,22 @@ fill_assert_error(
}
}
/*
* Compare "typ1" and "typ2". Put the result in "typ1".
*/
int
typval_compare(
typval_T *typ1, /* first operand */
typval_T *typ2, /* second operand */
exptype_T type, /* operator */
int type_is, /* TRUE for "is" and "isnot" */
int ic, /* ignore case */
int evaluate)
int ic) /* ignore case */
{
int i;
varnumber_T n1, n2;
char_u *s1, *s2;
char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN];
if (evaluate)
{
if (type_is && typ1->v_type != typ2->v_type)
{
/* For "is" a different type always means FALSE, for "notis"
@@ -9131,7 +9136,6 @@ typval_compare(
else
EMSG(_("E692: Invalid operation for List"));
clear_tv(typ1);
clear_tv(typ2);
return FAIL;
}
else
@@ -9161,7 +9165,6 @@ typval_compare(
else
EMSG(_("E736: Invalid operation for Dictionary"));
clear_tv(typ1);
clear_tv(typ2);
return FAIL;
}
else
@@ -9181,7 +9184,6 @@ typval_compare(
{
EMSG(_("E694: Invalid operation for Funcrefs"));
clear_tv(typ1);
clear_tv(typ2);
return FAIL;
}
if ((typ1->v_type == VAR_PARTIAL
@@ -9293,27 +9295,12 @@ typval_compare(
}
}
clear_tv(typ1);
clear_tv(typ2);
typ1->v_type = VAR_NUMBER;
typ1->vval.v_number = n1;
}
return OK;
}
int
typval_copy(typ1, typ2)
typval_T *typ1;
typval_T *typ2;
{
if (typ2 == NULL)
rettv_list_alloc(typ2);
if (typ1 != NULL && typ2 != NULL)
return item_copy(typ1, typ2, TRUE, 0);
return FAIL;
}
char_u *
typval_tostring(arg)
typval_T *arg;

View File

@@ -988,24 +988,21 @@ debuggy_find(
}
else
{
typval_T val3;
if (typval_copy(bp->dbg_val, &val3) == OK)
{
if (typval_compare(tv, &val3, TYPE_EQUAL,
TRUE, FALSE, TRUE) == OK
if (typval_compare(tv, bp->dbg_val, TYPE_EQUAL,
TRUE, FALSE) == OK
&& tv->vval.v_number == FALSE)
{
typval_T *v;
line = TRUE;
debug_oldval = typval_tostring(bp->dbg_val);
/* Need to evaluate again, typval_compare() overwrites
* "tv". */
v = eval_expr(bp->dbg_name, NULL);
debug_newval = typval_tostring(v);
free_tv(bp->dbg_val);
bp->dbg_val = v;
}
}
free_tv(tv);
}
}

View File

@@ -130,8 +130,7 @@ void assert_exception(typval_T *argvars);
void assert_beeps(typval_T *argvars);
void assert_fails(typval_T *argvars);
void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_str, typval_T *exp_tv, typval_T *got_tv, assert_type_T atype);
int typval_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int type_is, int ic, int evaluate);
int typval_copy(typval_T *typ1, typval_T *typ2);
int typval_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int type_is, int ic);
char_u *typval_tostring(typval_T *arg);
int var_exists(char_u *var);
int modify_fname(char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen);

View File

@@ -771,6 +771,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1511,
/**/
1510,
/**/