From 1977a47d0a72f470539be8e6bb6d6e321ce44770 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 1 Apr 2015 12:34:30 +0200 Subject: Fix scan for %d in mudraw. --- source/tools/mudraw.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source/tools') diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index 03e7d404..60d4223b 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -212,6 +212,22 @@ static int isrange(char *s) return 1; } +static int has_percent_d(char *s) +{ + /* find '%[0-9]*d' */ + while (*s) + { + if (*s++ == '%') + { + while (*s >= '0' && *s <= '9') + ++s; + if (*s == 'd') + return 1; + } + } + return 0; +} + static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) { fz_page *page; @@ -590,7 +606,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_output_png_band(ctx, output_file, pix->w, totalheight, pix->n, band, drawheight, pix->samples, savealpha, poc); else if (output_format == OUT_PWG) { - if (strstr(output, "%d") != NULL) + if (has_percent_d(output)) append = 0; if (out_cs == CS_MONO) { @@ -608,7 +624,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_pcl_preset(ctx, &options, "ljet4"); - if (strstr(output, "%d") != NULL) + if (has_percent_d(output)) append = 0; if (out_cs == CS_MONO) { -- cgit v1.2.3