+2008-09-28 Carlos Garcia Campos <carlosgc@gnome.org>
+
+ * backend/dvi/mdvi-lib/common.h:
+ * backend/dvi/mdvi-lib/dviread.c:
+ * backend/dvi/mdvi-lib/font.c:
+ * backend/dvi/mdvi-lib/fontmap.c:
+ * backend/dvi/mdvi-lib/fontsrch.c:
+ * backend/dvi/mdvi-lib/gf.c:
+ * backend/dvi/mdvi-lib/pagesel.c:
+ * backend/dvi/mdvi-lib/pk.c:
+ * backend/dvi/mdvi-lib/sp-epsf.c:
+ * backend/dvi/mdvi-lib/special.c:
+ * backend/dvi/mdvi-lib/tfm.c:
+ * backend/dvi/mdvi-lib/tfmfile.c:
+ * backend/dvi/mdvi-lib/util.c:
+ * backend/dvi/mdvi-lib/vf.c:
+
+ Rename error as mdvi_error to avoid symbol conflicts with the libc
+ error. Rename also message, crash, fatal and warning for
+ consistency. Fixes bug #553369.
+
2008-09-28 Carlos Garcia Campos <carlosgc@gnome.org>
* backend/dvi/dvi-document.c: (dvi_document_load):
/* miscellaneous */
-extern void message __PROTO((const char *, ...));
-extern void crash __PROTO((const char *, ...));
-extern void fatal __PROTO((const char *, ...));
-extern void error __PROTO((const char *, ...));
-extern void warning __PROTO((const char *, ...));
+extern void mdvi_message __PROTO((const char *, ...));
+extern void mdvi_crash __PROTO((const char *, ...));
+extern void mdvi_fatal __PROTO((const char *, ...));
+extern void mdvi_error __PROTO((const char *, ...));
+extern void mdvi_warning __PROTO((const char *, ...));
extern int unit2pix __PROTO((int, const char *));
extern double unit2pix_factor __PROTO((const char *));
extern void __debug __PROTO((int, const char *, ...));
#define DEBUG(x) __debug x
#define ASSERT(x) do { \
- if(!(x)) crash("%s:%d: Assertion %s failed\n", \
+ if(!(x)) mdvi_crash("%s:%d: Assertion %s failed\n", \
__FILE__, __LINE__, #x); \
} while(0)
#define ASSERT_VALUE(x,y) do { \
if((x) != (y)) \
- crash("%s:%d: Assertion failed (%d = %s != %s)\n", \
+ mdvi_crash("%s:%d: Assertion failed (%d = %s != %s)\n", \
__FILE__, __LINE__, (x), #x, #x); \
} while(0)
#else
newlen = fread(dvi->buffer.data + dvi->buffer.length,
1, dvi->buffer.size - dvi->buffer.length, dvi->in);
if(newlen == -1) {
- error("%s: %s\n", dvi->filename, strerror(errno));
+ mdvi_error("%s: %s\n", dvi->filename, strerror(errno));
return -1;
}
dvi->buffer.length += newlen;
hdpi, vdpi));
ref = font_reference(&dvi->params, arg, name, checksum, hdpi, vdpi, scale);
if(ref == NULL) {
- error(_("could not load font `%s'\n"), name);
+ mdvi_error(_("could not load font `%s'\n"), name);
mdvi_free(name);
return NULL;
}
/* load it again */
newdvi = mdvi_init_context(pars, dvi->pagesel, dvi->filename);
if(newdvi == NULL) {
- warning(_("could not reload `%s'\n"), dvi->filename);
+ mdvi_warning(_("could not reload `%s'\n"), dvi->filename);
return -1;
}
if(fuget1(p) != DVI_PRE)
goto bad_dvi;
if((arg = fuget1(p)) != DVI_ID) {
- error(_("%s: unsupported DVI format (version %u)\n"),
- file, arg);
+ mdvi_error(_("%s: unsupported DVI format (version %u)\n"),
+ file, arg);
goto error; /* jump to the end of this routine,
* where we handle errors */
}
}
pagecount++;
if(pagecount >= dvi->npages) {
- error(_("no pages selected\n"));
+ mdvi_error(_("no pages selected\n"));
goto error;
}
if(pagecount) {
return dvi;
bad_dvi:
- error(_("%s: File corrupted, or not a DVI file\n"), file);
+ mdvi_error(_("%s: File corrupted, or not a DVI file\n"), file);
error:
/* if we came from the font definitions, this will be non-trivial */
dreset(dvi);
/* try reopening the file */
dvi->in = fopen(dvi->filename, "r");
if(dvi->in == NULL) {
- warning(_("%s: could not reopen file (%s)\n"),
- dvi->filename,
- strerror(errno));
+ mdvi_warning(_("%s: could not reopen file (%s)\n"),
+ dvi->filename,
+ strerror(errno));
return -1;
}
DEBUG((DBG_FILES, "reopen(%s) -> Ok\n", dvi->filename));
}
if(pageno < 0 || pageno > dvi->npages-1) {
- error(_("%s: page %d out of range\n"),
- dvi->filename, pageno);
+ mdvi_error(_("%s: page %d out of range\n"),
+ dvi->filename, pageno);
return -1;
}
fseek(dvi->in, (long)dvi->pagemap[pageno][0], SEEK_SET);
if((op = fuget1(dvi->in)) != DVI_BOP) {
- error(_("%s: bad offset at page %d\n"),
- dvi->filename, pageno+1);
+ mdvi_error(_("%s: bad offset at page %d\n"),
+ dvi->filename, pageno+1);
return -1;
}
font_free_unused(&dvi->device);
if(dvi->fonts == NULL) {
- warning(_("%s: no fonts defined\n"), dvi->filename);
+ mdvi_warning(_("%s: no fonts defined\n"), dvi->filename);
return;
}
map = xnalloc(DviFontRef *, dvi->nfonts);
}
if(ent->encfile && enc){
if(ent->encoding && !STREQ(ent->encoding, enc->name)) {
- warning(
+ mdvi_warning(
_("%s: %d: [%s] requested encoding `%s' does not match vector `%s'\n"),
file, lineno, ent->encfile,
ent->encoding, enc->name);
DEBUG((DBG_FMAP, "%s: loading fontmap\n", arg));
ent = mdvi_load_fontmap(arg);
if(ent == NULL)
- warning(_("%s: could not load fontmap\n"), arg);
+ mdvi_warning(_("%s: could not load fontmap\n"), arg);
else {
DEBUG((DBG_FMAP,
"%s: installing fontmap\n", arg));
} else if(STRNEQ(line, "default-encoding", 16)) {
arg = getstring(line + 16, " \t", &line); *line = 0;
if(mdvi_set_default_encoding(arg) < 0)
- warning(_("%s: could not set as default encoding\n"),
- arg);
+ mdvi_warning(_("%s: could not set as default encoding\n"),
+ arg);
} else if(STRNEQ(line, "psfontpath", 10)) {
arg = getstring(line + 11, " \t", &line); *line = 0;
if(!psinitialized)
} else if(STRNEQ(line, "psfontmap", 9)) {
arg = getstring(line + 9, " \t", &line); *line = 0;
if(mdvi_ps_read_fontmap(arg) < 0)
- warning("%s: %s: could not read PS fontmap\n",
- config, arg);
+ mdvi_warning("%s: %s: could not read PS fontmap\n",
+ config, arg);
}
}
fclose(in);
for(; (enc = (DviEncoding *)encodings.head); ) {
encodings.head = LIST(enc->next);
if((enc != tex_text_encoding && enc->links) || enc->links > 1) {
- warning(_("encoding vector `%s' is in use\n"),
- enc->name);
+ mdvi_warning(_("encoding vector `%s' is in use\n"),
+ enc->name);
}
destroy_encoding(enc);
}
}
if(kid < MAX_CLASS - 1 && !STREQ(name, _mdvi_fallback_font)) {
- warning("font `%s' at %dx%d not found, trying `%s' instead\n",
- name, hdpi, vdpi, _mdvi_fallback_font);
+ mdvi_warning("font `%s' at %dx%d not found, trying `%s' instead\n",
+ name, hdpi, vdpi, _mdvi_fallback_font);
name = _mdvi_fallback_font;
kid = 0;
goto again;
}
ptr = last->next;
} else {
- warning("font `%s' not found, trying metric files instead\n",
- name);
+ mdvi_warning("font `%s' not found, trying metric files instead\n",
+ name);
ptr = (DviFontClass *)font_classes[MAX_CLASS-1].head;
}
return filename;
}
if(!STREQ(name, _mdvi_fallback_font)) {
- warning("metric file for `%s' not found, trying `%s' instead\n",
- name, _mdvi_fallback_font);
+ mdvi_warning("metric file for `%s' not found, trying `%s' instead\n",
+ name, _mdvi_fallback_font);
name = _mdvi_fallback_font;
ptr = (DviFontClass *)font_classes[MAX_CLASS-1].head;
goto metrics;
min_m = max_m - min_m;
min_n = max_n - min_n;
} else {
- error(_("GF: invalid opcode %d in character %d\n"),
- op, ch->code);
+ mdvi_error(_("GF: invalid opcode %d in character %d\n"),
+ op, ch->code);
return -1;
}
DEBUG((DBG_BITMAPS, "(gf) no_op\n"));
break;
default:
- error(_("(gf) Character %d: invalid opcode %d\n"),
- ch->code, op);
+ mdvi_error(_("(gf) Character %d: invalid opcode %d\n"),
+ ch->code, op);
goto error;
}
/* chech that we're still inside the bitmap */
return 0;
toobig:
- error(_("(gf) character %d has an incorrect bounding box\n"),
- ch->code);
+ mdvi_error(_("(gf) character %d has an incorrect bounding box\n"),
+ ch->code);
error:
bitmap_destroy(map);
ch->glyph.data = NULL;
/* the checksum */
word = fuget4(p);
if(word && font->checksum && font->checksum != word) {
- warning(_("%s: bad checksum (expected %u, found %u)\n"),
- font->fontname, font->checksum, word);
+ mdvi_warning(_("%s: bad checksum (expected %u, found %u)\n"),
+ font->fontname, font->checksum, word);
} else if(!font->checksum)
font->checksum = word;
/* skip pixels per point ratio */
/* dy assumed 0 */
break;
default:
- error(_("%s: junk in postamble\n"), font->fontname);
+ mdvi_error(_("%s: junk in postamble\n"), font->fontname);
goto error;
}
ch->code = cc;
return 0;
badgf:
- error(_("%s: File corrupted, or not a GF file\n"), font->fontname);
+ mdvi_error(_("%s: File corrupted, or not a GF file\n"), font->fontname);
error:
if(font->chars) {
mdvi_free(font->chars);
range = mdvi_parse_range(format, NULL, &count, &ptr);
if(ptr == format) {
if(range) mdvi_free(range);
- error(_("invalid page specification `%s'\n"), format);
+ mdvi_error(_("invalid page specification `%s'\n"), format);
return NULL;
}
} else
if(*ptr != '.') {
if(*ptr)
- warning(_("garbage after DVI page specification ignored\n"));
+ mdvi_warning(_("garbage after DVI page specification ignored\n"));
return spec;
}
}
if(i > 10)
- warning(_("more than 10 counters in page specification\n"));
+ mdvi_warning(_("more than 10 counters in page specification\n"));
else if(*ptr)
- warning(_("garbage after TeX page specification ignored\n"));
+ mdvi_warning(_("garbage after TeX page specification ignored\n"));
return spec;
}
paint = !paint;
}
if(row != h || inrow != w) {
- error(_("Bad PK file: More bits than required\n"));
+ mdvi_error(_("Bad PK file: More bits than required\n"));
bitmap_destroy(bm);
return NULL;
}
/* get the checksum */
checksum = fuget4(p);
if(checksum && font->checksum && font->checksum != checksum) {
- warning(_("%s: checksum mismatch (expected %u, got %u)\n"),
- font->fontname, font->checksum, checksum);
+ mdvi_warning(_("%s: checksum mismatch (expected %u, got %u)\n"),
+ font->fontname, font->checksum, checksum);
} else if(!font->checksum)
font->checksum = checksum;
/* skip pixel per point ratios */
case PK_NOOP:
break;
case PK_PRE:
- error(_("%s: unexpected preamble\n"), font->fontname);
+ mdvi_error(_("%s: unexpected preamble\n"), font->fontname);
goto error;
}
} else {
}
}
if(flag_byte != PK_POST) {
- error(_("%s: unexpected end of file (no postamble)\n"),
- font->fontname);
+ mdvi_error(_("%s: unexpected end of file (no postamble)\n"),
+ font->fontname);
goto error;
}
while((flag_byte = fuget1(p)) != EOF) {
if(flag_byte != PK_NOOP) {
- error(_("invalid PK file! (junk in postamble)\n"));
+ mdvi_error(_("invalid PK file! (junk in postamble)\n"));
goto error;
}
}
return 0;
badpk:
- error(_("%s: File corrupted, or not a PK file\n"), font->fontname);
+ mdvi_error(_("%s: File corrupted, or not a PK file\n"), font->fontname);
error:
mdvi_free(font->chars);
font->chars = NULL;
while(*p && *p != '"')
p++;
if(*p != '"')
- warning(
+ mdvi_warning(
_("%s: malformed value for key `%s'\n"),
filename, keyname);
} else
if(STRCEQ(keys[i].name, keyname))
break;
if(i == NKEYS) {
- warning(_("%s: unknown key `%s' ignored\n"),
- filename, keyname);
+ mdvi_warning(_("%s: unknown key `%s' ignored\n"),
+ filename, keyname);
continue;
}
if(keys[i].has_arg && val == NULL) {
- warning(_("%s: no argument for key `%s', using defaults\n"),
- filename, keyname);
+ mdvi_warning(_("%s: no argument for key `%s', using defaults\n"),
+ filename, keyname);
val = keys[i].value;
} else if(!keys[i].has_arg && val) {
- warning(_("%s: argument `%s' ignored for key `%s'\n"),
- filename, val, keyname);
+ mdvi_warning(_("%s: argument `%s' ignored for key `%s'\n"),
+ filename, val, keyname);
val = NULL;
}
if(val)
if(dvi->curr_layer)
dvi->curr_layer--;
else
- warning(_("%s: tried to pop top level layer\n"),
- dvi->filename);
+ mdvi_warning(_("%s: tried to pop top level layer\n"),
+ dvi->filename);
} else if(STREQ("reset", arg))
dvi->curr_layer = 0;
DEBUG((DBG_SPECIAL, "Layer level: %d\n", dvi->curr_layer));
return -1;
if(tfm->checksum && font->checksum && tfm->checksum != font->checksum) {
- warning(_("%s: Checksum mismatch (got %u, expected %u)\n"),
- font->fontname, (unsigned)tfm->checksum,
- (unsigned)font->checksum);
+ mdvi_warning(_("%s: Checksum mismatch (got %u, expected %u)\n"),
+ font->fontname, (unsigned)tfm->checksum,
+ (unsigned)font->checksum);
}
font->checksum = tfm->checksum;
font->design = tfm->design;
fclose(in);
if(status != ok) {
- error(_("%s: Error reading AFM data\n"), filename);
+ mdvi_error(_("%s: Error reading AFM data\n"), filename);
return -1;
}
/* allocate a word-aligned buffer to hold the file */
size = 4 * ROUND(st.st_size, 4);
if(size != st.st_size)
- warning(_("Warning: TFM file `%s' has suspicious size\n"),
- filename);
+ mdvi_warning(_("Warning: TFM file `%s' has suspicious size\n"),
+ filename);
tfm = (Uchar *)mdvi_malloc(size);
if(fread(tfm, st.st_size, 1, in) != 1)
goto error;
/* get the coding scheme */
i = n = msget1(ptr);
if(n < 0 || n > 39) {
- warning(_("%s: font coding scheme truncated to 40 bytes\n"),
- filename);
+ mdvi_warning(_("%s: font coding scheme truncated to 40 bytes\n"),
+ filename);
n = 39;
}
memcpy(info->coding, ptr, n);
return 0;
bad_tfm:
- error(_("%s: File corrupted, or not a TFM file\n"), filename);
+ mdvi_error(_("%s: File corrupted, or not a TFM file\n"), filename);
error:
if(tfm) mdvi_free(tfm);
if(in) fclose(in);
/* get the coding scheme */
i = n = fsget1(in);
if(n < 0 || n > 39) {
- warning(_("%s: font coding scheme truncated to 40 bytes\n"),
- filename);
+ mdvi_warning(_("%s: font coding scheme truncated to 40 bytes\n"),
+ filename);
n = 39;
}
fread(info->coding, 39, 1, in);
return 0;
bad_tfm:
- error(_("%s: File corrupted, or not a TFM file\n"), filename);
+ mdvi_error(_("%s: File corrupted, or not a TFM file\n"), filename);
fclose(in);
return -1;
}
}
#endif
-void message(const char *format, ...)
+void mdvi_message(const char *format, ...)
{
va_list ap;
va_end(ap);
}
-void crash(const char *format, ...)
+void mdvi_crash(const char *format, ...)
{
va_list ap;
abort();
}
-void error(const char *format, ...)
+void mdvi_error(const char *format, ...)
{
va_list ap;
va_end(ap);
}
-void warning(const char *format, ...)
+void mdvi_warning(const char *format, ...)
{
va_list ap;
va_end(ap);
}
-void fatal(const char *format, ...)
+void mdvi_fatal(const char *format, ...)
{
va_list ap;
void *ptr = malloc(nelems);
if(ptr == NULL)
- fatal(_("out of memory allocating %u bytes\n"),
- (unsigned)nelems);
+ mdvi_fatal(_("out of memory allocating %u bytes\n"),
+ (unsigned)nelems);
return ptr;
}
void *ptr;
if(newsize == 0)
- crash(_("attempted to reallocate with zero size\n"));
+ mdvi_crash(_("attempted to reallocate with zero size\n"));
ptr = realloc(data, newsize);
if(ptr == NULL)
- fatal(_("failed to reallocate %u bytes\n"), (unsigned)newsize);
+ mdvi_fatal(_("failed to reallocate %u bytes\n"), (unsigned)newsize);
return ptr;
}
void *ptr;
if(nmemb == 0)
- crash(_("attempted to callocate 0 members\n"));
+ mdvi_crash(_("attempted to callocate 0 members\n"));
if(size == 0)
- crash(_("attempted to callocate %u members with size 0\n"),
+ mdvi_crash(_("attempted to callocate %u members with size 0\n"),
(unsigned)nmemb);
ptr = calloc(nmemb, size);
if(ptr == 0)
- fatal(_("failed to allocate %ux%u bytes\n"),
- (unsigned)nmemb, (unsigned)size);
+ mdvi_fatal(_("failed to allocate %ux%u bytes\n"),
+ (unsigned)nmemb, (unsigned)size);
return ptr;
}
void mdvi_free(void *ptr)
{
if(ptr == NULL)
- crash(_("attempted to free NULL pointer\n"));
+ mdvi_crash(_("attempted to free NULL pointer\n"));
free(ptr);
}
fseek(p, (long)mlen, SEEK_CUR);
checksum = fuget4(p);
if(checksum && font->checksum && checksum != font->checksum) {
- warning(_("%s: Checksum mismatch (expected %u, got %u)\n"),
- font->fontname, font->checksum, checksum);
+ mdvi_warning(_("%s: Checksum mismatch (expected %u, got %u)\n"),
+ font->fontname, font->checksum, checksum);
} else if(!font->checksum)
font->checksum = checksum;
font->design = fuget4(p);
/* get the font */
ref = font_reference(params, id, name, checksum, hdpi, vdpi, scale);
if(ref == NULL) {
- error(_("(vf) %s: could not load font `%s'\n"),
- font->fontname, name);
+ mdvi_error(_("(vf) %s: could not load font `%s'\n"),
+ font->fontname, name);
goto error;
}
mdvi_free(name);
nchars = cc + 16;
}
if(font->chars[cc].offset) {
- error(_("(vf) %s: character %d redefined\n"),
- font->fontname, cc);
+ mdvi_error(_("(vf) %s: character %d redefined\n"),
+ font->fontname, cc);
goto error;
}
op = fuget1(p);
}
if(op != 248) {
- error(_("(vf) %s: no postamble\n"), font->fontname);
+ mdvi_error(_("(vf) %s: no postamble\n"), font->fontname);
goto error;
}
return 0;
badvf:
- error(_("%s: File corrupted, or not a VF file.\n"), font->fontname);
+ mdvi_error(_("%s: File corrupted, or not a VF file.\n"), font->fontname);
error:
if(font->chars)
mdvi_free(font->chars);