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

join: extra check for empty string + empty sep #576

Merged
merged 2 commits into from Apr 9, 2017

Conversation

timo
Copy link
Member

@timo timo commented Apr 8, 2017

this could cause \r and \n to be kept as two graphemes
when they were joined with an empty string in between and
the empty string as the separator.

this could cause \r and \n to be kept as two graphemes
when they were joined with an empty string in between and
the empty string as the separator.
Copy link
Member

@samcv samcv left a comment

Choose a reason for hiding this comment

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

Just these two things.

@@ -1220,9 +1220,18 @@ MVMString * MVM_string_join(MVMThreadContext *tc, MVMString *separator, MVMObjec

/* Add separator if needed. */
if (i > 0) {
/* If there's no separator and one piece is The Empty String we
* have to be extra careful about concat stability */
if (sgraphs == 0 && MVM_string_graphs(tc, piece) == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

You can use MVM_string_graphs_nocheck here since MVM_string_graphs is already run on each piece in the loop above.

* have to be extra careful about concat stability */
if (sgraphs == 0 && MVM_string_graphs(tc, piece) == 0) {
if (!concats_stable)
;
Copy link
Member

Choose a reason for hiding this comment

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

What is this empty block for? I think it would be more clear if the if statement on L1225 checked concat_stable and the else if loop below become just a plain if loop

Copy link
Member

@samcv samcv left a comment

Choose a reason for hiding this comment

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

Great. Will merge after Travis 👍

@samcv samcv merged commit dcbaa74 into master Apr 9, 2017
@timo timo deleted the join_handle_empty_string_and_sep branch June 30, 2017 14:08
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.

None yet

2 participants