From cb1b97dbd394abd4745ee97b667acab11ff0d0ed Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 16 Sep 2014 21:32:09 +0930 Subject: [PATCH 10/10] pdftocairo: improve win32 print option parsing - remove numeric value for source - fix infinite loop bug (add option++) --- utils/pdftocairo-win32.cc | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/utils/pdftocairo-win32.cc b/utils/pdftocairo-win32.cc index ffba984..5f184d1 100644 --- a/utils/pdftocairo-win32.cc +++ b/utils/pdftocairo-win32.cc @@ -35,25 +35,16 @@ static const Win32Option win32PaperSource[] = static void parseSource(GooString *source) { - int src; const Win32Option *option = win32PaperSource; while (option->name) { if (source->cmp(option->name) == 0) { - src = option->value; - break; - } - } - if (!option->name) { - if (isInt(source->getCString())) { - src = atoi(source->getCString()); - } else { - fprintf(stderr, "Warning: Unknown paper source \"%s\"\n", source->getCString()); + devmode->dmDefaultSource = option->value; + devmode->dmFields |= DM_DEFAULTSOURCE; return; } + option++; } - - devmode->dmDefaultSource = src; - devmode->dmFields |= DM_DEFAULTSOURCE; + fprintf(stderr, "Warning: Unknown paper source \"%s\"\n", source->getCString()); } static const Win32Option win32DuplexMode[] = @@ -66,21 +57,16 @@ static const Win32Option win32DuplexMode[] = static void parseDuplex(GooString *mode) { - int win32Duplex; const Win32Option *option = win32DuplexMode; while (option->name) { if (mode->cmp(option->name) == 0) { - win32Duplex = option->value; - break; + devmode->dmDuplex = option->value; + devmode->dmFields |= DM_DUPLEX; + return; } + option++; } - if (!option->name) { - fprintf(stderr, "Warning: Unknown duplex mode \"%s\"\n", mode->getCString()); - return; - } - - devmode->dmDuplex = win32Duplex; - devmode->dmFields |= DM_DUPLEX; + fprintf(stderr, "Warning: Unknown duplex mode \"%s\"\n", mode->getCString()); } static void fillCommonPrinterOptions(double w, double h, GBool duplex) -- 2.1.0