aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-12 03:48:41 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-12 03:48:41 -0400
commitd3f053d40f01aa807c10f0699ed9ff4349150adc (patch)
treead9519867b0f913ce4a6cb674de3870a71d874e2
parent6def17acf5ab7b624b710bf3ae9f5714ebf90151 (diff)
downloadbw-atari8-tools-d3f053d40f01aa807c10f0699ed9ff4349150adc.tar.gz
listbas: add -d (dots) mode, for non-Unicode terminals.
-rw-r--r--listbas.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/listbas.c b/listbas.c
index 0a57623..d085460 100644
--- a/listbas.c
+++ b/listbas.c
@@ -27,28 +27,29 @@ const char **table = ata2utf;
FILE *outfh;
void print_help(void) {
- printf("Usage: %s [-a] [-b] [-d] [-i] [-m] [-n] [-v] <inputfile>\n", self);
+ printf("Usage: %s [-a | -d | -m] [-b] [-i] [-n] [-v] <inputfile>\n", self);
printf(" -a: output raw ATASCII.\n");
- printf(" -b: use bold for color output.\n");
printf(" -d: use dots instead of Unicode/UTF-8.\n");
- printf(" -i: show immediate mode command (line 32768).\n");
printf(" -m: magazine style listing (see a8cat(1)).\n");
+ printf(" -b: use bold for color output.\n");
+ printf(" -i: show immediate mode command (line 32768).\n");
printf(" -n: disable color syntax highlighting.\n");
printf(" -v: verbose.\n");
}
void parse_args(int argc, char **argv) {
int opt;
+ int opt_a = 0, opt_m = 0, opt_d = 0;
while( (opt = getopt(argc, argv, "viamnbdh")) != -1) {
switch(opt) {
case 'v': verbose = 1; break;
case 'i': immediate = 1; break;
- case 'a': utf8 = magazine = 0; color = 0; break;
- case 'm': utf8 = 0 ; magazine = 1; color = 0; table = ata2mag; break;
+ case 'a': opt_a = 1; break;
+ case 'm': opt_m = 1; break;
+ case 'd': opt_d = 1; break;
case 'n': color = 0; break;
case 'b': bold = 1; break;
- case 'd': dots = 1; break;
case 'h': print_help(); exit(0);
default:
print_help();
@@ -56,6 +57,21 @@ void parse_args(int argc, char **argv) {
}
}
+ if(opt_a + opt_d + opt_m > 1)
+ die("Only use one of the -a, -d, -m options.");
+
+ if(opt_a) {
+ utf8 = magazine = color = dots = 0;
+ table = ata2utf;
+ } else if(opt_d) {
+ magazine = 0;
+ utf8 = dots = 1;
+ } else if(opt_m) {
+ magazine = 1;
+ utf8 = color = dots = 0;
+ table = ata2mag;
+ }
+
if(optind >= argc)
die("No input file given (use - for stdin).");
else
@@ -182,8 +198,10 @@ void print_ata_chr(unsigned char c) {
}
if(dots)
fputc(isprint(c & 0x7f) ? c & 0x7f : '.', outfh);
- else
+ else if(utf8 || magazine)
fputs(table[c & 0x7f], outfh);
+ else
+ putchar(c);
}
void print_string(unsigned int pos, unsigned int len) {