(https://github.com/ruby/stringio/pull/117)
We need to ensure shared buffers are made independent on mutation.
Otherwise we could end up mutating unrelated string buffers.
---------
5101cfb030
Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
Co-authored-by: Aaron Patterson <aaron.patterson@gmail.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
When ungetting the string same as the same buffer string, extending
the buffer can move the pointer in the argument. Reported by manun
Manu (manun) at https://hackerone.com/reports/2805165.
95c1194832
reads
(https://github.com/ruby/stringio/pull/95)
[[Bug #20418]](https://bugs.ruby-lang.org/issues/20418)
Ruby IO#read preserves the encoding on partial read, but change it when
reading the whole IO
from commit 0ca7036682:
> * io.c (read_all): should associate default external encoding.
> * io.c (io_read): should NOT associate default external encoding.
073172da31
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
(https://github.com/ruby/stringio/pull/85)
* Fix compile warnings on latest Java.
* Adjust one test for JRuby erroring on bad pos= value.
* Replace hard JVM synchronization with a spin lock.
* Avoid duplicate reads of state fields where possible.
* Remove long-deprecated codepoints, chars, bytes, lines methods.
* Mark fcntl as not implemented
* Split most of the remaining variable-arity methods.
31a9d42e6c
(https://github.com/ruby/stringio/pull/77)
Followup of #79
`rb_str_resize()` was changed by b0b9f7201a .
```c
rb_str_resize(string, shorter) // clear ENC_CODERANGE in some case
rb_str_resize(string, longer) // does not clear ENC_CODERANGE anymore
```
```c
// rb_str_resize in string.c
if (slen > len && ENC_CODERANGE(str) != ENC_CODERANGE_7BIT) {
ENC_CODERANGE_CLEAR(str);
}
```
I think this change is based on an assumption that appending null bytes
will not change flag `ascii_only?`.
`strio_extend()` will make the string longer if needed, and update the
flags correctly for appending null bytes.
Before `memmove()`, we need to `rb_str_modify()` because updated flags are not
updated for `memmove()`.
b31a538576
(https://github.com/ruby/stringio/pull/67)
Fix: https://github.com/ruby/stringio/issues/66
If length is 0, IO#pread don't even try to read the IO, it simply return
the buffer untouched if there is one or a new empty buffer otherwise.
It also doesn't validate the offset when length is 0.
cc @jdelStrother @kou
37e9279337
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
Both for being closer to real IOs and also because it's a convenient API
in multithreaded scenarios.
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
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]
a83ddbb7f0
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]
4bf64d5130
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
* 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
* 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
* 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
* 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
* 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