Mercurial > vim
comparison src/getchar.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 | c97b4b537572 |
children | dd725a8ab112 |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
235 buf->bh_space = 0; | 235 buf->bh_space = 0; |
236 buf->bh_curr = &(buf->bh_first); | 236 buf->bh_curr = &(buf->bh_first); |
237 } | 237 } |
238 else if (buf->bh_curr == NULL) /* buffer has already been read */ | 238 else if (buf->bh_curr == NULL) /* buffer has already been read */ |
239 { | 239 { |
240 IEMSG(_("E222: Add to read buffer")); | 240 iemsg(_("E222: Add to read buffer")); |
241 return; | 241 return; |
242 } | 242 } |
243 else if (buf->bh_index != 0) | 243 else if (buf->bh_index != 0) |
244 mch_memmove(buf->bh_first.b_next->b_str, | 244 mch_memmove(buf->bh_first.b_next->b_str, |
245 buf->bh_first.b_next->b_str + buf->bh_index, | 245 buf->bh_first.b_next->b_str + buf->bh_index, |
996 */ | 996 */ |
997 newoff = MAXMAPLEN + 4; | 997 newoff = MAXMAPLEN + 4; |
998 newlen = typebuf.tb_len + addlen + newoff + 4 * (MAXMAPLEN + 4); | 998 newlen = typebuf.tb_len + addlen + newoff + 4 * (MAXMAPLEN + 4); |
999 if (newlen < 0) /* string is getting too long */ | 999 if (newlen < 0) /* string is getting too long */ |
1000 { | 1000 { |
1001 EMSG(_(e_toocompl)); /* also calls flush_buffers */ | 1001 emsg(_(e_toocompl)); /* also calls flush_buffers */ |
1002 setcursor(); | 1002 setcursor(); |
1003 return FAIL; | 1003 return FAIL; |
1004 } | 1004 } |
1005 s1 = alloc(newlen); | 1005 s1 = alloc(newlen); |
1006 if (s1 == NULL) /* out of memory */ | 1006 if (s1 == NULL) /* out of memory */ |
1429 char_u *name, | 1429 char_u *name, |
1430 int directly) /* when TRUE execute directly */ | 1430 int directly) /* when TRUE execute directly */ |
1431 { | 1431 { |
1432 if (curscript + 1 == NSCRIPT) | 1432 if (curscript + 1 == NSCRIPT) |
1433 { | 1433 { |
1434 EMSG(_(e_nesting)); | 1434 emsg(_(e_nesting)); |
1435 return; | 1435 return; |
1436 } | 1436 } |
1437 #ifdef FEAT_EVAL | 1437 #ifdef FEAT_EVAL |
1438 if (ignore_script) | 1438 if (ignore_script) |
1439 /* Not reading from script, also don't open one. Warning message? */ | 1439 /* Not reading from script, also don't open one. Warning message? */ |
1444 ++curscript; | 1444 ++curscript; |
1445 /* use NameBuff for expanded name */ | 1445 /* use NameBuff for expanded name */ |
1446 expand_env(name, NameBuff, MAXPATHL); | 1446 expand_env(name, NameBuff, MAXPATHL); |
1447 if ((scriptin[curscript] = mch_fopen((char *)NameBuff, READBIN)) == NULL) | 1447 if ((scriptin[curscript] = mch_fopen((char *)NameBuff, READBIN)) == NULL) |
1448 { | 1448 { |
1449 EMSG2(_(e_notopen), name); | 1449 semsg(_(e_notopen), name); |
1450 if (curscript) | 1450 if (curscript) |
1451 --curscript; | 1451 --curscript; |
1452 return; | 1452 return; |
1453 } | 1453 } |
1454 if (save_typebuf() == FAIL) | 1454 if (save_typebuf() == FAIL) |
2506 * Put the replacement string in front of mapstr. | 2506 * Put the replacement string in front of mapstr. |
2507 * The depth check catches ":map x y" and ":map y x". | 2507 * The depth check catches ":map x y" and ":map y x". |
2508 */ | 2508 */ |
2509 if (++mapdepth >= p_mmd) | 2509 if (++mapdepth >= p_mmd) |
2510 { | 2510 { |
2511 EMSG(_("E223: recursive mapping")); | 2511 emsg(_("E223: recursive mapping")); |
2512 if (State & CMDLINE) | 2512 if (State & CMDLINE) |
2513 redrawcmdline(); | 2513 redrawcmdline(); |
2514 else | 2514 else |
2515 setcursor(); | 2515 setcursor(); |
2516 flush_buffers(FLUSH_MINIMAL); | 2516 flush_buffers(FLUSH_MINIMAL); |
3506 && mp->m_keylen == len | 3506 && mp->m_keylen == len |
3507 && unique | 3507 && unique |
3508 && STRNCMP(mp->m_keys, keys, (size_t)len) == 0) | 3508 && STRNCMP(mp->m_keys, keys, (size_t)len) == 0) |
3509 { | 3509 { |
3510 if (abbrev) | 3510 if (abbrev) |
3511 EMSG2(_("E224: global abbreviation already exists for %s"), | 3511 semsg(_("E224: global abbreviation already exists for %s"), |
3512 mp->m_keys); | 3512 mp->m_keys); |
3513 else | 3513 else |
3514 EMSG2(_("E225: global mapping already exists for %s"), | 3514 semsg(_("E225: global mapping already exists for %s"), |
3515 mp->m_keys); | 3515 mp->m_keys); |
3516 retval = 5; | 3516 retval = 5; |
3517 goto theend; | 3517 goto theend; |
3518 } | 3518 } |
3519 } | 3519 } |
3641 continue; | 3641 continue; |
3642 } | 3642 } |
3643 else if (unique) | 3643 else if (unique) |
3644 { | 3644 { |
3645 if (abbrev) | 3645 if (abbrev) |
3646 EMSG2(_("E226: abbreviation already exists for %s"), | 3646 semsg(_("E226: abbreviation already exists for %s"), |
3647 p); | 3647 p); |
3648 else | 3648 else |
3649 EMSG2(_("E227: mapping already exists for %s"), p); | 3649 semsg(_("E227: mapping already exists for %s"), p); |
3650 retval = 5; | 3650 retval = 5; |
3651 goto theend; | 3651 goto theend; |
3652 } | 3652 } |
3653 else /* new rhs for existing entry */ | 3653 else /* new rhs for existing entry */ |
3654 { | 3654 { |
3890 int local; | 3890 int local; |
3891 | 3891 |
3892 local = (STRCMP(arg, "<buffer>") == 0); | 3892 local = (STRCMP(arg, "<buffer>") == 0); |
3893 if (!local && *arg != NUL) | 3893 if (!local && *arg != NUL) |
3894 { | 3894 { |
3895 EMSG(_(e_invarg)); | 3895 emsg(_(e_invarg)); |
3896 return; | 3896 return; |
3897 } | 3897 } |
3898 #endif | 3898 #endif |
3899 | 3899 |
3900 mode = get_map_mode(&cmdp, forceit); | 3900 mode = get_map_mode(&cmdp, forceit); |
4918 break; | 4918 break; |
4919 case TERMINAL: | 4919 case TERMINAL: |
4920 c1 = 't'; | 4920 c1 = 't'; |
4921 break; | 4921 break; |
4922 default: | 4922 default: |
4923 IEMSG(_("E228: makemap: Illegal mode")); | 4923 iemsg(_("E228: makemap: Illegal mode")); |
4924 return FAIL; | 4924 return FAIL; |
4925 } | 4925 } |
4926 do /* do this twice if c2 is set, 3 times with c3 */ | 4926 do /* do this twice if c2 is set, 3 times with c3 */ |
4927 { | 4927 { |
4928 /* When outputting <> form, need to make sure that 'cpo' | 4928 /* When outputting <> form, need to make sure that 'cpo' |