(defun string< (s1 s2)
(let ((len-1 (length s1))
- (len-2 (length s2)))
- (cond ((= len-2 0) nil)
- ((= len-1 0) 0)
- (t (dotimes (i len-1 nil)
- (when (char< (char s1 i) (char s2 i))
- (return-from string< i)))))))
-
+ (len-2 (length s2)))
+ (cond ((= len-2 0) nil)
+ ((= len-1 0) 0)
+ (t (dotimes (i len-1 nil)
+ (when (char< (char s1 i) (char s2 i))
+ (return-from string< i))
+ (when (and (= i (1- len-1)) (> len-2 len-1))
+ (return-from string< (1+ i))))))))
+
(define-setf-expander char (string index)
(let ((g!string (gensym))
(g!index (gensym))
(test (null (string< "" "")))
(test (null (string< "a" "")))
(test (= (string< "" "a") 0))
+(test (= (string< "aaa" "aaaaa") 3))
;;; BUG: The compiler will macroexpand the forms below (char str N)
;;; will expand to internal SBCL code instead of our (setf char). It