Created
January 9, 2010 14:55
-
-
Save calavera/272928 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/org/jruby/RubyIO.java b/src/org/jruby/RubyIO.java | |
index 6ef60ac..f15a83d 100644 | |
--- a/src/org/jruby/RubyIO.java | |
+++ b/src/org/jruby/RubyIO.java | |
@@ -3688,6 +3688,13 @@ public class RubyIO extends RubyObject { | |
RubyHash rubyOptions = (RubyHash) options; | |
+ if (rubyOptions.containsKey(runtime.newSymbol("textmode")) && | |
+ rubyOptions.fastARef(runtime.newSymbol("textmode")).isTrue() | |
+ && rubyOptions.containsKey(runtime.newSymbol("binmode")) && | |
+ rubyOptions.fastARef(runtime.newSymbol("binmode")).isTrue()) { | |
+ throw runtime.newArgumentError("both textmode and binmode specified"); | |
+ } | |
+ | |
IRubyObject internalEncodingOption = rubyOptions.fastARef(runtime.newSymbol("internal_encoding")); | |
IRubyObject externalEncodingOption = rubyOptions.fastARef(runtime.newSymbol("external_encoding")); | |
RubyString dash = runtime.newString("-"); | |
@@ -3720,25 +3727,23 @@ public class RubyIO extends RubyObject { | |
modes = parseModes19(context, rubyOptions.fastARef(runtime.newSymbol("mode")).asString()); | |
} | |
-// FIXME: check how ruby 1.9 handles this | |
+ if (rubyOptions.containsKey(runtime.newSymbol("textmode")) && | |
+ rubyOptions.fastARef(runtime.newSymbol("textmode")).isTrue()) { | |
+ try { | |
+ modes = getIOModes(runtime, modes.toJavaModeString() + "t"); | |
+ } catch (InvalidValueException e) { | |
+ throw getRuntime().newErrnoEINVALError(); | |
+ } | |
+ } | |
-// if (rubyOptions.containsKey(runtime.newSymbol("textmode")) && | |
-// rubyOptions.fastARef(runtime.newSymbol("textmode")).isTrue()) { | |
-// try { | |
-// modes = getIOModes(runtime, "t"); | |
-// } catch (InvalidValueException e) { | |
-// throw getRuntime().newErrnoEINVALError(); | |
-// } | |
-// } | |
-// | |
-// if (rubyOptions.containsKey(runtime.newSymbol("binmode")) && | |
-// rubyOptions.fastARef(runtime.newSymbol("binmode")).isTrue()) { | |
-// try { | |
-// modes = getIOModes(runtime, "b"); | |
-// } catch (InvalidValueException e) { | |
-// throw getRuntime().newErrnoEINVALError(); | |
-// } | |
-// } | |
+ if (rubyOptions.containsKey(runtime.newSymbol("binmode")) && | |
+ rubyOptions.fastARef(runtime.newSymbol("binmode")).isTrue()) { | |
+ try { | |
+ modes = getIOModes(runtime, modes.toJavaModeString() + "b"); | |
+ } catch (InvalidValueException e) { | |
+ throw getRuntime().newErrnoEINVALError(); | |
+ } | |
+ } | |
return modes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment