Skip to content

Allow ',' at the start of OCAMLRUNPARAM#9634

Merged
gasche merged 3 commits intoocaml:trunkfrom
nojb:ocamlrunparam_comma_fix
Jun 5, 2020
Merged

Allow ',' at the start of OCAMLRUNPARAM#9634
gasche merged 3 commits intoocaml:trunkfrom
nojb:ocamlrunparam_comma_fix

Conversation

@nojb
Copy link
Copy Markdown
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.

case ',': continue;
}
while (*opt != '\0'){
if (*opt++ == ',') break;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

gasche commented Jun 4, 2020

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

@nojb
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

nojb commented Jun 4, 2020

Manual updated.

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

gasche commented Jun 5, 2020

Merged.

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

nojb commented Jun 5, 2020

Thanks!

@shindere
Copy link
Copy Markdown
Contributor

shindere commented Jun 5, 2020 via email

@shindere
Copy link
Copy Markdown
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.

3 participants