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

Allow ',' at the start of OCAMLRUNPARAM #9634

Merged
merged 3 commits into from Jun 5, 2020

Conversation

nojb
Copy link
Contributor

@nojb nojb commented Jun 4, 2020

Currently the idiom OCAMLRUNPARAM=$OCAMLRUNPARAM,b=1 doesn't work if $OCAMLRUNPARAM is empty, as the OCAMLRUNPARAM parsing code is not able to handle the initial comma. This PR makes it so that any number of initial commas, or repeated commas in general are skipped over.

@@ -135,6 +135,7 @@ void caml_parse_ocamlrunparam(void)
case 'v': scanmult (opt, &caml_verb_gc); break;
case 'w': scanmult (opt, &caml_init_major_window); break;
case 'W': scanmult (opt, &caml_runtime_warnings); break;
case ',': continue;
}
while (*opt != '\0'){
if (*opt++ == ',') break;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this while loop anymore, then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, if I understand correctly, the scanmult call does not update opt, so we still need to skip over the =... part read by it before going on to the next item (which is what the while loop is doing).

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I had misunderstood indeed. I thought that we were only skipping commas here.

Copy link
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

Approved. This seems minor but I think it could benefit from a Changes entry, in case users have been bitten by this issue before.

@nojb justifies skipping the first comma with the idiom FOO=$FOO,bar, but note that skipping middle commas (also implemented) is also useful to allow the idiom FOO=$FOO1,$FOO2,$FOO3.

@gasche
Copy link
Member

gasche commented Jun 4, 2020

(Is there no test for OCAMLRUNPARAM parsing in the testsuite?)

@nojb
Copy link
Contributor Author

nojb commented Jun 4, 2020

(Is there no test for OCAMLRUNPARAM parsing in the testsuite?)

Well, the code would have been exercised by the tests in #9633, but they were broken :) Am not aware of any other test using OCAMLRUNPARAM apart from those.

@shindere
Copy link
Contributor

shindere commented Jun 4, 2020

This is nice! Thanks!

Perhaps the documentation should be updated, too?

I'd definitely put everything in only one commmit.

@nojb
Copy link
Contributor Author

nojb commented Jun 4, 2020

Manual updated.

@gasche gasche merged commit a8a2a7b into ocaml:trunk Jun 5, 2020
@gasche
Copy link
Member

gasche commented Jun 5, 2020

Merged.

@nojb nojb deleted the ocamlrunparam_comma_fix branch June 5, 2020 05:39
@nojb
Copy link
Contributor Author

nojb commented Jun 5, 2020

Thanks!

@shindere
Copy link
Contributor

shindere commented Jun 5, 2020 via email

@shindere
Copy link
Contributor

shindere commented Jun 5, 2020 via email

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

3 participants