From 72584fe1fa0f53ecd7dd201e0397dc5ea54d3c89 Mon Sep 17 00:00:00 2001 From: arbitrary-dev Date: Thu, 21 Mar 2024 11:01:37 +0200 Subject: [PATCH] Add STDOUT output to mutool-convert --- source/fitz/output.c | 4 ++-- source/fitz/stext-output.c | 2 +- source/tools/muconvert.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/fitz/output.c b/source/fitz/output.c index 259e04ae30..7a459ba48f 100644 --- a/source/fitz/output.c +++ b/source/fitz/output.c @@ -245,8 +245,8 @@ fz_new_output_with_path(fz_context *ctx, const char *filename, int append) FILE *file; fz_output *out; - if (filename == NULL) - fz_throw(ctx, FZ_ERROR_ARGUMENT, "no output to write to"); + if (filename == NULL || !strcmp(filename, "-") || !fz_strcasecmp(filename, "stdout")) + return fz_new_output(ctx, 0, NULL, stdout_write, NULL, NULL); if (!strcmp(filename, "/dev/null") || !fz_strcasecmp(filename, "nul:")) return fz_new_output(ctx, 0, NULL, null_write, NULL, NULL); diff --git a/source/fitz/stext-output.c b/source/fitz/stext-output.c index 37ad479adf..cf147bdf81 100644 --- a/source/fitz/stext-output.c +++ b/source/fitz/stext-output.c @@ -933,6 +933,6 @@ fz_new_text_writer_with_output(fz_context *ctx, const char *format, fz_output *o fz_document_writer * fz_new_text_writer(fz_context *ctx, const char *format, const char *path, const char *options) { - fz_output *out = fz_new_output_with_path(ctx, path ? path : "out.txt", 0); + fz_output *out = fz_new_output_with_path(ctx, path, 0); return fz_new_text_writer_with_output(ctx, format, out, options); } diff --git a/source/tools/muconvert.c b/source/tools/muconvert.c index e7cbdd444d..85daa8489a 100644 --- a/source/tools/muconvert.c +++ b/source/tools/muconvert.c @@ -63,7 +63,7 @@ static int usage(void) "\t-U -\tfile name of user stylesheet for EPUB layout\n" "\t-X\tdisable document styles for EPUB layout\n" "\n" - "\t-o -\toutput file name (%%d for page number)\n" + "\t-o -\toutput file name (%%d for page number, - for stdout)\n" "\t-F -\toutput format (default inferred from output file name)\n" "\t\t\traster: cbz, png, pnm, pgm, ppm, pam, pbm, pkm.\n" "\t\t\tprint-raster: pcl, pclm, ps, pwg.\n"