summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2026-02-13 08:40:46 +0900
committerGitHub <noreply@github.com>2026-02-12 15:40:46 -0800
commit98269b6d64f26d1e8f22f3d8fddd30393f009e17 (patch)
tree4daa280c09f682738dc1198f3250b6f93c4766ef /pack.c
parentf0ff0df584b75b2588952e516d16ff8f134f9832 (diff)
[Feature #21796] unpack variant `^` that returns the final offset (#15647)
[Feature #21796] unpack variant `^` that returns the current offset
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/pack.c b/pack.c
index d2fb4f633f..f956e686e3 100644
--- a/pack.c
+++ b/pack.c
@@ -1570,6 +1570,10 @@ pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset)
s += len;
break;
+ case '^':
+ UNPACK_PUSH(SSIZET2NUM(s - RSTRING_PTR(str)));
+ break;
+
case 'P':
if (sizeof(char *) <= (size_t)(send - s)) {
VALUE tmp = Qnil;