summaryrefslogtreecommitdiff
path: root/dev-ruby/tty-screen/files/tty-screen-0.8.1-ioctl-test.patch
blob: 0933f1f611b0b978c1cb97eed09dac3095f9845a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From dba351b178ae06b56985cc77a291918a0fc4aff4 Mon Sep 17 00:00:00 2001
From: Piotr Murach <pmurach@gmail.com>
Date: Mon, 16 Aug 2021 22:13:27 +0200
Subject: [PATCH] Fix ioctl call test to stub terminal size encoding for
 big-endian systems

Fixes #13
---
 CHANGELOG.md             | 6 ++++++
 spec/unit/screen_spec.rb | 8 +++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 91dd6ab..0f369bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
 # Change log
 
+## [v0.8.2] - unreleased
+
+### Fixed
+* Fix ioctl call test to stub terminal size encoding for big-endian systems
+
 ## [v0.8.1] - 2020-07-17
 
 ### Fixed
@@ -136,6 +141,7 @@
 ### Fixed
 * Fix bug with screen detection from_io_console by @luxflux
 
+[v0.8.2]: https://github.com/piotrmurach/tty-screen/compare/v0.8.1...v0.8.2
 [v0.8.1]: https://github.com/piotrmurach/tty-screen/compare/v0.8.0...v0.8.1
 [v0.8.0]: https://github.com/piotrmurach/tty-screen/compare/v0.7.1...v0.8.0
 [v0.7.1]: https://github.com/piotrmurach/tty-screen/compare/v0.7.0...v0.7.1
diff --git a/spec/unit/screen_spec.rb b/spec/unit/screen_spec.rb
index 3666a3c..de78ff3 100644
--- a/spec/unit/screen_spec.rb
+++ b/spec/unit/screen_spec.rb
@@ -6,8 +6,14 @@ def winsize
       [100, 200]
     end
 
+    def big_endian?
+      [1].pack("S") == [1].pack("n")
+    end
+
     def ioctl(control, buf)
-      buf.replace("3\x00\xD3\x00\xF2\x04\xCA\x02\x00")
+      little_endian = "3\x00\xD3\x00\xF2\x04\xCA\x02\x00"
+      big_endian = "\x003\x00\xD3\x04\xF2\x02\xCA"
+      buf.replace(big_endian? ? big_endian : little_endian)
       0
     end
   end