aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--listamsb.112
-rw-r--r--listamsb.c9
-rw-r--r--listamsb.rst12
3 files changed, 22 insertions, 11 deletions
diff --git a/listamsb.1 b/listamsb.1
index a800004..c30c65e 100644
--- a/listamsb.1
+++ b/listamsb.1
@@ -32,7 +32,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
listamsb \- List the source of a tokenized Atari Microsoft BASIC program
.SH SYNOPSIS
.sp
-listamsb [\fB\-a\fP] [\fB\-v\fP] [\fB\-h\fP] [\fB\-i\fP] [\fB\-u\fP] [\fB\-t\fP] [\fB\-m\fP] [\fB\-s\fP] [\fB\-r\fP \fIline\-range\fP] [\fBinput\-file\fP]
+listamsb [\fB\-l\fP] | [[\fB\-a\fP] [\fB\-v\fP] [\fB\-h\fP] [\fB\-i\fP] [\fB\-u\fP] [\fB\-t\fP] [\fB\-m\fP] [\fB\-n\fP] [\fB\-s\fP] ...] [\fB\-r\fP \fIline\-range\fP] [\fBinput\-file\fP]
.SH DESCRIPTION
.sp
\fBlistamsb\fP acts like the \fILIST\fP command in Atari Microsoft BASIC. It reads a
@@ -95,6 +95,10 @@ listamsb \-l LOCKED.AMB > UNLOCKED.AMB
\fBa8cat\fP is not used with this option. None of the other options
have any effect with \fB\-l\fP\&.
.TP
+.B \fB\-n\fP
+No empty line. By default, \fBlistamsb\fP prints an empty line at the
+start of the output, to match AMSB\(aqs LIST command.
+.TP
.B \fB\-v\fP
Verbose output, on stderr. May be given twice for extra verbosity,
which shows each line number, its offset, length, and end\-of\-line pointer.
@@ -198,9 +202,9 @@ More likely, it means this is an Atari BASIC file.
program size doesn\(aqt match size in header
.sp
Might mean this isn\(aqt an AMSB file. If you\(aqre sure it is, it might
-be truncated, or part of the file might have been overwritten
-with \fI$00\fP bytes. It could also mean the length in the header has
-somehow gotten corrupted.
+be truncated, or part of the file might have been overwritten with
+\fI$00\fP bytes. It could also mean the length in the header has somehow
+gotten corrupted.
.IP \(bu 2
trailing garbage at end of file
.sp
diff --git a/listamsb.c b/listamsb.c
index 52d7bc7..182f928 100644
--- a/listamsb.c
+++ b/listamsb.c
@@ -80,6 +80,7 @@ int check_only = 0; /* -c */
int startline = 0; /* -r */
int endline = 65536; /* -r */
int unlock_mode = 0; /* -l */
+int initial_eol = 1; /* -n */
int locked = 0;
int need_pclose = 0;
@@ -305,7 +306,7 @@ int next_line(void) {
}
/* AMSB always prints a blank line when it LISTs, so we do too. */
- if(last_lineno == -1) fputc(EOL, outfile);
+ if(initial_eol && (last_lineno == -1)) fputc(EOL, outfile);
last_lineno = lineno;
@@ -451,10 +452,11 @@ void unlock_program(void) {
void print_help(void) {
printf("%s v" VERSION " - detokenize Atari Microsoft BASIC files\n", self);
puts("By B. Watson <urchlay@slackware.uk>, released under the WTFPL");
- printf("Usage: %s [[-l] | [-a] [-v] [-h] [-i] [-u] [-t] [-m] [-s] [-r *start,end*]] [file]\n", self);
+ printf("Usage: %s [[-l] | [-a] [-v] [-h] [-i] [-n] [-u] [-t] [-m] [-s] [-r *start,end*]] [file]\n", self);
puts(" -a: raw ATASCII output");
puts(" -c: check only (no listing)");
puts(" -l: lock or unlock program");
+ puts(" -n: no blank line at start of listing");
puts(" -v: verbosity");
puts(" -r: only list lines numbered from *start* to *end*");
puts(" --help, -h: print this help and exit");
@@ -512,12 +514,13 @@ void parse_args(int argc, char **argv) {
}
}
- while( (opt = getopt(argc, argv, "lr:cvaiutmsh")) != -1) {
+ while( (opt = getopt(argc, argv, "nlr:cvaiutmsh")) != -1) {
switch(opt) {
case 'l': unlock_mode = 1; break;
case 'c': check_only = 1; break;
case 'a': raw_output = 1; break;
case 'v': verbosity++ ; break;
+ case 'n': initial_eol = 0; break;
case 'h': print_help(); exit(0);
case 'r': get_line_range(optarg); break;
case 'i':
diff --git a/listamsb.rst b/listamsb.rst
index 91fa4e9..32d7f78 100644
--- a/listamsb.rst
+++ b/listamsb.rst
@@ -11,7 +11,7 @@ List the source of a tokenized Atari Microsoft BASIC program
SYNOPSIS
========
-listamsb [**-a**\] [**-v**\] [**-h**\] [**-i**\] [**-u**\] [**-t**\] [**-m**\] [**-s**\] [**-r** *line-range*] [**input-file**\]
+listamsb [**-l**] | [[**-a**\] [**-v**\] [**-h**\] [**-i**\] [**-u**\] [**-t**\] [**-m**\] [**-n**\] [**-s**\] ...] [**-r** *line-range*] [**input-file**\]
DESCRIPTION
===========
@@ -69,6 +69,10 @@ OPTIONS
**a8cat** is not used with this option. None of the other options
have any effect with **-l**.
+**-n**
+ No empty line. By default, **listamsb** prints an empty line at the
+ start of the output, to match AMSB's LIST command.
+
**-v**
Verbose output, on stderr. May be given twice for extra verbosity,
which shows each line number, its offset, length, and end-of-line pointer.
@@ -174,9 +178,9 @@ continues processing.
- program size doesn't match size in header
Might mean this isn't an AMSB file. If you're sure it is, it might
- be truncated, or part of the file might have been overwritten
- with *$00* bytes. It could also mean the length in the header has
- somehow gotten corrupted.
+ be truncated, or part of the file might have been overwritten with
+ *$00* bytes. It could also mean the length in the header has somehow
+ gotten corrupted.
- trailing garbage at end of file