(regexp-quote): Use string-for-each, now that function is
authorKevin Ryde <user42@zip.com.au>
Fri, 28 Jan 2005 21:10:55 +0000 (21:10 +0000)
committerKevin Ryde <user42@zip.com.au>
Fri, 28 Jan 2005 21:10:55 +0000 (21:10 +0000)
in the core.

ice-9/regex.scm

index 3d1bd3a..d6e666d 100644 (file)
@@ -1,4 +1,4 @@
-;;;;   Copyright (C) 1997, 1999, 2001, 2004 Free Software Foundation, Inc.
+;;;;   Copyright (C) 1997, 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
 (define (regexp-quote string)
   (call-with-output-string
    (lambda (p)
-     (let loop ((i 0))
-       (and (< i (string-length string))
-           (begin
-             (case (string-ref string i)
-               ((#\* #\. #\\ #\^ #\$ #\[)
-                (write-char #\\ p)
-                (write-char (string-ref string i) p))
-               ((#\( #\) #\+ #\? #\{ #\} #\|)
-                (write-char #\[ p)
-                (write-char (string-ref string i) p)
-                (write-char #\] p))
-               (else
-                (write-char (string-ref string i) p)))
-             (loop (1+ i))))))))
+     (string-for-each (lambda (c)
+                       (case c
+                         ((#\* #\. #\\ #\^ #\$ #\[)
+                          (write-char #\\ p)
+                          (write-char c p))
+                         ((#\( #\) #\+ #\? #\{ #\} #\|)
+                          (write-char #\[ p)
+                          (write-char c p)
+                          (write-char #\] p))
+                         (else
+                          (write-char c p))))
+                     string))))
 
 (define (match:start match . args)
   (let* ((matchnum (if (pair? args)