Commit 00549400 authored by Albert Astals Cid's avatar Albert Astals Cid

xpdf303: error() changes, new param and formatting

parent cd076492
......@@ -55,22 +55,22 @@ char *FoFiBase::readFile(char *fileName, int *fileLen) {
int n;
if (!(f = fopen(fileName, "rb"))) {
error(-1, "Cannot open '%s'", fileName);
error(errIO, -1, "Cannot open '{0:s}'", fileName);
return NULL;
}
if (fseek(f, 0, SEEK_END) != 0) {
error(-1, "Cannot seek to end of '%s'", fileName);
error(errIO, -1, "Cannot seek to end of '{0:s}'", fileName);
fclose(f);
return NULL;
}
n = (int)ftell(f);
if (n < 0) {
error(-1, "Cannot determine length of '%s'", fileName);
error(errIO, -1, "Cannot determine length of '{0:s}'", fileName);
fclose(f);
return NULL;
}
if (fseek(f, 0, SEEK_SET) != 0) {
error(-1, "Cannot seek to start of '%s'", fileName);
error(errIO, -1, "Cannot seek to start of '{0:s}'", fileName);
fclose(f);
return NULL;
}
......
......@@ -1976,7 +1976,7 @@ void FoFiTrueType::parse() {
tables[i].offset + tables[i].len > len) {
i--;
wrongTables++;
error(-1, "Found a bad table definition on true type definition, trying to continue...");
error(errSyntaxWarning, -1, "Found a bad table definition on true type definition, trying to continue...");
}
pos += 16;
}
......
......@@ -224,7 +224,7 @@ void FoFiType1::parse() {
j < 300 && line && (line1 = getNextLine(line));
++j, line = line1) {
if ((n = line1 - line) > 255) {
error(-1, "FoFiType1::parse a line has more than 255 characters, we don't support this");
error(errSyntaxWarning, -1, "FoFiType1::parse a line has more than 255 characters, we don't support this");
n = 255;
}
strncpy(buf, line, n);
......@@ -267,7 +267,7 @@ void FoFiType1::parse() {
line1 = &line[p - buf];
}
} else {
error(-1, "FoFiType1::parse no put after dup");
error(errSyntaxWarning, -1, "FoFiType1::parse no put after dup");
}
}
}
......
......@@ -25,7 +25,7 @@ void outputMessage(j_common_ptr cinfo)
(*cinfo->err->format_message) (cinfo, buffer);
// Send it to poppler's error handler
error(-1, "%s", buffer);
error(errInternal, -1, "{0:s}", buffer);
}
JpegWriter::JpegWriter(int q, bool p, J_COLOR_SPACE cm)
......
......@@ -59,25 +59,25 @@ bool PNGWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
/* initialize stuff */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) {
error(-1, "png_create_write_struct failed");
error(errInternal, -1, "png_create_write_struct failed");
return false;
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
error(-1, "png_create_info_struct failed");
error(errInternal, -1, "png_create_info_struct failed");
return false;
}
if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "png_jmpbuf failed");
error(errInternal, -1, "png_jmpbuf failed");
return false;
}
/* write header */
png_init_io(png_ptr, f);
if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "Error during writing header");
error(errInternal, -1, "Error during writing header");
return false;
}
......@@ -118,7 +118,7 @@ bool PNGWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
png_write_info(png_ptr, info_ptr);
if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "error during writing png info bytes");
error(errInternal, -1, "error during writing png info bytes");
return false;
}
......@@ -134,7 +134,7 @@ bool PNGWriter::writePointers(unsigned char **rowPointers, int rowCount)
png_write_image(png_ptr, rowPointers);
/* write bytes */
if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "Error during writing bytes");
error(errInternal, -1, "Error during writing bytes");
return false;
}
......@@ -146,7 +146,7 @@ bool PNGWriter::writeRow(unsigned char **row)
// Write the row to the file
png_write_rows(png_ptr, row, 1);
if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "error during png row write");
error(errInternal, -1, "error during png row write");
return false;
}
......@@ -158,7 +158,7 @@ bool PNGWriter::close()
/* end write */
png_write_end(png_ptr, info_ptr);
if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "Error during end of write");
error(errInternal, -1, "Error during end of write");
return false;
}
......
......@@ -251,7 +251,7 @@ void AnnotPath::parsePathArray(Array *array) {
GBool correct = gTrue;
if (array->getLength() % 2) {
error(-1, "Bad Annot Path");
error(errSyntaxError, -1, "Bad Annot Path");
return;
}
......@@ -341,7 +341,7 @@ AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) {
} else {
correct = gFalse;
obj.free();
error (-1, "Invalid QuadPoint in annot");
error (errSyntaxError, -1, "Invalid QuadPoint in annot");
break;
}
obj.free();
......@@ -895,7 +895,7 @@ void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) {
} else {
rect->x1 = rect->y1 = 0;
rect->x2 = rect->y2 = 1;
error(-1, "Bad bounding box for annotation");
error(errSyntaxError, -1, "Bad bounding box for annotation");
ok = gFalse;
}
obj1.free();
......@@ -1005,7 +1005,7 @@ void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) {
optContentConfig = catalog ? catalog->getOptContentConfig() : NULL;
dict->lookupNF("OC", &oc);
if (!oc.isRef() && !oc.isNull()) {
error (-1, "Annotation OC value not null or dict: %i", oc.getType());
error (errSyntaxError, -1, "Annotation OC value not null or dict: {0:d}", oc.getType());
}
}
......@@ -2133,7 +2133,7 @@ void AnnotFreeText::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) {
appearanceString = obj1.getString()->copy();
} else {
appearanceString = new GooString();
error(-1, "Bad appearance for annotation");
error(errSyntaxError, -1, "Bad appearance for annotation");
ok = gFalse;
}
obj1.free();
......@@ -2545,7 +2545,7 @@ void AnnotTextMarkup::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) {
if(dict->lookup("QuadPoints", &obj1)->isArray()) {
quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect);
} else {
error(-1, "Bad Annot Text Markup QuadPoints");
error(errSyntaxError, -1, "Bad Annot Text Markup QuadPoints");
quadrilaterals = NULL;
ok = gFalse;
}
......@@ -2815,7 +2815,7 @@ void AnnotWidget::layoutText(GooString *text, GooString *outBuf, int *i,
int last_i1, last_i2, last_o1, last_o2;
if (unicode && text->getLength() % 2 != 0) {
error(-1, "AnnotWidget::layoutText, bad unicode string");
error(errSyntaxError, -1, "AnnotWidget::layoutText, bad unicode string");
return;
}
......@@ -3083,16 +3083,16 @@ void AnnotWidget::drawText(GooString *text, GooString *da, GfxResources *resourc
freeFont = gTrue;
addDingbatsResource = gTrue;
} else {
error(-1, "Unknown font in field's DA string");
error(errSyntaxError, -1, "Unknown font in field's DA string");
}
}
} else {
error(-1, "Invalid font name in 'Tf' operator in field's DA string");
error(errSyntaxError, -1, "Invalid font name in 'Tf' operator in field's DA string");
}
tok = (GooString *)daToks->get(tfPos + 1);
fontSize = gatof(tok->getCString());
} else {
error(-1, "Missing 'Tf' operator in field's DA string");
error(errSyntaxError, -1, "Missing 'Tf' operator in field's DA string");
}
if (!font) {
if (daToks) {
......@@ -3442,15 +3442,15 @@ void AnnotWidget::drawListBox(FormFieldChoice *fieldChoice,
tok = (GooString *)daToks->get(tfPos);
if (tok->getLength() >= 1 && tok->getChar(0) == '/') {
if (!resources || !(font = resources->lookupFont(tok->getCString() + 1))) {
error(-1, "Unknown font in field's DA string");
error(errSyntaxError, -1, "Unknown font in field's DA string");
}
} else {
error(-1, "Invalid font name in 'Tf' operator in field's DA string");
error(errSyntaxError, -1, "Invalid font name in 'Tf' operator in field's DA string");
}
tok = (GooString *)daToks->get(tfPos + 1);
fontSize = gatof(tok->getCString());
} else {
error(-1, "Missing 'Tf' operator in field's DA string");
error(errSyntaxError, -1, "Missing 'Tf' operator in field's DA string");
}
if (!font) {
if (daToks) {
......@@ -3794,7 +3794,7 @@ void AnnotWidget::generateFieldAppearance() {
break;
case formUndef:
default:
error(-1, "Unknown field type");
error(errSyntaxError, -1, "Unknown field type");
}
// build the appearance stream dictionary
......@@ -3935,7 +3935,7 @@ void AnnotMovie::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
}
obj2.free();
} else {
error(-1, "Bad Annot Movie");
error(errSyntaxError, -1, "Bad Annot Movie");
movie = NULL;
ok = gFalse;
}
......@@ -4076,7 +4076,7 @@ void AnnotScreen::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
if (dict->lookup("A", &obj1)->isDict()) {
action = LinkAction::parseAction(&obj1, catalog->getBaseURI());
if (action->getKind() == actionRendition && page == 0) {
error (-1, "Invalid Rendition action: associated screen annotation without P");
error (errSyntaxError, -1, "Invalid Rendition action: associated screen annotation without P");
delete action;
action = NULL;
ok = gFalse;
......@@ -4391,7 +4391,7 @@ void AnnotPolygon::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
vertices = new AnnotPath(obj1.getArray());
} else {
vertices = new AnnotPath();
error(-1, "Bad Annot Polygon Vertices");
error(errSyntaxError, -1, "Bad Annot Polygon Vertices");
ok = gFalse;
}
obj1.free();
......@@ -4557,7 +4557,7 @@ void AnnotInk::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
} else {
inkListLength = 0;
inkList = NULL;
error(-1, "Bad Annot Ink List");
error(errSyntaxError, -1, "Bad Annot Ink List");
ok = gFalse;
}
obj1.free();
......@@ -4600,7 +4600,7 @@ void AnnotFileAttachment::initialize(XRef *xrefA, Catalog *catalog, Dict* dict)
if (dict->lookup("FS", &obj1)->isDict() || dict->lookup("FS", &obj1)->isString()) {
obj1.copy(&file);
} else {
error(-1, "Bad Annot File Attachment");
error(errSyntaxError, -1, "Bad Annot File Attachment");
ok = gFalse;
}
obj1.free();
......@@ -4815,7 +4815,7 @@ void AnnotSound::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
sound = Sound::parseSound(dict->lookup("Sound", &obj1));
if (!sound) {
error(-1, "Bad Annot Sound");
error(errSyntaxError, -1, "Bad Annot Sound");
ok = gFalse;
}
obj1.free();
......
......@@ -322,7 +322,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
dfp = globalParams->getDisplayFont(gfxFont);
}
if (!dfp) {
error(-1, "Couldn't find a font for '%s'",
error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
goto err2;
......@@ -353,7 +353,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
id,
fontsrc,
(const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
error(-1, "Couldn't create a font for '%s'",
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
goto err2;
......@@ -364,7 +364,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
id,
fontsrc,
(const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
error(-1, "Couldn't create a font for '%s'",
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
goto err2;
......@@ -375,7 +375,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
id,
fontsrc,
(const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
error(-1, "Couldn't create a font for '%s'",
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
goto err2;
......@@ -399,7 +399,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
id,
fontsrc,
codeToGID, n))) {
error(-1, "Couldn't create a font for '%s'",
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
goto err2;
......@@ -410,7 +410,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
if (!(fontFile = m_fontEngine->loadCIDFont(
id,
fontsrc))) {
error(-1, "Couldn't create a font for '%s'",
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
goto err2;
......@@ -420,7 +420,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont(
id,
fontsrc))) {
error(-1, "Couldn't create a font for '%s'",
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
goto err2;
......@@ -451,7 +451,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
id,
fontsrc,
codeToGID, n, faceIndex))) {
error(-1, "Couldn't create a font for '%s'",
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
goto err2;
......
......@@ -85,8 +85,8 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA,
return new CMap(collectionA->copy(), cMapNameA->copy(), 1);
}
error(-1, "Couldn't find '%s' CMap file for '%s' collection",
cMapNameA->getCString(), collectionA->getCString());
error(errSyntaxError, -1, "Couldn't find '{0:t}' CMap file for '{1:t}' collection",
cMapNameA, collectionA);
return NULL;
}
pst = new PSTokenizer(&getCharFromFile, f);
......@@ -111,7 +111,7 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA,
}
if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
!strcmp(tok2, "endcodespacerange")) {
error(-1, "Illegal entry in codespacerange block in CMap");
error(errSyntaxError, -1, "Illegal entry in codespacerange block in CMap");
break;
}
if (tok1[0] == '<' && tok2[0] == '<' &&
......@@ -131,17 +131,17 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA,
}
if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
!strcmp(tok2, "endcidchar")) {
error(-1, "Illegal entry in cidchar block in CMap");
error(errSyntaxError, -1, "Illegal entry in cidchar block in CMap");
break;
}
if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
n1 >= 4 && (n1 & 1) == 0)) {
error(-1, "Illegal entry in cidchar block in CMap");
error(errSyntaxError, -1, "Illegal entry in cidchar block in CMap");
continue;
}
tok1[n1 - 1] = '\0';
if (sscanf(tok1 + 1, "%x", &code) != 1) {
error(-1, "Illegal entry in cidchar block in CMap");
error(errSyntaxError, -1, "Illegal entry in cidchar block in CMap");
continue;
}
n1 = (n1 - 2) / 2;
......@@ -157,7 +157,7 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA,
!strcmp(tok2, "endcidrange") ||
!pst->getToken(tok3, sizeof(tok3), &n3) ||
!strcmp(tok3, "endcidrange")) {
error(-1, "Illegal entry in cidrange block in CMap");
error(errSyntaxError, -1, "Illegal entry in cidrange block in CMap");
break;
}
if (tok1[0] == '<' && tok2[0] == '<' &&
......@@ -242,7 +242,7 @@ void CMap::copyVector(CMapVectorEntry *dest, CMapVectorEntry *src) {
copyVector(dest[i].vector, src[i].vector);
} else {
if (dest[i].isVector) {
error(-1, "Collision in usecmap");
error(errSyntaxError, -1, "Collision in usecmap");
} else {
dest[i].cid = src[i].cid;
}
......@@ -285,8 +285,9 @@ void CMap::addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID) {
for (i = nBytes - 1; i >= 1; --i) {
byte = (start >> (8 * i)) & 0xff;
if (!vec[byte].isVector) {
error(-1, "Invalid CID (%0*x - %0*x) in CMap",
2*nBytes, start, 2*nBytes, end);
error(errSyntaxError, -1,
"Invalid CID ({0:x} - {1:x} [{2:d} bytes]) in CMap",
start, end, nBytes);
return;
}
vec = vec[byte].vector;
......@@ -294,8 +295,9 @@ void CMap::addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID) {
cid = firstCID;
for (byte = (int)(start & 0xff); byte <= (int)(end & 0xff); ++byte) {
if (vec[byte].isVector) {
error(-1, "Invalid CID (%0*x - %0*x) in CMap",
2*nBytes, start, 2*nBytes, end);
error(errSyntaxError, -1,
"Invalid CID ({0:x} - {1:x} [{2:d} bytes]) in CMap",
start, end, nBytes);
} else {
vec[byte].cid = cid;
}
......
......@@ -33,7 +33,7 @@ CachedFile::CachedFile(CachedFileLoader *cachedFileLoaderA, GooString *uriA)
chunks->resize(length/CachedFileChunkSize + 1);
}
else {
error(-1, "Failed to initialize file cache for '%s'.", uri->getCString());
error(errInternal, -1, "Failed to initialize file cache for '{0:t}'.", uri);
chunks->resize(0);
}
}
......
......@@ -425,7 +425,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
dfp = globalParams->getDisplayFont(gfxFont);
}
if (!dfp) {
error(-1, "Couldn't find a font for '%s'",
error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)");
goto err2;
......@@ -452,7 +452,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
case fontType1C:
case fontType1COT:
if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) {
error(-1, "could not create type1 face");
error(errSyntaxError, -1, "could not create type1 face");
goto err2;
}
......@@ -498,7 +498,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
ff = FoFiTrueType::load(fileNameC);
}
if (! ff) {
error(-1, "failed to load truetype font\n");
error(errSyntaxError, -1, "failed to load truetype font\n");
goto err2;
}
/* This might be set already for the CIDType2 case */
......@@ -508,7 +508,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
}
delete ff;
if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) {
error(-1, "could not create truetype face\n");
error(errSyntaxError, -1, "could not create truetype face\n");
goto err2;
}
break;
......@@ -535,7 +535,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) {
gfree(codeToGID);
codeToGID = NULL;
error(-1, "could not create cid face\n");
error(errSyntaxError, -1, "could not create cid face\n");
goto err2;
}
break;
......
......@@ -87,7 +87,7 @@ Catalog::Catalog(XRef *xrefA) {
xref->getCatalog(&catDict);
if (!catDict.isDict()) {
error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
goto err1;
}
// get the AcroForm dictionary
......@@ -186,7 +186,7 @@ GooString *Catalog::readMetadata() {
if (catDict.isDict()) {
catDict.dictLookup("Metadata", &metadata);
} else {
error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
metadata.initNull();
}
catDict.free();
......@@ -197,7 +197,7 @@ GooString *Catalog::readMetadata() {
}
dict = metadata.streamGetDict();
if (!dict->lookup("Subtype", &obj)->isName("XML")) {
error(-1, "Unknown Metadata type: '%s'",
error(errSyntaxWarning, -1, "Unknown Metadata type: '{0:s}'",
obj.isName() ? obj.getName() : "???");
}
obj.free();
......@@ -246,13 +246,13 @@ GBool Catalog::cachePageTree(int page)
pagesRef = pagesDictRef.getRef();
pagesDictRef.free();
} else {
error(-1, "Catalog dictionary does not contain a valid \"Pages\" entry");
error(errSyntaxError, -1, "Catalog dictionary does not contain a valid \"Pages\" entry");
pagesDictRef.free();
catDict.free();
return gFalse;
}
} else {
error(-1, "Could not find catalog dictionary");
error(errSyntaxError, -1, "Could not find catalog dictionary");
catDict.free();
return gFalse;
}
......@@ -268,7 +268,7 @@ GBool Catalog::cachePageTree(int page)
obj.free();
}
else {
error(-1, "Top-level pages object is wrong type (%s)", obj.getTypeName());
error(errSyntaxError, -1, "Top-level pages object is wrong type ({0:s})", obj.getTypeName());
obj.free();
return gFalse;
}
......@@ -304,7 +304,7 @@ GBool Catalog::cachePageTree(int page)
Object kids;
pagesDict->lookup("Kids", &kids);
if (!kids.isArray()) {
error(-1, "Kids object (page %d) is wrong type (%s)",
error(errSyntaxError, -1, "Kids object (page {0:d}) is wrong type ({1:s})",
lastCachedPage+1, kids.getTypeName());
kids.free();
return gFalse;
......@@ -328,7 +328,7 @@ GBool Catalog::cachePageTree(int page)
Object kidRef;
kids.arrayGetNF(kidsIdx, &kidRef);
if (!kidRef.isRef()) {
error(-1, "Kid object (page %d) is not an indirect reference (%s)",
error(errSyntaxError, -1, "Kid object (page {0:d}) is not an indirect reference ({1:s})",
lastCachedPage+1, kidRef.getTypeName());
kidRef.free();
kids.free();
......@@ -343,7 +343,7 @@ GBool Catalog::cachePageTree(int page)
}
}
if (loop) {
error(-1, "Loop in Pages tree");
error(errSyntaxError, -1, "Loop in Pages tree");
kidRef.free();
kids.free();
kidsIdxList->back()++;
......@@ -358,7 +358,7 @@ GBool Catalog::cachePageTree(int page)
Page *p = new Page(xref, lastCachedPage+1, kid.getDict(),
kidRef.getRef(), attrs, form);
if (!p->isOk()) {
error(-1, "Failed to create page (page %d)", lastCachedPage+1);
error(errSyntaxError, -1, "Failed to create page (page {0:d})", lastCachedPage+1);
delete p;
kidRef.free();
kid.free();
......@@ -366,7 +366,7 @@ GBool Catalog::cachePageTree(int page)
}
if (lastCachedPage >= numPages) {
error(-1, "Page count in top-level pages object is incorrect");
error(errSyntaxError, -1, "Page count in top-level pages object is incorrect");
kidRef.free();
kid.free();
return gFalse;
......@@ -388,7 +388,7 @@ GBool Catalog::cachePageTree(int page)
pagesList->push_back(kid.getDict());
kidsIdxList->push_back(0);
} else {
error(-1, "Kid object (page %d) is wrong type (%s)",
error(errSyntaxError, -1, "Kid object (page {0:d}) is wrong type ({1:s})",
lastCachedPage+1, kid.getTypeName());
kidsIdxList->back()++;
}
......@@ -441,10 +441,10 @@ LinkDest *Catalog::findDest(GooString *name) {
if (obj1.dictLookup("D", &obj2)->isArray())
dest = new LinkDest(obj2.getArray());
else
error(-1, "Bad named destination value");
error(errSyntaxWarning, -1, "Bad named destination value");
obj2.free();
} else {
error(-1, "Bad named destination value");
error(errSyntaxWarning, -1, "Bad named destination value");
}
obj1.free();
if (dest && !dest->isOk()) {
......@@ -520,7 +520,7 @@ Catalog::PageMode Catalog::getPageMode() {
xref->getCatalog(&catDict);
if (!catDict.isDict()) {
error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
catDict.free();
return pageMode;
}
......@@ -555,7 +555,7 @@ Catalog::PageLayout Catalog::getPageLayout() {
xref->getCatalog(&catDict);
if (!catDict.isDict()) {
error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
catDict.free();
return pageLayout;
}
......@@ -607,7 +607,7 @@ NameTree::Entry::Entry(Array *array, int index) {
name.append(aux.getString());
}
else
error(-1, "Invalid page tree");
error(errSyntaxError, -1, "Invalid page tree");
}
}
......@@ -752,7 +752,7 @@ int Catalog::getNumPages()
xref->getCatalog(&catDict);
if (!catDict.isDict()) {
error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
catDict.free();
return 0;
}
......@@ -762,7 +762,7 @@ int Catalog::getNumPages()
// This should really be isDict("Pages"), but I've seen at least one
// PDF file where the /Type entry is missing.
if (!pagesDict.isDict()) {
error(-1, "Top-level pages object is wrong type (%s)",
error(errSyntaxError, -1, "Top-level pages object is wrong type ({0:s})",
pagesDict.getTypeName());
pagesDict.free();
return 0;
......@@ -771,7 +771,7 @@ int Catalog::getNumPages()
pagesDict.dictLookup("Count", &obj);
// some PDF files actually use real numbers here ("/Count 9.0")
if (!obj.isNum()) {
error(-1, "Page count in top-level pages object is wrong type (%s)",
error(errSyntaxError, -1, "Page count in top-level pages object is wrong type ({0:s})",
obj.getTypeName());
numPages = 0;
} else {
......@@ -793,7 +793,7 @@ PageLabelInfo *Catalog::getPageLabelInfo()
xref->getCatalog(&catDict);
if (!catDict.isDict()) {
error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
catDict.free();
return NULL;
}
......@@ -818,7 +818,7 @@ Object *Catalog::getStructTreeRoot()
if (catDict.isDict()) {
catDict.dictLookup("StructTreeRoot", &structTreeRoot);
} else {
error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
structTreeRoot.initNull();
}
catDict.free();
......@@ -837,7 +837,7 @@ Object *Catalog::getOutline()
if (catDict.isDict()) {
catDict.dictLookup("Outlines", &outline);
} else {
error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
outline.initNull();
}
catDict.free();
......@@ -856,7 +856,7 @@ Object *Catalog::getDests()
if (catDict.isDict()) {
catDict.dictLookup("Dests", &dests);
} else {
error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
dests.initNull();
}
catDict.free();
......@@ -897,7 +897,7 @@ Object *Catalog::getNames()
if (catDict.isDict()) {
catDict.dictLookup("Names", &names);
} else {
error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
error(errSyntaxError, -1, "Catalog object is wrong type ({0:s})", catDict.getTypeName());
names.initNull();
}
catDict.free();
......
......@@ -83,8 +83,8 @@ CharCodeToUnicode *CharCodeToUnicode::parseCIDToUnicode(GooString *fileName,
CharCodeToUnicode *ctu;
if (!(f = fopen(fileName->getCString(), "r"))) {