From e3f8380d66eba3ad987c99f3b4035c8bdbf30f46 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Wed, 26 Jul 2017 16:05:54 -0700 Subject: [PATCH] runtime/stringio (string-in/read-substring): Swap src/dst strings. --- src/runtime/stringio.scm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/runtime/stringio.scm b/src/runtime/stringio.scm index b717aa0d9..b101a87af 100644 --- a/src/runtime/stringio.scm +++ b/src/runtime/stringio.scm @@ -97,10 +97,12 @@ USA. (let ((string* (istate-string ss)) (start* (istate-next ss)) (end* (istate-end ss))) - (let ((n (fix:min (fix:- end start) (fix:- end* start*)))) - (string-copy! string* start* string start (fix:+ start n)) - (set-istate-next! ss (fix:+ start* n)) - n)))) + (if (fix:= start* end*) + 0 + (let ((n (fix:min (fix:- end start) (fix:- end* start*)))) + (string-copy! string start string* start* (fix:+ start* n)) + (set-istate-next! ss (fix:+ start* n)) + n))))) (define (string-in/unread-char port char) (let ((ss (textual-port-state port))) -- 2.25.1