From 0e460243fd0bc52a4be354cd526911b5916c4bc3 Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 9 Jul 2000 13:19:25 +0000 Subject: [PATCH] Fix macro output in the listing git-svn-id: svn://svn.cc65.org/cc65/trunk@141 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/istack.c | 8 ++++++ src/ca65/istack.h | 5 +++- src/ca65/main.c | 62 +++++++++++++++++++++++------------------------ 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/ca65/istack.c b/src/ca65/istack.c index 5ba35a906..18b4031c2 100644 --- a/src/ca65/istack.c +++ b/src/ca65/istack.c @@ -136,6 +136,14 @@ int InputFromStack (void) +int HavePushedInput (void) +/* Return true if we have stacked input available, return false if not */ +{ + return (IStack != 0); +} + + + void CheckInputStack (void) /* Called from the scanner before closing an input file. Will check for any * stuff on the input stack. diff --git a/src/ca65/istack.h b/src/ca65/istack.h index 0e8d893e9..5529c7911 100644 --- a/src/ca65/istack.h +++ b/src/ca65/istack.h @@ -53,7 +53,10 @@ void PopInput (void); int InputFromStack (void); /* Try to get input from the input stack. Return true if we had such input, * return false otherwise. - */ + */ + +int HavePushedInput (void); +/* Return true if we have stacked input available, return false if not */ void CheckInputStack (void); /* Called from the scanner before closing an input file. Will check for any diff --git a/src/ca65/main.c b/src/ca65/main.c index b754950c0..f28224cb9 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -47,6 +47,7 @@ #include "global.h" #include "incpath.h" #include "instr.h" +#include "istack.h" #include "listing.h" #include "macro.h" #include "nexttok.h" @@ -299,8 +300,12 @@ static void OneLine (void) char Ident [MAX_STR_LEN+1]; int Done = 0; - /* Initialize the listing line */ - InitListingLine (); + /* Initialize the new listing line if we are actually reading from file + * and not from internally pushed input. + */ + if (!HavePushedInput ()) { + InitListingLine (); + } if (Tok == TOK_COLON) { /* An unnamed label */ @@ -342,41 +347,36 @@ static void OneLine (void) * without a colon if there is no whitespace before the * identifier. */ - if (Tok != TOK_COLON) { - if (HadWS || !NoColonLabels) { - Error (ERR_COLON_EXPECTED); - } - if (Tok == TOK_NAMESPACE) { - /* Smart :: handling */ - NextTok (); - } - } else { - /* Skip the colon */ - NextTok (); - } - } - } + if (Tok != TOK_COLON) { + if (HadWS || !NoColonLabels) { + Error (ERR_COLON_EXPECTED); + } + if (Tok == TOK_NAMESPACE) { + /* Smart :: handling */ + NextTok (); + } + } else { + /* Skip the colon */ + NextTok (); + } + } + } } if (!Done) { - if (TokIsPseudo (Tok)) { - /* A control command, IVal is index into table */ - HandlePseudo (); - } else if (Tok == TOK_MNEMO) { - /* A mnemonic - assemble one instruction */ - HandleInstruction (IVal); - } else if (Tok == TOK_IDENT && IsMacro (SVal)) { - /* A macro expansion */ - MacExpandStart (); - } + if (TokIsPseudo (Tok)) { + /* A control command, IVal is index into table */ + HandlePseudo (); + } else if (Tok == TOK_MNEMO) { + /* A mnemonic - assemble one instruction */ + HandleInstruction (IVal); + } else if (Tok == TOK_IDENT && IsMacro (SVal)) { + /* A macro expansion */ + MacExpandStart (); + } } - /* Calling InitListingLine again here is part of a hack that introduces - * enough magic to make the PC output in the listing work. - */ - InitListingLine (); - /* Line separator must come here */ ConsumeSep (); } -- 2.39.5