From: Fredrik Tolf Date: Thu, 15 Nov 2007 15:16:43 +0000 (+0100) Subject: Nicer, recursive implementation of read-hl. X-Git-Tag: 1.1~38 X-Git-Url: http://dolda2000.com/gitweb/?p=doldaconnect.git;a=commitdiff_plain;h=91328d65ff872c86ee23f38e87793b853b6404ea Nicer, recursive implementation of read-hl. --- diff --git a/lib/guile/hubmgr b/lib/guile/hubmgr index 5d8de74..8da04f5 100755 --- a/lib/guile/hubmgr +++ b/lib/guile/hubmgr @@ -50,22 +50,18 @@ (list r1 r2 l2))) (define (read-hl) - (catch 'system-error - (lambda () - (let ((p (open-input-file hl-file))) - (catch 'eof - (lambda () - (let ((lines '())) - (while #t - (let ((line (read-line p))) - (if (eof-object? line) - (throw 'eof lines) - (let ((lexed (dc-lexsexpr line))) - (if (> (length lexed) 0) - (set! lines (append lines (list lexed)))))))))) - (lambda (s a) (close-port p) a)))) - (lambda (key . args) - '()))) + (letrec ((read-lines (lambda (lines p) + (let ((line (read-line p))) + (if (eof-object? line) + (begin (close-port p) + lines) + (read-lines (let ((lexed (dc-lexsexpr line))) + (if (> (length lexed) 0) + (append lines (list lexed)) + lines)) p)))))) + (catch 'system-error + (lambda () (read-lines '() (open-input-file hl-file))) + (lambda (key . args) '())))) (define (cklist) (set! statelist (let ((nl '()) (ct (current-time)))