diff options
author | David N. Welton <davidw@efn.org> | 1998-11-09 21:18:01 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:27 -0800 |
commit | 926b1b647ac830660933a5e63eb52d4a2552e264 (patch) | |
tree | e25db5f6e1441d67f5d9af063432018ee20a5f51 /strsrch.scm | |
parent | b21cac3362022718634f7086964208b2eed8e897 (diff) | |
parent | fa3f23105ddcf07c5900de47f19af43d1db1b597 (diff) | |
download | slib-926b1b647ac830660933a5e63eb52d4a2552e264.tar.gz slib-926b1b647ac830660933a5e63eb52d4a2552e264.zip |
Import Debian changes 2c3-3debian/2c3-3
slib (2c3-3) frozen unstable; urgency=low
* Fixes #16235.
* Fixes #19943.
* Fixes #20265.
* Fixes #24917.
* Fixes #27389.
slib (2c3-2) frozen unstable; urgency=low
* Re-uploaded for slink freeze.
slib (2c3-1) unstable; urgency=low
* New upstream release.
Diffstat (limited to 'strsrch.scm')
-rw-r--r-- | strsrch.scm | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/strsrch.scm b/strsrch.scm index b25c229..68bcf0e 100644 --- a/strsrch.scm +++ b/strsrch.scm @@ -1,6 +1,6 @@ ;;; "MISCIO" Search for string from port. ; Written 1995, 1996 by Oleg Kiselyov (oleg@ponder.csci.unt.edu) -; Modified 1996, 1997 by A. Jaffer (jaffer@ai.mit.edu) +; Modified 1996, 1997, 1998 by A. Jaffer (jaffer@ai.mit.edu) ; ; This code is in the public domain. @@ -121,3 +121,23 @@ (backtrack (+ 1 i) matched-substr-len)))))))) ) (match-1st-char))) + +(define (string-subst text old new . rest) + (define sub + (lambda (text) + (set! text + (cond ((equal? "" text) text) + ((substring? old text) + => (lambda (idx) + (string-append + (substring text 0 idx) + new + (sub (substring + text (+ idx (string-length old)) + (string-length text)))))) + (else text))) + (if (null? rest) + text + (apply string-subst text rest)))) + (sub text)) + |