From 4918560f7dd434fa5489d4efc442d70835668650 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Thu, 19 Jan 2017 02:08:49 +0100 Subject: Return fz_document from all document handlers. To make it possible to avoid casting in most cases. --- source/cbz/mucbz.c | 10 +++++----- source/cbz/muimg.c | 10 +++++----- source/cbz/mutiff.c | 10 +++++----- source/gprf/gprf-doc.c | 6 +++--- source/html/epub-doc.c | 6 +++--- source/html/html-doc.c | 8 ++++---- source/pdf/pdf-xref.c | 6 +++--- source/svg/svg-doc.c | 4 ++-- source/xps/xps-doc.c | 6 +++--- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c index 53ad5938..a557a9c7 100644 --- a/source/cbz/mucbz.c +++ b/source/cbz/mucbz.c @@ -192,7 +192,7 @@ cbz_lookup_metadata(fz_context *ctx, cbz_document *doc, const char *key, char *b return -1; } -static cbz_document * +static fz_document * cbz_open_document_with_stream(fz_context *ctx, fz_stream *file) { cbz_document *doc; @@ -214,7 +214,7 @@ cbz_open_document_with_stream(fz_context *ctx, fz_stream *file) fz_drop_document(ctx, &doc->super); fz_rethrow(ctx); } - return doc; + return &doc->super; } static int @@ -238,7 +238,7 @@ cbz_recognize(fz_context *ctx, const char *magic) fz_document_handler cbz_document_handler = { - (fz_document_recognize_fn *)&cbz_recognize, - (fz_document_open_fn *)NULL, - (fz_document_open_with_stream_fn *)&cbz_open_document_with_stream + cbz_recognize, + NULL, + cbz_open_document_with_stream }; diff --git a/source/cbz/muimg.c b/source/cbz/muimg.c index 5c9b84bf..4c590f52 100644 --- a/source/cbz/muimg.c +++ b/source/cbz/muimg.c @@ -103,7 +103,7 @@ img_new_document(fz_context *ctx, fz_image *image) return doc; } -static img_document * +static fz_document * img_open_document_with_stream(fz_context *ctx, fz_stream *stm) { fz_buffer *buffer = NULL; @@ -127,7 +127,7 @@ img_open_document_with_stream(fz_context *ctx, fz_stream *stm) fz_catch(ctx) fz_rethrow(ctx); - return doc; + return &doc->super; } static int @@ -172,7 +172,7 @@ img_recognize(fz_context *doc, const char *magic) fz_document_handler img_document_handler = { - (fz_document_recognize_fn *)&img_recognize, - (fz_document_open_fn *)NULL, - (fz_document_open_with_stream_fn *)&img_open_document_with_stream + img_recognize, + NULL, + img_open_document_with_stream }; diff --git a/source/cbz/mutiff.c b/source/cbz/mutiff.c index 6b7b989c..637f4e3a 100644 --- a/source/cbz/mutiff.c +++ b/source/cbz/mutiff.c @@ -114,7 +114,7 @@ tiff_drop_document(fz_context *ctx, tiff_document *doc) fz_drop_buffer(ctx, doc->buffer); } -static tiff_document * +static fz_document * tiff_open_document_with_stream(fz_context *ctx, fz_stream *file) { tiff_document *doc; @@ -140,7 +140,7 @@ tiff_open_document_with_stream(fz_context *ctx, fz_stream *file) fz_rethrow(ctx); } - return doc; + return &doc->super; } static int @@ -162,7 +162,7 @@ tiff_recognize(fz_context *doc, const char *magic) fz_document_handler tiff_document_handler = { - (fz_document_recognize_fn *)&tiff_recognize, - (fz_document_open_fn *)NULL, - (fz_document_open_with_stream_fn *)&tiff_open_document_with_stream + tiff_recognize, + NULL, + tiff_open_document_with_stream }; diff --git a/source/gprf/gprf-doc.c b/source/gprf/gprf-doc.c index f08286ad..faeb8e2f 100644 --- a/source/gprf/gprf-doc.c +++ b/source/gprf/gprf-doc.c @@ -1004,8 +1004,8 @@ gprf_recognize(fz_context *doc, const char *magic) fz_document_handler gprf_document_handler = { - &gprf_recognize, - &gprf_open_document, - &gprf_open_document_with_stream + gprf_recognize, + gprf_open_document, + gprf_open_document_with_stream }; #endif diff --git a/source/html/epub-doc.c b/source/html/epub-doc.c index 441bfb83..44903d99 100644 --- a/source/html/epub-doc.c +++ b/source/html/epub-doc.c @@ -532,7 +532,7 @@ epub_recognize(fz_context *doc, const char *magic) fz_document_handler epub_document_handler = { - &epub_recognize, - &epub_open_document, - &epub_open_document_with_stream + epub_recognize, + epub_open_document, + epub_open_document_with_stream }; diff --git a/source/html/html-doc.c b/source/html/html-doc.c index fadb6ee3..ba765350 100644 --- a/source/html/html-doc.c +++ b/source/html/html-doc.c @@ -160,7 +160,7 @@ htdoc_open_document_with_stream(fz_context *ctx, fz_stream *file) fz_catch(ctx) fz_rethrow(ctx); - return (fz_document*)doc; + return &doc->super; } static fz_document * @@ -216,7 +216,7 @@ htdoc_recognize(fz_context *doc, const char *magic) fz_document_handler html_document_handler = { - &htdoc_recognize, - &htdoc_open_document, - &htdoc_open_document_with_stream + htdoc_recognize, + htdoc_open_document, + htdoc_open_document_with_stream }; diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index b757dfed..14da300d 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -2756,9 +2756,9 @@ pdf_recognize(fz_context *doc, const char *magic) fz_document_handler pdf_document_handler = { - (fz_document_recognize_fn *)&pdf_recognize, - (fz_document_open_fn *)&pdf_open_document, - (fz_document_open_with_stream_fn *)&pdf_open_document_with_stream + pdf_recognize, + (fz_document_open_fn *) pdf_open_document, + (fz_document_open_with_stream_fn *) pdf_open_document_with_stream }; void pdf_mark_xref(fz_context *ctx, pdf_document *doc) diff --git a/source/svg/svg-doc.c b/source/svg/svg-doc.c index 6e127d75..c7f8add8 100644 --- a/source/svg/svg-doc.c +++ b/source/svg/svg-doc.c @@ -172,7 +172,7 @@ fz_new_image_from_svg(fz_context *ctx, fz_buffer *buf) fz_document_handler svg_document_handler = { - &svg_recognize, + svg_recognize, NULL, - &svg_open_document_with_stream + svg_open_document_with_stream }; diff --git a/source/xps/xps-doc.c b/source/xps/xps-doc.c index d81ab5b6..5c91a591 100644 --- a/source/xps/xps-doc.c +++ b/source/xps/xps-doc.c @@ -484,7 +484,7 @@ xps_recognize(fz_context *ctx, const char *magic) fz_document_handler xps_document_handler = { - (fz_document_recognize_fn *)&xps_recognize, - (fz_document_open_fn *)&xps_open_document, - (fz_document_open_with_stream_fn *)&xps_open_document_with_stream + xps_recognize, + (fz_document_open_fn *) xps_open_document, + (fz_document_open_with_stream_fn *) xps_open_document_with_stream }; -- cgit v1.2.3