Mercurial > vim
comparison src/ex_getln.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 | db5d2429bda3 |
children | dd725a8ab112 |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
273 cmdmod_T save_cmdmod = cmdmod; | 273 cmdmod_T save_cmdmod = cmdmod; |
274 char_u *p; | 274 char_u *p; |
275 int delim_optional = FALSE; | 275 int delim_optional = FALSE; |
276 int delim; | 276 int delim; |
277 char_u *end; | 277 char_u *end; |
278 char_u *dummy; | 278 char *dummy; |
279 exarg_T ea; | 279 exarg_T ea; |
280 pos_T save_cursor; | 280 pos_T save_cursor; |
281 int use_last_pat; | 281 int use_last_pat; |
282 | 282 |
283 *skiplen = 0; | 283 *skiplen = 0; |
2599 * window is open or editing the cmdline in another way. | 2599 * window is open or editing the cmdline in another way. |
2600 */ | 2600 */ |
2601 void | 2601 void |
2602 text_locked_msg(void) | 2602 text_locked_msg(void) |
2603 { | 2603 { |
2604 EMSG(_(get_text_locked_msg())); | 2604 emsg(_(get_text_locked_msg())); |
2605 } | 2605 } |
2606 | 2606 |
2607 char_u * | 2607 char * |
2608 get_text_locked_msg(void) | 2608 get_text_locked_msg(void) |
2609 { | 2609 { |
2610 #ifdef FEAT_CMDWIN | 2610 #ifdef FEAT_CMDWIN |
2611 if (cmdwin_type != 0) | 2611 if (cmdwin_type != 0) |
2612 return e_cmdwin; | 2612 return e_cmdwin; |
2621 int | 2621 int |
2622 curbuf_locked(void) | 2622 curbuf_locked(void) |
2623 { | 2623 { |
2624 if (curbuf_lock > 0) | 2624 if (curbuf_lock > 0) |
2625 { | 2625 { |
2626 EMSG(_("E788: Not allowed to edit another buffer now")); | 2626 emsg(_("E788: Not allowed to edit another buffer now")); |
2627 return TRUE; | 2627 return TRUE; |
2628 } | 2628 } |
2629 return allbuf_locked(); | 2629 return allbuf_locked(); |
2630 } | 2630 } |
2631 | 2631 |
2636 int | 2636 int |
2637 allbuf_locked(void) | 2637 allbuf_locked(void) |
2638 { | 2638 { |
2639 if (allbuf_lock > 0) | 2639 if (allbuf_lock > 0) |
2640 { | 2640 { |
2641 EMSG(_("E811: Not allowed to change buffer information now")); | 2641 emsg(_("E811: Not allowed to change buffer information now")); |
2642 return TRUE; | 2642 return TRUE; |
2643 } | 2643 } |
2644 return FALSE; | 2644 return FALSE; |
2645 } | 2645 } |
2646 | 2646 |
4172 /* Illegal file name has been silently skipped. But when there | 4172 /* Illegal file name has been silently skipped. But when there |
4173 * are wildcards, the real problem is that there was no match, | 4173 * are wildcards, the real problem is that there was no match, |
4174 * causing the pattern to be added, which has illegal characters. | 4174 * causing the pattern to be added, which has illegal characters. |
4175 */ | 4175 */ |
4176 if (!(options & WILD_SILENT) && (options & WILD_LIST_NOTFOUND)) | 4176 if (!(options & WILD_SILENT) && (options & WILD_LIST_NOTFOUND)) |
4177 EMSG2(_(e_nomatch2), str); | 4177 semsg(_(e_nomatch2), str); |
4178 #endif | 4178 #endif |
4179 } | 4179 } |
4180 else if (xp->xp_numfiles == 0) | 4180 else if (xp->xp_numfiles == 0) |
4181 { | 4181 { |
4182 if (!(options & WILD_SILENT)) | 4182 if (!(options & WILD_SILENT)) |
4183 EMSG2(_(e_nomatch2), str); | 4183 semsg(_(e_nomatch2), str); |
4184 } | 4184 } |
4185 else | 4185 else |
4186 { | 4186 { |
4187 /* Escape the matches for use on the command line. */ | 4187 /* Escape the matches for use on the command line. */ |
4188 ExpandEscape(xp, str, xp->xp_numfiles, xp->xp_files, options); | 4188 ExpandEscape(xp, str, xp->xp_numfiles, xp->xp_files, options); |
4217 * interactively? If not, we can get rid of this all | 4217 * interactively? If not, we can get rid of this all |
4218 * together. Don't really want to wait for this message | 4218 * together. Don't really want to wait for this message |
4219 * (and possibly have to hit return to continue!). | 4219 * (and possibly have to hit return to continue!). |
4220 */ | 4220 */ |
4221 if (!(options & WILD_SILENT)) | 4221 if (!(options & WILD_SILENT)) |
4222 EMSG(_(e_toomany)); | 4222 emsg(_(e_toomany)); |
4223 else if (!(options & WILD_NO_BEEP)) | 4223 else if (!(options & WILD_NO_BEEP)) |
4224 beep_flush(); | 4224 beep_flush(); |
4225 } | 4225 } |
4226 if (!(non_suf_match != 1 && mode == WILD_EXPAND_FREE)) | 4226 if (!(non_suf_match != 1 && mode == WILD_EXPAND_FREE)) |
4227 ss = vim_strsave(xp->xp_files[0]); | 4227 ss = vim_strsave(xp->xp_files[0]); |
6656 histype2 = HIST_COUNT-1; | 6656 histype2 = HIST_COUNT-1; |
6657 } | 6657 } |
6658 else | 6658 else |
6659 { | 6659 { |
6660 *end = i; | 6660 *end = i; |
6661 EMSG(_(e_trailing)); | 6661 emsg(_(e_trailing)); |
6662 return; | 6662 return; |
6663 } | 6663 } |
6664 } | 6664 } |
6665 else | 6665 else |
6666 histype2 = histype1; | 6666 histype2 = histype1; |
6668 } | 6668 } |
6669 else | 6669 else |
6670 end = arg; | 6670 end = arg; |
6671 if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) | 6671 if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) |
6672 { | 6672 { |
6673 EMSG(_(e_trailing)); | 6673 emsg(_(e_trailing)); |
6674 return; | 6674 return; |
6675 } | 6675 } |
6676 | 6676 |
6677 for (; !got_int && histype1 <= histype2; ++histype1) | 6677 for (; !got_int && histype1 <= histype2; ++histype1) |
6678 { | 6678 { |
7199 void | 7199 void |
7200 cmd_pchar(int c, int offset) | 7200 cmd_pchar(int c, int offset) |
7201 { | 7201 { |
7202 if (ccline.cmdpos + offset >= ccline.cmdlen || ccline.cmdpos + offset < 0) | 7202 if (ccline.cmdpos + offset >= ccline.cmdlen || ccline.cmdpos + offset < 0) |
7203 { | 7203 { |
7204 EMSG(_("E198: cmd_pchar beyond the command length")); | 7204 emsg(_("E198: cmd_pchar beyond the command length")); |
7205 return; | 7205 return; |
7206 } | 7206 } |
7207 ccline.cmdbuff[ccline.cmdpos + offset] = (char_u)c; | 7207 ccline.cmdbuff[ccline.cmdpos + offset] = (char_u)c; |
7208 ccline.cmdbuff[ccline.cmdlen] = NUL; | 7208 ccline.cmdbuff[ccline.cmdlen] = NUL; |
7209 } | 7209 } |
7211 int | 7211 int |
7212 cmd_gchar(int offset) | 7212 cmd_gchar(int offset) |
7213 { | 7213 { |
7214 if (ccline.cmdpos + offset >= ccline.cmdlen || ccline.cmdpos + offset < 0) | 7214 if (ccline.cmdpos + offset >= ccline.cmdlen || ccline.cmdpos + offset < 0) |
7215 { | 7215 { |
7216 /* EMSG(_("cmd_gchar beyond the command length")); */ | 7216 // emsg(_("cmd_gchar beyond the command length")); |
7217 return NUL; | 7217 return NUL; |
7218 } | 7218 } |
7219 return (int)ccline.cmdbuff[ccline.cmdpos + offset]; | 7219 return (int)ccline.cmdbuff[ccline.cmdpos + offset]; |
7220 } | 7220 } |
7221 #endif | 7221 #endif |
7390 /* Safety check: The old window or buffer was deleted: It's a bug when | 7390 /* Safety check: The old window or buffer was deleted: It's a bug when |
7391 * this happens! */ | 7391 * this happens! */ |
7392 if (!win_valid(old_curwin) || !bufref_valid(&old_curbuf)) | 7392 if (!win_valid(old_curwin) || !bufref_valid(&old_curbuf)) |
7393 { | 7393 { |
7394 cmdwin_result = Ctrl_C; | 7394 cmdwin_result = Ctrl_C; |
7395 EMSG(_("E199: Active window or buffer deleted")); | 7395 emsg(_("E199: Active window or buffer deleted")); |
7396 } | 7396 } |
7397 else | 7397 else |
7398 { | 7398 { |
7399 # if defined(FEAT_EVAL) | 7399 # if defined(FEAT_EVAL) |
7400 /* autocmds may abort script processing */ | 7400 /* autocmds may abort script processing */ |