fixed mangled comment.
[bpt/guile.git] / ice-9 / regex.scm
index fb4a93e..97eb011 100644 (file)
@@ -1,15 +1,15 @@
 ;;;;   Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
-;;;; 
+;;;;
 ;;;; 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
 ;;;; the Free Software Foundation; either version 2, or (at your option)
 ;;;; any later version.
-;;;; 
+;;;;
 ;;;; This program is distributed in the hope that it will be useful,
 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;;;; GNU General Public License for more details.
-;;;; 
+;;;;
 ;;;; You should have received a copy of the GNU General Public License
 ;;;; along with this software; see the file COPYING.  If not, write to
 ;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 ;;;; If you write modifications of your own for GUILE, it is your choice
 ;;;; whether to permit this exception to apply to your modifications.
 ;;;; 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:
 \f
 ;;;; POSIX regex support functions.
 
                (loop (+ 1 i)))
               (else #f)))))
 
-(define (regexp-quote regexp)
+(define (regexp-quote string)
   (call-with-output-string
    (lambda (p)
      (let loop ((i 0))
-       (and (< i (string-length regexp))
+       (and (< i (string-length string))
            (begin
-             (case (string-ref regexp i)
+             (case (string-ref string i)
                ((#\* #\. #\( #\) #\+ #\? #\\ #\^ #\$ #\{ #\})
                 (write-char #\\ p)))
-             (write-char (string-ref regexp i) p)
+             (write-char (string-ref string i) p)
              (loop (1+ i))))))))
 
 (define (match:start match . args)
              ;; for-each, because we need to make sure 'post at the
              ;; end of the item list is a tail call.
              (let next-item ((items items))
-         
+
                (define (do-item item)
                  (cond
                   ((string? item)    (display item port))
                   ((integer? item)   (display (match:substring m item) port))
                   ((procedure? item) (display (item m) port))
-                  ((eq? item 'pre)  
+                  ((eq? item 'pre)
                    (display
                     (substring string start (match:start m))
                     port))