Bug 775567 - Importing QIF file from PayPal crashes GnuCash 2.6.14 on Windows XP service pack 3

Guile-1.8 doesn't know about BOM so check for one and strip it if it's there.
This commit is contained in:
John Ralls 2016-12-04 12:35:42 -08:00
parent 755c42a087
commit f382695345

View File

@ -96,6 +96,25 @@
(string-append str "\n" (_ "Read aborted.")))
(set! abort-read #t)))
(define (strip-bom)
(let ((c1 (read-char)))
(if (char=? c1 (integer->char #xEF))
(let ((c2 (read-char)))
(if (char=? c2 (integer->char #xBB))
(let ((c3 (read-char)))
(if (char=? c3 (integer->char #xBF)) #t
(begin
(unread-char c3)
(unread-char c2)
(unread-char c1)
#f)))
(begin
(unread-char c2)
(unread-char c1)
#f)))
(begin
(unread-char c1)
#f))))
(qif-file:set-path! self path)
(if (not (access? path R_OK))
@ -112,6 +131,7 @@
(with-input-from-file path
(lambda ()
(strip-bom)
;; loop over lines
(let line-loop ()
(set! line (read-delimited delimiters))