utils/parseargs.cc | 12 ++++++++++++ utils/parseargs.h | 2 ++ utils/pdftocairo.cc | 17 ++++++++--------- 3 files changed, 22 insertions(+), 9 deletions(-)
New commits: commit 40b56994dda79653c902977423f349efa55cf21e Author: Adrian Johnson <[email protected]> Date: Mon Oct 17 20:33:03 2011 +1030 utils: Add GooString arg to parseargs and use for paths in pdftocairo <sys/param.h> and MAXPATHLEN is not available on windows. Avoid the need to know the max path length by using GooString for the path. diff --git a/utils/parseargs.cc b/utils/parseargs.cc index c5f3007..ef971a5 100644 --- a/utils/parseargs.cc +++ b/utils/parseargs.cc @@ -30,6 +30,7 @@ #include "parseargs.h" #include "goo/gstrtod.h" +#include "goo/GooString.h" static const ArgDesc *findArg(const ArgDesc *args, char *arg); static GBool grabArg(const ArgDesc *arg, int i, int *argc, char *argv[]); @@ -87,6 +88,7 @@ void printUsage(char *program, char *otherArgs, const ArgDesc *args) { break; case argString: case argStringDummy: + case argGooString: typ = " <string>"; break; case argFlag: @@ -152,6 +154,16 @@ static GBool grabArg(const ArgDesc *arg, int i, int *argc, char *argv[]) { n = 1; } break; + case argGooString: + if (i + 1 < *argc) { + ((GooString*)arg->val)->Set(argv[i+1], arg->size - 1); + ((GooString*)arg->val)->append('\0'); + n = 2; + } else { + ok = gFalse; + n = 1; + } + break; default: fprintf(stderr, "Internal error in arg table\n"); n = 1; diff --git a/utils/parseargs.h b/utils/parseargs.h index 410dcc4..a2ec1d7 100644 --- a/utils/parseargs.h +++ b/utils/parseargs.h @@ -41,6 +41,8 @@ typedef enum { /* [val: double *] */ argString, /* string arg */ /* [val: char *] */ + argGooString, /* string arg */ + /* [val: GooString *] */ /* dummy entries -- these show up in the usage listing only; */ /* useful for X args, for example */ argFlagDummy, diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc index fb3ca30..e458ee5 100644 --- a/utils/pdftocairo.cc +++ b/utils/pdftocairo.cc @@ -32,7 +32,6 @@ #include "config.h" #include <poppler-config.h> -#include <sys/param.h> // for MAXPATHLEN #include <stdio.h> #include <math.h> #include <string.h> @@ -91,7 +90,7 @@ static GBool useCropBox = gFalse; static GBool mono = gFalse; static GBool gray = gFalse; static GBool transp = gFalse; -static char icc[MAXPATHLEN] = ""; +static GooString icc; static GBool level2 = gFalse; static GBool level3 = gFalse; @@ -179,7 +178,7 @@ static const ArgDesc argDesc[] = { {"-transp", argFlag, &transp, 0, "use a transparent background instead of white (PNG)"}, #if USE_CMS - {"-icc", argString, &icc, sizeof(icc), + {"-icc", argGooString, &icc, 0, "ICC color profile to use"}, #endif @@ -756,7 +755,7 @@ int main(int argc, char *argv[]) { checkInvalidPrintOption(mono, "-mono"); checkInvalidPrintOption(gray, "-gray"); checkInvalidPrintOption(transp, "-transp"); - checkInvalidPrintOption(icc[0], "-icc"); + checkInvalidPrintOption(icc.getCString()[0], "-icc"); checkInvalidPrintOption(singleFile, "-singlefile"); } else { checkInvalidImageOption(level2, "-level2"); @@ -772,7 +771,7 @@ int main(int argc, char *argv[]) { checkInvalidImageOption(duplex, "-duplex"); } - if (icc[0] && !png) { + if (icc.getCString()[0] && !png) { fprintf(stderr, "Error: -icc may only be used with png output.\n"); exit(99); } @@ -842,10 +841,10 @@ int main(int argc, char *argv[]) { #if USE_CMS icc_data = NULL; - if (icc[0]) { - FILE *file = fopen(icc, "rb"); + if (icc.getCString()[0]) { + FILE *file = fopen(icc.getCString(), "rb"); if (!file) { - fprintf(stderr, "Error: unable to open icc profile %s\n", icc); + fprintf(stderr, "Error: unable to open icc profile %s\n", icc.getCString()); exit(4); } fseek (file, 0, SEEK_END); @@ -853,7 +852,7 @@ int main(int argc, char *argv[]) { fseek (file, 0, SEEK_SET); icc_data = (unsigned char*)gmalloc(icc_data_size); if (fread(icc_data, icc_data_size, 1, file) != 1) { - fprintf(stderr, "Error: unable to read icc profile %s\n", icc); + fprintf(stderr, "Error: unable to read icc profile %s\n", icc.getCString()); exit(4); } fclose(file); _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
