Skip to content

Commit 6d2ceea

Browse files
authored
Merge branch 'master' into no_object_flags
2 parents a538c4d + c3474bf commit 6d2ceea

File tree

12 files changed

+247
-182
lines changed

12 files changed

+247
-182
lines changed

.github/workflows/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
git config --global core.autocrlf false
2929
git config --global core.eol lf
3030
git config --global advice.detachedHead 0
31-
- uses: actions/checkout@v5
31+
- uses: actions/checkout@v6
3232
- name: Set up Ruby
3333
uses: ruby/setup-ruby@v1
3434
with:

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
timeout-minutes: 10
1010
steps:
11-
- uses: actions/checkout@v5
11+
- uses: actions/checkout@v6
1212
- name: Extract release note
1313
run: |
1414
ruby \
@@ -40,7 +40,7 @@ jobs:
4040
- ruby
4141
- jruby
4242
steps:
43-
- uses: actions/checkout@v5
43+
- uses: actions/checkout@v6
4444
- uses: ruby/setup-ruby@v1
4545
with:
4646
ruby-version: ${{ matrix.ruby }}

.github/workflows/sync-ruby.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
if: ${{ github.repository_owner == 'ruby' }}
1010
steps:
11-
- uses: actions/checkout@v5
11+
- uses: actions/checkout@v6
1212

1313
- name: Create GitHub App token
1414
id: app-token

.github/workflows/ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
git config --global core.autocrlf false
2929
git config --global core.eol lf
3030
git config --global advice.detachedHead 0
31-
- uses: actions/checkout@v5
31+
- uses: actions/checkout@v6
3232
- uses: actions/setup-java@v5
3333
with:
3434
distribution: zulu

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
git config --global core.autocrlf false
3030
git config --global core.eol lf
3131
git config --global advice.detachedHead 0
32-
- uses: actions/checkout@v5
32+
- uses: actions/checkout@v6
3333
- uses: actions/setup-java@v5
3434
with:
3535
distribution: zulu

NEWS.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
# News
22

3+
## 3.1.8 - 2025-11-12
4+
5+
### Improvements
6+
7+
* Improved documents
8+
* Patch by Burdette Lamar
9+
10+
* Improved chilled string support
11+
* GH-128
12+
13+
### Fixes
14+
15+
* Fixed SEGV in `StringIO#seek` with `SEEK_END` on `StringIO.new(nil)`
16+
* GH-137
17+
* Patch by koh-sh
18+
19+
* Fixed SEGV in `StringIO#read` on `StringIO.new(nil)`
20+
21+
* Fixed SEGV in `StringIO#pread` on `StringIO.new(nil)`
22+
23+
* Fixed SEGV in `StringIO#eof?` on `StringIO.new(nil)`
24+
25+
* JRuby: Fixed a bug that `StringIO#read` doesn't clear code range
26+
* GH-156
27+
* Patch by Karol Bucek
28+
29+
### Thanks
30+
31+
* koh-sh
32+
33+
* Burdette Lamar
34+
35+
* Karol Bucek
36+
337
## 3.1.7 - 2025-04-21
438

539
### Improvements

