[poppler] poppler/poppler: Link.cc,1.2,1.3

Albert Astals Cid aacid at freedesktop.org
Tue Sep 20 07:34:33 PDT 2005


Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv29837/poppler

Modified Files:
	Link.cc 
Log Message:
Merge link.cc changes from xpdf 3.00 -> 3.01


Index: Link.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Link.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Link.cc	27 Aug 2005 08:43:43 -0000	1.2
+++ Link.cc	20 Sep 2005 14:34:31 -0000	1.3
@@ -119,14 +119,19 @@
 
   // dictionary
   } else if (fileSpecObj->isDict()) {
+#ifdef WIN32
+    if (!fileSpecObj->dictLookup("DOS", &obj1)->isString()) {
+#else
     if (!fileSpecObj->dictLookup("Unix", &obj1)->isString()) {
+#endif
       obj1.free();
       fileSpecObj->dictLookup("F", &obj1);
     }
-    if (obj1.isString())
+    if (obj1.isString()) {
       name = obj1.getString()->copy();
-    else
+    } else {
       error(-1, "Illegal file spec in link");
+    }
     obj1.free();
 
   // error
@@ -134,6 +139,55 @@
     error(-1, "Illegal file spec in link");
   }
 
+  // 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;
+	}
+      }
+    }
+    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);
+      }
+    }
+#else
+    // no manipulation needed for Unix
+#endif
+  }
+
   return name;
 }
 
@@ -499,7 +553,7 @@
   uri = NULL;
   if (uriObj->isString()) {
     uri2 = uriObj->getString()->copy();
-    if (baseURI) {
+    if (baseURI && baseURI->getLength() > 0) {
       n = strcspn(uri2->getCString(), "/:");
       if (n == uri2->getLength() || uri2->getChar(n) == '/') {
 	uri = baseURI->copy();
@@ -724,6 +778,10 @@
 	      }
 	      obj3.free();
 	    }
+	  } else {
+	    // Adobe draws no border at all if the last element is of
+	    // the wrong type.
+	    borderWidth = 0;
 	  }
 	  obj2.free();
 	}



More information about the poppler mailing list