From 5706d9907a1ccfdeb4743e84610d185cb6611eec Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sat, 20 May 2000 20:08:37 +0000 Subject: [PATCH] Supply missing STRING-GREATEST-COMMON-PREFIX, needed by completion code. --- v7/src/imail/imail-util.scm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/v7/src/imail/imail-util.scm b/v7/src/imail/imail-util.scm index f7d2dbbf5..4cf8edba9 100644 --- a/v7/src/imail/imail-util.scm +++ b/v7/src/imail/imail-util.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Id: imail-util.scm,v 1.21 2000/05/20 19:36:28 cph Exp $ +;;; $Id: imail-util.scm,v 1.22 2000/05/20 20:08:37 cph Exp $ ;;; ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology ;;; @@ -241,6 +241,32 @@ (define (burst-comma-list-string string) (list-transform-negative (map string-trim (burst-string string #\, #f)) string-null?)) + +(define (string-greatest-common-prefix strings) + (let loop + ((strings (cdr strings)) + (string (car strings)) + (index (string-length (car strings)))) + (if (null? strings) + (substring string 0 index) + (let ((string* (car strings))) + (let ((index* (string-match-forward string string*))) + (if (< index* index) + (loop (cdr strings) string* index*) + (loop (cdr strings) string index))))))) + +(define (string-greatest-common-prefix-ci strings) + (let loop + ((strings (cdr strings)) + (string (car strings)) + (index (string-length (car strings)))) + (if (null? strings) + (substring string 0 index) + (let ((string* (car strings))) + (let ((index* (string-match-forward-ci string string*))) + (if (< index* index) + (loop (cdr strings) string* index*) + (loop (cdr strings) string index))))))) ;;;; Broken-pipe handler -- 2.25.1