-
Notifications
You must be signed in to change notification settings - Fork 7.9k
strtok warns in case the string to split was not set. #10016
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
Conversation
e6f0172
to
10bc698
Compare
|
It s likely more confusing for pure php devs I think, just trying to clarify a bit the "quirks" behind :) |
ext/standard/string.c
Outdated
@@ -1080,7 +1080,7 @@ PHP_FUNCTION(strtok) | |||
|
|||
if (!BG(strtok_string)) { | |||
/* String to tokenize not set. */ | |||
// TODO: Should this warn? | |||
php_error_docref(NULL, E_WARNING, "First call must set the string argument to tokenize with `%s`", ZSTR_VAL(tok)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with either error messages... as long as no string user input is exposed (ZSTR_VAL(tok)
). :)
Just my 2c:
Both arguments must be provided when calling strtok() the first time
I'm really not sure which version is the best :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the "first time" isn't really appropriate because the parameter must be provided whenever there is a new tokenization starting, so: Both arguments must be provided when starting tokenization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oky doky.
10bc698
to
e14cfbc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine for me! Feel free to merge If @cmb69 is also satisfied with the error message :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like this error message! Thank you!
No description provided.