Skip to content

Commit 95f0960

Browse files
committed
patch 8.0.0074
Problem: Cannot make Vim fail on an internal error. Solution: Add IEMSG() and IEMSG2(). (Domenique Pelle) Avoid reporting an internal error without mentioning where.
1 parent 459ca56 commit 95f0960

30 files changed

Lines changed: 159 additions & 91 deletions

src/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,10 @@ SANITIZER_LIBS = $(SANITIZER_CFLAGS)
681681
#LEAK_CFLAGS = -DEXITFREE
682682
#LEAK_LIBS = -lccmalloc
683683

684+
# Uncomment this line to have Vim call abort() when an internal error is
685+
# detected. Useful when using a tool to find errors.
686+
#ABORT_CLFAGS = -DABORT_ON_INTERNAL_ERROR
687+
684688
#####################################################
685689
### Specific systems, check if yours is listed! ### {{{
686690
#####################################################
@@ -1409,7 +1413,7 @@ SHELL = /bin/sh
14091413
PRE_DEFS = -Iproto $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS)
14101414
POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(EXTRA_DEFS)
14111415

1412-
ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(SANITIZER_CFLAGS) $(LEAK_CFLAGS) $(POST_DEFS)
1416+
ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(SANITIZER_CFLAGS) $(LEAK_CFLAGS) $(ABORT_CLFAGS) $(POST_DEFS)
14131417

14141418
# Exclude $CFLAGS for osdef.sh, for Mac 10.4 some flags don't work together
14151419
# with "-E".

src/blowfish.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ bf_key_init(
426426
keylen = (int)STRLEN(key) / 2;
427427
if (keylen == 0)
428428
{
429-
EMSG(_("E831: bf_key_init() called with empty password"));
429+
IEMSG(_("E831: bf_key_init() called with empty password"));
430430
return;
431431
}
432432
for (i = 0; i < keylen; i++)

src/dict.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ dictitem_remove(dict_T *dict, dictitem_T *item)
214214

215215
hi = hash_find(&dict->dv_hashtab, item->di_key);
216216
if (HASHITEM_EMPTY(hi))
217-
EMSG2(_(e_intern2), "dictitem_remove()");
217+
internal_error("dictitem_remove()");
218218
else
219219
hash_remove(&dict->dv_hashtab, hi);
220220
dictitem_free(item);

src/edit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,7 @@ vim_is_ctrl_x_key(int c)
22992299
case CTRL_X_EVAL:
23002300
return (c == Ctrl_P || c == Ctrl_N);
23012301
}
2302-
EMSG(_(e_internal));
2302+
internal_error("vim_is_ctrl_x_key()");
23032303
return FALSE;
23042304
}
23052305

@@ -5431,7 +5431,7 @@ ins_complete(int c, int enable_pum)
54315431
}
54325432
else
54335433
{
5434-
EMSG2(_(e_intern2), "ins_complete()");
5434+
internal_error("ins_complete()");
54355435
return FAIL;
54365436
}
54375437

src/eval.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ restore_vimvar(int idx, typval_T *save_tv)
839839
{
840840
hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key);
841841
if (HASHITEM_EMPTY(hi))
842-
EMSG2(_(e_intern2), "restore_vimvar()");
842+
internal_error("restore_vimvar()");
843843
else
844844
hash_remove(&vimvarht, hi);
845845
}
@@ -1308,7 +1308,7 @@ ex_let_vars(
13081308
}
13091309
else if (*arg != ',' && *arg != ']')
13101310
{
1311-
EMSG2(_(e_intern2), "ex_let_vars()");
1311+
internal_error("ex_let_vars()");
13121312
return FAIL;
13131313
}
13141314
}
@@ -2830,7 +2830,7 @@ do_unlet(char_u *name, int forceit)
28302830
}
28312831
if (d == NULL)
28322832
{
2833-
EMSG2(_(e_intern2), "do_unlet()");
2833+
internal_error("do_unlet()");
28342834
return FAIL;
28352835
}
28362836
}
@@ -5678,7 +5678,7 @@ get_var_special_name(int nr)
56785678
case VVAL_NONE: return "v:none";
56795679
case VVAL_NULL: return "v:null";
56805680
}
5681-
EMSG2(_(e_intern2), "get_var_special_name()");
5681+
internal_error("get_var_special_name()");
56825682
return "42";
56835683
}
56845684

