From b5c02fa3b2b8e46b8536a2a443e88c1d88150bdd Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 8 May 2000 14:53:09 +0000 Subject: [PATCH] Implement NETWORK-STRING->LINES. --- v7/src/imail/imail-util.scm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/v7/src/imail/imail-util.scm b/v7/src/imail/imail-util.scm index 7c0410530..30c786d80 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.12 2000/05/02 20:59:35 cph Exp $ +;;; $Id: imail-util.scm,v 1.13 2000/05/08 14:53:09 cph Exp $ ;;; ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology ;;; @@ -206,4 +206,21 @@ (string-set! s j #\newline) (loop (cdr indexes) (fix:+ (car indexes) 2) (fix:+ j 1))) (substring-move! string i end s j))) - s))) \ No newline at end of file + s))) + +(define (network-string->lines string) + (network-substring->lines string 0 (string-length string))) + +(define (network-substring->lines string start end) + (let loop + ((start start) + (indexes (substring-search-all "\r\n" string start end)) + (lines '())) + (if (pair? indexes) + (loop (fix:+ (car indexes) 2) + (cdr indexes) + (cons (substring string start (car indexes)) lines)) + (reverse! + (if (fix:< start end) + (cons (substring string start end) lines) + lines))))) \ No newline at end of file -- 2.25.1