[前][次][番号順一覧][スレッド一覧]

ruby-changes:40404

From: nobu <ko1@a...>
Date: Sun, 8 Nov 2015 10:55:31 +0900 (JST)
Subject: [ruby-changes:40404] nobu:r52485 (trunk): io.c: [DOC] IO#gets [skip ci]

nobu	2015-11-08 10:55:14 +0900 (Sun, 08 Nov 2015)

  New Revision: 52485

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52485

  Log:
    io.c: [DOC] IO#gets [skip ci]
    
    * io.c (rb_io_gets_m): Update IO#gets doc for characters more than
      1 byte.  [Fix GH-1085]

  Modified files:
    trunk/ChangeLog
    trunk/io.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52484)
+++ ChangeLog	(revision 52485)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Nov  8 10:55:10 2015  Anton Davydov  <antondavydov.o@g...>
+
+	* io.c (rb_io_gets_m): Update IO#gets doc for characters more than
+	  1 byte.  [Fix GH-1085]
+
 Sun Nov  8 10:37:58 2015  SHIBATA Hiroshi  <hsbt@r...>
 
 	* lib/uri/ftp.rb: fix a typo.
Index: io.c
===================================================================
--- io.c	(revision 52484)
+++ io.c	(revision 52485)
@@ -3291,6 +3291,16 @@ rb_io_gets(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L3291
  *
  *     File.new("testfile").gets   #=> "This is line one\n"
  *     $_                          #=> "This is line one\n"
+ *
+ *  If StringIO contains characters more than 1 byte
+ *  then <code>gets(1)</code> returns character entirely:
+ *
+ *     # russian characters take 2 bytes
+ *     File.write("testfile", "\u{442 435 441 442}")
+ *     File.open("testfile") {|f|f.gets(1)} #=> "\u0442"
+ *     File.open("testfile") {|f|f.gets(2)} #=> "\u0442"
+ *     File.open("testfile") {|f|f.gets(3)} #=> "\u0442\u0435"
+ *     File.open("testfile") {|f|f.gets(4)} #=> "\u0442\u0435"
  */
 
 static VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]