Skip to content

Commit

Permalink
Fix JRUBY-5888: missing File#readbyte
Browse files Browse the repository at this point in the history
* Add IO#readbyte.
  • Loading branch information
headius committed Jun 24, 2011
1 parent 054dc72 commit ac992df
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
import org.jruby.util.io.OpenFile;
import org.jruby.util.io.ChannelDescriptor;

import java.util.Arrays;
import org.jcodings.specific.ASCIIEncoding;
import org.jcodings.specific.USASCIIEncoding;
import org.jruby.javasupport.util.RuntimeHelpers;
Expand Down Expand Up @@ -2374,6 +2373,16 @@ public IRubyObject readchar19(ThreadContext context) {
public IRubyObject getbyte19(ThreadContext context) {
return getc(); // Yes 1.8 getc is 1.9 getbyte
}

@JRubyMethod(compat = RUBY1_9)
public IRubyObject readbyte(ThreadContext context) {
int c = getcCommon();
if (c == -1) {
throw getRuntime().newEOFError();
}

return context.runtime.newFixnum(c);
}

@JRubyMethod(name = "getc", compat = RUBY1_9)
public IRubyObject getc19(ThreadContext context) {
Expand Down

0 comments on commit ac992df

Please sign in to comment.