Andrii Konchyn
8fa6c36492
[ruby/strscan] Omit tests for `#scan_byte` and `#peek_byte` on
...
TruffleRuby temporary
(https://github.com/ruby/strscan/pull/91 )
The methods were added in #89 but they aren't implemented in TruffleRuby
yet. So let's omit them for now to have CI green.
https://github.com/ruby/strscan/commit/844d963b56
2024-03-27 12:17:01 +09:00
Aaron Patterson
164e464b04
[ruby/strscan] Add a method for peeking and reading bytes as
...
integers
(https://github.com/ruby/strscan/pull/89 )
This commit adds `scan_byte` and `peek_byte`. `scan_byte` will scan the
current byte, return it as an integer, and advance the cursor.
`peek_byte` will return the current byte as an integer without advancing
the cursor.
Currently `StringScanner#get_byte` returns a string, but I want to get
the current byte without allocating a string. I think this will help
with writing high performance lexers.
---------
https://github.com/ruby/strscan/commit/873aba2e5d
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2024-02-26 15:54:54 +09:00
Charles Oliver Nutter
39f2e37ff1
[ruby/strscan] Don't add begin to length for new string slice
...
(https://github.com/ruby/strscan/pull/87 )
Fixes https://github.com/ruby/strscan/pull/86
https://github.com/ruby/strscan/commit/c17b015c00
2024-02-08 14:43:56 +09:00
NAITOH Jun
91f3530580
[ruby/strscan] Add test to check encoding for empty string
...
(https://github.com/ruby/strscan/pull/80 )
See: https://github.com/ruby/strscan/issues/78#issuecomment-1890849891
https://github.com/ruby/strscan/commit/d0508518a9
2024-01-19 10:49:12 +09:00
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
Peter Zhu
e27eab2f85
[ruby/strscan] Sync missed commit
...
Syncs commit ruby/strscan@76b377a5d8 .
2023-07-27 09:42:42 -04:00
Charles Oliver Nutter
4c7726516c
[ruby/strscan] Mask out this test on JRuby/Windows
...
See https://github.com/jruby/jruby/issues/7644 for the root issue,
which will require fixes to JRuby's regular expression engine,
JOni.
https://github.com/ruby/strscan/commit/29a65abff2
2023-02-21 19:31:39 +09:00
Sutou Kouhei
76a4cdfb02
[ruby/strscan] test: Run test more with fixed anchor mode
...
(https://github.com/ruby/strscan/pull/60 )
fix https://github.com/ruby/strscan/pull/56
2023-02-21 19:31:38 +09:00
OKURA Masafumi
260bc7cdfa
[ruby/strscan] Add test case to `test_string`
...
(https://github.com/ruby/strscan/pull/58 )
`string` returns the original string after `scan` is called. Current
test doesn't check this behavior and now it's covered.
2023-02-21 19:31:38 +09:00
Hiroshi SHIBATA
4e31fea77d
Merge strscan-3.0.5
2022-12-09 16:36:22 +09:00
Kenichi Kamiya
564ccd095a
[ruby/strscan] Fix segmentation fault of `StringScanner#charpos` when `String#byteslice` returns non string value [Bug #17756 ] ( #20 )
...
https://github.com/ruby/strscan/commit/92961cde2b
2021-05-06 16:20:38 +09:00
Hiroshi SHIBATA
822eb94563
Import from https://github.com/ruby/strscan/pull/19
...
* Use Gemfile instead of Gem::Specification#add_development_dependency.
* Use pend instead of skip for test-unit.
2021-05-06 16:18:58 +09:00
Kenta Murata
985f0af257
[strscan] Make strscan Ractor safe ( #17 )
...
* Make strscan Ractor safe
* Add test-unit in the development dependencies
https://github.com/ruby/strscan/commit/3c93c2bebe
2020-12-18 14:25:41 +09:00
Jeremy Evans
ffd0820ab3
Deprecate taint/trust and related methods, and make the methods no-ops
...
This removes the related tests, and puts the related specs behind
version guards. This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
Sutou Kouhei
95c420c4a6
Import StringScanner 1.0.3 ( #2553 )
2019-10-14 12:40:50 +09:00
nobu
256c88861b
strscan.c: add MatchData-like methods
...
* ext/strscan/strscan.c: added `size`, `captures` and `values_at`
to StringScanner, shorthands of accessing the matched data.
based on the patch by apeiros (Stefan Rusterholz) at
[ruby-core:20412]. [Feature #836 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-29 07:57:48 +00:00
nobu
90311f37e4
strscan.c: fix segfault in aref
...
* ext/strscan/strscan.c (strscan_aref): fix segfault after
get_byte or getch which do not apply regexp.
[ruby-core:82116] [Bug #13759 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-21 13:30:46 +00:00
kazu
a4fde3b60c
{ext,test}/strscan: Specify frozen_string_literal: true.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-06 13:23:39 +00:00
naruse
3e92b635fb
Add frozen_string_literal: false for all files
...
When you change this to true, you may need to add more tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
nobu
4713ace44c
strscan.c: encoding in messages
...
* ext/strscan/strscan.c (strscan_aref): preserve argument encoding
in error messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-03 01:56:31 +00:00
usa
5543a55b52
* test: get rid of warnings.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-11 04:22:34 +00:00
naruse
c43dd625b6
* ext/strscan/strscan.c (strscan_aref): raise error if given
...
name reference is not found.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-24 07:32:45 +00:00
naruse
ecd5bbe82a
* ext/strscan/strscan.c (strscan_aref): support named captures.
...
patched by Konstantin Haase [ruby-core:54664] [Feature #8343 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 13:48:57 +00:00
ryan
0700a9113f
Added #charpos for multibyte string position.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 00:17:33 +00:00
akr
47b8a0e7e4
avoid method redefinition.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-14 03:09:53 +00:00
nobu
2ef382231f
* ext/strscan/strscan.c (strscan_set_string): set string should not be
...
dupped or frozen, because freezing it causes #concat method failure,
and unnecessary to dup without freezing. a patch from Aaron
Patterson at [ruby-core:25145].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-26 23:16:40 +00:00
matz
d121a3fb79
* ext/strscan/strscan.c (Init_strscan): remove obsolete
...
matchedsize method, use matched_size instead. [ruby-dev:38591]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-17 04:57:11 +00:00
nobu
00b4a3f9c4
* test: assert_raises has been deprecated since a long time ago.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-24 17:44:39 +00:00
mame
437af4f46f
* test/stringio/test_stringio.rb: add tests to achieve over 95% test
...
coverage of stringio.
* test/strscan/test_stringscanner.rb: ditto for strscan.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-05 14:33:01 +00:00
matz
ab24f2b077
* re.c (rb_reg_prepare_re): made non static with small refactoring.
...
* ext/strscan/strscan.c (strscan_do_scan): should adjust encoding
before regex searching.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-12 06:09:53 +00:00
akr
b8a9eb304d
add a test.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-28 16:13:43 +00:00
akr
1c0416e6ee
* ext/strscan/strscan.c (str_new): new function for allocate an string
...
with encoding propagation.
(extract_range): use str_new.
(extract_beg_len): ditto.
(strscan_peek): ditto.
(strscan_rest): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-28 14:55:43 +00:00
matz
326659c0bf
* test/socket/test_socket.rb: update not to use 1.8 assignment to
...
external local variable in the block parameters. [ruby-dev:32251]
* test/strscan/test_stringscanner.rb: avoid $KCODE, and use
String#force_encoding(). [ruby-dev:32251]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-14 07:03:39 +00:00
aamine
544789bd79
* ext/strscan/strscan.c (strscan_do_scan): StringScanner.new("").scan(//) should return "". [ruby-Bugs:4361]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-07-26 08:44:57 +00:00
aamine
492dfc7c08
* ext/strscan/strscan.c: new method StringScanner#initialize_copy to allow #dup and #clone.
...
* test/strscan/test_strscan.rb: test StringScanner#dup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-03-05 11:20:12 +00:00
nahi
994dfc0ae6
* test/*: should not depend on $KCODE.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-02-18 13:08:08 +00:00
aamine
6ef31af2d1
introduce some new methods
...
* ext/strscan/strscan.c: new method StringScanner#beginning_of_line? (alias #bol?)
* ext/strscan/strscan.c: new method StringScanner#concat and #<<.
* ext/strscan/strscan.c: StringScanner#new(str) does not duplicate nor freeze STR (allow destructive modification).
* test/strscan/test_stringscanner.rb: test new methods above.
* test/strscan/test_stringscanner.rb: test destructive string modification.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-12-16 15:18:11 +00:00
aamine
ed970e2513
* test/strscan/test_stringscanner.rb: require test/unit.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-09-17 09:51:32 +00:00
aamine
dbfd0ae0bb
* test/strscan/test_stringscanner.rb: new file.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-09-17 09:36:04 +00:00