comparison src/ex_cmds.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 273649cad196
children 41fbbcea0f1b
comparison
equal deleted inserted replaced
15469:bc9b5261ed01 15470:55ccc2d353bd
465 else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL) 465 else if (!ASCII_ISALPHA(*p) && regmatch.regprog == NULL)
466 { 466 {
467 s = skip_regexp(p + 1, *p, TRUE, NULL); 467 s = skip_regexp(p + 1, *p, TRUE, NULL);
468 if (*s != *p) 468 if (*s != *p)
469 { 469 {
470 EMSG(_(e_invalpat)); 470 emsg(_(e_invalpat));
471 goto sortend; 471 goto sortend;
472 } 472 }
473 *s = NUL; 473 *s = NUL;
474 /* Use last search pattern if sort pattern is empty. */ 474 /* Use last search pattern if sort pattern is empty. */
475 if (s == p + 1) 475 if (s == p + 1)
476 { 476 {
477 if (last_search_pat() == NULL) 477 if (last_search_pat() == NULL)
478 { 478 {
479 EMSG(_(e_noprevre)); 479 emsg(_(e_noprevre));
480 goto sortend; 480 goto sortend;
481 } 481 }
482 regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC); 482 regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
483 } 483 }
484 else 484 else
488 p = s; /* continue after the regexp */ 488 p = s; /* continue after the regexp */
489 regmatch.rm_ic = p_ic; 489 regmatch.rm_ic = p_ic;
490 } 490 }
491 else 491 else
492 { 492 {
493 EMSG2(_(e_invarg2), p); 493 semsg(_(e_invarg2), p);
494 goto sortend; 494 goto sortend;
495 } 495 }
496 } 496 }
497 497
498 /* Can only have one of 'n', 'b', 'o' and 'x'. */ 498 /* Can only have one of 'n', 'b', 'o' and 'x'. */
499 if (format_found > 1) 499 if (format_found > 1)
500 { 500 {
501 EMSG(_(e_invarg)); 501 emsg(_(e_invarg));
502 goto sortend; 502 goto sortend;
503 } 503 }
504 504
505 /* From here on "sort_nr" is used as a flag for any integer number 505 /* From here on "sort_nr" is used as a flag for any integer number
506 * sorting. */ 506 * sorting. */
666 vim_free(nrs); 666 vim_free(nrs);
667 vim_free(sortbuf1); 667 vim_free(sortbuf1);
668 vim_free(sortbuf2); 668 vim_free(sortbuf2);
669 vim_regfree(regmatch.regprog); 669 vim_regfree(regmatch.regprog);
670 if (got_int) 670 if (got_int)
671 EMSG(_(e_interr)); 671 emsg(_(e_interr));
672 } 672 }
673 673
674 /* 674 /*
675 * ":retab". 675 * ":retab".
676 */ 676 */
723 new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str); 723 new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);
724 #else 724 #else
725 new_ts = getdigits(&(eap->arg)); 725 new_ts = getdigits(&(eap->arg));
726 if (new_ts < 0) 726 if (new_ts < 0)
727 { 727 {
728 EMSG(_(e_positive)); 728 emsg(_(e_positive));
729 return; 729 return;
730 } 730 }
731 if (new_ts == 0) 731 if (new_ts == 0)
732 new_ts = curbuf->b_p_ts; 732 new_ts = curbuf->b_p_ts;
733 #endif 733 #endif
833 if (new_line == NULL) /* out of memory */ 833 if (new_line == NULL) /* out of memory */
834 break; 834 break;
835 line_breakcheck(); 835 line_breakcheck();
836 } 836 }
837 if (got_int) 837 if (got_int)
838 EMSG(_(e_interr)); 838 emsg(_(e_interr));
839 839
840 #ifdef FEAT_VARTABS 840 #ifdef FEAT_VARTABS
841 // If a single value was given then it can be considered equal to 841 // If a single value was given then it can be considered equal to
842 // either the value of 'tabstop' or the value of 'vartabstop'. 842 // either the value of 'tabstop' or the value of 'vartabstop'.
843 if (tabstop_count(curbuf->b_p_vts_array) == 0 843 if (tabstop_count(curbuf->b_p_vts_array) == 0
907 tabpage_T *tp; 907 tabpage_T *tp;
908 #endif 908 #endif
909 909
910 if (dest >= line1 && dest < line2) 910 if (dest >= line1 && dest < line2)
911 { 911 {
912 EMSG(_("E134: Cannot move a range of lines into itself")); 912 emsg(_("E134: Cannot move a range of lines into itself"));
913 return FAIL; 913 return FAIL;
914 } 914 }
915 915
916 // Do nothing if we are not actually moving any lines. This will prevent 916 // Do nothing if we are not actually moving any lines. This will prevent
917 // the 'modified' flag from being set without cause. 917 // the 'modified' flag from being set without cause.
1000 1000
1001 for (l = line1; l <= line2; l++) 1001 for (l = line1; l <= line2; l++)
1002 ml_delete(line1 + extra, TRUE); 1002 ml_delete(line1 + extra, TRUE);
1003 1003
1004 if (!global_busy && num_lines > p_report) 1004 if (!global_busy && num_lines > p_report)
1005 smsg((char_u *)NGETTEXT("%ld line moved", "%ld lines moved", num_lines), 1005 smsg(NGETTEXT("%ld line moved", "%ld lines moved", num_lines),
1006 (long)num_lines); 1006 (long)num_lines);
1007 1007
1008 /* 1008 /*
1009 * Leave the cursor on the last of the moved lines. 1009 * Leave the cursor on the last of the moved lines.
1010 */ 1010 */
1145 len += (int)STRLEN(newcmd); 1145 len += (int)STRLEN(newcmd);
1146 if (ins_prevcmd) 1146 if (ins_prevcmd)
1147 { 1147 {
1148 if (prevcmd == NULL) 1148 if (prevcmd == NULL)
1149 { 1149 {
1150 EMSG(_(e_noprev)); 1150 emsg(_(e_noprev));
1151 vim_free(newcmd); 1151 vim_free(newcmd);
1152 return; 1152 return;
1153 } 1153 }
1154 len += (int)STRLEN(prevcmd); 1154 len += (int)STRLEN(prevcmd);
1155 } 1155 }
1332 else 1332 else
1333 #endif 1333 #endif
1334 if ((do_in && (itmp = vim_tempname('i', FALSE)) == NULL) 1334 if ((do_in && (itmp = vim_tempname('i', FALSE)) == NULL)
1335 || (do_out && (otmp = vim_tempname('o', FALSE)) == NULL)) 1335 || (do_out && (otmp = vim_tempname('o', FALSE)) == NULL))
1336 { 1336 {
1337 EMSG(_(e_notmp)); 1337 emsg(_(e_notmp));
1338 goto filterend; 1338 goto filterend;
1339 } 1339 }
1340 1340
1341 /* 1341 /*
1342 * The writing and reading of temp files will not be shown. 1342 * The writing and reading of temp files will not be shown.
1349 msg_putchar('\n'); /* keep message from buf_write() */ 1349 msg_putchar('\n'); /* keep message from buf_write() */
1350 --no_wait_return; 1350 --no_wait_return;
1351 #if defined(FEAT_EVAL) 1351 #if defined(FEAT_EVAL)
1352 if (!aborting()) 1352 if (!aborting())
1353 #endif 1353 #endif
1354 (void)EMSG2(_(e_notcreate), itmp); /* will call wait_return */ 1354 (void)semsg(_(e_notcreate), itmp); /* will call wait_return */
1355 goto filterend; 1355 goto filterend;
1356 } 1356 }
1357 if (curbuf != old_curbuf) 1357 if (curbuf != old_curbuf)
1358 goto filterend; 1358 goto filterend;
1359 1359
1424 #if defined(FEAT_EVAL) 1424 #if defined(FEAT_EVAL)
1425 if (!aborting()) 1425 if (!aborting())
1426 #endif 1426 #endif
1427 { 1427 {
1428 msg_putchar('\n'); 1428 msg_putchar('\n');
1429 EMSG2(_(e_notread), otmp); 1429 semsg(_(e_notread), otmp);
1430 } 1430 }
1431 goto error; 1431 goto error;
1432 } 1432 }
1433 if (curbuf != old_curbuf) 1433 if (curbuf != old_curbuf)
1434 goto filterend; 1434 goto filterend;
1512 filterend: 1512 filterend:
1513 1513
1514 if (curbuf != old_curbuf) 1514 if (curbuf != old_curbuf)
1515 { 1515 {
1516 --no_wait_return; 1516 --no_wait_return;
1517 EMSG(_("E135: *Filter* Autocommands must not change current buffer")); 1517 emsg(_("E135: *Filter* Autocommands must not change current buffer"));
1518 } 1518 }
1519 if (itmp != NULL) 1519 if (itmp != NULL)
1520 mch_remove(itmp); 1520 mch_remove(itmp);
1521 if (otmp != NULL) 1521 if (otmp != NULL)
1522 mch_remove(otmp); 1522 mch_remove(otmp);
1869 vim_snprintf((char *)IObuff, IOSIZE, _("%sviminfo: %s in line: "), 1869 vim_snprintf((char *)IObuff, IOSIZE, _("%sviminfo: %s in line: "),
1870 errnum, message); 1870 errnum, message);
1871 STRNCAT(IObuff, line, IOSIZE - STRLEN(IObuff) - 1); 1871 STRNCAT(IObuff, line, IOSIZE - STRLEN(IObuff) - 1);
1872 if (IObuff[STRLEN(IObuff) - 1] == '\n') 1872 if (IObuff[STRLEN(IObuff) - 1] == '\n')
1873 IObuff[STRLEN(IObuff) - 1] = NUL; 1873 IObuff[STRLEN(IObuff) - 1] = NUL;
1874 emsg(IObuff); 1874 emsg((char *)IObuff);
1875 if (++viminfo_errcnt >= 10) 1875 if (++viminfo_errcnt >= 10)
1876 { 1876 {
1877 EMSG(_("E136: viminfo: Too many errors, skipping rest of file")); 1877 emsg(_("E136: viminfo: Too many errors, skipping rest of file"));
1878 return TRUE; 1878 return TRUE;
1879 } 1879 }
1880 return FALSE; 1880 return FALSE;
1881 } 1881 }
1882 1882
1901 fp = mch_fopen((char *)fname, READBIN); 1901 fp = mch_fopen((char *)fname, READBIN);
1902 1902
1903 if (p_verbose > 0) 1903 if (p_verbose > 0)
1904 { 1904 {
1905 verbose_enter(); 1905 verbose_enter();
1906 smsg((char_u *)_("Reading viminfo file \"%s\"%s%s%s"), 1906 smsg(_("Reading viminfo file \"%s\"%s%s%s"),
1907 fname, 1907 fname,
1908 (flags & VIF_WANT_INFO) ? _(" info") : "", 1908 (flags & VIF_WANT_INFO) ? _(" info") : "",
1909 (flags & VIF_WANT_MARKS) ? _(" marks") : "", 1909 (flags & VIF_WANT_MARKS) ? _(" marks") : "",
1910 (flags & VIF_GET_OLDFILES) ? _(" oldfiles") : "", 1910 (flags & VIF_GET_OLDFILES) ? _(" oldfiles") : "",
1911 fp == NULL ? _(" FAILED") : ""); 1911 fp == NULL ? _(" FAILED") : "");
2001 : (st_old.st_mode & 0002)))) 2001 : (st_old.st_mode & 0002))))
2002 { 2002 {
2003 int tt = msg_didany; 2003 int tt = msg_didany;
2004 2004
2005 /* avoid a wait_return for this message, it's annoying */ 2005 /* avoid a wait_return for this message, it's annoying */
2006 EMSG2(_("E137: Viminfo file is not writable: %s"), fname); 2006 semsg(_("E137: Viminfo file is not writable: %s"), fname);
2007 msg_didany = tt; 2007 msg_didany = tt;
2008 fclose(fp_in); 2008 fclose(fp_in);
2009 goto end; 2009 goto end;
2010 } 2010 }
2011 #endif 2011 #endif
2124 /* Assume file exists, try again with another name. */ 2124 /* Assume file exists, try again with another name. */
2125 if (next_char == 'a' - 1) 2125 if (next_char == 'a' - 1)
2126 { 2126 {
2127 /* They all exist? Must be something wrong! Don't write 2127 /* They all exist? Must be something wrong! Don't write
2128 * the viminfo file then. */ 2128 * the viminfo file then. */
2129 EMSG2(_("E929: Too many viminfo temp files, like %s!"), 2129 semsg(_("E929: Too many viminfo temp files, like %s!"),
2130 tempname); 2130 tempname);
2131 break; 2131 break;
2132 } 2132 }
2133 *wp = next_char; 2133 *wp = next_char;
2134 --next_char; 2134 --next_char;
2170 /* 2170 /*
2171 * Check if the new viminfo file can be written to. 2171 * Check if the new viminfo file can be written to.
2172 */ 2172 */
2173 if (fp_out == NULL) 2173 if (fp_out == NULL)
2174 { 2174 {
2175 EMSG2(_("E138: Can't write viminfo file %s!"), 2175 semsg(_("E138: Can't write viminfo file %s!"),
2176 (fp_in == NULL || tempname == NULL) ? fname : tempname); 2176 (fp_in == NULL || tempname == NULL) ? fname : tempname);
2177 if (fp_in != NULL) 2177 if (fp_in != NULL)
2178 fclose(fp_in); 2178 fclose(fp_in);
2179 goto end; 2179 goto end;
2180 } 2180 }
2181 2181
2182 if (p_verbose > 0) 2182 if (p_verbose > 0)
2183 { 2183 {
2184 verbose_enter(); 2184 verbose_enter();
2185 smsg((char_u *)_("Writing viminfo file \"%s\""), fname); 2185 smsg(_("Writing viminfo file \"%s\""), fname);
2186 verbose_leave(); 2186 verbose_leave();
2187 } 2187 }
2188 2188
2189 viminfo_errcnt = 0; 2189 viminfo_errcnt = 0;
2190 do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS)); 2190 do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS));
2201 if (viminfo_errcnt == 0) 2201 if (viminfo_errcnt == 0)
2202 { 2202 {
2203 if (vim_rename(tempname, fname) == -1) 2203 if (vim_rename(tempname, fname) == -1)
2204 { 2204 {
2205 ++viminfo_errcnt; 2205 ++viminfo_errcnt;
2206 EMSG2(_("E886: Can't rename viminfo file to %s!"), fname); 2206 semsg(_("E886: Can't rename viminfo file to %s!"), fname);
2207 } 2207 }
2208 # ifdef WIN3264 2208 # ifdef WIN3264
2209 /* If the viminfo file was hidden then also hide the new file. */ 2209 /* If the viminfo file was hidden then also hide the new file. */
2210 else if (hidden) 2210 else if (hidden)
2211 mch_hide(fname); 2211 mch_hide(fname);
3125 if (eap->addr_count > 0 3125 if (eap->addr_count > 0
3126 && (*eap->arg != NUL 3126 && (*eap->arg != NUL
3127 || eap->line2 > 0 3127 || eap->line2 > 0
3128 || eap->addr_count > 1)) 3128 || eap->addr_count > 1))
3129 { 3129 {
3130 EMSG(_(e_invarg)); 3130 emsg(_(e_invarg));
3131 return; 3131 return;
3132 } 3132 }
3133 3133
3134 if (*eap->arg != NUL || eap->addr_count == 1) 3134 if (*eap->arg != NUL || eap->addr_count == 1)
3135 { 3135 {
3203 #endif 3203 #endif
3204 if (*ffname == NUL) 3204 if (*ffname == NUL)
3205 { 3205 {
3206 if (eap->cmdidx == CMD_saveas) 3206 if (eap->cmdidx == CMD_saveas)
3207 { 3207 {
3208 EMSG(_(e_argreq)); 3208 emsg(_(e_argreq));
3209 goto theend; 3209 goto theend;
3210 } 3210 }
3211 other = FALSE; 3211 other = FALSE;
3212 } 3212 }
3213 else 3213 else
3235 alt_buf = buflist_findname(ffname); 3235 alt_buf = buflist_findname(ffname);
3236 if (alt_buf != NULL && alt_buf->b_ml.ml_mfp != NULL) 3236 if (alt_buf != NULL && alt_buf->b_ml.ml_mfp != NULL)
3237 { 3237 {
3238 /* Overwriting a file that is loaded in another buffer is not a 3238 /* Overwriting a file that is loaded in another buffer is not a
3239 * good idea. */ 3239 * good idea. */
3240 EMSG(_(e_bufloaded)); 3240 emsg(_(e_bufloaded));
3241 goto theend; 3241 goto theend;
3242 } 3242 }
3243 } 3243 }
3244 3244
3245 /* 3245 /*
3276 eap->forceit = TRUE; 3276 eap->forceit = TRUE;
3277 } 3277 }
3278 else 3278 else
3279 #endif 3279 #endif
3280 { 3280 {
3281 EMSG(_("E140: Use ! to write partial buffer")); 3281 emsg(_("E140: Use ! to write partial buffer"));
3282 goto theend; 3282 goto theend;
3283 } 3283 }
3284 } 3284 }
3285 } 3285 }
3286 3286
3415 { 3415 {
3416 #ifdef UNIX 3416 #ifdef UNIX
3417 /* with UNIX it is possible to open a directory */ 3417 /* with UNIX it is possible to open a directory */
3418 if (mch_isdir(ffname)) 3418 if (mch_isdir(ffname))
3419 { 3419 {
3420 EMSG2(_(e_isadir2), ffname); 3420 semsg(_(e_isadir2), ffname);
3421 return FAIL; 3421 return FAIL;
3422 } 3422 }
3423 #endif 3423 #endif
3424 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) 3424 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
3425 if (p_confirm || cmdmod.confirm) 3425 if (p_confirm || cmdmod.confirm)
3432 eap->forceit = TRUE; 3432 eap->forceit = TRUE;
3433 } 3433 }
3434 else 3434 else
3435 #endif 3435 #endif
3436 { 3436 {
3437 EMSG(_(e_exists)); 3437 emsg(_(e_exists));
3438 return FAIL; 3438 return FAIL;
3439 } 3439 }
3440 } 3440 }
3441 3441
3442 /* For ":w! filename" check that no swap file exists for "filename". */ 3442 /* For ":w! filename" check that no swap file exists for "filename". */
3489 eap->forceit = TRUE; 3489 eap->forceit = TRUE;
3490 } 3490 }
3491 else 3491 else
3492 #endif 3492 #endif
3493 { 3493 {
3494 EMSG2(_("E768: Swap file exists: %s (:silent! overrides)"), 3494 semsg(_("E768: Swap file exists: %s (:silent! overrides)"),
3495 swapname); 3495 swapname);
3496 vim_free(swapname); 3496 vim_free(swapname);
3497 return FAIL; 3497 return FAIL;
3498 } 3498 }
3499 } 3499 }
3563 if (buf->b_ffname == NULL && cmdmod.browse) 3563 if (buf->b_ffname == NULL && cmdmod.browse)
3564 browse_save_fname(buf); 3564 browse_save_fname(buf);
3565 #endif 3565 #endif
3566 if (buf->b_ffname == NULL) 3566 if (buf->b_ffname == NULL)
3567 { 3567 {
3568 EMSGN(_("E141: No file name for buffer %ld"), (long)buf->b_fnum); 3568 semsg(_("E141: No file name for buffer %ld"), (long)buf->b_fnum);
3569 ++error; 3569 ++error;
3570 } 3570 }
3571 else if (check_readonly(&eap->forceit, buf) 3571 else if (check_readonly(&eap->forceit, buf)
3572 || check_overwrite(eap, buf, buf->b_fname, buf->b_ffname, 3572 || check_overwrite(eap, buf, buf->b_fname, buf->b_ffname,
3573 FALSE) == FAIL) 3573 FALSE) == FAIL)
3603 int 3603 int
3604 not_writing(void) 3604 not_writing(void)
3605 { 3605 {
3606 if (p_write) 3606 if (p_write)
3607 return FALSE; 3607 return FALSE;
3608 EMSG(_("E142: File not written: Writing is disabled by 'write' option")); 3608 emsg(_("E142: File not written: Writing is disabled by 'write' option"));
3609 return TRUE; 3609 return TRUE;
3610 } 3610 }
3611 3611
3612 /* 3612 /*
3613 * Check if a buffer is read-only (either 'readonly' option is set or file is 3613 * Check if a buffer is read-only (either 'readonly' option is set or file is
3649 return TRUE; 3649 return TRUE;
3650 } 3650 }
3651 else 3651 else
3652 #endif 3652 #endif
3653 if (buf->b_p_ro) 3653 if (buf->b_p_ro)
3654 EMSG(_(e_readonly)); 3654 emsg(_(e_readonly));
3655 else 3655 else
3656 EMSG2(_("E505: \"%s\" is read-only (add ! to override)"), 3656 semsg(_("E505: \"%s\" is read-only (add ! to override)"),
3657 buf->b_fname); 3657 buf->b_fname);
3658 return TRUE; 3658 return TRUE;
3659 } 3659 }
3660 3660
3661 return FALSE; 3661 return FALSE;
4486 } 4486 }
4487 4487
4488 static void 4488 static void
4489 delbuf_msg(char_u *name) 4489 delbuf_msg(char_u *name)
4490 { 4490 {
4491 EMSG2(_("E143: Autocommands unexpectedly deleted new buffer %s"), 4491 semsg(_("E143: Autocommands unexpectedly deleted new buffer %s"),
4492 name == NULL ? (char_u *)"" : name); 4492 name == NULL ? (char_u *)"" : name);
4493 vim_free(name); 4493 vim_free(name);
4494 au_new_curbuf.br_buf = NULL; 4494 au_new_curbuf.br_buf = NULL;
4495 au_new_curbuf.br_buf_free_count = 0; 4495 au_new_curbuf.br_buf_free_count = 0;
4496 } 4496 }
4705 4705
4706 if (*x != 0) 4706 if (*x != 0)
4707 { 4707 {
4708 if (!VIM_ISDIGIT(*x)) 4708 if (!VIM_ISDIGIT(*x))
4709 { 4709 {
4710 EMSG(_("E144: non-numeric argument to :z")); 4710 emsg(_("E144: non-numeric argument to :z"));
4711 return; 4711 return;
4712 } 4712 }
4713 else 4713 else
4714 { 4714 {
4715 bigness = atol((char *)x); 4715 bigness = atol((char *)x);
4815 int 4815 int
4816 check_restricted(void) 4816 check_restricted(void)
4817 { 4817 {
4818 if (restricted) 4818 if (restricted)
4819 { 4819 {
4820 EMSG(_("E145: Shell commands not allowed in rvim")); 4820 emsg(_("E145: Shell commands not allowed in rvim"));
4821 return TRUE; 4821 return TRUE;
4822 } 4822 }
4823 return FALSE; 4823 return FALSE;
4824 } 4824 }
4825 4825
4832 check_secure(void) 4832 check_secure(void)
4833 { 4833 {
4834 if (secure) 4834 if (secure)
4835 { 4835 {
4836 secure = 2; 4836 secure = 2;
4837 EMSG(_(e_curdir)); 4837 emsg(_(e_curdir));
4838 return TRUE; 4838 return TRUE;
4839 } 4839 }
4840 #ifdef HAVE_SANDBOX 4840 #ifdef HAVE_SANDBOX
4841 /* 4841 /*
4842 * In the sandbox more things are not allowed, including the things 4842 * In the sandbox more things are not allowed, including the things
4843 * disallowed in secure mode. 4843 * disallowed in secure mode.
4844 */ 4844 */
4845 if (sandbox != 0) 4845 if (sandbox != 0)
4846 { 4846 {
4847 EMSG(_(e_sandbox)); 4847 emsg(_(e_sandbox));
4848 return TRUE; 4848 return TRUE;
4849 } 4849 }
4850 #endif 4850 #endif
4851 return FALSE; 4851 return FALSE;
4852 } 4852 }
4931 && vim_strchr((char_u *)"0123456789cegriIp|\"", *cmd) == NULL) 4931 && vim_strchr((char_u *)"0123456789cegriIp|\"", *cmd) == NULL)
4932 { 4932 {
4933 /* don't accept alphanumeric for separator */ 4933 /* don't accept alphanumeric for separator */
4934 if (isalpha(*cmd)) 4934 if (isalpha(*cmd))
4935 { 4935 {
4936 EMSG(_("E146: Regular expressions can't be delimited by letters")); 4936 emsg(_("E146: Regular expressions can't be delimited by letters"));
4937 return; 4937 return;
4938 } 4938 }
4939 /* 4939 /*
4940 * undocumented vi feature: 4940 * undocumented vi feature:
4941 * "\/sub/" and "\?sub?" use last used search pattern (almost like 4941 * "\/sub/" and "\?sub?" use last used search pattern (almost like
4944 if (*cmd == '\\') 4944 if (*cmd == '\\')
4945 { 4945 {
4946 ++cmd; 4946 ++cmd;
4947 if (vim_strchr((char_u *)"/?&", *cmd) == NULL) 4947 if (vim_strchr((char_u *)"/?&", *cmd) == NULL)
4948 { 4948 {
4949 EMSG(_(e_backslash)); 4949 emsg(_(e_backslash));
4950 return; 4950 return;
4951 } 4951 }
4952 if (*cmd != '&') 4952 if (*cmd != '&')
4953 which_pat = RE_SEARCH; /* use last '/' pattern */ 4953 which_pat = RE_SEARCH; /* use last '/' pattern */
4954 pat = (char_u *)""; /* empty search pattern */ 4954 pat = (char_u *)""; /* empty search pattern */
4992 if (STRCMP(sub, "%") == 0 4992 if (STRCMP(sub, "%") == 0
4993 && vim_strchr(p_cpo, CPO_SUBPERCENT) != NULL) 4993 && vim_strchr(p_cpo, CPO_SUBPERCENT) != NULL)
4994 { 4994 {
4995 if (old_sub == NULL) /* there is no previous command */ 4995 if (old_sub == NULL) /* there is no previous command */
4996 { 4996 {
4997 EMSG(_(e_nopresub)); 4997 emsg(_(e_nopresub));
4998 return; 4998 return;
4999 } 4999 }
5000 sub = old_sub; 5000 sub = old_sub;
5001 } 5001 }
5002 else 5002 else
5008 } 5008 }
5009 else if (!eap->skip) /* use previous pattern and substitution */ 5009 else if (!eap->skip) /* use previous pattern and substitution */
5010 { 5010 {
5011 if (old_sub == NULL) /* there is no previous command */ 5011 if (old_sub == NULL) /* there is no previous command */
5012 { 5012 {
5013 EMSG(_(e_nopresub)); 5013 emsg(_(e_nopresub));
5014 return; 5014 return;
5015 } 5015 }
5016 pat = NULL; /* search_regcomp() will use previous pattern */ 5016 pat = NULL; /* search_regcomp() will use previous pattern */
5017 sub = old_sub; 5017 sub = old_sub;
5018 5018
5135 if (VIM_ISDIGIT(*cmd)) 5135 if (VIM_ISDIGIT(*cmd))
5136 { 5136 {
5137 i = getdigits(&cmd); 5137 i = getdigits(&cmd);
5138 if (i <= 0 && !eap->skip && subflags.do_error) 5138 if (i <= 0 && !eap->skip && subflags.do_error)
5139 { 5139 {
5140 EMSG(_(e_zerocount)); 5140 emsg(_(e_zerocount));
5141 return; 5141 return;
5142 } 5142 }
5143 eap->line1 = eap->line2; 5143 eap->line1 = eap->line2;
5144 eap->line2 += i - 1; 5144 eap->line2 += i - 1;
5145 if (eap->line2 > curbuf->b_ml.ml_line_count) 5145 if (eap->line2 > curbuf->b_ml.ml_line_count)
5153 if (*cmd && *cmd != '"') /* if not end-of-line or comment */ 5153 if (*cmd && *cmd != '"') /* if not end-of-line or comment */
5154 { 5154 {
5155 eap->nextcmd = check_nextcmd(cmd); 5155 eap->nextcmd = check_nextcmd(cmd);
5156 if (eap->nextcmd == NULL) 5156 if (eap->nextcmd == NULL)
5157 { 5157 {
5158 EMSG(_(e_trailing)); 5158 emsg(_(e_trailing));
5159 return; 5159 return;
5160 } 5160 }
5161 } 5161 }
5162 5162
5163 if (eap->skip) /* not executing commands, only parsing */ 5163 if (eap->skip) /* not executing commands, only parsing */
5164 return; 5164 return;
5165 5165
5166 if (!subflags.do_count && !curbuf->b_p_ma) 5166 if (!subflags.do_count && !curbuf->b_p_ma)
5167 { 5167 {
5168 /* Substitution is not allowed in non-'modifiable' buffer */ 5168 /* Substitution is not allowed in non-'modifiable' buffer */
5169 EMSG(_(e_modifiable)); 5169 emsg(_(e_modifiable));
5170 return; 5170 return;
5171 } 5171 }
5172 5172
5173 if (search_regcomp(pat, RE_SUBST, which_pat, SEARCH_HIS, &regmatch) == FAIL) 5173 if (search_regcomp(pat, RE_SUBST, which_pat, SEARCH_HIS, &regmatch) == FAIL)
5174 { 5174 {
5175 if (subflags.do_error) 5175 if (subflags.do_error)
5176 EMSG(_(e_invcmd)); 5176 emsg(_(e_invcmd));
5177 return; 5177 return;
5178 } 5178 }
5179 5179
5180 /* the 'i' or 'I' flag overrules 'ignorecase' and 'smartcase' */ 5180 /* the 'i' or 'I' flag overrules 'ignorecase' and 'smartcase' */
5181 if (subflags.do_ic == 'i') 5181 if (subflags.do_ic == 'i')
5494 needed */ 5494 needed */
5495 msg_no_more = TRUE; 5495 msg_no_more = TRUE;
5496 /* write message same highlighting as for 5496 /* write message same highlighting as for
5497 * wait_return */ 5497 * wait_return */
5498 smsg_attr(HL_ATTR(HLF_R), 5498 smsg_attr(HL_ATTR(HLF_R),
5499 (char_u *)_("replace with %s (y/n/a/q/l/^E/^Y)?"), sub); 5499 _("replace with %s (y/n/a/q/l/^E/^Y)?"), sub);
5500 msg_no_more = FALSE; 5500 msg_no_more = FALSE;
5501 msg_scroll = i; 5501 msg_scroll = i;
5502 showruler(TRUE); 5502 showruler(TRUE);
5503 windgoto(msg_row, msg_col); 5503 windgoto(msg_row, msg_col);
5504 RedrawingDisabled = temp; 5504 RedrawingDisabled = temp;
5947 subflags.do_number, subflags.do_list); 5947 subflags.do_number, subflags.do_list);
5948 } 5948 }
5949 else if (!global_busy) 5949 else if (!global_busy)
5950 { 5950 {
5951 if (got_int) /* interrupted */ 5951 if (got_int) /* interrupted */
5952 EMSG(_(e_interr)); 5952 emsg(_(e_interr));
5953 else if (got_match) /* did find something but nothing substituted */ 5953 else if (got_match) /* did find something but nothing substituted */
5954 MSG(""); 5954 MSG("");
5955 else if (subflags.do_error) /* nothing found */ 5955 else if (subflags.do_error) /* nothing found */
5956 EMSG2(_(e_patnotf2), get_search_pat()); 5956 semsg(_(e_patnotf2), get_search_pat());
5957 } 5957 }
5958 5958
5959 #ifdef FEAT_FOLDING 5959 #ifdef FEAT_FOLDING
5960 if (subflags.do_ask && hasAnyFolding(curwin)) 5960 if (subflags.do_ask && hasAnyFolding(curwin))
5961 /* Cursor position may require updating */ 5961 /* Cursor position may require updating */
6016 set_keep_msg(msg_buf, 0); 6016 set_keep_msg(msg_buf, 0);
6017 return TRUE; 6017 return TRUE;
6018 } 6018 }
6019 if (got_int) 6019 if (got_int)
6020 { 6020 {
6021 EMSG(_(e_interr)); 6021 emsg(_(e_interr));
6022 return TRUE; 6022 return TRUE;
6023 } 6023 }
6024 return FALSE; 6024 return FALSE;
6025 } 6025 }
6026 6026
6069 * ":g/found/v/notfound/command". */ 6069 * ":g/found/v/notfound/command". */
6070 if (global_busy && (eap->line1 != 1 6070 if (global_busy && (eap->line1 != 1
6071 || eap->line2 != curbuf->b_ml.ml_line_count)) 6071 || eap->line2 != curbuf->b_ml.ml_line_count))
6072 { 6072 {
6073 /* will increment global_busy to break out of the loop */ 6073 /* will increment global_busy to break out of the loop */
6074 EMSG(_("E147: Cannot do :global recursive with a range")); 6074 emsg(_("E147: Cannot do :global recursive with a range"));
6075 return; 6075 return;
6076 } 6076 }
6077 6077
6078 if (eap->forceit) /* ":global!" is like ":vglobal" */ 6078 if (eap->forceit) /* ":global!" is like ":vglobal" */
6079 type = 'v'; 6079 type = 'v';
6090 if (*cmd == '\\') 6090 if (*cmd == '\\')
6091 { 6091 {
6092 ++cmd; 6092 ++cmd;
6093 if (vim_strchr((char_u *)"/?&", *cmd) == NULL) 6093 if (vim_strchr((char_u *)"/?&", *cmd) == NULL)
6094 { 6094 {
6095 EMSG(_(e_backslash)); 6095 emsg(_(e_backslash));
6096 return; 6096 return;
6097 } 6097 }
6098 if (*cmd == '&') 6098 if (*cmd == '&')
6099 which_pat = RE_SUBST; /* use previous substitute pattern */ 6099 which_pat = RE_SUBST; /* use previous substitute pattern */
6100 else 6100 else
6102 ++cmd; 6102 ++cmd;
6103 pat = (char_u *)""; 6103 pat = (char_u *)"";
6104 } 6104 }
6105 else if (*cmd == NUL) 6105 else if (*cmd == NUL)
6106 { 6106 {
6107 EMSG(_("E148: Regular expression missing from global")); 6107 emsg(_("E148: Regular expression missing from global"));
6108 return; 6108 return;
6109 } 6109 }
6110 else 6110 else
6111 { 6111 {
6112 delim = *cmd; /* get the delimiter */ 6112 delim = *cmd; /* get the delimiter */
6123 lrFswap(pat,0); 6123 lrFswap(pat,0);
6124 #endif 6124 #endif
6125 6125
6126 if (search_regcomp(pat, RE_BOTH, which_pat, SEARCH_HIS, &regmatch) == FAIL) 6126 if (search_regcomp(pat, RE_BOTH, which_pat, SEARCH_HIS, &regmatch) == FAIL)
6127 { 6127 {
6128 EMSG(_(e_invcmd)); 6128 emsg(_(e_invcmd));
6129 return; 6129 return;
6130 } 6130 }
6131 6131
6132 if (global_busy) 6132 if (global_busy)
6133 { 6133 {
6161 if (got_int) 6161 if (got_int)
6162 MSG(_(e_interr)); 6162 MSG(_(e_interr));
6163 else if (ndone == 0) 6163 else if (ndone == 0)
6164 { 6164 {
6165 if (type == 'v') 6165 if (type == 'v')
6166 smsg((char_u *)_("Pattern found in every line: %s"), pat); 6166 smsg(_("Pattern found in every line: %s"), pat);
6167 else 6167 else
6168 smsg((char_u *)_("Pattern not found: %s"), pat); 6168 smsg(_("Pattern not found: %s"), pat);
6169 } 6169 }
6170 else 6170 else
6171 { 6171 {
6172 #ifdef FEAT_CLIPBOARD 6172 #ifdef FEAT_CLIPBOARD
6173 start_global_changes(); 6173 start_global_changes();
6364 } 6364 }
6365 arg = eap->arg; 6365 arg = eap->arg;
6366 6366
6367 if (eap->forceit && *arg == NUL && !curbuf->b_help) 6367 if (eap->forceit && *arg == NUL && !curbuf->b_help)
6368 { 6368 {
6369 EMSG(_("E478: Don't panic!")); 6369 emsg(_("E478: Don't panic!"));
6370 return; 6370 return;
6371 } 6371 }
6372 6372
6373 if (eap->skip) /* not executing commands */ 6373 if (eap->skip) /* not executing commands */
6374 return; 6374 return;
6410 #endif 6410 #endif
6411 if (i >= num_matches || n == FAIL) 6411 if (i >= num_matches || n == FAIL)
6412 { 6412 {
6413 #ifdef FEAT_MULTI_LANG 6413 #ifdef FEAT_MULTI_LANG
6414 if (lang != NULL) 6414 if (lang != NULL)
6415 EMSG3(_("E661: Sorry, no '%s' help for %s"), lang, arg); 6415 semsg(_("E661: Sorry, no '%s' help for %s"), lang, arg);
6416 else 6416 else
6417 #endif 6417 #endif
6418 EMSG2(_("E149: Sorry, no help for %s"), arg); 6418 semsg(_("E149: Sorry, no help for %s"), arg);
6419 if (n != FAIL) 6419 if (n != FAIL)
6420 FreeWild(num_matches, matches); 6420 FreeWild(num_matches, matches);
6421 return; 6421 return;
6422 } 6422 }
6423 6423
6449 * There is no help window yet. 6449 * There is no help window yet.
6450 * Try to open the file specified by the "helpfile" option. 6450 * Try to open the file specified by the "helpfile" option.
6451 */ 6451 */
6452 if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL) 6452 if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
6453 { 6453 {
6454 smsg((char_u *)_("Sorry, help file \"%s\" not found"), p_hf); 6454 smsg(_("Sorry, help file \"%s\" not found"), p_hf);
6455 goto erret; 6455 goto erret;
6456 } 6456 }
6457 fclose(helpfd); 6457 fclose(helpfd);
6458 6458
6459 /* Split off help window; put it at far top if no position 6459 /* Split off help window; put it at far top if no position
7228 if (gen_expand_wildcards(1, &NameBuff, &filecount, &files, 7228 if (gen_expand_wildcards(1, &NameBuff, &filecount, &files,
7229 EW_FILE|EW_SILENT) == FAIL 7229 EW_FILE|EW_SILENT) == FAIL
7230 || filecount == 0) 7230 || filecount == 0)
7231 { 7231 {
7232 if (!got_int) 7232 if (!got_int)
7233 EMSG2(_("E151: No match: %s"), NameBuff); 7233 semsg(_("E151: No match: %s"), NameBuff);
7234 return; 7234 return;
7235 } 7235 }
7236 7236
7237 /* 7237 /*
7238 * Open the tags file for writing. 7238 * Open the tags file for writing.
7242 add_pathsep(NameBuff); 7242 add_pathsep(NameBuff);
7243 STRCAT(NameBuff, tagfname); 7243 STRCAT(NameBuff, tagfname);
7244 fd_tags = mch_fopen((char *)NameBuff, "w"); 7244 fd_tags = mch_fopen((char *)NameBuff, "w");
7245 if (fd_tags == NULL) 7245 if (fd_tags == NULL)
7246 { 7246 {
7247 EMSG2(_("E152: Cannot open %s for writing"), NameBuff); 7247 semsg(_("E152: Cannot open %s for writing"), NameBuff);
7248 FreeWild(filecount, files); 7248 FreeWild(filecount, files);
7249 return; 7249 return;
7250 } 7250 }
7251 7251
7252 /* 7252 /*
7279 for (fi = 0; fi < filecount && !got_int; ++fi) 7279 for (fi = 0; fi < filecount && !got_int; ++fi)
7280 { 7280 {
7281 fd = mch_fopen((char *)files[fi], "r"); 7281 fd = mch_fopen((char *)files[fi], "r");
7282 if (fd == NULL) 7282 if (fd == NULL)
7283 { 7283 {
7284 EMSG2(_("E153: Unable to open %s for reading"), files[fi]); 7284 semsg(_("E153: Unable to open %s for reading"), files[fi]);
7285 continue; 7285 continue;
7286 } 7286 }
7287 fname = files[fi] + dirlen + 1; 7287 fname = files[fi] + dirlen + 1;
7288 7288
7289 # ifdef FEAT_MBYTE 7289 # ifdef FEAT_MBYTE
7315 this_utf8 = FALSE; 7315 this_utf8 = FALSE;
7316 if (utf8 == MAYBE) /* first file */ 7316 if (utf8 == MAYBE) /* first file */
7317 utf8 = this_utf8; 7317 utf8 = this_utf8;
7318 else if (utf8 != this_utf8) 7318 else if (utf8 != this_utf8)
7319 { 7319 {
7320 EMSG2(_("E670: Mix of help file encodings within a language: %s"), files[fi]); 7320 semsg(_("E670: Mix of help file encodings within a language: %s"), files[fi]);
7321 mix = !got_int; 7321 mix = !got_int;
7322 got_int = TRUE; 7322 got_int = TRUE;
7323 } 7323 }
7324 firstline = FALSE; 7324 firstline = FALSE;
7325 } 7325 }
7399 { 7399 {
7400 *p2 = NUL; 7400 *p2 = NUL;
7401 vim_snprintf((char *)NameBuff, MAXPATHL, 7401 vim_snprintf((char *)NameBuff, MAXPATHL,
7402 _("E154: Duplicate tag \"%s\" in file %s/%s"), 7402 _("E154: Duplicate tag \"%s\" in file %s/%s"),
7403 ((char_u **)ga.ga_data)[i], dir, p2 + 1); 7403 ((char_u **)ga.ga_data)[i], dir, p2 + 1);
7404 EMSG(NameBuff); 7404 emsg((char *)NameBuff);
7405 *p2 = '\t'; 7405 *p2 = '\t';
7406 break; 7406 break;
7407 } 7407 }
7408 ++p1; 7408 ++p1;
7409 ++p2; 7409 ++p2;
7471 STRCAT(NameBuff, "**"); 7471 STRCAT(NameBuff, "**");
7472 if (gen_expand_wildcards(1, &NameBuff, &filecount, &files, 7472 if (gen_expand_wildcards(1, &NameBuff, &filecount, &files,
7473 EW_FILE|EW_SILENT) == FAIL 7473 EW_FILE|EW_SILENT) == FAIL
7474 || filecount == 0) 7474 || filecount == 0)
7475 { 7475 {
7476 EMSG2(_("E151: No match: %s"), NameBuff); 7476 semsg(_("E151: No match: %s"), NameBuff);
7477 return; 7477 return;
7478 } 7478 }
7479 7479
7480 /* Go over all files in the directory to find out what languages are 7480 /* Go over all files in the directory to find out what languages are
7481 * present. */ 7481 * present. */
7584 ExpandInit(&xpc); 7584 ExpandInit(&xpc);
7585 xpc.xp_context = EXPAND_DIRECTORIES; 7585 xpc.xp_context = EXPAND_DIRECTORIES;
7586 dirname = ExpandOne(&xpc, eap->arg, NULL, 7586 dirname = ExpandOne(&xpc, eap->arg, NULL,
7587 WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); 7587 WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);
7588 if (dirname == NULL || !mch_isdir(dirname)) 7588 if (dirname == NULL || !mch_isdir(dirname))
7589 EMSG2(_("E150: Not a directory: %s"), eap->arg); 7589 semsg(_("E150: Not a directory: %s"), eap->arg);
7590 else 7590 else
7591 do_helptags(dirname, add_help_tags); 7591 do_helptags(dirname, add_help_tags);
7592 vim_free(dirname); 7592 vim_free(dirname);
7593 } 7593 }
7594 } 7594 }