Permalink
Browse files

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.
  • Loading branch information...
1 parent 459ca56 commit 95f096030ed1a8afea028f2ea295d6f6a70f466f @brammool brammool committed Nov 10, 2016
Showing with 159 additions and 91 deletions.
  1. +5 −1 src/Makefile
  2. +1 −1 src/blowfish.c
  3. +1 −1 src/dict.c
  4. +2 −2 src/edit.c
  5. +9 −9 src/eval.c
  6. +2 −2 src/evalfunc.c
  7. +4 −4 src/ex_eval.c
  8. +4 −4 src/getchar.c
  9. +1 −1 src/globals.h
  10. +1 −1 src/gui_beval.c
  11. +1 −1 src/gui_w32.c
  12. +1 −1 src/hangulin.c
  13. +1 −1 src/hashtab.c
  14. +1 −1 src/if_cscope.c
  15. +1 −1 src/json.c
  16. +1 −1 src/memfile.c
  17. +14 −14 src/memline.c
  18. +79 −0 src/message.c
  19. +2 −28 src/misc2.c
  20. +4 −4 src/option.c
  21. +6 −0 src/proto/message.pro
  22. +0 −2 src/proto/misc2.pro
  23. +1 −1 src/quickfix.c
  24. +4 −2 src/regexp.c
  25. +1 −1 src/spell.c
  26. +4 −4 src/undo.c
  27. +2 −2 src/userfunc.c
  28. +2 −0 src/version.c
  29. +3 −0 src/vim.h
  30. +1 −1 src/window.c
