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:
37
src/eval.c
37
src/eval.c
@@ -3596,7 +3596,13 @@ eval4(char_u **arg, typval_T *rettv, int evaluate)
|
|||||||
clear_tv(rettv);
|
clear_tv(rettv);
|
||||||
return FAIL;
|
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;
|
return OK;
|
||||||
@@ -9091,23 +9097,22 @@ fill_assert_error(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compare "typ1" and "typ2". Put the result in "typ1".
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
typval_compare(
|
typval_compare(
|
||||||
typval_T *typ1, /* first operand */
|
typval_T *typ1, /* first operand */
|
||||||
typval_T *typ2, /* second operand */
|
typval_T *typ2, /* second operand */
|
||||||
exptype_T type, /* operator */
|
exptype_T type, /* operator */
|
||||||
int type_is, /* TRUE for "is" and "isnot" */
|
int type_is, /* TRUE for "is" and "isnot" */
|
||||||
int ic, /* ignore case */
|
int ic) /* ignore case */
|
||||||
int evaluate)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
varnumber_T n1, n2;
|
varnumber_T n1, n2;
|
||||||
char_u *s1, *s2;
|
char_u *s1, *s2;
|
||||||
char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN];
|
char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN];
|
||||||
|
|
||||||
if (evaluate)
|
|
||||||
{
|
|
||||||
if (type_is && typ1->v_type != typ2->v_type)
|
if (type_is && typ1->v_type != typ2->v_type)
|
||||||
{
|
{
|
||||||
/* For "is" a different type always means FALSE, for "notis"
|
/* For "is" a different type always means FALSE, for "notis"
|
||||||
@@ -9131,7 +9136,6 @@ typval_compare(
|
|||||||
else
|
else
|
||||||
EMSG(_("E692: Invalid operation for List"));
|
EMSG(_("E692: Invalid operation for List"));
|
||||||
clear_tv(typ1);
|
clear_tv(typ1);
|
||||||
clear_tv(typ2);
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -9161,7 +9165,6 @@ typval_compare(
|
|||||||
else
|
else
|
||||||
EMSG(_("E736: Invalid operation for Dictionary"));
|
EMSG(_("E736: Invalid operation for Dictionary"));
|
||||||
clear_tv(typ1);
|
clear_tv(typ1);
|
||||||
clear_tv(typ2);
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -9181,7 +9184,6 @@ typval_compare(
|
|||||||
{
|
{
|
||||||
EMSG(_("E694: Invalid operation for Funcrefs"));
|
EMSG(_("E694: Invalid operation for Funcrefs"));
|
||||||
clear_tv(typ1);
|
clear_tv(typ1);
|
||||||
clear_tv(typ2);
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
if ((typ1->v_type == VAR_PARTIAL
|
if ((typ1->v_type == VAR_PARTIAL
|
||||||
@@ -9293,27 +9295,12 @@ typval_compare(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
clear_tv(typ1);
|
clear_tv(typ1);
|
||||||
clear_tv(typ2);
|
|
||||||
typ1->v_type = VAR_NUMBER;
|
typ1->v_type = VAR_NUMBER;
|
||||||
typ1->vval.v_number = n1;
|
typ1->vval.v_number = n1;
|
||||||
}
|
|
||||||
return OK;
|
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 *
|
char_u *
|
||||||
typval_tostring(arg)
|
typval_tostring(arg)
|
||||||
typval_T *arg;
|
typval_T *arg;
|
||||||
|
@@ -988,24 +988,21 @@ debuggy_find(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
typval_T val3;
|
if (typval_compare(tv, bp->dbg_val, TYPE_EQUAL,
|
||||||
|
TRUE, FALSE) == OK
|
||||||
if (typval_copy(bp->dbg_val, &val3) == OK)
|
|
||||||
{
|
|
||||||
if (typval_compare(tv, &val3, TYPE_EQUAL,
|
|
||||||
TRUE, FALSE, TRUE) == OK
|
|
||||||
&& tv->vval.v_number == FALSE)
|
&& tv->vval.v_number == FALSE)
|
||||||
{
|
{
|
||||||
typval_T *v;
|
typval_T *v;
|
||||||
|
|
||||||
line = TRUE;
|
line = TRUE;
|
||||||
debug_oldval = typval_tostring(bp->dbg_val);
|
debug_oldval = typval_tostring(bp->dbg_val);
|
||||||
|
/* Need to evaluate again, typval_compare() overwrites
|
||||||
|
* "tv". */
|
||||||
v = eval_expr(bp->dbg_name, NULL);
|
v = eval_expr(bp->dbg_name, NULL);
|
||||||
debug_newval = typval_tostring(v);
|
debug_newval = typval_tostring(v);
|
||||||
free_tv(bp->dbg_val);
|
free_tv(bp->dbg_val);
|
||||||
bp->dbg_val = v;
|
bp->dbg_val = v;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
free_tv(tv);
|
free_tv(tv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -130,8 +130,7 @@ void assert_exception(typval_T *argvars);
|
|||||||
void assert_beeps(typval_T *argvars);
|
void assert_beeps(typval_T *argvars);
|
||||||
void assert_fails(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);
|
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_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int type_is, int ic);
|
||||||
int typval_copy(typval_T *typ1, typval_T *typ2);
|
|
||||||
char_u *typval_tostring(typval_T *arg);
|
char_u *typval_tostring(typval_T *arg);
|
||||||
int var_exists(char_u *var);
|
int var_exists(char_u *var);
|
||||||
int modify_fname(char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen);
|
int modify_fname(char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen);
|
||||||
|
@@ -771,6 +771,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1511,
|
||||||
/**/
|
/**/
|
||||||
1510,
|
1510,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user