Mercurial > vim
comparison src/spell.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 | 6e4e0d43b20b |
children | dd725a8ab112 |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
715 if (byts[arridx] == 0) | 715 if (byts[arridx] == 0) |
716 { | 716 { |
717 if (endidxcnt == MAXWLEN) | 717 if (endidxcnt == MAXWLEN) |
718 { | 718 { |
719 /* Must be a corrupted spell file. */ | 719 /* Must be a corrupted spell file. */ |
720 EMSG(_(e_format)); | 720 emsg(_(e_format)); |
721 return; | 721 return; |
722 } | 722 } |
723 endlen[endidxcnt] = wlen; | 723 endlen[endidxcnt] = wlen; |
724 endidx[endidxcnt++] = arridx++; | 724 endidx[endidxcnt++] = arridx++; |
725 --len; | 725 --len; |
1535 no_spell_checking(win_T *wp) | 1535 no_spell_checking(win_T *wp) |
1536 { | 1536 { |
1537 if (!wp->w_p_spell || *wp->w_s->b_p_spl == NUL | 1537 if (!wp->w_p_spell || *wp->w_s->b_p_spl == NUL |
1538 || wp->w_s->b_langp.ga_len == 0) | 1538 || wp->w_s->b_langp.ga_len == 0) |
1539 { | 1539 { |
1540 EMSG(_("E756: Spell checking is not enabled")); | 1540 emsg(_("E756: Spell checking is not enabled")); |
1541 return TRUE; | 1541 return TRUE; |
1542 } | 1542 } |
1543 return FALSE; | 1543 return FALSE; |
1544 } | 1544 } |
1545 | 1545 |
1886 break; | 1886 break; |
1887 } | 1887 } |
1888 | 1888 |
1889 if (r == FAIL) | 1889 if (r == FAIL) |
1890 { | 1890 { |
1891 smsg((char_u *) | 1891 smsg( |
1892 #ifdef VMS | 1892 #ifdef VMS |
1893 _("Warning: Cannot find word list \"%s_%s.spl\" or \"%s_ascii.spl\""), | 1893 _("Warning: Cannot find word list \"%s_%s.spl\" or \"%s_ascii.spl\""), |
1894 #else | 1894 #else |
1895 _("Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\""), | 1895 _("Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\""), |
1896 #endif | 1896 #endif |
2305 | 2305 |
2306 /* | 2306 /* |
2307 * Parse 'spelllang' and set w_s->b_langp accordingly. | 2307 * Parse 'spelllang' and set w_s->b_langp accordingly. |
2308 * Returns NULL if it's OK, an error message otherwise. | 2308 * Returns NULL if it's OK, an error message otherwise. |
2309 */ | 2309 */ |
2310 char_u * | 2310 char * |
2311 did_set_spelllang(win_T *wp) | 2311 did_set_spelllang(win_T *wp) |
2312 { | 2312 { |
2313 garray_T ga; | 2313 garray_T ga; |
2314 char_u *splp; | 2314 char_u *splp; |
2315 char_u *region; | 2315 char_u *region; |
2328 int dont_use_region = FALSE; | 2328 int dont_use_region = FALSE; |
2329 int nobreak = FALSE; | 2329 int nobreak = FALSE; |
2330 int i, j; | 2330 int i, j; |
2331 langp_T *lp, *lp2; | 2331 langp_T *lp, *lp2; |
2332 static int recursive = FALSE; | 2332 static int recursive = FALSE; |
2333 char_u *ret_msg = NULL; | 2333 char *ret_msg = NULL; |
2334 char_u *spl_copy; | 2334 char_u *spl_copy; |
2335 bufref_T bufref; | 2335 bufref_T bufref; |
2336 | 2336 |
2337 set_bufref(&bufref, wp->w_buffer); | 2337 set_bufref(&bufref, wp->w_buffer); |
2338 | 2338 |
2433 spell_load_lang(lang); | 2433 spell_load_lang(lang); |
2434 /* SpellFileMissing autocommands may do anything, including | 2434 /* SpellFileMissing autocommands may do anything, including |
2435 * destroying the buffer we are using... */ | 2435 * destroying the buffer we are using... */ |
2436 if (!bufref_valid(&bufref)) | 2436 if (!bufref_valid(&bufref)) |
2437 { | 2437 { |
2438 ret_msg = (char_u *)N_("E797: SpellFileMissing autocommand deleted buffer"); | 2438 ret_msg = N_("E797: SpellFileMissing autocommand deleted buffer"); |
2439 goto theend; | 2439 goto theend; |
2440 } | 2440 } |
2441 } | 2441 } |
2442 } | 2442 } |
2443 | 2443 |
2462 region_mask = 0; | 2462 region_mask = 0; |
2463 } | 2463 } |
2464 else | 2464 else |
2465 /* This is probably an error. Give a warning and | 2465 /* This is probably an error. Give a warning and |
2466 * accept the words anyway. */ | 2466 * accept the words anyway. */ |
2467 smsg((char_u *) | 2467 smsg(_("Warning: region %s not supported"), |
2468 _("Warning: region %s not supported"), | |
2469 region); | 2468 region); |
2470 } | 2469 } |
2471 else | 2470 else |
2472 region_mask = 1 << c; | 2471 region_mask = 1 << c; |
2473 } | 2472 } |
3378 if (sug.su_ga.ga_len == 0) | 3377 if (sug.su_ga.ga_len == 0) |
3379 MSG(_("Sorry, no suggestions")); | 3378 MSG(_("Sorry, no suggestions")); |
3380 else if (count > 0) | 3379 else if (count > 0) |
3381 { | 3380 { |
3382 if (count > sug.su_ga.ga_len) | 3381 if (count > sug.su_ga.ga_len) |
3383 smsg((char_u *)_("Sorry, only %ld suggestions"), | 3382 smsg(_("Sorry, only %ld suggestions"), |
3384 (long)sug.su_ga.ga_len); | 3383 (long)sug.su_ga.ga_len); |
3385 } | 3384 } |
3386 else | 3385 else |
3387 { | 3386 { |
3388 VIM_CLEAR(repl_from); | 3387 VIM_CLEAR(repl_from); |
3613 int save_ws = p_ws; | 3612 int save_ws = p_ws; |
3614 linenr_T prev_lnum = 0; | 3613 linenr_T prev_lnum = 0; |
3615 | 3614 |
3616 if (repl_from == NULL || repl_to == NULL) | 3615 if (repl_from == NULL || repl_to == NULL) |
3617 { | 3616 { |
3618 EMSG(_("E752: No previous spell replacement")); | 3617 emsg(_("E752: No previous spell replacement")); |
3619 return; | 3618 return; |
3620 } | 3619 } |
3621 addlen = (int)(STRLEN(repl_to) - STRLEN(repl_from)); | 3620 addlen = (int)(STRLEN(repl_to) - STRLEN(repl_from)); |
3622 | 3621 |
3623 frompat = alloc((unsigned)STRLEN(repl_from) + 7); | 3622 frompat = alloc((unsigned)STRLEN(repl_from) + 7); |
3663 p_ws = save_ws; | 3662 p_ws = save_ws; |
3664 curwin->w_cursor = pos; | 3663 curwin->w_cursor = pos; |
3665 vim_free(frompat); | 3664 vim_free(frompat); |
3666 | 3665 |
3667 if (sub_nsubs == 0) | 3666 if (sub_nsubs == 0) |
3668 EMSG2(_("E753: Not found: %s"), repl_from); | 3667 semsg(_("E753: Not found: %s"), repl_from); |
3669 else | 3668 else |
3670 do_sub_msg(FALSE); | 3669 do_sub_msg(FALSE); |
3671 } | 3670 } |
3672 | 3671 |
3673 /* | 3672 /* |
3903 | 3902 |
3904 /* Open the file. */ | 3903 /* Open the file. */ |
3905 fd = mch_fopen((char *)fname, "r"); | 3904 fd = mch_fopen((char *)fname, "r"); |
3906 if (fd == NULL) | 3905 if (fd == NULL) |
3907 { | 3906 { |
3908 EMSG2(_(e_notopen), fname); | 3907 semsg(_(e_notopen), fname); |
3909 return; | 3908 return; |
3910 } | 3909 } |
3911 | 3910 |
3912 /* Read it line by line. */ | 3911 /* Read it line by line. */ |
3913 while (!vim_fgets(line, MAXWLEN * 2, fd) && !got_int) | 3912 while (!vim_fgets(line, MAXWLEN * 2, fd) && !got_int) |