summaryrefslogtreecommitdiff
path: root/source/tools/pdfmerge.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-04-25 10:14:12 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-04-26 15:12:57 +0200
commite9f53724a29616033b1c076a4bb99da9f82d98c8 (patch)
treead2099f9b658824c595193fb0ca91e69a346f521 /source/tools/pdfmerge.c
parent35d56cac4707498fec436d3b85c34b3f65a12da9 (diff)
downloadmupdf-e9f53724a29616033b1c076a4bb99da9f82d98c8.tar.xz
pdfmerge: Clean up error messages and fix try/catch variable error.
Diffstat (limited to 'source/tools/pdfmerge.c')
-rw-r--r--source/tools/pdfmerge.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/source/tools/pdfmerge.c b/source/tools/pdfmerge.c
index 27258a9e..13905460 100644
--- a/source/tools/pdfmerge.c
+++ b/source/tools/pdfmerge.c
@@ -149,7 +149,7 @@ int pdfmerge_main(int argc, char **argv)
{
pdf_write_options opts = { 0 };
char *output = "out.pdf";
- char *infile_src;
+ char *input;
int c;
while ((c = fz_getopt(argc, argv, "adlszo:")) != -1)
@@ -172,7 +172,7 @@ int pdfmerge_main(int argc, char **argv)
ctx = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED);
if (!ctx)
{
- fprintf(stderr, "Cannot initialise context\n");
+ fprintf(stderr, "error: Cannot initialize MuPDF context.\n");
exit(1);
}
@@ -182,19 +182,18 @@ int pdfmerge_main(int argc, char **argv)
}
fz_catch(ctx)
{
- fprintf(stderr, "Failed to allocate destination document file %s\n", output);
+ fprintf(stderr, "error: Cannot create destination document.\n");
exit(1);
}
/* Step through the source files */
while (fz_optind < argc)
{
+ input = argv[fz_optind++];
fz_try(ctx)
{
- infile_src = argv[fz_optind++];
pdf_drop_document(ctx, doc_src);
- doc_src = pdf_open_document(ctx, infile_src);
-
+ doc_src = pdf_open_document(ctx, input);
if (fz_optind == argc || !isrange(argv[fz_optind]))
merge_range("1-");
else
@@ -202,7 +201,7 @@ int pdfmerge_main(int argc, char **argv)
}
fz_catch(ctx)
{
- fprintf(stderr, "Failed merging document %s\n", infile_src);
+ fprintf(stderr, "error: Cannot merge document '%s'.\n", input);
exit(1);
}
}
@@ -218,11 +217,11 @@ int pdfmerge_main(int argc, char **argv)
}
fz_catch(ctx)
{
- fprintf(stderr, "Error encountered during file save.\n");
+ fprintf(stderr, "error: Cannot save output file: '%s'.\n", output);
exit(1);
}
+
fz_flush_warnings(ctx);
fz_drop_context(ctx);
-
return 0;
}