[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/06: syscalls: 'terminal-columns' ignores non-file ports.
From: |
Ludovic Courtès |
Subject: |
04/06: syscalls: 'terminal-columns' ignores non-file ports. |
Date: |
Fri, 15 Apr 2016 22:52:59 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit 6d2b43915f8a628588f03136b3008902f7643e06
Author: Ludovic Courtès <address@hidden>
Date: Fri Apr 15 19:47:35 2016 +0200
syscalls: 'terminal-columns' ignores non-file ports.
* guix/build/syscalls.scm (terminal-columns): Call
'terminal-window-size' only when PORT is a file port.
* tests/syscalls.scm ("terminal-columns non-file port"): New test.
---
guix/build/syscalls.scm | 10 ++++++----
tests/syscalls.scm | 4 ++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index ed833c1..5ce0abb 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -915,10 +915,12 @@ always a positive integer."
(catch 'system-error
(lambda ()
- (match (window-size-columns (terminal-window-size port))
- ;; Things like Emacs shell-mode return 0, which is unreasonable.
- (0 (fall-back))
- ((? number? columns) columns)))
+ (if (file-port? port)
+ (match (window-size-columns (terminal-window-size port))
+ ;; Things like Emacs shell-mode return 0, which is unreasonable.
+ (0 (fall-back))
+ ((? number? columns) columns))
+ (fall-back)))
(lambda args
(let ((errno (system-error-errno args)))
(if (= errno ENOTTY)
diff --git a/tests/syscalls.scm b/tests/syscalls.scm
index 1b443be..24ea8f5 100644
--- a/tests/syscalls.scm
+++ b/tests/syscalls.scm
@@ -257,4 +257,8 @@
(test-assert "terminal-columns"
(> (terminal-columns) 0))
+(test-assert "terminal-columns non-file port"
+ (> (terminal-columns (open-input-string "Join us now, share the software!"))
+ 0))
+
(test-end)
- branch master updated (770305f -> 3a25c63), Ludovic Courtès, 2016/04/15
- 04/06: syscalls: 'terminal-columns' ignores non-file ports.,
Ludovic Courtès <=
- 06/06: doc: Mention --localstatedir for when building from Git., Ludovic Courtès, 2016/04/15
- 02/06: gnu: Add tcc., Ludovic Courtès, 2016/04/15
- 05/06: doc: Fix typos., Ludovic Courtès, 2016/04/15
- 01/06: doc: Remove mention of GNU release freshness checks., Ludovic Courtès, 2016/04/15
- 03/06: gnu: Add tcc-wrapper., Ludovic Courtès, 2016/04/15