Age | Commit message (Collapse) | Author |
|
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>
|
|
https://github.com/ruby/strscan/commit/ba338b882c
|
|
https://github.com/ruby/strscan/commit/842845af1f
|
|
https://github.com/ruby/strscan/commit/d6f97ec102
|
|
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
|
|
This reverts commit 6a79e53823e328281b9e9eee53cd141af28f8548.
|
|
|
|
https://github.com/ruby/strscan/commit/1b3393be05
|
|
[ci skip]
|
|
rb_reg_onig_match performs preparation, error handling, and cleanup for
matching a regex against a string. This reduces repetitive code and
removes the need for StringScanner to access internal data of regex.
Notes:
Merged: https://github.com/ruby/ruby/pull/8123
|
|
Syncs commit ruby/strscan@76b377a5d875ec77282d9319d62d8f24fe283b40.
|
|
https://github.com/ruby/strscan/commit/681cde0f27
|
|
(https://github.com/ruby/strscan/pull/49)
The doc of `rest?` was unclear about return value. This commit adds the
return value to the doc.
|
|
https://github.com/ruby/strscan/commit/3ada12613d
Notes:
Merged: https://github.com/ruby/ruby/pull/7025
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/6890
|
|
If we use the same version as the default strscan gem in Ruby, "gem
install" doesn't extract .gem. It fails "gem install" because "gem
install" can't find ext/strscan/ to be built.
https://github.com/ruby/strscan/commit/3ceafa6cdc
Notes:
Merged: https://github.com/ruby/ruby/pull/5011
|
|
iff means if and only if, but readers without that knowledge might
assume this to be a spelling mistake. To me, this seems like
exclusionary language that is unnecessary. Simply using "if and only if"
instead should suffice.
https://github.com/ruby/strscan/commit/066451c11e
|
|
`String#byteslice` returns non string value [Bug #17756] (#20)
https://github.com/ruby/strscan/commit/92961cde2b
|
|
The [] wasn't being displayed, and try to fix formatting for bol?
and << (even if they aren't linked).
Fixes [Bug #17620]
|
|
https://github.com/ruby/strscan/commit/a999f2c6d1
|
|
https://github.com/ruby/strscan/commit/08645e4e77
|
|
* Make strscan Ractor safe
* Add test-unit in the development dependencies
https://github.com/ruby/strscan/commit/3c93c2bebe
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/3623
|
|
Fixes [Bug #17139]
|
|
https://github.com/ruby/strscan/commit/df90d541fa
|
|
`$KCODE` has been deprecated and not effective since years ago.
https://github.com/ruby/strscan/commit/7c4dbd4cb3
|
|
|
|
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.
Notes:
Merged: https://github.com/ruby/ruby/pull/2476
|
|
To get rid of a bug of `onig_region_set` which takes `int`s
instead of `OnigPosition`s, set elements of `beg` and `end`
members directly, for the time being.
|
|
Notes:
Merged-By: kou <kou@clear-code.com>
|
|
Init functions are called only once, cache is useless.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* 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
|
|
* 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
|
|
* ext/strscan/strscan.c (minl): extract to reduce repeated S_LEN.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* ext/strscan/strscan.c (strscan_getch, strscan_peek),
(strscan_rest_size, inspect2): use S_RESTLEN consistently.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
patch by dbussink.
partially merge https://github.com/ruby/ruby/pull/497
* include/ruby/ruby.h: ditto.
* gc.c: ditto.
* ext/strscan/strscan.c: ditto.
* parse.y: ditto.
* string.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* parse.y (rb_parser_new, ripper_s_allocate): allocate structs
with making new wrapper objects and get rid of potential memory
leak.
* variable.c (rb_autoload): ditto.
* ext/digest/digest.c (rb_digest_base_alloc): ditto.
* ext/strscan/strscan.c (strscan_s_allocate): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* re.c (rb_reg_region_copy): new function to try with GC if copy
failed and return the error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* ext/strscan/strscan.c (strscan_init_copy): fix inverted
condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* re.c (CHECK_REGION_COPIED): onig_region_copy() can fail when
memory exhausted but returns nothing, so check by if allocated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* 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
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Using calloc where possible reduces code and binary sizes.
* include/ruby/ruby.h (ZALLOC, ZALLOC_N): implement
(Data_Make_Struct, TypedData_Make_Struct):
ZALLOC replaces ALLOC+memset
* compile.c (iseq_seq_sequence): ZALLOC_N replaces ALLOC_N+MEMZERO
* cont.c (fiber_t_alloc): ZALLOC replaces ALLOC+MEMZERO
* io.c (rb_io_reopen): ditto
* iseq.c (prepare_iseq_build): ditto
* parse.y (new_args_tail_gen, parser_new, ripper_s_allocate): ditto
* re.c (match_alloc): ditto
* variable.c (rb_const_set): ditto
* ext/socket/raddrinfo.c (get_addrinfo): ditto
* ext/strscan/strscan.c (strscan_s_allocate): ditto
* gc.c (rb_objspace_alloc): calloc replaces malloc+MEMZERO
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* ext/strscan/strscan.c (BUFSIZE): Ditto.
* ext/zlib/zlib.c (OBJ_IS_FREED): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* ext/strscan/strscan.c (inspect1): fix typo, rb_str_cat() instead
of rb_str_cat2().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* ext/strscan/strscan.c (inspect1): extract intermediate string from
the buffer directly, like as inspect2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|