diff lisp/subr.el @ 414:da8ed4261e83 r21-2-15

Import from CVS: tag r21-2-15
author cvs
date Mon, 13 Aug 2007 11:21:38 +0200
parents 697ef44129c6
children ebe98a74bd68
line wrap: on
line diff
--- a/lisp/subr.el	Mon Aug 13 11:20:44 2007 +0200
+++ b/lisp/subr.el	Mon Aug 13 11:21:38 2007 +0200
@@ -294,10 +294,14 @@
 If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
   (or pattern
       (setq pattern "[ \f\t\n\r\v]+"))
-  ;; The FSF version of this function takes care not to cons in case
-  ;; of infloop.  Maybe we should synch?
-  (let (parts (start 0))
-    (while (string-match pattern string start)
+  (let (parts (start 0) (len (length string)))
+    (if (string-match pattern string)
+	(setq parts (cons (substring string 0 (match-beginning 0)) parts)
+	      start (match-end 0)))
+    (while (and (< start len)
+		(string-match pattern string (if (> start (match-beginning 0))
+						 start
+					       (1+ start))))
       (setq parts (cons (substring string start (match-beginning 0)) parts)
 	    start (match-end 0)))
     (nreverse (cons (substring string start) parts))))