Marco Gidde
2004-06-08 13:16:41 UTC
Both STRING-LEFT-TRIM and STRING-RIGHT-TRIM raise
first check the index and then access the character with CHAR:
Index: cl-strings.el
===================================================================
RCS file: /usr/local/cvsroot/emacs-cl/cl-strings.el,v
retrieving revision 1.27
diff -u -3 -p -r1.27 cl-strings.el
--- cl-strings.el 1 Apr 2004 10:37:33 -0000 1.27
+++ cl-strings.el 8 Jun 2004 13:10:20 -0000
@@ -139,16 +139,16 @@
(setq string (STRING string))
(let ((i 0)
(len (LENGTH string)))
- (while (and (FIND (CHAR string i) chars)
- (< i len))
+ (while (and (< i len)
+ (FIND (CHAR string i) chars))
(incf i))
(SUBSEQ string i)))
(defun STRING-RIGHT-TRIM (chars string)
(setq string (STRING string))
(let* ((i (1- (LENGTH string))))
- (while (and (FIND (CHAR string i) chars)
- (>= i 0))
+ (while (and (>= i 0)
+ (FIND (CHAR string i) chars))
(decf i))
(SUBSEQ string 0 (1+ i))))
(EMACS-LISP:|args-out-of-range| " " -1)
when all characters of the string match. The while loop shouldfirst check the index and then access the character with CHAR:
Index: cl-strings.el
===================================================================
RCS file: /usr/local/cvsroot/emacs-cl/cl-strings.el,v
retrieving revision 1.27
diff -u -3 -p -r1.27 cl-strings.el
--- cl-strings.el 1 Apr 2004 10:37:33 -0000 1.27
+++ cl-strings.el 8 Jun 2004 13:10:20 -0000
@@ -139,16 +139,16 @@
(setq string (STRING string))
(let ((i 0)
(len (LENGTH string)))
- (while (and (FIND (CHAR string i) chars)
- (< i len))
+ (while (and (< i len)
+ (FIND (CHAR string i) chars))
(incf i))
(SUBSEQ string i)))
(defun STRING-RIGHT-TRIM (chars string)
(setq string (STRING string))
(let* ((i (1- (LENGTH string))))
- (while (and (FIND (CHAR string i) chars)
- (>= i 0))
+ (while (and (>= i 0)
+ (FIND (CHAR string i) chars))
(decf i))
(SUBSEQ string 0 (1+ i))))
--
Marco Gidde
Marco Gidde