From e4288a04fc0d14190743e6e2700315436d468817 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 25 May 2024 16:14:04 -0400 Subject: unprotbas: do not try to read tokenized BASIC from stdin if it's a terminal. --- unprotbas.1 | 2 +- unprotbas.c | 5 ++++- unprotbas.rst | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/unprotbas.1 b/unprotbas.1 index 33afa02..6f1fa8f 100644 --- a/unprotbas.1 +++ b/unprotbas.1 @@ -170,7 +170,7 @@ a new one that\(aqs valid. However, since there are no real variable names in the program, the recovery process just invents new ones, named A through Z, A1 through A9, B1 through B9, etc, etc. It\(aqll require human intelligence to figure out what each variable is for, -since the names are meaningless. +since the names are meaningless. See \fBVARIABLE NAMES\fP, below. .sp The \fBoutput\-file\fP may not be the exact size that the \fBinput\-file\fP was. Some types of variable\-name scrambling shrink diff --git a/unprotbas.c b/unprotbas.c index 1697aa8..4ed831f 100644 --- a/unprotbas.c +++ b/unprotbas.c @@ -633,6 +633,9 @@ FILE *open_file(const char *name, const char *mode) { void open_input(const char *name) { if(!name) { + if(isatty(fileno(stdin))) { + die("can't read binary data from the terminal"); + } if(freopen(NULL, "rb", stdin)) { input_file = stdin; return; @@ -648,7 +651,7 @@ void open_input(const char *name) { void open_output(const char *name) { if(!name) { if(isatty(fileno(stdout))) { - die("refusing to write binary data to standard output"); + die("refusing to write binary data to the terminal"); } if(freopen(NULL, "wb", stdout)) { output_file = stdout; diff --git a/unprotbas.rst b/unprotbas.rst index c8584e8..743559b 100644 --- a/unprotbas.rst +++ b/unprotbas.rst @@ -144,7 +144,7 @@ Variable name table scrambling names in the program, the recovery process just invents new ones, named A through Z, A1 through A9, B1 through B9, etc, etc. It'll require human intelligence to figure out what each variable is for, - since the names are meaningless. + since the names are meaningless. See **VARIABLE NAMES**, below. The **output-file** may not be the exact size that the **input-file** was. Some types of variable-name scrambling shrink -- cgit v1.2.3