mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-28 16:00:22 +02:00
(regexp-quote): Use string-for-each, now that function is
in the core.
This commit is contained in:
parent
91f5e9f7ec
commit
9b694b12e3
1 changed files with 13 additions and 15 deletions
|
@ -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
|
||||
|
@ -101,20 +101,18 @@
|
|||
(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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue