+ va_list args;
+ char buffer[2000];
+
+ va_start (args, format);
+ vsnprintf (buffer, sizeof (buffer), format, args);
+ va_end (args);
+
+ as_bad_internal ((char *) NULL, 0, buffer);
+}
+
+/* Like as_bad but the file name and line number are passed in.
+ Unfortunately, we have to repeat the function in order to handle
+ the varargs correctly and portably. */
+
+void
+as_bad_where (const char *file, unsigned int line, const char *format, ...)
+{
+ va_list args;
+ char buffer[2000];
+
+ va_start (args, format);
+ vsnprintf (buffer, sizeof (buffer), format, args);
+ va_end (args);
+
+ as_bad_internal (file, line, buffer);
+}
+
+/* Send to stderr a string as a fatal message, and print location of
+ error in input file(s).
+ Please only use this for when we DON'T have some recovery action.
+ It xexit()s with a warning status. */
+
+void
+as_fatal (const char *format, ...)
+{
+ va_list args;
+
+ as_show_where ();
+ va_start (args, format);
+ fprintf (stderr, _("Fatal error: "));
+ vfprintf (stderr, format, args);
+ (void) putc ('\n', stderr);
+ va_end (args);
+ /* Delete the output file, if it exists. This will prevent make from
+ thinking that a file was created and hence does not need rebuilding. */
+ if (out_file_name != NULL)
+ unlink_if_ordinary (out_file_name);
+ xexit (EXIT_FAILURE);
+}
+
+/* Indicate internal constency error.
+ Arguments: Filename, line number, optional function name.
+ FILENAME may be NULL, which we use for crash-via-signal. */
+
+void
+as_abort (const char *file, int line, const char *fn)
+{
+ as_show_where ();
+
+ if (!file)
+ fprintf (stderr, _("Internal error (%s).\n"), fn ? fn : "unknown");
+ else if (fn)
+ fprintf (stderr, _("Internal error in %s at %s:%d.\n"), fn, file, line);
+ else
+ fprintf (stderr, _("Internal error at %s:%d.\n"), file, line);
+
+ fprintf (stderr, _("Please report this bug.\n"));
+
+ xexit (EXIT_FAILURE);
+}
+
+/* Handler for fatal signals, such as SIGSEGV. */
+
+static void
+signal_crash (int signo)
+{
+ /* Reset, to prevent unbounded recursion. */
+ signal (signo, SIG_DFL);
+
+ as_abort (NULL, 0, strsignal (signo));
+}
+
+/* Register signal handlers, for less abrubt crashes. */
+
+void
+signal_init (void)
+{
+#ifdef SIGSEGV
+ signal (SIGSEGV, signal_crash);
+#endif
+#ifdef SIGILL
+ signal (SIGILL, signal_crash);
+#endif
+#ifdef SIGBUS
+ signal (SIGBUS, signal_crash);
+#endif
+#ifdef SIGABRT
+ signal (SIGABRT, signal_crash);
+#endif
+#if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
+ signal (SIGIOT, signal_crash);
+#endif
+#ifdef SIGFPE
+ signal (SIGFPE, signal_crash);