Project

General

Profile

Backport #5791

Please backport r34043, r34045 (Unexpected error of STDIN#read with non-ascii input)

Added by jonforums (Jon Forums) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:41778]

Description

Please backport r34043 and it's fixup r34045 to ruby_1_9_3.


Related issues

Related to Ruby trunk - Bug #5714: Unexpected error of STDIN#read with non-ascii input on Windows XPClosed12/06/2011Actions

Associated revisions

Revision a208a750
Added by naruse (Yui NARUSE) over 7 years ago

merge revision(s) 34043,34045,34132: [Backport #5791]

    * win32/win32.c, include/ruby/win32.h (rb_w32_fd_is_text): new function.

    * win32/win32.c (init_stdhandle): set default mode of stdin as binmode.

    * io.c (set_binary_mode_with_seek_cur): new function to replace
      SET_BINARY_MODE_WITH_SEEK_CUR macro.  now returns previous mode of the
      fd and take care of LF in rbuf.

    * io.c (do_writeconv): set text mode when needed.

    * io.c (io_read): need to change the mode of the IO to binmode
      temporally when the length for IO#read, because IO#read with length
      must behave so.

    * test/ruby/test_io_m17n.rb (TestIO_M17N#est_{read_with_length,
      read_with_length_binmode,get[cs]_and_read_with_binmode,
      read_with_binmode_and_get[cs],read_write_with_binmode}): tests for
      above changes.
    all patches are written by Hiroshi Shirosaki. [ruby-core:41496]
    [Feature #5714]

    * test/ruby/test_io_m17n.rb
      (TestIO_M17N#test_{read_with_binmode_and_get[cs]}): only for Windows.

    * test/ruby/test_io_m17n.rb (TestIO_M17N#test_{read_with_length,

    * io.c (rb_sys_fail_path): move the definition.
      Move above for using it in set_binary_mode_with_seek_cur().

    * io.c (set_binary_mode_with_seek_cur): fix improper seek cursor.
      Seeking file cursor with setting binary mode has possibility to
      cause infinite loop. Fixed the bug and refined error handling.
      Introduced at r34043.
      And cleanups as below.
      Remove unnecessary parentheses of `fptr`.
      Use return value of setmode().

    * test/ruby/test_io_m17n.rb
      (TestIO_M17N#test_seek_with_setting_binmode): add a test for abobe.
      [ruby-core:41671] [Bug #5714]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34546
Added by naruse (Yui NARUSE) over 7 years ago

merge revision(s) 34043,34045,34132: [Backport #5791]

* win32/win32.c, include/ruby/win32.h (rb_w32_fd_is_text): new function.

* win32/win32.c (init_stdhandle): set default mode of stdin as binmode.

* io.c (set_binary_mode_with_seek_cur): new function to replace
  SET_BINARY_MODE_WITH_SEEK_CUR macro.  now returns previous mode of the
  fd and take care of LF in rbuf.

* io.c (do_writeconv): set text mode when needed.

* io.c (io_read): need to change the mode of the IO to binmode
  temporally when the length for IO#read, because IO#read with length
  must behave so.

* test/ruby/test_io_m17n.rb (TestIO_M17N#est_{read_with_length,
  read_with_length_binmode,get[cs]_and_read_with_binmode,
  read_with_binmode_and_get[cs],read_write_with_binmode}): tests for
  above changes.
all patches are written by Hiroshi Shirosaki. [ruby-core:41496]
[Feature #5714]

* test/ruby/test_io_m17n.rb
  (TestIO_M17N#test_{read_with_binmode_and_get[cs]}): only for Windows.

* test/ruby/test_io_m17n.rb (TestIO_M17N#test_{read_with_length,

* io.c (rb_sys_fail_path): move the definition.
  Move above for using it in set_binary_mode_with_seek_cur().

* io.c (set_binary_mode_with_seek_cur): fix improper seek cursor.
  Seeking file cursor with setting binary mode has possibility to
  cause infinite loop. Fixed the bug and refined error handling.
  Introduced at r34043.
  And cleanups as below.
  Remove unnecessary parentheses of `fptr`.
  Use return value of setmode().

* test/ruby/test_io_m17n.rb
  (TestIO_M17N#test_seek_with_setting_binmode): add a test for abobe.
  [ruby-core:41671] [Bug #5714]

History

Updated by kosaki (Motohiro KOSAKI) over 7 years ago

maybe, following commit is necessary too.


r34132 | shirosaki | 2011-12-26 08:49:31 -0500 (Mon, 26 Dec 2011) | 17 lines

  • io.c (rb_sys_fail_path): move the definition.
    Move above for using it in set_binary_mode_with_seek_cur().

  • io.c (set_binary_mode_with_seek_cur): fix improper seek cursor.
    Seeking file cursor with setting binary mode has possibility to
    cause infinite loop. Fixed the bug and refined error handling.
    Introduced at r34043.

And cleanups as below.
Remove unnecessary parentheses of fptr.
Use return value of setmode().

  • test/ruby/test_io_m17n.rb (TestIO_M17N#test_seek_with_setting_binmode): add a test for abobe. [ruby-core:41671] [Bug #5714]

Updated by kosaki (Motohiro KOSAKI) over 7 years ago

  • Subject changed from Please backport r34043, r34045 to Please backport r34043, r34045 (Unexpected error of STDIN#read with non-ascii input)

Updated by luislavena (Luis Lavena) over 7 years ago

  • Assignee set to luislavena (Luis Lavena)

If nobody objects I'll backport this next week (wednesday tops)

#5

Updated by naruse (Yui NARUSE) over 7 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r34546.
Jon, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 34043,34045,34132: [Backport #5791]

* win32/win32.c, include/ruby/win32.h (rb_w32_fd_is_text): new function.

* win32/win32.c (init_stdhandle): set default mode of stdin as binmode.

* io.c (set_binary_mode_with_seek_cur): new function to replace
  SET_BINARY_MODE_WITH_SEEK_CUR macro.  now returns previous mode of the
  fd and take care of LF in rbuf.

* io.c (do_writeconv): set text mode when needed.

* io.c (io_read): need to change the mode of the IO to binmode
  temporally when the length for IO#read, because IO#read with length
  must behave so.

* test/ruby/test_io_m17n.rb (TestIO_M17N#est_{read_with_length,
  read_with_length_binmode,get[cs]_and_read_with_binmode,
  read_with_binmode_and_get[cs],read_write_with_binmode}): tests for
  above changes.
all patches are written by Hiroshi Shirosaki. [ruby-core:41496]
[Feature #5714]

* test/ruby/test_io_m17n.rb
  (TestIO_M17N#test_{read_with_binmode_and_get[cs]}): only for Windows.

* test/ruby/test_io_m17n.rb (TestIO_M17N#test_{read_with_length,

* io.c (rb_sys_fail_path): move the definition.
  Move above for using it in set_binary_mode_with_seek_cur().

* io.c (set_binary_mode_with_seek_cur): fix improper seek cursor.
  Seeking file cursor with setting binary mode has possibility to
  cause infinite loop. Fixed the bug and refined error handling.
  Introduced at r34043.
  And cleanups as below.
  Remove unnecessary parentheses of `fptr`.
  Use return value of setmode().

* test/ruby/test_io_m17n.rb
  (TestIO_M17N#test_seek_with_setting_binmode): add a test for abobe.
  [ruby-core:41671] [Bug #5714]

Also available in: Atom PDF