source: project/release/5/scan-input-lines/trunk/scan-input-lines.scm @ 33085

Last change on this file since 33085 was 33085, checked in by evhan, 4 years ago

scan-input-lines: Convert to module

File size: 567 bytes
Line 
1;;;; scan-input-lines.scm - scan lines until regex or predicate matches
2
3(declare
4  (unit scan-input-lines)
5  (fixnum))
6
7(module scan-input-lines
8  (scan-input-lines)
9
10(import scheme chicken)
11(use extras irregex)
12
13;;; Scan lines until regex or predicate matches
14
15(define (scan-input-lines rx #!optional (port ##sys#standard-input))
16  (let ((rx (if (procedure? rx)
17                rx
18                (cute irregex-search (irregex rx) <>))))
19    (let loop ()
20      (let ((ln (read-line port)))
21        (and (not (eof-object? ln))
22             (or (rx ln) (loop))))))))
Note: See TracBrowser for help on using the repository browser.