Граф коммитов

106 Коммитов

Автор SHA1 Сообщение Дата
Hiroshi SHIBATA 78bfde5d9f
Revert "[ruby/strscan] Doc for StringScanner"
This reverts commit 974ed1408c.
2024-05-30 21:13:10 +09:00
Hiroshi SHIBATA d70b0da482
Revert "Fix reference path for strscan documentation"
This reverts commit 1fa93fb948.
2024-05-30 21:13:01 +09:00
Hiroshi SHIBATA 1fa93fb948
Fix reference path for strscan documentation 2024-05-30 14:29:25 +09:00
Burdette Lamar 974ed1408c
[ruby/strscan] Doc for StringScanner
(https://github.com/ruby/strscan/pull/96)

#peek_byte and #scan_byte not updated (not available in my repo --
sorry).

---------

https://github.com/ruby/strscan/commit/0123da7352

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
2024-05-30 12:34:18 +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
Sutou Kouhei ce2618c628
[ruby/strscan] Bump version
https://github.com/ruby/strscan/commit/ba338b882c
2024-02-08 14:43:56 +09:00
Sutou Kouhei 5afae77ce9
[ruby/strscan] Bump version
https://github.com/ruby/strscan/commit/842845af1f
2024-02-08 14:43:56 +09:00
Sutou Kouhei ac636f5709
[ruby/strscan] Bump version
https://github.com/ruby/strscan/commit/d6f97ec102
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
Hiroshi SHIBATA f54369830f Revert "Rollback to released version numbers of stringio and strscan"
This reverts commit 6a79e53823.
2023-12-25 21:12:49 +09:00
Hiroshi SHIBATA 6a79e53823
Rollback to released version numbers of stringio and strscan 2023-12-16 12:00:59 +08:00
Sutou Kouhei ce8301084f [ruby/strscan] Bump version
https://github.com/ruby/strscan/commit/1b3393be05
2023-11-08 09:26:58 +09:00
Peter Zhu 91e13a5207 [ruby/strscan] Fix indentation in strscan.c
[ci skip]
2023-07-28 10:12:52 -04:00
Peter Zhu 7193b404a1 Add function rb_reg_onig_match
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.
2023-07-27 13:33:40 -04:00
Peter Zhu e27eab2f85 [ruby/strscan] Sync missed commit
Syncs commit ruby/strscan@76b377a5d8.
2023-07-27 09:42:42 -04:00
Sutou Kouhei 18e840ac60 [ruby/strscan] Bump version
https://github.com/ruby/strscan/commit/681cde0f27
2023-02-21 19:31:36 +09:00
OKURA Masafumi a44f5ab089 [ruby/strscan] Mention return value of `rest?` in the doc
(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.
2023-02-21 19:31:35 +09:00
Sutou Kouhei 79ad045214 [ruby/strscan] Bump version
https://github.com/ruby/strscan/commit/3ada12613d
2022-12-26 15:09:21 +09:00
Hiroshi SHIBATA 4e31fea77d Merge strscan-3.0.5 2022-12-09 16:36:22 +09:00
Sutou Kouhei c0c43276a1 [ruby/strscan] Bump version
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
2021-10-24 05:57:48 +09:00
Gannon McGibbon a42b7de436 [ruby/strscan] Replace "iff" with "if and only if" (#18)
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
2021-05-06 16:21:14 +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
Jeremy Evans c03b723f56 Update class documentation for StringScanner
The [] wasn't being displayed, and try to fix formatting for bol?
and << (even if they aren't linked).

Fixes [Bug #17620]
2021-02-10 08:17:07 -08:00
Kenta Murata b5de66e132
[strscan] Fix license comment and files
https://github.com/ruby/strscan/commit/a999f2c6d1
2020-12-18 14:25:48 +09:00
Kenta Murata 5370963992
[strscan] Version 3.0.0
https://github.com/ruby/strscan/commit/08645e4e77
2020-12-18 14:25:42 +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
Aaron Patterson 6aa466ba9c mark regex internal to string scanner 2020-10-02 12:01:57 -07:00
Jeremy Evans d9b8411a7b Document that StringScanner#matched_size returns size in bytes [ci skip]
Fixes [Bug #17139]
2020-09-02 10:41:49 -07:00
Sutou Kouhei c23c880f56
[ruby/strscan] Bump version
https://github.com/ruby/strscan/commit/df90d541fa
2020-08-31 21:57:35 +09:00
Nobuyoshi Nakada c76508b88c
[ruby/strscan] Replaced examples using $KCODE with encodings
`$KCODE` has been deprecated and not effective since years ago.

https://github.com/ruby/strscan/commit/7c4dbd4cb3
2020-08-31 21:57:35 +09:00
Nobuyoshi Nakada d8720eb7de
Suppress -Wshorten-64-to-32 warnings 2020-04-08 16:28:38 +09:00
Jeremy Evans d03da13b17 [ruby/strscan] Remove taint support
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.
2019-11-18 01:00:25 +02:00
Nobuyoshi Nakada 3e763883ea
Fixed overflow at onig_region_set
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.
2019-10-14 15:10:56 +09:00
Sutou Kouhei 95c420c4a6
Import StringScanner 1.0.3 (#2553) 2019-10-14 12:40:50 +09:00
nobu c8094ff154 no ID cache in Init functions
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
2018-02-16 08:39:48 +00:00
stomar 9a26a4c13a ext/strscan/strscan.c: [DOC] grammar fixes
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-08 22:42:19 +00: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
nobu 0b149ab5f3 strscan.c: minl
* 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
2016-09-28 05:11:22 +00:00
nobu 604ae2e151 strscan.c: use S_RESTLEN
* 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
2016-09-28 05:11:20 +00:00
naruse 21daa56b2a * re.c: Introduce RREGEXP_PTR.
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
2016-02-02 04:39:44 +00:00
ko1 dff42b0ea0 * ext/**/*.c (*_memsize): same as r52986 for extensions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09 01:01:17 +00:00
nobu 6fb9349d85 allocate structs with wrapper
* 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
2015-05-16 12:56:48 +00:00
nobu 012c558127 re.c: rb_reg_region_copy
* 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
2014-12-01 21:30:58 +00:00
nobu 8b3813f6b0 strscan.c: fix condition
* 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
2014-12-01 19:47:36 +00:00
nobu 4d63c85031 re.c: check if onig_region_copy failed
* 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
2014-12-01 19:43:10 +00:00
nobu e580a631be use 0 for reserved
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
2014-12-01 06:38:04 +00:00
nobu 28b9f11d5a protoize no-arguments functions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-30 05:25:32 +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
nobu 27c4fb3361 ext: get rid of inadvertent ID creation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-03 01:56:16 +00:00