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) { ...@@ -55,22 +55,22 @@ char *FoFiBase::readFile(char *fileName, int *fileLen) {
int n; int n;
if (!(f = fopen(fileName, "rb"))) { if (!(f = fopen(fileName, "rb"))) {
error(-1, "Cannot open '%s'", fileName); error(errIO, -1, "Cannot open '{0:s}'", fileName);
return NULL; return NULL;
} }
if (fseek(f, 0, SEEK_END) != 0) { 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); fclose(f);
return NULL; return NULL;
} }
n = (int)ftell(f); n = (int)ftell(f);
if (n < 0) { if (n < 0) {
error(-1, "Cannot determine length of '%s'", fileName); error(errIO, -1, "Cannot determine length of '{0:s}'", fileName);
fclose(f); fclose(f);
return NULL; return NULL;
} }
if (fseek(f, 0, SEEK_SET) != 0) { 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); fclose(f);
return NULL; return NULL;
} }
......
...@@ -1976,7 +1976,7 @@ void FoFiTrueType::parse() { ...@@ -1976,7 +1976,7 @@ void FoFiTrueType::parse() {
tables[i].offset + tables[i].len > len) { tables[i].offset + tables[i].len > len) {
i--; i--;
wrongTables++; 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; pos += 16;
} }
......
...@@ -224,7 +224,7 @@ void FoFiType1::parse() { ...@@ -224,7 +224,7 @@ void FoFiType1::parse() {
j < 300 && line && (line1 = getNextLine(line)); j < 300 && line && (line1 = getNextLine(line));
++j, line = line1) { ++j, line = line1) {
if ((n = line1 - line) > 255) { 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; n = 255;
} }
strncpy(buf, line, n); strncpy(buf, line, n);
...@@ -267,7 +267,7 @@ void FoFiType1::parse() { ...@@ -267,7 +267,7 @@ void FoFiType1::parse() {
line1 = &line[p - buf]; line1 = &line[p - buf];
} }
} else { } 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) ...@@ -25,7 +25,7 @@ void outputMessage(j_common_ptr cinfo)
(*cinfo->err->format_message) (cinfo, buffer); (*cinfo->err->format_message) (cinfo, buffer);
// Send it to poppler's error handler // 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) 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) ...@@ -59,25 +59,25 @@ bool PNGWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
/* initialize stuff */ /* initialize stuff */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) { if (!png_ptr) {
error(-1, "png_create_write_struct failed"); error(errInternal, -1, "png_create_write_struct failed");
return false; return false;
} }
info_ptr = png_create_info_struct(png_ptr); info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) { if (!info_ptr) {
error(-1, "png_create_info_struct failed"); error(errInternal, -1, "png_create_info_struct failed");
return false; return false;
} }
if (setjmp(png_jmpbuf(png_ptr))) { if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "png_jmpbuf failed"); error(errInternal, -1, "png_jmpbuf failed");
return false; return false;
} }
/* write header */ /* write header */
png_init_io(png_ptr, f); png_init_io(png_ptr, f);
if (setjmp(png_jmpbuf(png_ptr))) { if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "Error during writing header"); error(errInternal, -1, "Error during writing header");
return false; return false;
} }
...@@ -118,7 +118,7 @@ bool PNGWriter::init(FILE *f, int width, int height, int hDPI, int vDPI) ...@@ -118,7 +118,7 @@ bool PNGWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
png_write_info(png_ptr, info_ptr); png_write_info(png_ptr, info_ptr);
if (setjmp(png_jmpbuf(png_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; return false;
} }
...@@ -134,7 +134,7 @@ bool PNGWriter::writePointers(unsigned char **rowPointers, int rowCount) ...@@ -134,7 +134,7 @@ bool PNGWriter::writePointers(unsigned char **rowPointers, int rowCount)
png_write_image(png_ptr, rowPointers); png_write_image(png_ptr, rowPointers);
/* write bytes */ /* write bytes */
if (setjmp(png_jmpbuf(png_ptr))) { if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "Error during writing bytes"); error(errInternal, -1, "Error during writing bytes");
return false; return false;
} }
...@@ -146,7 +146,7 @@ bool PNGWriter::writeRow(unsigned char **row) ...@@ -146,7 +146,7 @@ bool PNGWriter::writeRow(unsigned char **row)
// Write the row to the file // Write the row to the file
png_write_rows(png_ptr, row, 1); png_write_rows(png_ptr, row, 1);
if (setjmp(png_jmpbuf(png_ptr))) { if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "error during png row write"); error(errInternal, -1, "error during png row write");
return false; return false;
} }
...@@ -158,7 +158,7 @@ bool PNGWriter::close() ...@@ -158,7 +158,7 @@ bool PNGWriter::close()
/* end write */ /* end write */
png_write_end(png_ptr, info_ptr); png_write_end(png_ptr, info_ptr);
if (setjmp(png_jmpbuf(png_ptr))) { if (setjmp(png_jmpbuf(png_ptr))) {
error(-1, "Error during end of write"); error(errInternal, -1, "Error during end of write");
return false; return false;
} }
......
...@@ -251,7 +251,7 @@ void AnnotPath::parsePathArray(Array *array) { ...@@ -251,7 +251,7 @@ void AnnotPath::parsePathArray(Array *array) {
GBool correct = gTrue; GBool correct = gTrue;
if (array->getLength() % 2) { if (array->getLength() % 2) {
error(-1, "Bad Annot Path"); error(errSyntaxError, -1, "Bad Annot Path");
return; return;
} }
...@@ -341,7 +341,7 @@ AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) { ...@@ -341,7 +341,7 @@ AnnotQuadrilaterals::AnnotQuadrilaterals(Array *array, PDFRectangle *rect) {
} else { } else {
correct = gFalse; correct = gFalse;
obj.free(); obj.free();
error (-1, "Invalid QuadPoint in annot"); error (errSyntaxError, -1, "Invalid QuadPoint in annot");
break; break;
} }
obj.free(); obj.free();
...@@ -895,7 +895,7 @@ void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) { ...@@ -895,7 +895,7 @@ void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) {
} else { } else {
rect->x1 = rect->y1 = 0; rect->x1 = rect->y1 = 0;
rect->x2 = rect->y2 = 1; rect->x2 = rect->y2 = 1;
error(-1, "Bad bounding box for annotation"); error(errSyntaxError, -1, "Bad bounding box for annotation");
ok = gFalse; ok = gFalse;
} }
obj1.free(); obj1.free();
...@@ -1005,7 +1005,7 @@ void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) { ...@@ -1005,7 +1005,7 @@ void Annot::initialize(XRef *xrefA, Dict *dict, Catalog *catalog) {
optContentConfig = catalog ? catalog->getOptContentConfig() : NULL; optContentConfig = catalog ? catalog->getOptContentConfig() : NULL;
dict->lookupNF("OC", &oc); dict->lookupNF("OC", &oc);
if (!oc.isRef() && !oc.isNull()) { 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) { ...@@ -2133,7 +2133,7 @@ void AnnotFreeText::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) {
appearanceString = obj1.getString()->copy(); appearanceString = obj1.getString()->copy();
} else { } else {
appearanceString = new GooString(); appearanceString = new GooString();
error(-1, "Bad appearance for annotation"); error(errSyntaxError, -1, "Bad appearance for annotation");
ok = gFalse; ok = gFalse;
} }
obj1.free(); obj1.free();
...@@ -2545,7 +2545,7 @@ void AnnotTextMarkup::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) { ...@@ -2545,7 +2545,7 @@ void AnnotTextMarkup::initialize(XRef *xrefA, Catalog *catalog, Dict *dict) {
if(dict->lookup("QuadPoints", &obj1)->isArray()) { if(dict->lookup("QuadPoints", &obj1)->isArray()) {
quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect); quadrilaterals = new AnnotQuadrilaterals(obj1.getArray(), rect);
} else { } else {
error(-1, "Bad Annot Text Markup QuadPoints"); error(errSyntaxError, -1, "Bad Annot Text Markup QuadPoints");
quadrilaterals = NULL; quadrilaterals = NULL;
ok = gFalse; ok = gFalse;
} }
...@@ -2815,7 +2815,7 @@ void AnnotWidget::layoutText(GooString *text, GooString *outBuf, int *i, ...@@ -2815,7 +2815,7 @@ void AnnotWidget::layoutText(GooString *text, GooString *outBuf, int *i,
int last_i1, last_i2, last_o1, last_o2; int last_i1, last_i2, last_o1, last_o2;
if (unicode && text->getLength() % 2 != 0) { if (unicode && text->getLength() % 2 != 0) {
error(-1, "AnnotWidget::layoutText, bad unicode string"); error(errSyntaxError, -1, "AnnotWidget::layoutText, bad unicode string");
return; return;
} }
...@@ -3083,16 +3083,16 @@ void AnnotWidget::drawText(GooString *text, GooString *da, GfxResources *resourc ...@@ -3083,16 +3083,16 @@ void AnnotWidget::drawText(GooString *text, GooString *da, GfxResources *resourc
freeFont = gTrue; freeFont = gTrue;
addDingbatsResource = gTrue; addDingbatsResource = gTrue;
} else { } else {
error(-1, "Unknown font in field's DA string"); error(errSyntaxError, -1, "Unknown font in field's DA string");
} }
} }
} else { } 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); tok = (GooString *)daToks->get(tfPos + 1);
fontSize = gatof(tok->getCString()); fontSize = gatof(tok->getCString());
} else { } 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 (!font) {
if (daToks) { if (daToks) {
...@@ -3442,15 +3442,15 @@ void AnnotWidget::drawListBox(FormFieldChoice *fieldChoice, ...@@ -3442,15 +3442,15 @@ void AnnotWidget::drawListBox(FormFieldChoice *fieldChoice,
tok = (GooString *)daToks->get(tfPos); tok = (GooString *)daToks->get(tfPos);
if (tok->getLength() >= 1 && tok->getChar(0) == '/') { if (tok->getLength() >= 1 && tok->getChar(0) == '/') {
if (!resources || !(font = resources->lookupFont(tok->getCString() + 1))) { 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 { } 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); tok = (GooString *)daToks->get(tfPos + 1);
fontSize = gatof(tok->getCString()); fontSize = gatof(tok->getCString());
} else { } 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 (!font) {
if (daToks) { if (daToks) {
...@@ -3794,7 +3794,7 @@ void AnnotWidget::generateFieldAppearance() { ...@@ -3794,7 +3794,7 @@ void AnnotWidget::generateFieldAppearance() {
break; break;
case formUndef: case formUndef:
default: default:
error(-1, "Unknown field type"); error(errSyntaxError, -1, "Unknown field type");
} }
// build the appearance stream dictionary // build the appearance stream dictionary
...@@ -3935,7 +3935,7 @@ void AnnotMovie::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { ...@@ -3935,7 +3935,7 @@ void AnnotMovie::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
} }
obj2.free(); obj2.free();
} else { } else {
error(-1, "Bad Annot Movie"); error(errSyntaxError, -1, "Bad Annot Movie");
movie = NULL; movie = NULL;
ok = gFalse; ok = gFalse;
} }
...@@ -4076,7 +4076,7 @@ void AnnotScreen::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { ...@@ -4076,7 +4076,7 @@ void AnnotScreen::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
if (dict->lookup("A", &obj1)->isDict()) { if (dict->lookup("A", &obj1)->isDict()) {
action = LinkAction::parseAction(&obj1, catalog->getBaseURI()); action = LinkAction::parseAction(&obj1, catalog->getBaseURI());
if (action->getKind() == actionRendition && page == 0) { 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; delete action;
action = NULL; action = NULL;
ok = gFalse; ok = gFalse;
...@@ -4391,7 +4391,7 @@ void AnnotPolygon::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { ...@@ -4391,7 +4391,7 @@ void AnnotPolygon::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
vertices = new AnnotPath(obj1.getArray()); vertices = new AnnotPath(obj1.getArray());
} else { } else {
vertices = new AnnotPath(); vertices = new AnnotPath();
error(-1, "Bad Annot Polygon Vertices"); error(errSyntaxError, -1, "Bad Annot Polygon Vertices");
ok = gFalse; ok = gFalse;
} }
obj1.free(); obj1.free();
...@@ -4557,7 +4557,7 @@ void AnnotInk::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { ...@@ -4557,7 +4557,7 @@ void AnnotInk::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
} else { } else {
inkListLength = 0; inkListLength = 0;
inkList = NULL; inkList = NULL;
error(-1, "Bad Annot Ink List"); error(errSyntaxError, -1, "Bad Annot Ink List");
ok = gFalse; ok = gFalse;
} }
obj1.free(); obj1.free();
...@@ -4600,7 +4600,7 @@ void AnnotFileAttachment::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) ...@@ -4600,7 +4600,7 @@ void AnnotFileAttachment::initialize(XRef *xrefA, Catalog *catalog, Dict* dict)
if (dict->lookup("FS", &obj1)->isDict() || dict->lookup("FS", &obj1)->isString()) { if (dict->lookup("FS", &obj1)->isDict() || dict->lookup("FS", &obj1)->isString()) {
obj1.copy(&file); obj1.copy(&file);
} else { } else {
error(-1, "Bad Annot File Attachment"); error(errSyntaxError, -1, "Bad Annot File Attachment");
ok = gFalse; ok = gFalse;
} }
obj1.free(); obj1.free();
...@@ -4815,7 +4815,7 @@ void AnnotSound::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) { ...@@ -4815,7 +4815,7 @@ void AnnotSound::initialize(XRef *xrefA, Catalog *catalog, Dict* dict) {
sound = Sound::parseSound(dict->lookup("Sound", &obj1)); sound = Sound::parseSound(dict->lookup("Sound", &obj1));
if (!sound) { if (!sound) {
error(-1, "Bad Annot Sound"); error(errSyntaxError, -1, "Bad Annot Sound");
ok = gFalse; ok = gFalse;
} }
obj1.free(); obj1.free();
......
...@@ -322,7 +322,7 @@ void ArthurOutputDev::updateFont(GfxState *state) ...@@ -322,7 +322,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
dfp = globalParams->getDisplayFont(gfxFont); dfp = globalParams->getDisplayFont(gfxFont);
} }
if (!dfp) { 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() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
goto err2; goto err2;
...@@ -353,7 +353,7 @@ void ArthurOutputDev::updateFont(GfxState *state) ...@@ -353,7 +353,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
id, id,
fontsrc, fontsrc,
(const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { (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() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
goto err2; goto err2;
...@@ -364,7 +364,7 @@ void ArthurOutputDev::updateFont(GfxState *state) ...@@ -364,7 +364,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
id, id,
fontsrc, fontsrc,
(const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { (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() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
goto err2; goto err2;
...@@ -375,7 +375,7 @@ void ArthurOutputDev::updateFont(GfxState *state) ...@@ -375,7 +375,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
id, id,
fontsrc, fontsrc,
(const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) { (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() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
goto err2; goto err2;
...@@ -399,7 +399,7 @@ void ArthurOutputDev::updateFont(GfxState *state) ...@@ -399,7 +399,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
id, id,
fontsrc, fontsrc,
codeToGID, n))) { 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() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
goto err2; goto err2;
...@@ -410,7 +410,7 @@ void ArthurOutputDev::updateFont(GfxState *state) ...@@ -410,7 +410,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
if (!(fontFile = m_fontEngine->loadCIDFont( if (!(fontFile = m_fontEngine->loadCIDFont(
id, id,
fontsrc))) { 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() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
goto err2; goto err2;
...@@ -420,7 +420,7 @@ void ArthurOutputDev::updateFont(GfxState *state) ...@@ -420,7 +420,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont( if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont(
id, id,
fontsrc))) { 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() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
goto err2; goto err2;
...@@ -451,7 +451,7 @@ void ArthurOutputDev::updateFont(GfxState *state) ...@@ -451,7 +451,7 @@ void ArthurOutputDev::updateFont(GfxState *state)
id, id,
fontsrc, fontsrc,
codeToGID, n, faceIndex))) { 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() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
goto err2; goto err2;
......
...@@ -85,8 +85,8 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA, ...@@ -85,8 +85,8 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA,
return new CMap(collectionA->copy(), cMapNameA->copy(), 1); return new CMap(collectionA->copy(), cMapNameA->copy(), 1);
} }
error(-1, "Couldn't find '%s' CMap file for '%s' collection", error(errSyntaxError, -1, "Couldn't find '{0:t}' CMap file for '{1:t}' collection",
cMapNameA->getCString(), collectionA->getCString()); cMapNameA, collectionA);
return NULL; return NULL;
} }
pst = new PSTokenizer(&getCharFromFile, f); pst = new PSTokenizer(&getCharFromFile, f);
...@@ -111,7 +111,7 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA, ...@@ -111,7 +111,7 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA,
} }
if (!pst->getToken(tok2, sizeof(tok2), &n2) || if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
!strcmp(tok2, "endcodespacerange")) { !strcmp(tok2, "endcodespacerange")) {
error(-1, "Illegal entry in codespacerange block in CMap"); error(errSyntaxError, -1, "Illegal entry in codespacerange block in CMap");
break; break;
} }
if (tok1[0] == '<' && tok2[0] == '<' && if (tok1[0] == '<' && tok2[0] == '<' &&
...@@ -131,17 +131,17 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA, ...@@ -131,17 +131,17 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA,
} }
if (!pst->getToken(tok2, sizeof(tok2), &n2) || if (!pst->getToken(tok2, sizeof(tok2), &n2) ||
!strcmp(tok2, "endcidchar")) { !strcmp(tok2, "endcidchar")) {
error(-1, "Illegal entry in cidchar block in CMap"); error(errSyntaxError, -1, "Illegal entry in cidchar block in CMap");
break; break;
} }
if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' && if (!(tok1[0] == '<' && tok1[n1 - 1] == '>' &&
n1 >= 4 && (n1 & 1) == 0)) { 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; continue;
} }
tok1[n1 - 1] = '\0'; tok1[n1 - 1] = '\0';
if (sscanf(tok1 + 1, "%x", &code) != 1) { 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; continue;
} }
n1 = (n1 - 2) / 2; n1 = (n1 - 2) / 2;
...@@ -157,7 +157,7 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA, ...@@ -157,7 +157,7 @@ CMap *CMap::parse(CMapCache *cache, GooString *collectionA,
!strcmp(tok2, "endcidrange") || !strcmp(tok2, "endcidrange") ||
!pst->getToken(tok3, sizeof(tok3), &n3) || !pst->getToken(tok3, sizeof(tok3), &n3) ||
!strcmp(tok3, "endcidrange")) { !strcmp(tok3, "endcidrange")) {
error(-1, "Illegal entry in cidrange block in CMap"); error(errSyntaxError, -1, "Illegal entry in cidrange block in CMap");
break; break;
} }
if (tok1[0] == '<' && tok2[0] == '<' && if (tok1[0] == '<' && tok2[0] == '<' &&
...@@ -242,7 +242,7 @@ void CMap::copyVector(CMapVectorEntry *dest, CMapVectorEntry *src) { ...@@ -242,7 +242,7 @@ void CMap::copyVector(CMapVectorEntry *dest, CMapVectorEntry *src) {
copyVector(dest[i].vector, src[i].vector); copyVector(dest[i].vector, src[i].vector);
} else { } else {
if (dest[i].isVector) { if (dest[i].isVector) {
error(-1, "Collision in usecmap"); error(errSyntaxError, -1, "Collision in usecmap");
} else { } else {
dest[i].cid = src[i].cid; dest[i].cid = src[i].cid;
} }
...@@ -285,8 +285,9 @@ void CMap::addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID) { ...@@ -285,8 +285,9 @@ void CMap::addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID) {
for (i = nBytes - 1; i >= 1; --i) { for (i = nBytes - 1; i >= 1; --i) {
byte = (start >> (8 * i)) & 0xff; byte = (start >> (8 * i)) & 0xff;
if (!vec[byte].isVector) { if (!vec[byte].isVector) {
error(-1, "Invalid CID (%0*x - %0*x) in CMap", error(errSyntaxError, -1,
2*nBytes, start, 2*nBytes, end); "Invalid CID ({0:x} - {1:x} [{2:d} bytes]) in CMap",
start, end, nBytes);
return; return;
} }
vec = vec[byte].vector; vec = vec[byte].vector;
...@@ -294,8 +295,9 @@ void CMap::addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID) { ...@@ -294,8 +295,9 @@ void CMap::addCIDs(Guint start, Guint end, Guint nBytes, CID firstCID) {
cid = firstCID; cid = firstCID;
for (byte = (int)(start & 0xff); byte <= (int)(end & 0xff); ++byte) { for (byte = (int)(start & 0xff); byte <= (int)(end & 0xff); ++byte) {
if (vec[byte].isVector) { if (vec[byte].isVector) {
error(-1, "Invalid CID (%0*x - %0*x) in CMap", error(errSyntaxError, -1,
2*nBytes, start, 2*nBytes, end); "Invalid CID ({0:x} - {1:x} [{2:d} bytes]) in CMap",
start, end, nBytes);
} else { } else {
vec[byte].cid = cid; vec[byte].cid = cid;
} }
......
...@@ -33,7 +33,7 @@ CachedFile::CachedFile(CachedFileLoader *cachedFileLoaderA, GooString *uriA) ...@@ -33,7 +33,7 @@ CachedFile::CachedFile(CachedFileLoader *cachedFileLoaderA, GooString *uriA)
chunks->resize(length/CachedFileChunkSize + 1); chunks->resize(length/CachedFileChunkSize + 1);
} }
else { 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); chunks->resize(0);
} }
} }
......
...@@ -425,7 +425,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, ...@@ -425,7 +425,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
dfp = globalParams->getDisplayFont(gfxFont); dfp = globalParams->getDisplayFont(gfxFont);
} }
if (!dfp) { 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() gfxFont->getName() ? gfxFont->getName()->getCString()
: "(unnamed)"); : "(unnamed)");
goto err2; goto err2;
...@@ -452,7 +452,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, ...@@ -452,7 +452,7 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref,
case fontType1C: case fontType1C:
case fontType1COT: case fontType1COT:
if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) { if (! _ft_new_face (lib, fileNameC, font_data, font_data_len, &face, &font_face)) {
error(-1, "could not create type1 face");