+Sun Nov 9 06:10:59 1997 Gary Houston <ghouston@actrix.gen.nz>
+
+ * boot-9.scm (set-batch-mode?!, batch-mode?): initialize more
+ usefully so they will work from a script.
+
1997-10-31 Marius Vollmer <mvo@zagadka.ping.de>
* boot-9.scm (inherit-print-state): Moved definition to the
(define abort-hook '())
-;; defined in error-catching-loop as a closures.
-(define set-batch-mode?! #f)
-(define batch-mode? #f)
+;; these definitions are used if running a script.
+;; otherwise redefined in error-catching-loop.
+(define (set-batch-mode?! arg) #t)
+(define (batch-mode?) #t)
(define (error-catching-loop thunk)
(let ((status #f)
;;;;
\f
-(define-module (ice-9 expect))
+(define-module (ice-9 expect) :use-module (ice-9 regex))
;;; Expect: a macro for selecting actions based on what it reads from a port.
;;; The idea is from Don Libes' expect based on Tcl.
(cond
,@(let next-expr ((tests (map car clauses))
(exprs (map cdr clauses))
- (body ()))
+ (body '()))
(cond
((null? tests)
(reverse body))
(cons
`((,(car tests) ,s)
,@(cond ((null? (car exprs))
- ())
+ '())
((eq? (caar exprs) '=>)
(if (not (= (length (car exprs))
2))
(defmacro-public expect-strings clauses
`(let ,@(let next-test ((tests (map car clauses))
(exprs (map cdr clauses))
- (defs ())
- (body ()))
+ (defs '())
+ (body '()))
(cond ((null? tests)
(list (reverse defs) `(expect ,@(reverse body))))
(else
regexp/newline))
defs)
(cons `((lambda (s)
- (regexp-exec ,rxname s))
+ (expect-regexec ,rxname s))
,@(car exprs))
body))))))))
(/ (cdr secs-usecs)
1000000)))) ; one million.
(and (> relative 0)
- (pair? (car (select (list port) () ()
+ (pair? (car (select (list port) '() '()
relative))))))
+
+;;; convert a match object to a list of strings, for the => syntax.
+(define-public (expect-regexec rx s)
+ (let ((match (regexp-exec rx s)))
+ (if match
+ (do ((i (- (match:count match) 1) (- i 1))
+ (result '() (cons (match:substring match i) result)))
+ ((< i 0) result))
+ #f)))