ruby-changes:3995
From: ko1@a...
Date: Fri, 15 Feb 2008 16:35:27 +0900 (JST)
Subject: [ruby-changes:3995] matz - Ruby:r15485 (trunk): * io.c (open_key_args): allow specifying both :mode and :encoding.
matz 2008-02-15 16:35:11 +0900 (Fri, 15 Feb 2008) New Revision: 15485 Modified files: trunk/ChangeLog trunk/io.c Log: * io.c (open_key_args): allow specifying both :mode and :encoding. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15485&r2=15484&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=15485&r2=15484&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15484) +++ ChangeLog (revision 15485) @@ -1,3 +1,7 @@ +Fri Feb 15 16:22:49 2008 Yukihiro Matsumoto <matz@r...> + + * io.c (open_key_args): allow specifying both :mode and :encoding. + Fri Feb 15 15:34:47 2008 Tanaka Akira <akr@f...> * string.c (rb_str_getbyte): new method. Index: io.c =================================================================== --- io.c (revision 15484) +++ io.c (revision 15485) @@ -5820,6 +5820,7 @@ static VALUE encoding, mode, open_args; FilePathValue(argv[0]); + arg->io = 0; arg->argc = argc > 1 ? 1 : 0; arg->argv = argv + 1; if (argc == 1) { @@ -5861,16 +5862,16 @@ args[0] = argv[0]; args[1] = v; arg->io = rb_f_open(2, args); - return; } v = rb_hash_aref(opt, encoding); if (!NIL_P(v)) { rb_io_t *fptr; - arg->io = rb_io_open(RSTRING_PTR(argv[0]), "r"); + if (!arg->io) { + arg->io = rb_io_open(RSTRING_PTR(argv[0]), "r"); + } GetOpenFile(arg->io, fptr); mode_enc(fptr, StringValueCStr(v)); - return; } } @@ -5971,8 +5972,9 @@ * <code>read</code> ensures the file is closed before returning. * * If the last argument is a hash, it specifies option for internal - * open(). The key would be the following. They are all exclusive, - * + * open(). The key would be the following. open_args: is exclusive + * to others. + * * encoding: string or encoding * * specifies encoding of the read string. encoding will be ignored -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/