From 19e1167b825e7796321cb5289b0ea06bf8e46612 Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 10 Oct 2004 10:30:03 +0000 Subject: [PATCH] Use Line only if available git-svn-id: svn://svn.cc65.org/cc65/trunk@3238 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/error.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/cc65/error.c b/src/cc65/error.c index 44825287e..29b4a3443 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -75,9 +75,11 @@ static void IntWarning (const char* Filename, unsigned LineNo, const char* Msg, fprintf (stderr, "%s(%u): Warning: ", Filename, LineNo); vfprintf (stderr, Msg, ap); fprintf (stderr, "\n"); - - Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); - ++WarningCount; + + if (Line) { + Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + } + ++WarningCount; } } @@ -112,7 +114,9 @@ static void IntError (const char* Filename, unsigned LineNo, const char* Msg, va vfprintf (stderr, Msg, ap); fprintf (stderr, "\n"); - Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + if (Line) { + Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + } ++ErrorCount; if (ErrorCount > 10) { Fatal ("Too many errors"); @@ -151,11 +155,11 @@ void Fatal (const char* Format, ...) const char* FileName; unsigned LineNum; if (CurTok.LI) { - FileName = GetInputName (CurTok.LI); - LineNum = GetInputLine (CurTok.LI); + FileName = GetInputName (CurTok.LI); + LineNum = GetInputLine (CurTok.LI); } else { - FileName = GetCurrentFile (); - LineNum = GetCurrentLine (); + FileName = GetCurrentFile (); + LineNum = GetCurrentLine (); } fprintf (stderr, "%s(%u): Fatal: ", FileName, LineNum); @@ -165,7 +169,9 @@ void Fatal (const char* Format, ...) va_end (ap); fprintf (stderr, "\n"); - Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + if (Line) { + Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + } exit (EXIT_FAILURE); } @@ -179,20 +185,23 @@ void Internal (const char* Format, ...) const char* FileName; unsigned LineNum; if (CurTok.LI) { - FileName = GetInputName (CurTok.LI); - LineNum = GetInputLine (CurTok.LI); + FileName = GetInputName (CurTok.LI); + LineNum = GetInputLine (CurTok.LI); } else { - FileName = GetCurrentFile (); - LineNum = GetCurrentLine (); + FileName = GetCurrentFile (); + LineNum = GetCurrentLine (); } fprintf (stderr, "%s(%u): Internal compiler error:\n", - FileName, LineNum); + FileName, LineNum); va_start (ap, Format); vfprintf (stderr, Format, ap); va_end (ap); - fprintf (stderr, "\nInput: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + + if (Line) { + fprintf (stderr, "\nInput: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + } /* Use abort to create a core dump */ abort (); -- 2.39.5