-const char *progname, *filename;
-int lineno;
-
-int nerrors = 0;
-int nwarnings = 0;
-
-static char where[200];
-
-enum {
- /* Use exactly one of these: */
- E_NOFILE = 0, /* "progname: " */
- E_FILE = 1, /* "filename: " */
- E_FILELINE = 2, /* "filename:lineno: " */
- E_FILEWHERE = 3, /* "filename:%s: " -- set %s with ewhere() */
-
- /* Add in any of these with |': */
- E_WARNING = 0x10,
- E_PERROR = 0x20
-};
-
-void ewhere (const char *format, ...);
-void einfo (int type, const char *format, ...);
-
-
-void
-ewhere (const char *format, ...) {
- va_list args;
- va_start (args, format);
- vsprintf (where, format, args);
- va_end (args);
-}
-
-
-void
-einfo (int type, const char *format, ...) {
- va_list args;
-
- switch (type & 0x0f) {
- case E_NOFILE:
- fprintf (stderr, "%s: ", progname);
- break;
- case E_FILE:
- fprintf (stderr, "%s: ", filename);
- break;
- case E_FILELINE:
- ewhere ("%d", lineno);
- /* fall-through */
- case E_FILEWHERE:
- fprintf (stderr, "%s:%s: ", filename, where);
- break;
- }
-
- if (type & E_WARNING) {
- fprintf (stderr, "warning: ");
- nwarnings++;
- } else {
- nerrors++;
- }
-
- va_start (args, format);
- vfprintf (stderr, format, args);
- va_end (args);
-
- if (type & E_PERROR)
- perror ("");
- else
- fprintf (stderr, "\n");
-}
-