From f4e44bec6441de72c1fdf3552747481bfae4d4a1 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sun, 28 May 2000 15:25:37 +0000 Subject: [PATCH] Modularize line-ending translator. --- v7/src/imail/imap-response.scm | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/v7/src/imail/imap-response.scm b/v7/src/imail/imap-response.scm index f1693fa6b..170d40e09 100644 --- a/v7/src/imail/imap-response.scm +++ b/v7/src/imail/imap-response.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Id: imap-response.scm,v 1.26 2000/05/28 15:16:51 cph Exp $ +;;; $Id: imap-response.scm,v 1.27 2000/05/28 15:25:37 cph Exp $ ;;; ;;; Copyright (c) 2000 Massachusetts Institute of Technology ;;; @@ -299,19 +299,18 @@ (loop start*))))) (if imap-transcript-port (write-string s imap-transcript-port)) - (translate-network-line-endings-to-scheme! s) + (let ((n* (translate-line-endings!:network->scheme string 0 n))) + (if (fix:< n* n) + (set-string-maximum-length! s n*))) s))) -(define (translate-network-line-endings-to-scheme! string) - (let ((n (string-length string))) - (let ((i (substring-search-forward "\r\n" string 0 n))) +(define (translate-line-endings!:network->scheme string start end) + (let loop ((start start) (end end)) + (let ((i (substring-search-forward "\r\n" string start end))) (if i - (let loop ((i i) (n n)) - (let* ((n (substring-move! string (fix:+ i 1) n string i)) - (i (substring-search-forward "\r\n" string (fix:+ i 1) n))) - (if i - (loop i n) - (set-string-maximum-length! string n)))))))) + (loop (fix:+ i 1) + (substring-move! string (fix:+ i 1) end string i)) + end)))) (define (read-list port #!optional read-item) (read-closed-list #\( #\) -- 2.25.1