From e74df981077189c6408be4cdfb1f9dc4738e4ed0 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 30 May 2016 14:29:08 +0200 Subject: Respect FZ_ENABLE_PDF=0 to allow dropping all PDF specific code in tools. --- source/fitz/document.c | 12 ++++++++---- source/fitz/writer.c | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'source/fitz') diff --git a/source/fitz/document.c b/source/fitz/document.c index 227c93e1..5c913012 100644 --- a/source/fitz/document.c +++ b/source/fitz/document.c @@ -70,8 +70,10 @@ fz_open_document_with_stream(fz_context *ctx, const char *magic, fz_stream *stre int best_i, best_score; fz_document_handler_context *dc; - if (ctx == NULL || magic == NULL || stream == NULL) + if (ctx == NULL) return NULL; + if (magic == NULL || stream == NULL) + fz_throw(ctx, FZ_ERROR_GENERIC, "no document to open"); dc = ctx->handler; if (dc->count == 0) @@ -92,7 +94,7 @@ fz_open_document_with_stream(fz_context *ctx, const char *magic, fz_stream *stre if (best_i >= 0) return dc->handler[best_i]->open_with_stream(ctx, stream); - return NULL; + fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find document handler for file type: %s", magic); } fz_document * @@ -102,8 +104,10 @@ fz_open_document(fz_context *ctx, const char *filename) int best_i, best_score; fz_document_handler_context *dc; - if (ctx == NULL || filename == NULL) + if (ctx == NULL) return NULL; + if (filename == NULL) + fz_throw(ctx, FZ_ERROR_GENERIC, "no document to open"); dc = ctx->handler; if (dc->count == 0) @@ -124,7 +128,7 @@ fz_open_document(fz_context *ctx, const char *filename) if (best_i >= 0) return dc->handler[best_i]->open(ctx, filename); - return NULL; + fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find document handler for file: '%s'", filename); } void * diff --git a/source/fitz/writer.c b/source/fitz/writer.c index 94f601b5..2a344e52 100644 --- a/source/fitz/writer.c +++ b/source/fitz/writer.c @@ -54,8 +54,10 @@ fz_new_document_writer(fz_context *ctx, const char *path, const char *format, co if (!fz_strcasecmp(format, "cbz")) return fz_new_cbz_writer(ctx, path, options); +#if FZ_ENABLE_PDF if (!fz_strcasecmp(format, "pdf")) return fz_new_pdf_writer(ctx, path, options); +#endif fz_throw(ctx, FZ_ERROR_GENERIC, "unknown document format: %s", format); } -- cgit v1.2.3