Discussion:
STRING-TRIM
Marco Gidde
2004-06-08 13:16:41 UTC
Permalink
Both STRING-LEFT-TRIM and STRING-RIGHT-TRIM raise
(EMACS-LISP:|args-out-of-range| " " -1)
when all characters of the string match. The while loop should
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))))
--
Marco Gidde
Lars Brinkhoff
2004-06-08 15:44:47 UTC
Permalink
Both STRING-LEFT-TRIM and STRING-RIGHT-TRIM raise [an error] when
all characters of the string match.
Thanks, fixed in CVS.
diff -u -3 -p -r1.27 cl-strings.el
A nice option when diffing Lisp files is -F"^(def" or similar.
--
Lars Brinkhoff, Services for Unix, Linux, GCC, HTTP
Brinkhoff Consulting http://www.brinkhoff.se/
Marco Gidde
2004-06-08 17:08:23 UTC
Permalink
Post by Lars Brinkhoff
Post by Marco Gidde
diff -u -3 -p -r1.27 cl-strings.el
A nice option when diffing Lisp files is -F"^(def" or similar.
I knew something was missing :-)

Thanks
--
Marco Gidde
Loading...