Better checks for EOF
This commit is contained in:
parent
1bf429571f
commit
076fe6f24b
18
vcarded.scm
18
vcarded.scm
|
@ -253,7 +253,7 @@
|
||||||
(and first-element?
|
(and first-element?
|
||||||
(string-contains line "BEGIN")
|
(string-contains line "BEGIN")
|
||||||
(string-contains line "VCARD")))
|
(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
|
;; 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.
|
;; line *isn’t* a BEGIN:VCARD line, then the file probably isn’t a vCard.
|
||||||
[#t
|
[#t
|
||||||
|
@ -268,10 +268,12 @@
|
||||||
;; Reader-thunk. Read a “logical” folded-line, where a line beginning with a
|
;; Reader-thunk. Read a “logical” folded-line, where a line beginning with a
|
||||||
;; space is a continuation of the previous line — like with vcards.
|
;; space is a continuation of the previous line — like with vcards.
|
||||||
(define (read-folded-line #!optional limit)
|
(define (read-folded-line #!optional limit)
|
||||||
(let [(line (read-line (current-input-port) limit))]
|
(if (not (eof-object? (peek-char)))
|
||||||
(if (or (eq? (peek-char) #\space)
|
(let [(line (read-line (current-input-port) limit))]
|
||||||
(eq? (peek-char) #\tab))
|
(if (or (eq? (peek-char) #\space)
|
||||||
(string-concatenate
|
(eq? (peek-char) #\tab))
|
||||||
(list line
|
(string-concatenate
|
||||||
(string-drop (read-folded-line) 1)))
|
(list line
|
||||||
line))))
|
(string-drop (read-folded-line) 1)))
|
||||||
|
line))
|
||||||
|
"")))
|
||||||
|
|
Ŝarĝante…
Reference in New Issue