Attached patch fixes ticket #870.
From 72b4138d0fd1f314f9129ea1bf54f67892e25d38 Mon Sep 17 00:00:00 2001
From: Jim Ursetto <[email protected]>
Date: Mon, 18 Jun 2012 20:16:24 -0500
Subject: [PATCH] Ensure that srfi-13 string= and its string-comparison
friends return booleans on success
This corrects a deficiency which exists in the reference implementation
and fixes ticket #870.
---
srfi-13.scm | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/srfi-13.scm b/srfi-13.scm
index 615cbb7..e4a0509 100644
--- a/srfi-13.scm
+++ b/srfi-13.scm
@@ -783,7 +783,7 @@
(or (and (eq? s1 s2) (= start1 start2)) ; Fast path
(%string-compare s1 start1 end1 s2 start2 end2 ; Real test
(lambda (i) #f)
- values
+ (lambda (i) (if i #t #f))
(lambda (i) #f))))))
(define (string<> s1 s2 . maybe-starts+ends)
@@ -792,9 +792,9 @@
(or (not (= (- end1 start1) (- end2 start2))) ; Fast path
(and (not (and (eq? s1 s2) (= start1 start2))) ; Quick filter
(%string-compare s1 start1 end1 s2 start2 end2 ; Real test
- values
+ (lambda (i) (if i #t #f))
(lambda (i) #f)
- values)))))
+ (lambda (i) (if i #t #f)))))))
(define (string< s1 s2 . maybe-starts+ends)
(let-string-start+end2 (start1 end1 start2 end2)
@@ -803,7 +803,7 @@
(< end1 end2)
(%string-compare s1 start1 end1 s2 start2 end2 ; Real test
- values
+ (lambda (i) (if i #t #f))
(lambda (i) #f)
(lambda (i) #f)))))
@@ -816,7 +816,7 @@
(%string-compare s1 start1 end1 s2 start2 end2 ; Real test
(lambda (i) #f)
(lambda (i) #f)
- values))))
+ (lambda (i) (if i #t #f))))))
(define (string<= s1 s2 . maybe-starts+ends)
(let-string-start+end2 (start1 end1 start2 end2)
@@ -825,8 +825,8 @@
(<= end1 end2)
(%string-compare s1 start1 end1 s2 start2 end2 ; Real test
- values
- values
+ (lambda (i) (if i #t #f))
+ (lambda (i) (if i #t #f))
(lambda (i) #f)))))
(define (string>= s1 s2 . maybe-starts+ends)
@@ -837,8 +837,8 @@
(%string-compare s1 start1 end1 s2 start2 end2 ; Real test
(lambda (i) #f)
- values
- values))))
+ (lambda (i) (if i #t #f))
+ (lambda (i) (if i #t #f))))))
(define (string-ci= s1 s2 . maybe-starts+ends)
(let-string-start+end2 (start1 end1 start2 end2)
@@ -847,7 +847,7 @@
(or (and (eq? s1 s2) (= start1 start2)) ; Fast path
(%string-compare-ci s1 start1 end1 s2 start2 end2 ; Real test
(lambda (i) #f)
- values
+ (lambda (i) (if i #t #f))
(lambda (i) #f))))))
(define (string-ci<> s1 s2 . maybe-starts+ends)
@@ -856,9 +856,9 @@
(or (not (= (- end1 start1) (- end2 start2))) ; Fast path
(and (not (and (eq? s1 s2) (= start1 start2))) ; Quick filter
(%string-compare-ci s1 start1 end1 s2 start2 end2 ; Real test
- values
+ (lambda (i) (if i #t #f))
(lambda (i) #f)
- values)))))
+ (lambda (i) (if i #t #f)))))))
(define (string-ci< s1 s2 . maybe-starts+ends)
(let-string-start+end2 (start1 end1 start2 end2)
@@ -867,7 +867,7 @@
(< end1 end2)
(%string-compare-ci s1 start1 end1 s2 start2 end2 ; Real test
- values
+ (lambda (i) (if i #t #f))
(lambda (i) #f)
(lambda (i) #f)))))
@@ -880,7 +880,7 @@
(%string-compare-ci s1 start1 end1 s2 start2 end2 ; Real test
(lambda (i) #f)
(lambda (i) #f)
- values))))
+ (lambda (i) (if i #t #f))))))
(define (string-ci<= s1 s2 . maybe-starts+ends)
(let-string-start+end2 (start1 end1 start2 end2)
@@ -889,8 +889,8 @@
(<= end1 end2)
(%string-compare-ci s1 start1 end1 s2 start2 end2 ; Real test
- values
- values
+ (lambda (i) (if i #t #f))
+ (lambda (i) (if i #t #f))
(lambda (i) #f)))))
(define (string-ci>= s1 s2 . maybe-starts+ends)
@@ -901,8 +901,8 @@
(%string-compare-ci s1 start1 end1 s2 start2 end2 ; Real test
(lambda (i) #f)
- values
- values))))
+ (lambda (i) (if i #t #f))
+ (lambda (i) (if i #t #f))))))
;;; Hash
--
1.7.6.1
On Jun 18, 2012, at 6:58 PM, Chicken Trac wrote:
> #870: SRFI-13's string comparison procedures return integers
> ----------------------------------------+-----------------------------------
> Reporter: mario | Owner:
> Type: defect | Status: new
> Priority: major | Milestone:
> Component: core libraries | Version: 4.7.x
> Keywords: srfi-13, string comparison |
> ----------------------------------------+-----------------------------------
> CHICKEN procedures from the srfi-13 unit for string comparison return
> integers, while SRFI-13 (and the wiki documentation for SRFI-13) state
> that they return booleans.
>
> The following SRFI-13 procedures (and their case-insensitive counterparts)
> return integers in chicken:
>
> * string=
> * string<>
> * string<=
> * string<
> * string>=
> * string>
>
> I'm not sure if the behavior of these procedures in CHICKEN deviate from
> SRFI-13's by design or if it is really a bug.
>
> If that's the intended behavior, we have to fix the documentation and add
> a note about that deviation.
>
> --
> Ticket URL: <http://bugs.call-cc.org/ticket/870>
> Chicken Scheme <http://www.call-with-current-continuation.org/>
> Chicken Scheme is a compiler for the Scheme programming language.
> _______________________________________________
> Chicken-janitors mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/chicken-janitors
_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers