ruby/ext/stringio
tomoya ishida fd1bafc11f [ruby/stringio] Fix ascii_only? flag in strio_write
(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()`.

https://github.com/ruby/stringio/commit/b31a538576
2024-01-18 03:42:21 +00:00
..
README.md ext/stringio/README.md: update [ci skip] 2016-06-08 07:47:39 +00:00
depend Update the depend files 2023-02-28 09:09:00 -08:00
extconf.rb [ruby/stringio] Do not compile the C extension on TruffleRuby 2023-11-27 12:21:24 +00:00
stringio.c [ruby/stringio] Fix ascii_only? flag in strio_write 2024-01-18 03:42:21 +00:00
stringio.gemspec [ruby/stringio] Make STRINGIO_VERSION uniform 2023-11-04 19:28:49 +09:00

README.md

StringIO

Pseudo IO class from/to String.

This library is based on MoonWolf version written in Ruby. Thanks a lot.

Differences to IO

  • fileno raises NotImplementedError.
  • encoding conversion is not implemented, and ignored silently.