Commit b31a538
authored
Fix ascii_only? flag in strio_write (#77)
Followup of #79
`rb_str_resize()` was changed by ruby/ruby@b0b9f72 .
```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()`.1 parent 8230552 commit b31a538
2 files changed
+7
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | 918 | | |
922 | 919 | | |
923 | 920 | | |
| |||
1464 | 1461 | | |
1465 | 1462 | | |
1466 | 1463 | | |
1467 | | - | |
1468 | | - | |
1469 | | - | |
1470 | | - | |
1471 | | - | |
1472 | 1464 | | |
| 1465 | + | |
1473 | 1466 | | |
1474 | | - | |
1475 | 1467 | | |
1476 | 1468 | | |
1477 | 1469 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
961 | 961 | | |
962 | 962 | | |
963 | 963 | | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
964 | 970 | | |
965 | 971 | | |
966 | 972 | | |
| |||
0 commit comments