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

ruby-changes:63893

From: Kenta <ko1@a...>
Date: Fri, 4 Dec 2020 15:07:43 +0900 (JST)
Subject: [ruby-changes:63893] c0de997edd (master): memory_view.c: Fix endianness of n, N, v, V

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

From c0de997eddfccd0a9d398a91ef122b16af1686d4 Mon Sep 17 00:00:00 2001
From: Kenta Murata <mrkn@m...>
Date: Fri, 4 Dec 2020 14:23:24 +0900
Subject: memory_view.c: Fix endianness of n, N, v, V


diff --git a/memory_view.c b/memory_view.c
index 4a4245a..8b2a2c0 100644
--- a/memory_view.c
+++ b/memory_view.c
@@ -473,10 +473,14 @@ rb_memory_view_parse_item_format(const char *format, https://github.com/ruby/ruby/blob/trunk/memory_view.c#L473
                 switch (type_char) {
                   case 'e':
                   case 'E':
+                  case 'v':
+                  case 'V':
                     little_endian_p = true;
                     break;
                   case 'g':
                   case 'G':
+                  case 'n':
+                  case 'N':
                     little_endian_p = false;
                     break;
                   default:
diff --git a/test/ruby/test_memory_view.rb b/test/ruby/test_memory_view.rb
index 2432f71..baf544c 100644
--- a/test/ruby/test_memory_view.rb
+++ b/test/ruby/test_memory_view.rb
@@ -93,8 +93,8 @@ class TestMemoryView < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_memory_view.rb#L93
       ["S",  false, NATIVE_ENDIAN,  SHORT_ALIGNMENT, sizeof(:short), 1],
       ["s!", true,  NATIVE_ENDIAN,  SHORT_ALIGNMENT, sizeof(:short), 1],
       ["S!", true,  NATIVE_ENDIAN,  SHORT_ALIGNMENT, sizeof(:short), 1],
-      ["n",  false, NATIVE_ENDIAN,  INT16_ALIGNMENT, sizeof(:int16_t), 1],
-      ["v",  false, NATIVE_ENDIAN,  INT16_ALIGNMENT, sizeof(:int16_t), 1],
+      ["n",  false, :big_endian,    INT16_ALIGNMENT, sizeof(:int16_t), 1],
+      ["v",  false, :little_endian, INT16_ALIGNMENT, sizeof(:int16_t), 1],
       ["i",  false, NATIVE_ENDIAN,  INT_ALIGNMENT, sizeof(:int), 1],
       ["I",  false, NATIVE_ENDIAN,  INT_ALIGNMENT, sizeof(:int), 1],
       ["i!", true,  NATIVE_ENDIAN,  INT_ALIGNMENT, sizeof(:int), 1],
@@ -103,8 +103,8 @@ class TestMemoryView < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_memory_view.rb#L103
       ["L",  false, NATIVE_ENDIAN,  INT32_ALIGNMENT, sizeof(:int32_t), 1],
       ["l!", true,  NATIVE_ENDIAN,  LONG_ALIGNMENT, sizeof(:long), 1],
       ["L!", true,  NATIVE_ENDIAN,  LONG_ALIGNMENT, sizeof(:long), 1],
-      ["N",  false, NATIVE_ENDIAN,  INT32_ALIGNMENT, sizeof(:int32_t), 1],
-      ["V",  false, NATIVE_ENDIAN,  INT32_ALIGNMENT, sizeof(:int32_t), 1],
+      ["N",  false, :big_endian,    INT32_ALIGNMENT, sizeof(:int32_t), 1],
+      ["V",  false, :little_endian, INT32_ALIGNMENT, sizeof(:int32_t), 1],
       ["f",  false, NATIVE_ENDIAN,  FLOAT_ALIGNMENT, sizeof(:float), 1],
       ["e",  false, :little_endian, FLOAT_ALIGNMENT, sizeof(:float), 1],
       ["g",  false, :big_endian,    FLOAT_ALIGNMENT, sizeof(:float), 1],
-- 
cgit v0.10.2


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

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