[前][次][番号順一覧][スレッド一覧]

ruby-changes:68213

From: aycabta <ko1@a...>
Date: Sun, 3 Oct 2021 14:09:07 +0900 (JST)
Subject: [ruby-changes:68213] 4401bbe8a7 (master): [ruby/reline] Use String#unpack1

https://git.ruby-lang.org/ruby.git/commit/?id=4401bbe8a7

From 4401bbe8a7d9677cd3347073cf3a36b371b3ad62 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Thu, 30 Sep 2021 20:49:42 +0900
Subject: [ruby/reline] Use String#unpack1

https://github.com/ruby/reline/commit/179c52bca8
---
 lib/reline/windows.rb | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb
index 5bbf1e9d57..e94d69a4a6 100644
--- a/lib/reline/windows.rb
+++ b/lib/reline/windows.rb
@@ -235,21 +235,21 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L235
     num_of_events = 0.chr * 8
     while @@output_buf.empty? #or true
       next if @@WaitForSingleObject.(@@hConsoleInputHandle, 100) != 0 # max 0.1 sec
-      next if @@GetNumberOfConsoleInputEvents.(@@hConsoleInputHandle, num_of_events) == 0 or num_of_events.unpack('L').first == 0
+      next if @@GetNumberOfConsoleInputEvents.(@@hConsoleInputHandle, num_of_events) == 0 or num_of_events.unpack1('L') == 0
       input_record = 0.chr * 18
       read_event = 0.chr * 4
       if @@ReadConsoleInputW.(@@hConsoleInputHandle, input_record, 1, read_event) != 0
-        event = input_record[0, 2].unpack('s*').first
+        event = input_record[0, 2].unpack1('s*')
         case event
         when WINDOW_BUFFER_SIZE_EVENT
           @@winch_handler.()
         when KEY_EVENT
-          key_down = input_record[4, 4].unpack('l*').first
-          repeat_count = input_record[8, 2].unpack('s*').first
-          virtual_key_code = input_record[10, 2].unpack('s*').first
-          virtual_scan_code = input_record[12, 2].unpack('s*').first
-          char_code = input_record[14, 2].unpack('S*').first
-          control_key_state = input_record[16, 2].unpack('S*').first
+          key_down = input_record[4, 4].unpack1('l*')
+          repeat_count = input_record[8, 2].unpack1('s*')
+          virtual_key_code = input_record[10, 2].unpack1('s*')
+          virtual_scan_code = input_record[12, 2].unpack1('s*')
+          char_code = input_record[14, 2].unpack1('S*')
+          control_key_state = input_record[16, 2].unpack1('S*')
           is_key_down = key_down.zero? ? false : true
           if is_key_down
             process_key_event(repeat_count, virtual_key_code, virtual_scan_code, char_code, control_key_state)
@@ -291,8 +291,8 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L291
   def self.cursor_pos
     csbi = 0.chr * 22
     @@GetConsoleScreenBufferInfo.call(@@hConsoleHandle, csbi)
-    x = csbi[4, 2].unpack('s*').first
-    y = csbi[6, 2].unpack('s*').first
+    x = csbi[4, 2].unpack1('s*')
+    y = csbi[6, 2].unpack1('s*')
     Reline::CursorPos.new(x, y)
   end
 
@@ -324,7 +324,7 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L324
   def self.erase_after_cursor
     csbi = 0.chr * 24
     @@GetConsoleScreenBufferInfo.call(@@hConsoleHandle, csbi)
-    cursor = csbi[4, 4].unpack('L').first
+    cursor = csbi[4, 4].unpack1('L')
     written = 0.chr * 4
     @@FillConsoleOutputCharacter.call(@@hConsoleHandle, 0x20, get_screen_size.last - cursor_pos.x, cursor, written)
     @@FillConsoleOutputAttribute.call(@@hConsoleHandle, 0, get_screen_size.last - cursor_pos.x, cursor, written)
@@ -343,8 +343,8 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L343
   def self.clear_screen
     csbi = 0.chr * 22
     return if @@GetConsoleScreenBufferInfo.call(@@hConsoleHandle, csbi) == 0
-    buffer_width = csbi[0, 2].unpack('S').first
-    attributes = csbi[8, 2].unpack('S').first
+    buffer_width = csbi[0, 2].unpack1('S')
+    attributes = csbi[8, 2].unpack1('S')
     _window_left, window_top, _window_right, window_bottom = *csbi[10,8].unpack('S*')
     fill_length = buffer_width * (window_bottom - window_top + 1)
     screen_topleft = window_top * 65536
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]