aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dla2csv.c29
-rw-r--r--dla2csv.xexbin11338 -> 11322 bytes
2 files changed, 18 insertions, 11 deletions
diff --git a/dla2csv.c b/dla2csv.c
index 5d9c083..1cc6769 100644
--- a/dla2csv.c
+++ b/dla2csv.c
@@ -156,6 +156,19 @@ void show_dir(char drive) {
closedir(dir);
if(column) putchar('\n');
}
+
+/* On the Atari, EOF is Ctrl-3. *Terrible* things happen if we
+ ever get EOF on stdin on the Atari! The screen shows gibberish
+ (display list gets mangled). Even calling exit() doesn't help.
+
+ There's not really a way to avoid this (other than not using stdin,
+ or hoping your users never press Ctrl-3), but we can avoid crashing
+ the Atari by jumping directly to DOS (do not call the exit stuff from
+ cc65's runtime, do not pass Go, do not collect $200). This seems to
+ work reliably, but I hesistate to document "Press Ctrl-3 to exit"...
+*/
+ #define exit_eof_stdin() (*(OS.dosvec))()
+
#else
/* non-Atari is assumed to be POSIX (and not something like
Commodore or Apple II). */
@@ -166,6 +179,7 @@ void show_dir(char drive) {
#define enable_break() noop()
#define disable_break() noop()
#define init_console() noop()
+ #define exit_eof_stdin() exit(1)
#endif
char inbuf[INBUF_SIZE];
@@ -185,20 +199,13 @@ char *eoltypes[][2] = {
};
/* Read a string from stdin (E: on the Atari).
- Exit on EOF (or Break key on the Atari, except we disable it).
- On Linux, EOF is the ^D character, and this works.
- On the Atari, EOF is ^3... On DOS 2.0S, we end up back at the DUP
- menu... but SpartaDOS 3.2d locks up with a black screen. So don't
- document ctrl-3 as a way to exit the program (too bad), and just
- hope the user never presses it.
+ Exit if we get EOF on stdin (e.g. ^D on Linux, ^3 on Atari).
+ See exit_eof_stdin() comments above.
*/
void readstring(void) {
- char *result;
memset(stringbuf, 0, STRINGBUF_SIZE);
- result = fgets(stringbuf, STRINGBUF_SIZE - 1, stdin);
- if(result == NULL) {
- exit(1);
- }
+ if(fgets(stringbuf, STRINGBUF_SIZE - 1, stdin) == NULL)
+ exit_eof_stdin();
}
int prompt_yn(char *prompt, int default_y) {
diff --git a/dla2csv.xex b/dla2csv.xex
index ece05b8..eaaec27 100644
--- a/dla2csv.xex
+++ b/dla2csv.xex
Binary files differ