Skip to content
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

Implement StringIO#pread #56

Merged
merged 1 commit into from
Jun 8, 2023
Merged

Implement StringIO#pread #56

merged 1 commit into from
Jun 8, 2023

Conversation

casperisfine
Copy link
Contributor

Both for being closer to real IOs and also because it's a convenient API in multithreaded scenarios.

cc @kddnewton @nobu

long offset = NUM2LONG(rb_offset);

if (len < 0) {
rb_raise(rb_eArgError, "negative string size (or size too big)");
Copy link
Member

Choose a reason for hiding this comment

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

Could you add rb_len to error message?

}

if (offset < 0) {
rb_exc_raise(rb_syserr_new(EINVAL, "pread: Invalid offset argument"));
Copy link
Member

Choose a reason for hiding this comment

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

Could you add rb_offset to error message?

ext/stringio/stringio.c Outdated Show resolved Hide resolved
@casperisfine
Copy link
Contributor Author

@kou I applied your suggestions.

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

We need a review for JRuby part from @headius before we merge this.

ext/stringio/stringio.c Outdated Show resolved Hide resolved
ext/stringio/stringio.c Outdated Show resolved Hide resolved
Both for being closer to real IOs and also because it's a convenient
API in multithreaded scenarios.
@casperisfine
Copy link
Contributor Author

@kou done.

We need a review for JRuby part

No problem. Note that there are pre-existing failures on the JRuby suite, but the added test does pass on JRuby.

Copy link
Contributor

@headius headius left a comment

Choose a reason for hiding this comment

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

JRuby part looks fine. I can do a small optimization (split out separate arities) once this is merged.

@kou kou merged commit 2b5e2a5 into ruby:master Jun 8, 2023
@kou
Copy link
Member

kou commented Jun 8, 2023

OK.
I've merged this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants