diff options
-rw-r--r-- | include/mupdf/fitz/writer.h | 1 | ||||
-rw-r--r-- | source/fitz/writer.c | 7 | ||||
-rw-r--r-- | source/pdf/pdf-write.c | 32 |
3 files changed, 21 insertions, 19 deletions
diff --git a/include/mupdf/fitz/writer.h b/include/mupdf/fitz/writer.h index 069cc7a5..b9d28138 100644 --- a/include/mupdf/fitz/writer.h +++ b/include/mupdf/fitz/writer.h @@ -18,6 +18,7 @@ struct fz_document_writer_s }; int fz_has_option(fz_context *ctx, const char *opts, const char *key, const char **val); +int fz_option_eq(const char *a, const char *b); fz_document_writer *fz_new_document_writer(fz_context *ctx, const char *path, const char *format, const char *options); diff --git a/source/fitz/writer.c b/source/fitz/writer.c index c4e95e2a..d7fd60f9 100644 --- a/source/fitz/writer.c +++ b/source/fitz/writer.c @@ -41,6 +41,13 @@ fz_has_option(fz_context *ctx, const char *opts, const char *key, const char **v return 0; } +int +fz_option_eq(const char *a, const char *b) +{ + size_t n = strlen(b); + return !strncmp(a, b, n) && (a[n] == ',' || a[n] == 0); +} + fz_document_writer * fz_new_document_writer(fz_context *ctx, const char *path, const char *format, const char *options) { diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c index 2dead828..eb1a2f29 100644 --- a/source/pdf/pdf-write.c +++ b/source/pdf/pdf-write.c @@ -2747,12 +2747,6 @@ static void finalise_write_state(fz_context *ctx, pdf_write_state *opts) page_objects_list_destroy(ctx, opts->page_object_lists); } -static int opteq(const char *a, const char *b) -{ - size_t n = strlen(b); - return !strncmp(a, b, n) && (a[n] == ',' || a[n] == 0); -} - const char *fz_pdf_write_options_usage = "PDF output options:\n" "\tdecompress: decompress all streams (except compress-fonts/images)\n" @@ -2776,32 +2770,32 @@ pdf_parse_write_options(fz_context *ctx, pdf_write_options *opts, const char *ar memset(opts, 0, sizeof *opts); if (fz_has_option(ctx, args, "decompress", &val)) - opts->do_decompress = opteq(val, "yes"); + opts->do_decompress = fz_option_eq(val, "yes"); if (fz_has_option(ctx, args, "compress", &val)) - opts->do_compress = opteq(val, "yes"); + opts->do_compress = fz_option_eq(val, "yes"); if (fz_has_option(ctx, args, "compress-fonts", &val)) - opts->do_compress_fonts = opteq(val, "yes"); + opts->do_compress_fonts = fz_option_eq(val, "yes"); if (fz_has_option(ctx, args, "compress-images", &val)) - opts->do_compress_images = opteq(val, "yes"); + opts->do_compress_images = fz_option_eq(val, "yes"); if (fz_has_option(ctx, args, "ascii", &val)) - opts->do_ascii = opteq(val, "yes"); + opts->do_ascii = fz_option_eq(val, "yes"); if (fz_has_option(ctx, args, "pretty", &val)) - opts->do_pretty = opteq(val, "yes"); + opts->do_pretty = fz_option_eq(val, "yes"); if (fz_has_option(ctx, args, "linearize", &val)) - opts->do_linear = opteq(val, "yes"); + opts->do_linear = fz_option_eq(val, "yes"); if (fz_has_option(ctx, args, "sanitize", &val)) - opts->do_clean = opteq(val, "yes"); + opts->do_clean = fz_option_eq(val, "yes"); if (fz_has_option(ctx, args, "incremental", &val)) - opts->do_incremental = opteq(val, "yes"); + opts->do_incremental = fz_option_eq(val, "yes"); if (fz_has_option(ctx, args, "continue-on-error", &val)) - opts->continue_on_error = opteq(val, "yes"); + opts->continue_on_error = fz_option_eq(val, "yes"); if (fz_has_option(ctx, args, "garbage", &val)) { - if (opteq(val, "yes")) + if (fz_option_eq(val, "yes")) opts->do_garbage = 1; - else if (opteq(val, "compact")) + else if (fz_option_eq(val, "compact")) opts->do_garbage = 2; - else if (opteq(val, "deduplicate")) + else if (fz_option_eq(val, "deduplicate")) opts->do_garbage = 3; else opts->do_garbage = atoi(val); |