Skip to content

Conversation

@naitoh
Copy link
Contributor

@naitoh naitoh commented Feb 22, 2025

Fix GH-135

@naitoh naitoh force-pushed the clear_named_captures branch 2 times, most recently from 2b814b2 to 56368c2 Compare February 22, 2025 10:01
@naitoh naitoh requested a review from kou February 22, 2025 10:08
end

def test_string
omit("not implemented on TruffleRuby") if ["truffleruby"].include?(RUBY_ENGINE)
Copy link
Member

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?

Suggested change
omit("not implemented on TruffleRuby") if ["truffleruby"].include?(RUBY_ENGINE)
omit("not implemented on TruffleRuby") if RUBY_ENGINE == "truffleruby"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

#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)
Copy link
Member

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:

#define GET_SCANNER(obj,var) do {\
(var) = check_strscan(obj);\
if (NIL_P((var)->str)) rb_raise(rb_eArgError, "uninitialized StringScanner object");\
} while (0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK,
I see.

@naitoh naitoh force-pushed the clear_named_captures branch from 56368c2 to 38ef27a Compare February 22, 2025 22:10
@naitoh naitoh requested a review from kou February 22, 2025 22:18
@kou kou merged commit b957443 into ruby:master Feb 23, 2025
40 checks passed
@kou
Copy link
Member

kou commented Feb 23, 2025

Thanks.

@naitoh naitoh deleted the clear_named_captures branch February 23, 2025 02:14
hsbt pushed a commit to hsbt/ruby that referenced this pull request Feb 25, 2025
hsbt pushed a commit to ruby/ruby that referenced this pull request Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scanning methods that don't use Regexp don't clear named capture groups

2 participants