Skip to content

Expose rb_int_parse_cstr() as public API#16322

Closed
jinroq wants to merge 1 commit intoruby:masterfrom
jinroq:expose-rb_int_parse_cstr-public-api
Closed

Expose rb_int_parse_cstr() as public API#16322
jinroq wants to merge 1 commit intoruby:masterfrom
jinroq:expose-rb_int_parse_cstr-public-api

Conversation

@jinroq
Copy link
Copy Markdown
Contributor

@jinroq jinroq commented Mar 6, 2026

Move rb_int_parse_cstr() declaration and RB_INT_PARSE_* flags from internal/bignum.h to the public header include/ruby/internal/intern/bignum.h so that C extensions can use this function without writing their own prototype declarations.

The flags are changed from an enum to #define macros to follow the convention used in the public header for similar constants.

see: ruby/strscan#192

Move rb_int_parse_cstr() declaration and RB_INT_PARSE_* flags from
internal/bignum.h to the public header include/ruby/internal/intern/bignum.h
so that C extensions can use this function without writing their own
prototype declarations.

The flags are changed from an enum to #define macros to follow the
convention used in the public header for similar constants.
@jinroq
Copy link
Copy Markdown
Contributor Author

jinroq commented Mar 18, 2026

Due to a change in the specification of StringScanner#integer_at, there is no longer a need to expose rb_int_parse_cstr(). This PR will be closed.

see: ruby/strscan#193 (comment)

@jinroq jinroq closed this Mar 18, 2026
@nobu
Copy link
Copy Markdown
Member

nobu commented Mar 29, 2026

see: ruby/strscan#193 (comment)

I can't see that comment. What is that change?

And rb_str_to_inum(rb_str_new(ptr, len), base, 0) will be less efficient than rb_int_parse_cstr because it creates an intermediate string object.

@jinroq
Copy link
Copy Markdown
Contributor Author

jinroq commented Mar 31, 2026

@nobu

I can't see that comment. What is that change?

I'm sorry if it's hard to understand.

The specification for MatchData#integer_at has been defined here. StringScanner#integer_at follows this specification.

I just wanted to convey that it follows the same specifications as MatchData#integer_at.

And rb_str_to_inum(rb_str_new(ptr, len), base, 0) will be less efficient than rb_int_parse_cstr because it creates an intermediate string object.

StringScanner#integer_at implements fast pass. rb_str_to_inum(rb_str_new(ptr, len), base, 0) will be called if the input does not pass fast pass.

@jinroq
Copy link
Copy Markdown
Contributor Author

jinroq commented Mar 31, 2026

@nobu
BTW, should we reopen this PR?

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.

2 participants