Граф коммитов

63 Коммитов

Автор SHA1 Сообщение Дата
nobu aeaeb4b068 stringio.c: write multiple arguments
* ext/stringio/stringio.c (strio_write_m): make StringIO#write
  accept multiple arguments, as well as IO#write.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23 06:25:39 +00:00
nobu e022015c62 stringio.c: encoding at empty chomped result
* ext/stringio/stringio.c (strio_gets): should return string with
  the external encoding, at empty chomped result .

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-13 07:31:49 +00:00
nobu 24d03b2204 stringio.c: encoding at empty result
* ext/stringio/stringio.c (strio_gets): should return string with
  the external encoding, at empty result.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-13 07:21:13 +00:00
nobu 6ee82564fa stringio.c: encoding at EOF
* ext/stringio/stringio.c (strio_read): should return string with
  the external encoding, at EOF too.
  [ruby-core:82349] [Bug #13806]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-12 01:47:09 +00:00
nobu 555d477d2e test_stringio.rb: more assertions
* test/stringio/test_stringio.rb (test_read): add assertions
  of return value of read with a buffer string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-12 01:34:13 +00:00
nobu c8d66b5d82 stringio.c: check range
* ext/stringio/stringio.c (strio_ungetc): raise RangeError instead
  of TypeError at too big value, as well as IO#ungetc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-21 03:15:57 +00:00
nobu 853ab8662f stringio.c: check character code
* ext/stringio/stringio.c (strio_ungetc): check if the character
  code is valid in the encoding.  reported by Ahmad Sherif
  (ahmadsherif) at https://hackerone.com/reports/209593.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-21 03:15:56 +00:00
nobu 30540c5675 stringio.c: chomp CR
* ext/stringio/stringio.c (strio_getline): chomp CR not only LF,
  as well as String#chomp.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-10 08:54:40 +00:00
nobu 35623d779d stringio: chomp option
* ext/stringio/stringio.c (strio_getline): implement chomp option.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-03 11:01:25 +00:00
nobu 856da5b407 test_stringio.rb: paragraph mode
* test/stringio/test_stringio.rb (test_gets, test_each):
  assertions for paragraph mode.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-03 11:01:24 +00:00
rhe e6e66094f9 stringio.c: fix signed integer overflow
* ext/stringio/stringio.c (strio_seek): Avoid signed integer overflow.
  It's not harmful in practice here, but is still undefined behavior.

* ext/stringio/stringio.c (strio_extend): Check that the new length does
  not exceed LONG_MAX. This fixes the invalid write on the overflow.

* test/stringio/test_stringio.rb (test_write_integer_overflow): Add a
  test case for the above fix in strio_extend().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-26 07:24:55 +00:00
naruse 8667e8b186 require "rbconfig/sizeof"
They may fail parallel test-all

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-06 18:17:36 +00:00
nobu 7d4db05679 test_stringio.rb: reduce retry count
* test/stringio/test_stringio.rb (test_overflow): reduce maximum
  retry count to get rid of timeout on some platforms.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-30 08:13:27 +00:00
nobu 513345607d Refine test of r55432
* test/stringio/test_stringio.rb (test_overflow): could occur only
  on sizeof(long) >= sizeof(void*).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-18 04:50:14 +00:00
nobu 815e8e992d Refine test of r55432
* test/stringio/test_stringio.rb (test_overflow): refine the
  conditinon, try to allocate strings until the buffer is located
  in higher half address.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-18 04:40:15 +00:00
nobu ed4aed86fb stringio.c: fix index overflow
* ext/stringio/stringio.c (strio_getline): fix pointer index
  overflow.  reported by Guido Vranken <guido AT guidovranken.nl>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-17 23:52:48 +00:00
nobu 7a5b56677a stringio.c: warn block for new
* ext/stringio/stringio.c (strio_s_new): warn if a block is given,
  as well as IO.new.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-27 06:47:56 +00:00
normal dc59c76898 stringio: binmode sets encoding to ASCII-8BIT
This should match the behavior of IO#binmode as far
as treating content as ASCII-8BIT (binary).

* ext/stringio/stringio.c (strio_binmode): implement to set encoding
* test/stringio/test_stringio.rb (test_binmode): new test
  [ruby-core:72699] [Bug #11945]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-04 20:45:14 +00:00
nobu 3586aef4b8 test_stringio.rb: test_initialize
* test/stringio/test_stringio.rb (test_initialize): add test for
  StringIO#initialize.  [ruby-core:72585] [Feature #11920]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-29 23:44:01 +00:00
nobu 3e1c01ae46 stringio.c: separate encoding from buffer
* ext/stringio/stringio.c (strio_set_encoding): add StringIO's own
  encoding and separate it from the buffer string to override the
  encoding of string when reading.  [ruby-core:72189] [Bug #11827]
  note that setting the encoding of its buffer string may cause
  unpredictable behavior.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-18 07:54:33 +00:00
nobu b7d1536991 stringio.c: padding in ungetbyte
* ext/stringio/stringio.c (strio_ungetbyte): pad with \000 when
  the current position is after the end.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-18 03:09:16 +00:00
nobu 07f53e4830 test_stringio.rb: add test
* test/stringio/test_stringio.rb (test_ungetc_pos): add a test for
  r26588.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-18 03:05:53 +00:00
naruse 3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
nobu a3d6de4adc Simple testing for StringIO#sysread
* test/stringio/test_stringio.rb (test_sysread): add a test for
  StringIO#sysread.  [Fix GH-966]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-11 21:42:27 +00:00
nobu f75fe0bcc7 stringio.c: don't raise after close
* ext/stringio/stringio.c (strio_close): don't raise on dobule
  close for consistent to IO#close.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-13 06:04:39 +00:00
nobu 2e02f2dfd2 stringio.c: don't raise after close
* ext/stringio/stringio.c (strio_close): don't raise on dobule
  close for consistent to IO#close.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-09 07:34:39 +00:00
nobu 2a8989d71c stringio.c: ASCII-8BIT StringIO rejects no encodings
* ext/stringio/stringio.c (strio_write): ASCII-8BIT StringIO
  should be writable any encoding strings, without conversion.
  [ruby-core:65240] [Bug #10285]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-26 03:52:37 +00:00
nobu 2c14872b9f stringio.c: use rb_str_append other than ASCII-8BIT
* ext/stringio/stringio.c (strio_write): use rb_str_append to
  reuse coderange bits other than ASCII-8BIT, and keep
  taintedness.  [ruby-dev:48118] [Bug #9769]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-23 02:03:43 +00:00
naruse 506c6f52b9 Revert r45670 "stringio.c: use rb_str_append"
It breaks test-all.
http://u64b.rubyci.org/~chkbuild/ruby-trunk/log/20140422T143301Z.diff.html.gz

rb_str_conv_enc() return original string for example when
from ASCII-8BIT to UTF-8 with non ASCII strings

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-22 18:44:48 +00:00
nobu a197581765 stringio.c: use rb_str_append
* ext/stringio/stringio.c (strio_write): use rb_str_append to
  reuse coderange bits and keep taintedness.
  [ruby-dev:48118] [Bug #9769]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-22 14:14:30 +00:00
nobu 90e393b368 stringio.c: non-ascii encoding
* ext/stringio/stringio.c (strio_putc): fix for non-ascii
  encoding, like as IO#putc.  [ruby-dev:48114] [Bug #9765]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21 05:11:50 +00:00
tenderlove 988ca60565 * io.c (io_read_nonblock): support non-blocking reads without raising
exceptions. As in: `io.read_nonblock(size, exception: false)`
  [ruby-core:38666] [Feature #5138]
* ext/openssl/ossl_ssl.c (ossl_ssl_read_internal): ditto
* ext/stringio/stringio.c (strio_sysread): ditto
* io.c (rb_io_write_nonblock): support non-blocking writes without
  raising an exception.
* ext/openssl/ossl_ssl.c (ossl_ssl_write_internal): ditto
* test/openssl/test_pair.rb (class OpenSSL): tests
* test/ruby/test_io.rb (class TestIO): ditto
* test/socket/test_nonblock.rb (class TestSocketNonblock): ditto
* test/stringio/test_stringio.rb (class TestStringIO): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 22:41:44 +00:00
glass 89182621d9 * ext/stringio/stringio.c (strio_getline): fix not to raise TypeError
when limit is nil.
  [Bug #7232] [ruby-core:48531]

* test/stringio/test_stringio.rb: a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-27 12:21:17 +00:00
glass cd453f16b4 * ext/stringio/stringio.c (strio_ungetc): raise IOError instead of RuntimeError
if the string is frozen.
  [Bug #7231] [ruby-core:48530]

* ext/stringio/stringio.c (strio_ungetbyte): ditto.

* test/stringio/test_stringio.rb: a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-27 11:43:02 +00:00
nobu 56f9574de8 stringio.c: close separatedly
* ext/stringio/stringio.c (strio_close): close separatedly per each
  instances, as well as IO.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-29 09:23:02 +00:00
drbrain ab0eb272f9 * io.c (io_readpartial): Document the output buffer parameter is
overwritten with the read contents even when non-empty.
  Patch by yu nobuoka.  [ruby-trunk - Bug #6285]
* io.c (io_read_nonblock):  ditto.
* io.c (io_read):  ditto.
* io.c (rb_io_sysread):  ditto.
* io.c (argf_read):  ditto.
* io.c (argf_readpartial):  ditto.
* ext/stringio/stringio.c (strio_read):  ditto.
* test/ruby/test_argf.rb (class TestArgf):  Add test for existing
  behavior of read outbuf.
* test/ruby/test_io.rb (class TestIO):  ditto.
* test/stringio/test_stringio.rb (class TestStringIO):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-18 23:48:27 +00:00
nobu dcb7cc1a8b * ext/stringio/stringio.c (strio_read): return new string if nil
is explicitly given as a buffer ([Bug #5207]), otherwise set the
  encoding.  also removed dead code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-20 01:43:26 +00:00
sorah 4e817b39b4 * ext/stringio/stringio.c (strio_each):
Fix exception message and don't raise immediately if block is not given.
  Fixes [ruby-dev:43394].

* test/stringio/test_stringio.rb (test_each_line_limit_0):
  Fix test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-09 14:28:06 +00:00
sorah 0a69f2e39d * ext/stringio/stringio.c (strio_each, strio_readlines):
limit must not be zero. Fixes [ruby-dev:43392].

* test/stringio/test_stringio.rb: Add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-09 13:01:23 +00:00
naruse 653b4248a3 * ext/stringio/stringio.c (strio_getline): check whether str is
a string when str and lim are given.
  https://twitter.com/watson1978/status/56225052152168449

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-08 07:50:49 +00:00
nobu d8d9bac5c8 * ext/stringio/stringio.c (get_strio, strio_set_string)
(strio_reopen): check if frozen.  [ruby-core:33648]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-05 20:14:43 +00:00
nobu bfcd4e5453 * ext/stringio/stringio.c (strio_getline): round upto next char
boundary.  [ruby-dev:42674]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-02 22:08:45 +00:00
nahi 39802186b2 * ext/stringio/stringio.c (ungetc): RDoc updated. trunk allows
pushing back behind the beginning of the pseudo stream.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-04 04:14:37 +00:00
nobu 8252adfd5a * ext/stringio/stringio.c (Init_stringio): added read_nonblock and
write_nonblock aliases.  [ruby-dev:39551]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-27 13:22:40 +00:00
naruse b07650769e * stringio/stringio.c (strio_read): set ASCII-8BIT encoding
when length argument is given.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-28 01:08:24 +00:00
naruse 6bbed0e31b * test: use require_relative.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-12 17:00:51 +00:00
matz fa31dda1f8 * ext/stringio/stringio.c (strio_each_codepoint): new method.
[ruby-core:23949]

* ext/stringio/stringio.c (strio_each_codepoint): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-22 08:23:30 +00:00
nobu af634f8455 * ext/stringio/stringio.c (strio_ungetbyte): encoding should not
be effective.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-14 07:07:55 +00:00
nobu 090dc8fd54 * test/stringio/test_stringio.rb (test_path): StringIO#path is no
longer defined.  [ruby-dev:38254]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-06 01:49:48 +00:00
nobu 287a34ae0d * {ext,lib,test}/**/*.rb: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-06 03:56:38 +00:00