ruby/ext
NAITOH Jun 338eb0065b [ruby/strscan] StringScanner#captures: Return nil not "" for
unmached capture
(https://github.com/ruby/strscan/pull/72)

fix https://github.com/ruby/strscan/issues/70
If there is no substring matching the group (s[3]), the behavior is
different.

If there is no substring matching the group, the corresponding element
(s[3]) should be nil.

```
s = StringScanner.new('foobarbaz') #=> #<StringScanner 0/9 @ "fooba...">
s.scan /(foo)(bar)(BAZ)?/  #=> "foobar"
s[0]           #=> "foobar"
s[1]           #=> "foo"
s[2]           #=> "bar"
s[3]           #=> nil
s.captures #=> ["foo", "bar", ""]
s.captures.compact #=> ["foo", "bar", ""]
```

```
s = StringScanner.new('foobarbaz') #=> #<StringScanner 0/9 @ "fooba...">
s.scan /(foo)(bar)(BAZ)?/  #=> "foobar"
s[0]           #=> "foobar"
s[1]           #=> "foo"
s[2]           #=> "bar"
s[3]           #=> nil
s.captures #=> ["foo", "bar", nil]
s.captures.compact #=> ["foo", "bar"]
```

https://docs.ruby-lang.org/ja/latest/method/MatchData/i/captures.html
```
/(foo)(bar)(BAZ)?/ =~ "foobarbaz" #=> 0
$~.to_a        #=> ["foobar", "foo", "bar", nil]
$~.captures #=> ["foo", "bar", nil]
$~.captures.compact #=> ["foo", "bar"]
```

* StringScanner#captures is not yet documented.
https://docs.ruby-lang.org/ja/latest/class/StringScanner.html

https://github.com/ruby/strscan/commit/1fbfdd3c6f
2024-01-14 22:27:24 +09:00
..
-test- Fix CRLF -> LF conversion on read for rb_io_fdopen & rb_file_open 2024-01-10 21:02:23 +11:00
bigdecimal [ruby/bigdecimal] Clarify that JSON methods come from the JSON gem 2023-12-06 16:14:54 +00:00
cgi/escape [ruby/cgi] Fix unescapeHTML 2023-11-30 08:19:28 +00:00
continuation
coverage [Feature #19719] Universal Parser 2023-06-12 18:23:48 +09:00
date [ruby/date] Provide a 'Changelog' link on rubygems.org/gems/date 2023-12-25 21:12:49 +09:00
digest [ruby/digest] Suppress implicit cast down warnings 2023-11-09 07:20:00 +00:00
erb/escape [ruby/erb] Skip building a native extension for JRuby 2024-01-04 22:33:16 +00:00
etc [ruby/etc] [DOC] Add minimal documents for constants 2023-12-27 10:09:24 +00:00
fcntl [ruby/fcntl] Bump up 1.1.0 2023-11-07 06:55:45 +00:00
fiddle [ruby/fiddle] Bump version 2023-12-25 21:12:49 +09:00
io [ruby/io-console] `IO_CONSOLE_VERSION` is no longer a macro 2024-01-03 02:12:30 +00:00
json [flori/json] Use rb_sym2str instead of SYM2ID 2023-12-25 21:12:49 +09:00
monitor `rb_bug` prints a newline after the message 2023-05-20 21:43:30 +09:00
nkf [ruby/nkf] Bump up nkf-0.1.3 2023-05-25 09:11:36 +00:00
objspace Revert "Mark asan fake stacks during machine stack marking" 2024-01-12 17:58:54 +11:00
openssl [ruby/openssl] Add support for `gets(chomp: true)`. 2024-01-13 00:28:26 +00:00
pathname [ruby/pathname] require fileutils in both methods using it 2023-12-28 00:07:56 +00:00
psych [ruby/psych] Remove now-unreachable rescue block 2023-12-25 21:12:49 +09:00
pty [DOC] Show `PTY.getpty` as an alias of `PTY.spawn` 2023-12-18 20:17:45 +09:00
rbconfig/sizeof
ripper Statically allocate parser config 2024-01-12 21:17:41 +09:00
rubyvm
socket Revert "Mark asan fake stacks during machine stack marking" 2024-01-12 17:58:54 +11:00
stringio Revert "Rollback to released version numbers of stringio and strscan" 2023-12-25 21:12:49 +09:00
strscan [ruby/strscan] StringScanner#captures: Return nil not "" for 2024-01-14 22:27:24 +09:00
syslog [ruby/syslog] Bump up v0.1.2 2023-12-16 13:06:37 +08:00
win32 Fix memory overread in registry.rb 2023-12-28 18:03:58 +11:00
win32ole [ruby/win32ole] [DOC] Fix indent 2023-12-31 11:52:19 +00:00
zlib [ruby/zlib] Bump up 3.1.0 2023-11-07 08:50:40 +00:00
.document [ruby/io-console] [DOC] Split .document files to sync with ruby/ruby 2023-10-22 11:09:06 +09:00
Setup
Setup.atheos racc/cparse is extracted from ruby/ruby repository 2023-06-08 18:05:07 +09:00
Setup.nt racc/cparse is extracted from ruby/ruby repository 2023-06-08 18:05:07 +09:00
extmk.rb Use `File::NULL` instead of hard coded null device names 2023-07-10 19:21:47 +09:00