//
// Error.cc
//
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
-#ifdef __GNUC__
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include <stdio.h>
#include <stddef.h>
#include <stdarg.h>
-#include "gtypes.h"
-#include "Params.h"
+#include "GlobalParams.h"
#include "Error.h"
-// Send error messages to /dev/tty instead of stderr.
-GBool errorsToTTY = gFalse;
-
-// File to send error (and other) messages to.
-FILE *errFile;
-
-void errorInit() {
- if (!errorsToTTY || !(errFile = fopen("/dev/tty", "w")))
- errFile = stderr;
-}
-
void CDECL error(int pos, char *msg, ...) {
va_list args;
- if (printCommands)
- fflush(stdout);
- if (pos >= 0)
- fprintf(errFile, "Error (%d): ", pos);
- else
- fprintf(errFile, "Error: ");
+ // NB: this can be called before the globalParams object is created
+ if (globalParams && globalParams->getErrQuiet()) {
+ return;
+ }
+ if (pos >= 0) {
+ fprintf(stderr, "Error (%d): ", pos);
+ } else {
+ fprintf(stderr, "Error: ");
+ }
va_start(args, msg);
- vfprintf(errFile, msg, args);
+ vfprintf(stderr, msg, args);
va_end(args);
- fprintf(errFile, "\n");
- fflush(errFile);
+ fprintf(stderr, "\n");
+ fflush(stderr);
}