From ed910cdfa474bd7a3fd0cf3082119abc41b094e4 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 16 Jun 2024 18:04:09 -0400 Subject: cxrefbas: computed warning now says ON/GOTO or ON/GOSUB, not just ON. --- cxrefbas.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'cxrefbas.c') diff --git a/cxrefbas.c b/cxrefbas.c index 45369d4..7cc3114 100644 --- a/cxrefbas.c +++ b/cxrefbas.c @@ -11,7 +11,7 @@ unsigned short *linerefs[32769]; int refcounts[32769]; int lines_exist[32769]; -int last_cmd; +unsigned char last_cmd, on_op; int last_cmd_pos; void add_lineref(unsigned short from, unsigned short to) { @@ -57,9 +57,10 @@ CALLBACK(start_stmt) { CALLBACK(got_cmd) { last_cmd = tok; last_cmd_pos = pos; + on_op = 0; } -void computed_msg(unsigned char tok, unsigned short lineno) { +void computed_msg(unsigned short lineno) { static int last_lineno = -1; char *cmd; @@ -67,7 +68,7 @@ void computed_msg(unsigned char tok, unsigned short lineno) { if(lineno == last_lineno) return; last_lineno = lineno; - switch(tok) { + switch(last_cmd) { case CMD_GOTO: cmd = "GOTO"; break; case CMD_GO_TO: @@ -79,7 +80,11 @@ void computed_msg(unsigned char tok, unsigned short lineno) { case CMD_TRAP: cmd = "TRAP"; break; case CMD_ON: - cmd = "ON"; break; + if(on_op == OP_GOSUB) + cmd = "ON/GOSUB"; + else + cmd = "ON/GOTO"; + break; default: /* should never happen! */ cmd = "???"; break; } @@ -94,7 +99,7 @@ CALLBACK(got_var) { case CMD_GOSUB: case CMD_RESTORE: case CMD_TRAP: - computed_msg(last_cmd, lineno); + computed_msg(lineno); break; default: break; @@ -104,6 +109,11 @@ CALLBACK(got_var) { CALLBACK(got_exp) { int standalone; + if(last_cmd == CMD_ON) { + if(tok == OP_GOTO || tok == OP_GOSUB) + on_op = tok; + } + if(tok != OP_NUMCONST) return; standalone = is_standalone_num(pos); @@ -116,7 +126,7 @@ CALLBACK(got_exp) { if((pos == last_cmd_pos + 1) && standalone) { add_lineref(lineno, fp2int(program + pos + 1)); } else { - computed_msg(last_cmd, lineno); + computed_msg(lineno); } break; case CMD_ON: { @@ -128,7 +138,7 @@ CALLBACK(got_exp) { if(standalone) add_lineref(lineno, fp2int(program + pos + 1)); else - computed_msg(last_cmd, lineno); + computed_msg(lineno); break; default: break; -- cgit v1.2.3