Move the functions to output config file errors from scanner.c to error.c.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user