comparison src/eval.c @ 5973:99d8f2d72dcd v7.4.327

updated for version 7.4.327 Problem: When 'verbose' is set to display the return value of a function, may get E724 repeatedly. Solution: Do not give an error for verbose messages. Abort conversion to string after an error.
author Bram Moolenaar <bram@vim.org>
date Tue, 17 Jun 2014 12:51:16 +0200
parents 238f5027830c
children f9fa2e506b9f
comparison
equal deleted inserted replaced
5972:6e8b6a7f7bff 5973:99d8f2d72dcd
131 * The last bit is used for previous_funccal, ignored when comparing. 131 * The last bit is used for previous_funccal, ignored when comparing.
132 */ 132 */
133 static int current_copyID = 0; 133 static int current_copyID = 0;
134 #define COPYID_INC 2 134 #define COPYID_INC 2
135 #define COPYID_MASK (~0x1) 135 #define COPYID_MASK (~0x1)
136
137 /* Abort conversion to string after a recursion error. */
138 static int did_echo_string_emsg = FALSE;
136 139
137 /* 140 /*
138 * Array to hold the hashtab with variables local to each sourced script. 141 * Array to hold the hashtab with variables local to each sourced script.
139 * Each item holds a variable (nameless) that points to the dict_T. 142 * Each item holds a variable (nameless) that points to the dict_T.
140 */ 143 */
6684 p->s = vim_strnsave(s, len); 6687 p->s = vim_strnsave(s, len);
6685 p->tofree = p->s; 6688 p->tofree = p->s;
6686 } 6689 }
6687 6690
6688 line_breakcheck(); 6691 line_breakcheck();
6692 if (did_echo_string_emsg) /* recursion error, bail out */
6693 break;
6689 } 6694 }
6690 6695
6691 /* Allocate result buffer with its total size, avoid re-allocation and 6696 /* Allocate result buffer with its total size, avoid re-allocation and
6692 * multiple copy operations. Add 2 for a tailing ']' and NUL. */ 6697 * multiple copy operations. Add 2 for a tailing ']' and NUL. */
6693 if (join_gap->ga_len >= 2) 6698 if (join_gap->ga_len >= 2)
7458 ga_concat(&ga, (char_u *)": "); 7463 ga_concat(&ga, (char_u *)": ");
7459 s = tv2string(&HI2DI(hi)->di_tv, &tofree, numbuf, copyID); 7464 s = tv2string(&HI2DI(hi)->di_tv, &tofree, numbuf, copyID);
7460 if (s != NULL) 7465 if (s != NULL)
7461 ga_concat(&ga, s); 7466 ga_concat(&ga, s);
7462 vim_free(tofree); 7467 vim_free(tofree);
7463 if (s == NULL) 7468 if (s == NULL || did_echo_string_emsg)
7464 break; 7469 break;
7470 line_breakcheck();
7471
7465 } 7472 }
7466 } 7473 }
7467 if (todo > 0) 7474 if (todo > 0)
7468 { 7475 {
7469 vim_free(ga.ga_data); 7476 vim_free(ga.ga_data);
7617 static int recurse = 0; 7624 static int recurse = 0;
7618 char_u *r = NULL; 7625 char_u *r = NULL;
7619 7626
7620 if (recurse >= DICT_MAXNEST) 7627 if (recurse >= DICT_MAXNEST)
7621 { 7628 {
7622 EMSG(_("E724: variable nested too deep for displaying")); 7629 if (!did_echo_string_emsg)
7630 {
7631 /* Only give this message once for a recursive call to avoid
7632 * flooding the user with errors. And stop iterating over lists
7633 * and dicts. */
7634 did_echo_string_emsg = TRUE;
7635 EMSG(_("E724: variable nested too deep for displaying"));
7636 }
7623 *tofree = NULL; 7637 *tofree = NULL;
7624 return NULL; 7638 return (char_u *)"{E724}";
7625 } 7639 }
7626 ++recurse; 7640 ++recurse;
7627 7641
7628 switch (tv->v_type) 7642 switch (tv->v_type)
7629 { 7643 {
7687 default: 7701 default:
7688 EMSG2(_(e_intern2), "echo_string()"); 7702 EMSG2(_(e_intern2), "echo_string()");
7689 *tofree = NULL; 7703 *tofree = NULL;
7690 } 7704 }
7691 7705
7692 --recurse; 7706 if (--recurse == 0)
7707 did_echo_string_emsg = FALSE;
7693 return r; 7708 return r;
7694 } 7709 }
7695 7710
7696 /* 7711 /*
7697 * Return a string with the string representation of a variable. 7712 * Return a string with the string representation of a variable.
23301 msg_puts((char_u *)", "); 23316 msg_puts((char_u *)", ");
23302 if (argvars[i].v_type == VAR_NUMBER) 23317 if (argvars[i].v_type == VAR_NUMBER)
23303 msg_outnum((long)argvars[i].vval.v_number); 23318 msg_outnum((long)argvars[i].vval.v_number);
23304 else 23319 else
23305 { 23320 {
23321 /* Do not want errors such as E724 here. */
23322 ++emsg_off;
23306 s = tv2string(&argvars[i], &tofree, numbuf2, 0); 23323 s = tv2string(&argvars[i], &tofree, numbuf2, 0);
23324 --emsg_off;
23307 if (s != NULL) 23325 if (s != NULL)
23308 { 23326 {
23309 if (vim_strsize(s) > MSG_BUF_CLEN) 23327 if (vim_strsize(s) > MSG_BUF_CLEN)
23310 { 23328 {
23311 trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN); 23329 trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN);
23393 char_u *tofree; 23411 char_u *tofree;
23394 char_u *s; 23412 char_u *s;
23395 23413
23396 /* The value may be very long. Skip the middle part, so that we 23414 /* The value may be very long. Skip the middle part, so that we
23397 * have some idea how it starts and ends. smsg() would always 23415 * have some idea how it starts and ends. smsg() would always
23398 * truncate it at the end. */ 23416 * truncate it at the end. Don't want errors such as E724 here. */
23417 ++emsg_off;
23399 s = tv2string(fc->rettv, &tofree, numbuf2, 0); 23418 s = tv2string(fc->rettv, &tofree, numbuf2, 0);
23419 --emsg_off;
23400 if (s != NULL) 23420 if (s != NULL)
23401 { 23421 {
23402 if (vim_strsize(s) > MSG_BUF_CLEN) 23422 if (vim_strsize(s) > MSG_BUF_CLEN)
23403 { 23423 {
23404 trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN); 23424 trunc_string(s, buf, MSG_BUF_CLEN, MSG_BUF_LEN);