#include <stdlib.h>
#include <stdarg.h>
+/* common */
+#include "print.h"
+
+/* cc65 */
#include "global.h"
#include "input.h"
+#include "lineinfo.h"
#include "scanner.h"
#include "stmt.h"
#include "error.h"
vfprintf (stderr, Msg, ap);
fprintf (stderr, "\n");
- if (Verbose) {
- fprintf (stderr, "Line: %s\n", line);
- }
+ Print (stderr, 1, "Line: %s\n", line);
++WarningCount;
}
}
{
va_list ap;
va_start (ap, Format);
- IntWarning (GetCurrentFile(), curpos, Format, ap);
+ IntWarning (GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Format, ap);
va_end (ap);
}
vfprintf (stderr, Msg, ap);
fprintf (stderr, "\n");
- if (Verbose) {
- fprintf (stderr, "Line: %s\n", line);
- }
+ Print (stderr, 1, "Line: %s\n", line);
++ErrorCount;
if (ErrorCount > 10) {
Fatal ("Too many errors");
{
va_list ap;
va_start (ap, Format);
- IntError (GetCurrentFile(), curpos, Format, ap);
+ IntError (GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Format, ap);
va_end (ap);
}
{
va_list ap;
- fprintf (stderr, "%s(%u): Fatal: ", GetCurrentFile(), curpos);
+ const char* FileName;
+ unsigned LineNum;
+ if (CurTok.LI) {
+ FileName = GetInputName (CurTok.LI);
+ LineNum = GetInputLine (CurTok.LI);
+ } else {
+ FileName = GetCurrentFile ();
+ LineNum = GetCurrentLine ();
+ }
+
+ fprintf (stderr, "%s(%u): Fatal: ", FileName, LineNum);
va_start (ap, Format);
vfprintf (stderr, Format, ap);
va_end (ap);
fprintf (stderr, "\n");
- if (Verbose) {
- fprintf (stderr, "Line: %s\n", line);
- }
+ Print (stderr, 1, "Line: %s\n", line);
exit (EXIT_FAILURE);
}
-void Internal (char* Format, ...)
+void Internal (const char* Format, ...)
/* Print a message about an internal compiler error and die. */
{
va_list ap;
+ const char* FileName;
+ unsigned LineNum;
+ if (CurTok.LI) {
+ FileName = GetInputName (CurTok.LI);
+ LineNum = GetInputLine (CurTok.LI);
+ } else {
+ FileName = GetCurrentFile ();
+ LineNum = GetCurrentLine ();
+ }
+
fprintf (stderr, "%s(%u): Internal compiler error:\n",
- GetCurrentFile(), curpos);
+ FileName, LineNum);
va_start (ap, Format);
vfprintf (stderr, Format, ap);
/* Use abort to create a core dump */
abort ();
-}
+}
void ErrorReport (void)
/* Report errors (called at end of compile) */
{
- if (ErrorCount == 0 && Verbose) {
+ if (ErrorCount == 0 && Verbosity > 0) {
printf ("No errors.\n");
}
}
+