From 0125c86b46a51b0041fcbff50beb375a1ce0aaa1 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Wed, 4 Oct 2023 12:35:31 -0500 Subject: [PATCH] Fixes for each_byte --- core/src/main/java/org/jruby/RubyIOBuffer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/jruby/RubyIOBuffer.java b/core/src/main/java/org/jruby/RubyIOBuffer.java index 547e18c910a3..f2d5345bb027 100644 --- a/core/src/main/java/org/jruby/RubyIOBuffer.java +++ b/core/src/main/java/org/jruby/RubyIOBuffer.java @@ -1046,7 +1046,7 @@ private RubyArray values(ThreadContext context, ByteBuffer buffer, DataType data @JRubyMethod(name = "each_byte") public IRubyObject each_byte(ThreadContext context, Block block) { - if (!block.isGiven()) return RubyEnumerator.enumeratorize(context.runtime, this, "each"); + if (!block.isGiven()) return RubyEnumerator.enumeratorize(context.runtime, this, "each_byte"); ByteBuffer buffer = getBufferForReading(context); @@ -1055,7 +1055,7 @@ public IRubyObject each_byte(ThreadContext context, Block block) { @JRubyMethod(name = "each_byte") public IRubyObject each_byte(ThreadContext context, IRubyObject _offset, Block block) { - if (!block.isGiven()) return RubyEnumerator.enumeratorize(context.runtime, this, "each", Helpers.arrayOf(_offset)); + if (!block.isGiven()) return RubyEnumerator.enumeratorize(context.runtime, this, "each_byte", Helpers.arrayOf(_offset)); ByteBuffer buffer = getBufferForReading(context); int offset = _offset.convertToInteger().getIntValue(); @@ -1065,7 +1065,7 @@ public IRubyObject each_byte(ThreadContext context, IRubyObject _offset, Block b @JRubyMethod(name = "each_byte") public IRubyObject each_byte(ThreadContext context, IRubyObject _offset, IRubyObject _count, Block block) { - if (!block.isGiven()) return RubyEnumerator.enumeratorize(context.runtime, this, "each", Helpers.arrayOf(_offset, _count)); + if (!block.isGiven()) return RubyEnumerator.enumeratorize(context.runtime, this, "each_byte", Helpers.arrayOf(_offset, _count)); ByteBuffer buffer = getBufferForReading(context); int offset = _offset.convertToInteger().getIntValue(); @@ -1078,7 +1078,7 @@ private IRubyObject eachByte(ThreadContext context, ByteBuffer buffer, int offse Ruby runtime = context.runtime; for (int i = 0 ; i < count; i++) { - IRubyObject value = wrap(runtime, readByte(context, buffer, offset)); + IRubyObject value = wrap(runtime, readByte(context, buffer, offset + i)); block.yieldSpecific(context, value); }