doc/stringio/each_line.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
With a block given calls the block with each remaining line (see "Position" below) in the stream;
2+
returns `self`.
3+
4+
Leaves stream position at end-of-stream.
5+
6+
**No Arguments**
7+
8+
With no arguments given,
9+
reads lines using the default record separator
10+
(global variable `$/`, whose initial value is `"\n"`).
11+
12+
```ruby
13+
strio = StringIO.new(TEXT)
14+
strio.each_line {|line| p line }
15+
strio.eof? # => true
16+
```
17+
18+
Output:
19+
20+
```
21+
"First line\n"
22+
"Second line\n"
23+
"\n"
24+
"Fourth line\n"
25+
"Fifth line\n"
26+
```
27+
28+
**Argument `sep`**
29+
30+
With only string argument `sep` given,
31+
reads lines using that string as the record separator:
32+
33+
```ruby
34+
strio = StringIO.new(TEXT)
35+
strio.each_line(' ') {|line| p line }
36+
```
37+
38+
Output:
39+
40+
```
41+
"First "
42+
"line\nSecond "
43+
"line\n\nFourth "
44+
"line\nFifth "
45+
"line\n"
46+
```
47+
48+
**Argument `limit`**
49+
50+
With only integer argument `limit` given,
51+
reads lines using the default record separator;
52+
also limits the size (in characters) of each line to the given limit:
53+
54+
```ruby
55+
strio = StringIO.new(TEXT)
56+
strio.each_line(10) {|line| p line }
57+
```
58+
59+
Output:
60+
61+
```
62+
"First line"
63+
"\n"
64+
"Second lin"
65+
"e\n"
66+
"\n"
67+
"Fourth lin"
68+
"e\n"
69+
"Fifth line"
70+
"\n"
71+
```
72+
73+
**Arguments `sep` and `limit`**
74+
75+
With arguments `sep` and `limit` both given,
76+
honors both:
77+
78+
```ruby
79+
strio = StringIO.new(TEXT)
80+
strio.each_line(' ', 10) {|line| p line }
81+
```
82+
83+
Output:
84+
85+
```
86+
"First "
87+
"line\nSecon"
88+
"d "
89+
"line\n\nFour"
90+
"th "
91+
"line\nFifth"
92+
" "
93+
"line\n"
94+
```
95+
96+
**Position**
97+
98+
As stated above, method `each` _remaining_ line in the stream.
99+
100+
In the examples above each `strio` object starts with its position at beginning-of-stream;
101+
but in other cases the position may be anywhere (see StringIO#pos):
102+
103+
```ruby
104+
strio = StringIO.new(TEXT)
105+
strio.pos = 30 # Set stream position to character 30.
106+
strio.each_line {|line| p line }
107+
```
108+
109+
Output:
110+
111+
```
112+
" line\n"
113+
"Fifth line\n"
114+
```
115+
116+
In all the examples above, the stream position is at the beginning of a character;
117+
in other cases, that need not be so:
118+
119+
```ruby
120+
s = 'こんにちは' # Five 3-byte characters.
121+
strio = StringIO.new(s)
122+
strio.pos = 3 # At beginning of second character.
123+
strio.each_line {|line| p line }
124+
strio.pos = 4 # At second byte of second character.
125+
strio.each_line {|line| p line }
126+
strio.pos = 5 # At third byte of second character.
127+
strio.each_line {|line| p line }
128+
```
129+
130+
Output:
131+
132+
```
133+
"んにちは"
134+
"\x82\x93にちは"
135+
"\x93にちは"
136+
```
137+
138+
**Special Record Separators**
139+
140+
Like some methods in class `IO`, StringIO.each honors two special record separators;
141+
see {Special Line Separators}[https://docs.ruby-lang.org/en/master/IO.html#class-IO-label-Special+Line+Separator+Values].
142+
143+
```ruby
144+
strio = StringIO.new(TEXT)
145+
strio.each_line('') {|line| p line } # Read as paragraphs (separated by blank lines).
146+
```
147+
148+
Output:
149+
150+
```
151+
"First line\nSecond line\n\n"
152+
"Fourth line\nFifth line\n"
153+
```
154+
155+
```ruby
156+
strio = StringIO.new(TEXT)
157+
strio.each_line(nil) {|line| p line } # "Slurp"; read it all.
158+
```
159+
160+
Output:
161+
162+
```
163+
"First line\nSecond line\n\nFourth line\nFifth line\n"
164+
```
165+
166+
**Keyword Argument `chomp`**
167+
168+
With keyword argument `chomp` given as `true` (the default is `false`),
169+
removes trailing newline (if any) from each line:
170+
171+
```ruby
172+
strio = StringIO.new(TEXT)
173+
strio.each_line(chomp: true) {|line| p line }
174+
```
175+
176+
Output:
177+
178+
```
179+
"First line"
180+
"Second line"
181+
""
182+
"Fourth line"
183+
"Fifth line"
184+
```
185+
186+
With no block given, returns a new {Enumerator}[https://docs.ruby-lang.org/en/master/Enumerator.html].
187+
188+
189+
Related: StringIO.each_byte, StringIO.each_char, StringIO.each_codepoint.

doc/stringio/size.rdoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Returns the number of bytes in the string in +self+:
2+
3+
StringIO.new('hello').size # => 5 # Five 1-byte characters.
4+
StringIO.new('тест').size # => 8 # Four 2-byte characters.
5+
StringIO.new('こんにちは').size # => 15 # Five 3-byte characters.

docs/io.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
# The {built-in class for I/O}[https://docs.ruby-lang.org/en/master/IO.html].
22
class IO
3-
# :stopdoc:
4-
module generic_readable
5-
end
6-
module generic_writable
7-
end
83
end

ext/java/org/jruby/ext/stringio/StringIO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private StringIOData getPtr() {
102102
}
103103

104104
private static final String
105-
STRINGIO_VERSION = "3.1.8";
105+
STRINGIO_VERSION = "3.1.9";
106106

107107
private static final byte STRIO_READABLE = 1;
108108
private static final byte STRIO_WRITABLE = 2;

0 commit comments

Comments
 (0)