Commit ecf3dcad authored by Brad Hards's avatar Brad Hards

Merge some missing parts of previous patches, and some other minor

cleanups from xpdf 3.0.1
parent de787381
......@@ -67,17 +67,8 @@ Catalog::Catalog(XRef *xrefA) {
}
pagesSize = numPages0 = (int)obj.getNum();
obj.free();
// The gcc doesnt optimize this away, so this check is ok,
// even if it looks like a pagesSize != pagesSize check
if (pagesSize*(int)sizeof(Page *)/sizeof(Page *) != pagesSize ||
pagesSize*(int)sizeof(Ref)/sizeof(Ref) != pagesSize) {
error(-1, "Invalid 'pagesSize'");
ok = gFalse;
return;
}
pages = (Page **)gmallocn(pagesSize, sizeof(Page *));
pageRefs = (Ref *)gmallocn(pagesSize, sizeof(Ref));
pageRefs = (Ref *)gmallocn(pagesSize, sizeof(Ref));
for (i = 0; i < pagesSize; ++i) {
pages[i] = NULL;
pageRefs[i].num = -1;
......@@ -243,11 +234,6 @@ int Catalog::readPageTree(Dict *pagesDict, PageAttrs *attrs, int start) {
}
if (start >= pagesSize) {
pagesSize += 32;
if (pagesSize*(int)sizeof(Page *)/sizeof(Page *) != pagesSize ||
pagesSize*(int)sizeof(Ref)/sizeof(Ref) != pagesSize) {
error(-1, "Invalid 'pagesSize' parameter.");
goto err3;
}
pages = (Page **)greallocn(pages, pagesSize, sizeof(Page *));
pageRefs = (Ref *)greallocn(pageRefs, pagesSize, sizeof(Ref));
for (j = pagesSize - 32; j < pagesSize; ++j) {
......
This diff is collapsed.
......@@ -42,18 +42,22 @@ enum JPXColorSpaceType {
jpxCSYPbPr1250 = 24
};
struct JPXColorSpecCIELab {
Guint rl, ol, ra, oa, rb, ob, il;
};
struct JPXColorSpecEnumerated {
JPXColorSpaceType type; // color space type
union {
JPXColorSpecCIELab cieLab;
};
};
struct JPXColorSpec {
Guint meth; // method
int prec; // precedence
union {
struct {
JPXColorSpaceType type; // color space type
union {
struct {
Guint rl, ol, ra, oa, rb, ob, il;
} cieLab;
};
} enumerated;
JPXColorSpecEnumerated enumerated;
};
};
......@@ -133,6 +137,8 @@ struct JPXCodeBlock {
//----- coefficient data
JPXCoeff *coeffs; // the coefficients
JArithmeticDecoder // arithmetic decoder
*arithDecoder;
JArithmeticDecoderStats // arithmetic decoder stats
*stats;
};
......@@ -273,10 +279,13 @@ public:
virtual int lookChar();
virtual GooString *getPSFilter(int psLevel, char *indent);
virtual GBool isBinary(GBool last = gTrue);
virtual void getImageParams(int *bitsPerComponent,
StreamColorSpaceMode *csMode);
private:
void fillReadBuf();
void getImageParams2(int *bitsPerComponent, StreamColorSpaceMode *csMode);
GBool readBoxes();
GBool readColorSpecBox(Guint dataLen);
GBool readCodestream(Guint len);
......
......@@ -171,6 +171,13 @@ Object *Lexer::getObj(Object *obj) {
scale = 0.1;
while (1) {
c = lookChar();
if (c == '-') {
// ignore minus signs in the middle of numbers to match
// Adobe's behavior
error(getPos(), "Badly formatted number");
getChar();
continue;
}
if (!isdigit(c)) {
break;
}
......@@ -472,3 +479,7 @@ void Lexer::skipToNextLine() {
}
}
}
GBool Lexer::isSpace(int c) {
return c >= 0 && c <= 0xff && specialChars[c] == 1;
}
......@@ -60,6 +60,9 @@ public:
void setPos(Guint pos, int dir = 0)
{ if (!curStr.isNone()) curStr.streamSetPos(pos, dir); }
// Returns true if <c> is a whitespace character.
static GBool isSpace(int c);
private:
int getChar();
......
......@@ -807,13 +807,13 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
// initialize fontIDs, fontFileIDs, and fontFileNames lists
fontIDSize = 64;
fontIDLen = 0;
fontIDs = (Ref *)gmalloc(fontIDSize * sizeof(Ref));
fontIDs = (Ref *)gmallocn(fontIDSize, sizeof(Ref));
fontFileIDSize = 64;
fontFileIDLen = 0;
fontFileIDs = (Ref *)gmalloc(fontFileIDSize * sizeof(Ref));
fontFileIDs = (Ref *)gmallocn(fontFileIDSize, sizeof(Ref));
fontFileNameSize = 64;
fontFileNameLen = 0;
fontFileNames = (GooString **)gmalloc(fontFileNameSize * sizeof(GooString *));
fontFileNames = (GooString **)gmallocn(fontFileNameSize, sizeof(GooString *));
nextTrueTypeNum = 0;
font16EncLen = 0;
font16EncSize = 0;
......@@ -1108,6 +1108,7 @@ void PSOutputDev::setupResources(Dict *resDict) {
setupFonts(resDict);
setupImages(resDict);
//----- recursively scan XObjects
resDict->lookup("XObject", &xObjDict);
if (xObjDict.isDict()) {
for (i = 0; i < xObjDict.dictGetLength(); ++i) {
......@@ -1206,7 +1207,7 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) {
// add entry to fontIDs list
if (fontIDLen >= fontIDSize) {
fontIDSize += 64;
fontIDs = (Ref *)grealloc(fontIDs, fontIDSize * sizeof(Ref));
fontIDs = (Ref *)greallocn(fontIDs, fontIDSize, sizeof(Ref));
}
fontIDs[fontIDLen++] = *font->getID();
......@@ -1342,8 +1343,8 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) {
psName = fontParam->psFontName->copy();
if (font16EncLen >= font16EncSize) {
font16EncSize += 16;
font16Enc = (PSFont16Enc *)grealloc(font16Enc,
font16EncSize * sizeof(PSFont16Enc));
font16Enc = (PSFont16Enc *)greallocn(font16Enc,
font16EncSize, sizeof(PSFont16Enc));
}
font16Enc[font16EncLen].fontID = *font->getID();
font16Enc[font16EncLen].enc = fontParam->encoding->copy();
......@@ -1427,7 +1428,7 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, GooString *psName) {
// add entry to fontFileIDs list
if (fontFileIDLen >= fontFileIDSize) {
fontFileIDSize += 64;
fontFileIDs = (Ref *)grealloc(fontFileIDs, fontFileIDSize * sizeof(Ref));
fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref));
}
fontFileIDs[fontFileIDLen++] = *id;
......@@ -1554,8 +1555,8 @@ void PSOutputDev::setupExternalType1Font(GooString *fileName, GooString *psName)
// add entry to fontFileNames list
if (fontFileNameLen >= fontFileNameSize) {
fontFileNameSize += 64;
fontFileNames = (GooString **)grealloc(fontFileNames,
fontFileNameSize * sizeof(GooString *));
fontFileNames = (GooString **)greallocn(fontFileNames,
fontFileNameSize, sizeof(GooString *));
}
fontFileNames[fontFileNameLen++] = fileName->copy();
......@@ -1596,7 +1597,7 @@ void PSOutputDev::setupEmbeddedType1CFont(GfxFont *font, Ref *id,
// add entry to fontFileIDs list
if (fontFileIDLen >= fontFileIDSize) {
fontFileIDSize += 64;
fontFileIDs = (Ref *)grealloc(fontFileIDs, fontFileIDSize * sizeof(Ref));
fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref));
}
fontFileIDs[fontFileIDLen++] = *id;
......@@ -1641,7 +1642,7 @@ void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id,
if (i == fontFileIDLen) {
if (fontFileIDLen >= fontFileIDSize) {
fontFileIDSize += 64;
fontFileIDs = (Ref *)grealloc(fontFileIDs, fontFileIDSize * sizeof(Ref));
fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref));
}
fontFileIDs[fontFileIDLen++] = *id;
}
......@@ -1694,8 +1695,8 @@ void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, GooString *psName) {
if (fontFileNameLen >= fontFileNameSize) {
fontFileNameSize += 64;
fontFileNames =
(GooString **)grealloc(fontFileNames,
fontFileNameSize * sizeof(GooString *));
(GooString **)greallocn(fontFileNames,
fontFileNameSize, sizeof(GooString *));
}
}
fontFileNames[fontFileNameLen++] = fileName->copy();
......@@ -1740,7 +1741,7 @@ void PSOutputDev::setupEmbeddedCIDType0Font(GfxFont *font, Ref *id,
// add entry to fontFileIDs list
if (fontFileIDLen >= fontFileIDSize) {
fontFileIDSize += 64;
fontFileIDs = (Ref *)grealloc(fontFileIDs, fontFileIDSize * sizeof(Ref));
fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref));
}
fontFileIDs[fontFileIDLen++] = *id;
......@@ -1785,7 +1786,7 @@ void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id,
// add entry to fontFileIDs list
if (fontFileIDLen >= fontFileIDSize) {
fontFileIDSize += 64;
fontFileIDs = (Ref *)grealloc(fontFileIDs, fontFileIDSize * sizeof(Ref));
fontFileIDs = (Ref *)greallocn(fontFileIDs, fontFileIDSize, sizeof(Ref));
}
fontFileIDs[fontFileIDLen++] = *id;
......
......@@ -38,6 +38,13 @@ enum StreamKind {
strWeird // internal-use stream types
};
enum StreamColorSpaceMode {
streamCSNone,
streamCSDeviceGray,
streamCSDeviceRGB,
streamCSDeviceCMYK
};
//------------------------------------------------------------------------
// Stream (base class)
//------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment