[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
13/16: ui: Don't use '%default-port-encoding' to set the encoding of str
From: |
Ludovic Courtès |
Subject: |
13/16: ui: Don't use '%default-port-encoding' to set the encoding of string ports. |
Date: |
Wed, 8 Mar 2017 17:44:34 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit 1062063a65036f32a061c54866d33ffe079ec44e
Author: Ludovic Courtès <address@hidden>
Date: Wed Mar 8 22:21:31 2017 +0100
ui: Don't use '%default-port-encoding' to set the encoding of string ports.
* guix/ui.scm (right-arrow): Call 'set-port-encoding!' to set PORT's
encoding; remove use of 'with-fluids'. This is for compatibility with
Guile 2.2 where the encoding of string ports is not influenced by
%DEFAULT-PORT-ENCODING.
* tests/ui.scm ("show-manifest-transaction"): Likewise.
---
guix/ui.scm | 21 +++++++++++----------
tests/ui.scm | 11 +++++++----
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/guix/ui.scm b/guix/ui.scm
index 5ae082f..3a0a650 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -635,16 +635,17 @@ report what is prerequisites are available for download."
(define (right-arrow port)
"Return either a string containing the 'RIGHT ARROW' character, or an ASCII
replacement if PORT is not Unicode-capable."
- (with-fluids ((%default-port-encoding (port-encoding port)))
- (let ((arrow "→"))
- (catch 'encoding-error
- (lambda ()
- (call-with-output-string
- (lambda (port)
- (set-port-conversion-strategy! port 'error)
- (display arrow port))))
- (lambda (key . args)
- "->")))))
+ (let ((encoding (port-encoding port))
+ (arrow "→"))
+ (catch 'encoding-error
+ (lambda ()
+ (call-with-output-string
+ (lambda (port)
+ (set-port-encoding! port encoding)
+ (set-port-conversion-strategy! port 'error)
+ (display arrow port))))
+ (lambda (key . args)
+ "->"))))
(define* (show-manifest-transaction store manifest transaction
#:key dry-run?)
diff --git a/tests/ui.scm b/tests/ui.scm
index 058207e..cfe417d 100644
--- a/tests/ui.scm
+++ b/tests/ui.scm
@@ -248,9 +248,12 @@ Second line" 24))
(lambda ()
(show-manifest-transaction store m t)))))
(string-match "guile\t1.8.8 -> 2.0.9"
- (with-fluids ((%default-port-encoding "ISO-8859-1"))
- (with-error-to-string
- (lambda ()
- (show-manifest-transaction store m t)))))))))
+ (with-error-to-string
+ (lambda ()
+ ;; In Guile 2.2, %DEFAULT-PORT-ENCODING doesn't
+ ;; influence the encoding of string ports.
+ (set-port-encoding! (current-error-port)
+ "ISO-8859-1")
+ (show-manifest-transaction store m t))))))))
(test-end "ui")
- 03/16: services: prosody: Make sure 'id' is available at expansion time., (continued)
- 03/16: services: prosody: Make sure 'id' is available at expansion time., Ludovic Courtès, 2017/03/08
- 02/16: gnu: Remove unneeded imports., Ludovic Courtès, 2017/03/08
- 04/16: services: prosody: Use 'id' to introduce unhygienic top-level identifiers., Ludovic Courtès, 2017/03/08
- 05/16: build: Unset 'NIX_BUILD_HOOK' when offloading support is missing., Ludovic Courtès, 2017/03/08
- 09/16: gnu: Add guile2.2-reader., Ludovic Courtès, 2017/03/08
- 01/16: guix archive: Allow compilation with Guile 2.2., Ludovic Courtès, 2017/03/08
- 06/16: hash: Close or flush sha256 output ports before calling their 'get' procedure., Ludovic Courtès, 2017/03/08
- 11/16: download: Update the Savannah mirror list., Ludovic Courtès, 2017/03/08
- 12/16: ui: Avoid '_' as a pattern variable in 'match'., Ludovic Courtès, 2017/03/08
- 15/16: packages: Use address@hidden syntax when reporting ambiguities., Ludovic Courtès, 2017/03/08
- 13/16: ui: Don't use '%default-port-encoding' to set the encoding of string ports.,
Ludovic Courtès <=
- 16/16: utils: Make sure to use the right 'bytevector->string'., Ludovic Courtès, 2017/03/08
- 14/16: list-runtime-roots: Bufferize the lsof pipe., Ludovic Courtès, 2017/03/08
- 07/16: tests: Avoid zero-expression 'begin' form., Ludovic Courtès, 2017/03/08
- 08/16: gnu: guile-reader: Update to 0.6.2., Ludovic Courtès, 2017/03/08
- 10/16: gnu: Add guile2.2-haunt., Ludovic Courtès, 2017/03/08