static LONG macuniq; // Unique-per-macro number
static SYM * curmac; // Macro currently being defined
-static uint32_t argno; // Formal argument count
+static uint32_t argno; // Formal argument count
+LONG reptuniq; // Unique-per-rept number
static LLIST * firstrpt; // First .rept line
static LLIST * nextrpt; // Last .rept line
-static int rptlevel; // .rept nesting level
+int rptlevel; // .rept nesting level
// Function prototypes
static int KWMatch(char *, char *);
{
macuniq = 0;
macnum = 1;
+ reptuniq = 0;
}
DEBUG { printf("end-repeat-block\n"); }
return NULL;
}
-
+ reptuniq++;
// strp = irept->ir_nextln;
}
// Mark the current macro line in the irept object
// error reporting anyway)
irept->lineno = irept->ir_nextln->lineno;
-// strcpy(irbuf, (char *)(irept->ir_nextln + 1));
- strcpy(irbuf, irept->ir_nextln->line);
+ // Copy the rept lines verbatim, unless we're in nest level 0.
+ // Then, expand any \~ labels to unique numbers (Rn)
+ if (rptlevel)
+ {
+ strcpy(irbuf, irept->ir_nextln->line);
+ }
+ else
+ {
+ uint32_t linelen = strlen(irept->ir_nextln->line);
+ uint8_t *p_line = irept->ir_nextln->line;
+ char *irbufwrite = irbuf;
+ for (int i = 0; i <= linelen; i++)
+ {
+ uint8_t c;
+ c = *p_line++;
+ if (c == '\\' && *p_line == '~')
+ {
+ p_line++;
+ irbufwrite += sprintf(irbufwrite, "R%u", reptuniq);
+ }
+ else
+ {
+ *irbufwrite++ = c;
+ }
+ }
+ }
+
DEBUG { printf("repeat line='%s'\n", irbuf); }
// irept->ir_nextln = (LONG *)*strp;
irept->ir_nextln = irept->ir_nextln->next;