Mercurial > vim
comparison src/term.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 | 6fcfff2b4ba5 |
children | dd725a8ab112 |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
90 static void del_termcode_idx(int idx); | 90 static void del_termcode_idx(int idx); |
91 static int term_is_builtin(char_u *name); | 91 static int term_is_builtin(char_u *name); |
92 static int term_7to8bit(char_u *p); | 92 static int term_7to8bit(char_u *p); |
93 | 93 |
94 #ifdef HAVE_TGETENT | 94 #ifdef HAVE_TGETENT |
95 static char_u *tgetent_error(char_u *, char_u *); | 95 static char *tgetent_error(char_u *, char_u *); |
96 | 96 |
97 /* | 97 /* |
98 * Here is our own prototype for tgetstr(), any prototypes from the include | 98 * Here is our own prototype for tgetstr(), any prototypes from the include |
99 * files have been disabled by the define at the start of this file. | 99 * files have been disabled by the define at the start of this file. |
100 */ | 100 */ |
1355 if (*name == NUL) | 1355 if (*name == NUL) |
1356 return INVALCOLOR; | 1356 return INVALCOLOR; |
1357 t = termgui_mch_get_color(name); | 1357 t = termgui_mch_get_color(name); |
1358 | 1358 |
1359 if (t == INVALCOLOR) | 1359 if (t == INVALCOLOR) |
1360 EMSG2(_("E254: Cannot allocate color %s"), name); | 1360 semsg(_("E254: Cannot allocate color %s"), name); |
1361 return t; | 1361 return t; |
1362 } | 1362 } |
1363 | 1363 |
1364 guicolor_T | 1364 guicolor_T |
1365 termgui_mch_get_rgb(guicolor_T color) | 1365 termgui_mch_get_rgb(guicolor_T color) |
1694 # endif | 1694 # endif |
1695 } | 1695 } |
1696 #endif | 1696 #endif |
1697 | 1697 |
1698 static void | 1698 static void |
1699 report_term_error(char_u *error_msg, char_u *term) | 1699 report_term_error(char *error_msg, char_u *term) |
1700 { | 1700 { |
1701 struct builtin_term *termp; | 1701 struct builtin_term *termp; |
1702 | 1702 |
1703 mch_errmsg("\r\n"); | 1703 mch_errmsg("\r\n"); |
1704 if (error_msg != NULL) | 1704 if (error_msg != NULL) |
1705 { | 1705 { |
1706 mch_errmsg((char *)error_msg); | 1706 mch_errmsg(error_msg); |
1707 mch_errmsg("\r\n"); | 1707 mch_errmsg("\r\n"); |
1708 } | 1708 } |
1709 mch_errmsg("'"); | 1709 mch_errmsg("'"); |
1710 mch_errmsg((char *)term); | 1710 mch_errmsg((char *)term); |
1711 mch_errmsg(_("' not known. Available builtin terminals are:")); | 1711 mch_errmsg(_("' not known. Available builtin terminals are:")); |
1754 int builtin_first = p_tbi; | 1754 int builtin_first = p_tbi; |
1755 int try; | 1755 int try; |
1756 int termcap_cleared = FALSE; | 1756 int termcap_cleared = FALSE; |
1757 #endif | 1757 #endif |
1758 int width = 0, height = 0; | 1758 int width = 0, height = 0; |
1759 char_u *error_msg = NULL; | 1759 char *error_msg = NULL; |
1760 char_u *bs_p, *del_p; | 1760 char_u *bs_p, *del_p; |
1761 | 1761 |
1762 /* In silect mode (ex -s) we don't use the 'term' option. */ | 1762 /* In silect mode (ex -s) we don't use the 'term' option. */ |
1763 if (silent_mode) | 1763 if (silent_mode) |
1764 return OK; | 1764 return OK; |
2189 #ifdef HAVE_TGETENT | 2189 #ifdef HAVE_TGETENT |
2190 /* | 2190 /* |
2191 * Call tgetent() | 2191 * Call tgetent() |
2192 * Return error message if it fails, NULL if it's OK. | 2192 * Return error message if it fails, NULL if it's OK. |
2193 */ | 2193 */ |
2194 static char_u * | 2194 static char * |
2195 tgetent_error(char_u *tbuf, char_u *term) | 2195 tgetent_error(char_u *tbuf, char_u *term) |
2196 { | 2196 { |
2197 int i; | 2197 int i; |
2198 | 2198 |
2199 i = TGETENT(tbuf, term); | 2199 i = TGETENT(tbuf, term); |
2208 * hang. */ | 2208 * hang. */ |
2209 (void)TGETENT(tbuf, "dumb"); | 2209 (void)TGETENT(tbuf, "dumb"); |
2210 | 2210 |
2211 if (i < 0) | 2211 if (i < 0) |
2212 # ifdef TGETENT_ZERO_ERR | 2212 # ifdef TGETENT_ZERO_ERR |
2213 return (char_u *)_("E557: Cannot open termcap file"); | 2213 return _("E557: Cannot open termcap file"); |
2214 if (i == 0) | 2214 if (i == 0) |
2215 # endif | 2215 # endif |
2216 #ifdef TERMINFO | 2216 #ifdef TERMINFO |
2217 return (char_u *)_("E558: Terminal entry not found in terminfo"); | 2217 return _("E558: Terminal entry not found in terminfo"); |
2218 #else | 2218 #else |
2219 return (char_u *)_("E559: Terminal entry not found in termcap"); | 2219 return _("E559: Terminal entry not found in termcap"); |
2220 #endif | 2220 #endif |
2221 } | 2221 } |
2222 return NULL; | 2222 return NULL; |
2223 } | 2223 } |
2224 | 2224 |
2280 int i; | 2280 int i; |
2281 int builtin_first; | 2281 int builtin_first; |
2282 char_u tbuf[TBUFSZ]; | 2282 char_u tbuf[TBUFSZ]; |
2283 char_u tstrbuf[TBUFSZ]; | 2283 char_u tstrbuf[TBUFSZ]; |
2284 char_u *tp = tstrbuf; | 2284 char_u *tp = tstrbuf; |
2285 char_u *error_msg = NULL; | 2285 char *error_msg = NULL; |
2286 #endif | 2286 #endif |
2287 | 2287 |
2288 /* | 2288 /* |
2289 * If the GUI is running or will start in a moment, we only support the keys | 2289 * If the GUI is running or will start in a moment, we only support the keys |
2290 * that the GUI can produce. | 2290 * that the GUI can produce. |
2367 | 2367 |
2368 if (sourcing_name == NULL) | 2368 if (sourcing_name == NULL) |
2369 { | 2369 { |
2370 #ifdef HAVE_TGETENT | 2370 #ifdef HAVE_TGETENT |
2371 if (error_msg != NULL) | 2371 if (error_msg != NULL) |
2372 EMSG(error_msg); | 2372 emsg(error_msg); |
2373 else | 2373 else |
2374 #endif | 2374 #endif |
2375 EMSG2(_("E436: No \"%s\" entry in termcap"), name); | 2375 semsg(_("E436: No \"%s\" entry in termcap"), name); |
2376 } | 2376 } |
2377 return FAIL; | 2377 return FAIL; |
2378 } | 2378 } |
2379 | 2379 |
2380 static int | 2380 static int |
3053 | 3053 |
3054 /* | 3054 /* |
3055 * MUST have "cm": cursor motion. | 3055 * MUST have "cm": cursor motion. |
3056 */ | 3056 */ |
3057 if (*T_CM == NUL) | 3057 if (*T_CM == NUL) |
3058 EMSG(_("E437: terminal capability \"cm\" required")); | 3058 emsg(_("E437: terminal capability \"cm\" required")); |
3059 | 3059 |
3060 /* | 3060 /* |
3061 * if "cs" defined, use a scroll region, it's faster. | 3061 * if "cs" defined, use a scroll region, it's faster. |
3062 */ | 3062 */ |
3063 if (*T_CS != NUL) | 3063 if (*T_CS != NUL) |
6151 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) | 6151 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) |
6152 */ | 6152 */ |
6153 if (STRNICMP(src, "<SID>", 5) == 0) | 6153 if (STRNICMP(src, "<SID>", 5) == 0) |
6154 { | 6154 { |
6155 if (current_sctx.sc_sid <= 0) | 6155 if (current_sctx.sc_sid <= 0) |
6156 EMSG(_(e_usingsid)); | 6156 emsg(_(e_usingsid)); |
6157 else | 6157 else |
6158 { | 6158 { |
6159 src += 5; | 6159 src += 5; |
6160 result[dlen++] = K_SPECIAL; | 6160 result[dlen++] = K_SPECIAL; |
6161 result[dlen++] = (int)KS_EXTRA; | 6161 result[dlen++] = (int)KS_EXTRA; |