comparison src/eval.c @ 15543:dd725a8ab112 v8.1.0779

patch 8.1.0779: argument for message functions is inconsistent commit https://github.com/vim/vim/commit/32526b3c1846025f0e655f41efd4e5428da16b6c Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 19 17:43:09 2019 +0100 patch 8.1.0779: argument for message functions is inconsistent Problem: Argument for message functions is inconsistent. Solution: Make first argument to msg() "char *".
author Bram Moolenaar <Bram@vim.org>
date Sat, 19 Jan 2019 17:45:07 +0100
parents 2ad5f0ffaa2e
children c2382f0d1279
comparison
equal deleted inserted replaced
15542:5baedae7ca7a 15543:dd725a8ab112
243 static int get_env_len(char_u **arg); 243 static int get_env_len(char_u **arg);
244 static char_u * make_expanded_name(char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end); 244 static char_u * make_expanded_name(char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end);
245 static void check_vars(char_u *name, int len); 245 static void check_vars(char_u *name, int len);
246 static typval_T *alloc_string_tv(char_u *string); 246 static typval_T *alloc_string_tv(char_u *string);
247 static void delete_var(hashtab_T *ht, hashitem_T *hi); 247 static void delete_var(hashtab_T *ht, hashitem_T *hi);
248 static void list_one_var(dictitem_T *v, char_u *prefix, int *first); 248 static void list_one_var(dictitem_T *v, char *prefix, int *first);
249 static void list_one_var_a(char_u *prefix, char_u *name, int type, char_u *string, int *first); 249 static void list_one_var_a(char *prefix, char_u *name, int type, char_u *string, int *first);
250 static char_u *find_option_end(char_u **arg, int *opt_flags); 250 static char_u *find_option_end(char_u **arg, int *opt_flags);
251 251
252 /* for VIM_VERSION_ defines */ 252 /* for VIM_VERSION_ defines */
253 #include "version.h" 253 #include "version.h"
254 254
1446 * If "empty" is TRUE also list NULL strings as empty strings. 1446 * If "empty" is TRUE also list NULL strings as empty strings.
1447 */ 1447 */
1448 void 1448 void
1449 list_hashtable_vars( 1449 list_hashtable_vars(
1450 hashtab_T *ht, 1450 hashtab_T *ht,
1451 char_u *prefix, 1451 char *prefix,
1452 int empty, 1452 int empty,
1453 int *first) 1453 int *first)
1454 { 1454 {
1455 hashitem_T *hi; 1455 hashitem_T *hi;
1456 dictitem_T *di; 1456 dictitem_T *di;
1464 { 1464 {
1465 --todo; 1465 --todo;
1466 di = HI2DI(hi); 1466 di = HI2DI(hi);
1467 1467
1468 // apply :filter /pat/ to variable name 1468 // apply :filter /pat/ to variable name
1469 vim_strncpy((char_u *) buf, prefix, IOSIZE - 1); 1469 vim_strncpy((char_u *)buf, (char_u *)prefix, IOSIZE - 1);
1470 vim_strcat((char_u *) buf, di->di_key, IOSIZE); 1470 vim_strcat((char_u *)buf, di->di_key, IOSIZE);
1471 if (message_filtered(buf)) 1471 if (message_filtered(buf))
1472 continue; 1472 continue;
1473 1473
1474 if (empty || di->di_tv.v_type != VAR_STRING 1474 if (empty || di->di_tv.v_type != VAR_STRING
1475 || di->di_tv.vval.v_string != NULL) 1475 || di->di_tv.vval.v_string != NULL)
1482 * List global variables. 1482 * List global variables.
1483 */ 1483 */
1484 static void 1484 static void
1485 list_glob_vars(int *first) 1485 list_glob_vars(int *first)
1486 { 1486 {
1487 list_hashtable_vars(&globvarht, (char_u *)"", TRUE, first); 1487 list_hashtable_vars(&globvarht, "", TRUE, first);
1488 } 1488 }
1489 1489
1490 /* 1490 /*
1491 * List buffer variables. 1491 * List buffer variables.
1492 */ 1492 */
1493 static void 1493 static void
1494 list_buf_vars(int *first) 1494 list_buf_vars(int *first)
1495 { 1495 {
1496 list_hashtable_vars(&curbuf->b_vars->dv_hashtab, (char_u *)"b:", 1496 list_hashtable_vars(&curbuf->b_vars->dv_hashtab, "b:", TRUE, first);
1497 TRUE, first);
1498 } 1497 }
1499 1498
1500 /* 1499 /*
1501 * List window variables. 1500 * List window variables.
1502 */ 1501 */
1503 static void 1502 static void
1504 list_win_vars(int *first) 1503 list_win_vars(int *first)
1505 { 1504 {
1506 list_hashtable_vars(&curwin->w_vars->dv_hashtab, 1505 list_hashtable_vars(&curwin->w_vars->dv_hashtab, "w:", TRUE, first);
1507 (char_u *)"w:", TRUE, first);
1508 } 1506 }
1509 1507
1510 /* 1508 /*
1511 * List tab page variables. 1509 * List tab page variables.
1512 */ 1510 */
1513 static void 1511 static void
1514 list_tab_vars(int *first) 1512 list_tab_vars(int *first)
1515 { 1513 {
1516 list_hashtable_vars(&curtab->tp_vars->dv_hashtab, 1514 list_hashtable_vars(&curtab->tp_vars->dv_hashtab, "t:", TRUE, first);
1517 (char_u *)"t:", TRUE, first);
1518 } 1515 }
1519 1516
1520 /* 1517 /*
1521 * List Vim variables. 1518 * List Vim variables.
1522 */ 1519 */
1523 static void 1520 static void
1524 list_vim_vars(int *first) 1521 list_vim_vars(int *first)
1525 { 1522 {
1526 list_hashtable_vars(&vimvarht, (char_u *)"v:", FALSE, first); 1523 list_hashtable_vars(&vimvarht, "v:", FALSE, first);
1527 } 1524 }
1528 1525
1529 /* 1526 /*
1530 * List script-local variables, if there is a script. 1527 * List script-local variables, if there is a script.
1531 */ 1528 */
1532 static void 1529 static void
1533 list_script_vars(int *first) 1530 list_script_vars(int *first)
1534 { 1531 {
1535 if (current_sctx.sc_sid > 0 && current_sctx.sc_sid <= ga_scripts.ga_len) 1532 if (current_sctx.sc_sid > 0 && current_sctx.sc_sid <= ga_scripts.ga_len)
1536 list_hashtable_vars(&SCRIPT_VARS(current_sctx.sc_sid), 1533 list_hashtable_vars(&SCRIPT_VARS(current_sctx.sc_sid),
1537 (char_u *)"s:", FALSE, first); 1534 "s:", FALSE, first);
1538 } 1535 }
1539 1536
1540 /* 1537 /*
1541 * List variables in "arg". 1538 * List variables in "arg".
1542 */ 1539 */
1617 char_u *s; 1614 char_u *s;
1618 1615
1619 s = echo_string(&tv, &tf, numbuf, 0); 1616 s = echo_string(&tv, &tf, numbuf, 0);
1620 c = *arg; 1617 c = *arg;
1621 *arg = NUL; 1618 *arg = NUL;
1622 list_one_var_a((char_u *)"", 1619 list_one_var_a("",
1623 arg == arg_subsc ? name : name_start, 1620 arg == arg_subsc ? name : name_start,
1624 tv.v_type, 1621 tv.v_type,
1625 s == NULL ? (char_u *)"" : s, 1622 s == NULL ? (char_u *)"" : s,
1626 first); 1623 first);
1627 *arg = c; 1624 *arg = c;
5460 */ 5457 */
5461 free_unref_funccal(copyID, testing); 5458 free_unref_funccal(copyID, testing);
5462 } 5459 }
5463 else if (p_verbose > 0) 5460 else if (p_verbose > 0)
5464 { 5461 {
5465 verb_msg((char_u *)_("Not enough memory to set references, garbage collection aborted!")); 5462 verb_msg(_("Not enough memory to set references, garbage collection aborted!"));
5466 } 5463 }
5467 5464
5468 return did_free; 5465 return did_free;
5469 } 5466 }
5470 5467
7789 7786
7790 /* 7787 /*
7791 * List the value of one internal variable. 7788 * List the value of one internal variable.
7792 */ 7789 */
7793 static void 7790 static void
7794 list_one_var(dictitem_T *v, char_u *prefix, int *first) 7791 list_one_var(dictitem_T *v, char *prefix, int *first)
7795 { 7792 {
7796 char_u *tofree; 7793 char_u *tofree;
7797 char_u *s; 7794 char_u *s;
7798 char_u numbuf[NUMBUFLEN]; 7795 char_u numbuf[NUMBUFLEN];
7799 7796
7803 vim_free(tofree); 7800 vim_free(tofree);
7804 } 7801 }
7805 7802
7806 static void 7803 static void
7807 list_one_var_a( 7804 list_one_var_a(
7808 char_u *prefix, 7805 char *prefix,
7809 char_u *name, 7806 char_u *name,
7810 int type, 7807 int type,
7811 char_u *string, 7808 char_u *string,
7812 int *first) /* when TRUE clear rest of screen and set to FALSE */ 7809 int *first) /* when TRUE clear rest of screen and set to FALSE */
7813 { 7810 {
7814 /* don't use msg() or msg_attr() to avoid overwriting "v:statusmsg" */ 7811 /* don't use msg() or msg_attr() to avoid overwriting "v:statusmsg" */
7815 msg_start(); 7812 msg_start();
7816 msg_puts(prefix); 7813 msg_puts(prefix);
7817 if (name != NULL) /* "a:" vars don't have a name stored */ 7814 if (name != NULL) /* "a:" vars don't have a name stored */
7818 msg_puts(name); 7815 msg_puts((char *)name);
7819 msg_putchar(' '); 7816 msg_putchar(' ');
7820 msg_advance(22); 7817 msg_advance(22);
7821 if (type == VAR_NUMBER) 7818 if (type == VAR_NUMBER)
7822 msg_putchar('#'); 7819 msg_putchar('#');
7823 else if (type == VAR_FUNC || type == VAR_PARTIAL) 7820 else if (type == VAR_FUNC || type == VAR_PARTIAL)
7838 msg_putchar(' '); 7835 msg_putchar(' ');
7839 7836
7840 msg_outtrans(string); 7837 msg_outtrans(string);
7841 7838
7842 if (type == VAR_FUNC || type == VAR_PARTIAL) 7839 if (type == VAR_FUNC || type == VAR_PARTIAL)
7843 msg_puts((char_u *)"()"); 7840 msg_puts("()");
7844 if (*first) 7841 if (*first)
7845 { 7842 {
7846 msg_clr_eos(); 7843 msg_clr_eos();
7847 *first = FALSE; 7844 *first = FALSE;
7848 } 7845 }
8302 ++p; 8299 ++p;
8303 c = *p; 8300 c = *p;
8304 *p = NUL; 8301 *p = NUL;
8305 msg_start(); 8302 msg_start();
8306 msg_clr_eos(); 8303 msg_clr_eos();
8307 msg_puts_attr(prompt, echo_attr); 8304 msg_puts_attr((char *)prompt, echo_attr);
8308 msg_didout = FALSE; 8305 msg_didout = FALSE;
8309 msg_starthere(); 8306 msg_starthere();
8310 *p = c; 8307 *p = c;
8311 } 8308 }
8312 cmdline_row = msg_row; 8309 cmdline_row = msg_row;
8420 msg_sb_eol(); 8417 msg_sb_eol();
8421 msg_start(); 8418 msg_start();
8422 } 8419 }
8423 } 8420 }
8424 else if (eap->cmdidx == CMD_echo) 8421 else if (eap->cmdidx == CMD_echo)
8425 msg_puts_attr((char_u *)" ", echo_attr); 8422 msg_puts_attr(" ", echo_attr);
8426 p = echo_string(&rettv, &tofree, numbuf, get_copyID()); 8423 p = echo_string(&rettv, &tofree, numbuf, get_copyID());
8427 if (p != NULL) 8424 if (p != NULL)
8428 for ( ; *p != NUL && !got_int; ++p) 8425 for ( ; *p != NUL && !got_int; ++p)
8429 { 8426 {
8430 if (*p == '\n' || *p == '\r' || *p == TAB) 8427 if (*p == '\n' || *p == '\r' || *p == TAB)
8544 msg_sb_eol(); 8541 msg_sb_eol();
8545 } 8542 }
8546 8543
8547 if (eap->cmdidx == CMD_echomsg) 8544 if (eap->cmdidx == CMD_echomsg)
8548 { 8545 {
8549 MSG_ATTR(ga.ga_data, echo_attr); 8546 msg_attr(ga.ga_data, echo_attr);
8550 out_flush(); 8547 out_flush();
8551 } 8548 }
8552 else if (eap->cmdidx == CMD_echoerr) 8549 else if (eap->cmdidx == CMD_echoerr)
8553 { 8550 {
8554 /* We don't want to abort following commands, restore did_emsg. */ 8551 /* We don't want to abort following commands, restore did_emsg. */
9157 { 9154 {
9158 p = home_replace_save(NULL, get_scriptname(script_ctx.sc_sid)); 9155 p = home_replace_save(NULL, get_scriptname(script_ctx.sc_sid));
9159 if (p != NULL) 9156 if (p != NULL)
9160 { 9157 {
9161 verbose_enter(); 9158 verbose_enter();
9162 MSG_PUTS(_("\n\tLast set from ")); 9159 msg_puts(_("\n\tLast set from "));
9163 MSG_PUTS(p); 9160 msg_puts((char *)p);
9164 if (script_ctx.sc_lnum > 0) 9161 if (script_ctx.sc_lnum > 0)
9165 { 9162 {
9166 MSG_PUTS(_(" line ")); 9163 msg_puts(_(" line "));
9167 msg_outnum((long)script_ctx.sc_lnum); 9164 msg_outnum((long)script_ctx.sc_lnum);
9168 } 9165 }
9169 verbose_leave(); 9166 verbose_leave();
9170 vim_free(p); 9167 vim_free(p);
9171 } 9168 }