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

86 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 302f353fd9 [ruby/stringio] Fix the result of `StringIO#truncate` so compatible with `File`
https://github.com/ruby/stringio/commit/16847fea32
2022-07-01 00:52:29 +09:00
Nobuyoshi Nakada d3e986d9ab [ruby/stringio] Accept external and internal encodings pair
Fix https://github.com/ruby/stringio/pull/16

https://github.com/ruby/stringio/commit/c8a69e80d2
2022-05-30 14:48:44 +09:00
Jeremy Evans 609d73e892 [ruby/stringio] Fix handling of chomp with paragraph separator
Try to mirror IO behavior, where chomp takes out the entire paragraph
separators between entries, but does not chomp a single line separator
at the end of the string.

Partially Fixes [Bug #18768]

https://github.com/ruby/stringio/commit/a83ddbb7f0
2022-05-30 13:10:46 +09:00
Jeremy Evans adaaf12857 [ruby/stringio] Ignore chomp keyword for nil separator
nil separator means no separator at all, so nothing should be
chomped.

Partial fix for Ruby [Bug #18770]

https://github.com/ruby/stringio/commit/feaa2ec631
2022-05-30 13:01:17 +09:00
Jeremy Evans 1f82269f4e [ruby/stringio] Fix each with multiple character string and chomp
Previously, this could result in an infinite loop.  Always update
the e pointer in this case, setting w when chomping so the chomped
data is not included in the output.

Fixes [Bug #18769]

https://github.com/ruby/stringio/commit/4bf64d5130
2022-05-30 12:55:47 +09:00
Nobuyoshi Nakada bb6357cddd [ruby/stringio] Fix expanding size at ungetc/ungetbyte
https://github.com/ruby/stringio/commit/a35268a3ac
2022-05-30 12:51:37 +09:00
Nobuyoshi Nakada 32a13591e0
[ruby/stringio] Check if closed in loop
[Bug #17675] https://bugs.ruby-lang.org/issues/17675

https://github.com/ruby/stringio/commit/1ed61d0cbc
2021-03-08 10:13:29 +09:00
Hiroshi SHIBATA c3c1800708
Prefer to use omit 2021-03-08 09:34:16 +09:00
Kenta Murata 3d31944129
[stringio] Make stringio Ractor safe
https://github.com/ruby/stringio/commit/ee3fec7512
https://github.com/ruby/stringio/commit/18dcd045ef
https://github.com/ruby/stringio/commit/18dcd045ef
2020-12-18 22:00:07 +09:00
Yoann Lecuyer b3c1c767ea [stringio] fix stringio codepoint enumerator off by one error 2020-08-27 23:41:22 +09:00
Nobuyoshi Nakada ddb2acbba6 [ruby/stringio] No compatibility check in US-ASCII case
https://github.com/ruby/stringio/commit/59df1c8293
2020-07-20 14:59:19 +09:00
Nobuyoshi Nakada c62aff1632 [ruby/stringio] Added non-ASCII but convertible encoding case
https://github.com/ruby/stringio/commit/1d28e5c969
2020-07-20 14:59:19 +09:00
Nobuyoshi Nakada 6ff9604f85 [ruby/stringio] Raise an error if encoding conversion not succeeded
As `rb_str_conv_enc()` returns the argument string object itself
unchanged when any conversion failed, check the incompatibility in
that case.

Fixes https://github.com/ruby/stringio/issues/13

https://github.com/ruby/stringio/commit/ede6bdcc71
2020-07-20 14:59:19 +09:00
Jean Boussier e257c08f2e
[ruby/stringio] StringIO#initialize default to the source string encoding
[Bug #16497]

https://github.com/ruby/stringio/commit/4958a5ccab
2020-03-15 18:43:01 +09:00
Jeremy Evans ebc884461b
[ruby/stringio] Remove taint support
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.

https://github.com/ruby/stringio/commit/60ee9ccd95
2019-10-31 16:24:02 +09:00
卜部昌平 11b6ff12af more use of RbConfig::LIMITS
`8 * RbConfig::SIZEOF` ... is not straight.
2019-10-08 11:21:20 +09:00
Nobuyoshi Nakada cad41bb6d3
[ruby/stringio] Supported BOM
https://github.com/ruby/stringio/commit/b249631c43
2019-08-14 11:20:58 +09:00
Nobuyoshi Nakada c8f9e9a2a0
[ruby/stringio] stringio: encoding support
https://github.com/ruby/stringio/commit/7b20075ab0
2019-08-14 11:20:57 +09:00
Nobuyoshi Nakada e0c4cb2ea1
Define singleton method on each new objects 2019-06-28 15:22:27 +09:00
shyouhei d154bec0d5 setbyte / ungetbyte allow out-of-range integers
* string.c: String#setbyte to accept arbitrary integers [Bug #15460]

* io.c: ditto for IO#ungetbyte

* ext/strringio/stringio.c: ditto for StringIO#ungetbyte



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-15 06:41:58 +00:00
kazu 730f2886b5 Follow behaviour of IO#ungetbyte
see r65802 and [Bug #14359]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-09 12:55:20 +00:00
hsbt 1380aa04a6 Support old versions of Ruby with FrozenError.
They should work separatedly from Ruby core repository.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-07 12:47:11 +00:00
shyouhei b57915eddc Add FrozenError as a subclass of RuntimeError
FrozenError will be used instead of RuntimeError for exceptions
raised when there is an attempt to modify a frozen object. The
reason for this change is to differentiate exceptions related
to frozen objects from generic exceptions such as those generated
by Kernel#raise without an exception class.

From: Jeremy Evans <code@jeremyevans.net>
Signed-off-by: Urabe Shyouhei <shyouhei@ruby-lang.org>


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 00:46:34 +00:00
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