From bd9733926076885e3417b74de76e4c9c7bc56254 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Feb 2017 00:05:28 -0800 Subject: Import Upstream version 2c7 --- strsrch.scm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'strsrch.scm') diff --git a/strsrch.scm b/strsrch.scm index 68bcf0e..71c69df 100644 --- a/strsrch.scm +++ b/strsrch.scm @@ -66,16 +66,19 @@ (set! max-no-char (if (null? max-no-char) #f (car max-no-char))) (letrec ((no-chars-read 0) + (peeked? #f) (my-peek-char ; Return a peeked char or #f (lambda () (and (or (not (number? max-no-char)) (< no-chars-read max-no-char)) (let ((c (peek-char ))) - (and (not (eof-object? c)) - (if (procedure? max-no-char) - (not (max-no-char c)) - (not (eqv? max-no-char c))) - c))))) - (next-char (lambda () (read-char ) + (cond (peeked? c) + ((eof-object? c) #f) + ((procedure? max-no-char) + (set! peeked? #t) + (if (max-no-char c) #f c)) + ((eqv? max-no-char c) #f) + (else c)))))) + (next-char (lambda () (set! peeked? #f) (read-char ) (set! no-chars-read (+ 1 no-chars-read)))) (match-1st-char ; of the string str (lambda () -- cgit v1.2.3