memory_view.c: Fix endianness of n, N, v, V

This commit is contained in:
Kenta Murata 2020-12-04 14:23:24 +09:00
Родитель e8cee4915b
Коммит c0de997edd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: CEFE8AFB6081B062
2 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -473,10 +473,14 @@ rb_memory_view_parse_item_format(const char *format,
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:

Просмотреть файл

@ -93,8 +93,8 @@ class TestMemoryView < Test::Unit::TestCase
["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
["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],