[poppler] 2 commits - glib/demo poppler/FileSpec.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Wed Jul 8 02:31:20 PDT 2009


 glib/demo/utils.c   |    2 
 poppler/FileSpec.cc |  114 +++++++++++++++++++++++-----------------------------
 2 files changed, 52 insertions(+), 64 deletions(-)

New commits:
commit ef261f5f72d37a0aa2709611ee2bad7d55340ed8
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Tue Jul 7 10:57:31 2009 +0200

    Do not use F and UF entries if Unix or DOS are present in FileSpec dict

diff --git a/poppler/FileSpec.cc b/poppler/FileSpec.cc
index 07a5ed8..9ec4857 100644
--- a/poppler/FileSpec.cc
+++ b/poppler/FileSpec.cc
@@ -5,7 +5,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2008 Carlos Garcia Campos <carlosgc at gnome.org>
+// Copyright (C) 2008-2009 Carlos Garcia Campos <carlosgc at gnome.org>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -63,84 +63,72 @@ GBool getFileSpecNameForPlatform (Object *fileSpec, Object *fileName)
     return gTrue;
   }
 
-  Object obj1;
-  GooString *name;
-
-  name = NULL;
-  
   if (fileSpec->isDict()) {
 #ifdef WIN32
-    if (!fileSpec->dictLookup("DOS", &obj1)->isString()) {
+    fileSpec->dictLookup("DOS", fileName);
 #else
-    if (!fileSpec->dictLookup("Unix", &obj1)->isString()) {
+    fileSpec->dictLookup("Unix", fileName);
 #endif
-      obj1.free();
-      if (fileSpec->dictLookup("UF", &obj1)->isString ()) {
-        name = obj1.getString()->copy();
-      } else if (fileSpec->dictLookup("F", &obj1)->isString ()) {
-        name = obj1.getString()->copy();
-      } else {
-        error(-1, "Illegal file spec in link");
+    if (!fileName->isString()) {
+      fileName->free();
+      if (!fileSpec->dictLookup("UF", fileName)->isString ()) {
+        fileName->free();
+        if (!fileSpec->dictLookup("F", fileName)->isString ()) {
+	  fileName->free();
+	  error(-1, "Illegal file spec");
+	  return gFalse;
+	}
       }
     }
-    obj1.free();
-
-  // error
   } else {
-    error(-1, "Illegal file spec in link");
+    error(-1, "Illegal file spec");
+    return gFalse;
   }
 
   // system-dependent path manipulation
-  if (name) {
 #ifdef WIN32
-    int i, j;
-
-    // "//...."             --> "\...."
-    // "/x/...."            --> "x:\...."
-    // "/server/share/...." --> "\\server\share\...."
-    // convert escaped slashes to slashes and unescaped slashes to backslashes
-    i = 0;
-    if (name->getChar(0) == '/') {
-      if (name->getLength() >= 2 && name->getChar(1) == '/') {
-	name->del(0);
-	i = 0;
-      } else if (name->getLength() >= 2 &&
-		 ((name->getChar(1) >= 'a' && name->getChar(1) <= 'z') ||
-		  (name->getChar(1) >= 'A' && name->getChar(1) <= 'Z')) &&
-		 (name->getLength() == 2 || name->getChar(2) == '/')) {
-	name->setChar(0, name->getChar(1));
-	name->setChar(1, ':');
-	i = 2;
-      } else {
-	for (j = 2; j < name->getLength(); ++j) {
-	  if (name->getChar(j-1) != '\\' &&
-	      name->getChar(j) == '/') {
-	    break;
-	  }
-	}
-	if (j < name->getLength()) {
-	  name->setChar(0, '\\');
-	  name->insert(0, '\\');
-	  i = 2;
+  int i, j;
+  GooString *name = fileName->getString();
+  // "//...."             --> "\...."
+  // "/x/...."            --> "x:\...."
+  // "/server/share/...." --> "\\server\share\...."
+  // convert escaped slashes to slashes and unescaped slashes to backslashes
+  i = 0;
+  if (name->getChar(0) == '/') {
+    if (name->getLength() >= 2 && name->getChar(1) == '/') {
+      name->del(0);
+      i = 0;
+    } else if (name->getLength() >= 2 &&
+	       ((name->getChar(1) >= 'a' && name->getChar(1) <= 'z') ||
+		(name->getChar(1) >= 'A' && name->getChar(1) <= 'Z')) &&
+	       (name->getLength() == 2 || name->getChar(2) == '/')) {
+      name->setChar(0, name->getChar(1));
+      name->setChar(1, ':');
+      i = 2;
+    } else {
+      for (j = 2; j < name->getLength(); ++j) {
+        if (name->getChar(j-1) != '\\' &&
+	    name->getChar(j) == '/') {
+	  break;
 	}
       }
-    }
-    for (; i < name->getLength(); ++i) {
-      if (name->getChar(i) == '/') {
-	name->setChar(i, '\\');
-      } else if (name->getChar(i) == '\\' &&
-		 i+1 < name->getLength() &&
-		 name->getChar(i+1) == '/') {
-	name->del(i);
+      if (j < name->getLength()) {
+        name->setChar(0, '\\');
+	name->insert(0, '\\');
+	i = 2;
       }
     }
-#else
-    // no manipulation needed for Unix
-#endif
-  } else {
-    return gFalse;
   }
+  for (; i < name->getLength(); ++i) {
+    if (name->getChar(i) == '/') {
+      name->setChar(i, '\\');
+    } else if (name->getChar(i) == '\\' &&
+	       i+1 < name->getLength() &&
+	       name->getChar(i+1) == '/') {
+      name->del(i);
+    }
+  }
+#endif /* WIN32 */
 
-  fileName->initString (name);
   return gTrue;
 }
commit cafd4653dc6c7574214e80aa09489dcd24e347a6
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Wed Jul 1 11:41:32 2009 +0200

    [glib-demo] Fix a typo

diff --git a/glib/demo/utils.c b/glib/demo/utils.c
index d1fa8ff..010fab3 100644
--- a/glib/demo/utils.c
+++ b/glib/demo/utils.c
@@ -216,7 +216,7 @@ pgd_action_view_set_action (GtkWidget     *action_view,
 	case POPPLER_ACTION_LAUNCH:
 		pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "Launch", &row);
 		pgd_table_add_property (GTK_TABLE (table), "<b>Filename:</b>", action->launch.file_name, &row);
-		pgd_table_add_property (GTK_TABLE (table), "<b>Params:</b>", action->launch.file_name, &row);
+		pgd_table_add_property (GTK_TABLE (table), "<b>Params:</b>", action->launch.params, &row);
 		break;
 	case POPPLER_ACTION_URI:
 		pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "External URI", &row);


More information about the poppler mailing list