*/
static MMacro *defining;
+static uint64_t nested_mac_count;
+static uint64_t nested_rep_count;
+
/*
* The number of macro parameters to allocate space for at a time.
*/
return NO_DIRECTIVE_FOUND;
}
+ if (defining) {
+ if (i == PP_MACRO || i == PP_IMACRO) {
+ nested_mac_count++;
+ return NO_DIRECTIVE_FOUND;
+ } else if (nested_mac_count > 0) {
+ if (i == PP_ENDMACRO) {
+ nested_mac_count--;
+ return NO_DIRECTIVE_FOUND;
+ }
+ }
+ if (!defining->name) {
+ if (i == PP_REP) {
+ nested_rep_count++;
+ return NO_DIRECTIVE_FOUND;
+ } else if (nested_rep_count > 0) {
+ if (i == PP_ENDREP) {
+ nested_rep_count--;
+ return NO_DIRECTIVE_FOUND;
+ }
+ }
+ }
+ }
+
switch (i) {
case PP_INVALID:
error(ERR_NONFATAL, "unknown preprocessor directive `%s'",
break;
if (l)
- l->finishes->in_progress = 0;
+ l->finishes->in_progress = 1;
else
error(ERR_NONFATAL, "`%%exitrep' not within `%%rep' block");
free_tlist(origline);
error(ERR_FATAL | ERR_NOFILE, "unable to open input file `%s'",
file);
defining = NULL;
+ nested_mac_count = 0;
+ nested_rep_count = 0;
init_macros();
unique = 0;
if (tasm_compatible_mode) {
* condition, in which case we don't want to meddle with
* anything.
*/
- if (!defining && !(istk->conds && !emitting(istk->conds->state)))
+ if (!defining && !(istk->conds && !emitting(istk->conds->state))
+ && !(istk->mstk && !istk->mstk->in_progress))
tline = expand_mmac_params(tline);
/*