X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fxpdf%2FGlobalParams.cc;h=8981ba9e4ec903a8d8e85f037da5097106e89f3e;hb=c26ca847941ca0acfc9f3b4bdc519d904ba09a39;hp=882083a0e3932cdc5cad71ab0cdfbc2d7a3896ab;hpb=ebe12c095d5a5274feb5f4475b3782aa64a07d0a;p=swftools.git diff --git a/pdf2swf/xpdf/GlobalParams.cc b/pdf2swf/xpdf/GlobalParams.cc index 882083a..8981ba9 100644 --- a/pdf2swf/xpdf/GlobalParams.cc +++ b/pdf2swf/xpdf/GlobalParams.cc @@ -682,6 +682,32 @@ void GlobalParams::parseFile(GString *fileName, FILE *f) { } } +static GString* qualify_filename(GString*path, GString*filename) +{ + GString*fullpath = 0; + char*prefix = "/usr/local/share/xpdf/"; + + if (filename->getChar(0) != '\\' && filename->getChar(0) != '/') { + /* relative path */ + fullpath = path->copy(); + fullpath->append(filename); + } else if (!strncmp(filename->getCString(), prefix, strlen(prefix))) { + /* xpdf default path */ + char*s = strchr(filename->getCString()+strlen(prefix), '/'); + if(s) { + fullpath = path->copy(); + fullpath->append(s+1); + } else { + fullpath = filename->copy(); + } + } else { + /* absolute path */ + fullpath = filename->copy(); + } + //printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString()); + return fullpath; +} + void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName, int line) { GString *name; @@ -696,7 +722,7 @@ void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName, fileName->getCString(), line); return; } - name = (GString *)tokens->get(1); + name = qualify_filename(this->path, (GString *)tokens->get(1)); if (!(f = fopen(name->getCString(), "r"))) { error(-1, "Couldn't open 'nameToUnicode' file '%s'", name->getCString()); @@ -717,32 +743,6 @@ void GlobalParams::parseNameToUnicode(GList *tokens, GString *fileName, fclose(f); } -static GString* qualify_filename(GString*path, GString*filename) -{ - GString*fullpath = 0; - char*prefix = "/usr/local/share/xpdf/"; - - if (filename->getChar(0) != '\\' && filename->getChar(0) != '/') { - /* relative path */ - fullpath = path->copy(); - fullpath->append(filename); - } else if (!strncmp(filename->getCString(), prefix, strlen(prefix))) { - /* xpdf default path */ - char*s = strchr(filename->getCString()+strlen(prefix), '/'); - if(s) { - fullpath = path->copy(); - fullpath->append(s+1); - } else { - fullpath = filename->copy(); - } - } else { - /* absolute path */ - fullpath = filename->copy(); - } - printf("%s -%s-> %s\n", filename->getCString(), path->getCString(), fullpath->getCString()); - return fullpath; -} - void GlobalParams::parseCIDToUnicode(GList *tokens, GString *fileName, int line) { GString *collection, *name, *old;