aboutsummaryrefslogtreecommitdiff
path: root/listbas.c
diff options
context:
space:
mode:
Diffstat (limited to 'listbas.c')
-rw-r--r--listbas.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/listbas.c b/listbas.c
index 328330b..338e8d0 100644
--- a/listbas.c
+++ b/listbas.c
@@ -482,12 +482,22 @@ const char *get_bxl_ext_name(unsigned char tok) {
void clear_callbacks(void);
void init_callbacks(void);
+int cmd_is_if;
+
+CALLBACK(find_cmd_if) {
+ cmd_is_if = 0;
+ if((bas_type == B_APLUS && tok == 0x06) || (bas_type != B_APLUS && tok == CMD_IF)) {
+ cmd_is_if = 1;
+ if_without_then++; /* find_then() decrements it, if there's a THEN */
+ }
+}
+
CALLBACK(find_op_then) {
if(verbose)
fprintf(stderr, "find_op_then lineno %d, pos %04x, tok %02x\n", lineno, pos, tok);
- if(tok == OP_THEN)
- if_without_then = 0;
+ if(cmd_is_if && tok == OP_THEN)
+ if_without_then--;
}
/* walk_code()'s API isn't really set up to be reentrant, but we
@@ -495,6 +505,7 @@ CALLBACK(find_op_then) {
void find_then(int lineno, unsigned short pos) {
clear_callbacks();
on_exp_token = find_op_then;
+ on_cmd_token = find_cmd_if;
walk_code(lineno, lineno);
init_callbacks();
}
@@ -504,11 +515,12 @@ CALLBACK(print_lineno) {
first_stmt = 1;
- cmd_tok = program[pos + 4];
- if_without_then = 0;
- if((bas_type == B_APLUS && cmd_tok == 0x06) || (bas_type != B_APLUS && cmd_tok == CMD_IF)) {
- if_without_then = 1; /* find_then() clears it, if there's a THEN */
- find_then(lineno, pos);
+ if(indent) {
+ cmd_tok = program[pos + 4];
+ if_without_then = 0;
+ if((bas_type == B_APLUS && cmd_tok == 0x06) || (bas_type != B_APLUS && cmd_tok == CMD_IF)) {
+ find_then(lineno, pos);
+ }
}
if(skip_lineno) return;