Mercurial > vim
comparison src/ex_cmds2.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 | 4880dc2ccc3f |
children | dd725a8ab112 |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
144 | 144 |
145 if (!debug_did_msg) | 145 if (!debug_did_msg) |
146 MSG(_("Entering Debug mode. Type \"cont\" to continue.")); | 146 MSG(_("Entering Debug mode. Type \"cont\" to continue.")); |
147 if (debug_oldval != NULL) | 147 if (debug_oldval != NULL) |
148 { | 148 { |
149 smsg((char_u *)_("Oldval = \"%s\""), debug_oldval); | 149 smsg(_("Oldval = \"%s\""), debug_oldval); |
150 vim_free(debug_oldval); | 150 vim_free(debug_oldval); |
151 debug_oldval = NULL; | 151 debug_oldval = NULL; |
152 } | 152 } |
153 if (debug_newval != NULL) | 153 if (debug_newval != NULL) |
154 { | 154 { |
155 smsg((char_u *)_("Newval = \"%s\""), debug_newval); | 155 smsg(_("Newval = \"%s\""), debug_newval); |
156 vim_free(debug_newval); | 156 vim_free(debug_newval); |
157 debug_newval = NULL; | 157 debug_newval = NULL; |
158 } | 158 } |
159 if (sourcing_name != NULL) | 159 if (sourcing_name != NULL) |
160 msg(sourcing_name); | 160 msg(sourcing_name); |
161 if (sourcing_lnum != 0) | 161 if (sourcing_lnum != 0) |
162 smsg((char_u *)_("line %ld: %s"), (long)sourcing_lnum, cmd); | 162 smsg(_("line %ld: %s"), (long)sourcing_lnum, cmd); |
163 else | 163 else |
164 smsg((char_u *)_("cmd: %s"), cmd); | 164 smsg(_("cmd: %s"), cmd); |
165 /* | 165 /* |
166 * Repeat getting a command and executing it. | 166 * Repeat getting a command and executing it. |
167 */ | 167 */ |
168 for (;;) | 168 for (;;) |
169 { | 169 { |
397 int max = get_maxbacktrace_level(); | 397 int max = get_maxbacktrace_level(); |
398 | 398 |
399 if (debug_backtrace_level > max) | 399 if (debug_backtrace_level > max) |
400 { | 400 { |
401 debug_backtrace_level = max; | 401 debug_backtrace_level = max; |
402 smsg((char_u *)_("frame at highest level: %d"), max); | 402 smsg(_("frame at highest level: %d"), max); |
403 } | 403 } |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 static void | 407 static void |
419 { | 419 { |
420 next = strstr(cur, ".."); | 420 next = strstr(cur, ".."); |
421 if (next != NULL) | 421 if (next != NULL) |
422 *next = NUL; | 422 *next = NUL; |
423 if (i == max - debug_backtrace_level) | 423 if (i == max - debug_backtrace_level) |
424 smsg((char_u *)"->%d %s", max - i, cur); | 424 smsg("->%d %s", max - i, cur); |
425 else | 425 else |
426 smsg((char_u *)" %d %s", max - i, cur); | 426 smsg(" %d %s", max - i, cur); |
427 ++i; | 427 ++i; |
428 if (next == NULL) | 428 if (next == NULL) |
429 break; | 429 break; |
430 *next = '.'; | 430 *next = '.'; |
431 cur = next + 2; | 431 cur = next + 2; |
432 } | 432 } |
433 } | 433 } |
434 if (sourcing_lnum != 0) | 434 if (sourcing_lnum != 0) |
435 smsg((char_u *)_("line %ld: %s"), (long)sourcing_lnum, cmd); | 435 smsg(_("line %ld: %s"), (long)sourcing_lnum, cmd); |
436 else | 436 else |
437 smsg((char_u *)_("cmd: %s"), cmd); | 437 smsg(_("cmd: %s"), cmd); |
438 } | 438 } |
439 | 439 |
440 /* | 440 /* |
441 * ":debug". | 441 * ":debug". |
442 */ | 442 */ |
485 && debug_breakpoint_name[1] == KS_EXTRA | 485 && debug_breakpoint_name[1] == KS_EXTRA |
486 && debug_breakpoint_name[2] == (int)KE_SNR) | 486 && debug_breakpoint_name[2] == (int)KE_SNR) |
487 p = (char_u *)"<SNR>"; | 487 p = (char_u *)"<SNR>"; |
488 else | 488 else |
489 p = (char_u *)""; | 489 p = (char_u *)""; |
490 smsg((char_u *)_("Breakpoint in \"%s%s\" line %ld"), | 490 smsg(_("Breakpoint in \"%s%s\" line %ld"), |
491 p, | 491 p, |
492 debug_breakpoint_name + (*p == NUL ? 0 : 3), | 492 debug_breakpoint_name + (*p == NUL ? 0 : 3), |
493 (long)debug_breakpoint_lnum); | 493 (long)debug_breakpoint_lnum); |
494 debug_breakpoint_name = NULL; | 494 debug_breakpoint_name = NULL; |
495 do_debug(eap->cmd); | 495 do_debug(eap->cmd); |
605 #endif | 605 #endif |
606 STRNCMP(p, "here", 4) == 0) | 606 STRNCMP(p, "here", 4) == 0) |
607 { | 607 { |
608 if (curbuf->b_ffname == NULL) | 608 if (curbuf->b_ffname == NULL) |
609 { | 609 { |
610 EMSG(_(e_noname)); | 610 emsg(_(e_noname)); |
611 return FAIL; | 611 return FAIL; |
612 } | 612 } |
613 bp->dbg_type = DBG_FILE; | 613 bp->dbg_type = DBG_FILE; |
614 here = TRUE; | 614 here = TRUE; |
615 } | 615 } |
619 #endif | 619 #endif |
620 STRNCMP(p, "expr", 4) == 0) | 620 STRNCMP(p, "expr", 4) == 0) |
621 bp->dbg_type = DBG_EXPR; | 621 bp->dbg_type = DBG_EXPR; |
622 else | 622 else |
623 { | 623 { |
624 EMSG2(_(e_invarg2), p); | 624 semsg(_(e_invarg2), p); |
625 return FAIL; | 625 return FAIL; |
626 } | 626 } |
627 p = skipwhite(p + 4); | 627 p = skipwhite(p + 4); |
628 | 628 |
629 /* Find optional line number. */ | 629 /* Find optional line number. */ |
644 /* Find the function or file name. Don't accept a function name with (). */ | 644 /* Find the function or file name. Don't accept a function name with (). */ |
645 if ((!here && *p == NUL) | 645 if ((!here && *p == NUL) |
646 || (here && *p != NUL) | 646 || (here && *p != NUL) |
647 || (bp->dbg_type == DBG_FUNC && strstr((char *)p, "()") != NULL)) | 647 || (bp->dbg_type == DBG_FUNC && strstr((char *)p, "()") != NULL)) |
648 { | 648 { |
649 EMSG2(_(e_invarg2), arg); | 649 semsg(_(e_invarg2), arg); |
650 return FAIL; | 650 return FAIL; |
651 } | 651 } |
652 | 652 |
653 if (bp->dbg_type == DBG_FUNC) | 653 if (bp->dbg_type == DBG_FUNC) |
654 bp->dbg_name = vim_strsave(p); | 654 bp->dbg_name = vim_strsave(p); |
815 } | 815 } |
816 vim_free(bp->dbg_name); | 816 vim_free(bp->dbg_name); |
817 } | 817 } |
818 | 818 |
819 if (todel < 0) | 819 if (todel < 0) |
820 EMSG2(_("E161: Breakpoint not found: %s"), eap->arg); | 820 semsg(_("E161: Breakpoint not found: %s"), eap->arg); |
821 else | 821 else |
822 { | 822 { |
823 while (gap->ga_len > 0) | 823 while (gap->ga_len > 0) |
824 { | 824 { |
825 vim_free(DEBUGGY(gap, todel).dbg_name); | 825 vim_free(DEBUGGY(gap, todel).dbg_name); |
863 { | 863 { |
864 bp = &BREAKP(i); | 864 bp = &BREAKP(i); |
865 if (bp->dbg_type == DBG_FILE) | 865 if (bp->dbg_type == DBG_FILE) |
866 home_replace(NULL, bp->dbg_name, NameBuff, MAXPATHL, TRUE); | 866 home_replace(NULL, bp->dbg_name, NameBuff, MAXPATHL, TRUE); |
867 if (bp->dbg_type != DBG_EXPR) | 867 if (bp->dbg_type != DBG_EXPR) |
868 smsg((char_u *)_("%3d %s %s line %ld"), | 868 smsg(_("%3d %s %s line %ld"), |
869 bp->dbg_nr, | 869 bp->dbg_nr, |
870 bp->dbg_type == DBG_FUNC ? "func" : "file", | 870 bp->dbg_type == DBG_FUNC ? "func" : "file", |
871 bp->dbg_type == DBG_FUNC ? bp->dbg_name : NameBuff, | 871 bp->dbg_type == DBG_FUNC ? bp->dbg_name : NameBuff, |
872 (long)bp->dbg_lnum); | 872 (long)bp->dbg_lnum); |
873 else | 873 else |
874 smsg((char_u *)_("%3d expr %s"), | 874 smsg(_("%3d expr %s"), |
875 bp->dbg_nr, bp->dbg_name); | 875 bp->dbg_nr, bp->dbg_name); |
876 } | 876 } |
877 } | 877 } |
878 | 878 |
879 /* | 879 /* |
1724 do_profiling = PROF_YES; | 1724 do_profiling = PROF_YES; |
1725 profile_zero(&prof_wait_time); | 1725 profile_zero(&prof_wait_time); |
1726 set_vim_var_nr(VV_PROFILING, 1L); | 1726 set_vim_var_nr(VV_PROFILING, 1L); |
1727 } | 1727 } |
1728 else if (do_profiling == PROF_NONE) | 1728 else if (do_profiling == PROF_NONE) |
1729 EMSG(_("E750: First use \":profile start {fname}\"")); | 1729 emsg(_("E750: First use \":profile start {fname}\"")); |
1730 else if (STRCMP(eap->arg, "pause") == 0) | 1730 else if (STRCMP(eap->arg, "pause") == 0) |
1731 { | 1731 { |
1732 if (do_profiling == PROF_YES) | 1732 if (do_profiling == PROF_YES) |
1733 profile_start(&pause_time); | 1733 profile_start(&pause_time); |
1734 do_profiling = PROF_PAUSED; | 1734 do_profiling = PROF_PAUSED; |
1826 | 1826 |
1827 if (profile_fname != NULL) | 1827 if (profile_fname != NULL) |
1828 { | 1828 { |
1829 fd = mch_fopen((char *)profile_fname, "w"); | 1829 fd = mch_fopen((char *)profile_fname, "w"); |
1830 if (fd == NULL) | 1830 if (fd == NULL) |
1831 EMSG2(_(e_notopen), profile_fname); | 1831 semsg(_(e_notopen), profile_fname); |
1832 else | 1832 else |
1833 { | 1833 { |
1834 script_dump_profile(fd); | 1834 script_dump_profile(fd); |
1835 func_dump_profile(fd); | 1835 func_dump_profile(fd); |
1836 fclose(fd); | 1836 fclose(fd); |
2355 msg_didout = FALSE; | 2355 msg_didout = FALSE; |
2356 } | 2356 } |
2357 if ( | 2357 if ( |
2358 #ifdef FEAT_TERMINAL | 2358 #ifdef FEAT_TERMINAL |
2359 term_job_running(buf->b_term) | 2359 term_job_running(buf->b_term) |
2360 ? EMSG2(_("E947: Job still running in buffer \"%s\""), | 2360 ? semsg(_("E947: Job still running in buffer \"%s\""), |
2361 buf->b_fname) | 2361 buf->b_fname) |
2362 : | 2362 : |
2363 #endif | 2363 #endif |
2364 EMSG2(_("E162: No write since last change for buffer \"%s\""), | 2364 semsg(_("E162: No write since last change for buffer \"%s\""), |
2365 buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname)) | 2365 buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname)) |
2366 { | 2366 { |
2367 save = no_wait_return; | 2367 save = no_wait_return; |
2368 no_wait_return = FALSE; | 2368 no_wait_return = FALSE; |
2369 wait_return(FALSE); | 2369 wait_return(FALSE); |
2405 int | 2405 int |
2406 check_fname(void) | 2406 check_fname(void) |
2407 { | 2407 { |
2408 if (curbuf->b_ffname == NULL) | 2408 if (curbuf->b_ffname == NULL) |
2409 { | 2409 { |
2410 EMSG(_(e_noname)); | 2410 emsg(_(e_noname)); |
2411 return FAIL; | 2411 return FAIL; |
2412 } | 2412 } |
2413 return OK; | 2413 return OK; |
2414 } | 2414 } |
2415 | 2415 |
2627 } | 2627 } |
2628 | 2628 |
2629 vim_regfree(regmatch.regprog); | 2629 vim_regfree(regmatch.regprog); |
2630 vim_free(p); | 2630 vim_free(p); |
2631 if (!didone) | 2631 if (!didone) |
2632 EMSG2(_(e_nomatch2), ((char_u **)new_ga.ga_data)[i]); | 2632 semsg(_(e_nomatch2), ((char_u **)new_ga.ga_data)[i]); |
2633 } | 2633 } |
2634 ga_clear(&new_ga); | 2634 ga_clear(&new_ga); |
2635 } | 2635 } |
2636 else | 2636 else |
2637 { | 2637 { |
2638 i = expand_wildcards(new_ga.ga_len, (char_u **)new_ga.ga_data, | 2638 i = expand_wildcards(new_ga.ga_len, (char_u **)new_ga.ga_data, |
2639 &exp_count, &exp_files, EW_DIR|EW_FILE|EW_ADDSLASH|EW_NOTFOUND); | 2639 &exp_count, &exp_files, EW_DIR|EW_FILE|EW_ADDSLASH|EW_NOTFOUND); |
2640 ga_clear(&new_ga); | 2640 ga_clear(&new_ga); |
2641 if (i == FAIL || exp_count == 0) | 2641 if (i == FAIL || exp_count == 0) |
2642 { | 2642 { |
2643 EMSG(_(e_nomatch)); | 2643 emsg(_(e_nomatch)); |
2644 return FAIL; | 2644 return FAIL; |
2645 } | 2645 } |
2646 | 2646 |
2647 if (what == AL_ADD) | 2647 if (what == AL_ADD) |
2648 { | 2648 { |
2845 int old_arg_idx = curwin->w_arg_idx; | 2845 int old_arg_idx = curwin->w_arg_idx; |
2846 | 2846 |
2847 if (argn < 0 || argn >= ARGCOUNT) | 2847 if (argn < 0 || argn >= ARGCOUNT) |
2848 { | 2848 { |
2849 if (ARGCOUNT <= 1) | 2849 if (ARGCOUNT <= 1) |
2850 EMSG(_("E163: There is only one file to edit")); | 2850 emsg(_("E163: There is only one file to edit")); |
2851 else if (argn < 0) | 2851 else if (argn < 0) |
2852 EMSG(_("E164: Cannot go before first file")); | 2852 emsg(_("E164: Cannot go before first file")); |
2853 else | 2853 else |
2854 EMSG(_("E165: Cannot go beyond last file")); | 2854 emsg(_("E165: Cannot go beyond last file")); |
2855 } | 2855 } |
2856 else | 2856 else |
2857 { | 2857 { |
2858 setpcmark(); | 2858 setpcmark(); |
2859 #ifdef FEAT_GUI | 2859 #ifdef FEAT_GUI |
2990 if (eap->line2 > ARGCOUNT) | 2990 if (eap->line2 > ARGCOUNT) |
2991 eap->line2 = ARGCOUNT; | 2991 eap->line2 = ARGCOUNT; |
2992 n = eap->line2 - eap->line1 + 1; | 2992 n = eap->line2 - eap->line1 + 1; |
2993 if (*eap->arg != NUL) | 2993 if (*eap->arg != NUL) |
2994 /* Can't have both a range and an argument. */ | 2994 /* Can't have both a range and an argument. */ |
2995 EMSG(_(e_invarg)); | 2995 emsg(_(e_invarg)); |
2996 else if (n <= 0) | 2996 else if (n <= 0) |
2997 { | 2997 { |
2998 /* Don't give an error for ":%argdel" if the list is empty. */ | 2998 /* Don't give an error for ":%argdel" if the list is empty. */ |
2999 if (eap->line1 != 1 || eap->line2 != 0) | 2999 if (eap->line1 != 1 || eap->line2 != 0) |
3000 EMSG(_(e_invrange)); | 3000 emsg(_(e_invrange)); |
3001 } | 3001 } |
3002 else | 3002 else |
3003 { | 3003 { |
3004 for (i = eap->line1; i <= eap->line2; ++i) | 3004 for (i = eap->line1; i <= eap->line2; ++i) |
3005 vim_free(ARGLIST[i - 1].ae_fname); | 3005 vim_free(ARGLIST[i - 1].ae_fname); |
3015 else if (curwin->w_arg_idx >= ARGCOUNT) | 3015 else if (curwin->w_arg_idx >= ARGCOUNT) |
3016 curwin->w_arg_idx = ARGCOUNT - 1; | 3016 curwin->w_arg_idx = ARGCOUNT - 1; |
3017 } | 3017 } |
3018 } | 3018 } |
3019 else if (*eap->arg == NUL) | 3019 else if (*eap->arg == NUL) |
3020 EMSG(_(e_argreq)); | 3020 emsg(_(e_argreq)); |
3021 else | 3021 else |
3022 do_arglist(eap->arg, AL_DEL, 0, FALSE); | 3022 do_arglist(eap->arg, AL_DEL, 0, FALSE); |
3023 #ifdef FEAT_TITLE | 3023 #ifdef FEAT_TITLE |
3024 maketitle(); | 3024 maketitle(); |
3025 #endif | 3025 #endif |
3362 do_unlet((char_u *)"g:current_compiler", TRUE); | 3362 do_unlet((char_u *)"g:current_compiler", TRUE); |
3363 do_unlet((char_u *)"b:current_compiler", TRUE); | 3363 do_unlet((char_u *)"b:current_compiler", TRUE); |
3364 | 3364 |
3365 sprintf((char *)buf, "compiler/%s.vim", eap->arg); | 3365 sprintf((char *)buf, "compiler/%s.vim", eap->arg); |
3366 if (source_runtime(buf, DIP_ALL) == FAIL) | 3366 if (source_runtime(buf, DIP_ALL) == FAIL) |
3367 EMSG2(_("E666: compiler not supported: %s"), eap->arg); | 3367 semsg(_("E666: compiler not supported: %s"), eap->arg); |
3368 vim_free(buf); | 3368 vim_free(buf); |
3369 | 3369 |
3370 do_cmdline_cmd((char_u *)":delcommand CompilerSet"); | 3370 do_cmdline_cmd((char_u *)":delcommand CompilerSet"); |
3371 | 3371 |
3372 /* Set "b:current_compiler" from "current_compiler". */ | 3372 /* Set "b:current_compiler" from "current_compiler". */ |
3474 if (buf != NULL && rtp_copy != NULL) | 3474 if (buf != NULL && rtp_copy != NULL) |
3475 { | 3475 { |
3476 if (p_verbose > 1 && name != NULL) | 3476 if (p_verbose > 1 && name != NULL) |
3477 { | 3477 { |
3478 verbose_enter(); | 3478 verbose_enter(); |
3479 smsg((char_u *)_("Searching for \"%s\" in \"%s\""), | 3479 smsg(_("Searching for \"%s\" in \"%s\""), |
3480 (char *)name, (char *)path); | 3480 (char *)name, (char *)path); |
3481 verbose_leave(); | 3481 verbose_leave(); |
3482 } | 3482 } |
3483 | 3483 |
3484 /* Loop over all entries in 'runtimepath'. */ | 3484 /* Loop over all entries in 'runtimepath'. */ |
3522 "\t "); | 3522 "\t "); |
3523 | 3523 |
3524 if (p_verbose > 2) | 3524 if (p_verbose > 2) |
3525 { | 3525 { |
3526 verbose_enter(); | 3526 verbose_enter(); |
3527 smsg((char_u *)_("Searching for \"%s\""), buf); | 3527 smsg(_("Searching for \"%s\""), buf); |
3528 verbose_leave(); | 3528 verbose_leave(); |
3529 } | 3529 } |
3530 | 3530 |
3531 /* Expand wildcards, invoke the callback for each match. */ | 3531 /* Expand wildcards, invoke the callback for each match. */ |
3532 if (gen_expand_wildcards(1, &buf, &num_files, &files, | 3532 if (gen_expand_wildcards(1, &buf, &num_files, &files, |
3550 if (!did_one && name != NULL) | 3550 if (!did_one && name != NULL) |
3551 { | 3551 { |
3552 char *basepath = path == p_rtp ? "runtimepath" : "packpath"; | 3552 char *basepath = path == p_rtp ? "runtimepath" : "packpath"; |
3553 | 3553 |
3554 if (flags & DIP_ERR) | 3554 if (flags & DIP_ERR) |
3555 EMSG3(_(e_dirnotf), basepath, name); | 3555 semsg(_(e_dirnotf), basepath, name); |
3556 else if (p_verbose > 0) | 3556 else if (p_verbose > 0) |
3557 { | 3557 { |
3558 verbose_enter(); | 3558 verbose_enter(); |
3559 smsg((char_u *)_("not found in '%s': \"%s\""), basepath, name); | 3559 smsg(_("not found in '%s': \"%s\""), basepath, name); |
3560 verbose_leave(); | 3560 verbose_leave(); |
3561 } | 3561 } |
3562 } | 3562 } |
3563 | 3563 |
3564 #ifdef AMIGA | 3564 #ifdef AMIGA |
4206 | 4206 |
4207 static void | 4207 static void |
4208 cmd_source(char_u *fname, exarg_T *eap) | 4208 cmd_source(char_u *fname, exarg_T *eap) |
4209 { | 4209 { |
4210 if (*fname == NUL) | 4210 if (*fname == NUL) |
4211 EMSG(_(e_argreq)); | 4211 emsg(_(e_argreq)); |
4212 | 4212 |
4213 else if (eap != NULL && eap->forceit) | 4213 else if (eap != NULL && eap->forceit) |
4214 /* ":source!": read Normal mode commands | 4214 /* ":source!": read Normal mode commands |
4215 * Need to execute the commands directly. This is required at least | 4215 * Need to execute the commands directly. This is required at least |
4216 * for: | 4216 * for: |
4225 #endif | 4225 #endif |
4226 ); | 4226 ); |
4227 | 4227 |
4228 /* ":source" read ex commands */ | 4228 /* ":source" read ex commands */ |
4229 else if (do_source(fname, FALSE, DOSO_NONE) == FAIL) | 4229 else if (do_source(fname, FALSE, DOSO_NONE) == FAIL) |
4230 EMSG2(_(e_notopen), fname); | 4230 semsg(_(e_notopen), fname); |
4231 } | 4231 } |
4232 | 4232 |
4233 /* | 4233 /* |
4234 * ":source" and associated commands. | 4234 * ":source" and associated commands. |
4235 */ | 4235 */ |
4369 vim_free(p); | 4369 vim_free(p); |
4370 if (fname_exp == NULL) | 4370 if (fname_exp == NULL) |
4371 return retval; | 4371 return retval; |
4372 if (mch_isdir(fname_exp)) | 4372 if (mch_isdir(fname_exp)) |
4373 { | 4373 { |
4374 smsg((char_u *)_("Cannot source a directory: \"%s\""), fname); | 4374 smsg(_("Cannot source a directory: \"%s\""), fname); |
4375 goto theend; | 4375 goto theend; |
4376 } | 4376 } |
4377 | 4377 |
4378 /* Apply SourceCmd autocommands, they should get the file and source it. */ | 4378 /* Apply SourceCmd autocommands, they should get the file and source it. */ |
4379 if (has_autocmd(EVENT_SOURCECMD, fname_exp, NULL) | 4379 if (has_autocmd(EVENT_SOURCECMD, fname_exp, NULL) |
4428 { | 4428 { |
4429 if (p_verbose > 0) | 4429 if (p_verbose > 0) |
4430 { | 4430 { |
4431 verbose_enter(); | 4431 verbose_enter(); |
4432 if (sourcing_name == NULL) | 4432 if (sourcing_name == NULL) |
4433 smsg((char_u *)_("could not source \"%s\""), fname); | 4433 smsg(_("could not source \"%s\""), fname); |
4434 else | 4434 else |
4435 smsg((char_u *)_("line %ld: could not source \"%s\""), | 4435 smsg(_("line %ld: could not source \"%s\""), |
4436 sourcing_lnum, fname); | 4436 sourcing_lnum, fname); |
4437 verbose_leave(); | 4437 verbose_leave(); |
4438 } | 4438 } |
4439 goto theend; | 4439 goto theend; |
4440 } | 4440 } |
4446 */ | 4446 */ |
4447 if (p_verbose > 1) | 4447 if (p_verbose > 1) |
4448 { | 4448 { |
4449 verbose_enter(); | 4449 verbose_enter(); |
4450 if (sourcing_name == NULL) | 4450 if (sourcing_name == NULL) |
4451 smsg((char_u *)_("sourcing \"%s\""), fname); | 4451 smsg(_("sourcing \"%s\""), fname); |
4452 else | 4452 else |
4453 smsg((char_u *)_("line %ld: sourcing \"%s\""), | 4453 smsg(_("line %ld: sourcing \"%s\""), |
4454 sourcing_lnum, fname); | 4454 sourcing_lnum, fname); |
4455 verbose_leave(); | 4455 verbose_leave(); |
4456 } | 4456 } |
4457 if (is_vimrc == DOSO_VIMRC) | 4457 if (is_vimrc == DOSO_VIMRC) |
4458 vimrc_found(fname_exp, (char_u *)"MYVIMRC"); | 4458 vimrc_found(fname_exp, (char_u *)"MYVIMRC"); |
4636 } | 4636 } |
4637 } | 4637 } |
4638 #endif | 4638 #endif |
4639 | 4639 |
4640 if (got_int) | 4640 if (got_int) |
4641 EMSG(_(e_interr)); | 4641 emsg(_(e_interr)); |
4642 sourcing_name = save_sourcing_name; | 4642 sourcing_name = save_sourcing_name; |
4643 sourcing_lnum = save_sourcing_lnum; | 4643 sourcing_lnum = save_sourcing_lnum; |
4644 if (p_verbose > 1) | 4644 if (p_verbose > 1) |
4645 { | 4645 { |
4646 verbose_enter(); | 4646 verbose_enter(); |
4647 smsg((char_u *)_("finished sourcing %s"), fname); | 4647 smsg(_("finished sourcing %s"), fname); |
4648 if (sourcing_name != NULL) | 4648 if (sourcing_name != NULL) |
4649 smsg((char_u *)_("continuing in %s"), sourcing_name); | 4649 smsg(_("continuing in %s"), sourcing_name); |
4650 verbose_leave(); | 4650 verbose_leave(); |
4651 } | 4651 } |
4652 #ifdef STARTUPTIME | 4652 #ifdef STARTUPTIME |
4653 if (time_fd != NULL) | 4653 if (time_fd != NULL) |
4654 { | 4654 { |
4707 | 4707 |
4708 if (eap->addr_count > 0) | 4708 if (eap->addr_count > 0) |
4709 { | 4709 { |
4710 // :script {scriptId}: edit the script | 4710 // :script {scriptId}: edit the script |
4711 if (eap->line2 < 1 || eap->line2 > script_items.ga_len) | 4711 if (eap->line2 < 1 || eap->line2 > script_items.ga_len) |
4712 EMSG(_(e_invarg)); | 4712 emsg(_(e_invarg)); |
4713 else | 4713 else |
4714 { | 4714 { |
4715 eap->arg = SCRIPT_ITEM(eap->line2).sn_name; | 4715 eap->arg = SCRIPT_ITEM(eap->line2).sn_name; |
4716 do_exedit(eap, NULL); | 4716 do_exedit(eap, NULL); |
4717 } | 4717 } |
4721 for (i = 1; i <= script_items.ga_len && !got_int; ++i) | 4721 for (i = 1; i <= script_items.ga_len && !got_int; ++i) |
4722 if (SCRIPT_ITEM(i).sn_name != NULL) | 4722 if (SCRIPT_ITEM(i).sn_name != NULL) |
4723 { | 4723 { |
4724 home_replace(NULL, SCRIPT_ITEM(i).sn_name, | 4724 home_replace(NULL, SCRIPT_ITEM(i).sn_name, |
4725 NameBuff, MAXPATHL, TRUE); | 4725 NameBuff, MAXPATHL, TRUE); |
4726 smsg((char_u *)"%3d: %s", i, NameBuff); | 4726 smsg("%3d: %s", i, NameBuff); |
4727 } | 4727 } |
4728 } | 4728 } |
4729 | 4729 |
4730 # if defined(BACKSLASH_IN_FILENAME) || defined(PROTO) | 4730 # if defined(BACKSLASH_IN_FILENAME) || defined(PROTO) |
4731 /* | 4731 /* |
5065 else /* lines like ":map xx yy^M" will have failed */ | 5065 else /* lines like ":map xx yy^M" will have failed */ |
5066 { | 5066 { |
5067 if (!sp->error) | 5067 if (!sp->error) |
5068 { | 5068 { |
5069 msg_source(HL_ATTR(HLF_W)); | 5069 msg_source(HL_ATTR(HLF_W)); |
5070 EMSG(_("W15: Warning: Wrong line separator, ^M may be missing")); | 5070 emsg(_("W15: Warning: Wrong line separator, ^M may be missing")); |
5071 } | 5071 } |
5072 sp->error = TRUE; | 5072 sp->error = TRUE; |
5073 sp->fileformat = EOL_UNIX; | 5073 sp->fileformat = EOL_UNIX; |
5074 } | 5074 } |
5075 } | 5075 } |
5198 struct source_cookie *sp; | 5198 struct source_cookie *sp; |
5199 char_u *name; | 5199 char_u *name; |
5200 | 5200 |
5201 if (!getline_equal(eap->getline, eap->cookie, getsourceline)) | 5201 if (!getline_equal(eap->getline, eap->cookie, getsourceline)) |
5202 { | 5202 { |
5203 EMSG(_("E167: :scriptencoding used outside of a sourced file")); | 5203 emsg(_("E167: :scriptencoding used outside of a sourced file")); |
5204 return; | 5204 return; |
5205 } | 5205 } |
5206 | 5206 |
5207 if (*eap->arg != NUL) | 5207 if (*eap->arg != NUL) |
5208 { | 5208 { |
5230 ex_finish(exarg_T *eap) | 5230 ex_finish(exarg_T *eap) |
5231 { | 5231 { |
5232 if (getline_equal(eap->getline, eap->cookie, getsourceline)) | 5232 if (getline_equal(eap->getline, eap->cookie, getsourceline)) |
5233 do_finish(eap, FALSE); | 5233 do_finish(eap, FALSE); |
5234 else | 5234 else |
5235 EMSG(_("E168: :finish used outside of a sourced file")); | 5235 emsg(_("E168: :finish used outside of a sourced file")); |
5236 } | 5236 } |
5237 | 5237 |
5238 /* | 5238 /* |
5239 * Mark a sourced file as finished. Possibly makes the ":finish" pending. | 5239 * Mark a sourced file as finished. Possibly makes the ":finish" pending. |
5240 * Also called for a pending finish at the ":endtry" or after returning from | 5240 * Also called for a pending finish at the ":endtry" or after returning from |
5551 else | 5551 else |
5552 #endif | 5552 #endif |
5553 p = (char_u *)setlocale(what, NULL); | 5553 p = (char_u *)setlocale(what, NULL); |
5554 if (p == NULL || *p == NUL) | 5554 if (p == NULL || *p == NUL) |
5555 p = (char_u *)"Unknown"; | 5555 p = (char_u *)"Unknown"; |
5556 smsg((char_u *)_("Current %slanguage: \"%s\""), whatstr, p); | 5556 smsg(_("Current %slanguage: \"%s\""), whatstr, p); |
5557 } | 5557 } |
5558 else | 5558 else |
5559 { | 5559 { |
5560 #ifndef LC_MESSAGES | 5560 #ifndef LC_MESSAGES |
5561 if (what == VIM_LC_MESSAGES) | 5561 if (what == VIM_LC_MESSAGES) |
5568 /* Make sure strtod() uses a decimal point, not a comma. */ | 5568 /* Make sure strtod() uses a decimal point, not a comma. */ |
5569 setlocale(LC_NUMERIC, "C"); | 5569 setlocale(LC_NUMERIC, "C"); |
5570 #endif | 5570 #endif |
5571 } | 5571 } |
5572 if (loc == NULL) | 5572 if (loc == NULL) |
5573 EMSG2(_("E197: Cannot set language to \"%s\""), name); | 5573 semsg(_("E197: Cannot set language to \"%s\""), name); |
5574 else | 5574 else |
5575 { | 5575 { |
5576 #ifdef HAVE_NL_MSG_CAT_CNTR | 5576 #ifdef HAVE_NL_MSG_CAT_CNTR |
5577 /* Need to do this for GNU gettext, otherwise cached translations | 5577 /* Need to do this for GNU gettext, otherwise cached translations |
5578 * will be used again. */ | 5578 * will be used again. */ |