"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xpdf/CharCodeToUnicode.cc" between
xpdf-4.03.tar.gz and xpdf-4.04.tar.gz

About: Xpdf is a PDF viewer for X.

CharCodeToUnicode.cc  (xpdf-4.03):CharCodeToUnicode.cc  (xpdf-4.04)
skipping to change at line 235 skipping to change at line 235
ctu = new CharCodeToUnicode(fileName->copy(), mapA, len, gTrue, ctu = new CharCodeToUnicode(fileName->copy(), mapA, len, gTrue,
sMapA, sMapLenA, sMapSizeA); sMapA, sMapLenA, sMapSizeA);
gfree(mapA); gfree(mapA);
return ctu; return ctu;
} }
CharCodeToUnicode *CharCodeToUnicode::make8BitToUnicode(Unicode *toUnicode) { CharCodeToUnicode *CharCodeToUnicode::make8BitToUnicode(Unicode *toUnicode) {
return new CharCodeToUnicode(NULL, toUnicode, 256, gTrue, NULL, 0, 0); return new CharCodeToUnicode(NULL, toUnicode, 256, gTrue, NULL, 0, 0);
} }
CharCodeToUnicode *CharCodeToUnicode::make16BitToUnicode(Unicode *toUnicode) {
return new CharCodeToUnicode(NULL, toUnicode, 65536, gTrue, NULL, 0, 0);
}
CharCodeToUnicode *CharCodeToUnicode::parseCMap(GString *buf, int nBits) { CharCodeToUnicode *CharCodeToUnicode::parseCMap(GString *buf, int nBits) {
CharCodeToUnicode *ctu; CharCodeToUnicode *ctu;
GStringIndex idx; GStringIndex idx;
ctu = new CharCodeToUnicode(NULL); ctu = new CharCodeToUnicode(NULL);
idx.s = buf; idx.s = buf;
idx.i = 0; idx.i = 0;
if (!ctu->parseCMap1(&getCharFromGString, &idx, nBits)) { if (!ctu->parseCMap1(&getCharFromGString, &idx, nBits)) {
delete ctu; delete ctu;
return NULL; return NULL;
skipping to change at line 473 skipping to change at line 477
strcpy(tok1, tok2); strcpy(tok1, tok2);
} }
} }
delete pst; delete pst;
return ok; return ok;
} }
void CharCodeToUnicode::addMapping(CharCode code, char *uStr, int n, void CharCodeToUnicode::addMapping(CharCode code, char *uStr, int n,
int offset) { int offset) {
CharCode oldLen, i; CharCode oldLen, i;
#if 1 //~utf16
Unicode u[maxUnicodeString]; Unicode u[maxUnicodeString];
int uLen, j; int uLen, j;
#else
Unicode u;
int j;
#endif
if (code > 0xffffff) { if (code > 0xffffff) {
// This is an arbitrary limit to avoid integer overflow issues. // This is an arbitrary limit to avoid integer overflow issues.
// (I've seen CMaps with mappings for <ffffffff>.) // (I've seen CMaps with mappings for <ffffffff>.)
return; return;
} }
#if 1 //~utf16
if ((uLen = parseUTF16String(uStr, n, u)) == 0) { if ((uLen = parseUTF16String(uStr, n, u)) == 0) {
return; return;
} }
#endif
if (code >= mapLen) { if (code >= mapLen) {
oldLen = mapLen; oldLen = mapLen;
mapLen = mapLen ? 2 * mapLen : 256; mapLen = mapLen ? 2 * mapLen : 256;
if (code >= mapLen) { if (code >= mapLen) {
mapLen = (code + 256) & ~255; mapLen = (code + 256) & ~255;
} }
map = (Unicode *)greallocn(map, mapLen, sizeof(Unicode)); map = (Unicode *)greallocn(map, mapLen, sizeof(Unicode));
for (i = oldLen; i < mapLen; ++i) { for (i = oldLen; i < mapLen; ++i) {
map[i] = 0; map[i] = 0;
} }
} }
#if 1 //~utf16
if (uLen == 1) { if (uLen == 1) {
map[code] = u[0] + offset; map[code] = u[0] + offset;
} else { } else {
if (sMapLen >= sMapSize) { if (sMapLen >= sMapSize) {
sMapSize = sMapSize + 16; sMapSize = sMapSize + 16;
sMap = (CharCodeToUnicodeString *) sMap = (CharCodeToUnicodeString *)
greallocn(sMap, sMapSize, sizeof(CharCodeToUnicodeString)); greallocn(sMap, sMapSize, sizeof(CharCodeToUnicodeString));
} }
map[code] = 0; map[code] = 0;
sMap[sMapLen].c = code; sMap[sMapLen].c = code;
for (j = 0; j < uLen; ++j) { for (j = 0; j < uLen; ++j) {
sMap[sMapLen].u[j] = u[j]; sMap[sMapLen].u[j] = u[j];
} }
sMap[sMapLen].u[uLen - 1] += offset; sMap[sMapLen].u[uLen - 1] += offset;
sMap[sMapLen].len = uLen; sMap[sMapLen].len = uLen;
++sMapLen; ++sMapLen;
} }
#else //~utf16
if (n <= 4) {
if (!parseHex(uStr, n, &u)) {
error(errSyntaxWarning, -1, "Illegal entry in ToUnicode CMap");
return;
}
map[code] = u + offset;
} else {
if (sMapLen >= sMapSize) {
sMapSize = sMapSize + 16;
sMap = (CharCodeToUnicodeString *)
greallocn(sMap, sMapSize, sizeof(CharCodeToUnicodeString));
}
map[code] = 0;
sMap[sMapLen].c = code;
if ((sMap[sMapLen].len = n / 4) > maxUnicodeString) {
sMap[sMapLen].len = maxUnicodeString;
}
for (j = 0; j < sMap[sMapLen].len; ++j) {
if (!parseHex(uStr + j*4, 4, &sMap[sMapLen].u[j])) {
error(errSyntaxWarning, -1, "Illegal entry in ToUnicode CMap");
return;
}
}
sMap[sMapLen].u[sMap[sMapLen].len - 1] += offset;
++sMapLen;
}
#endif //~utf16
} }
// Convert a UTF-16BE hex string into a sequence of up to // Convert a UTF-16BE hex string into a sequence of up to
// maxUnicodeString Unicode chars. // maxUnicodeString Unicode chars.
int CharCodeToUnicode::parseUTF16String(char *uStr, int n, Unicode *uOut) { int CharCodeToUnicode::parseUTF16String(char *uStr, int n, Unicode *uOut) {
int i = 0; int i = 0;
int uLen = 0; int uLen = 0;
while (i < n) { while (i < n) {
Unicode u; Unicode u;
int j = n; int j = n;
 End of changes. 7 change blocks. 
36 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)