-
Notifications
You must be signed in to change notification settings - Fork 42
Fix a bug that scanning methods that don't use Regexp don't clear named capture groups #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2b814b2 to
56368c2
Compare
test/strscan/test_stringscanner.rb
Outdated
| end | ||
|
|
||
| def test_string | ||
| omit("not implemented on TruffleRuby") if ["truffleruby"].include?(RUBY_ENGINE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use RUBY_ENGINE == "truffleruby" like existing code?
| omit("not implemented on TruffleRuby") if ["truffleruby"].include?(RUBY_ENGINE) | |
| omit("not implemented on TruffleRuby") if RUBY_ENGINE == "truffleruby" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
ext/strscan/strscan.c
Outdated
| #define MATCHED(s) ((s)->flags |= FLAG_MATCHED) | ||
| #define CLEAR_MATCHED(s) ((s)->flags &= ~FLAG_MATCHED) | ||
| #define CLEAR_NAMED_CAPTURES(s) ((s)->regex = Qnil) | ||
| #define CLEAR_MATCHED_AND_NAMED_CAPTURES(s) CLEAR_MATCHED(s); CLEAR_NAMED_CAPTURES(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use better name (more logical name) for this?
If we rename existing CLEAR_MATCH_STATUS() to CLEAR_MATCHED(), we may be able to use CLEAR_MATCH_STATUS() for CLEAR_MATCHED_AND_NAMED_CAPTURES().
Could you use while {statement1; statment2; ...} do (false) when you want to use multiple statements in a macro?
See also:
Lines 72 to 75 in c4e4795
| #define GET_SCANNER(obj,var) do {\ | |
| (var) = check_strscan(obj);\ | |
| if (NIL_P((var)->str)) rb_raise(rb_eArgError, "uninitialized StringScanner object");\ | |
| } while (0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,
I see.
…ed capture groups Fix rubyGH-135
56368c2 to
38ef27a
Compare
|
Thanks. |
don't clear named capture groups (ruby/strscan#142) Fix ruby/strscan#135 ruby/strscan@b957443e20
don't clear named capture groups (ruby/strscan#142) Fix ruby/strscan#135 ruby/strscan@b957443e20
Fix GH-135