From 076fe6f24bcd8c2bcf6431bda02b70aa60ed465e Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Tue, 13 Feb 2024 17:59:20 -0600 Subject: [PATCH] Better checks for EOF --- vcarded.scm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/vcarded.scm b/vcarded.scm index d1abfb4..5e666da 100644 --- a/vcarded.scm +++ b/vcarded.scm @@ -253,7 +253,7 @@ (and first-element? (string-contains line "BEGIN") (string-contains line "VCARD"))) - (parse-vcard-line (read-folded-line))] + (parse-vcard-line line)] ;; If we’re still making sure the file is vCard, and the first non-blank ;; line *isn’t* a BEGIN:VCARD line, then the file probably isn’t a vCard. [#t @@ -268,10 +268,12 @@ ;; Reader-thunk. Read a “logical” folded-line, where a line beginning with a ;; space is a continuation of the previous line — like with vcards. (define (read-folded-line #!optional limit) - (let [(line (read-line (current-input-port) limit))] - (if (or (eq? (peek-char) #\space) - (eq? (peek-char) #\tab)) - (string-concatenate - (list line - (string-drop (read-folded-line) 1))) - line)))) + (if (not (eof-object? (peek-char))) + (let [(line (read-line (current-input-port) limit))] + (if (or (eq? (peek-char) #\space) + (eq? (peek-char) #\tab)) + (string-concatenate + (list line + (string-drop (read-folded-line) 1))) + line)) + "")))