static void cite_biblio(keywordlist *kl, wchar_t *key, filepos fpos) {
keyword *kw = kw_lookup(kl, key);
if (!kw)
- error(err_nosuchkw, &fpos, key);
+ err_nosuchkw(&fpos, key);
else {
/*
* We've found a \k reference. If it's a
if (para->type == para_BR) {
keyword *kw = kw_lookup(kl, para->keyword);
if (!kw) {
- error(err_nosuchkw, ¶->fpos, para->keyword);
+ err_nosuchkw(¶->fpos, para->keyword);
} else if (kw->text) {
- error(err_multiBR, ¶->fpos, para->keyword);
+ err_multiBR(¶->fpos, para->keyword);
} else {
kw->text = dup_word_list(para->words);
}
break;
if (i == lenof(versions))
- error(err_htmlver, &p->fpos, vername);
+ err_htmlver(&p->fpos, vername);
else
ret.htmlver = versions[i].ver;
} else if (!ustricmp(k, L"html-single-filename")) {
frag = adv(frag);
}
} else
- error(err_cfginsufarg, &p->fpos, p->origkeyword, 1);
+ err_cfginsufarg(&p->fpos, p->origkeyword, 1);
} else if (!ustricmp(k, L"html-chapter-numeric")) {
ret.achapter.just_numbers = utob(uadv(k));
} else if (!ustricmp(k, L"html-chapter-shownumber")) {
* turn both off.
*/
if (!ret.chm_filename ^ !ret.hhp_filename) {
- error(err_chmnames);
+ err_chmnames();
sfree(ret.chm_filename); ret.chm_filename = NULL;
sfree(ret.hhp_filename); ret.hhp_filename = NULL;
}
else
ho.fp = fopen(f->filename, "w");
if (!ho.fp)
- error(err_cantopenw, f->filename);
+ err_cantopenw(f->filename);
ho.charset = conf.output_charset;
ho.restrict_charset = conf.restrict_charset;
ho.fp = fopen(conf.hhp_filename, "w");
if (!ho.fp)
- error(err_cantopenw, conf.hhp_filename);
+ err_cantopenw(conf.hhp_filename);
fprintf(ho.fp,
"[OPTIONS]\n"
ho.fp = fopen(conf.hhc_filename, "w");
if (!ho.fp)
- error(err_cantopenw, conf.hhc_filename);
+ err_cantopenw(conf.hhc_filename);
ho.charset = CS_CP1252; /* as far as I know, HHC files are */
ho.restrict_charset = CS_CP1252; /* hardwired to this charset */
ho.fp = fopen(hhk_filename, "w");
if (!ho.fp)
- error(err_cantopenw, hhk_filename);
+ err_cantopenw(hhk_filename);
ho.charset = CS_CP1252; /* as far as I know, HHK files are */
ho.restrict_charset = CS_CP1252; /* hardwired to this charset */
kw = *longname ? uadv(longname) : L"";
if (!*longname) {
- error(err_cfginsufarg, &p->fpos, p->origkeyword, 3);
+ err_cfginsufarg(&p->fpos, p->origkeyword, 3);
continue;
}
*/
fp = fopen(conf.filename, "w");
if (!fp) {
- error(err_cantopenw, conf.filename);
+ err_cantopenw(conf.filename);
return;
}
fputs(intro_text.output.text, fp);
sprintf(fname, "%s-%d", conf.filename, filenum);
fp = fopen(fname, "w");
if (!fp) {
- error(err_cantopenw, fname);
+ err_cantopenw(fname);
return;
}
sfree(fname);
p = q = id->output.text;
while (*p) {
if (*p == ':' || *p == ',' || *p == '(' || *p == ')') {
- error(err_infonodechar, fpos, *p);
+ err_infonodechar(fpos, *p);
} else {
*q++ = *p;
}
else
fp = fopen(conf.filename, "w");
if (!fp) {
- error(err_cantopenw, conf.filename);
+ err_cantopenw(conf.filename);
return;
}
fonts[i] = f;
else
/* FIXME: proper error */
- error(err_nofont, fpos, wp);
+ err_nofont(fpos, wp);
}
}
else
fp = fopen(filename, "wb");
if (!fp) {
- error(err_cantopenw, filename);
+ err_cantopenw(filename);
return;
}
else
fp = fopen(filename, "w");
if (!fp) {
- error(err_cantopenw, filename);
+ err_cantopenw(filename);
return;
}
else
tf.fp = fopen(conf.filename, "w");
if (!tf.fp) {
- error(err_cantopenw, conf.filename);
+ err_cantopenw(conf.filename);
return;
}
tf.charset = conf.charset;
for (; text; text = text->next) if (text->type == word_WeakCode) {
int wid = ustrwid(text->text, tf->charset);
if (wid > width)
- error(err_text_codeline, &text->fpos, wid, width);
+ err_text_codeline(&text->fpos, wid, width);
text_output_many(tf, indent, L' ');
text_output(tf, text->text);
text_output(tf, L"\n");
state.cntfp = fopen(cntname, "wb");
if (!state.cntfp) {
- error(err_cantopenw, cntname);
+ err_cantopenw(cntname);
return;
}
state.cnt_last_level = -1; state.cnt_workaround = 0;
p->private_data = whlp_register_topic(h, rs.text, &errstr);
if (!p->private_data) {
p->private_data = whlp_register_topic(h, NULL, NULL);
- error(err_winhelp_ctxclash, &p->fpos, rs.text, errstr);
+ err_winhelp_ctxclash(&p->fpos, rs.text, errstr);
}
sfree(rs.text);
}
case para_Subsect:
level = (p->type == para_Heading ? 0 : p->aux);
if (level > state->oklevel) {
- error(err_sectjump, &p->fpos);
+ err_sectjump(&p->fpos);
*errflag = TRUE;
ret = NULL;
break;
#define PREFIX 0x0001 /* give `halibut:' prefix */
#define FILEPOS 0x0002 /* give file position prefix */
-static void do_error(int code, va_list ap) {
- char error[1024];
- char c;
- int i, j;
- char *sp, *sp2;
- wchar_t *wsp, *wsp2;
- unsigned wc;
- filepos fpos, fpos2, *fposp;
- int flags = 0;
-
- switch(code) {
- case err_nomemory: /* no arguments */
- sprintf(error, "out of memory");
- flags = PREFIX;
- break;
- case err_optnoarg:
- sp = va_arg(ap, char *);
- sprintf(error, "option `-%.200s' requires an argument", sp);
- flags = PREFIX;
- break;
- case err_nosuchopt:
- sp = va_arg(ap, char *);
- sprintf(error, "unrecognised option `-%.200s'", sp);
- flags = PREFIX;
- break;
- case err_cmdcharset:
- sp = va_arg(ap, char *);
- sprintf(error, "character set `%.200s' not recognised", sp);
- flags = PREFIX;
- break;
- case err_futileopt:
- sp = va_arg(ap, char *);
- sp2 = va_arg(ap, char *);
- sprintf(error, "warning: option `-%s' has no effect%s", sp, sp2);
- flags = PREFIX;
- break;
- case err_noinput: /* no arguments */
- sprintf(error, "no input files");
- flags = PREFIX;
- break;
- case err_cantopen:
- sp = va_arg(ap, char *);
- sprintf(error, "unable to open input file `%.200s'", sp);
- flags = PREFIX;
- break;
- case err_nodata: /* no arguments */
- sprintf(error, "no data in input files");
- flags = PREFIX;
- break;
- case err_brokencodepara:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "every line of a code paragraph should begin `\\c'");
- flags = FILEPOS;
- break;
- case err_kwunclosed:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "expected `}' after paragraph keyword");
- flags = FILEPOS;
- break;
- case err_kwexpected:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "expected a paragraph keyword");
- flags = FILEPOS;
- break;
- case err_kwillegal:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "expected no paragraph keyword");
- flags = FILEPOS;
- break;
- case err_kwtoomany:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "expected only one paragraph keyword");
- flags = FILEPOS;
- break;
- case err_bodyillegal:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "expected no text after paragraph keyword");
- flags = FILEPOS;
- break;
- case err_badparatype:
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "command `%.200s' unrecognised at start of"
- " paragraph", sp);
- flags = FILEPOS;
- sfree(sp);
- break;
- case err_badmidcmd:
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "command `%.200s' unexpected in mid-paragraph", sp);
- flags = FILEPOS;
- sfree(sp);
- break;
- case err_unexbrace:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "brace character unexpected in mid-paragraph");
- flags = FILEPOS;
- break;
- case err_explbr:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "expected `{' after command");
- flags = FILEPOS;
- break;
- case err_commenteof:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "end of file unexpected inside `\\#{...}' comment");
- flags = FILEPOS;
- break;
- case err_kwexprbr:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "expected `}' after cross-reference");
- flags = FILEPOS;
- break;
- case err_codequote:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "unable to nest \\q{...} within \\c{...} or \\cw{...}");
- flags = FILEPOS;
- break;
- case err_missingrbrace:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "unclosed braces at end of paragraph");
- flags = FILEPOS;
- break;
- case err_missingrbrace2:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "unclosed braces at end of input file");
- flags = FILEPOS;
- break;
- case err_nestedstyles:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "unable to nest text styles");
- flags = FILEPOS;
- break;
- case err_nestedindex:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "unable to nest index markings");
- flags = FILEPOS;
- break;
- case err_indexcase:
- fpos = *va_arg(ap, filepos *);
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- fpos2 = *va_arg(ap, filepos *);
- wsp2 = va_arg(ap, wchar_t *);
- sp2 = utoa_locale_dup(wsp2);
- sprintf(error, "warning: index tag `%.200s' used with ", sp);
- sprintf(error + strlen(error), "different case (`%.200s') at %s:%d",
- sp2, fpos2.filename, fpos2.line);
- flags = FILEPOS;
- sfree(sp);
- sfree(sp2);
- break;
- case err_nosuchkw:
- fpos = *va_arg(ap, filepos *);
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- sprintf(error, "unable to resolve cross-reference to `%.200s'", sp);
- flags = FILEPOS;
- sfree(sp);
- break;
- case err_multiBR:
- fpos = *va_arg(ap, filepos *);
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- sprintf(error, "multiple `\\BR' entries given for `%.200s'", sp);
- flags = FILEPOS;
- sfree(sp);
- break;
- case err_nosuchidxtag:
- fpos = *va_arg(ap, filepos *);
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- sprintf(error, "`\\IM' on unknown index tag `%.200s'", sp);
- sfree(sp);
- flags = FILEPOS;
- break;
- case err_cantopenw:
- sp = va_arg(ap, char *);
- sprintf(error, "unable to open output file `%.200s'", sp);
- flags = PREFIX;
- break;
- case err_macroexists:
- fpos = *va_arg(ap, filepos *);
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- sprintf(error, "macro `%.200s' already defined", sp);
- flags = FILEPOS;
- sfree(sp);
- break;
- case err_sectjump:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "expected higher heading levels before this one");
- flags = FILEPOS;
- break;
- case err_winhelp_ctxclash:
- fpos = *va_arg(ap, filepos *);
- sp = va_arg(ap, char *);
- sp2 = va_arg(ap, char *);
- sprintf(error, "Windows Help context id `%.200s' clashes with "
- "previously defined `%.200s'", sp, sp2);
- flags = FILEPOS;
- break;
- case err_multikw:
- fpos = *va_arg(ap, filepos *);
- fpos2 = *va_arg(ap, filepos *);
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- sprintf(error, "paragraph keyword `%.200s' already defined at ", sp);
- sprintf(error + strlen(error), "%s:%d", fpos2.filename, fpos2.line);
- flags = FILEPOS;
- sfree(sp);
- break;
- case err_misplacedlcont:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "\\lcont is only expected after a list item");
- flags = FILEPOS;
- break;
- case err_sectmarkerinblock:
- fpos = *va_arg(ap, filepos *);
- sp = va_arg(ap, char *);
- sprintf(error, "section headings are not supported within \\%.100s",
- sp);
- flags = FILEPOS;
- break;
- case err_cfginsufarg:
- fpos = *va_arg(ap, filepos *);
- sp = va_arg(ap, char *);
- i = va_arg(ap, int);
- sprintf(error, "\\cfg{%s} expects at least %d parameter%s", sp,
- i, (i==1)?"":"s");
- flags = FILEPOS;
- break;
- case err_infonodechar:
- fposp = va_arg(ap, filepos *);
- c = (char)va_arg(ap, int);
- sprintf(error, "info output format does not support '%c' in"
- " node names; removing", c);
- if (fposp) {
- flags = FILEPOS;
- fpos = *fposp;
- }
- break;
- case err_text_codeline:
- fpos = *va_arg(ap, filepos *);
- i = va_arg(ap, int);
- j = va_arg(ap, int);
- sprintf(error, "warning: code paragraph line is %d chars wide, wider"
- " than body width %d", i, j);
- flags = FILEPOS;
- break;
- case err_htmlver:
- fpos = *va_arg(ap, filepos *);
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- sprintf(error, "unrecognised HTML version keyword `%.200s'", sp);
- sfree(sp);
- flags = FILEPOS;
- break;
- case err_charset:
- fpos = *va_arg(ap, filepos *);
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- sprintf(error, "character set `%.200s' not recognised", sp);
- flags = FILEPOS;
- sfree(sp);
- break;
- case err_nofont:
- fpos = *va_arg(ap, filepos *);
- wsp = va_arg(ap, wchar_t *);
- sp = utoa_locale_dup(wsp);
- sprintf(error, "font `%.200s' not recognised", sp);
- flags = FILEPOS;
- sfree(sp);
- break;
- case err_afmeof:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "AFM file ended unexpectedly");
- flags = FILEPOS;
- break;
- case err_afmkey:
- fpos = *va_arg(ap, filepos *);
- sp = va_arg(ap, char *);
- sprintf(error, "required AFM key '%.200s' missing", sp);
- flags = FILEPOS;
- break;
- case err_afmvers:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "unsupported AFM version");
- flags = FILEPOS;
- break;
- case err_afmval:
- fpos = *va_arg(ap, filepos *);
- sp = va_arg(ap, char *);
- i = va_arg(ap, int);
- if (i == 1)
- sprintf(error, "AFM key '%.200s' requires a value", sp);
- else
- sprintf(error, "AFM key '%.200s' requires %d values", sp, i);
- flags = FILEPOS;
- break;
- case err_pfeof:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "Type 1 font file ended unexpectedly");
- flags = FILEPOS;
- break;
- case err_pfhead:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "Type 1 font file header line invalid");
- flags = FILEPOS;
- break;
- case err_pfbad:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "Type 1 font file invalid");
- flags = FILEPOS;
- break;
- case err_pfnoafm:
- fpos = *va_arg(ap, filepos *);
- sp = va_arg(ap, char *);
- sprintf(error, "no metrics available for Type 1 font '%.200s'", sp);
- flags = FILEPOS;
- break;
- case err_chmnames:
- sprintf(error, "only one of html-mshtmlhelp-chm and "
- "html-mshtmlhelp-hhp found");
- flags = PREFIX;
- break;
- case err_sfntnotable:
- fpos = *va_arg(ap, filepos *);
- sp = va_arg(ap, char *);
- sprintf(error, "font has no '%.4s' table", sp);
- flags = FILEPOS;
- break;
- case err_sfntnopsname:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "font has no PostScript name");
- flags = FILEPOS;
- break;
- case err_sfntbadtable:
- fpos = *va_arg(ap, filepos *);
- sp = va_arg(ap, char *);
- sprintf(error, "font has an invalid '%.4s' table", sp);
- flags = FILEPOS;
- break;
- case err_sfntnounicmap:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "font has no UCS-2 character map");
- flags = FILEPOS;
- break;
- case err_sfnttablevers:
- fpos = *va_arg(ap, filepos *);
- sp = va_arg(ap, char *);
- sprintf(error, "font has an unsupported '%.4s' table version", sp);
- flags = FILEPOS;
- break;
- case err_sfntbadhdr:
- fpos = *va_arg(ap, filepos *);
- sprintf(error, "font has an invalid header");
- flags = FILEPOS;
- break;
- case err_sfntbadglyph:
- fpos = *va_arg(ap, filepos *);
- wc = va_arg(ap, unsigned);
- sprintf(error,
- "warning: character U+%04X references an non-existent glyph",
- wc);
- flags = FILEPOS;
- break;
- case err_whatever:
- sp = va_arg(ap, char *);
- vsprintf(error, sp, ap);
- flags = PREFIX;
- break;
- }
+static void do_error(const filepos *fpos, const char *fmt, ...)
+{
+ va_list ap;
- if (flags & PREFIX)
- fputs("halibut: ", stderr);
- if (flags & FILEPOS) {
- fprintf(stderr, "%s:", fpos.filename ? fpos.filename : "<standard input>");
- if (fpos.line > 0)
- fprintf(stderr, "%d:", fpos.line);
- if (fpos.col > 0)
- fprintf(stderr, "%d:", fpos.col);
+ if (fpos) {
+ fprintf(stderr, "%s:",
+ fpos->filename ? fpos->filename : "<standard input>");
+ if (fpos->line > 0)
+ fprintf(stderr, "%d:", fpos->line);
+ if (fpos->col > 0)
+ fprintf(stderr, "%d:", fpos->col);
fputc(' ', stderr);
+ } else {
+ fputs("halibut: ", stderr);
}
- fputs(error, stderr);
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+
fputc('\n', stderr);
}
-void fatal(int code, ...) {
- va_list ap;
- va_start(ap, code);
- do_error(code, ap);
- va_end(ap);
+void fatalerr_nomemory(void)
+{
+ do_error(NULL, "out of memory");
exit(EXIT_FAILURE);
}
-void error(int code, ...) {
- va_list ap;
- va_start(ap, code);
- do_error(code, ap);
- va_end(ap);
+void err_optnoarg(const char *sp)
+{
+ do_error(NULL, "option `-%s' requires an argument", sp);
+}
+
+void err_nosuchopt(const char *sp)
+{
+ do_error(NULL, "unrecognised option `-%s'", sp);
+}
+
+void err_cmdcharset(const char *sp)
+{
+ do_error(NULL, "character set `%s' not recognised", sp);
+}
+
+void err_futileopt(const char *sp, const char *sp2)
+{
+ do_error(NULL, "warning: option `-%s' has no effect%s", sp, sp2);
+}
+
+void err_noinput(void)
+{
+ do_error(NULL, "no input files");
+}
+
+void err_cantopen(const char *sp)
+{
+ do_error(NULL, "unable to open input file `%s'", sp);
+}
+
+void err_nodata(void)
+{
+ do_error(NULL, "no data in input files");
+}
+
+void err_brokencodepara(const filepos *fpos)
+{
+ do_error(fpos, "every line of a code paragraph should begin `\\c'");
+}
+
+void err_kwunclosed(const filepos *fpos)
+{
+ do_error(fpos, "expected `}' after paragraph keyword");
+}
+
+void err_kwexpected(const filepos *fpos)
+{
+ do_error(fpos, "expected a paragraph keyword");
+}
+
+void err_kwillegal(const filepos *fpos)
+{
+ do_error(fpos, "expected no paragraph keyword");
+}
+
+void err_kwtoomany(const filepos *fpos)
+{
+ do_error(fpos, "expected only one paragraph keyword");
+}
+
+void err_bodyillegal(const filepos *fpos)
+{
+ do_error(fpos, "expected no text after paragraph keyword");
+}
+
+void err_badparatype(const wchar_t *wsp, const filepos *fpos)
+{
+ char *sp = utoa_locale_dup(wsp);
+ do_error(fpos, "command `%s' unrecognised at start of paragraph", sp);
+ sfree(sp);
+}
+
+void err_badmidcmd(const wchar_t *wsp, const filepos *fpos)
+{
+ char *sp = utoa_locale_dup(wsp);
+ do_error(fpos, "command `%s' unexpected in mid-paragraph", sp);
+ sfree(sp);
+}
+
+void err_unexbrace(const filepos *fpos)
+{
+ do_error(fpos, "brace character unexpected in mid-paragraph");
+}
+
+void err_explbr(const filepos *fpos)
+{
+ do_error(fpos, "expected `{' after command");
+}
+
+void err_commenteof(const filepos *fpos)
+{
+ do_error(fpos, "end of file unexpected inside `\\#{...}' comment");
+}
+
+void err_kwexprbr(const filepos *fpos)
+{
+ do_error(fpos, "expected `}' after cross-reference");
+}
+
+void err_codequote(const filepos *fpos)
+{
+ do_error(fpos, "unable to nest \\q{...} within \\c{...} or \\cw{...}");
+}
+
+void err_missingrbrace(const filepos *fpos)
+{
+ do_error(fpos, "unclosed braces at end of paragraph");
+}
+
+void err_missingrbrace2(const filepos *fpos)
+{
+ do_error(fpos, "unclosed braces at end of input file");
+}
+
+void err_nestedstyles(const filepos *fpos)
+{
+ do_error(fpos, "unable to nest text styles");
+}
+
+void err_nestedindex(const filepos *fpos)
+{
+ do_error(fpos, "unable to nest index markings");
+}
+
+void err_indexcase(const filepos *fpos, const wchar_t *wsp,
+ const filepos *fpos2, const wchar_t *wsp2)
+{
+ char *sp = utoa_locale_dup(wsp), *sp2 = utoa_locale_dup(wsp2);
+ do_error(fpos, "warning: index tag `%s' used with different "
+ "case (`%s') at %s:%d",
+ sp, sp2, fpos2->filename, fpos2->line);
+ sfree(sp);
+ sfree(sp2);
+}
+
+void err_nosuchkw(const filepos *fpos, const wchar_t *wsp)
+{
+ char *sp = utoa_locale_dup(wsp);
+ do_error(fpos, "unable to resolve cross-reference to `%s'", sp);
+ sfree(sp);
+}
+
+void err_multiBR(const filepos *fpos, const wchar_t *wsp)
+{
+ char *sp = utoa_locale_dup(wsp);
+ do_error(fpos, "multiple `\\BR' entries given for `%s'", sp);
+ sfree(sp);
+}
+
+void err_nosuchidxtag(const filepos *fpos, const wchar_t *wsp)
+{
+ char *sp = utoa_locale_dup(wsp);
+ do_error(fpos, "`\\IM' on unknown index tag `%s'", sp);
+ sfree(sp);
+}
+
+void err_cantopenw(const char *sp)
+{
+ do_error(NULL, "unable to open output file `%s'", sp);
+}
+
+void err_macroexists(const filepos *fpos, const wchar_t *wsp)
+{
+ char *sp = utoa_locale_dup(wsp);
+ do_error(fpos, "macro `%s' already defined", sp);
+ sfree(sp);
+}
+
+void err_sectjump(const filepos *fpos)
+{
+ do_error(fpos, "expected higher heading levels before this one");
+}
+
+void err_winhelp_ctxclash(const filepos *fpos, const char *sp, const char *sp2)
+{
+ do_error(fpos, "Windows Help context id `%s' clashes with "
+ "previously defined `%s'", sp, sp2);
+}
+
+void err_multikw(const filepos *fpos, const filepos *fpos2, const wchar_t *wsp)
+{
+ char *sp = utoa_locale_dup(wsp);
+ do_error(fpos, "paragraph keyword `%s' already defined at %s:%d",
+ sp, fpos2->filename, fpos2->line);
+ sfree(sp);
+}
+
+void err_misplacedlcont(const filepos *fpos)
+{
+ do_error(fpos, "\\lcont is only expected after a list item");
+}
+
+void err_sectmarkerinblock(const filepos *fpos, const char *sp)
+{
+ do_error(fpos, "section headings are not supported within \\%s", sp);
+}
+
+void err_cfginsufarg(const filepos *fpos, const char *sp, int i)
+{
+ do_error(fpos, "\\cfg{%s} expects at least %d parameter%s",
+ sp, i, (i==1)?"":"s");
+}
+
+void err_infonodechar(const filepos *fpos, char c) /* fpos might be NULL */
+{
+ do_error(fpos, "info output format does not support '%c' in"
+ " node names; removing", c);
+}
+
+void err_text_codeline(const filepos *fpos, int i, int j)
+{
+ do_error(fpos, "warning: code paragraph line is %d chars wide, wider"
+ " than body width %d", i, j);
+}
+
+void err_htmlver(const filepos *fpos, const wchar_t *wsp)
+{
+ char *sp = utoa_locale_dup(wsp);
+ do_error(fpos, "unrecognised HTML version keyword `%s'", sp);
+ sfree(sp);
+}
+
+void err_charset(const filepos *fpos, const wchar_t *wsp)
+{
+ char *sp = utoa_locale_dup(wsp);
+ do_error(fpos, "character set `%s' not recognised", sp);
+ sfree(sp);
+}
+
+void err_nofont(const filepos *fpos, const wchar_t *wsp)
+{
+ char *sp = utoa_locale_dup(wsp);
+ do_error(fpos, "font `%s' not recognised", sp);
+ sfree(sp);
+}
+
+void err_afmeof(const filepos *fpos)
+{
+ do_error(fpos, "AFM file ended unexpectedly");
+}
+
+void err_afmkey(const filepos *fpos, const char *sp)
+{
+ do_error(fpos, "required AFM key '%s' missing", sp);
+}
+
+void err_afmvers(const filepos *fpos)
+{
+ do_error(fpos, "unsupported AFM version");
+}
+
+void err_afmval(const filepos *fpos, const char *sp, int i)
+{
+ if (i == 1)
+ do_error(fpos, "AFM key '%s' requires a value", sp);
+ else
+ do_error(fpos, "AFM key '%s' requires %d values", sp, i);
+}
+
+void err_pfeof(const filepos *fpos)
+{
+ do_error(fpos, "Type 1 font file ended unexpectedly");
+}
+
+void err_pfhead(const filepos *fpos)
+{
+ do_error(fpos, "Type 1 font file header line invalid");
+}
+
+void err_pfbad(const filepos *fpos)
+{
+ do_error(fpos, "Type 1 font file invalid");
+}
+
+void err_pfnoafm(const filepos *fpos, const char *sp)
+{
+ do_error(fpos, "no metrics available for Type 1 font '%s'", sp);
+}
+
+void err_chmnames(void)
+{
+ do_error(NULL, "only one of html-mshtmlhelp-chm and "
+ "html-mshtmlhelp-hhp found");
+}
+
+void err_sfntnotable(const filepos *fpos, const char *sp)
+{
+ do_error(fpos, "font has no '%s' table", sp);
+}
+
+void err_sfntnopsname(const filepos *fpos)
+{
+ do_error(fpos, "font has no PostScript name");
+}
+
+void err_sfntbadtable(const filepos *fpos, const char *sp)
+{
+ do_error(fpos, "font has an invalid '%s' table", sp);
+}
+
+void err_sfntnounicmap(const filepos *fpos)
+{
+ do_error(fpos, "font has no UCS-2 character map");
+}
+
+void err_sfnttablevers(const filepos *fpos, const char *sp)
+{
+ do_error(fpos, "font has an unsupported '%s' table version", sp);
+}
+
+void err_sfntbadhdr(const filepos *fpos)
+{
+ do_error(fpos, "font has an invalid header");
+}
+
+void err_sfntbadglyph(const filepos *fpos, unsigned wc)
+{
+ do_error(fpos,
+ "warning: character U+%04X references a non-existent glyph",
+ wc);
}
/*
* error.c
*/
-void fatal(int code, ...) NORETURN;
-void error(int code, ...);
-enum {
- err_nomemory, /* out of memory */
- err_optnoarg, /* option `-%s' requires an argument */
- err_nosuchopt, /* unrecognised option `-%s' */
- err_cmdcharset, /* unrecognised charset %s (cmdline) */
- err_futileopt, /* futile option `-%s'%s */
- err_noinput, /* no input files */
- err_cantopen, /* unable to open input file `%s' */
- err_nodata, /* no data in input files */
- err_brokencodepara, /* line in codepara didn't begin `\c' */
- err_kwunclosed, /* expected `}' after keyword */
- err_kwillegal, /* paragraph type expects no keyword */
- err_kwexpected, /* paragraph type expects a keyword */
- err_kwtoomany, /* paragraph type expects only 1 */
- err_bodyillegal, /* paragraph type expects only kws! */
- err_badparatype, /* invalid command at start of para */
- err_badmidcmd, /* invalid command in mid-para */
- err_unexbrace, /* unexpected brace */
- err_explbr, /* expected `{' after command */
- err_commenteof, /* EOF inside braced comment */
- err_kwexprbr, /* expected `}' after cross-ref */
- err_codequote, /* \q within \c is not supported */
- err_missingrbrace, /* unclosed braces at end of para */
- err_missingrbrace2, /* unclosed braces at end of file */
- err_nestedstyles, /* unable to nest text styles */
- err_nestedindex, /* unable to nest `\i' thingys */
- err_indexcase, /* two \i differing only in case */
- err_nosuchkw, /* unresolved cross-reference */
- err_multiBR, /* multiple \BRs on same keyword */
- err_nosuchidxtag, /* \IM on unknown index tag (warning) */
- err_cantopenw, /* can't open output file for write */
- err_macroexists, /* this macro already exists */
- err_sectjump, /* jump a heading level, eg \C -> \S */
- err_winhelp_ctxclash, /* WinHelp context ID hash clash */
- err_multikw, /* keyword clash in sections */
- err_misplacedlcont, /* \lcont not after a list item */
- err_sectmarkerinblock, /* section marker appeared in block */
- err_cfginsufarg, /* \cfg{%s} insufficient args (<%d) */
- err_infonodechar, /* colon/comma in node name in info */
- err_text_codeline, /* \c line too long in text backend */
- err_htmlver, /* unrecognised HTML version keyword */
- err_charset, /* unrecognised character set name */
- err_nofont, /* unrecognised font name */
- err_afmeof, /* eof in AFM file */
- err_afmkey, /* missing expected keyword in AFM */
- err_afmvers, /* unsupported AFM version */
- err_afmval, /* missing value(s) for AFM key */
- err_pfeof, /* eof in Type 1 font file */
- err_pfhead, /* bad Type 1 header line */
- err_pfbad, /* otherwise invalide Type 1 font */
- err_pfnoafm, /* Type 1 font but no AFM */
- err_chmnames, /* need both or neither of hhp+chm */
- err_sfntnotable, /* required sfnt table missing */
- err_sfntnopsname, /* sfnt has no PostScript name */
- err_sfntbadtable, /* sfnt table not valid */
- err_sfntnounicmap, /* sfnt has no UCS-2 cmap */
- err_sfnttablevers, /* sfnt table version unknown */
- err_sfntbadhdr, /* sfnt has bad header */
- err_sfntbadglyph, /* sfnt cmap references bad glyph */
- err_whatever /* random error of another type */
-};
+/* out of memory */
+void fatalerr_nomemory(void) NORETURN;
+/* option `-%s' requires an argument */
+void err_optnoarg(const char *sp);
+/* unrecognised option `-%s' */
+void err_nosuchopt(const char *sp);
+/* unrecognised charset %s (cmdline) */
+void err_cmdcharset(const char *sp);
+/* futile option `-%s'%s */
+void err_futileopt(const char *sp, const char *sp2);
+/* no input files */
+void err_noinput(void);
+/* unable to open input file `%s' */
+void err_cantopen(const char *sp);
+/* no data in input files */
+void err_nodata(void);
+/* line in codepara didn't begin `\c' */
+void err_brokencodepara(const filepos *fpos);
+/* expected `}' after keyword */
+void err_kwunclosed(const filepos *fpos);
+/* paragraph type expects no keyword */
+void err_kwexpected(const filepos *fpos);
+/* paragraph type expects a keyword */
+void err_kwillegal(const filepos *fpos);
+/* paragraph type expects only 1 */
+void err_kwtoomany(const filepos *fpos);
+/* paragraph type expects only kws! */
+void err_bodyillegal(const filepos *fpos);
+/* invalid command at start of para */
+void err_badparatype(const wchar_t *wsp, const filepos *fpos);
+/* invalid command in mid-para */
+void err_badmidcmd(const wchar_t *wsp, const filepos *fpos);
+/* unexpected brace */
+void err_unexbrace(const filepos *fpos);
+/* expected `{' after command */
+void err_explbr(const filepos *fpos);
+/* EOF inside braced comment */
+void err_commenteof(const filepos *fpos);
+/* expected `}' after cross-ref */
+void err_kwexprbr(const filepos *fpos);
+/* \q within \c is not supported */
+void err_codequote(const filepos *fpos);
+/* unclosed braces at end of para */
+void err_missingrbrace(const filepos *fpos);
+/* unclosed braces at end of file */
+void err_missingrbrace2(const filepos *fpos);
+/* unable to nest text styles */
+void err_nestedstyles(const filepos *fpos);
+/* unable to nest `\i' thingys */
+void err_nestedindex(const filepos *fpos);
+/* two \i differing only in case */
+void err_indexcase(const filepos *fpos, const wchar_t *wsp,
+ const filepos *fpos2, const wchar_t *wsp2);
+/* unresolved cross-reference */
+void err_nosuchkw(const filepos *fpos, const wchar_t *wsp);
+/* multiple \BRs on same keyword */
+void err_multiBR(const filepos *fpos, const wchar_t *wsp);
+/* \IM on unknown index tag (warning) */
+void err_nosuchidxtag(const filepos *fpos, const wchar_t *wsp);
+/* can't open output file for write */
+void err_cantopenw(const char *sp);
+/* this macro already exists */
+void err_macroexists(const filepos *fpos, const wchar_t *wsp);
+/* jump a heading level, eg \C -> \S */
+void err_sectjump(const filepos *fpos);
+/* WinHelp context ID hash clash */
+void err_winhelp_ctxclash(const filepos *fpos, const char *sp, const char *sp2);
+/* keyword clash in sections */
+void err_multikw(const filepos *fpos, const filepos *fpos2, const wchar_t *wsp);
+/* \lcont not after a list item */
+void err_misplacedlcont(const filepos *fpos);
+/* section marker appeared in block */
+void err_sectmarkerinblock(const filepos *fpos, const char *sp);
+/* \cfg{%s} insufficient args (<%d) */
+void err_cfginsufarg(const filepos *fpos, const char *sp, int i);
+/* colon/comma in node name in info */
+void err_infonodechar(const filepos *fpos, char c) /* fpos might be NULL */;
+/* \c line too long in text backend */
+void err_text_codeline(const filepos *fpos, int i, int j);
+/* unrecognised HTML version keyword */
+void err_htmlver(const filepos *fpos, const wchar_t *wsp);
+/* unrecognised character set name */
+void err_charset(const filepos *fpos, const wchar_t *wsp);
+/* unrecognised font name */
+void err_nofont(const filepos *fpos, const wchar_t *wsp);
+/* eof in AFM file */
+void err_afmeof(const filepos *fpos);
+/* missing expected keyword in AFM */
+void err_afmkey(const filepos *fpos, const char *sp);
+/* unsupported AFM version */
+void err_afmvers(const filepos *fpos);
+/* missing value(s) for AFM key */
+void err_afmval(const filepos *fpos, const char *sp, int i);
+/* eof in Type 1 font file */
+void err_pfeof(const filepos *fpos);
+/* bad Type 1 header line */
+void err_pfhead(const filepos *fpos);
+/* otherwise invalide Type 1 font */
+void err_pfbad(const filepos *fpos);
+/* Type 1 font but no AFM */
+void err_pfnoafm(const filepos *fpos, const char *sp);
+/* need both or neither of hhp+chm */
+void err_chmnames(void);
+/* required sfnt table missing */
+void err_sfntnotable(const filepos *fpos, const char *sp);
+/* sfnt has no PostScript name */
+void err_sfntnopsname(const filepos *fpos);
+/* sfnt table not valid */
+void err_sfntbadtable(const filepos *fpos, const char *sp);
+/* sfnt has no UCS-2 cmap */
+void err_sfntnounicmap(const filepos *fpos);
+/* sfnt table version unknown */
+void err_sfnttablevers(const filepos *fpos, const char *sp);
+/* sfnt has bad header */
+void err_sfntbadhdr(const filepos *fpos);
+/* sfnt cmap references bad glyph */
+void err_sfntbadglyph(const filepos *fpos, unsigned wc);
/*
* malloc.c
in->pos.line++;
c = getc(in->currfp);
if (c == EOF) {
- error(err_afmeof, &in->pos);
+ err_afmeof(&in->pos);
return NULL;
}
line = snewn(len, char);
if (strcmp(key, expected) == 0)
return TRUE;
- error(err_afmkey, &in->pos, expected);
+ err_afmkey(&in->pos, expected);
return FALSE;
}
if (!line || !afm_require_key(line, "StartFontMetrics", in))
goto giveup;
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, in->pos, "StartFontMetrics", 1);
+ err_afmval(&in->pos, "StartFontMetrics", 1);
goto giveup;
}
if (atof(val) >= 5.0) {
- error(err_afmvers, &in->pos);
+ err_afmvers(&in->pos);
goto giveup;
}
sfree(line);
return;
} else if (strcmp(key, "FontName") == 0) {
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
fi->name = dupstr(val);
int i;
for (i = 0; i < 3; i++) {
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 4);
+ err_afmval(&in->pos, key, 4);
goto giveup;
}
fi->fontbbox[i] = atof(val);
}
} else if (strcmp(key, "CapHeight") == 0) {
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
fi->capheight = atof(val);
} else if (strcmp(key, "XHeight") == 0) {
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
fi->xheight = atof(val);
} else if (strcmp(key, "Ascender") == 0) {
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
fi->ascent = atof(val);
} else if (strcmp(key, "Descender") == 0) {
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
fi->descent = atof(val);
} else if (strcmp(key, "CapHeight") == 0) {
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
fi->capheight = atof(val);
} else if (strcmp(key, "StdHW") == 0) {
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
fi->stemh = atof(val);
} else if (strcmp(key, "StdVW") == 0) {
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
fi->stemv = atof(val);
} else if (strcmp(key, "ItalicAngle") == 0) {
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
fi->italicangle = atof(val);
} else if (strcmp(key, "StartCharMetrics") == 0) {
int nglyphs, i;
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
nglyphs = atoi(val);
if (strcmp(key, "WX") == 0 || strcmp(key, "W0X") == 0) {
if (!(val = strtok(NULL, " \t")) ||
!strcmp(val, ";")) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
width = atoi(val);
} else if (strcmp(key, "N") == 0) {
if (!(val = strtok(NULL, " \t")) ||
!strcmp(val, ";")) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
g = glyph_intern(val);
glyph succ, lig;
if (!(val = strtok(NULL, " \t")) ||
!strcmp(val, ";")) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
succ = glyph_intern(val);
if (!(val = strtok(NULL, " \t")) ||
!strcmp(val, ";")) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
lig = glyph_intern(val);
strcmp(key, "StartKernPairs0") == 0) {
int nkerns, i;
if (!(val = strtok(NULL, " \t"))) {
- error(err_afmval, &in->pos, key, 1);
+ err_afmval(&in->pos, key, 1);
goto giveup;
}
nkerns = atoi(val);
nr = strtok(NULL, " \t");
val = strtok(NULL, " \t");
if (!val) {
- error(err_afmval, &in->pos, key, 3);
+ err_afmval(&in->pos, key, 3);
goto giveup;
}
l = glyph_intern(nl);
c = pf_getc(pf);
if (c == EOF) {
sfree(rsc.text);
- error(err_pfeof, &tf->pos);
+ err_pfeof(&tf->pos);
return;
}
rdaddc(&rsc, c);
p = rsc.text;
if ((p = strchr(p, ':')) == NULL) {
sfree(rsc.text);
- error(err_pfhead, &tf->pos);
+ err_pfhead(&tf->pos);
return;
}
p++;
return;
}
}
- error(err_pfnoafm, &tf->pos, fontname);
+ err_pfnoafm(&tf->pos, fontname);
sfree(fontname);
}
ret = pf_findtoken(tf, 0, "eexec");
if (ret == (size_t)-1) {
- error(err_pfeof, &tf->pos);
+ err_pfeof(&tf->pos);
return 0;
}
return ret;
tf->length1 = pf_length1(tf);
ret = pf_findtoken(tf, tf->length1, "cleartomark");
if (ret == (size_t)-1) {
- error(err_pfeof, &tf->pos);
+ err_pfeof(&tf->pos);
return 0;
}
return ret - 12 - tf->length1; /* backspace over "cleartomark\n" */
namerecord *nr;
if (!sfnt_findtable(sf, TAG_name, &ptr, &end)) {
- error(err_sfntnotable, &sf->pos, "name");
+ err_sfntnotable(&sf->pos, "name");
return NULL;
}
ptr = decode(t_name_decode, ptr, end, &name);
}
}
}
- error(err_sfntnopsname, &sf->pos);
+ err_sfntnopsname(&sf->pos);
return NULL;
}
if (sfnt_findtable(sf, TAG_post, &ptr, &end)) {
ptr = decode(t_post_decode, ptr, end, &post);
if (ptr == NULL) {
- error(err_sfntbadtable, &sf->pos, "post");
+ err_sfntbadtable(&sf->pos, "post");
goto noglyphs;
}
switch (post.format) {
case 0x00010000:
if (sf->nglyphs != 258) {
- error(err_sfntbadtable, &sf->pos, "post");
+ err_sfntbadtable(&sf->pos, "post");
break;
}
sf->glyphsbyindex = (glyph *)tt_std_glyphs;
break;
case 0x00020000:
if ((char *)ptr + 2 > (char *)end) {
- error(err_sfntbadtable, &sf->pos, "post");
+ err_sfntbadtable(&sf->pos, "post");
break;
}
ptr = (char *)ptr + 2;
if ((char *)ptr + 2*sf->nglyphs > (char *)end) {
- error(err_sfntbadtable, &sf->pos, "post");
+ err_sfntbadtable(&sf->pos, "post");
break;
}
nextras = 0;
else if (g < 258 + nextras)
sf->glyphsbyindex[i] = extraglyphs[g - 258];
else {
- error(err_sfntbadtable, &sf->pos, "post");
+ err_sfntbadtable(&sf->pos, "post");
sf->glyphsbyindex[i] = genglyph(i);
}
}
case 0x00030000:
break;
default:
- error(err_sfnttablevers, &sf->pos, "post");
+ err_sfnttablevers(&sf->pos, "post");
break;
}
}
fi->fontbbox[2] = sf->head.xMax * FUNITS_PER_PT / sf->head.unitsPerEm;
fi->fontbbox[3] = sf->head.yMax * FUNITS_PER_PT / sf->head.unitsPerEm;
if (!sfnt_findtable(sf, TAG_hhea, &ptr, &end)) {
- error(err_sfntnotable, &sf->pos, "hhea");
+ err_sfntnotable(&sf->pos, "hhea");
return;
}
if (decode(t_hhea_decode, ptr, end, &hhea) == NULL) {
- error(err_sfntbadtable, &sf->pos, "hhea");
+ err_sfntbadtable(&sf->pos, "hhea");
return;
}
if ((hhea.version & 0xffff0000) != 0x00010000) {
- error(err_sfnttablevers, &sf->pos, "hhea");
+ err_sfnttablevers(&sf->pos, "hhea");
return;
}
fi->ascent = hhea.ascent;
fi->descent = hhea.descent;
if (hhea.metricDataFormat != 0) {
- error(err_sfnttablevers, &sf->pos, "hmtx");
+ err_sfnttablevers(&sf->pos, "hmtx");
return;
}
if (!sfnt_findtable(sf, TAG_hmtx, &ptr, &end)) {
- error(err_sfntnotable, &sf->pos, "hmtx");
+ err_sfntnotable(&sf->pos, "hmtx");
return;
}
hmtx = snewn(hhea.numOfLongHorMetrics, unsigned);
if (decoden(longhormetric_decode, ptr, end, hmtx, sizeof(*hmtx),
hhea.numOfLongHorMetrics) == NULL) {
- error(err_sfntbadtable, &sf->pos, "hmtx");
+ err_sfntbadtable(&sf->pos, "hmtx");
return;
}
for (i = 0; i < sf->nglyphs; i++) {
fi->descent = OS_2.sTypoDescender * FUNITS_PER_PT / sf->head.unitsPerEm;
return;
bados2:
- error(err_sfntbadtable, &sf->pos, "OS/2");
+ err_sfntbadtable(&sf->pos, "OS/2");
}
/*
}
return;
bad:
- error(err_sfntbadtable, &sf->pos, "kern");
+ err_sfntbadtable(&sf->pos, "kern");
return;
}
for (i = 0; i < lenof(fi->bmp); i++)
fi->bmp[i] = 0xFFFF;
if (!sfnt_findtable(sf, TAG_cmap, &ptr, &end)) {
- error(err_sfntnotable, &sf->pos, "cmap");
+ err_sfntnotable(&sf->pos, "cmap");
}
base = ptr;
ptr = decode(t_cmap_decode, ptr, end, &cmap);
idx = (k + idDelta[j]) & 0xffff;
if (idx != 0) {
if (idx > sf->nglyphs) {
- error(err_sfntbadglyph, &sf->pos, k);
+ err_sfntbadglyph(&sf->pos, k);
continue;
}
fi->bmp[k] = sfnt_indextoglyph(sf, idx);
for (k = startCode[j]; k <= endCode[j]; k++) {
if (startidx + k - startCode[j] >=
nglyphindex) {
- error(err_sfntbadglyph, &sf->pos, k);
+ err_sfntbadglyph(&sf->pos, k);
continue;
}
idx = glyphIndexArray[startidx + k - startCode[j]];
if (idx != 0) {
idx = (idx + idDelta[j]) & 0xffff;
if (idx > sf->nglyphs) {
- error(err_sfntbadglyph, &sf->pos, k);
+ err_sfntbadglyph(&sf->pos, k);
continue;
}
fi->bmp[k] = sfnt_indextoglyph(sf, idx);
}
}
}
- error(err_sfntnounicmap, &sf->pos);
+ err_sfntnounicmap(&sf->pos);
return;
bad:
- error(err_sfntbadtable, &sf->pos, "cmap");
+ err_sfntbadtable(&sf->pos, "cmap");
}
void read_sfnt_file(input *in) {
sf->nglyphs = 0;
ptr = decode(offsubdir_decode, sf->data, sf->end, &sf->osd);
if (ptr == NULL) {
- error(err_sfntbadhdr, &sf->pos);
+ err_sfntbadhdr(&sf->pos);
return;
}
sf->td = snewn(sf->osd.numTables, tabledir);
ptr = decoden(tabledir_decode, ptr, sf->end, sf->td, sizeof(*sf->td),
sf->osd.numTables);
if (ptr == NULL) {
- error(err_sfntbadhdr, &sf->pos);
+ err_sfntbadhdr(&sf->pos);
return;
}
if (!sfnt_findtable(sf, TAG_head, &ptr, &end)) {
- error(err_sfntnotable, &sf->pos, "head");
+ err_sfntnotable(&sf->pos, "head");
return;
}
if (decode(t_head_decode, ptr, end, &sf->head) == NULL) {
- error(err_sfntbadtable, &sf->pos, "head");
+ err_sfntbadtable(&sf->pos, "head");
return;
}
if ((sf->head.version & 0xffff0000) != 0x00010000) {
- error(err_sfnttablevers, &sf->pos, "head");
+ err_sfnttablevers(&sf->pos, "head");
return;
}
if (!sfnt_findtable(sf, TAG_maxp, &ptr, &end)) {
- error(err_sfntnotable, &sf->pos, "maxp");
+ err_sfntnotable(&sf->pos, "maxp");
return;
}
if (decode(t_maxp_decode, ptr, end, &maxp) == NULL) {
- error(err_sfntbadtable, &sf->pos, "maxp");
+ err_sfntbadtable(&sf->pos, "maxp");
return;
}
if (maxp.version < 0x00005000 || maxp.version > 0x0001ffff) {
- error(err_sfnttablevers, &sf->pos, "maxp");
+ err_sfnttablevers(&sf->pos, "maxp");
return;
}
sf->nglyphs = maxp.numGlyphs;
breaks[i] = sf->td[i].offset;
}
if (!sfnt_findtable(sf, TAG_glyf, &glyfptr, &glyfend)) {
- error(err_sfntnotable, &sf->pos, "glyf");
+ err_sfntnotable(&sf->pos, "glyf");
return;
}
glyfoff = (char *)glyfptr - (char *)sf->data;
glyflen = (char *)glyfend - (char *)glyfptr;
if (!sfnt_findtable(sf, TAG_loca, &locaptr, &locaend)) {
- error(err_sfntnotable, &sf->pos, "loca");
+ err_sfntnotable(&sf->pos, "loca");
return;
}
loca = snewn(sf->nglyphs, unsigned);
fprintf(ofp, "end /%s exch definefont\n", fi->name);
return;
badloca:
- error(err_sfntbadtable, &sf->pos, "loca");
+ err_sfntbadtable(&sf->pos, "loca");
}
void sfnt_data(font_info *fi, char **bufp, size_t *lenp) {
* warn (and drop it, since it won't be referenced).
*/
if (is_explicit) {
- error(err_nosuchidxtag, fpos, tags);
+ err_nosuchidxtag(fpos, tags);
continue;
}
* see if the cases match.
*/
if (ustrcmp(t->name, existing->name)) {
- error(err_indexcase, fpos, t->name,
+ err_indexcase(fpos, t->name,
&existing->implicit_fpos, existing->name);
}
m->name = name;
m->text = text;
if (add234(macros, m) != m) {
- error(err_macroexists, &fpos, name);
+ err_macroexists(&fpos, name);
sfree(name);
sfree(text);
}
wtype == word_WeakCode) {
wtype = word_Emph;
} else {
- error(err_brokencodepara, &t.pos);
+ err_brokencodepara(&t.pos);
prev_para_type = par.type;
addpara(par, ret);
while (t.type != tok_eop) /* error recovery: */
*/
dtor(t), t = get_token(in);
if (t.type != tok_lbrace) {
- error(err_explbr, &t.pos);
+ err_explbr(&t.pos);
continue;
}
* don't give a cascade error.
*/
sitem->type = -1;
- error(err_misplacedlcont, &t.pos);
+ err_misplacedlcont(&t.pos);
}
} else {
/*
} else if (t.type == tok_rbrace) {
struct crossparaitem *sitem = stk_pop(crossparastk);
if (!sitem)
- error(err_unexbrace, &t.pos);
+ err_unexbrace(&t.pos);
else {
switch (sitem->type) {
case c_lcont:
needkw = -1;
break;
case c__invalid:
- error(err_badparatype, t.text, &t.pos);
+ err_badparatype(t.text, &t.pos);
needkw = 4;
break;
case c__comment:
par.type == para_UnnumberedChapter) {
struct crossparaitem *sitem = stk_top(crossparastk);
if (sitem && (sitem->seen_lcont || sitem->seen_quote)) {
- error(err_sectmarkerinblock,
- &t.pos,
+ err_sectmarkerinblock( &t.pos,
(sitem->seen_lcont ? "lcont" : "quote"));
}
}
}
}
if (t.type != tok_rbrace) {
- error(err_kwunclosed, &t.pos);
+ err_kwunclosed(&t.pos);
continue;
}
rdadd(&rs, 0); /* add string terminator */
/* See whether we have the right number of keywords. */
if ((needkw & 48) && nkeys > 0)
- error(err_kwillegal, &fp);
+ err_kwillegal(&fp);
if ((needkw & 11) && nkeys == 0)
- error(err_kwexpected, &fp);
+ err_kwexpected(&fp);
if ((needkw & 5) && nkeys > 1)
- error(err_kwtoomany, &fp);
+ err_kwtoomany(&fp);
if (is_macro) {
/*
if (t.type != tok_eop && t.type != tok_eof &&
(start_cmd == c__invalid ||
t.type != tok_cmd || t.cmd != start_cmd)) {
- error(err_bodyillegal, &t.pos);
+ err_bodyillegal(&t.pos);
/* Error recovery: eat the rest of the paragraph */
while (t.type != tok_eop && t.type != tok_eof &&
(start_cmd == c__invalid ||
}
break;
case tok_lbrace:
- error(err_unexbrace, &t.pos);
+ err_unexbrace(&t.pos);
/* Error recovery: push nop */
sitem = snew(struct stack_item);
sitem->type = stack_nop;
*/
dtor(t), t = get_token(in);
if (t.type != tok_lbrace) {
- error(err_explbr, &t.pos);
+ err_explbr(&t.pos);
} else {
int braces = 1;
while (braces > 0) {
else if (t.type == tok_rbrace)
braces--;
else if (t.type == tok_eof) {
- error(err_commenteof, &t.pos);
+ err_commenteof(&t.pos);
break;
}
}
type = t.cmd;
dtor(t), t = get_token(in);
if (t.type != tok_lbrace) {
- error(err_explbr, &t.pos);
+ err_explbr(&t.pos);
} else {
/*
* Enforce that \q may not be used anywhere
}
stype = stack_quote;
} else {
- error(err_codequote, &t.pos);
+ err_codequote(&t.pos);
stype = stack_nop;
}
sitem = snew(struct stack_item);
sitem->type = stype;
if (type == c_cq) {
if (style != word_Normal) {
- error(err_nestedstyles, &t.pos);
+ err_nestedstyles(&t.pos);
} else {
style = word_WeakCode;
spcstyle = tospacestyle(style);
wdtext = ustrftime(NULL, broken);
wd.type = style;
} else {
- error(err_explbr, &t.pos);
+ err_explbr(&t.pos);
wdtext = NULL;
}
} else {
}
sfree(rs.text);
if (t.type != tok_rbrace) {
- error(err_kwexprbr, &t.pos);
+ err_kwexprbr(&t.pos);
}
}
wd.alt = NULL;
if (t.type == tok_cmd &&
(t.cmd == c_i || t.cmd == c_ii)) {
if (indexing) {
- error(err_nestedindex, &t.pos);
+ err_nestedindex(&t.pos);
} else {
/* Add an index-reference word with no
* text as yet */
if (t.type == tok_cmd &&
(t.cmd == c_e || t.cmd == c_c || t.cmd == c_cw)) {
if (style != word_Normal)
- error(err_nestedstyles, &t.pos);
+ err_nestedstyles(&t.pos);
else {
style = (t.cmd == c_c ? word_Code :
t.cmd == c_cw ? word_WeakCode :
dtor(t), t = get_token(in);
}
if (t.type != tok_lbrace) {
- error(err_explbr, &t.pos);
+ err_explbr(&t.pos);
sfree(sitem);
} else {
stk_push(parsestk, sitem);
case c_e:
type = t.cmd;
if (style != word_Normal) {
- error(err_nestedstyles, &t.pos);
+ err_nestedstyles(&t.pos);
/* Error recovery: eat lbrace, push nop. */
dtor(t), t = get_token(in);
sitem = snew(struct stack_item);
}
dtor(t), t = get_token(in);
if (t.type != tok_lbrace) {
- error(err_explbr, &t.pos);
+ err_explbr(&t.pos);
} else {
style = (type == c_c ? word_Code :
type == c_cw ? word_WeakCode :
case c_I:
type = t.cmd;
if (indexing) {
- error(err_nestedindex, &t.pos);
+ err_nestedindex(&t.pos);
/* Error recovery: eat lbrace, push nop. */
dtor(t), t = get_token(in);
sitem = snew(struct stack_item);
if (t.type == tok_cmd &&
(t.cmd == c_e || t.cmd == c_c || t.cmd == c_cw)) {
if (style != word_Normal)
- error(err_nestedstyles, &t.pos);
+ err_nestedstyles(&t.pos);
else {
style = (t.cmd == c_c ? word_Code :
t.cmd == c_cw ? word_WeakCode :
}
if (t.type != tok_lbrace) {
sfree(sitem);
- error(err_explbr, &t.pos);
+ err_explbr(&t.pos);
} else {
/* Add an index-reference word with no text as yet */
wd.type = word_IndexRef;
break;
default:
if (!macrolookup(macros, in, t.text, &t.pos))
- error(err_badmidcmd, t.text, &t.pos);
+ err_badmidcmd(t.text, &t.pos);
break;
}
}
if (stk_top(parsestk)) {
while ((sitem = stk_pop(parsestk)))
sfree(sitem);
- error(err_missingrbrace, &t.pos);
+ err_missingrbrace(&t.pos);
}
stk_free(parsestk);
prev_para_type = par.type;
if (stk_top(crossparastk)) {
void *p;
- error(err_missingrbrace2, &t.pos);
+ err_missingrbrace2(&t.pos);
while ((p = stk_pop(crossparastk)))
sfree(p);
}
kw->para = source;
ret = add234(kl->keys, kw);
if (ret != kw) {
- error(err_multikw, &source->fpos, &ret->para->fpos, p);
+ err_multikw(&source->fpos, &ret->para->fpos, p);
sfree(kw);
/* FIXME: what happens to kw->text? Does it leak? */
}
kw = kw_lookup(kl, ptr->text);
if (!kw) {
- error(err_nosuchkw, &ptr->fpos, ptr->text);
+ err_nosuchkw(&ptr->fpos, ptr->text);
subst = NULL;
} else
subst = dup_word_list(kw->text);
/* do nothing */;
} else if (!strcmp(opt, "-input-charset")) {
if (!val) {
- errs = TRUE, error(err_optnoarg, opt);
+ errs = TRUE, err_optnoarg(opt);
} else {
int charset = charset_from_localenc(val);
if (charset == CS_NONE) {
- errs = TRUE, error(err_cmdcharset, val);
+ errs = TRUE, err_cmdcharset(val);
} else {
input_charset = charset;
}
} else if (!strcmp(opt, "-precise")) {
reportcols = 1;
} else {
- errs = TRUE, error(err_nosuchopt, opt);
+ errs = TRUE, err_nosuchopt(opt);
}
}
p = NULL;
char opt[2];
opt[0] = c;
opt[1] = '\0';
- errs = TRUE, error(err_optnoarg, opt);
+ errs = TRUE, err_optnoarg(opt);
}
/*
* Now c is the option and p is the parameter.
*r = '\0';
/* XXX ad-hoc diagnostic */
if (!strcmp(s, "input-charset"))
- error(err_futileopt, "Cinput-charset",
+ err_futileopt("Cinput-charset",
"; use --input-charset");
cmdline_cfg_add(para, s);
r = s;
char opt[2];
opt[0] = c;
opt[1] = '\0';
- errs = TRUE, error(err_nosuchopt, opt);
+ errs = TRUE, err_nosuchopt(opt);
}
}
}
* Do the work.
*/
if (nfiles == 0 && !list_fonts) {
- error(err_noinput);
+ err_noinput();
usage();
exit(EXIT_FAILURE);
}
file, line, (long)size));
p = malloc(size);
if (!p)
- fatal(err_nomemory);
+ fatalerr_nomemory();
LOGPRINT((" returns %p\n", p));
return p;
}
LOGPRINT((" returns %p\n", q));
}
if (!q)
- fatal(err_nomemory);
+ fatalerr_nomemory();
return q;
}
if (charset == CS_NONE) {
charset = CS_ASCII;
- error(err_charset, fpos, name);
+ err_charset(fpos, name);
}
sfree(csname);