poppler/CMap.cc | 58 +++++++------------------------------------------------- poppler/CMap.h | 2 - 2 files changed, 8 insertions(+), 52 deletions(-)
New commits: commit b9ecfdf4cb27a19e65817af51c048e8030825035 Author: Albert Astals Cid <[email protected]> Date: Mon Sep 5 19:27:36 2011 +0200 xpdf303: Delay memory allocation up to when it is really needed diff --git a/poppler/CMap.cc b/poppler/CMap.cc index 357b0f0..e26849b 100644 --- a/poppler/CMap.cc +++ b/poppler/CMap.cc @@ -104,26 +104,6 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA, } else if (!strcmp(tok1, "/WMode")) { cmap->wMode = atoi(tok2); pst->getToken(tok1, sizeof(tok1), &n1); - } else if (!strcmp(tok2, "begincodespacerange")) { - while (pst->getToken(tok1, sizeof(tok1), &n1)) { - if (!strcmp(tok1, "endcodespacerange")) { - break; - } - if (!pst->getToken(tok2, sizeof(tok2), &n2) || - !strcmp(tok2, "endcodespacerange")) { - error(errSyntaxError, -1, "Illegal entry in codespacerange block in CMap"); - break; - } - if (tok1[0] == '<' && tok2[0] == '<' && - n1 == n2 && n1 >= 4 && (n1 & 1) == 0) { - tok1[n1 - 1] = tok2[n1 - 1] = '\0'; - sscanf(tok1 + 1, "%x", &start); - sscanf(tok2 + 1, "%x", &end); - n1 = (n1 - 2) / 2; - cmap->addCodeSpace(cmap->vector, start, end, n1); - } - } - pst->getToken(tok1, sizeof(tok1), &n1); } else if (!strcmp(tok2, "begincidchar")) { while (pst->getToken(tok1, sizeof(tok1), &n1)) { if (!strcmp(tok1, "endcidchar")) { @@ -263,45 +243,23 @@ void CMap::copyVector(CMapVectorEntry *dest, CMapVectorEntry *src) { } } -void CMap::addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end, - Guint nBytes) { - Guint start2, end2; - int startByte, endByte, i, j; - - if (nBytes > 1) { - startByte = (start >> (8 * (nBytes - 1))) & 0xff; - endByte = (end >> (8 * (nBytes - 1))) & 0xff; - start2 = start & ((1 << (8 * (nBytes - 1))) - 1); - end2 = end & ((1 << (8 * (nBytes - 1))) - 1); - for (i = startByte; i <= endByte; ++i) { - if (!vec[i].isVector) { - vec[i].isVector = gTrue; - vec[i].vector = - (CMapVectorEntry *)gmallocn(256, sizeof(CMapVectorEntry)); - for (j = 0; j < 256; ++j) { - vec[i].vector[j].isVector = gFalse; - vec[i].vector[j].cid = 0; - } - } - addCodeSpace(vec[i].vector, start2, end2, nBytes - 1); - } - } -} - void CMap::addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID) { CMapVectorEntry *vec; CID cid; int byte; - Guint i; + Guint i, j; vec = vector; for (i = nBytes - 1; i >= 1; --i) { byte = (start >> (8 * i)) & 0xff; if (!vec[byte].isVector) { - error(errSyntaxError, -1, - "Invalid CID ({0:x} - {1:x} [{2:d} bytes]) in CMap", - start, end, nBytes); - return; + vec[byte].isVector = gTrue; + vec[byte].vector = + (CMapVectorEntry *)gmallocn(256, sizeof(CMapVectorEntry)); + for (j = 0; j < 256; ++j) { + vec[byte].vector[j].isVector = gFalse; + vec[byte].vector[j].cid = 0; + } } vec = vec[byte].vector; } diff --git a/poppler/CMap.h b/poppler/CMap.h index 7803d63..f2e61f1 100644 --- a/poppler/CMap.h +++ b/poppler/CMap.h @@ -82,8 +82,6 @@ private: CMap(GooString *collectionA, GooString *cMapNameA, int wModeA); void useCMap(CMapCache *cache, char *useName); void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src); - void addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end, - Guint nBytes); void addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID); void freeCMapVector(CMapVectorEntry *vec); void setReverseMapVector(Guint startCode, CMapVectorEntry *vec, _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