View
@@ -681,6 +681,10 @@ SANITIZER_LIBS = $(SANITIZER_CFLAGS)
#LEAK_CFLAGS = -DEXITFREE
#LEAK_LIBS = -lccmalloc
+# Uncomment this line to have Vim call abort() when an internal error is
+# detected. Useful when using a tool to find errors.
+#ABORT_CLFAGS = -DABORT_ON_INTERNAL_ERROR
+
#####################################################
### Specific systems, check if yours is listed! ### {{{
#####################################################
@@ -1409,7 +1413,7 @@ SHELL = /bin/sh
PRE_DEFS = -Iproto $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS)
POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(EXTRA_DEFS)
-ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(SANITIZER_CFLAGS) $(LEAK_CFLAGS) $(POST_DEFS)
+ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(SANITIZER_CFLAGS) $(LEAK_CFLAGS) $(ABORT_CLFAGS) $(POST_DEFS)
# Exclude $CFLAGS for osdef.sh, for Mac 10.4 some flags don't work together
# with "-E".
View
@@ -426,7 +426,7 @@ bf_key_init(
keylen = (int)STRLEN(key) / 2;
if (keylen == 0)
{
- EMSG(_("E831: bf_key_init() called with empty password"));
+ IEMSG(_("E831: bf_key_init() called with empty password"));
return;
}
for (i = 0; i < keylen; i++)
View
@@ -214,7 +214,7 @@ dictitem_remove(dict_T *dict, dictitem_T *item)
hi = hash_find(&dict->dv_hashtab, item->di_key);
if (HASHITEM_EMPTY(hi))
- EMSG2(_(e_intern2), "dictitem_remove()");
+ internal_error("dictitem_remove()");
else
hash_remove(&dict->dv_hashtab, hi);
dictitem_free(item);
View
@@ -2299,7 +2299,7 @@ vim_is_ctrl_x_key(int c)
case CTRL_X_EVAL:
return (c == Ctrl_P || c == Ctrl_N);
}
- EMSG(_(e_internal));
+ internal_error("vim_is_ctrl_x_key()");
return FALSE;
}
@@ -5431,7 +5431,7 @@ ins_complete(int c, int enable_pum)
}
else
{
- EMSG2(_(e_intern2), "ins_complete()");
+ internal_error("ins_complete()");
return FAIL;
}
View
@@ -839,7 +839,7 @@ restore_vimvar(int idx, typval_T *save_tv)
{
hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key);
if (HASHITEM_EMPTY(hi))
- EMSG2(_(e_intern2), "restore_vimvar()");
+ internal_error("restore_vimvar()");
else
hash_remove(&vimvarht, hi);
}
@@ -1308,7 +1308,7 @@ ex_let_vars(
}
else if (*arg != ',' && *arg != ']')
{
- EMSG2(_(e_intern2), "ex_let_vars()");
+ internal_error("ex_let_vars()");
return FAIL;
}
}
@@ -2830,7 +2830,7 @@ do_unlet(char_u *name, int forceit)
}
if (d == NULL)
{
- EMSG2(_(e_intern2), "do_unlet()");
+ internal_error("do_unlet()");
return FAIL;
}
}
@@ -5678,7 +5678,7 @@ get_var_special_name(int nr)
case VVAL_NONE: return "v:none";
case VVAL_NULL: return "v:null";
}
- EMSG2(_(e_intern2), "get_var_special_name()");
+ internal_error("get_var_special_name()");
return "42";
}
@@ -7152,7 +7152,7 @@ get_tv_number_chk(typval_T *varp, int *denote)
break;
#endif
case VAR_UNKNOWN:
- EMSG2(_(e_intern2), "get_tv_number(UNKNOWN)");
+ internal_error("get_tv_number(UNKNOWN)");
break;
}
if (denote == NULL) /* useful for values that must be unsigned */
@@ -7199,7 +7199,7 @@ get_tv_float(typval_T *varp)
break;
# endif
case VAR_UNKNOWN:
- EMSG2(_(e_intern2), "get_tv_float(UNKNOWN)");
+ internal_error("get_tv_float(UNKNOWN)");
break;
}
return 0;
@@ -7733,7 +7733,7 @@ set_var(
return;
}
else if (v->di_tv.v_type != tv->v_type)
- EMSG2(_(e_intern2), "set_var()");
+ internal_error("set_var()");
}
clear_tv(&v->di_tv);
@@ -7962,7 +7962,7 @@ copy_tv(typval_T *from, typval_T *to)
}
break;
case VAR_UNKNOWN:
- EMSG2(_(e_intern2), "copy_tv(UNKNOWN)");
+ internal_error("copy_tv(UNKNOWN)");
break;
}
}
@@ -8036,7 +8036,7 @@ item_copy(
ret = FAIL;
break;
case VAR_UNKNOWN:
- EMSG2(_(e_intern2), "item_copy(UNKNOWN)");
+ internal_error("item_copy(UNKNOWN)");
ret = FAIL;
}
--recurse;
View
@@ -2644,7 +2644,7 @@ f_empty(typval_T *argvars, typval_T *rettv)
break;
#endif
case VAR_UNKNOWN:
- EMSG2(_(e_intern2), "f_empty(UNKNOWN)");
+ internal_error("f_empty(UNKNOWN)");
n = TRUE;
break;
}
@@ -12695,7 +12695,7 @@ f_type(typval_T *argvars, typval_T *rettv)
case VAR_JOB: n = VAR_TYPE_JOB; break;
case VAR_CHANNEL: n = VAR_TYPE_CHANNEL; break;
case VAR_UNKNOWN:
- EMSG2(_(e_intern2), "f_type(UNKNOWN)");
+ internal_error("f_type(UNKNOWN)");
n = -1;
break;
}
View
@@ -595,7 +595,7 @@ discard_exception(except_T *excp, int was_finished)
if (excp == NULL)
{
- EMSG(_(e_internal));
+ internal_error("discard_exception()");
return;
}
@@ -700,7 +700,7 @@ catch_exception(except_T *excp)
finish_exception(except_T *excp)
{
if (excp != caught_stack)
- EMSG(_(e_internal));
+ internal_error("finish_exception()");
caught_stack = caught_stack->caught;
if (caught_stack != NULL)
{
@@ -1603,7 +1603,7 @@ ex_catch(exarg_T *eap)
* ":break", ":return", ":finish", error, interrupt, or another
* exception. */
if (cstack->cs_exception[cstack->cs_idx] != current_exception)
- EMSG(_(e_internal));
+ internal_error("ex_catch()");
}
else
{
@@ -1737,7 +1737,7 @@ ex_finally(exarg_T *eap)
* exception will be discarded. */
if (did_throw && cstack->cs_exception[cstack->cs_idx]
!= current_exception)
- EMSG(_(e_internal));
+ internal_error("ex_finally()");
}
/*
View
@@ -250,7 +250,7 @@ add_buff(
}
else if (buf->bh_curr == NULL) /* buffer has already been read */
{
- EMSG(_("E222: Add to read buffer"));
+ IEMSG(_("E222: Add to read buffer"));
return;
}
else if (buf->bh_index != 0)
@@ -1321,11 +1321,11 @@ alloc_typebuf(void)
free_typebuf(void)
{
if (typebuf.tb_buf == typebuf_init)
- EMSG2(_(e_intern2), "Free typebuf 1");
+ internal_error("Free typebuf 1");
else
vim_free(typebuf.tb_buf);
if (typebuf.tb_noremap == noremapbuf_init)
- EMSG2(_(e_intern2), "Free typebuf 2");
+ internal_error("Free typebuf 2");
else
vim_free(typebuf.tb_noremap);
}
@@ -4868,7 +4868,7 @@ makemap(
c1 = 'l';
break;
default:
- EMSG(_("E228: makemap: Illegal mode"));
+ IEMSG(_("E228: makemap: Illegal mode"));
return FAIL;
}
do /* do this twice if c2 is set, 3 times with c3 */
View
@@ -1440,6 +1440,7 @@ EXTERN char_u e_font[] INIT(= N_("E235: Unknown font: %s"));
EXTERN char_u e_fontwidth[] INIT(= N_("E236: Font \"%s\" is not fixed-width"));
#endif
EXTERN char_u e_internal[] INIT(= N_("E473: Internal error"));
+EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s"));
EXTERN char_u e_interr[] INIT(= N_("Interrupted"));
EXTERN char_u e_invaddr[] INIT(= N_("E14: Invalid address"));
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"));
EXTERN char_u e_guarded[] INIT(= N_("E463: Region is guarded, cannot modify"));
EXTERN char_u e_nbreadonly[] INIT(= N_("E744: NetBeans does not allow changes in read-only files"));
#endif
-EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s"));
EXTERN char_u e_maxmempat[] INIT(= N_("E363: pattern uses more memory than 'maxmempattern'"));
EXTERN char_u e_emptybuf[] INIT(= N_("E749: empty buffer"));
EXTERN char_u e_nobufnr[] INIT(= N_("E86: Buffer %ld does not exist"));
View
@@ -218,7 +218,7 @@ gui_mch_create_beval_area(
if (mesg != NULL && mesgCB != NULL)
{
- EMSG(_("E232: Cannot create BalloonEval with both message and callback"));
+ IEMSG(_("E232: Cannot create BalloonEval with both message and callback"));
return NULL;
}
View
@@ -8620,7 +8620,7 @@ gui_mch_create_beval_area(
if (mesg != NULL && mesgCB != NULL)
{
- EMSG(_("E232: Cannot create BalloonEval with both message and callback"));
+ IEMSG(_("E232: Cannot create BalloonEval with both message and callback"));
return NULL;
}
View
@@ -590,7 +590,7 @@ hangul_automata2(char_u *buf, int_u *c)
return AUTOMATA_CORRECT_NEW;
default:
- EMSG(_("E256: Hangul automata ERROR"));
+ IEMSG(_("E256: Hangul automata ERROR"));
break;
}
return AUTOMATA_ERROR; /* RrEeAaLlLlYy EeRrRrOoRr */
View
@@ -210,7 +210,7 @@ hash_add(hashtab_T *ht, char_u *key)
hi = hash_lookup(ht, key, hash);
if (!HASHITEM_EMPTY(hi))
{
- EMSG2(_(e_intern2), "hash_add()");
+ internal_error("hash_add()");
return FAIL;
}
return hash_add_item(ht, hi, key, hash);
View
@@ -1792,7 +1792,7 @@ cs_manage_matches(
cs_print_tags_priv(mp, cp, cnt);
break;
default: /* should not reach here */
- (void)EMSG(_("E570: fatal error in cs_manage_matches"));
+ IEMSG(_("E570: fatal error in cs_manage_matches"));
return NULL;
}
View
@@ -328,7 +328,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
break;
#endif
case VAR_UNKNOWN:
- EMSG2(_(e_intern2), "json_encode_item()");
+ internal_error("json_encode_item()");
return FAIL;
}
return OK;
View
@@ -482,7 +482,7 @@ mf_put(
flags = hp->bh_flags;
if ((flags & BH_LOCKED) == 0)
- EMSG(_("E293: block was not locked"));
+ IEMSG(_("E293: block was not locked"));
flags &= ~BH_LOCKED;
if (dirty)
{
Oops, something went wrong.

0 comments on commit 95f0960

Please sign in to comment.