diff --git a/src/ld65/error.c b/src/ld65/error.c index 344e4c1b3..0714d9902 100644 --- a/src/ld65/error.c +++ b/src/ld65/error.c @@ -43,6 +43,7 @@ /* ld65 */ #include "error.h" +#include "spool.h" @@ -121,3 +122,43 @@ void Internal (const char* Format, ...) exit (EXIT_FAILURE); } + + + +void CfgWarning (const FilePos* Pos, const char* Format, ...) +/* Print a warning message adding file name and line number of a given file */ +{ + StrBuf Buf = STATIC_STRBUF_INITIALIZER; + va_list ap; + + va_start (ap, Format); + SB_VPrintf (&Buf, Format, ap); + va_end (ap); + + Warning ("%s:%u: %s", + GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf)); + SB_Done (&Buf); + + /* Count warnings */ + ++WarningCount; +} + + + +void CfgError (const FilePos* Pos, const char* Format, ...) +/* Print an error message adding file name and line number of a given file */ +{ + StrBuf Buf = STATIC_STRBUF_INITIALIZER; + va_list ap; + + va_start (ap, Format); + SB_VPrintf (&Buf, Format, ap); + va_end (ap); + + Error ("%s:%u: %s", + GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf)); + SB_Done (&Buf); +} + + + diff --git a/src/ld65/error.h b/src/ld65/error.h index 1285ca725..dcc0e6c4f 100644 --- a/src/ld65/error.h +++ b/src/ld65/error.h @@ -40,6 +40,7 @@ /* common */ #include "attrib.h" +#include "filepos.h" @@ -69,6 +70,12 @@ void Error (const char* Format, ...) attribute((noreturn, format(printf,1,2))); void Internal (const char* Format, ...) attribute((noreturn, format(printf,1,2))); /* Print an internal error message and die */ +void CfgWarning (const FilePos* Pos, const char* Format, ...) attribute((format(printf,2,3))); +/* Print a warning message adding file name and line number of the config file */ + +void CfgError (const FilePos* Pos, const char* Format, ...) attribute((format(printf,2,3))); +/* Print an error message adding file name and line number of a given file */ + /* End of error.h */ diff --git a/src/ld65/scanner.c b/src/ld65/scanner.c index 5f53e5765..80b017996 100644 --- a/src/ld65/scanner.c +++ b/src/ld65/scanner.c @@ -76,49 +76,6 @@ static FILE* InputFile = 0; -/*****************************************************************************/ -/* Error handling */ -/*****************************************************************************/ - - - -void CfgWarning (const FilePos* Pos, const char* Format, ...) -/* Print a warning message adding file name and line number of a given file */ -{ - StrBuf Buf = STATIC_STRBUF_INITIALIZER; - va_list ap; - - va_start (ap, Format); - SB_VPrintf (&Buf, Format, ap); - va_end (ap); - - Warning ("%s:%u: %s", - GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf)); - SB_Done (&Buf); - - /* Count warnings */ - ++WarningCount; -} - - - -void CfgError (const FilePos* Pos, const char* Format, ...) -/* Print an error message adding file name and line number of a given file */ -{ - StrBuf Buf = STATIC_STRBUF_INITIALIZER; - va_list ap; - - va_start (ap, Format); - SB_VPrintf (&Buf, Format, ap); - va_end (ap); - - Error ("%s:%u: %s", - GetString (Pos->Name), Pos->Line, SB_GetConstBuf (&Buf)); - SB_Done (&Buf); -} - - - /*****************************************************************************/ /* Code */ /*****************************************************************************/ diff --git a/src/ld65/scanner.h b/src/ld65/scanner.h index aeabbdca8..acc23d323 100644 --- a/src/ld65/scanner.h +++ b/src/ld65/scanner.h @@ -186,12 +186,6 @@ extern FilePos CfgErrorPos; -void CfgWarning (const FilePos* Pos, const char* Format, ...) attribute((format(printf,2,3))); -/* Print a warning message adding file name and line number of the config file */ - -void CfgError (const FilePos* Pos, const char* Format, ...) attribute((format(printf,2,3))); -/* Print an error message adding file name and line number of a given file */ - void CfgNextTok (void); /* Read the next token from the input stream */