X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fld65%2Ferror.c;h=3fea97fdcf05520ad77a48aa383e6b825e2dcff6;hb=0807da74bd7c3ebe3e6e75129a07a810b17174b2;hp=53b06d16bdffcbe60bf815093f3a92c576b08684;hpb=a20f4dd8c8fc6b234758c6f343f8a419d319f26c;p=cc65 diff --git a/src/ld65/error.c b/src/ld65/error.c index 53b06d16b..3fea97fdc 100644 --- a/src/ld65/error.c +++ b/src/ld65/error.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 1998-2008 Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -37,23 +37,12 @@ #include #include -#include "error.h" - - - -/*****************************************************************************/ -/* Data */ -/*****************************************************************************/ - - +/* common */ +#include "cmdline.h" +#include "strbuf.h" -/* Messages for internal compiler errors */ -const char _MsgCheckFailed [] = - "Check failed: `%s' (= %d), file `%s', line %u\n"; -const char _MsgPrecondition [] = - "Precondition violated: `%s' (= %d), file `%s', line %u\n"; -const char _MsgFail [] = - "%s, file `%s', line %u\n"; +/* ld65 */ +#include "error.h" @@ -66,12 +55,17 @@ const char _MsgFail [] = void Warning (const char* Format, ...) /* Print a warning message */ { + StrBuf S = STATIC_STRBUF_INITIALIZER; va_list ap; + va_start (ap, Format); - fprintf (stderr, "Warning: "); - vfprintf (stderr, Format, ap); - putc ('\n', stderr); + SB_VPrintf (&S, Format, ap); va_end (ap); + SB_Terminate (&S); + + fprintf (stderr, "%s: Warning: %s\n", ProgName, SB_GetConstBuf (&S)); + + SB_Done (&S); } @@ -79,12 +73,18 @@ void Warning (const char* Format, ...) void Error (const char* Format, ...) /* Print an error message and die */ { + StrBuf S = STATIC_STRBUF_INITIALIZER; va_list ap; + va_start (ap, Format); - fprintf (stderr, "Error: "); - vfprintf (stderr, Format, ap); - putc ('\n', stderr); + SB_VPrintf (&S, Format, ap); va_end (ap); + SB_Terminate (&S); + + fprintf (stderr, "%s: Error: %s\n", ProgName, SB_GetConstBuf (&S)); + + SB_Done (&S); + exit (EXIT_FAILURE); } @@ -93,12 +93,18 @@ void Error (const char* Format, ...) void Internal (const char* Format, ...) /* Print an internal error message and die */ { + StrBuf S = STATIC_STRBUF_INITIALIZER; va_list ap; + va_start (ap, Format); - fprintf (stderr, "Internal error: "); - vfprintf (stderr, Format, ap); - putc ('\n', stderr); + SB_VPrintf (&S, Format, ap); va_end (ap); + SB_Terminate (&S); + + fprintf (stderr, "%s: Internal Error: %s\n", ProgName, SB_GetConstBuf (&S)); + + SB_Done (&S); + exit (EXIT_FAILURE); }