ruby/ext/stringio
Takashi Kokubun 1df1538be4 merge revision(s) f54369830f, 338eb0065b, ac636f5709: [Backport #20516]
Revert "Rollback to released version numbers of stringio and strscan"

	This reverts commit 6a79e53823.

	[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

	1fbfdd3c6f

	[ruby/strscan] Bump version

	d6f97ec102
2024-06-04 13:14:09 -07: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
README.md ext/stringio/README.md: update [ci skip] 2016-06-08 07:47:39 +00:00
stringio.c merge revision(s) f54369830f, 338eb0065b, ac636f5709: [Backport #20516] 2024-06-04 13:14:09 -07:00
stringio.gemspec [ruby/stringio] Make STRINGIO_VERSION uniform 2023-11-04 19:28:49 +09:00

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.