[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
string comparison predicates return non-boolean values
Lindsay Smith reported the following bug in SISC, which turns out to be
present in the srfi-13 reference implementation:
#;> (string> "bar" "foo")
#;> (string> "foo" "bar")
The srfi-13 spec clearly states that the return value should be a
boolean. Further investigation shows that all string comparison
predicates suffer from this problem, returning a numeric value when they
should be returning #t.
The cause is found in the way %string-compare and %string-compare-ci are
called by the predicates. The procedures take three continuations as
arguments - for the <,=,> cases. These continuations are invoked with an
index. For string< the < continuation is 'values' and the other two are
(lambda (i) #f). So if the first k is invoked we end up with the index
as the result. Similarly for the other string comparison predicates.
The fix is to replace 'values' with (lambda (i) #t).