@@ -7152,7 +7152,7 @@ get_tv_number_chk(typval_T *varp, int *denote)
71527152
break;
71537153
#endif
71547154
case VAR_UNKNOWN:
7155-
EMSG2(_(e_intern2), "get_tv_number(UNKNOWN)");
7155+
internal_error("get_tv_number(UNKNOWN)");
71567156
break;
71577157
}
71587158
if (denote == NULL) /* useful for values that must be unsigned */
@@ -7199,7 +7199,7 @@ get_tv_float(typval_T *varp)
71997199
break;
72007200
# endif
72017201
case VAR_UNKNOWN:
7202-
EMSG2(_(e_intern2), "get_tv_float(UNKNOWN)");
7202+
internal_error("get_tv_float(UNKNOWN)");
72037203
break;
72047204
}
72057205
return 0;
@@ -7733,7 +7733,7 @@ set_var(
77337733
return;
77347734
}
77357735
else if (v->di_tv.v_type != tv->v_type)
7736-
EMSG2(_(e_intern2), "set_var()");
7736+
internal_error("set_var()");
77377737
}
77387738

77397739
clear_tv(&v->di_tv);
@@ -7962,7 +7962,7 @@ copy_tv(typval_T *from, typval_T *to)
79627962
}
79637963
break;
79647964
case VAR_UNKNOWN:
7965-
EMSG2(_(e_intern2), "copy_tv(UNKNOWN)");
7965+
internal_error("copy_tv(UNKNOWN)");
79667966
break;
79677967
}
79687968
}
@@ -8036,7 +8036,7 @@ item_copy(
80368036
ret = FAIL;
80378037
break;
80388038
case VAR_UNKNOWN:
8039-
EMSG2(_(e_intern2), "item_copy(UNKNOWN)");
8039+
internal_error("item_copy(UNKNOWN)");
80408040
ret = FAIL;
80418041
}
80428042
--recurse;

src/evalfunc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,7 +2644,7 @@ f_empty(typval_T *argvars, typval_T *rettv)
26442644
break;
26452645
#endif
26462646
case VAR_UNKNOWN:
2647-
EMSG2(_(e_intern2), "f_empty(UNKNOWN)");
2647+
internal_error("f_empty(UNKNOWN)");
26482648
n = TRUE;
26492649
break;
26502650
}
@@ -12695,7 +12695,7 @@ f_type(typval_T *argvars, typval_T *rettv)
1269512695
case VAR_JOB: n = VAR_TYPE_JOB; break;
1269612696
case VAR_CHANNEL: n = VAR_TYPE_CHANNEL; break;
1269712697
case VAR_UNKNOWN:
12698-
EMSG2(_(e_intern2), "f_type(UNKNOWN)");
12698+
internal_error("f_type(UNKNOWN)");
1269912699
n = -1;
1270012700
break;
1270112701
}

src/ex_eval.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ discard_exception(except_T *excp, int was_finished)
595595

596596
if (excp == NULL)
597597
{
598-
EMSG(_(e_internal));
598+
internal_error("discard_exception()");
599599
return;
600600
}
601601

@@ -700,7 +700,7 @@ catch_exception(except_T *excp)
700700
finish_exception(except_T *excp)
701701
{
702702
if (excp != caught_stack)
703-
EMSG(_(e_internal));
703+
internal_error("finish_exception()");
704704
caught_stack = caught_stack->caught;
705705
if (caught_stack != NULL)
706706
{
@@ -1603,7 +1603,7 @@ ex_catch(exarg_T *eap)
16031603
* ":break", ":return", ":finish", error, interrupt, or another
16041604
* exception. */
16051605
if (cstack->cs_exception[cstack->cs_idx] != current_exception)
1606-
EMSG(_(e_internal));
1606+
internal_error("ex_catch()");
16071607
}
16081608
else
16091609
{
@@ -1737,7 +1737,7 @@ ex_finally(exarg_T *eap)
17371737
* exception will be discarded. */
17381738
if (did_throw && cstack->cs_exception[cstack->cs_idx]
17391739
!= current_exception)
1740-
EMSG(_(e_internal));
1740+
internal_error("ex_finally()");
17411741
}
17421742

17431743
/*

src/getchar.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ add_buff(
250250
}
251251
else if (buf->bh_curr == NULL) /* buffer has already been read */
252252
{
253-
EMSG(_("E222: Add to read buffer"));
253+
IEMSG(_("E222: Add to read buffer"));
254254
return;
255255
}
256256
else if (buf->bh_index != 0)
@@ -1321,11 +1321,11 @@ alloc_typebuf(void)
13211321
free_typebuf(void)
13221322
{
13231323
if (typebuf.tb_buf == typebuf_init)
1324-
EMSG2(_(e_intern2), "Free typebuf 1");
1324+
internal_error("Free typebuf 1");
13251325
else
13261326
vim_free(typebuf.tb_buf);
13271327
if (typebuf.tb_noremap == noremapbuf_init)
1328-
EMSG2(_(e_intern2), "Free typebuf 2");
1328+
internal_error("Free typebuf 2");
13291329
else
13301330
vim_free(typebuf.tb_noremap);
13311331
}
@@ -4868,7 +4868,7 @@ makemap(
48684868
c1 = 'l';
48694869
break;
48704870
default:
4871-
EMSG(_("E228: makemap: Illegal mode"));
4871+
IEMSG(_("E228: makemap: Illegal mode"));
48724872
return FAIL;
48734873
}
48744874
do /* do this twice if c2 is set, 3 times with c3 */

src/globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@ EXTERN char_u e_font[] INIT(= N_("E235: Unknown font: %s"));
14401440
EXTERN char_u e_fontwidth[] INIT(= N_("E236: Font \"%s\" is not fixed-width"));
14411441
#endif
14421442
EXTERN char_u e_internal[] INIT(= N_("E473: Internal error"));
1443+
EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s"));
14431444
EXTERN char_u e_interr[] INIT(= N_("Interrupted"));
14441445
EXTERN char_u e_invaddr[] INIT(= N_("E14: Invalid address"));
14451446
EXTERN char_u e_invarg[] INIT(= N_("E474: Invalid argument"));
@@ -1589,7 +1590,6 @@ EXTERN char_u e_invexprmsg[] INIT(= N_("E449: Invalid expression received"));
15891590
EXTERN char_u e_guarded[] INIT(= N_("E463: Region is guarded, cannot modify"));
15901591
EXTERN char_u e_nbreadonly[] INIT(= N_("E744: NetBeans does not allow changes in read-only files"));
15911592
#endif
1592-
EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s"));
15931593
EXTERN char_u e_maxmempat[] INIT(= N_("E363: pattern uses more memory than 'maxmempattern'"));
15941594
EXTERN char_u e_emptybuf[] INIT(= N_("E749: empty buffer"));
15951595
EXTERN char_u e_nobufnr[] INIT(= N_("E86: Buffer %ld does not exist"));

src/gui_beval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ gui_mch_create_beval_area(
218218

219219
if (mesg != NULL && mesgCB != NULL)
220220
{
221-
EMSG(_("E232: Cannot create BalloonEval with both message and callback"));
221+
IEMSG(_("E232: Cannot create BalloonEval with both message and callback"));
222222
return NULL;
223223
}
224224

0 commit comments

Comments
 (0)