summaryrefslogtreecommitdiff
path: root/src/hardcopy.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-13 23:38:42 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-13 23:38:42 +0100
commitf9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d (patch)
treea6b07005c19279a4f5d01be14f14861c2657fa95 /src/hardcopy.c
parent05500ece6282407f9f7227aaf564e24147326863 (diff)
downloadvim-git-f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d.tar.gz
patch 8.1.0743: giving error messages is not flexiblev8.1.0743
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.
Diffstat (limited to 'src/hardcopy.c')
-rw-r--r--src/hardcopy.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/hardcopy.c b/src/hardcopy.c
index 486ae7d3d..508cf413f 100644
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -135,7 +135,7 @@ typedef struct
int ff; /* seen form feed character */
} prt_pos_T;
-static char_u *parse_list_options(char_u *option_str, option_table_T *table, int table_size);
+static char *parse_list_options(char_u *option_str, option_table_T *table, int table_size);
static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T *ppos);
@@ -143,7 +143,7 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
* Parse 'printoptions' and set the flags in "printer_opts".
* Returns an error message or NULL;
*/
- char_u *
+ char *
parse_printoptions(void)
{
return parse_list_options(p_popt, printer_opts, OPT_PRINT_NUM_OPTIONS);
@@ -154,7 +154,7 @@ parse_printoptions(void)
* Parse 'printmbfont' and set the flags in "mbfont_opts".
* Returns an error message or NULL;
*/
- char_u *
+ char *
parse_printmbfont(void)
{
return parse_list_options(p_pmfn, mbfont_opts, OPT_MBFONT_NUM_OPTIONS);
@@ -170,14 +170,14 @@ parse_printmbfont(void)
* Returns an error message for an illegal option, NULL otherwise.
* Only used for the printer at the moment...
*/
- static char_u *
+ static char *
parse_list_options(
char_u *option_str,
option_table_T *table,
int table_size)
{
option_table_T *old_opts;
- char_u *ret = NULL;
+ char *ret = NULL;
char_u *stringp;
char_u *colonp;
char_u *commap;
@@ -205,7 +205,7 @@ parse_list_options(
colonp = vim_strchr(stringp, ':');
if (colonp == NULL)
{
- ret = (char_u *)N_("E550: Missing colon");
+ ret = N_("E550: Missing colon");
break;
}
commap = vim_strchr(stringp, ',');
@@ -220,7 +220,7 @@ parse_list_options(
if (idx == table_size)
{
- ret = (char_u *)N_("E551: Illegal component");
+ ret = N_("E551: Illegal component");
break;
}
p = colonp + 1;
@@ -230,7 +230,7 @@ parse_list_options(
{
if (!VIM_ISDIGIT(*p))
{
- ret = (char_u *)N_("E552: digit expected");
+ ret = N_("E552: digit expected");
break;
}
@@ -576,13 +576,13 @@ ex_hardcopy(exarg_T *eap)
# ifdef FEAT_POSTSCRIPT
if (*eap->arg == '>')
{
- char_u *errormsg = NULL;
+ char *errormsg = NULL;
/* Expand things like "%.ps". */
if (expand_filename(eap, eap->cmdlinep, &errormsg) == FAIL)
{
if (errormsg != NULL)
- EMSG(errormsg);
+ emsg(errormsg);
return;
}
settings.outfile = skipwhite(eap->arg + 1);
@@ -1431,7 +1431,7 @@ prt_write_file_raw_len(char_u *buffer, int bytes)
&& fwrite(buffer, sizeof(char_u), bytes, prt_ps_fd)
!= (size_t)bytes)
{
- EMSG(_("E455: Error writing to PostScript output file"));
+ emsg(_("E455: Error writing to PostScript output file"));
prt_file_error = TRUE;
}
}
@@ -1873,7 +1873,7 @@ prt_open_resource(struct prt_ps_resource_S *resource)
fd_resource = mch_fopen((char *)resource->filename, READBIN);
if (fd_resource == NULL)
{
- EMSG2(_("E624: Can't open file \"%s\""), resource->filename);
+ semsg(_("E624: Can't open file \"%s\""), resource->filename);
return FALSE;
}
vim_memset(prt_resfile.buffer, NUL, PRT_FILE_BUFFER_LEN);
@@ -1883,7 +1883,7 @@ prt_open_resource(struct prt_ps_resource_S *resource)
PRT_FILE_BUFFER_LEN, fd_resource);
if (ferror(fd_resource))
{
- EMSG2(_("E457: Can't read PostScript resource file \"%s\""),
+ semsg(_("E457: Can't read PostScript resource file \"%s\""),
resource->filename);
fclose(fd_resource);
return FALSE;
@@ -1900,7 +1900,7 @@ prt_open_resource(struct prt_ps_resource_S *resource)
if (prt_resfile_strncmp(offset, PRT_RESOURCE_HEADER,
(int)STRLEN(PRT_RESOURCE_HEADER)) != 0)
{
- EMSG2(_("E618: file \"%s\" is not a PostScript resource file"),
+ semsg(_("E618: file \"%s\" is not a PostScript resource file"),
resource->filename);
return FALSE;
}
@@ -1917,7 +1917,7 @@ prt_open_resource(struct prt_ps_resource_S *resource)
if (prt_resfile_strncmp(offset, PRT_RESOURCE_RESOURCE,
(int)STRLEN(PRT_RESOURCE_RESOURCE)) != 0)
{
- EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"),
+ semsg(_("E619: file \"%s\" is not a supported PostScript resource file"),
resource->filename);
return FALSE;
}
@@ -1935,7 +1935,7 @@ prt_open_resource(struct prt_ps_resource_S *resource)
resource->type = PRT_RESOURCE_TYPE_CMAP;
else
{
- EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"),
+ semsg(_("E619: file \"%s\" is not a supported PostScript resource file"),
resource->filename);
return FALSE;
}
@@ -1977,7 +1977,7 @@ prt_open_resource(struct prt_ps_resource_S *resource)
if (!seen_title || !seen_version)
{
- EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"),
+ semsg(_("E619: file \"%s\" is not a supported PostScript resource file"),
resource->filename);
return FALSE;
}
@@ -1991,7 +1991,7 @@ prt_check_resource(struct prt_ps_resource_S *resource, char_u *version)
/* Version number m.n should match, the revision number does not matter */
if (STRNCMP(resource->version, version, STRLEN(version)))
{
- EMSG2(_("E621: \"%s\" resource file has wrong version"),
+ semsg(_("E621: \"%s\" resource file has wrong version"),
resource->name);
return FALSE;
}
@@ -2465,7 +2465,7 @@ mch_print_init(
/* Check encoding and character set are compatible */
if ((p_mbenc->needs_charset & p_mbchar->has_charset) == 0)
{
- EMSG(_("E673: Incompatible multi-byte encoding and character set."));
+ emsg(_("E673: Incompatible multi-byte encoding and character set."));
return FALSE;
}
@@ -2482,7 +2482,7 @@ mch_print_init(
/* Add custom CMap character set name */
if (*p_pmcs == NUL)
{
- EMSG(_("E674: printmbcharset cannot be empty with multi-byte encoding."));
+ emsg(_("E674: printmbcharset cannot be empty with multi-byte encoding."));
return FALSE;
}
vim_strncpy((char_u *)prt_cmap, p_pmcs, sizeof(prt_cmap) - 3);
@@ -2500,7 +2500,7 @@ mch_print_init(
if (!mbfont_opts[OPT_MBFONT_REGULAR].present)
{
- EMSG(_("E675: No default font specified for multi-byte printing."));
+ emsg(_("E675: No default font specified for multi-byte printing."));
return FALSE;
}
@@ -2677,7 +2677,7 @@ mch_print_init(
prt_ps_file_name = vim_tempname('p', TRUE);
if (prt_ps_file_name == NULL)
{
- EMSG(_(e_notmp));
+ emsg(_(e_notmp));
return FAIL;
}
prt_ps_fd = mch_fopen((char *)prt_ps_file_name, WRITEBIN);
@@ -2693,7 +2693,7 @@ mch_print_init(
}
if (prt_ps_fd == NULL)
{
- EMSG(_("E324: Can't open PostScript output file"));
+ emsg(_("E324: Can't open PostScript output file"));
mch_print_cleanup();
return FAIL;
}
@@ -2729,7 +2729,7 @@ prt_add_resource(struct prt_ps_resource_S *resource)
fd_resource = mch_fopen((char *)resource->filename, READBIN);
if (fd_resource == NULL)
{
- EMSG2(_("E456: Can't open file \"%s\""), resource->filename);
+ semsg(_("E456: Can't open file \"%s\""), resource->filename);
return FALSE;
}
prt_dsc_resources("BeginResource", prt_resource_types[resource->type],
@@ -2743,7 +2743,7 @@ prt_add_resource(struct prt_ps_resource_S *resource)
sizeof(resource_buffer), fd_resource);
if (ferror(fd_resource))
{
- EMSG2(_("E457: Can't read PostScript resource file \"%s\""),
+ semsg(_("E457: Can't read PostScript resource file \"%s\""),
resource->filename);
fclose(fd_resource);
return FALSE;
@@ -2880,7 +2880,7 @@ mch_print_begin(prt_settings_T *psettings)
/* Search for external resources VIM supplies */
if (!prt_find_resource("prolog", res_prolog))
{
- EMSG(_("E456: Can't find PostScript resource file \"prolog.ps\""));
+ emsg(_("E456: Can't find PostScript resource file \"prolog.ps\""));
goto theend;
}
if (!prt_open_resource(res_prolog))
@@ -2893,7 +2893,7 @@ mch_print_begin(prt_settings_T *psettings)
/* Look for required version of multi-byte printing procset */
if (!prt_find_resource("cidfont", res_cidfont))
{
- EMSG(_("E456: Can't find PostScript resource file \"cidfont.ps\""));
+ emsg(_("E456: Can't find PostScript resource file \"cidfont.ps\""));
goto theend;
}
if (!prt_open_resource(res_cidfont))
@@ -2931,7 +2931,7 @@ mch_print_begin(prt_settings_T *psettings)
p_encoding = (char_u *)"latin1";
if (!prt_find_resource((char *)p_encoding, res_encoding))
{
- EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
+ semsg(_("E456: Can't find PostScript resource file \"%s.ps\""),
p_encoding);
goto theend;
}
@@ -2953,7 +2953,7 @@ mch_print_begin(prt_settings_T *psettings)
/* Include ASCII range encoding vector */
if (!prt_find_resource(prt_ascii_encoding, res_encoding))
{
- EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
+ semsg(_("E456: Can't find PostScript resource file \"%s.ps\""),
prt_ascii_encoding);
goto theend;
}
@@ -2969,7 +2969,7 @@ mch_print_begin(prt_settings_T *psettings)
/* Set up encoding conversion if required */
if (FAIL == convert_setup(&prt_conv, p_enc, p_encoding))
{
- EMSG2(_("E620: Unable to convert to print encoding \"%s\""),
+ semsg(_("E620: Unable to convert to print encoding \"%s\""),
p_encoding);
goto theend;
}
@@ -2982,7 +2982,7 @@ mch_print_begin(prt_settings_T *psettings)
/* Find user supplied CMap */
if (!prt_find_resource(prt_cmap, res_cmap))
{
- EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
+ semsg(_("E456: Can't find PostScript resource file \"%s.ps\""),
prt_cmap);
goto theend;
}
@@ -3236,7 +3236,7 @@ mch_print_end(prt_settings_T *psettings)
/* Not printing to a file: use 'printexpr' to print the file. */
if (eval_printexpr(prt_ps_file_name, psettings->arguments) == FAIL)
- EMSG(_("E365: Failed to print PostScript file"));
+ emsg(_("E365: Failed to print PostScript file"));
else
prt_message((char_u *)_("Print job sent."));
}