From 1f4aa08899a9681807928d9a8cd83eca2a79df78 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Thu, 6 Apr 2000 04:23:01 +0000 Subject: [PATCH] Fix a handful of small bugs. --- v7/src/imail/imail-util.scm | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/v7/src/imail/imail-util.scm b/v7/src/imail/imail-util.scm index b9aacb4ea..afe909896 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.6 2000/04/06 03:14:36 cph Exp $ +;;; $Id: imail-util.scm,v 1.7 2000/04/06 04:23:01 cph Exp $ ;;; ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology ;;; @@ -111,12 +111,14 @@ lines)) (define (string->lines string) - (let ((lines (burst-string string #\newline #f))) - (if (pair? (cdr lines)) - (let loop ((prev lines) (this (cdr lines))) - (cond ((pair? (cdr this)) (loop this (cdr this))) - ((string-null? (car this)) (set-cdr! prev (cdr this)))))) - lines)) + (if (string-null? string) + '() + (let ((lines (burst-string string #\newline #f))) + (if (pair? (cdr lines)) + (let loop ((prev lines) (this (cdr lines))) + (cond ((pair? (cdr this)) (loop this (cdr this))) + ((string-null? (car this)) (set-cdr! prev (cdr this)))))) + lines))) (define (lines->string lines) (suffixed-append lines "\n")) @@ -176,7 +178,7 @@ (fix:+ count (fix:+ (string-length (car tokens)) ns)))) ((not (pair? tokens)) count)))))) - (let loop ((tokens (cdr tokens)) (index 0)) + (let loop ((tokens tokens) (index 0)) (if (pair? tokens) (loop (cdr tokens) (string-move! suffix @@ -195,7 +197,7 @@ (fix:+ count (fix:+ (string-length (car tokens)) ns)))) ((not (pair? tokens)) count)))))) - (let loop ((tokens (cdr tokens)) (index 0)) + (let loop ((tokens tokens) (index 0)) (if (pair? tokens) (loop (cdr tokens) (string-move! (car tokens) @@ -215,7 +217,9 @@ (begin (string-set! to ti (string-ref from fi)) (loop (fix:+ fi 1) (fix:+ ti 1))))) - (substring-move-left! from 0 end to index)))) + (begin + (substring-move-left! from 0 end to index) + (fix:+ index end))))) (define (read-lines port) (source->list (lambda () (read-line port)))) -- 2.25.1