Huub Schaeks fix for .schange
[swftools.git] / pdf2swf / xpdf / GlobalParams.cc
index 882083a..8981ba9 100644 (file)
@@ -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;