aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jindroush/Makefile6
-rw-r--r--jindroush/man/chkbas.18
-rw-r--r--jindroush/man/chkbas.rst6
-rw-r--r--listbas.c92
4 files changed, 40 insertions, 72 deletions
diff --git a/jindroush/Makefile b/jindroush/Makefile
index 0a11a8f..605dc70 100644
--- a/jindroush/Makefile
+++ b/jindroush/Makefile
@@ -54,9 +54,3 @@ install: all
chmod 644 $(DESTDIR)/$(MAN1DIR)/$$i.1 ; \
[ "$(GZIP_MAN)" = "y" ] && gzip -f $(DESTDIR)/$(MAN1DIR)/$$i.1 ; \
done
- ln -sf chkbas $(DESTDIR)$(BINDIR)/listbas
- if [ "$(GZIP_MAN)" = "y" ]; then \
- ln -sf chkbas.1.gz $(DESTDIR)$(MAN1DIR)/listbas.1.gz ; \
- else \
- ln -sf chkbas.1 $(DESTDIR)$(MAN1DIR)/listbas.1 ; \
- fi
diff --git a/jindroush/man/chkbas.1 b/jindroush/man/chkbas.1
index 5fbcbae..1f5313a 100644
--- a/jindroush/man/chkbas.1
+++ b/jindroush/man/chkbas.1
@@ -27,14 +27,12 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "CHKBAS" 1 "2024-05-19" "1.10" "Jindroush's Atari 8-bit tools"
+.TH "CHKBAS" 1 "2024-06-25" "1.10" "Jindroush's Atari 8-bit tools"
.SH NAME
chkbas \- check and detokenize Atari BASIC SAVEd files
.SH SYNOPSIS
.sp
chkbas [\fB\-atari\fP] [\fB\-short\fP] [\fB\-verbose\fP] [\fB\-noinverse\fP] [\fB\-tbs\fP | \fB\-bxl\fP | \fB\-bxe\fP] \fBbasic\-file\fP [\fBoutput\-file\fP]
-.sp
-listbas [\fB\-atari\fP] [\fB\-verbose\fP] [\fB\-noinverse\fP] [\fB\-tbs\fP | \fB\-bxl\fP | \fB\-bxe\fP] \fBbasic\-file\fP [\fBoutput\-file\fP]
.SH DESCRIPTION
.sp
\fBchkbas\fP detokenizes Atari 8\-bit BASIC SAVEd files. It lists the BASIC
@@ -47,8 +45,6 @@ standard output. If \fBbasic\-file\fP is anything other than standard
Atari BASIC, the BASIC dialect must be specified (see \fBOPTIONS\fP,
below).
.sp
-\fBlistbas\fP is simply an alias for \fBchkbas \-short\fP\&.
-.sp
Sample run, with no options:
.INDENT 0.0
.INDENT 3.5
@@ -125,7 +121,7 @@ EOL characters (\fB$9B\fP).
.B \fB\-short\fP
Output only the program listing, with lines terminated by the
system default newline character(s), e.g. \fBn\fP on UNIX\-like OSes,
-\fBrn\fP on MS\-DOS or Windows. This is the default for \fBlistbas\fP\&.
+\fBrn\fP on MS\-DOS or Windows.
.TP
.B \fB\-verbose\fP
Program listing will be interspersed with per\-line and per\-statement
diff --git a/jindroush/man/chkbas.rst b/jindroush/man/chkbas.rst
index 2ab92e7..e16f475 100644
--- a/jindroush/man/chkbas.rst
+++ b/jindroush/man/chkbas.rst
@@ -15,8 +15,6 @@ SYNOPSIS
chkbas [**-atari**] [**-short**] [**-verbose**] [**-noinverse**] [**-tbs** | **-bxl** | **-bxe**] **basic-file** [**output-file**]
-listbas [**-atari**] [**-verbose**] [**-noinverse**] [**-tbs** | **-bxl** | **-bxe**] **basic-file** [**output-file**]
-
DESCRIPTION
===========
@@ -30,8 +28,6 @@ standard output. If **basic-file** is anything other than standard
Atari BASIC, the BASIC dialect must be specified (see **OPTIONS**,
below).
-**listbas** is simply an alias for **chkbas -short**.
-
Sample run, with no options::
$ chkbas HELLO.BAS
@@ -103,7 +99,7 @@ Output Options
**-short**
Output only the program listing, with lines terminated by the
system default newline character(s), e.g. **\n** on UNIX-like OSes,
- **\r\n** on MS-DOS or Windows. This is the default for **listbas**.
+ **\r\n** on MS-DOS or Windows.
**-verbose**
Program listing will be interspersed with per-line and per-statement
diff --git a/listbas.c b/listbas.c
index bc56695..2cb9dcc 100644
--- a/listbas.c
+++ b/listbas.c
@@ -45,6 +45,40 @@ void parse_args(int argc, char **argv) {
open_input(argv[optind]);
}
+void setup_outfh(void) {
+ const char *cmd;
+
+ /* search current dir before PATH. no easy way to detect errors here,
+ have to wait until we call pclose(). */
+ if(a8eol) {
+ cmd = "./a8eol -u -c 2>/dev/null || a8eol -u -c 2>/dev/null || exit 1";
+ } else if(a8utf8) {
+ cmd = "./a8utf8 2>/dev/null || a8utf8 2>/dev/null || exit 1";
+ } else {
+ if(isatty(fileno(stdout))) {
+ die("Refusing to write ATASCII data to the terminal.");
+ }
+ outfh = stdout;
+ return;
+ }
+
+ outfh = popen(cmd, "w");
+ if(!outfh) {
+ /* fork() or pipe() failed. does NOT detect if the command
+ wasn't found. */
+ perror(self);
+ exit(1);
+ }
+}
+
+void close_outfh(void) {
+ if(a8eol || a8utf8) {
+ if(pclose(outfh)) {
+ die("output filter failed; a8eol or a8utf8 not in current dir or $PATH.");
+ }
+ }
+}
+
void outchr(char c) {
putc(c, outfh);
}
@@ -89,27 +123,17 @@ CALLBACK(print_lineno) {
}
CALLBACK(print_cmd) {
- int bad;
const char *name;
if(tok == CMD_ILET) return;
- if(tok > last_command) {
- bad = 1;
- } else if( (name = commands[tok]) ) {
- bad = 0;
- } else {
- bad = 1;
- }
-
- if(bad)
- fprintf(outfh, "(bad cmd token $%02x)", tok);
+ if(tok > last_command || (!(name = commands[tok])))
+ fprintf(outfh, "(bad cmd token $%02x) ", tok);
else
fprintf(outfh, "%s ", name);
}
CALLBACK(print_op) {
- int bad;
const char *name;
switch(tok) {
@@ -125,15 +149,7 @@ CALLBACK(print_op) {
}
- if(tok > last_operator) {
- bad = 1;
- } else if( (name = operators[tok]) ) {
- bad = 0;
- } else {
- bad = 1;
- }
-
- if(bad)
+ if(tok > last_operator || (!(name = operators[tok])))
fprintf(outfh, "(bad op token $%02x)", tok);
else
fprintf(outfh, "%s", name);
@@ -162,40 +178,6 @@ CALLBACK(print_newline) {
outchr(0x9b);
}
-void setup_outfh(void) {
- const char *cmd;
-
- /* search current dir before PATH. no easy way to detect errors here,
- have to wait until we call pclose(). */
- if(a8eol) {
- cmd = "./a8eol -u -c 2>/dev/null || a8eol -u -c 2>/dev/null || exit 1";
- } else if(a8utf8) {
- cmd = "./a8utf8 2>/dev/null || a8utf8 2>/dev/null || exit 1";
- } else {
- if(isatty(fileno(stdout))) {
- die("Refusing to write ATASCII data to the terminal.");
- }
- outfh = stdout;
- return;
- }
-
- outfh = popen(cmd, "w");
- if(!outfh) {
- /* fork() or pipe() failed. does NOT detect if the command
- wasn't found. */
- perror(self);
- exit(1);
- }
-}
-
-void close_outfh(void) {
- if(a8eol || a8utf8) {
- if(pclose(outfh)) {
- die("output filter failed; a8eol or a8utf8 not in current dir or $PATH.");
- }
- }
-}
-
CALLBACK(code_prot) {
fprintf(stderr, "%s: Program is code-protected, stopping at line %d.\n", self, lineno);
close_outfh();