/* messages.c - error reporter -
- Copyright (C) 1987, 1991 Free Software Foundation, Inc.
-
+ Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
+
This file is part of GAS, the GNU Assembler.
-
+
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* $Id$ */
-
#include <stdio.h> /* define stderr */
#include <errno.h>
/*
ERRORS
-
+
JF: this is now bogus. We now print more standard error messages
that try to look like everyone else's.
-
+
We print the error message 1st, beginning in column 1.
All ancillary info starts in column 2 on lines after the
key error text.
just after the main error text.
Caller then prints any appendices after that, begining all
lines with at least 1 space.
-
+
Optionally, we may die.
There is no need for a trailing '\n' in your error text format
because we supply one.
-
+
as_warn(fmt,args) Like fprintf(stderr,fmt,args) but also call errwhere().
-
+
as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
-
- */
+
+ */
static int warning_count = 0; /* Count of number of warnings issued */
char *gripe; /* Unpunctuated error theme. */
char *filename;
{
- extern int sys_nerr;
- extern char *sys_errlist[];
+#ifndef HAVE_STRERROR
+ extern char *strerror();
+#endif /* HAVE_STRERROR */
as_where();
- fprintf(stderr,gripe,filename);
-
- if (errno > sys_nerr)
- fprintf(stderr, "Unknown error #%d.\n", errno);
- else
- fprintf(stderr, "%s.\n", sys_errlist[errno]);
+ fprintf(stderr, gripe, filename);
+ fprintf(stderr, "%s.\n", strerror(errno));
errno = 0; /* After reporting, clear it. */
} /* as_perror() */
*/
#ifndef NO_STDARG
-void as_tsktsk(Format)
-const char *Format;
+void as_tsktsk(const char *Format, ...)
{
va_list args;
#endif /* not NO_VARARGS */
#endif /* not NO_STDARG */
-#ifdef DONTDEF
-void as_tsktsk(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
-char *format;
-{
- as_where();
- fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
- (void)putc('\n',stderr);
-} /* as_tsktsk() */
-#endif
/*
* a s _ w a r n ()
*
*/
#ifndef NO_STDARG
-void as_warn(Format)
-const char *Format;
+void as_warn(const char *Format, ...)
{
va_list args;
+ char buffer[200];
if(!flagseen['W']) {
++warning_count;
as_where();
va_start(args, Format);
- vfprintf(stderr, Format, args);
+ fprintf(stderr,"Warning: ");
+ vsprintf(buffer, Format, args);
+ fprintf(stderr, buffer);
+#ifndef NO_LISTING
+ listing_warning(buffer);
+#endif
va_end(args);
(void) putc('\n', stderr);
}
va_dcl
{
va_list args;
+ char buffer[200];
if(!flagseen['W']) {
++warning_count;
as_where();
va_start(args);
- vfprintf(stderr, Format, args);
+ fprintf(stderr,"Warning: ");
+ vsprintf(buffer, Format, args);
+ fprintf(stderr,buffer);
+#ifndef NO_LISTING
+ listing_warning(buffer);
+#endif
va_end(args);
(void) putc('\n', stderr);
}
#endif /* not NO_VARARGS */
#endif /* not NO_STDARG */
-#ifdef DONTDEF
-void as_warn(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
-char *format;
-{
- if(!flagseen['W']) {
- ++warning_count;
- as_where();
- fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
- (void)putc('\n',stderr);
- }
-} /* as_warn() */
-#endif
/*
* a s _ b a d ()
*
*/
#ifndef NO_STDARG
-void as_bad(Format)
-const char *Format;
+void as_bad(const char *Format, ...)
{
va_list args;
-
+ char buffer[200];
+
++error_count;
as_where();
va_start(args, Format);
- vfprintf(stderr, Format, args);
+ fprintf(stderr,"Error: ");
+
+ vsprintf(buffer, Format, args);
+ fprintf(stderr,buffer);
+#ifndef NO_LISTING
+ listing_error(buffer);
+#endif
va_end(args);
(void) putc('\n', stderr);
} /* as_bad() */
va_dcl
{
va_list args;
-
+ char buffer[200];
+
++error_count;
as_where();
va_start(args);
- vfprintf(stderr, Format, args);
+ vsprintf(buffer, Format, args);
+ fprintf(stderr,buffer);
+#ifndef NO_LISTING
+ listing_error(buffer);
+#endif
+
va_end(args);
(void) putc('\n', stderr);
-} /* as_bad() */
+} /* as_bad() */
#else
/*VARARGS1 */
as_bad(Format,args)
char *Format;
{
++error_count;
+
as_where();
+ fprintf(stderr,"Error: ");
_doprnt (Format, &args, stderr);
(void)putc ('\n', stderr);
/* as_where(); */
#endif /* not NO_VARARGS */
#endif /* not NO_STDARG */
-#ifdef DONTDEF
-void as_bad(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
-char *format;
-{
- ++error_count;
- as_where();
- fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
- (void)putc('\n',stderr);
-} /* as_bad() */
-#endif
-
/*
* a s _ f a t a l ()
*
*/
#ifndef NO_STDARG
-void as_fatal(Format)
-const char *Format;
+void as_fatal(const char *Format, ...)
{
va_list args;
-
+
as_where();
va_start(args, Format);
fprintf (stderr, "FATAL:");
vfprintf(stderr, Format, args);
(void) putc('\n', stderr);
va_end(args);
- exit(42);
+ exit(33);
} /* as_fatal() */
#else
#ifndef NO_VARARGS
va_dcl
{
va_list args;
-
+
as_where();
va_start(args);
fprintf (stderr, "FATAL:");
vfprintf(stderr, Format, args);
(void) putc('\n', stderr);
va_end(args);
- exit(42);
+ exit(33);
} /* as_fatal() */
#else
/*VARARGS1 */
_doprnt (Format, &args, stderr);
(void)putc ('\n', stderr);
/* as_where(); */
- exit(42); /* What is a good exit status? */
+ exit(33); /* What is a good exit status? */
} /* as_fatal() */
#endif /* not NO_VARARGS */
#endif /* not NO_STDARG */
-#ifdef DONTDEF
-void as_fatal(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
-char *Format;
-{
- as_where();
- fprintf (stderr, "FATAL:");
- fprintf(stderr, Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
- (void) putc('\n', stderr);
- exit(42);
-} /* as_fatal() */
-#endif
-
-/* end: messages.c */
+/* end of messages.c */