From: Shamus Hammons Date: Mon, 9 May 2016 18:13:41 +0000 (-0500) Subject: Possible fix for bug #72 (no warning on unclosed .ifs). X-Git-Tag: v2.1.0~161 X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=commitdiff_plain;h=e968236d060c7dbae1647d5f54b27d4070b63b06 Possible fix for bug #72 (no warning on unclosed .ifs). --- diff --git a/procln.c b/procln.c index 04b8ddd..3b8c607 100644 --- 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 -IFENT * ifent; // Current ifent 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: - d_if (); + d_if(); 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) diff --git a/token.c b/token.c index 7bba199..77fec1e 100644 --- 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. + int numUnmatched = 0; + 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) { - case SRC_IFILE: // Pop and release an IFILE + case SRC_IFILE: // Pop and release an IFILE 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 (fpop()==0) // Pop input level + if (fpop() == 0) // Pop input level goto retry; // Try for more lines else { diff --git a/version.h b/version.h index 5354b8e..fa8b08b 100644 --- a/version.h +++ b/version.h @@ -13,6 +13,6 @@ #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__