mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-03 05:20:16 +02:00
Add commentary; nfc.
This commit is contained in:
parent
cb8aa0ead8
commit
3ae7cde94f
1 changed files with 30 additions and 10 deletions
|
@ -39,6 +39,26 @@
|
||||||
;;;; whether to permit this exception to apply to your modifications.
|
;;;; whether to permit this exception to apply to your modifications.
|
||||||
;;;; If you do not wish that, delete this exception notice.
|
;;;; If you do not wish that, delete this exception notice.
|
||||||
;;;;
|
;;;;
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;; These procedures are exported:
|
||||||
|
;; (match:count match)
|
||||||
|
;; (match:string match)
|
||||||
|
;; (match:prefix match)
|
||||||
|
;; (match:suffix match)
|
||||||
|
;; (regexp-match? match)
|
||||||
|
;; (regexp-quote string)
|
||||||
|
;; (match:start match . submatch-num)
|
||||||
|
;; (match:end match . submatch-num)
|
||||||
|
;; (match:substring match . submatch-num)
|
||||||
|
;; (string-match pattern str . start)
|
||||||
|
;; (regexp-substitute port match . items)
|
||||||
|
;; (fold-matches regexp string init proc . flags)
|
||||||
|
;; (list-matches regexp string . flags)
|
||||||
|
;; (regexp-substitute/global port regexp string . items)
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
;;;; POSIX regex support functions.
|
;;;; POSIX regex support functions.
|
||||||
|
|
||||||
|
@ -83,16 +103,16 @@
|
||||||
(loop (+ 1 i)))
|
(loop (+ 1 i)))
|
||||||
(else #f)))))
|
(else #f)))))
|
||||||
|
|
||||||
(define (regexp-quote regexp)
|
(define (regexp-quote string)
|
||||||
(call-with-output-string
|
(call-with-output-string
|
||||||
(lambda (p)
|
(lambda (p)
|
||||||
(let loop ((i 0))
|
(let loop ((i 0))
|
||||||
(and (< i (string-length regexp))
|
(and (< i (string-length string))
|
||||||
(begin
|
(begin
|
||||||
(case (string-ref regexp i)
|
(case (string-ref string i)
|
||||||
((#\* #\. #\( #\) #\+ #\? #\\ #\^ #\$ #\{ #\})
|
((#\* #\. #\( #\) #\+ #\? #\\ #\^ #\$ #\{ #\})
|
||||||
(write-char #\\ p)))
|
(write-char #\\ p)))
|
||||||
(write-char (string-ref regexp i) p)
|
(write-char (string-ref string i) p)
|
||||||
(loop (1+ i))))))))
|
(loop (1+ i))))))))
|
||||||
|
|
||||||
(define (match:start match . args)
|
(define (match:start match . args)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue