diff options
| -rw-r--r-- | TODO | 5 | ||||
| -rw-r--r-- | listamsb.c | 24 | 
2 files changed, 14 insertions, 15 deletions
@@ -1,10 +1,5 @@  for now: -listamsb: -- don't display the colon before a ! or ' comment that appears -  as the 2nd or later statement on a line. -- actually exit with status 2 if there were uknown tokens. -  fauxtari:  - Figure out why fauxtari doesn't show up in font-selections    dialogs in xfc4-terminal, gnome-terminal; also it doesn't @@ -24,6 +24,7 @@ int raw_output = 0;  int need_pclose = 0;  int bytes_read = 0; +int unknowns = 0;  FILE *infile;  FILE *outfile; @@ -77,12 +78,13 @@ int read_header(void) {  }  void unknown_token(int lineno, unsigned char byte, int ext) { +	unknowns++;  	fprintf(outfile, "<unknown %stoken ", (ext ? "extended " : ""));  	fprintf(outfile, "%s%02x>", (ext ? "ff ": ""), byte);  }  int next_line(void) { -	int ptr, lineno, was_ff, in_string, start; +	int ptr, lineno, was_ff, in_string;  	unsigned char byte;  	/* pointer to last token on the line, offset by whatever MEMLO @@ -105,20 +107,11 @@ int next_line(void) {  	was_ff = 0;  	in_string = 0; -	start = 1;  	/* walk and print the tokens. when we hit a null byte, we're done. */  	while(1) {  		byte = read_byte(); -		/* lines that consist entirely of a comment introduced with a -			single-quote or exclamation point have a : before the comment -			start character. don't print it. */ -		if(start) { -			start = 0; -			if(byte == ':') continue; -		} -  		if(in_string) {  			if(byte == 0x00 || byte == '|') {  				/* end of string */ @@ -134,6 +127,12 @@ int next_line(void) {  				}  			}  			putc(byte, outfile); +		} else if(byte == ':') { +			/* don't print the colon if the next token is a ! or ' for a comment */ +			unsigned char next = read_byte(); +			if( !(next == 0x9a || next == 0x9b) ) +				putc(byte, outfile); +			ungetc(next, infile);  		} else if(byte == '"') {  			/* strings start but *don't end* with a double-quote */  			in_string = 1; @@ -247,5 +246,10 @@ int main(int argc, char **argv) {  	if(need_pclose) pclose(outfile); +	if(unknowns) { +		fprintf(stderr, "%s: input has %d unknown tokens\n", self, unknowns);; +		exit(2); +	} +  	exit(0);  }  | 
