Mercurial > vim
comparison src/search.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 |
---|---|
154 else | 154 else |
155 i = pat_use; | 155 i = pat_use; |
156 if (spats[i].pat == NULL) /* pattern was never defined */ | 156 if (spats[i].pat == NULL) /* pattern was never defined */ |
157 { | 157 { |
158 if (pat_use == RE_SUBST) | 158 if (pat_use == RE_SUBST) |
159 EMSG(_(e_nopresub)); | 159 emsg(_(e_nopresub)); |
160 else | 160 else |
161 EMSG(_(e_noprevre)); | 161 emsg(_(e_noprevre)); |
162 rc_did_emsg = TRUE; | 162 rc_did_emsg = TRUE; |
163 return FAIL; | 163 return FAIL; |
164 } | 164 } |
165 pat = spats[i].pat; | 165 pat = spats[i].pat; |
166 magic = spats[i].magic; | 166 magic = spats[i].magic; |
367 */ | 367 */ |
368 void | 368 void |
369 save_last_search_pattern(void) | 369 save_last_search_pattern(void) |
370 { | 370 { |
371 if (did_save_last_search_spat != 0) | 371 if (did_save_last_search_spat != 0) |
372 IEMSG("did_save_last_search_spat is not zero"); | 372 iemsg("did_save_last_search_spat is not zero"); |
373 else | 373 else |
374 ++did_save_last_search_spat; | 374 ++did_save_last_search_spat; |
375 | 375 |
376 saved_last_search_spat = spats[RE_SEARCH]; | 376 saved_last_search_spat = spats[RE_SEARCH]; |
377 if (spats[RE_SEARCH].pat != NULL) | 377 if (spats[RE_SEARCH].pat != NULL) |
383 void | 383 void |
384 restore_last_search_pattern(void) | 384 restore_last_search_pattern(void) |
385 { | 385 { |
386 if (did_save_last_search_spat != 1) | 386 if (did_save_last_search_spat != 1) |
387 { | 387 { |
388 IEMSG("did_save_last_search_spat is not one"); | 388 iemsg("did_save_last_search_spat is not one"); |
389 return; | 389 return; |
390 } | 390 } |
391 --did_save_last_search_spat; | 391 --did_save_last_search_spat; |
392 | 392 |
393 vim_free(spats[RE_SEARCH].pat); | 393 vim_free(spats[RE_SEARCH].pat); |
668 | 668 |
669 if (search_regcomp(pat, RE_SEARCH, pat_use, | 669 if (search_regcomp(pat, RE_SEARCH, pat_use, |
670 (options & (SEARCH_HIS + SEARCH_KEEP)), ®match) == FAIL) | 670 (options & (SEARCH_HIS + SEARCH_KEEP)), ®match) == FAIL) |
671 { | 671 { |
672 if ((options & SEARCH_MSG) && !rc_did_emsg) | 672 if ((options & SEARCH_MSG) && !rc_did_emsg) |
673 EMSG2(_("E383: Invalid search string: %s"), mr_pattern); | 673 semsg(_("E383: Invalid search string: %s"), mr_pattern); |
674 return FAIL; | 674 return FAIL; |
675 } | 675 } |
676 | 676 |
677 /* | 677 /* |
678 * find the string | 678 * find the string |
1134 called_emsg |= save_called_emsg; | 1134 called_emsg |= save_called_emsg; |
1135 | 1135 |
1136 if (!found) /* did not find it */ | 1136 if (!found) /* did not find it */ |
1137 { | 1137 { |
1138 if (got_int) | 1138 if (got_int) |
1139 EMSG(_(e_interr)); | 1139 emsg(_(e_interr)); |
1140 else if ((options & SEARCH_MSG) == SEARCH_MSG) | 1140 else if ((options & SEARCH_MSG) == SEARCH_MSG) |
1141 { | 1141 { |
1142 if (p_ws) | 1142 if (p_ws) |
1143 EMSG2(_(e_patnotf2), mr_pattern); | 1143 semsg(_(e_patnotf2), mr_pattern); |
1144 else if (lnum == 0) | 1144 else if (lnum == 0) |
1145 EMSG2(_("E384: search hit TOP without match for: %s"), | 1145 semsg(_("E384: search hit TOP without match for: %s"), |
1146 mr_pattern); | 1146 mr_pattern); |
1147 else | 1147 else |
1148 EMSG2(_("E385: search hit BOTTOM without match for: %s"), | 1148 semsg(_("E385: search hit BOTTOM without match for: %s"), |
1149 mr_pattern); | 1149 mr_pattern); |
1150 } | 1150 } |
1151 return FAIL; | 1151 return FAIL; |
1152 } | 1152 } |
1153 | 1153 |
1322 if (spats[RE_SEARCH].pat == NULL) /* no previous pattern */ | 1322 if (spats[RE_SEARCH].pat == NULL) /* no previous pattern */ |
1323 { | 1323 { |
1324 searchstr = spats[RE_SUBST].pat; | 1324 searchstr = spats[RE_SUBST].pat; |
1325 if (searchstr == NULL) | 1325 if (searchstr == NULL) |
1326 { | 1326 { |
1327 EMSG(_(e_noprevre)); | 1327 emsg(_(e_noprevre)); |
1328 retval = 0; | 1328 retval = 0; |
1329 goto end_do_search; | 1329 goto end_do_search; |
1330 } | 1330 } |
1331 } | 1331 } |
1332 else | 1332 else |
1579 | 1579 |
1580 dirc = *++pat; | 1580 dirc = *++pat; |
1581 if (dirc != '?' && dirc != '/') | 1581 if (dirc != '?' && dirc != '/') |
1582 { | 1582 { |
1583 retval = 0; | 1583 retval = 0; |
1584 EMSG(_("E386: Expected '?' or '/' after ';'")); | 1584 emsg(_("E386: Expected '?' or '/' after ';'")); |
1585 goto end_do_search; | 1585 goto end_do_search; |
1586 } | 1586 } |
1587 ++pat; | 1587 ++pat; |
1588 } | 1588 } |
1589 | 1589 |
5217 else | 5217 else |
5218 #endif | 5218 #endif |
5219 if (p_verbose >= 5) | 5219 if (p_verbose >= 5) |
5220 { | 5220 { |
5221 verbose_enter(); | 5221 verbose_enter(); |
5222 smsg((char_u *)_("Searching included file %s"), | 5222 smsg(_("Searching included file %s"), |
5223 (char *)new_fname); | 5223 (char *)new_fname); |
5224 verbose_leave(); | 5224 verbose_leave(); |
5225 } | 5225 } |
5226 | 5226 |
5227 } | 5227 } |
5440 if (depth == -1 && lnum == curwin->w_cursor.lnum | 5440 if (depth == -1 && lnum == curwin->w_cursor.lnum |
5441 #if defined(FEAT_QUICKFIX) | 5441 #if defined(FEAT_QUICKFIX) |
5442 && g_do_tagpreview == 0 | 5442 && g_do_tagpreview == 0 |
5443 #endif | 5443 #endif |
5444 ) | 5444 ) |
5445 EMSG(_("E387: Match is on current line")); | 5445 emsg(_("E387: Match is on current line")); |
5446 else if (action == ACTION_SHOW) | 5446 else if (action == ACTION_SHOW) |
5447 { | 5447 { |
5448 show_pat_in_path(line, type, did_show, action, | 5448 show_pat_in_path(line, type, did_show, action, |
5449 (depth == -1) ? NULL : files[depth].fp, | 5449 (depth == -1) ? NULL : files[depth].fp, |
5450 (depth == -1) ? &lnum : &files[depth].lnum, 1L); | 5450 (depth == -1) ? &lnum : &files[depth].lnum, 1L); |
5607 #ifdef FEAT_INS_EXPAND | 5607 #ifdef FEAT_INS_EXPAND |
5608 if (got_int || compl_interrupted) | 5608 if (got_int || compl_interrupted) |
5609 #else | 5609 #else |
5610 if (got_int) | 5610 if (got_int) |
5611 #endif | 5611 #endif |
5612 EMSG(_(e_interr)); | 5612 emsg(_(e_interr)); |
5613 else if (type == FIND_DEFINE) | 5613 else if (type == FIND_DEFINE) |
5614 EMSG(_("E388: Couldn't find definition")); | 5614 emsg(_("E388: Couldn't find definition")); |
5615 else | 5615 else |
5616 EMSG(_("E389: Couldn't find pattern")); | 5616 emsg(_("E389: Couldn't find pattern")); |
5617 } | 5617 } |
5618 if (action == ACTION_SHOW || action == ACTION_SHOW_ALL) | 5618 if (action == ACTION_SHOW || action == ACTION_SHOW_ALL) |
5619 msg_end(); | 5619 msg_end(); |
5620 | 5620 |
5621 fpip_end: | 5621 fpip_end: |