From 95d746f13a86d914dd88310c994b27b08db4bb5b Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 2 Apr 2015 19:27:51 +0100 Subject: Fix oddity with pdfinfo If pdfinfo is invoked as: mutool info file.pdf 1,2,3 then it will show the items found on page 1, then the items found on pages 1 and 2, then the items shown on pages 1,2 and 3. Fix this by clearing the data after each show operation. --- source/tools/pdfinfo.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/source/tools/pdfinfo.c b/source/tools/pdfinfo.c index a3a7ba24..cc18a1e1 100644 --- a/source/tools/pdfinfo.c +++ b/source/tools/pdfinfo.c @@ -87,14 +87,9 @@ typedef struct globals_s int psobjs; } globals; -static void closexref(fz_context *ctx, globals *glo) +static void clearinfo(fz_context *ctx, globals *glo) { int i; - if (glo->doc) - { - pdf_close_document(ctx, glo->doc); - glo->doc = NULL; - } if (glo->dim) { @@ -148,6 +143,17 @@ static void closexref(fz_context *ctx, globals *glo) } } +static void closexref(fz_context *ctx, globals *glo) +{ + if (glo->doc) + { + pdf_close_document(ctx, glo->doc); + glo->doc = NULL; + } + + clearinfo(ctx, glo); +} + static void infousage(void) { @@ -954,6 +960,7 @@ showinfo(fz_context *ctx, globals *glo, char *filename, int show, char *pagelist fz_printf(ctx, out, "Page %d:\n", page); printinfo(ctx, glo, filename, show, page); fz_printf(ctx, out, "\n"); + clearinfo(ctx, glo); } } -- cgit v1.2.3