Made ca65 give error messages when it sees duplicate .define commands.

This commit is contained in:
Greg King
2020-01-02 04:26:02 -05:00
parent 00ab3c2d34
commit 5109c0b68f

View File

@@ -821,8 +821,17 @@ static void DoDebugInfo (void)
static void DoDefine (void) static void DoDefine (void)
/* Define a one line macro */ /* Define a one-line macro */
{ {
/* The function is called with the .DEFINE token in place, because we need
** to disable .define macro expansions before reading the next token.
** Otherwise, the name of the macro might be expanded; therefore,
** we never would see it.
*/
DisableDefineStyleMacros ();
NextTok ();
EnableDefineStyleMacros ();
MacDef (MAC_STYLE_DEFINE); MacDef (MAC_STYLE_DEFINE);
} }
@@ -1871,12 +1880,12 @@ static void DoTag (void)
static void DoUnDef (void) static void DoUnDef (void)
/* Undefine a define style macro */ /* Undefine a define-style macro */
{ {
/* The function is called with the .UNDEF token in place, because we need /* The function is called with the .UNDEF token in place, because we need
** to disable .define macro expansions before reading the next token. ** to disable .define macro expansions before reading the next token.
** Otherwise the name of the macro would be expanded, so we would never ** Otherwise, the name of the macro would be expanded; therefore,
** see it. ** we never would see it.
*/ */
DisableDefineStyleMacros (); DisableDefineStyleMacros ();
NextTok (); NextTok ();
@@ -1962,7 +1971,7 @@ static void DoZeropage (void)
/* Control commands flags */ /* Control commands flags */
enum { enum {
ccNone = 0x0000, /* No special flags */ ccNone = 0x0000, /* No special flags */
ccKeepToken = 0x0001 /* Do not skip the current token */ ccKeepToken = 0x0001 /* Do not skip the control token */
}; };
/* Control command table */ /* Control command table */
@@ -2001,7 +2010,7 @@ static CtrlDesc CtrlCmdTab [] = {
{ ccNone, DoDbg, }, { ccNone, DoDbg, },
{ ccNone, DoDByt }, { ccNone, DoDByt },
{ ccNone, DoDebugInfo }, { ccNone, DoDebugInfo },
{ ccNone, DoDefine }, { ccKeepToken, DoDefine },
{ ccNone, DoUnexpected }, /* .DEFINED */ { ccNone, DoUnexpected }, /* .DEFINED */
{ ccNone, DoUnexpected }, /* .DEFINEDMACRO */ { ccNone, DoUnexpected }, /* .DEFINEDMACRO */
{ ccNone, DoDelMac }, { ccNone, DoDelMac },