ref: 38372c59edb070d2c0320d21c6cf898e118e3e26
parent: 547abfefc1bcc45a906329c51f180de703d1ced9
author: Ben10do <[email protected]>
date: Thu Feb 2 11:27:53 EST 2017
Verify that IFs, REPTs and MACROs are terminated Ensure that IF constructs, REPT blocks, and MACRO defintions are terminated with ENDC, ENDR, or ENDM respectively. If they are not, print an error and stop assembly. As well as aiding a forgetful programmer, this reduces the risk of memory problems if the file ends less than four bytes after the block starts.
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -182,6 +182,10 @@
}
}
+ if (level != 0) {
+ fatalerror("Unterminated REPT block");
+ }
+
len=src-pCurrentBuffer->pBuffer-4;
src=pCurrentBuffer->pBuffer;
@@ -257,6 +261,10 @@
}
}
+ if (level != 0) {
+ fatalerror("Unterminated MACRO definition");
+ }
+
len=src-pCurrentBuffer->pBuffer-4;
src=pCurrentBuffer->pBuffer;
@@ -348,6 +356,10 @@
}
}
+ if (level != 0) {
+ fatalerror("Unterminated IF construct");
+ }
+
len=src-pCurrentBuffer->pBuffer;
yyskipbytes( len );
@@ -401,6 +413,10 @@
src+=1;
}
}
+ }
+
+ if (level != 0) {
+ fatalerror("Unterminated IF construct");
}
len=src-pCurrentBuffer->pBuffer;