(define (input-port/read-line port)
(port/with-input-blocking-mode port 'BLOCKING
(lambda ()
- (let loop ((a (make-accum 128)))
- (let ((char (input-port/read-char port)))
- (cond ((eof-object? char)
- (if (fix:> (accum-count a) 0)
- (accum->string a)
- char))
- ((char=? char #\newline) (accum->string a))
- (else (loop (accum char a)))))))))
+ (let ((read-char (port/operation/read-char port)))
+ (let loop ((a (make-accum 128)))
+ (let ((char (read-char port)))
+ (cond ((eof-object? char)
+ (if (fix:> (accum-count a) 0)
+ (accum->string a)
+ char))
+ ((char=? char #\newline) (accum->string a))
+ (else (loop (accum char a))))))))))
(define (input-port/read-string port delimiters)
(port/with-input-blocking-mode port 'BLOCKING
(lambda ()
- (let loop ((a (make-accum 128)))
- (let ((char (input-port/read-char port)))
- (cond ((eof-object? char)
- (if (fix:> (accum-count a) 0)
- (accum->string a)
- char))
- ((char-set-member? delimiters char)
- (input-port/unread-char port char)
- (accum->string a))
- (else
- (loop (accum char a)))))))))
+ (let ((read-char (port/operation/read-char port)))
+ (let loop ((a (make-accum 128)))
+ (let ((char (read-char port)))
+ (cond ((eof-object? char)
+ (if (fix:> (accum-count a) 0)
+ (accum->string a)
+ char))
+ ((char-set-member? delimiters char)
+ (input-port/unread-char port char)
+ (accum->string a))
+ (else
+ (loop (accum char a))))))))))
(define (input-port/discard-chars port delimiters)
(port/with-input-blocking-mode port 'BLOCKING
(lambda ()
- (let loop ()
- (let ((char (input-port/read-char port)))
- (cond ((eof-object? char)
- unspecific)
- ((char-set-member? delimiters char)
- (input-port/unread-char port char))
- (else
- (loop))))))))
+ (let ((read-char (port/operation/read-char port)))
+ (let loop ()
+ (let ((char (read-char port)))
+ (cond ((eof-object? char)
+ unspecific)
+ ((char-set-member? delimiters char)
+ (input-port/unread-char port char))
+ (else
+ (loop)))))))))
(define-integrable (make-accum n)
(cons (make-string n) 0))