X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fca65%2Ferror.c;h=06bbf26153bf48b3d3f84e68b8acbbffa21733b4;hb=88855545e40bc95d09b5e5e8d4b94acc40a20b52;hp=fc984268bf60d373234d77d001698d4704e06d83;hpb=faea6dd29ccd859dbb79519fb98000f408da7c3b;p=cc65 diff --git a/src/ca65/error.c b/src/ca65/error.c index fc984268b..06bbf2615 100644 --- a/src/ca65/error.c +++ b/src/ca65/error.c @@ -7,7 +7,7 @@ /* */ /* */ /* (C) 1998-2003 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ +/* Römerstraße 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ @@ -51,7 +51,7 @@ /* Warning level */ -unsigned WarnLevel = 1; +unsigned WarnLevel = 1; /* Statistics */ unsigned ErrorCount = 0; @@ -65,23 +65,13 @@ unsigned WarningCount = 0; -void WarningMsg (const FilePos* Pos, unsigned WarnNum, va_list ap) +void WarningMsg (const FilePos* Pos, unsigned Level, const char* Format, va_list ap) /* Print warning message. */ { - static const struct { - unsigned char Level; - const char* Msg; - } Warnings [WARN_COUNT-1] = { - { 2, "Symbol `%s' is defined but never used" }, - { 2, "Symbol `%s' is imported but never used" }, - { 1, "Cannot track processor status byte" }, - { 0, "User warning: %s" }, - }; - - if (Warnings [WarnNum-1].Level <= WarnLevel) { - fprintf (stderr, "%s(%lu): Warning #%u: ", - GetFileName (Pos->Name), Pos->Line, WarnNum); - vfprintf (stderr, Warnings [WarnNum-1].Msg, ap); + if (Level <= WarnLevel) { + fprintf (stderr, "%s(%lu): Warning: ", + GetFileName (Pos->Name), Pos->Line); + vfprintf (stderr, Format, ap); fprintf (stderr, "\n"); ++WarningCount; } @@ -89,23 +79,23 @@ void WarningMsg (const FilePos* Pos, unsigned WarnNum, va_list ap) -void Warning (unsigned WarnNum, ...) +void Warning (unsigned Level, const char* Format, ...) /* Print warning message. */ { va_list ap; - va_start (ap, WarnNum); - WarningMsg (&CurPos, WarnNum, ap); + va_start (ap, Format); + WarningMsg (&CurPos, Level, Format, ap); va_end (ap); } -void PWarning (const FilePos* Pos, unsigned WarnNum, ...) +void PWarning (const FilePos* Pos, unsigned Level, const char* Format, ...) /* Print warning message giving an explicit file and position. */ { va_list ap; - va_start (ap, WarnNum); - WarningMsg (Pos, WarnNum, ap); + va_start (ap, Format); + WarningMsg (Pos, Level, Format, ap); va_end (ap); } @@ -117,120 +107,46 @@ void PWarning (const FilePos* Pos, unsigned WarnNum, ...) -void ErrorMsg (const FilePos* Pos, unsigned ErrNum, va_list ap) +void ErrorMsg (const FilePos* Pos, const char* Format, va_list ap) /* Print an error message */ { - static const char* Msgs [ERR_COUNT-1] = { - "Command/operation not implemented", - "Cannot open include file `%s': %s", - "Cannot read from include file `%s': %s", - "Include nesting too deep", - "Invalid input character: %02X", - "Hex digit expected", - "Digit expected", - "`0' or `1' expected", - "Numerical overflow", - "Control statement expected", - "Too many characters", - "`:' expected", - "`(' expected", - "`)' expected", - "`]' expected", - "`,' expected", - "Boolean switch value expected (on/off/+/-)", - "`Y' expected", - "`X' expected", - "Integer constant expected", - "String constant expected", - "Character constant expected", - "Constant expression expected", - "Identifier expected", - "`.ENDMACRO' expected", - "Option key expected", - "`=' expected", - "Command is only valid in 65816 mode", - "User error: %s", - "String constant too long", - "Newline in string constant", - "Illegal character constant", - "Illegal addressing mode", - "Illegal character to start local symbols", - "Illegal use of local symbol", - "Illegal segment name: `%s'", - "Illegal segment attribute", - "Illegal macro package name", - "Illegal emulation feature", - "Illegal scope specifier", - "Syntax error", - "Symbol `%s' is already defined", - "Undefined symbol `%s'", - "Symbol `%s' is already marked as import", - "Symbol `%s' is already marked as export", - "Exported symbol `%s' is undefined", - "Exported values must be constant", - "Unexpected end of file", - "Unexpected end of line", - "Unexpected `%s'", - "Division by zero", - "Modulo operation with zero", - "Range error", - "Too many macro parameters", - "Macro parameter expected", - "Circular reference in symbol definition", - "Symbol `%s' redeclaration mismatch", - "Alignment value must be a power of 2", - "Duplicate `.ELSE'", - "Conditional assembly branch was never closed", - "Lexical level was not terminated correctly", - "No open lexical level", - "Segment attribute mismatch", - "Segment stack overflow", - "Segment stack is empty", - "Segment stack is not empty at end of assembly", - "CPU not supported", - "Counter underflow", - "Undefined label", - "Open `%s'", - "File name `%s' not found in file table", - }; - - fprintf (stderr, "%s(%lu): Error #%u: ", - GetFileName (Pos->Name), Pos->Line, ErrNum); - vfprintf (stderr, Msgs [ErrNum-1], ap); + fprintf (stderr, "%s(%lu): Error: ", + GetFileName (Pos->Name), Pos->Line); + vfprintf (stderr, Format, ap); fprintf (stderr, "\n"); ++ErrorCount; } -void Error (unsigned ErrNum, ...) +void Error (const char* Format, ...) /* Print an error message */ { va_list ap; - va_start (ap, ErrNum); - ErrorMsg (&CurPos, ErrNum, ap); + va_start (ap, Format); + ErrorMsg (&CurPos, Format, ap); va_end (ap); } -void PError (const FilePos* Pos, unsigned ErrNum, ...) +void PError (const FilePos* Pos, const char* Format, ...) /* Print an error message giving an explicit file and position. */ { va_list ap; - va_start (ap, ErrNum); - ErrorMsg (Pos, ErrNum, ap); + va_start (ap, Format); + ErrorMsg (Pos, Format, ap); va_end (ap); } -void ErrorSkip (unsigned ErrNum, ...) +void ErrorSkip (const char* Format, ...) /* Print an error message and skip the rest of the line */ { va_list ap; - va_start (ap, ErrNum); - ErrorMsg (&CurPos, ErrNum, ap); + va_start (ap, Format); + ErrorMsg (&CurPos, Format, ap); va_end (ap); SkipUntilSep (); @@ -244,30 +160,14 @@ void ErrorSkip (unsigned ErrNum, ...) -void Fatal (unsigned FatNum, ...) +void Fatal (const char* Format, ...) /* Print a message about a fatal error and die */ { - static const char* Msgs [FAT_COUNT-1] = { - "Maximum number of input files reached", - "Out of memory", - "Too many segments", - "String too long", - "Cannot open input file `%s': %s", - "Cannot stat input file `%s': %s", - "Cannot open output file `%s': %s", - "Cannot write to output file `%s': %s", - "Cannot open listing file: %s", - "Cannot write to listing file: %s", - "Cannot read from listing file: %s", - "Too many nested constructs", - ".IF nesting too deep", - "Too many symbols", - }; va_list ap; - va_start (ap, FatNum); - fprintf (stderr, "Fatal #%u: ", FatNum); - vfprintf (stderr, Msgs [FatNum-1], ap); + va_start (ap, Format); + fprintf (stderr, "Fatal error: "); + vfprintf (stderr, Format, ap); fprintf (stderr, "\n"); va_end (ap); @@ -282,7 +182,7 @@ void Internal (const char* Format, ...) { va_list ap; va_start (ap, Format); - fprintf (stderr, "Internal assembler error\n"); + fprintf (stderr, "Internal assembler error:\n"); vfprintf (stderr, Format, ap); va_end (ap); fprintf (stderr, "\n");