[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Exit on eof
If you're annoyed that kcl dies on ^D, here's a patch to fix it.
Replace the existing feof1 in c/file.d with this:
-------------
bool
feof1(fp)
FILE *fp;
{
if (!feof(fp))
return(FALSE);
if (fp == terminal_io->sm.sm_object0->sm.sm_fp) {
#ifdef UNIX
clearerr(fp);
#endif
#ifdef AOSVS
#endif
if (symbol_value(siVignore_eof_on_terminal_io) == Cnil)
return(TRUE);
return(FALSE);
}
return(TRUE);
}
--------
In lsp/top.lsp, replace the lines in function top-level
(setq - (locally (declare (notinline read))
(read *standard-input* nil *eof*)))
(when (eq - *eof*) (bye))
by
(setq - (locally (declare (notinline read))
(read *standard-input* nil nil)))
Replace the lines in function break-level
(setq - (locally (declare (notinline read))
(read *standard-input* nil *eof*)))
(when (eq - *eof*) (bye))
by
(setq - (locally (declare (notinline read))
(read *standard-input* nil :quit)))
This makes a ^D in the top level behave like a nil,
and like a :quit in the break loop.
Now the only way to exit is to call (bye) explicitly.
(And you can get into infinite loops sometimes.)
We solved this problem by replacing the unconditional (bye)
with a confirmation. I won't post a version of this.
Instead, if there is enough interest, I will post the code
for an entirely new top level that we have been running
for around two years. It has many new features, including
an integrated tracer and stepper.
The fix to feof1 is worthwhile by itself.