/* Handle errors.
- Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation,
+ Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
Inc.
Contributed by Andy Vaught & Niels Kristian Bech Jensen
#include "config.h"
#include "system.h"
-
-#include <string.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "flags.h"
#include "gfortran.h"
void
gfc_error_init_1 (void)
{
-
- terminal_width = gfc_terminal_width();
+ terminal_width = gfc_terminal_width ();
errors = 0;
warnings = 0;
buffer_flag = 0;
void
gfc_buffer_error (int flag)
{
-
buffer_flag = flag;
}
static void
error_char (char c)
{
-
if (buffer_flag)
{
if (use_warning_buffer)
else
{
if (c != 0)
- fputc (c, stderr);
+ {
+ /* We build up complete lines before handing things
+ over to the library in order to speed up error printing. */
+ static char line[MAX_ERROR_MESSAGE + 1];
+ static int index = 0;
+
+ line[index++] = c;
+ if (c == '\n' || index == MAX_ERROR_MESSAGE)
+ {
+ line[index] = '\0';
+ fputs (line, stderr);
+ index = 0;
+ }
+ }
}
}
static void
error_string (const char *p)
{
-
while (*p)
error_char (*p++);
}
-/* Show the file, where it was included and the source line give a
+/* Show the file, where it was included and the source line, give a
locus. Calls error_printf() recursively, but the recursion is at
most one level deep. */
lb = loc->lb;
f = lb->file;
- error_printf ("In file %s:%d\n", f->filename, lb->linenum);
+ error_printf ("In file %s:%d\n", f->filename,
+#ifdef USE_MAPPED_LOCATION
+ LOCATION_LINE (lb->location)
+#else
+ lb->linenum
+#endif
+ );
for (;;)
{
case 'C':
if (c == 'C')
- loc = gfc_current_locus ();
+ loc = &gfc_current_locus;
if (have_l1)
{
/* Possibly issue a warning/error about use of a nonstandard (or deleted)
feature. An error/warning will be issued if the currently selected
standard does not contain the requested bits. Return FAILURE if
- and error is generated. */
+ an error is generated. */
try
gfc_notify_std (int std, const char *format, ...)
void
gfc_clear_warning (void)
{
-
warning_buffer.flag = 0;
}
void
gfc_warning_check (void)
{
-
if (warning_buffer.flag)
{
warnings++;
va_start (argp, format);
- show_loci (gfc_current_locus (), NULL);
+ show_loci (&gfc_current_locus, NULL);
error_printf ("Internal Error at (1):");
error_print ("", format, argp);
void
gfc_clear_error (void)
{
-
error_buffer.flag = 0;
}
void
gfc_push_error (gfc_error_buf * err)
{
-
err->flag = error_buffer.flag;
if (error_buffer.flag)
strcpy (err->message, error_buffer.message);
void
gfc_pop_error (gfc_error_buf * err)
{
-
error_buffer.flag = err->flag;
if (error_buffer.flag)
strcpy (error_buffer.message, err->message);
}
-/* Report the number of warnings and errors that occored to the caller. */
+/* Report the number of warnings and errors that occurred to the caller. */
void
gfc_get_errors (int *w, int *e)
{
-
if (w != NULL)
*w = warnings;
if (e != NULL)