From adae59075c4a0659d8abfe7e5e37f8fbac88f29d Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 8 Mar 2025 22:54:07 -0500 Subject: listamsb: refactor a bit (is_comment_start()). --- listamsb.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'listamsb.c') diff --git a/listamsb.c b/listamsb.c index 7d9ca81..e7dba8a 100644 --- a/listamsb.c +++ b/listamsb.c @@ -141,6 +141,10 @@ const char *plural(int count) { return count == 1 ? "" : "s"; } +int is_comment_start(unsigned char tok) { + return (tok == TOK_REM || tok == TOK_SQUOTE || tok == TOK_BANG); +} + /* post-processing: print "summary", exit. called by either die() or main() (on normal exit). */ void finish(int rv) { @@ -408,7 +412,7 @@ int next_line(void) { } else if(byte >= MIN_STD_TOK && byte <= MAX_STD_TOK) { /* statement token */ list_token(byte); - if(byte == TOK_SQUOTE || byte == TOK_BANG || byte == TOK_REM) + if(is_comment_start(byte)) in_comment = 1; } else if(byte >= 0x80) { /* invalid token */ @@ -515,7 +519,7 @@ int crunch_line(void) { } else { if(byte == '"') in_string = 1; - else if(byte == TOK_REM || byte == TOK_SQUOTE || byte == TOK_BANG) { + else if(is_comment_start(byte)) { in_comment = 1; commentstart = codelen; } @@ -629,7 +633,7 @@ int decrunch_line(void) { } else { if(byte == '"') { in_string = 1; - } else if(byte == TOK_REM || byte == TOK_SQUOTE || byte == TOK_BANG) { + } else if(is_comment_start(byte)) { in_comment = 1; } else if(byte == 0xff) { byte = read_prog_byte(); -- cgit v1.2.3