comparison src/ex_docmd.c @ 15470:55ccc2d353bd v8.1.0743

patch 8.1.0743: giving error messages is not flexible commit https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 13 23:38:42 2019 +0100 patch 8.1.0743: giving error messages is not flexible Problem: Giving error messages is not flexible. Solution: Add semsg(). Change argument from "char_u *" to "char *", also for msg() and get rid of most MSG macros. (Ozaki Kiichi, closes #3302) Also make emsg() accept a "char *" argument. Get rid of an enormous number of type casts.
author Bram Moolenaar <Bram@vim.org>
date Sun, 13 Jan 2019 23:45:08 +0100
parents 1c6a708a5fee
children 79e3dcc5aa50
comparison
equal deleted inserted replaced
15469:bc9b5261ed01 15470:55ccc2d353bd
124 || !defined(FEAT_LUA) \ 124 || !defined(FEAT_LUA) \
125 || !defined(FEAT_MZSCHEME) 125 || !defined(FEAT_MZSCHEME)
126 # define HAVE_EX_SCRIPT_NI 126 # define HAVE_EX_SCRIPT_NI
127 static void ex_script_ni(exarg_T *eap); 127 static void ex_script_ni(exarg_T *eap);
128 #endif 128 #endif
129 static char_u *invalid_range(exarg_T *eap); 129 static char *invalid_range(exarg_T *eap);
130 static void correct_range(exarg_T *eap); 130 static void correct_range(exarg_T *eap);
131 #ifdef FEAT_QUICKFIX 131 #ifdef FEAT_QUICKFIX
132 static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep); 132 static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep);
133 #endif 133 #endif
134 static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep); 134 static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep);
299 static void ex_redrawtabline(exarg_T *eap); 299 static void ex_redrawtabline(exarg_T *eap);
300 static void close_redir(void); 300 static void close_redir(void);
301 static void ex_mkrc(exarg_T *eap); 301 static void ex_mkrc(exarg_T *eap);
302 static void ex_mark(exarg_T *eap); 302 static void ex_mark(exarg_T *eap);
303 #ifdef FEAT_USR_CMDS 303 #ifdef FEAT_USR_CMDS
304 static char_u *uc_fun_cmd(void); 304 static char *uc_fun_cmd(void);
305 static char_u *find_ucmd(exarg_T *eap, char_u *p, int *full, expand_T *xp, int *compl); 305 static char_u *find_ucmd(exarg_T *eap, char_u *p, int *full, expand_T *xp, int *compl);
306 #endif 306 #endif
307 static void ex_startinsert(exarg_T *eap); 307 static void ex_startinsert(exarg_T *eap);
308 static void ex_stopinsert(exarg_T *eap); 308 static void ex_stopinsert(exarg_T *eap);
309 #ifdef FEAT_FIND_ID 309 #ifdef FEAT_FIND_ID
592 592
593 if ((prev_line != curwin->w_cursor.lnum 593 if ((prev_line != curwin->w_cursor.lnum
594 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint) 594 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint)
595 { 595 {
596 if (curbuf->b_ml.ml_flags & ML_EMPTY) 596 if (curbuf->b_ml.ml_flags & ML_EMPTY)
597 EMSG(_(e_emptybuf)); 597 emsg(_(e_emptybuf));
598 else 598 else
599 { 599 {
600 if (ex_pressedreturn) 600 if (ex_pressedreturn)
601 { 601 {
602 /* go up one line, to overwrite the ":<CR>" line, so the 602 /* go up one line, to overwrite the ":<CR>" line, so the
611 } 611 }
612 } 612 }
613 else if (ex_pressedreturn && !ex_no_reprint) /* must be at EOF */ 613 else if (ex_pressedreturn && !ex_no_reprint) /* must be at EOF */
614 { 614 {
615 if (curbuf->b_ml.ml_flags & ML_EMPTY) 615 if (curbuf->b_ml.ml_flags & ML_EMPTY)
616 EMSG(_(e_emptybuf)); 616 emsg(_(e_emptybuf));
617 else 617 else
618 EMSG(_("E501: At end-of-file")); 618 emsg(_("E501: At end-of-file"));
619 } 619 }
620 } 620 }
621 621
622 #ifdef FEAT_GUI 622 #ifdef FEAT_GUI
623 --hold_gui_events; 623 --hold_gui_events;
716 #ifdef FEAT_EVAL 716 #ifdef FEAT_EVAL
717 && call_depth >= p_mfd 717 && call_depth >= p_mfd
718 #endif 718 #endif
719 ) 719 )
720 { 720 {
721 EMSG(_("E169: Command too recursive")); 721 emsg(_("E169: Command too recursive"));
722 #ifdef FEAT_EVAL 722 #ifdef FEAT_EVAL
723 /* When converting to an exception, we do not include the command name 723 /* When converting to an exception, we do not include the command name
724 * since this is not an error of the specific command. */ 724 * since this is not an error of the specific command. */
725 do_errthrow((struct condstack *)NULL, (char_u *)NULL); 725 do_errthrow((struct condstack *)NULL, (char_u *)NULL);
726 msg_list = saved_msg_list; 726 msg_list = saved_msg_list;
965 else if (cmdline_copy == NULL) 965 else if (cmdline_copy == NULL)
966 { 966 {
967 next_cmdline = vim_strsave(next_cmdline); 967 next_cmdline = vim_strsave(next_cmdline);
968 if (next_cmdline == NULL) 968 if (next_cmdline == NULL)
969 { 969 {
970 EMSG(_(e_outofmem)); 970 emsg(_(e_outofmem));
971 retval = FAIL; 971 retval = FAIL;
972 break; 972 break;
973 } 973 }
974 } 974 }
975 cmdline_copy = next_cmdline; 975 cmdline_copy = next_cmdline;
1017 if (p_verbose >= 15 && sourcing_name != NULL) 1017 if (p_verbose >= 15 && sourcing_name != NULL)
1018 { 1018 {
1019 ++no_wait_return; 1019 ++no_wait_return;
1020 verbose_enter_scroll(); 1020 verbose_enter_scroll();
1021 1021
1022 smsg((char_u *)_("line %ld: %s"), 1022 smsg(_("line %ld: %s"),
1023 (long)sourcing_lnum, cmdline_copy); 1023 (long)sourcing_lnum, cmdline_copy);
1024 if (msg_silent == 0) 1024 if (msg_silent == 0)
1025 msg_puts((char_u *)"\n"); /* don't overwrite this */ 1025 msg_puts((char_u *)"\n"); /* don't overwrite this */
1026 1026
1027 verbose_leave_scroll(); 1027 verbose_leave_scroll();
1249 && !source_finished(fgetline, cookie)) 1249 && !source_finished(fgetline, cookie))
1250 || (getline_equal(fgetline, cookie, get_func_line) 1250 || (getline_equal(fgetline, cookie, get_func_line)
1251 && !func_has_ended(real_cookie)))) 1251 && !func_has_ended(real_cookie))))
1252 { 1252 {
1253 if (cstack.cs_flags[cstack.cs_idx] & CSF_TRY) 1253 if (cstack.cs_flags[cstack.cs_idx] & CSF_TRY)
1254 EMSG(_(e_endtry)); 1254 emsg(_(e_endtry));
1255 else if (cstack.cs_flags[cstack.cs_idx] & CSF_WHILE) 1255 else if (cstack.cs_flags[cstack.cs_idx] & CSF_WHILE)
1256 EMSG(_(e_endwhile)); 1256 emsg(_(e_endwhile));
1257 else if (cstack.cs_flags[cstack.cs_idx] & CSF_FOR) 1257 else if (cstack.cs_flags[cstack.cs_idx] & CSF_FOR)
1258 EMSG(_(e_endfor)); 1258 emsg(_(e_endfor));
1259 else 1259 else
1260 EMSG(_(e_endif)); 1260 emsg(_(e_endif));
1261 } 1261 }
1262 1262
1263 /* 1263 /*
1264 * Reset "trylevel" in case of a ":finish" or ":return" or a missing 1264 * Reset "trylevel" in case of a ":finish" or ":return" or a missing
1265 * ":endtry" in a sourced file or executed function. If the try 1265 * ":endtry" in a sourced file or executed function. If the try
1345 } 1345 }
1346 while (messages != NULL); 1346 while (messages != NULL);
1347 } 1347 }
1348 else if (p != NULL) 1348 else if (p != NULL)
1349 { 1349 {
1350 emsg(p); 1350 semsg(p);
1351 vim_free(p); 1351 vim_free(p);
1352 } 1352 }
1353 vim_free(sourcing_name); 1353 vim_free(sourcing_name);
1354 sourcing_name = saved_sourcing_name; 1354 sourcing_name = saved_sourcing_name;
1355 sourcing_lnum = saved_sourcing_lnum; 1355 sourcing_lnum = saved_sourcing_lnum;
1698 void *cookie) /* argument for fgetline() */ 1698 void *cookie) /* argument for fgetline() */
1699 { 1699 {
1700 char_u *p; 1700 char_u *p;
1701 linenr_T lnum; 1701 linenr_T lnum;
1702 long n; 1702 long n;
1703 char_u *errormsg = NULL; /* error message */ 1703 char *errormsg = NULL; /* error message */
1704 char_u *after_modifier = NULL; 1704 char_u *after_modifier = NULL;
1705 exarg_T ea; /* Ex command arguments */ 1705 exarg_T ea; /* Ex command arguments */
1706 int save_msg_scroll = msg_scroll; 1706 int save_msg_scroll = msg_scroll;
1707 cmdmod_T save_cmdmod; 1707 cmdmod_T save_cmdmod;
1708 int ni; /* set when Not Implemented */ 1708 int ni; /* set when Not Implemented */
1896 else 1896 else
1897 ea.line2 = curbuf->b_ml.ml_line_count; 1897 ea.line2 = curbuf->b_ml.ml_line_count;
1898 } 1898 }
1899 1899
1900 if (ea.line2 < 0) 1900 if (ea.line2 < 0)
1901 errormsg = (char_u *)_(e_invrange); 1901 errormsg = _(e_invrange);
1902 else 1902 else
1903 { 1903 {
1904 if (ea.line2 == 0) 1904 if (ea.line2 == 0)
1905 curwin->w_cursor.lnum = 1; 1905 curwin->w_cursor.lnum = 1;
1906 else 1906 else
1936 1936
1937 #ifdef FEAT_USR_CMDS 1937 #ifdef FEAT_USR_CMDS
1938 if (p == NULL) 1938 if (p == NULL)
1939 { 1939 {
1940 if (!ea.skip) 1940 if (!ea.skip)
1941 errormsg = (char_u *)_("E464: Ambiguous use of user-defined command"); 1941 errormsg = _("E464: Ambiguous use of user-defined command");
1942 goto doend; 1942 goto doend;
1943 } 1943 }
1944 /* Check for wrong commands. */ 1944 /* Check for wrong commands. */
1945 if (*p == '!' && ea.cmd[1] == 0151 && ea.cmd[0] == 78 1945 if (*p == '!' && ea.cmd[1] == 0151 && ea.cmd[0] == 78
1946 && !IS_USER_CMDIDX(ea.cmdidx)) 1946 && !IS_USER_CMDIDX(ea.cmdidx))
1961 if (after_modifier != NULL) 1961 if (after_modifier != NULL)
1962 append_command(after_modifier); 1962 append_command(after_modifier);
1963 else 1963 else
1964 append_command(*cmdlinep); 1964 append_command(*cmdlinep);
1965 } 1965 }
1966 errormsg = IObuff; 1966 errormsg = (char *)IObuff;
1967 did_emsg_syntax = TRUE; 1967 did_emsg_syntax = TRUE;
1968 } 1968 }
1969 goto doend; 1969 goto doend;
1970 } 1970 }
1971 1971
2012 { 2012 {
2013 #ifdef HAVE_SANDBOX 2013 #ifdef HAVE_SANDBOX
2014 if (sandbox != 0 && !(ea.argt & SBOXOK)) 2014 if (sandbox != 0 && !(ea.argt & SBOXOK))
2015 { 2015 {
2016 /* Command not allowed in sandbox. */ 2016 /* Command not allowed in sandbox. */
2017 errormsg = (char_u *)_(e_sandbox); 2017 errormsg = _(e_sandbox);
2018 goto doend; 2018 goto doend;
2019 } 2019 }
2020 #endif 2020 #endif
2021 if (!curbuf->b_p_ma && (ea.argt & MODIFY)) 2021 if (!curbuf->b_p_ma && (ea.argt & MODIFY))
2022 { 2022 {
2023 /* Command not allowed in non-'modifiable' buffer */ 2023 /* Command not allowed in non-'modifiable' buffer */
2024 errormsg = (char_u *)_(e_modifiable); 2024 errormsg = _(e_modifiable);
2025 goto doend; 2025 goto doend;
2026 } 2026 }
2027 2027
2028 if (text_locked() && !(ea.argt & CMDWIN) 2028 if (text_locked() && !(ea.argt & CMDWIN)
2029 && !IS_USER_CMDIDX(ea.cmdidx)) 2029 && !IS_USER_CMDIDX(ea.cmdidx))
2030 { 2030 {
2031 /* Command not allowed when editing the command line. */ 2031 /* Command not allowed when editing the command line. */
2032 errormsg = (char_u *)_(get_text_locked_msg()); 2032 errormsg = _(get_text_locked_msg());
2033 goto doend; 2033 goto doend;
2034 } 2034 }
2035 2035
2036 /* Disallow editing another buffer when "curbuf_lock" is set. 2036 /* Disallow editing another buffer when "curbuf_lock" is set.
2037 * Do allow ":checktime" (it is postponed). 2037 * Do allow ":checktime" (it is postponed).
2046 goto doend; 2046 goto doend;
2047 2047
2048 if (!ni && !(ea.argt & RANGE) && ea.addr_count > 0) 2048 if (!ni && !(ea.argt & RANGE) && ea.addr_count > 0)
2049 { 2049 {
2050 /* no range allowed */ 2050 /* no range allowed */
2051 errormsg = (char_u *)_(e_norange); 2051 errormsg = _(e_norange);
2052 goto doend; 2052 goto doend;
2053 } 2053 }
2054 } 2054 }
2055 2055
2056 if (!ni && !(ea.argt & BANG) && ea.forceit) /* no <!> allowed */ 2056 if (!ni && !(ea.argt & BANG) && ea.forceit) /* no <!> allowed */
2057 { 2057 {
2058 errormsg = (char_u *)_(e_nobang); 2058 errormsg = _(e_nobang);
2059 goto doend; 2059 goto doend;
2060 } 2060 }
2061 2061
2062 /* 2062 /*
2063 * Don't complain about the range if it is not used 2063 * Don't complain about the range if it is not used
2074 { 2074 {
2075 if (msg_silent == 0) 2075 if (msg_silent == 0)
2076 { 2076 {
2077 if (sourcing || exmode_active) 2077 if (sourcing || exmode_active)
2078 { 2078 {
2079 errormsg = (char_u *)_("E493: Backwards range given"); 2079 errormsg = _("E493: Backwards range given");
2080 goto doend; 2080 goto doend;
2081 } 2081 }
2082 if (ask_yesno((char_u *) 2082 if (ask_yesno((char_u *)
2083 _("Backwards range given, OK to swap"), FALSE) != 'y') 2083 _("Backwards range given, OK to swap"), FALSE) != 'y')
2084 goto doend; 2084 goto doend;
2136 */ 2136 */
2137 if (ea.argt & ARGOPT) 2137 if (ea.argt & ARGOPT)
2138 while (ea.arg[0] == '+' && ea.arg[1] == '+') 2138 while (ea.arg[0] == '+' && ea.arg[1] == '+')
2139 if (getargopt(&ea) == FAIL && !ni) 2139 if (getargopt(&ea) == FAIL && !ni)
2140 { 2140 {
2141 errormsg = (char_u *)_(e_invarg); 2141 errormsg = _(e_invarg);
2142 goto doend; 2142 goto doend;
2143 } 2143 }
2144 2144
2145 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) 2145 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update)
2146 { 2146 {
2147 if (*ea.arg == '>') /* append */ 2147 if (*ea.arg == '>') /* append */
2148 { 2148 {
2149 if (*++ea.arg != '>') /* typed wrong */ 2149 if (*++ea.arg != '>') /* typed wrong */
2150 { 2150 {
2151 errormsg = (char_u *)_("E494: Use w or w>>"); 2151 errormsg = _("E494: Use w or w>>");
2152 goto doend; 2152 goto doend;
2153 } 2153 }
2154 ea.arg = skipwhite(ea.arg + 1); 2154 ea.arg = skipwhite(ea.arg + 1);
2155 ea.append = TRUE; 2155 ea.append = TRUE;
2156 } 2156 }
2320 { 2320 {
2321 n = getdigits(&ea.arg); 2321 n = getdigits(&ea.arg);
2322 ea.arg = skipwhite(ea.arg); 2322 ea.arg = skipwhite(ea.arg);
2323 if (n <= 0 && !ni && (ea.argt & ZEROR) == 0) 2323 if (n <= 0 && !ni && (ea.argt & ZEROR) == 0)
2324 { 2324 {
2325 errormsg = (char_u *)_(e_zerocount); 2325 errormsg = _(e_zerocount);
2326 goto doend; 2326 goto doend;
2327 } 2327 }
2328 if (ea.argt & NOTADR) /* e.g. :buffer 2, :sleep 3 */ 2328 if (ea.argt & NOTADR) /* e.g. :buffer 2, :sleep 3 */
2329 { 2329 {
2330 ea.line2 = n; 2330 ea.line2 = n;
2352 get_flags(&ea); 2352 get_flags(&ea);
2353 /* no arguments allowed */ 2353 /* no arguments allowed */
2354 if (!ni && !(ea.argt & EXTRA) && *ea.arg != NUL 2354 if (!ni && !(ea.argt & EXTRA) && *ea.arg != NUL
2355 && *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & TRLBAR) == 0)) 2355 && *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & TRLBAR) == 0))
2356 { 2356 {
2357 errormsg = (char_u *)_(e_trailing); 2357 errormsg = _(e_trailing);
2358 goto doend; 2358 goto doend;
2359 } 2359 }
2360 2360
2361 if (!ni && (ea.argt & NEEDARG) && *ea.arg == NUL) 2361 if (!ni && (ea.argt & NEEDARG) && *ea.arg == NUL)
2362 { 2362 {
2363 errormsg = (char_u *)_(e_argreq); 2363 errormsg = _(e_argreq);
2364 goto doend; 2364 goto doend;
2365 } 2365 }
2366 2366
2367 #ifdef FEAT_EVAL 2367 #ifdef FEAT_EVAL
2368 /* 2368 /*
2523 * Call the function to execute the command. 2523 * Call the function to execute the command.
2524 */ 2524 */
2525 ea.errmsg = NULL; 2525 ea.errmsg = NULL;
2526 (cmdnames[ea.cmdidx].cmd_func)(&ea); 2526 (cmdnames[ea.cmdidx].cmd_func)(&ea);
2527 if (ea.errmsg != NULL) 2527 if (ea.errmsg != NULL)
2528 errormsg = (char_u *)_(ea.errmsg); 2528 errormsg = _(ea.errmsg);
2529 } 2529 }
2530 2530
2531 #ifdef FEAT_EVAL 2531 #ifdef FEAT_EVAL
2532 /* 2532 /*
2533 * If the command just executed called do_cmdline(), any throw or ":return" 2533 * If the command just executed called do_cmdline(), any throw or ":return"
2558 2558
2559 if (errormsg != NULL && *errormsg != NUL && !did_emsg) 2559 if (errormsg != NULL && *errormsg != NUL && !did_emsg)
2560 { 2560 {
2561 if (sourcing) 2561 if (sourcing)
2562 { 2562 {
2563 if (errormsg != IObuff) 2563 if (errormsg != (char *)IObuff)
2564 { 2564 {
2565 STRCPY(IObuff, errormsg); 2565 STRCPY(IObuff, errormsg);
2566 errormsg = IObuff; 2566 errormsg = (char *)IObuff;
2567 } 2567 }
2568 append_command(*cmdlinep); 2568 append_command(*cmdlinep);
2569 } 2569 }
2570 emsg(errormsg); 2570 emsg(errormsg);
2571 } 2571 }
2631 * "cmdmod". 2631 * "cmdmod".
2632 * Return FAIL when the command is not to be executed. 2632 * Return FAIL when the command is not to be executed.
2633 * May set "errormsg" to an error message. 2633 * May set "errormsg" to an error message.
2634 */ 2634 */
2635 int 2635 int
2636 parse_command_modifiers(exarg_T *eap, char_u **errormsg, int skip_only) 2636 parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
2637 { 2637 {
2638 char_u *p; 2638 char_u *p;
2639 2639
2640 vim_memset(&cmdmod, 0, sizeof(cmdmod)); 2640 vim_memset(&cmdmod, 0, sizeof(cmdmod));
2641 eap->verbose_save = -1; 2641 eap->verbose_save = -1;
2837 cmdmod.tab = tabpage_index(curtab) + 1; 2837 cmdmod.tab = tabpage_index(curtab) + 1;
2838 else 2838 else
2839 { 2839 {
2840 if (tabnr < 0 || tabnr > LAST_TAB_NR) 2840 if (tabnr < 0 || tabnr > LAST_TAB_NR)
2841 { 2841 {
2842 *errormsg = (char_u *)_(e_invrange); 2842 *errormsg = _(e_invrange);
2843 return FAIL; 2843 return FAIL;
2844 } 2844 }
2845 cmdmod.tab = tabnr + 1; 2845 cmdmod.tab = tabnr + 1;
2846 } 2846 }
2847 } 2847 }
2910 * Parse the address range, if any, in "eap". 2910 * Parse the address range, if any, in "eap".
2911 * May set the last search pattern, unless "silent" is TRUE. 2911 * May set the last search pattern, unless "silent" is TRUE.
2912 * Return FAIL and set "errormsg" or return OK. 2912 * Return FAIL and set "errormsg" or return OK.
2913 */ 2913 */
2914 int 2914 int
2915 parse_cmd_address(exarg_T *eap, char_u **errormsg, int silent) 2915 parse_cmd_address(exarg_T *eap, char **errormsg, int silent)
2916 { 2916 {
2917 int address_count = 1; 2917 int address_count = 1;
2918 linenr_T lnum; 2918 linenr_T lnum;
2919 2919
2920 // Repeat for all ',' or ';' separated addresses. 2920 // Repeat for all ',' or ';' separated addresses.
2996 } 2996 }
2997 else 2997 else
2998 { 2998 {
2999 // there is no Vim command which uses '%' and 2999 // there is no Vim command which uses '%' and
3000 // ADDR_WINDOWS or ADDR_TABS 3000 // ADDR_WINDOWS or ADDR_TABS
3001 *errormsg = (char_u *)_(e_invrange); 3001 *errormsg = _(e_invrange);
3002 return FAIL; 3002 return FAIL;
3003 } 3003 }
3004 break; 3004 break;
3005 case ADDR_TABS_RELATIVE: 3005 case ADDR_TABS_RELATIVE:
3006 case ADDR_OTHER: 3006 case ADDR_OTHER:
3007 *errormsg = (char_u *)_(e_invrange); 3007 *errormsg = _(e_invrange);
3008 return FAIL; 3008 return FAIL;
3009 case ADDR_ARGUMENTS: 3009 case ADDR_ARGUMENTS:
3010 if (ARGCOUNT == 0) 3010 if (ARGCOUNT == 0)
3011 eap->line1 = eap->line2 = 0; 3011 eap->line1 = eap->line2 = 0;
3012 else 3012 else
3031 pos_T *fp; 3031 pos_T *fp;
3032 3032
3033 // '*' - visual area 3033 // '*' - visual area
3034 if (eap->addr_type != ADDR_LINES) 3034 if (eap->addr_type != ADDR_LINES)
3035 { 3035 {
3036 *errormsg = (char_u *)_(e_invrange); 3036 *errormsg = _(e_invrange);
3037 return FAIL; 3037 return FAIL;
3038 } 3038 }
3039 3039
3040 ++eap->cmd; 3040 ++eap->cmd;
3041 if (!eap->skip) 3041 if (!eap->skip)
3214 int c1 = eap->cmd[0]; 3214 int c1 = eap->cmd[0];
3215 int c2 = eap->cmd[1]; 3215 int c2 = eap->cmd[1];
3216 3216
3217 if (command_count != (int)CMD_SIZE) 3217 if (command_count != (int)CMD_SIZE)
3218 { 3218 {
3219 iemsg((char_u *)_("E943: Command table needs to be updated, run 'make cmdidxs'")); 3219 iemsg(_("E943: Command table needs to be updated, run 'make cmdidxs'"));
3220 getout(1); 3220 getout(1);
3221 } 3221 }
3222 3222
3223 /* Use a precomputed index for fast look-up in cmdnames[] 3223 /* Use a precomputed index for fast look-up in cmdnames[]
3224 * taking into account the first 2 letters of eap->cmd. */ 3224 * taking into account the first 2 letters of eap->cmd. */
4489 break; 4489 break;
4490 case ADDR_TABS: 4490 case ADDR_TABS:
4491 lnum = CURRENT_TAB_NR; 4491 lnum = CURRENT_TAB_NR;
4492 break; 4492 break;
4493 case ADDR_TABS_RELATIVE: 4493 case ADDR_TABS_RELATIVE:
4494 EMSG(_(e_invrange)); 4494 emsg(_(e_invrange));
4495 cmd = NULL; 4495 cmd = NULL;
4496 goto error; 4496 goto error;
4497 break; 4497 break;
4498 #ifdef FEAT_QUICKFIX 4498 #ifdef FEAT_QUICKFIX
4499 case ADDR_QUICKFIX: 4499 case ADDR_QUICKFIX:
4531 break; 4531 break;
4532 case ADDR_TABS: 4532 case ADDR_TABS:
4533 lnum = LAST_TAB_NR; 4533 lnum = LAST_TAB_NR;
4534 break; 4534 break;
4535 case ADDR_TABS_RELATIVE: 4535 case ADDR_TABS_RELATIVE:
4536 EMSG(_(e_invrange)); 4536 emsg(_(e_invrange));
4537 cmd = NULL; 4537 cmd = NULL;
4538 goto error; 4538 goto error;
4539 break; 4539 break;
4540 #ifdef FEAT_QUICKFIX 4540 #ifdef FEAT_QUICKFIX
4541 case ADDR_QUICKFIX: 4541 case ADDR_QUICKFIX:
4553 cmd = NULL; 4553 cmd = NULL;
4554 goto error; 4554 goto error;
4555 } 4555 }
4556 if (addr_type != ADDR_LINES) 4556 if (addr_type != ADDR_LINES)
4557 { 4557 {
4558 EMSG(_(e_invaddr)); 4558 emsg(_(e_invaddr));
4559 cmd = NULL; 4559 cmd = NULL;
4560 goto error; 4560 goto error;
4561 } 4561 }
4562 if (skip) 4562 if (skip)
4563 ++cmd; 4563 ++cmd;
4585 case '/': 4585 case '/':
4586 case '?': /* '/' or '?' - search */ 4586 case '?': /* '/' or '?' - search */
4587 c = *cmd++; 4587 c = *cmd++;
4588 if (addr_type != ADDR_LINES) 4588 if (addr_type != ADDR_LINES)
4589 { 4589 {
4590 EMSG(_(e_invaddr)); 4590 emsg(_(e_invaddr));
4591 cmd = NULL; 4591 cmd = NULL;
4592 goto error; 4592 goto error;
4593 } 4593 }
4594 if (skip) /* skip "/pat/" */ 4594 if (skip) /* skip "/pat/" */
4595 { 4595 {
4635 4635
4636 case '\\': /* "\?", "\/" or "\&", repeat search */ 4636 case '\\': /* "\?", "\/" or "\&", repeat search */
4637 ++cmd; 4637 ++cmd;
4638 if (addr_type != ADDR_LINES) 4638 if (addr_type != ADDR_LINES)
4639 { 4639 {
4640 EMSG(_(e_invaddr)); 4640 emsg(_(e_invaddr));
4641 cmd = NULL; 4641 cmd = NULL;
4642 goto error; 4642 goto error;
4643 } 4643 }
4644 if (*cmd == '&') 4644 if (*cmd == '&')
4645 i = RE_SUBST; 4645 i = RE_SUBST;
4646 else if (*cmd == '?' || *cmd == '/') 4646 else if (*cmd == '?' || *cmd == '/')
4647 i = RE_SEARCH; 4647 i = RE_SEARCH;
4648 else 4648 else
4649 { 4649 {
4650 EMSG(_(e_backslash)); 4650 emsg(_(e_backslash));
4651 cmd = NULL; 4651 cmd = NULL;
4652 goto error; 4652 goto error;
4653 } 4653 }
4654 4654
4655 if (!skip) 4655 if (!skip)
4740 else 4740 else
4741 n = getdigits(&cmd); 4741 n = getdigits(&cmd);
4742 4742
4743 if (addr_type == ADDR_TABS_RELATIVE) 4743 if (addr_type == ADDR_TABS_RELATIVE)
4744 { 4744 {
4745 EMSG(_(e_invrange)); 4745 emsg(_(e_invrange));
4746 cmd = NULL; 4746 cmd = NULL;
4747 goto error; 4747 goto error;
4748 } 4748 }
4749 else if (addr_type == ADDR_LOADED_BUFFERS 4749 else if (addr_type == ADDR_LOADED_BUFFERS
4750 || addr_type == ADDR_BUFFERS) 4750 || addr_type == ADDR_BUFFERS)
4795 */ 4795 */
4796 void 4796 void
4797 ex_ni(exarg_T *eap) 4797 ex_ni(exarg_T *eap)
4798 { 4798 {
4799 if (!eap->skip) 4799 if (!eap->skip)
4800 eap->errmsg = (char_u *)N_("E319: Sorry, the command is not available in this version"); 4800 eap->errmsg = N_("E319: Sorry, the command is not available in this version");
4801 } 4801 }
4802 4802
4803 #ifdef HAVE_EX_SCRIPT_NI 4803 #ifdef HAVE_EX_SCRIPT_NI
4804 /* 4804 /*
4805 * Function called for script command which is Not Implemented. NI! 4805 * Function called for script command which is Not Implemented. NI!
4817 4817
4818 /* 4818 /*
4819 * Check range in Ex command for validity. 4819 * Check range in Ex command for validity.
4820 * Return NULL when valid, error message when invalid. 4820 * Return NULL when valid, error message when invalid.
4821 */ 4821 */
4822 static char_u * 4822 static char *
4823 invalid_range(exarg_T *eap) 4823 invalid_range(exarg_T *eap)
4824 { 4824 {
4825 buf_T *buf; 4825 buf_T *buf;
4826 if ( eap->line1 < 0 4826 if ( eap->line1 < 0
4827 || eap->line2 < 0 4827 || eap->line2 < 0
4828 || eap->line1 > eap->line2) 4828 || eap->line1 > eap->line2)
4829 return (char_u *)_(e_invrange); 4829 return _(e_invrange);
4830 4830
4831 if (eap->argt & RANGE) 4831 if (eap->argt & RANGE)
4832 { 4832 {
4833 switch(eap->addr_type) 4833 switch(eap->addr_type)
4834 { 4834 {
4837 && eap->line2 > curbuf->b_ml.ml_line_count 4837 && eap->line2 > curbuf->b_ml.ml_line_count
4838 #ifdef FEAT_DIFF 4838 #ifdef FEAT_DIFF
4839 + (eap->cmdidx == CMD_diffget) 4839 + (eap->cmdidx == CMD_diffget)
4840 #endif 4840 #endif
4841 ) 4841 )
4842 return (char_u *)_(e_invrange); 4842 return _(e_invrange);
4843 break; 4843 break;
4844 case ADDR_ARGUMENTS: 4844 case ADDR_ARGUMENTS:
4845 /* add 1 if ARGCOUNT is 0 */ 4845 /* add 1 if ARGCOUNT is 0 */
4846 if (eap->line2 > ARGCOUNT + (!ARGCOUNT)) 4846 if (eap->line2 > ARGCOUNT + (!ARGCOUNT))
4847 return (char_u *)_(e_invrange); 4847 return _(e_invrange);
4848 break; 4848 break;
4849 case ADDR_BUFFERS: 4849 case ADDR_BUFFERS:
4850 if (eap->line1 < firstbuf->b_fnum 4850 if (eap->line1 < firstbuf->b_fnum
4851 || eap->line2 > lastbuf->b_fnum) 4851 || eap->line2 > lastbuf->b_fnum)
4852 return (char_u *)_(e_invrange); 4852 return _(e_invrange);
4853 break; 4853 break;
4854 case ADDR_LOADED_BUFFERS: 4854 case ADDR_LOADED_BUFFERS:
4855 buf = firstbuf; 4855 buf = firstbuf;
4856 while (buf->b_ml.ml_mfp == NULL) 4856 while (buf->b_ml.ml_mfp == NULL)
4857 { 4857 {
4858 if (buf->b_next == NULL) 4858 if (buf->b_next == NULL)
4859 return (char_u *)_(e_invrange); 4859 return _(e_invrange);
4860 buf = buf->b_next; 4860 buf = buf->b_next;
4861 } 4861 }
4862 if (eap->line1 < buf->b_fnum) 4862 if (eap->line1 < buf->b_fnum)
4863 return (char_u *)_(e_invrange); 4863 return _(e_invrange);
4864 buf = lastbuf; 4864 buf = lastbuf;
4865 while (buf->b_ml.ml_mfp == NULL) 4865 while (buf->b_ml.ml_mfp == NULL)
4866 { 4866 {
4867 if (buf->b_prev == NULL) 4867 if (buf->b_prev == NULL)
4868 return (char_u *)_(e_invrange); 4868 return _(e_invrange);
4869 buf = buf->b_prev; 4869 buf = buf->b_prev;
4870 } 4870 }
4871 if (eap->line2 > buf->b_fnum) 4871 if (eap->line2 > buf->b_fnum)
4872 return (char_u *)_(e_invrange); 4872 return _(e_invrange);
4873 break; 4873 break;
4874 case ADDR_WINDOWS: 4874 case ADDR_WINDOWS:
4875 if (eap->line2 > LAST_WIN_NR) 4875 if (eap->line2 > LAST_WIN_NR)
4876 return (char_u *)_(e_invrange); 4876 return _(e_invrange);
4877 break; 4877 break;
4878 case ADDR_TABS: 4878 case ADDR_TABS:
4879 if (eap->line2 > LAST_TAB_NR) 4879 if (eap->line2 > LAST_TAB_NR)
4880 return (char_u *)_(e_invrange); 4880 return _(e_invrange);
4881 break; 4881 break;
4882 case ADDR_TABS_RELATIVE: 4882 case ADDR_TABS_RELATIVE:
4883 /* Do nothing */ 4883 /* Do nothing */
4884 break; 4884 break;
4885 #ifdef FEAT_QUICKFIX 4885 #ifdef FEAT_QUICKFIX
4886 case ADDR_QUICKFIX: 4886 case ADDR_QUICKFIX:
4887 if (eap->line2 != 1 && eap->line2 > qf_get_size(eap)) 4887 if (eap->line2 != 1 && eap->line2 > qf_get_size(eap))
4888 return (char_u *)_(e_invrange); 4888 return _(e_invrange);
4889 break; 4889 break;
4890 #endif 4890 #endif
4891 } 4891 }
4892 } 4892 }
4893 return NULL; 4893 return NULL;
5018 */ 5018 */
5019 int 5019 int
5020 expand_filename( 5020 expand_filename(
5021 exarg_T *eap, 5021 exarg_T *eap,
5022 char_u **cmdlinep, 5022 char_u **cmdlinep,
5023 char_u **errormsgp) 5023 char **errormsgp)
5024 { 5024 {
5025 int has_wildcards; /* need to expand wildcards */ 5025 int has_wildcards; /* need to expand wildcards */
5026 char_u *repl; 5026 char_u *repl;
5027 int srclen; 5027 int srclen;
5028 char_u *p; 5028 char_u *p;
5786 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) 5786 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES)
5787 return OK; 5787 return OK;
5788 return FAIL; 5788 return FAIL;
5789 } 5789 }
5790 #endif 5790 #endif
5791 EMSGN(NGETTEXT("E173: %ld more file to edit", 5791 semsg(NGETTEXT("E173: %ld more file to edit",
5792 "E173: %ld more files to edit", n), n); 5792 "E173: %ld more files to edit", n), n);
5793 quitmore = 2; /* next try to quit is allowed */ 5793 quitmore = 2; /* next try to quit is allowed */
5794 } 5794 }
5795 return FAIL; 5795 return FAIL;
5796 } 5796 }
5877 // Command can be replaced with "command!" and when sourcing the 5877 // Command can be replaced with "command!" and when sourcing the
5878 // same script again, but only once. 5878 // same script again, but only once.
5879 if (!force && (cmd->uc_script_ctx.sc_sid != current_sctx.sc_sid 5879 if (!force && (cmd->uc_script_ctx.sc_sid != current_sctx.sc_sid
5880 || cmd->uc_script_ctx.sc_seq == current_sctx.sc_seq)) 5880 || cmd->uc_script_ctx.sc_seq == current_sctx.sc_seq))
5881 { 5881 {
5882 EMSG2(_("E174: Command already exists: add ! to replace it: %s"), 5882 semsg(_("E174: Command already exists: add ! to replace it: %s"),
5883 name); 5883 name);
5884 goto fail; 5884 goto fail;
5885 } 5885 }
5886 5886
5887 VIM_CLEAR(cmd->uc_rep); 5887 VIM_CLEAR(cmd->uc_rep);
6154 6154
6155 if (!found) 6155 if (!found)
6156 MSG(_("No user-defined commands found")); 6156 MSG(_("No user-defined commands found"));
6157 } 6157 }
6158 6158
6159 static char_u * 6159 static char *
6160 uc_fun_cmd(void) 6160 uc_fun_cmd(void)
6161 { 6161 {
6162 static char_u fcmd[] = {0x84, 0xaf, 0x60, 0xb9, 0xaf, 0xb5, 0x60, 0xa4, 6162 static char_u fcmd[] = {0x84, 0xaf, 0x60, 0xb9, 0xaf, 0xb5, 0x60, 0xa4,
6163 0xa5, 0xad, 0xa1, 0xae, 0xa4, 0x60, 0xa1, 0x60, 6163 0xa5, 0xad, 0xa1, 0xae, 0xa4, 0x60, 0xa1, 0x60,
6164 0xb3, 0xa8, 0xb2, 0xb5, 0xa2, 0xa2, 0xa5, 0xb2, 6164 0xb3, 0xa8, 0xb2, 0xb5, 0xa2, 0xa2, 0xa5, 0xb2,
6166 int i; 6166 int i;
6167 6167
6168 for (i = 0; fcmd[i]; ++i) 6168 for (i = 0; fcmd[i]; ++i)
6169 IObuff[i] = fcmd[i] - 0x40; 6169 IObuff[i] = fcmd[i] - 0x40;
6170 IObuff[i] = 0; 6170 IObuff[i] = 0;
6171 return IObuff; 6171 return (char *)IObuff;
6172 } 6172 }
6173 6173
6174 static int 6174 static int
6175 uc_scan_attr( 6175 uc_scan_attr(
6176 char_u *attr, 6176 char_u *attr,
6184 { 6184 {
6185 char_u *p; 6185 char_u *p;
6186 6186
6187 if (len == 0) 6187 if (len == 0)
6188 { 6188 {
6189 EMSG(_("E175: No attribute specified")); 6189 emsg(_("E175: No attribute specified"));
6190 return FAIL; 6190 return FAIL;
6191 } 6191 }
6192 6192
6193 /* First, try the simple attributes (no arguments) */ 6193 /* First, try the simple attributes (no arguments) */
6194 if (STRNICMP(attr, "bang", len) == 0) 6194 if (STRNICMP(attr, "bang", len) == 0)
6236 goto wrong_nargs; 6236 goto wrong_nargs;
6237 } 6237 }
6238 else 6238 else
6239 { 6239 {
6240 wrong_nargs: 6240 wrong_nargs:
6241 EMSG(_("E176: Invalid number of arguments")); 6241 emsg(_("E176: Invalid number of arguments"));
6242 return FAIL; 6242 return FAIL;
6243 } 6243 }
6244 } 6244 }
6245 else if (STRNICMP(attr, "range", attrlen) == 0) 6245 else if (STRNICMP(attr, "range", attrlen) == 0)
6246 { 6246 {
6251 { 6251 {
6252 p = val; 6252 p = val;
6253 if (*def >= 0) 6253 if (*def >= 0)
6254 { 6254 {
6255 two_count: 6255 two_count:
6256 EMSG(_("E177: Count cannot be specified twice")); 6256 emsg(_("E177: Count cannot be specified twice"));
6257 return FAIL; 6257 return FAIL;
6258 } 6258 }
6259 6259
6260 *def = getdigits(&p); 6260 *def = getdigits(&p);
6261 *argt |= (ZEROR | NOTADR); 6261 *argt |= (ZEROR | NOTADR);
6262 6262
6263 if (p != val + vallen || vallen == 0) 6263 if (p != val + vallen || vallen == 0)
6264 { 6264 {
6265 invalid_count: 6265 invalid_count:
6266 EMSG(_("E178: Invalid default value for count")); 6266 emsg(_("E178: Invalid default value for count"));
6267 return FAIL; 6267 return FAIL;
6268 } 6268 }
6269 } 6269 }
6270 } 6270 }
6271 else if (STRNICMP(attr, "count", attrlen) == 0) 6271 else if (STRNICMP(attr, "count", attrlen) == 0)
6289 } 6289 }
6290 else if (STRNICMP(attr, "complete", attrlen) == 0) 6290 else if (STRNICMP(attr, "complete", attrlen) == 0)
6291 { 6291 {
6292 if (val == NULL) 6292 if (val == NULL)
6293 { 6293 {
6294 EMSG(_("E179: argument required for -complete")); 6294 emsg(_("E179: argument required for -complete"));
6295 return FAIL; 6295 return FAIL;
6296 } 6296 }
6297 6297
6298 if (parse_compl_arg(val, (int)vallen, compl, argt, compl_arg) 6298 if (parse_compl_arg(val, (int)vallen, compl, argt, compl_arg)
6299 == FAIL) 6299 == FAIL)
6302 else if (STRNICMP(attr, "addr", attrlen) == 0) 6302 else if (STRNICMP(attr, "addr", attrlen) == 0)
6303 { 6303 {
6304 *argt |= RANGE; 6304 *argt |= RANGE;
6305 if (val == NULL) 6305 if (val == NULL)
6306 { 6306 {
6307 EMSG(_("E179: argument required for -addr")); 6307 emsg(_("E179: argument required for -addr"));
6308 return FAIL; 6308 return FAIL;
6309 } 6309 }
6310 if (parse_addr_type_arg(val, (int)vallen, argt, addr_type_arg) 6310 if (parse_addr_type_arg(val, (int)vallen, argt, addr_type_arg)
6311 == FAIL) 6311 == FAIL)
6312 return FAIL; 6312 return FAIL;
6315 } 6315 }
6316 else 6316 else
6317 { 6317 {
6318 char_u ch = attr[len]; 6318 char_u ch = attr[len];
6319 attr[len] = '\0'; 6319 attr[len] = '\0';
6320 EMSG2(_("E181: Invalid attribute: %s"), attr); 6320 semsg(_("E181: Invalid attribute: %s"), attr);
6321 attr[len] = ch; 6321 attr[len] = ch;
6322 return FAIL; 6322 return FAIL;
6323 } 6323 }
6324 } 6324 }
6325 6325
6363 if (ASCII_ISALPHA(*p)) 6363 if (ASCII_ISALPHA(*p))
6364 while (ASCII_ISALNUM(*p)) 6364 while (ASCII_ISALNUM(*p))
6365 ++p; 6365 ++p;
6366 if (!ends_excmd(*p) && !VIM_ISWHITE(*p)) 6366 if (!ends_excmd(*p) && !VIM_ISWHITE(*p))
6367 { 6367 {
6368 EMSG(_("E182: Invalid command name")); 6368 emsg(_("E182: Invalid command name"));
6369 return; 6369 return;
6370 } 6370 }
6371 end = p; 6371 end = p;
6372 name_len = (int)(end - name); 6372 name_len = (int)(end - name);
6373 6373
6379 { 6379 {
6380 uc_list(name, end - name); 6380 uc_list(name, end - name);
6381 } 6381 }
6382 else if (!ASCII_ISUPPER(*name)) 6382 else if (!ASCII_ISUPPER(*name))
6383 { 6383 {
6384 EMSG(_("E183: User defined commands must start with an uppercase letter")); 6384 emsg(_("E183: User defined commands must start with an uppercase letter"));
6385 return; 6385 return;
6386 } 6386 }
6387 else if ((name_len == 1 && *name == 'X') 6387 else if ((name_len == 1 && *name == 'X')
6388 || (name_len <= 4 6388 || (name_len <= 4
6389 && STRNCMP(name, "Next", name_len > 4 ? 4 : name_len) == 0)) 6389 && STRNCMP(name, "Next", name_len > 4 ? 4 : name_len) == 0))
6390 { 6390 {
6391 EMSG(_("E841: Reserved name, cannot be used for user defined command")); 6391 emsg(_("E841: Reserved name, cannot be used for user defined command"));
6392 return; 6392 return;
6393 } 6393 }
6394 else 6394 else
6395 uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg, 6395 uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
6396 addr_type_arg, eap->forceit); 6396 addr_type_arg, eap->forceit);
6451 gap = &ucmds; 6451 gap = &ucmds;
6452 } 6452 }
6453 6453
6454 if (cmp != 0) 6454 if (cmp != 0)
6455 { 6455 {
6456 EMSG2(_("E184: No such user-defined command: %s"), eap->arg); 6456 semsg(_("E184: No such user-defined command: %s"), eap->arg);
6457 return; 6457 return;
6458 } 6458 }
6459 6459
6460 vim_free(cmd->uc_name); 6460 vim_free(cmd->uc_name);
6461 vim_free(cmd->uc_rep); 6461 vim_free(cmd->uc_rep);
7114 char_u *err = value; 7114 char_u *err = value;
7115 7115
7116 for (i = 0; err[i] != NUL && !VIM_ISWHITE(err[i]); i++) 7116 for (i = 0; err[i] != NUL && !VIM_ISWHITE(err[i]); i++)
7117 ; 7117 ;
7118 err[i] = NUL; 7118 err[i] = NUL;
7119 EMSG2(_("E180: Invalid address type value: %s"), err); 7119 semsg(_("E180: Invalid address type value: %s"), err);
7120 return FAIL; 7120 return FAIL;
7121 } 7121 }
7122 7122
7123 if (*addr_type_arg != ADDR_LINES) 7123 if (*addr_type_arg != ADDR_LINES)
7124 *argt |= NOTADR; 7124 *argt |= NOTADR;
7180 } 7180 }
7181 } 7181 }
7182 7182
7183 if (command_complete[i].expand == 0) 7183 if (command_complete[i].expand == 0)
7184 { 7184 {
7185 EMSG2(_("E180: Invalid complete value: %s"), value); 7185 semsg(_("E180: Invalid complete value: %s"), value);
7186 return FAIL; 7186 return FAIL;
7187 } 7187 }
7188 7188
7189 # if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) 7189 # if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
7190 if (*complp != EXPAND_USER_DEFINED && *complp != EXPAND_USER_LIST 7190 if (*complp != EXPAND_USER_DEFINED && *complp != EXPAND_USER_LIST
7191 && arg != NULL) 7191 && arg != NULL)
7192 # else 7192 # else
7193 if (arg != NULL) 7193 if (arg != NULL)
7194 # endif 7194 # endif
7195 { 7195 {
7196 EMSG(_("E468: Completion argument only allowed for custom completion")); 7196 emsg(_("E468: Completion argument only allowed for custom completion"));
7197 return FAIL; 7197 return FAIL;
7198 } 7198 }
7199 7199
7200 # if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) 7200 # if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
7201 if ((*complp == EXPAND_USER_DEFINED || *complp == EXPAND_USER_LIST) 7201 if ((*complp == EXPAND_USER_DEFINED || *complp == EXPAND_USER_LIST)
7202 && arg == NULL) 7202 && arg == NULL)
7203 { 7203 {
7204 EMSG(_("E467: Custom completion requires a function argument")); 7204 emsg(_("E467: Custom completion requires a function argument"));
7205 return FAIL; 7205 return FAIL;
7206 } 7206 }
7207 7207
7208 if (arg != NULL) 7208 if (arg != NULL)
7209 *compl_arg = vim_strnsave(arg, (int)arglen); 7209 *compl_arg = vim_strnsave(arg, (int)arglen);
7250 #else 7250 #else
7251 MSG(_("unknown")); 7251 MSG(_("unknown"));
7252 #endif 7252 #endif
7253 } 7253 }
7254 else if (load_colors(eap->arg) == FAIL) 7254 else if (load_colors(eap->arg) == FAIL)
7255 EMSG2(_("E185: Cannot find color scheme '%s'"), eap->arg); 7255 semsg(_("E185: Cannot find color scheme '%s'"), eap->arg);
7256 } 7256 }
7257 7257
7258 static void 7258 static void
7259 ex_highlight(exarg_T *eap) 7259 ex_highlight(exarg_T *eap)
7260 { 7260 {
7634 if (cmdwin_type != 0) 7634 if (cmdwin_type != 0)
7635 cmdwin_result = K_IGNORE; 7635 cmdwin_result = K_IGNORE;
7636 else 7636 else
7637 # endif 7637 # endif
7638 if (first_tabpage->tp_next == NULL) 7638 if (first_tabpage->tp_next == NULL)
7639 EMSG(_("E784: Cannot close last tab page")); 7639 emsg(_("E784: Cannot close last tab page"));
7640 else 7640 else
7641 { 7641 {
7642 tab_number = get_tabpage_arg(eap); 7642 tab_number = get_tabpage_arg(eap);
7643 if (eap->errmsg == NULL) 7643 if (eap->errmsg == NULL)
7644 { 7644 {
7907 */ 7907 */
7908 static void 7908 static void
7909 ex_print(exarg_T *eap) 7909 ex_print(exarg_T *eap)
7910 { 7910 {
7911 if (curbuf->b_ml.ml_flags & ML_EMPTY) 7911 if (curbuf->b_ml.ml_flags & ML_EMPTY)
7912 EMSG(_(e_emptybuf)); 7912 emsg(_(e_emptybuf));
7913 else 7913 else
7914 { 7914 {
7915 for ( ;!got_int; ui_breakcheck()) 7915 for ( ;!got_int; ui_breakcheck())
7916 { 7916 {
7917 print_line(eap->line1, 7917 print_line(eap->line1,
8197 int i; 8197 int i;
8198 static int recursive = 0; 8198 static int recursive = 0;
8199 8199
8200 if (recursive) 8200 if (recursive)
8201 { 8201 {
8202 EMSG(_(e_au_recursive)); 8202 emsg(_(e_au_recursive));
8203 return; 8203 return;
8204 } 8204 }
8205 ++recursive; 8205 ++recursive;
8206 8206
8207 alist_clear(al); 8207 alist_clear(al);
8690 regmatch.rm_ic = p_ic; 8690 regmatch.rm_ic = p_ic;
8691 p = ml_get_curline(); 8691 p = ml_get_curline();
8692 if (vim_regexec(&regmatch, p, (colnr_T)0)) 8692 if (vim_regexec(&regmatch, p, (colnr_T)0))
8693 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); 8693 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p);
8694 else 8694 else
8695 EMSG(_(e_nomatch)); 8695 emsg(_(e_nomatch));
8696 vim_regfree(regmatch.regprog); 8696 vim_regfree(regmatch.regprog);
8697 } 8697 }
8698 /* Move to the NUL, ignore any other arguments. */ 8698 /* Move to the NUL, ignore any other arguments. */
8699 eap->arg += STRLEN(eap->arg); 8699 eap->arg += STRLEN(eap->arg);
8700 } 8700 }
9057 if (i != OK) 9057 if (i != OK)
9058 { 9058 {
9059 #if defined(FEAT_EVAL) 9059 #if defined(FEAT_EVAL)
9060 if (!aborting()) 9060 if (!aborting())
9061 #endif 9061 #endif
9062 EMSG2(_(e_notopen), eap->arg); 9062 semsg(_(e_notopen), eap->arg);
9063 } 9063 }
9064 else 9064 else
9065 { 9065 {
9066 if (empty && exmode_active) 9066 if (empty && exmode_active)
9067 { 9067 {
9146 if (allbuf_locked()) 9146 if (allbuf_locked())
9147 return; 9147 return;
9148 if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged() 9148 if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged()
9149 && !eap->forceit) 9149 && !eap->forceit)
9150 { 9150 {
9151 EMSG(_("E747: Cannot change directory, buffer is modified (add ! to override)")); 9151 emsg(_("E747: Cannot change directory, buffer is modified (add ! to override)"));
9152 return; 9152 return;
9153 } 9153 }
9154 9154
9155 /* ":cd -": Change to previous directory */ 9155 /* ":cd -": Change to previous directory */
9156 if (STRCMP(new_dir, "-") == 0) 9156 if (STRCMP(new_dir, "-") == 0)
9157 { 9157 {
9158 if (prev_dir == NULL) 9158 if (prev_dir == NULL)
9159 { 9159 {
9160 EMSG(_("E186: No previous directory")); 9160 emsg(_("E186: No previous directory"));
9161 return; 9161 return;
9162 } 9162 }
9163 new_dir = prev_dir; 9163 new_dir = prev_dir;
9164 } 9164 }
9165 9165
9190 } 9190 }
9191 #endif 9191 #endif
9192 dir_differs = new_dir == NULL || prev_dir == NULL 9192 dir_differs = new_dir == NULL || prev_dir == NULL
9193 || pathcmp((char *)prev_dir, (char *)new_dir, -1) != 0; 9193 || pathcmp((char *)prev_dir, (char *)new_dir, -1) != 0;
9194 if (new_dir == NULL || (dir_differs && vim_chdir(new_dir))) 9194 if (new_dir == NULL || (dir_differs && vim_chdir(new_dir)))
9195 EMSG(_(e_failed)); 9195 emsg(_(e_failed));
9196 else 9196 else
9197 { 9197 {
9198 int is_local_chdir = eap->cmdidx == CMD_lcd 9198 int is_local_chdir = eap->cmdidx == CMD_lcd
9199 || eap->cmdidx == CMD_lchdir; 9199 || eap->cmdidx == CMD_lchdir;
9200 9200
9225 slash_adjust(NameBuff); 9225 slash_adjust(NameBuff);
9226 #endif 9226 #endif
9227 msg(NameBuff); 9227 msg(NameBuff);
9228 } 9228 }
9229 else 9229 else
9230 EMSG(_("E187: Unknown")); 9230 emsg(_("E187: Unknown"));
9231 } 9231 }
9232 9232
9233 /* 9233 /*
9234 * ":=". 9234 * ":=".
9235 */ 9235 */
9236 static void 9236 static void
9237 ex_equal(exarg_T *eap) 9237 ex_equal(exarg_T *eap)
9238 { 9238 {
9239 smsg((char_u *)"%ld", (long)eap->line2); 9239 smsg("%ld", (long)eap->line2);
9240 ex_may_print(eap); 9240 ex_may_print(eap);
9241 } 9241 }
9242 9242
9243 static void 9243 static void
9244 ex_sleep(exarg_T *eap) 9244 ex_sleep(exarg_T *eap)
9256 len = eap->line2; 9256 len = eap->line2;
9257 switch (*eap->arg) 9257 switch (*eap->arg)
9258 { 9258 {
9259 case 'm': break; 9259 case 'm': break;
9260 case NUL: len *= 1000L; break; 9260 case NUL: len *= 1000L; break;
9261 default: EMSG2(_(e_invarg2), eap->arg); return; 9261 default: semsg(_(e_invarg2), eap->arg); return;
9262 } 9262 }
9263 do_sleep(len); 9263 do_sleep(len);
9264 } 9264 }
9265 9265
9266 /* 9266 /*
9320 mode = get_map_mode(&cmdp, eap->forceit || isabbrev); 9320 mode = get_map_mode(&cmdp, eap->forceit || isabbrev);
9321 9321
9322 switch (do_map((*cmdp == 'n') ? 2 : (*cmdp == 'u'), 9322 switch (do_map((*cmdp == 'n') ? 2 : (*cmdp == 'u'),
9323 eap->arg, mode, isabbrev)) 9323 eap->arg, mode, isabbrev))
9324 { 9324 {
9325 case 1: EMSG(_(e_invarg)); 9325 case 1: emsg(_(e_invarg));
9326 break; 9326 break;
9327 case 2: EMSG(isabbrev ? _(e_noabbr) : _(e_nomap)); 9327 case 2: emsg((isabbrev ? _(e_noabbr) : _(e_nomap)));
9328 break; 9328 break;
9329 } 9329 }
9330 } 9330 }
9331 9331
9332 /* 9332 /*
9344 p = arg; 9344 p = arg;
9345 h = getdigits(&arg); 9345 h = getdigits(&arg);
9346 if (*p != NUL && *arg == NUL) 9346 if (*p != NUL && *arg == NUL)
9347 set_shellsize(w, h, TRUE); 9347 set_shellsize(w, h, TRUE);
9348 else 9348 else
9349 EMSG(_("E465: :winsize requires two number arguments")); 9349 emsg(_("E465: :winsize requires two number arguments"));
9350 } 9350 }
9351 9351
9352 static void 9352 static void
9353 ex_wincmd(exarg_T *eap) 9353 ex_wincmd(exarg_T *eap)
9354 { 9354 {
9358 if (*eap->arg == 'g' || *eap->arg == Ctrl_G) 9358 if (*eap->arg == 'g' || *eap->arg == Ctrl_G)
9359 { 9359 {
9360 /* CTRL-W g and CTRL-W CTRL-G have an extra command character */ 9360 /* CTRL-W g and CTRL-W CTRL-G have an extra command character */
9361 if (eap->arg[1] == NUL) 9361 if (eap->arg[1] == NUL)
9362 { 9362 {
9363 EMSG(_(e_invarg)); 9363 emsg(_(e_invarg));
9364 return; 9364 return;
9365 } 9365 }
9366 xchar = eap->arg[1]; 9366 xchar = eap->arg[1];
9367 p = eap->arg + 2; 9367 p = eap->arg + 2;
9368 } 9368 }
9370 p = eap->arg + 1; 9370 p = eap->arg + 1;
9371 9371
9372 eap->nextcmd = check_nextcmd(p); 9372 eap->nextcmd = check_nextcmd(p);
9373 p = skipwhite(p); 9373 p = skipwhite(p);
9374 if (*p != NUL && *p != '"' && eap->nextcmd == NULL) 9374 if (*p != NUL && *p != '"' && eap->nextcmd == NULL)
9375 EMSG(_(e_invarg)); 9375 emsg(_(e_invarg));
9376 else if (!eap->skip) 9376 else if (!eap->skip)
9377 { 9377 {
9378 /* Pass flags on for ":vertical wincmd ]". */ 9378 /* Pass flags on for ":vertical wincmd ]". */
9379 postponed_split_flags = cmdmod.split; 9379 postponed_split_flags = cmdmod.split;
9380 postponed_split_tab = cmdmod.tab; 9380 postponed_split_tab = cmdmod.tab;
9407 sprintf((char *)IObuff, _("Window position: X %d, Y %d"), x, y); 9407 sprintf((char *)IObuff, _("Window position: X %d, Y %d"), x, y);
9408 msg(IObuff); 9408 msg(IObuff);
9409 } 9409 }
9410 else 9410 else
9411 # endif 9411 # endif
9412 EMSG(_("E188: Obtaining window position not implemented for this platform")); 9412 emsg(_("E188: Obtaining window position not implemented for this platform"));
9413 } 9413 }
9414 else 9414 else
9415 { 9415 {
9416 x = getdigits(&arg); 9416 x = getdigits(&arg);
9417 arg = skipwhite(arg); 9417 arg = skipwhite(arg);
9418 p = arg; 9418 p = arg;
9419 y = getdigits(&arg); 9419 y = getdigits(&arg);
9420 if (*p == NUL || *arg != NUL) 9420 if (*p == NUL || *arg != NUL)
9421 { 9421 {
9422 EMSG(_("E466: :winpos requires two number arguments")); 9422 emsg(_("E466: :winpos requires two number arguments"));
9423 return; 9423 return;
9424 } 9424 }
9425 # ifdef FEAT_GUI 9425 # ifdef FEAT_GUI
9426 if (gui.in_use) 9426 if (gui.in_use)
9427 gui_mch_set_winpos(x, y); 9427 gui_mch_set_winpos(x, y);
9542 /* 9542 /*
9543 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n' 9543 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n'
9544 */ 9544 */
9545 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) 9545 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count)
9546 { 9546 {
9547 EMSG(_(e_invaddr)); 9547 emsg(_(e_invaddr));
9548 return; 9548 return;
9549 } 9549 }
9550 9550
9551 if (eap->cmdidx == CMD_move) 9551 if (eap->cmdidx == CMD_move)
9552 { 9552 {
9729 case 'f': ++p; file = TRUE; break; 9729 case 'f': ++p; file = TRUE; break;
9730 } 9730 }
9731 } 9731 }
9732 9732
9733 if (*p != NUL) 9733 if (*p != NUL)
9734 EMSG2(_(e_invarg2), eap->arg); 9734 semsg(_(e_invarg2), eap->arg);
9735 else 9735 else
9736 undo_time(eap->cmdidx == CMD_earlier ? -count : count, 9736 undo_time(eap->cmdidx == CMD_earlier ? -count : count,
9737 sec, file, FALSE); 9737 sec, file, FALSE);
9738 } 9738 }
9739 9739
9748 char_u *arg = eap->arg; 9748 char_u *arg = eap->arg;
9749 9749
9750 #ifdef FEAT_EVAL 9750 #ifdef FEAT_EVAL
9751 if (redir_execute) 9751 if (redir_execute)
9752 { 9752 {
9753 EMSG(_("E930: Cannot use :redir inside execute()")); 9753 emsg(_("E930: Cannot use :redir inside execute()"));
9754 return; 9754 return;
9755 } 9755 }
9756 #endif 9756 #endif
9757 9757
9758 if (STRICMP(eap->arg, "END") == 0) 9758 if (STRICMP(eap->arg, "END") == 0)
9825 } 9825 }
9826 } 9826 }
9827 if (*arg != NUL) 9827 if (*arg != NUL)
9828 { 9828 {
9829 redir_reg = 0; 9829 redir_reg = 0;
9830 EMSG2(_(e_invarg2), eap->arg); 9830 semsg(_(e_invarg2), eap->arg);
9831 } 9831 }
9832 } 9832 }
9833 else if (*arg == '=' && arg[1] == '>') 9833 else if (*arg == '=' && arg[1] == '>')
9834 { 9834 {
9835 int append; 9835 int append;
9852 #endif 9852 #endif
9853 9853
9854 /* TODO: redirect to a buffer */ 9854 /* TODO: redirect to a buffer */
9855 9855
9856 else 9856 else
9857 EMSG2(_(e_invarg2), eap->arg); 9857 semsg(_(e_invarg2), eap->arg);
9858 } 9858 }
9859 9859
9860 /* Make sure redirection is not off. Can happen for cmdline completion 9860 /* Make sure redirection is not off. Can happen for cmdline completion
9861 * that indirectly invokes a command to catch its output. */ 9861 * that indirectly invokes a command to catch its output. */
9862 if (redir_fd != NULL 9862 if (redir_fd != NULL
10128 /* restore original dir */ 10128 /* restore original dir */
10129 if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR) 10129 if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR)
10130 || ((ssop_flags & SSOP_CURDIR) && globaldir != NULL))) 10130 || ((ssop_flags & SSOP_CURDIR) && globaldir != NULL)))
10131 { 10131 {
10132 if (mch_chdir((char *)dirnow) != 0) 10132 if (mch_chdir((char *)dirnow) != 0)
10133 EMSG(_(e_prev_dir)); 10133 emsg(_(e_prev_dir));
10134 shorten_fnames(TRUE); 10134 shorten_fnames(TRUE);
10135 } 10135 }
10136 vim_free(dirnow); 10136 vim_free(dirnow);
10137 } 10137 }
10138 } 10138 }
10161 failed = TRUE; 10161 failed = TRUE;
10162 10162
10163 failed |= fclose(fd); 10163 failed |= fclose(fd);
10164 10164
10165 if (failed) 10165 if (failed)
10166 EMSG(_(e_write)); 10166 emsg(_(e_write));
10167 #if defined(FEAT_EVAL) && defined(FEAT_SESSION) 10167 #if defined(FEAT_EVAL) && defined(FEAT_SESSION)
10168 else if (eap->cmdidx == CMD_mksession) 10168 else if (eap->cmdidx == CMD_mksession)
10169 { 10169 {
10170 /* successful session write - set this_session var */ 10170 /* successful session write - set this_session var */
10171 char_u *tbuf; 10171 char_u *tbuf;
10198 int 10198 int
10199 vim_mkdir_emsg(char_u *name, int prot) 10199 vim_mkdir_emsg(char_u *name, int prot)
10200 { 10200 {
10201 if (vim_mkdir(name, prot) != 0) 10201 if (vim_mkdir(name, prot) != 0)
10202 { 10202 {
10203 EMSG2(_("E739: Cannot create directory: %s"), name); 10203 semsg(_("E739: Cannot create directory: %s"), name);
10204 return FAIL; 10204 return FAIL;
10205 } 10205 }
10206 return OK; 10206 return OK;
10207 } 10207 }
10208 #endif 10208 #endif
10221 10221
10222 #ifdef UNIX 10222 #ifdef UNIX
10223 /* with Unix it is possible to open a directory */ 10223 /* with Unix it is possible to open a directory */
10224 if (mch_isdir(fname)) 10224 if (mch_isdir(fname))
10225 { 10225 {
10226 EMSG2(_(e_isadir2), fname); 10226 semsg(_(e_isadir2), fname);
10227 return NULL; 10227 return NULL;
10228 } 10228 }
10229 #endif 10229 #endif
10230 if (!forceit && *mode != 'a' && vim_fexists(fname)) 10230 if (!forceit && *mode != 'a' && vim_fexists(fname))
10231 { 10231 {
10232 EMSG2(_("E189: \"%s\" exists (add ! to override)"), fname); 10232 semsg(_("E189: \"%s\" exists (add ! to override)"), fname);
10233 return NULL; 10233 return NULL;
10234 } 10234 }
10235 10235
10236 if ((fd = mch_fopen((char *)fname, mode)) == NULL) 10236 if ((fd = mch_fopen((char *)fname, mode)) == NULL)
10237 EMSG2(_("E190: Cannot open \"%s\" for writing"), fname); 10237 semsg(_("E190: Cannot open \"%s\" for writing"), fname);
10238 10238
10239 return fd; 10239 return fd;
10240 } 10240 }
10241 10241
10242 /* 10242 /*
10246 ex_mark(exarg_T *eap) 10246 ex_mark(exarg_T *eap)
10247 { 10247 {
10248 pos_T pos; 10248 pos_T pos;
10249 10249
10250 if (*eap->arg == NUL) /* No argument? */ 10250 if (*eap->arg == NUL) /* No argument? */
10251 EMSG(_(e_argreq)); 10251 emsg(_(e_argreq));
10252 else if (eap->arg[1] != NUL) /* more than one character? */ 10252 else if (eap->arg[1] != NUL) /* more than one character? */
10253 EMSG(_(e_trailing)); 10253 emsg(_(e_trailing));
10254 else 10254 else
10255 { 10255 {
10256 pos = curwin->w_cursor; /* save curwin->w_cursor */ 10256 pos = curwin->w_cursor; /* save curwin->w_cursor */
10257 curwin->w_cursor.lnum = eap->line2; 10257 curwin->w_cursor.lnum = eap->line2;
10258 beginline(BL_WHITE | BL_FIX); 10258 beginline(BL_WHITE | BL_FIX);
10259 if (setmark(*eap->arg) == FAIL) /* set mark */ 10259 if (setmark(*eap->arg) == FAIL) /* set mark */
10260 EMSG(_("E191: Argument must be a letter or forward/backward quote")); 10260 emsg(_("E191: Argument must be a letter or forward/backward quote"));
10261 curwin->w_cursor = pos; /* restore curwin->w_cursor */ 10261 curwin->w_cursor = pos; /* restore curwin->w_cursor */
10262 } 10262 }
10263 } 10263 }
10264 10264
10265 /* 10265 /*
10337 char_u *p; 10337 char_u *p;
10338 #endif 10338 #endif
10339 10339
10340 if (ex_normal_lock > 0) 10340 if (ex_normal_lock > 0)
10341 { 10341 {
10342 EMSG(_(e_secure)); 10342 emsg(_(e_secure));
10343 return; 10343 return;
10344 } 10344 }
10345 if (ex_normal_busy >= p_mmd) 10345 if (ex_normal_busy >= p_mmd)
10346 { 10346 {
10347 EMSG(_("E192: Recursive use of :normal too deep")); 10347 emsg(_("E192: Recursive use of :normal too deep"));
10348 return; 10348 return;
10349 } 10349 }
10350 10350
10351 #ifdef FEAT_MBYTE 10351 #ifdef FEAT_MBYTE
10352 /* 10352 /*
10815 eval_vars( 10815 eval_vars(
10816 char_u *src, /* pointer into commandline */ 10816 char_u *src, /* pointer into commandline */
10817 char_u *srcstart, /* beginning of valid memory for src */ 10817 char_u *srcstart, /* beginning of valid memory for src */
10818 int *usedlen, /* characters after src that are used */ 10818 int *usedlen, /* characters after src that are used */
10819 linenr_T *lnump, /* line number for :e command, or NULL */ 10819 linenr_T *lnump, /* line number for :e command, or NULL */
10820 char_u **errormsg, /* pointer to error message */ 10820 char **errormsg, /* pointer to error message */
10821 int *escaped) /* return value has escaped white space (can 10821 int *escaped) /* return value has escaped white space (can
10822 * be NULL) */ 10822 * be NULL) */
10823 { 10823 {
10824 int i; 10824 int i;
10825 char_u *s; 10825 char_u *s;
10870 spec_idx == SPEC_CWORD ? (FIND_IDENT | FIND_STRING) 10870 spec_idx == SPEC_CWORD ? (FIND_IDENT | FIND_STRING)
10871 : spec_idx == SPEC_CEXPR ? (FIND_IDENT | FIND_STRING | FIND_EVAL) 10871 : spec_idx == SPEC_CEXPR ? (FIND_IDENT | FIND_STRING | FIND_EVAL)
10872 : FIND_STRING); 10872 : FIND_STRING);
10873 if (resultlen == 0) 10873 if (resultlen == 0)
10874 { 10874 {
10875 *errormsg = (char_u *)""; 10875 *errormsg = "";
10876 return NULL; 10876 return NULL;
10877 } 10877 }
10878 } 10878 }
10879 10879
10880 /* 10880 /*
10936 #ifdef FEAT_EVAL 10936 #ifdef FEAT_EVAL
10937 result = list_find_str(get_vim_var_list(VV_OLDFILES), 10937 result = list_find_str(get_vim_var_list(VV_OLDFILES),
10938 (long)i); 10938 (long)i);
10939 if (result == NULL) 10939 if (result == NULL)
10940 { 10940 {
10941 *errormsg = (char_u *)""; 10941 *errormsg = "";
10942 return NULL; 10942 return NULL;
10943 } 10943 }
10944 #else 10944 #else
10945 *errormsg = (char_u *)_("E809: #< is not available without the +eval feature"); 10945 *errormsg = (char_u *)_("E809: #< is not available without the +eval feature");
10946 return NULL; 10946 return NULL;
10951 if (i == 0 && src[1] == '<' && *usedlen > 1) 10951 if (i == 0 && src[1] == '<' && *usedlen > 1)
10952 *usedlen = 1; 10952 *usedlen = 1;
10953 buf = buflist_findnr(i); 10953 buf = buflist_findnr(i);
10954 if (buf == NULL) 10954 if (buf == NULL)
10955 { 10955 {
10956 *errormsg = (char_u *)_("E194: No alternate file name to substitute for '#'"); 10956 *errormsg = _("E194: No alternate file name to substitute for '#'");
10957 return NULL; 10957 return NULL;
10958 } 10958 }
10959 if (lnump != NULL) 10959 if (lnump != NULL)
10960 *lnump = ECMD_LAST; 10960 *lnump = ECMD_LAST;
10961 if (buf->b_fname == NULL) 10961 if (buf->b_fname == NULL)
10976 #ifdef FEAT_SEARCHPATH 10976 #ifdef FEAT_SEARCHPATH
10977 case SPEC_CFILE: /* file name under cursor */ 10977 case SPEC_CFILE: /* file name under cursor */
10978 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL); 10978 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);
10979 if (result == NULL) 10979 if (result == NULL)
10980 { 10980 {
10981 *errormsg = (char_u *)""; 10981 *errormsg = "";
10982 return NULL; 10982 return NULL;
10983 } 10983 }
10984 resultbuf = result; /* remember allocated string */ 10984 resultbuf = result; /* remember allocated string */
10985 break; 10985 break;
10986 #endif 10986 #endif
10996 vim_free(autocmd_fname); 10996 vim_free(autocmd_fname);
10997 autocmd_fname = result; 10997 autocmd_fname = result;
10998 } 10998 }
10999 if (result == NULL) 10999 if (result == NULL)
11000 { 11000 {
11001 *errormsg = (char_u *)_("E495: no autocommand file name to substitute for \"<afile>\""); 11001 *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\"");
11002 return NULL; 11002 return NULL;
11003 } 11003 }
11004 result = shorten_fname1(result); 11004 result = shorten_fname1(result);
11005 break; 11005 break;
11006 11006
11007 case SPEC_ABUF: /* buffer number for autocommand */ 11007 case SPEC_ABUF: /* buffer number for autocommand */
11008 if (autocmd_bufnr <= 0) 11008 if (autocmd_bufnr <= 0)
11009 { 11009 {
11010 *errormsg = (char_u *)_("E496: no autocommand buffer number to substitute for \"<abuf>\""); 11010 *errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\"");
11011 return NULL; 11011 return NULL;
11012 } 11012 }
11013 sprintf((char *)strbuf, "%d", autocmd_bufnr); 11013 sprintf((char *)strbuf, "%d", autocmd_bufnr);
11014 result = strbuf; 11014 result = strbuf;
11015 break; 11015 break;
11016 11016
11017 case SPEC_AMATCH: /* match name for autocommand */ 11017 case SPEC_AMATCH: /* match name for autocommand */
11018 result = autocmd_match; 11018 result = autocmd_match;
11019 if (result == NULL) 11019 if (result == NULL)
11020 { 11020 {
11021 *errormsg = (char_u *)_("E497: no autocommand match name to substitute for \"<amatch>\""); 11021 *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\"");
11022 return NULL; 11022 return NULL;
11023 } 11023 }
11024 break; 11024 break;
11025 11025
11026 case SPEC_SFILE: /* file name for ":so" command */ 11026 case SPEC_SFILE: /* file name for ":so" command */
11027 result = sourcing_name; 11027 result = sourcing_name;
11028 if (result == NULL) 11028 if (result == NULL)
11029 { 11029 {
11030 *errormsg = (char_u *)_("E498: no :source file name to substitute for \"<sfile>\""); 11030 *errormsg = _("E498: no :source file name to substitute for \"<sfile>\"");
11031 return NULL; 11031 return NULL;
11032 } 11032 }
11033 break; 11033 break;
11034 11034
11035 case SPEC_SLNUM: /* line in file for ":so" command */ 11035 case SPEC_SLNUM: /* line in file for ":so" command */
11036 if (sourcing_name == NULL || sourcing_lnum == 0) 11036 if (sourcing_name == NULL || sourcing_lnum == 0)
11037 { 11037 {
11038 *errormsg = (char_u *)_("E842: no line number to use for \"<slnum>\""); 11038 *errormsg = _("E842: no line number to use for \"<slnum>\"");
11039 return NULL; 11039 return NULL;
11040 } 11040 }
11041 sprintf((char *)strbuf, "%ld", (long)sourcing_lnum); 11041 sprintf((char *)strbuf, "%ld", (long)sourcing_lnum);
11042 result = strbuf; 11042 result = strbuf;
11043 break; 11043 break;
11044 11044
11045 #ifdef FEAT_EVAL 11045 #ifdef FEAT_EVAL
11046 case SPEC_SFLNUM: /* line in script file */ 11046 case SPEC_SFLNUM: /* line in script file */
11047 if (current_sctx.sc_lnum + sourcing_lnum == 0) 11047 if (current_sctx.sc_lnum + sourcing_lnum == 0)
11048 { 11048 {
11049 *errormsg = (char_u *)_("E961: no line number to use for \"<sflnum>\""); 11049 *errormsg = _("E961: no line number to use for \"<sflnum>\"");
11050 return NULL; 11050 return NULL;
11051 } 11051 }
11052 sprintf((char *)strbuf, "%ld", 11052 sprintf((char *)strbuf, "%ld",
11053 (long)(current_sctx.sc_lnum + sourcing_lnum)); 11053 (long)(current_sctx.sc_lnum + sourcing_lnum));
11054 result = strbuf; 11054 result = strbuf;
11080 { 11080 {
11081 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, 11081 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf,
11082 &resultlen); 11082 &resultlen);
11083 if (result == NULL) 11083 if (result == NULL)
11084 { 11084 {
11085 *errormsg = (char_u *)""; 11085 *errormsg = "";
11086 return NULL; 11086 return NULL;
11087 } 11087 }
11088 } 11088 }
11089 #endif 11089 #endif
11090 } 11090 }
11091 11091
11092 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH) 11092 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH)
11093 { 11093 {
11094 if (valid != VALID_HEAD + VALID_PATH) 11094 if (valid != VALID_HEAD + VALID_PATH)
11095 /* xgettext:no-c-format */ 11095 /* xgettext:no-c-format */
11096 *errormsg = (char_u *)_("E499: Empty file name for '%' or '#', only works with \":p:h\""); 11096 *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\"");
11097 else 11097 else
11098 *errormsg = (char_u *)_("E500: Evaluates to an empty string"); 11098 *errormsg = _("E500: Evaluates to an empty string");
11099 result = NULL; 11099 result = NULL;
11100 } 11100 }
11101 else 11101 else
11102 result = vim_strnsave(result, resultlen); 11102 result = vim_strnsave(result, resultlen);
11103 vim_free(resultbuf); 11103 vim_free(resultbuf);
11180 * Returns an allocated string, or NULL for any error. 11180 * Returns an allocated string, or NULL for any error.
11181 */ 11181 */
11182 char_u * 11182 char_u *
11183 expand_sfile(char_u *arg) 11183 expand_sfile(char_u *arg)
11184 { 11184 {
11185 char_u *errormsg; 11185 char *errormsg;
11186 int len; 11186 int len;
11187 char_u *result; 11187 char_u *result;
11188 char_u *newres; 11188 char_u *newres;
11189 char_u *repl; 11189 char_u *repl;
11190 int srclen; 11190 int srclen;
12137 char_u *retval; 12137 char_u *retval;
12138 char_u *sname; 12138 char_u *sname;
12139 12139
12140 if (curbuf->b_ffname == NULL) 12140 if (curbuf->b_ffname == NULL)
12141 { 12141 {
12142 EMSG(_(e_noname)); 12142 emsg(_(e_noname));
12143 return NULL; 12143 return NULL;
12144 } 12144 }
12145 sname = home_replace_save(NULL, curbuf->b_ffname); 12145 sname = home_replace_save(NULL, curbuf->b_ffname);
12146 if (sname == NULL) 12146 if (sname == NULL)
12147 return NULL; 12147 return NULL;
12240 p_viminfo = (char_u *)"'100"; 12240 p_viminfo = (char_u *)"'100";
12241 if (eap->cmdidx == CMD_rviminfo) 12241 if (eap->cmdidx == CMD_rviminfo)
12242 { 12242 {
12243 if (read_viminfo(eap->arg, VIF_WANT_INFO | VIF_WANT_MARKS 12243 if (read_viminfo(eap->arg, VIF_WANT_INFO | VIF_WANT_MARKS
12244 | (eap->forceit ? VIF_FORCEIT : 0)) == FAIL) 12244 | (eap->forceit ? VIF_FORCEIT : 0)) == FAIL)
12245 EMSG(_("E195: Cannot open viminfo file for reading")); 12245 emsg(_("E195: Cannot open viminfo file for reading"));
12246 } 12246 }
12247 else 12247 else
12248 write_viminfo(eap->arg, eap->forceit); 12248 write_viminfo(eap->arg, eap->forceit);
12249 p_viminfo = save_viminfo; 12249 p_viminfo = save_viminfo;
12250 } 12250 }
12284 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0); 12284 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0);
12285 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0); 12285 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0);
12286 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0); 12286 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0);
12287 } 12287 }
12288 else 12288 else
12289 EMSG2(_(e_invarg2), eap->arg); 12289 semsg(_(e_invarg2), eap->arg);
12290 } 12290 }
12291 12291
12292 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) 12292 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
12293 /* 12293 /*
12294 * Function given to ExpandGeneric() to obtain the possible arguments of the 12294 * Function given to ExpandGeneric() to obtain the possible arguments of the
12346 int indent = FALSE; 12346 int indent = FALSE;
12347 12347
12348 if (*eap->arg == NUL) 12348 if (*eap->arg == NUL)
12349 { 12349 {
12350 /* Print current status. */ 12350 /* Print current status. */
12351 smsg((char_u *)"filetype detection:%s plugin:%s indent:%s", 12351 smsg("filetype detection:%s plugin:%s indent:%s",
12352 filetype_detect ? "ON" : "OFF", 12352 filetype_detect ? "ON" : "OFF",
12353 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF", 12353 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF",
12354 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF"); 12354 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF");
12355 return; 12355 return;
12356 } 12356 }
12415 source_runtime((char_u *)FTOFF_FILE, DIP_ALL); 12415 source_runtime((char_u *)FTOFF_FILE, DIP_ALL);
12416 filetype_detect = FALSE; 12416 filetype_detect = FALSE;
12417 } 12417 }
12418 } 12418 }
12419 else 12419 else
12420 EMSG2(_(e_invarg2), arg); 12420 semsg(_(e_invarg2), arg);
12421 } 12421 }
12422 12422
12423 /* 12423 /*
12424 * ":setfiletype [FALLBACK] {name}" 12424 * ":setfiletype [FALLBACK] {name}"
12425 */ 12425 */
12446 if (*eap->arg != NUL) 12446 if (*eap->arg != NUL)
12447 putdigraph(eap->arg); 12447 putdigraph(eap->arg);
12448 else 12448 else
12449 listdigraphs(eap->forceit); 12449 listdigraphs(eap->forceit);
12450 #else 12450 #else
12451 EMSG(_("E196: No digraphs in this version")); 12451 emsg(_("E196: No digraphs in this version"));
12452 #endif 12452 #endif
12453 } 12453 }
12454 12454
12455 static void 12455 static void
12456 ex_set(exarg_T *eap) 12456 ex_set(exarg_T *eap)
12505 12505
12506 if (eap->line2 <= 3) 12506 if (eap->line2 <= 3)
12507 id = eap->line2; 12507 id = eap->line2;
12508 else 12508 else
12509 { 12509 {
12510 EMSG(e_invcmd); 12510 emsg(_(e_invcmd));
12511 return; 12511 return;
12512 } 12512 }
12513 12513
12514 /* First clear any old pattern. */ 12514 /* First clear any old pattern. */
12515 if (!eap->skip) 12515 if (!eap->skip)
12528 p = skipwhite(p); 12528 p = skipwhite(p);
12529 if (*p == NUL) 12529 if (*p == NUL)
12530 { 12530 {
12531 /* There must be two arguments. */ 12531 /* There must be two arguments. */
12532 vim_free(g); 12532 vim_free(g);
12533 EMSG2(_(e_invarg2), eap->arg); 12533 semsg(_(e_invarg2), eap->arg);
12534 return; 12534 return;
12535 } 12535 }
12536 end = skip_regexp(p + 1, *p, TRUE, NULL); 12536 end = skip_regexp(p + 1, *p, TRUE, NULL);
12537 if (!eap->skip) 12537 if (!eap->skip)
12538 { 12538 {
12543 return; 12543 return;
12544 } 12544 }
12545 if (*end != *p) 12545 if (*end != *p)
12546 { 12546 {
12547 vim_free(g); 12547 vim_free(g);
12548 EMSG2(_(e_invarg2), p); 12548 semsg(_(e_invarg2), p);
12549 return; 12549 return;
12550 } 12550 }
12551 12551
12552 c = *end; 12552 c = *end;
12553 *end = NUL; 12553 *end = NUL;