From d79dd55a18cb158778fbdc796a60f27518d1f971 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 18 Jun 2024 06:53:54 -0400 Subject: cxrefbas and renumbas: round fractional line numbers like BASIC does. --- linetab.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'linetab.c') diff --git a/linetab.c b/linetab.c index 0351f59..59a96e3 100644 --- a/linetab.c +++ b/linetab.c @@ -93,6 +93,8 @@ void computed_msg(unsigned short lineno) { CALLBACK(got_var) { switch(last_cmd) { + /* any use of a variable in the arguments to these means + we can't renumber that argument. */ case CMD_GOTO: case CMD_GO_TO: case CMD_GOSUB: @@ -102,6 +104,7 @@ CALLBACK(got_var) { computed_msg(lineno); break; case CMD_ON: + /* vars are OK in ON, before the GOTO or GOSUB */ if(on_op) computed_msg(lineno); break; default: @@ -119,9 +122,14 @@ CALLBACK(got_exp) { } if(tok != OP_NUMCONST) return; + + /* beware: standalone only means nothing *follows* the constant + in the same expression. still have to check last_tok to see + what came before. */ standalone = is_standalone_num(pos); switch(last_cmd) { + /* these take a single argument */ case CMD_GOTO: case CMD_GO_TO: case CMD_GOSUB: @@ -134,11 +142,14 @@ CALLBACK(got_exp) { } break; case CMD_IF: + /* this only applies to bare line numbers, like IF A THEN 1000, + not IF A THEN GOTO 1000 (or anything else after THEN). */ if(last_tok == OP_THEN) { add_lineref(lineno, pos + 1); } break; case CMD_ON: { + /* takes arbitrary number of arguments */ switch(last_tok) { case OP_GOTO: case OP_GOSUB: @@ -154,6 +165,7 @@ CALLBACK(got_exp) { } break; case CMD_LIST: { + /* takes one or two arguments */ switch(last_tok) { case CMD_LIST: case OP_COMMA: -- cgit v1.2.3