two bugs in reference implementation of SRFI 13
Jamison Hope 24 Dec 2011 19:48 UTC
A Kawa user just discovered a bug in string-contains, which I tracked
down to the reference implementation of make-kmp-restart-vector.
string-parse-start+end is documented to return three values:
"rest start end", but in make-kmp-restart-vector its result is bound
to two variables (start end). I found the same issue in
string-kmp-partial-search, which also attempts to capture only the
"start" and "end" values.
The fix in both places is to call string-parse-final-start+end instead,
which strips off the first unwanted rest value from string-parse-start
+end.
--- srfi-13.scm 2006-11-21 16:18:11.000000000 -0500
+++ srfi-13-fixed.scm 2011-12-22 15:17:59.000000000 -0500
@@ -1381,7 +1381,7 @@
(let-optionals* maybe-c=+start+end
((c= char=? (procedure? c=))
((start end) (lambda (args)
- (string-parse-start+end make-kmp-restart-vector
+ (string-parse-final-start+end make-kmp-restart-vector
pattern args))))
(let* ((rvlen (- end start))
(rv (make-vector rvlen -1)))
@@ -1450,7 +1450,7 @@
((c= char=? (procedure? c=))
(p-start 0 (and (integer? p-start) (exact? p-start) (<= 0 p-
start)))
((s-start s-end) (lambda (args)
- (string-parse-start+end string-kmp-partial-search
+ (string-parse-final-start+end string-kmp-partial-search
s args))))
(let ((patlen (vector-length rv)))
(check-arg (lambda (i) (and (integer? i) (exact? i) (<= 0 i)
(< i patlen)))
--
Jamison Hope
The PTR Group
www.theptrgroup.com