return the quit args.
(scm-style-repl): call -quit, passing return value from
error-catching-repl. Make -quit return its args.
- stand-along-repl: comment out, since it seems unused.
- (top-repl): convert the value returned by scm-style-repl to
- an integer and return it.
+ stand-alone-repl: comment out, since it seems unused.
(error-catching-loop thunk): discard trailing junk after a (quit).
;; (set-current-error-port errp)
(define (top-repl)
- ;; scm-style-repl returns the list of arguments from quit: convert to
- ;; an integer status and return.
- (let ((quit-args (scm-style-repl)))
- (if (null? quit-args)
- 0
- (let ((cqa (car quit-args)))
- (cond ((number? cqa) cqa)
- ((eq? cqa #f) 1)
- (else 0))))))
+ (scm-style-repl))
(defmacro false-if-exception (expr)
`(catch #t (lambda () ,expr)
+Sun Mar 2 06:37:31 1997 Gary Houston <ghouston@actrix.gen.nz>
+
+ * throw.h: prototype for scm_exit_status.
+ * throw.c (scm_handle_by_message): if a 'quit is caught, use its
+ args to derive an exit status. Allows (quit) to work from a
+ script.
+ (scm_exit_status): new function.
+ #include "eq.h".
+
Sat Mar 1 00:09:15 1997 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
* eval.c (scm_deval): Removed some old code.
#include "smob.h"
#include "alist.h"
#include "eval.h"
+#include "eq.h"
#include "dynwind.h"
#include "backtrace.h"
#ifdef DEBUG_EXTENSIONS
char *prog_name = (char *) handler_data;
SCM p = scm_def_errp;
+ if (SCM_NFALSEP (scm_eq_p (tag, SCM_CAR (scm_intern0 ("quit")))))
+ exit (scm_exit_status (args));
+
if (! prog_name)
prog_name = "guile";
exit (2);
}
+/* Derive the an exit status from the arguments to (quit ...). */
+int
+scm_exit_status (args)
+ SCM args;
+{
+ if (SCM_NNULLP (args))
+ {
+ SCM cqa = SCM_CAR (args);
+
+ if (SCM_INUMP (cqa))
+ return (SCM_INUM (cqa));
+ else if (SCM_FALSEP (cqa))
+ return 1;
+ }
+ return 0;
+}
+
SCM_PROC(s_throw, "throw", 1, 0, 1, scm_throw);
SCM
extern SCM scm_handle_by_proc SCM_P ((void *, SCM, SCM));
extern SCM scm_handle_by_message SCM_P ((void *, SCM, SCM));
+extern int scm_exit_status SCM_P ((SCM args));
extern SCM scm_catch SCM_P ((SCM tag, SCM thunk, SCM handler));
extern SCM scm_lazy_catch SCM_P ((SCM tag, SCM thunk, SCM handler));
extern SCM scm_ithrow SCM_P ((SCM key, SCM args, int noreturn));
+
extern SCM scm_throw SCM_P ((SCM key, SCM args));
extern void scm_init_throw SCM_P ((void));
#endif /* THROWH */