X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=token.c;h=d6426600b8f5de1c94acf12256a80b0094eaac81;hb=refs%2Ftags%2Fv2.1.9;hp=5b783a3be2e378e3b787846775e75b6757a027a9;hpb=cbc8347d4ffea164ca05b03e4e3be39945be8777;p=rmac diff --git a/token.c b/token.c index 5b783a3..d642660 100644 --- a/token.c +++ b/token.c @@ -40,13 +40,6 @@ TOKEN tokeol[1] = {EOL}; // Bailout end-of-line token char * string[TOKBUFSIZE*2];// Token buffer string pointer storage int optimizeOff; // Optimization override flag -// File record, used to maintain a list of every include file ever visited -#define FILEREC struct _filerec -FILEREC -{ - FILEREC * frec_next; - char * frec_name; -}; FILEREC * filerec; FILEREC * last_fr; @@ -706,7 +699,7 @@ char * GetNextRepeatLine(void) DEBUG { printf("end-repeat-block\n"); } return NULL; } - + reptuniq++; // strp = irept->ir_nextln; } // Mark the current macro line in the irept object @@ -715,8 +708,33 @@ char * GetNextRepeatLine(void) // 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; @@ -1662,7 +1680,7 @@ int d_goto(WORD unused) { // Compare names (sleazo string compare) char * s1 = sym; - char * s2 = defln->line; + char * s2 = defln->line + 1; // Either we will match the strings to EOS on both, or we will // match EOS on string 1 to whitespace on string 2. Otherwise, we