X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=token.c;h=6ba200c769aa86f0c9d6e54b3ce979cf90b61f70;hp=4a06efedcbebf1a0fdb72aec48857e74d6286b5a;hb=090bda1c00a18b3f616e734090ba456a461879a1;hpb=6c1bc379012b1c1ca369e71e39509f3538042382 diff --git a/token.c b/token.c index 4a06efe..6ba200c 100644 --- a/token.c +++ b/token.c @@ -452,7 +452,8 @@ arg_num: continue; } - if (tk != NULL) // arg # is in range, so expand it + // Argument # is in range, so expand it + if (tk != NULL) { while (*tk != EOL) { @@ -794,11 +795,17 @@ char * GetNextLine(void) // Scan for next end-of-line; handle stupid text formats by treating // \r\n the same as \n. (lone '\r' at end of buffer means we have to // check for '\n'). +#if 0 i = 0; j = fl->ifcnt; d = &fl->ifbuf[fl->ifind]; for(p=d; iifbuf[fl->ifind]; + + for(p=d, i=0, j=fl->ifcnt; i= j) - { - break; // Look for '\n' to eat - } + break; // Need to read more, then look for '\n' to eat else if (p[1] == '\n') - { i++; - } } + // Cover up the newline with end-of-string sentinel *p = '\0'; fl->ifind += i; @@ -826,11 +830,19 @@ char * GetNextLine(void) // Handle hanging lines by ignoring them (Input file is exhausted, no // \r or \n on last line) + // Shamus: This is retarded. Never ignore any input! if (!readamt && fl->ifcnt) { +#if 0 fl->ifcnt = 0; *p = '\0'; return NULL; +#else + // Really should check to see if we're at the end of the buffer! :-P + fl->ifbuf[fl->ifind + fl->ifcnt] = '\0'; + fl->ifcnt = 0; + return &fl->ifbuf[fl->ifind]; +#endif } // Truncate and return absurdly long lines. @@ -855,7 +867,9 @@ char * GetNextLine(void) fl->ifind = fl->ifcnt & 1; } - if ((readamt = read(fl->ifhandle, &fl->ifbuf[fl->ifind + fl->ifcnt], QUANTUM)) < 0) + readamt = read(fl->ifhandle, &fl->ifbuf[fl->ifind + fl->ifcnt], QUANTUM); + + if (readamt < 0) return NULL; if ((fl->ifcnt += readamt) == 0) @@ -994,12 +1008,12 @@ if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); if (c & STSYM) { - if (stuffnull) // Terminate old symbol from previous pass + if (stuffnull) // Terminate old symbol from previous pass *nullspot = EOS; - v = 0; // Assume no DOT attrib follows symbol + v = 0; // Assume no DOT attrib follows symbol stuffnull = 1; - p = nullspot = ln++; // Nullspot -> start of this symbol + p = nullspot = ln++; // Nullspot -> start of this symbol // Find end of symbol (and compute its length) for(j=1; (int)chrtab[*ln]&CTSYM; j++) @@ -1009,8 +1023,8 @@ if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); // symbol or keyword: if (*ln == '.') { - *ln++ = EOS; // Terminate symbol - stuffnull = 0; // And never try it again + *ln++ = EOS; // Terminate symbol + stuffnull = 0; // And never try it again // Character following the `.' must have a DOT attribute, and // the chararacter after THAT one must not have a start-symbol @@ -1071,7 +1085,6 @@ if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); case 120: // time case 121: // date j = -1; -// break; } // If not tokenized keyword OR token was not found @@ -1079,8 +1092,8 @@ if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); { *tk++ = SYMBOL; //#warning -//problem here: nullspot is a char * but TOKEN is a uint32_t. On a 64-bit system, -//this will cause all kinds of mischief. +//problem here: nullspot is a char * but TOKEN is a uint32_t. On a 64-bit +//system, this will cause all kinds of mischief. #if 0 *tk++ = (TOKEN)nullspot; #else @@ -1438,6 +1451,7 @@ if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); *tk++ = CONST; *tk++ = v; +//printf("CONST: %i\n", v); continue; } @@ -1478,11 +1492,8 @@ goteol: //int d_goto(void) int d_goto(WORD unused) { -// char * sym; // Label to search for -// LONG * defln; // Macro definition strings - char * s1; // Temps for string comparison + char * s1; // Temps for string comparison char * s2; -// IMACRO * imacro; // Macro invocation block // Setup for the search if (*tok != SYMBOL)