mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 21:10:27 +02:00
Add commentary; nfc.
This commit is contained in:
parent
cb8aa0ead8
commit
3ae7cde94f
1 changed files with 30 additions and 10 deletions
|
@ -1,15 +1,15 @@
|
||||||
;;;; Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
|
;;;; Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This program is free software; you can redistribute it and/or modify
|
;;;; This program is free software; you can redistribute it and/or modify
|
||||||
;;;; it under the terms of the GNU General Public License as published by
|
;;;; it under the terms of the GNU General Public License as published by
|
||||||
;;;; the Free Software Foundation; either version 2, or (at your option)
|
;;;; the Free Software Foundation; either version 2, or (at your option)
|
||||||
;;;; any later version.
|
;;;; any later version.
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This program is distributed in the hope that it will be useful,
|
;;;; This program is distributed in the hope that it will be useful,
|
||||||
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
;;;; GNU General Public License for more details.
|
;;;; GNU General Public License for more details.
|
||||||
;;;;
|
;;;;
|
||||||
;;;; You should have received a copy of the GNU General Public License
|
;;;; You should have received a copy of the GNU General Public License
|
||||||
;;;; along with this software; see the file COPYING. If not, write to
|
;;;; along with this software; see the file COPYING. If not, write to
|
||||||
;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
@ -38,7 +38,27 @@
|
||||||
;;;; If you write modifications of your own for GUILE, it is your choice
|
;;;; If you write modifications of your own for GUILE, it is your choice
|
||||||
;;;; 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)
|
||||||
|
@ -197,13 +217,13 @@
|
||||||
;; for-each, because we need to make sure 'post at the
|
;; for-each, because we need to make sure 'post at the
|
||||||
;; end of the item list is a tail call.
|
;; end of the item list is a tail call.
|
||||||
(let next-item ((items items))
|
(let next-item ((items items))
|
||||||
|
|
||||||
(define (do-item item)
|
(define (do-item item)
|
||||||
(cond
|
(cond
|
||||||
((string? item) (display item port))
|
((string? item) (display item port))
|
||||||
((integer? item) (display (match:substring m item) port))
|
((integer? item) (display (match:substring m item) port))
|
||||||
((procedure? item) (display (item m) port))
|
((procedure? item) (display (item m) port))
|
||||||
((eq? item 'pre)
|
((eq? item 'pre)
|
||||||
(display
|
(display
|
||||||
(substring string start (match:start m))
|
(substring string start (match:start m))
|
||||||
port))
|
port))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue