]> Shamusworld >> Repos - rmac/commitdiff
Possible fix for bug #72 (no warning on unclosed .ifs).
authorShamus Hammons <jlhamm@acm.org>
Mon, 9 May 2016 18:13:41 +0000 (13:13 -0500)
committerShamus Hammons <jlhamm@acm.org>
Mon, 9 May 2016 18:13:41 +0000 (13:13 -0500)
procln.c
token.c
version.h

index 04b8ddd6392ea64bb5ebac5c7c515cdd755d703c..3b8c607db3c8c5ed40ffc6778da64bda7e36aa86 100644 (file)
--- a/procln.c
+++ b/procln.c
@@ -36,7 +36,6 @@ static IFENT * f_ifent;                       // Freelist of ifents
 static int disabled;                   // Assembly conditionally disabled
 int just_bss;                                  // 1, ds.b in microprocessor mode 
 VALUE pcloc;                                   // Value of "PC" at beginning of line 
 static int disabled;                   // Assembly conditionally disabled
 int just_bss;                                  // 1, ds.b in microprocessor mode 
 VALUE pcloc;                                   // Value of "PC" at beginning of line 
-IFENT * ifent;                                 // Current ifent
 SYM * lab_sym;                                 // Label on line (or NULL)
 
 const char extra_stuff[] = "extra (unexpected) text found after addressing mode";
 SYM * lab_sym;                                 // Label on line (or NULL)
 
 const char extra_stuff[] = "extra (unexpected) text found after addressing mode";
@@ -265,13 +264,13 @@ as68label:
                switch (state)
                {
                case MN_IF:
                switch (state)
                {
                case MN_IF:
-                       d_if ();
+                       d_if();
                goto loop;
                case MN_ELSE:
                        d_else();
                        goto loop;
                case MN_ENDIF:
                goto loop;
                case MN_ELSE:
                        d_else();
                        goto loop;
                case MN_ENDIF:
-                       d_endif ();
+                       d_endif();
                        goto loop;
                case MN_IIF:                                            // .iif --- immediate if
                        if (disabled || expr(exprbuf, &eval, &eattr, &esym) != OK)
                        goto loop;
                case MN_IIF:                                            // .iif --- immediate if
                        if (disabled || expr(exprbuf, &eval, &eattr, &esym) != OK)
diff --git a/token.c b/token.c
index 7bba1993fd815aa13befd0c80228063fcd07e0eb..77fec1efbeac0071594df0dbd22de787d8b02dd8 100644 (file)
--- a/token.c
+++ b/token.c
@@ -730,18 +730,26 @@ int fpop(void)
        {
                // Pop IFENT levels until we reach the conditional assembly context we
                // were at when the input object was entered.
        {
                // Pop IFENT levels until we reach the conditional assembly context we
                // were at when the input object was entered.
+               int numUnmatched = 0;
+
                while (ifent != inobj->in_ifent)
                {
                while (ifent != inobj->in_ifent)
                {
-                       if (d_endif() != 0)                             // Something bad happened during endif parsing?
-                               return -1;                                      // If yes, bail instead of getting stuck in a loop
+                       if (d_endif() != 0)             // Something bad happened during endif parsing?
+                               return -1;                      // If yes, bail instead of getting stuck in a loop
+
+                       numUnmatched++;
                }
 
                }
 
-               tok = inobj->in_otok;                           // Restore tok and otok
+               // Give a warning to the user that we had to wipe their bum for them
+               if (numUnmatched > 0)
+                       warni("missing %d .endif(s)", numUnmatched);
+
+               tok = inobj->in_otok;           // Restore tok and otok
                etok = inobj->in_etok;
 
                switch (inobj->in_type)
                {
                etok = inobj->in_etok;
 
                switch (inobj->in_type)
                {
-               case SRC_IFILE:                                         // Pop and release an IFILE
+               case SRC_IFILE:                         // Pop and release an IFILE
                        if (debug)
                                printf("[Leaving: %s]\n", curfname);
 
                        if (debug)
                                printf("[Leaving: %s]\n", curfname);
 
@@ -912,7 +920,7 @@ retry:
                if ((ln = GetNextLine()) == NULL)
                {
 if (debug) printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n");
                if ((ln = GetNextLine()) == NULL)
                {
 if (debug) printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n");
-                       if (fpop()==0)                                  // Pop input level
+                       if (fpop() == 0)                                // Pop input level
                                goto retry;                                     // Try for more lines 
                        else
                        {
                                goto retry;                                     // Try for more lines 
                        else
                        {
index 5354b8effbe66d012bcce6df837a629758b93047..fa8b08b7188604ec01b4a29ff7977bd3165ddf7a 100644 (file)
--- a/version.h
+++ b/version.h
@@ -13,6 +13,6 @@
 
 #define MAJOR   1              // Major version number
 #define MINOR   4              // Minor version number
 
 #define MAJOR   1              // Major version number
 #define MINOR   4              // Minor version number
-#define PATCH   10             // Patch release number
+#define PATCH   11             // Patch release number
 
 #endif // __VERSION_H__
 
 #endif // __VERSION_H__