mruby-pack/pack.c (read_tmpl): support J/j template in pack

J/j is available since Ruby 2.3.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-07-18 12:01:30 +09:00
parent 663f936ba8
commit 2a1e3a572c
2 changed files with 18 additions and 0 deletions
+2
View File
@@ -28,6 +28,8 @@ There is no dependency on other mrbgems.
- h : hex string (low nibble first)
- I : unsigned integer, native endian (`unsigned int` in C)
- i : signed integer, native endian (`int` in C)
- J : unsigned integer, native endian (`uintptr_t` in C)
- j : signed integer, native endian (`intptr_t` in C)
- L : 32-bit unsigned, native endian (`uint32_t`)
- l : 32-bit signed, native endian (`int32_t`)
- m : base64 encoded string (see RFC 2045, count is width)
+16
View File
@@ -1219,6 +1219,22 @@ alias:
mrb_raisef(mrb, E_RUNTIME_ERROR, "mruby-pack does not support sizeof(int) == %d", (int)sizeof(int));
}
break;
case 'J':
switch (sizeof(intptr_t)) {
case 4: t = 'L'; goto alias;
case 8: t = 'Q'; goto alias;
default:
mrb_raisef(mrb, E_RUNTIME_ERROR, "mruby-pack does not support sizeof(uintptr_t) == %d", (int)sizeof(uintptr_t));
}
break;
case 'j':
switch (sizeof(intptr_t)) {
case 4: t = 'l'; goto alias;
case 8: t = 'q'; goto alias;
default:
mrb_raisef(mrb, E_RUNTIME_ERROR, "mruby-pack does not support sizeof(intptr_t) == %d", (int)sizeof(intptr_t));
}
break;
case 'L':
dir = PACK_DIR_LONG;
type = PACK_TYPE_INTEGER;