// 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
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;
}
delete dest;
dest = NULL;
}
-
// error
} else {
- error(-1, "Illegal annotation destination");
+ error(-1, "Illegal annotation destination %d", destObj->getType());
}
}
delete dest;
dest = NULL;
}
-
// error
} else {
- error(-1, "Illegal annotation destination");
+ error(-1, "Illegal annotation destination %d", destObj->getType());
}
}
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();
obj2.free();
if (obj1.dictLookup("D", &obj2)->isArray()) {
borderDashLength = obj2.arrayGetLength();
- borderDash = (double *)gmalloc(borderDashLength * sizeof(double));
+ borderDash = (double *)gmallocn(borderDashLength, sizeof(double));
for (i = 0; i < borderDashLength; ++i) {
if (obj2.arrayGet(i, &obj3)->isNum()) {
borderDash[i] = obj3.getNum();
if (obj1.arrayGet(3, &obj2)->isArray()) {
borderType = linkBorderDashed;
borderDashLength = obj2.arrayGetLength();
- borderDash = (double *)gmalloc(borderDashLength * sizeof(double));
+ borderDash = (double *)gmallocn(borderDashLength, sizeof(double));
for (i = 0; i < borderDashLength; ++i) {
if (obj2.arrayGet(i, &obj3)->isNum()) {
borderDash[i] = obj3.getNum();
}
obj3.free();
}
+ } else {
+ // Adobe draws no border at all if the last element is of
+ // the wrong type.
+ borderWidth = 0;
}
obj2.free();
}
if (link->isOk()) {
if (numLinks >= size) {
size += 16;
- links = (Link **)grealloc(links, size * sizeof(Link *));
+ links = (Link **)greallocn(links, size, sizeof(Link *));
}
links[numLinks++] = link;
} else {