diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-23 07:56:25 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-23 07:56:25 +0000 |
commit | aa5b65b2edf4e79f09b6e9dd488bf160b6a39260 (patch) | |
tree | 25fcdc057d9bdced3e0d999754e2cd17a1f40a1d /io.c | |
parent | e7d83904cb0698d304fb8631ca34d4434152fd17 (diff) | |
download | ruby-aa5b65b2edf4e79f09b6e9dd488bf160b6a39260.tar.gz |
* io.c (extract_binmode): raise an exception if binmode/textmode
is specified with both vmode and opthash.
[ruby-core:42199] [Bug #5918]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -4786,11 +4786,19 @@ extract_binmode(VALUE opthash, int *fmode) if (!NIL_P(opthash)) { VALUE v; v = rb_hash_aref(opthash, sym_textmode); - if (!NIL_P(v) && RTEST(v)) - *fmode |= FMODE_TEXTMODE; + if (!NIL_P(v)) { + if (*fmode & FMODE_TEXTMODE) + rb_raise(rb_eArgError, "textmode specified twice"); + if (RTEST(v)) + *fmode |= FMODE_TEXTMODE; + } v = rb_hash_aref(opthash, sym_binmode); - if (!NIL_P(v) && RTEST(v)) - *fmode |= FMODE_BINMODE; + if (!NIL_P(v)) { + if (*fmode & FMODE_BINMODE) + rb_raise(rb_eArgError, "binmode specified twice"); + if (RTEST(v)) + *fmode |= FMODE_BINMODE; + } if ((*fmode & FMODE_BINMODE) && (*fmode & FMODE_TEXTMODE)) rb_raise(rb_eArgError, "both textmode and binmode specified"); |