From 133507b031fe6b5e31fa2732651363521728576f Mon Sep 17 00:00:00 2001 From: acqn Date: Thu, 29 Sep 2022 17:55:09 +0800 Subject: [PATCH] Fixed line info for #pragma messages and diagnostics. --- src/cc65/preproc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index 0835bac1e..99a8af116 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -3025,6 +3025,7 @@ static int ParseDirectives (unsigned ModeFlags) if (!PPSkip) { if ((ModeFlags & MSM_IN_ARG_LIST) == 0) { DoPragma (); + return Whitespace; } else { PPError ("Embedded #pragma directive within macro arguments is unsupported"); } @@ -3153,16 +3154,12 @@ static void PreprocessDirective (StrBuf* Source, StrBuf* Target, unsigned ModeFl ** whitespace and comments, then do macro replacement. */ { - int OldIndex = SB_GetIndex (Source); MacroExp E; SkipWhitespace (0); InitMacroExp (&E); ReplaceMacros (Source, Target, &E, ModeFlags | MSM_IN_DIRECTIVE); DoneMacroExp (&E); - - /* Restore the source input index */ - SB_SetIndex (Source, OldIndex); } @@ -3186,7 +3183,9 @@ void Preprocess (void) AddPreLine (PLine); /* Add leading whitespace to prettify preprocessor output */ - AppendIndent (PLine, SB_GetIndex (Line)); + if (CurC != '\0') { + AppendIndent (PLine, SB_GetIndex (Line)); + } /* Expand macros if any */ InitMacroExp (&E);