ruby-changes:3048
From: ko1@a...
Date: 24 Dec 2007 02:13:27 +0900
Subject: [ruby-changes:3048] matz - Ruby:r14540 (trunk): * io.c (rb_f_open): documentation update.
matz 2007-12-24 02:13:07 +0900 (Mon, 24 Dec 2007) New Revision: 14540 Modified files: trunk/ChangeLog trunk/io.c Log: * io.c (rb_f_open): documentation update. * io.c (rb_io_s_pipe): ditto. * io.c (io_fwrite): wrong encoding destination. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14540&r2=14539 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=14540&r2=14539 Index: ChangeLog =================================================================== --- ChangeLog (revision 14539) +++ ChangeLog (revision 14540) @@ -1,3 +1,11 @@ +Mon Dec 24 02:06:35 2007 Yukihiro Matsumoto <matz@r...> + + * io.c (rb_f_open): documentation update. + + * io.c (rb_io_s_pipe): ditto. + + * io.c (io_fwrite): wrong encoding destination. + Mon Dec 24 01:46:43 2007 Yukihiro Matsumoto <matz@r...> * io.c (rb_io_s_pipe): allow specifying read-side encoding. Index: io.c =================================================================== --- io.c (revision 14539) +++ io.c (revision 14540) @@ -635,8 +635,8 @@ /* Can't use encode! because puts writes a frozen newline */ if (fptr->enc2) { str = rb_funcall(str, id_encode, 2, - rb_enc_from_encoding(fptr->enc), - rb_enc_from_encoding(fptr->enc2)); + rb_enc_from_encoding(fptr->enc2), + rb_enc_from_encoding(fptr->enc)); } else { str = rb_funcall(str, id_encode, 1, @@ -3811,10 +3811,29 @@ * * If <i>path</i> does not start with a pipe character * (``<code>|</code>''), treat it as the name of a file to open using - * the specified mode (defaulting to ``<code>r</code>''). (See the table - * of valid modes on page 331.) If a file is being created, its initial - * permissions may be set using the integer third parameter. + * the specified mode (defaulting to ``<code>r</code>''). The mode is + * either a string or an integer. If it is an integer, it must be + * bitwise-or of open(2) flags, such as File::RDWR or File::EXCL. + * If it is a string, it is either "mode", "mode:encoding", or + * "mode:encoding:encoding". "mode" is one of the following: * + * r: read (default) + * w: write + * a: append + * + * The mode can be followed by "b" (means binary-mode), or "+" + * (means both reading and writing allowed) or both. If one + * encoding is specified, read string will be tagged by the + * encoding in reading, and output string will be converted + * to the specified encoding in writing. If two encoding names + * are specified, the read string is converted from the former + * encoding to the latter encoding then tagged with the latter + * in read mode, and in write mode, the output string will be + * converted from the latter to the former before writing. + * + * If a file is being created, its initial permissions may be + * set using the integer third parameter. + * * If a block is specified, it will be invoked with the * <code>File</code> object as a parameter, and the file will be * automatically closed when the block terminates. The call @@ -5533,7 +5552,9 @@ * available on all platforms. * * If optional argument is specified, read string from pipe is tagged - * the encoding specified. + * with the encoding specified. If encoding is a comma separated two + * encoding names "A:B", the read string is converted from encoding A + * to encoding B, then tagged with B. * * In the example below, the two processes close the ends of the pipe * that they are not using. This is not just a cosmetic nicety. The -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml