From b0eec4c320253238aa528d3899fc70a7eab91379 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 5 Jul 2024 04:28:40 -0400 Subject: listbas: error exit on bad tokens. --- listbas.1 | 12 ++++++------ listbas.c | 18 +++++++++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/listbas.1 b/listbas.1 index 110fde5..13d53f4 100644 --- a/listbas.1 +++ b/listbas.1 @@ -45,6 +45,10 @@ escape sequences for inverse video and color syntax highlighting. .SS List options .INDENT 0.0 .TP +.B \fB\-a\fP +Output raw ATASCII; no translation to the host character set. Must be +used with redirection; \fBlistbas\fP will not write ATASCII to the terminal. +.TP .B \fB\-b\fP Use bold, for color output. This may make it easier to read on some terminals. Or, it may hurt your eyes... @@ -52,16 +56,12 @@ some terminals. Or, it may hurt your eyes... .B \fB\-i\fP Include the immediate mode command (line 32768) in the output. .TP -.B \fB\-a\fP -Output raw ATASCII; no translation to the host character set. Must be -used with redirection; \fBlistbas\fP will not write ATASCII to the terminal. +.B \fB\-m\fP +Output "magazine listing". See the \fB\-m\fP option for \fBa8cat\fP for details. .TP .B \fB\-n\fP No color. Has no effect if \fB\-a\fP or \fB\-m\fP are in effect, since these modes don\(aqt support color anyway. -.TP -.B \fB\-m\fP -Output "magazine listing". See the \fB\-m\fP option for \fBa8cat\fP for details. .UNINDENT .SS General Options .INDENT 0.0 diff --git a/listbas.c b/listbas.c index 7421816..fd7d8aa 100644 --- a/listbas.c +++ b/listbas.c @@ -19,7 +19,8 @@ #define C_PURPLE 5 #define C_CYAN 6 -int immediate = 0, utf8 = 1, magazine = 0, inv = 0, color = 1, bold = 0; +int immediate = 0, utf8 = 1, magazine = 0, inv = 0, + color = 1, bold = 0, badtok = 0; const char **table = ata2utf; @@ -200,10 +201,12 @@ CALLBACK(print_cmd) { if(tok == CMD_ILET) return; if(color) color_on(C_YELLOW); - if(tok > last_command || (!(name = commands[tok]))) + if(tok > last_command || (!(name = commands[tok]))) { fprintf(outfh, "(bad cmd token $%02x) ", tok); - else + badtok = 1; + } else { fprintf(outfh, "%s ", name); + } if(color) color_off(); } @@ -232,10 +235,12 @@ CALLBACK(print_op) { else color_on(C_GREEN); } - if(tok > last_operator || (!(name = operators[tok]))) + if(tok > last_operator || (!(name = operators[tok]))) { fprintf(outfh, "(bad op token $%02x)", tok); - else + badtok = 1; + } else { fprintf(outfh, "%s", name); + } if(color) color_off(); } @@ -316,5 +321,8 @@ int main(int argc, char **argv) { setup_outfh(); list(); + if(badtok) + die("program has unknown tokens; maybe Turbo BASIC or BASIC XL/XE?"); + return 0; } -- cgit v1.2.3