[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/03: style: '-f' reads input files as UTF-8 by default.
From: |
guix-commits |
Subject: |
01/03: style: '-f' reads input files as UTF-8 by default. |
Date: |
Sun, 20 Nov 2022 17:23:01 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 82bde985f47a84b9b05a2adc26c2f2cee278b1f5
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Nov 20 22:52:16 2022 +0100
style: '-f' reads input files as UTF-8 by default.
Reported by mirai on #guix.
* guix/scripts/style.scm (format-whole-file): Wrap body in
'with-fluids'. Pass #:guess-encoding to 'call-with-input-file'.
---
guix/scripts/style.scm | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm
index c0b9ea1a28..fa7175fb16 100644
--- a/guix/scripts/style.scm
+++ b/guix/scripts/style.scm
@@ -335,13 +335,15 @@ PACKAGE."
(define* (format-whole-file file #:rest rest)
"Reformat all of FILE."
- (let ((lst (call-with-input-file file read-with-comments/sequence)))
- (with-atomic-file-output file
- (lambda (port)
- (apply pretty-print-with-comments/splice port lst
- #:format-comment canonicalize-comment
- #:format-vertical-space canonicalize-vertical-space
- rest)))))
+ (with-fluids ((%default-port-encoding "UTF-8"))
+ (let ((lst (call-with-input-file file read-with-comments/sequence
+ #:guess-encoding #t)))
+ (with-atomic-file-output file
+ (lambda (port)
+ (apply pretty-print-with-comments/splice port lst
+ #:format-comment canonicalize-comment
+ #:format-vertical-space canonicalize-vertical-space
+ rest))))))
;;;