X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=token.c;h=24b7c955d6cbe04591fc6d634453b629ec5be9e2;hp=629f8a6f98a18bb8afeb90bb86461b8f37600caa;hb=732c626abe986e60ea947bd65cad4a4a1b84e800;hpb=a3feec3b2d24d0f4685549a5059a210e074c2b99 diff --git a/token.c b/token.c index 629f8a6..24b7c95 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,11 +517,11 @@ 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++); + sprintf(numbuf, "$%lx", (long unsigned int)*tk++); d = numbuf; break; case DEQUALS: @@ -648,7 +648,6 @@ char * GetNextMacroLine(void) // char * GetNextRepeatLine(void) { - IREPT * irept = cur_inobj->inobj.irept; LONG * strp = irept->ir_nextln; // initial null @@ -1177,25 +1176,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;) { @@ -1310,16 +1303,19 @@ dostring: if (obj_format == ALCYON) { - if ((*(ln + 1) == 'w') || (*(ln + 1) == 'W')) - { - *tk++ = DOTW; - ln += 2; - } - else if ((*(ln + 1) == 'l') || (*(ln + 1) == 'L')) - { - *tk++ = DOTL; - ln += 2; - } + if (*ln == '.') + { + if ((*(ln + 1) == 'w') || (*(ln + 1) == 'W')) + { + *tk++ = DOTW; + ln += 2; + } + else if ((*(ln + 1) == 'l') || (*(ln + 1) == 'L')) + { + *tk++ = DOTL; + ln += 2; + } + } } } else @@ -1573,17 +1569,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 +1582,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++; } } }