X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=token.c;h=81a040a958aefc6971baf53ef30f8186cbc3e070;hp=629f8a6f98a18bb8afeb90bb86461b8f37600caa;hb=9207a38ed4a09c60a1e9b9995a92bcd4580e3662;hpb=a3feec3b2d24d0f4685549a5059a210e074c2b99 diff --git a/token.c b/token.c index 629f8a6..81a040a 100644 --- a/token.c +++ b/token.c @@ -20,7 +20,7 @@ int lnsave; // 1; strcpy() text of current line -int curlineno; // Current line number +uint16_t curlineno; // Current line number (64K max currently) int totlines; // Total # of lines int mjump_align = 0; // mjump alignment flag char lntag; // Line tag @@ -517,9 +517,9 @@ DEBUG printf("ExM: SYMBOL=\"%s\"", d); *dst++ = '"'; continue; break; -// Shamus: Changing the format specifier from %lx to %ux caused -// the assembler to choke on legitimate code... Need to investigate -// this further before changing anything else here! +// Shamus: Changing the format specifier from %lx to %ux caused the assembler +// to choke on legitimate code... Need to investigate this further +// before changing anything else here! case CONST: sprintf(numbuf, "$%lx", (LONG)*tk++); d = numbuf; @@ -1177,25 +1177,19 @@ if (debug) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); continue; case '\'': // 'string' if (m6502) - { - *tk++ = STRINGA8; // hardcoded for now, maybe this will change in the future - goto dostring; - } + { + // Hardcoded for now, maybe this will change in the future + *tk++ = STRINGA8; + goto dostring; + } // Fall through case '\"': // "string" *tk++ = STRING; dostring: c1 = ln[-1]; -//#warning -// More char * stuffing (8 bytes) into the space of 4 (TOKEN). -// Need to figure out how to fix this crap. -#if 0 - *tk++ = (TOKEN)ln; -#else string[stringNum] = ln; *tk++ = stringNum; stringNum++; -#endif for(p=ln; *ln!=EOS && *ln!=c1;) { @@ -1573,17 +1567,12 @@ goteol: // expansion, and is NOT subject to macro expansion. The whitespace may also // be EOL. // -//int d_goto(WORD siz) { -//int d_goto(void) int d_goto(WORD unused) { - char * s1, * s2; - // Setup for the search if (*tok != SYMBOL) return error("missing label"); -// sym = (char *)tok[1]; char * sym = string[tok[1]]; tok += 2; @@ -1591,39 +1580,35 @@ int d_goto(WORD unused) return error("goto not in macro"); IMACRO * imacro = cur_inobj->inobj.imacro; -// defln = (LONG *)imacro->im_macro->svalue; struct LineList * defln = imacro->im_macro->lineList; - // Find the label, starting with the first line. + // Attempt to find the label, starting with the first line. for(; defln!=NULL; defln=defln->next) { -// if (*(char *)(defln + 1) == ':') + // Must start with a colon if (defln->line[0] == ':') { // Compare names (sleazo string compare) - // This string compare is not right. Doesn't check for lengths. - // (actually it does, but in a crappy, unclear way.) -WARNING(!!!! Bad string comparison !!!) - s1 = sym; -// s2 = (char *)(defln + 1) + 1; - s2 = defln->line; - - while (*s1 == *s2) + char * s1 = sym; + char * s2 = defln->line; + + // 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 + // have no match. + while ((*s1 == *s2) || ((*s1 == EOS) && (chrtab[*s2] & WHITE))) { + // If we reached the end of string 1 (sym), we're done. + // Note that we're also checking for the end of string 2 as + // well, since we've established they're equal above. if (*s1 == EOS) - break; - else { - s1++; - s2++; + // Found the label, set new macro next-line and return. + imacro->im_nextln = defln; + return 0; } - } - // Found the label, set new macro next-line and return. - if ((*s2 == EOS) || ((int)chrtab[*s2] & WHITE)) - { - imacro->im_nextln = defln; - return 0; + s1++; + s2++; } } }