mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
strtok warns in case the string to split was not set.
Close GH-10016.
This commit is contained in:
parent
7936c8085e
commit
256a34ed15
7 changed files with 94 additions and 5 deletions
2
NEWS
2
NEWS
|
@ -99,6 +99,8 @@ PHP NEWS
|
|||
- Standard:
|
||||
. E_NOTICEs emitted by unserialize() have been promoted to E_WARNING. (timwolla)
|
||||
. Make array_pad's $length warning less confusing. (nielsdos)
|
||||
. E_WARNING emitted by strtok in the caase both arguments are not provided when
|
||||
starting tokenisation. (David Carlier)
|
||||
|
||||
- Streams:
|
||||
. Fixed bug #51056: blocking fread() will block even if data is available.
|
||||
|
|
|
@ -68,6 +68,7 @@ PHP 8.3 UPGRADE NOTES
|
|||
. array_pad() is now only limited by the maximum number of elements an array
|
||||
can have. Before, it was only possible to add at most 1048576 elements at a
|
||||
time.
|
||||
. strtok() raises a warninin the case token is not provided when starting tokenization.
|
||||
|
||||
========================================
|
||||
6. New Functions
|
||||
|
|
|
@ -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, "Both arguments must be provided when starting tokenization");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ foreach($heredoc_strings as $string) {
|
|||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
*** Testing strtok() : with heredoc strings ***
|
||||
|
||||
--- Iteration 1 ---
|
||||
|
@ -80,15 +80,35 @@ bool(false)
|
|||
|
||||
--- Iteration 2 ---
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--- Iteration 3 ---
|
||||
|
@ -137,9 +157,19 @@ string(3) "rld"
|
|||
string(4) "hell"
|
||||
string(4) "hell"
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
Done
|
||||
|
|
|
@ -36,15 +36,25 @@ foreach( $strings_with_nulls as $string ) {
|
|||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
*** Testing strtok() : with embedded nulls in the strings ***
|
||||
|
||||
--- Iteration 1 ---
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--- Iteration 2 ---
|
||||
|
@ -82,9 +92,17 @@ bool(false)
|
|||
--- Iteration 6 ---
|
||||
string(11) "hello world"
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--- Iteration 7 ---
|
||||
|
|
|
@ -52,7 +52,7 @@ foreach( $string_array as $string ) {
|
|||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
*** Testing strtok() : with miscellaneous inputs ***
|
||||
|
||||
--- Iteration 1 ---
|
||||
|
@ -65,10 +65,20 @@ bool(false)
|
|||
|
||||
--- Iteration 2 ---
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--- Iteration 3 ---
|
||||
|
@ -113,18 +123,38 @@ bool(false)
|
|||
|
||||
--- Iteration 8 ---
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--- Iteration 9 ---
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
--- Iteration 10 ---
|
||||
|
|
|
@ -42,7 +42,7 @@ foreach( $string_array as $string ) {
|
|||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
*** Testing strtok() : with invalid escape sequences in token ***
|
||||
|
||||
--- Iteration 1 ---
|
||||
|
@ -69,6 +69,8 @@ bool(false)
|
|||
string(1) " "
|
||||
string(1) "r"
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
|
||||
|
@ -91,11 +93,15 @@ bool(false)
|
|||
string(5) "hello"
|
||||
string(6) " world"
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
string(1) " "
|
||||
string(1) "r"
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
|
||||
|
@ -113,6 +119,8 @@ bool(false)
|
|||
string(6) "hello\"
|
||||
string(6) " world"
|
||||
bool(false)
|
||||
|
||||
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||
bool(false)
|
||||
|
||||
string(1) "/"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue