a4f04fe
From 5109c0b68f7a2cd07ece07b6812affeab07ae17a Mon Sep 17 00:00:00 2001
a4f04fe
From: Greg King <gregdk@users.sf.net>
a4f04fe
Date: Thu, 2 Jan 2020 04:26:02 -0500
a4f04fe
Subject: [PATCH 134/170] Made ca65 give error messages when it sees duplicate
a4f04fe
 .define commands.
a4f04fe
a4f04fe
---
a4f04fe
 src/ca65/pseudo.c | 21 +++++++++++++++------
a4f04fe
 1 file changed, 15 insertions(+), 6 deletions(-)
a4f04fe
a4f04fe
diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c
a4f04fe
index a0eb2869..5b2ef057 100644
a4f04fe
--- a/src/ca65/pseudo.c
a4f04fe
+++ b/src/ca65/pseudo.c
a4f04fe
@@ -821,8 +821,17 @@ static void DoDebugInfo (void)
a4f04fe
 
a4f04fe
 
a4f04fe
 static void DoDefine (void)
a4f04fe
-/* Define a one line macro */
a4f04fe
+/* Define a one-line macro */
a4f04fe
 {
a4f04fe
+    /* The function is called with the .DEFINE token in place, because we need
a4f04fe
+    ** to disable .define macro expansions before reading the next token.
a4f04fe
+    ** Otherwise, the name of the macro might be expanded; therefore,
a4f04fe
+    ** we never would see it.
a4f04fe
+    */
a4f04fe
+    DisableDefineStyleMacros ();
a4f04fe
+    NextTok ();
a4f04fe
+    EnableDefineStyleMacros ();
a4f04fe
+
a4f04fe
     MacDef (MAC_STYLE_DEFINE);
a4f04fe
 }
a4f04fe
 
a4f04fe
@@ -1871,12 +1880,12 @@ static void DoTag (void)
a4f04fe
 
a4f04fe
 
a4f04fe
 static void DoUnDef (void)
a4f04fe
-/* Undefine a define style macro */
a4f04fe
+/* Undefine a define-style macro */
a4f04fe
 {
a4f04fe
     /* The function is called with the .UNDEF token in place, because we need
a4f04fe
     ** to disable .define macro expansions before reading the next token.
a4f04fe
-    ** Otherwise the name of the macro would be expanded, so we would never
a4f04fe
-    ** see it.
a4f04fe
+    ** Otherwise, the name of the macro would be expanded; therefore,
a4f04fe
+    ** we never would see it.
a4f04fe
     */
a4f04fe
     DisableDefineStyleMacros ();
a4f04fe
     NextTok ();
a4f04fe
@@ -1962,7 +1971,7 @@ static void DoZeropage (void)
a4f04fe
 /* Control commands flags */
a4f04fe
 enum {
a4f04fe
     ccNone      = 0x0000,               /* No special flags */
a4f04fe
-    ccKeepToken = 0x0001                /* Do not skip the current token */
a4f04fe
+    ccKeepToken = 0x0001                /* Do not skip the control token */
a4f04fe
 };
a4f04fe
 
a4f04fe
 /* Control command table */
a4f04fe
@@ -2001,7 +2010,7 @@ static CtrlDesc CtrlCmdTab [] = {
a4f04fe
     { ccNone,           DoDbg,          },
a4f04fe
     { ccNone,           DoDByt          },
a4f04fe
     { ccNone,           DoDebugInfo     },
a4f04fe
-    { ccNone,           DoDefine        },
a4f04fe
+    { ccKeepToken,      DoDefine        },
a4f04fe
     { ccNone,           DoUnexpected    },      /* .DEFINED */
a4f04fe
     { ccNone,           DoUnexpected    },      /* .DEFINEDMACRO */
a4f04fe
     { ccNone,           DoDelMac        },
a4f04fe
-- 
a4f04fe
2.26.0
a4f04fe