Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ PHP 8.7 UPGRADE NOTES
. The number of filters that can be chained in a php://filter URL is limited
to 16 by default. Set the stream context option max_filter_count to change
this.
. sscanf() and fscanf() %c conversions now correctly read whitespace
characters, restoring ANSI C behavior. Previously, they stopped at
whitespace.

========================================
2. New Features
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/scanf.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
break;

case 'c':
op = 's';
op = 'c';
flags |= SCAN_NOSKIP;
/*-cc-*/
if (0 == width) {
Expand Down Expand Up @@ -833,7 +833,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
end = string;
while (*end != '\0') {
sch = *end;
if ( isspace( (unsigned char)sch ) ) {
if (op == 's' && isspace( (unsigned char)sch ) ) {
break;
}
end++;
Expand Down
72 changes: 48 additions & 24 deletions ext/standard/tests/file/fscanf_variation20.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -710,15 +710,18 @@ bool(false)
-- iteration 10 --
array(1) {
[0]=>
string(1) "0"
string(2) "0
"
}
array(1) {
[0]=>
string(1) "1"
string(2) "1
"
}
array(1) {
[0]=>
string(2) "-1"
string(3) "-1
"
}
array(1) {
[0]=>
Expand Down Expand Up @@ -750,7 +753,8 @@ array(1) {
}
array(1) {
[0]=>
string(3) "250"
string(4) "250
"
}
array(1) {
[0]=>
Expand All @@ -766,11 +770,13 @@ array(1) {
}
array(1) {
[0]=>
string(2) "83"
string(3) "83
"
}
array(1) {
[0]=>
string(1) "1"
string(2) "1
"
}
array(1) {
[0]=>
Expand All @@ -785,75 +791,93 @@ bool(false)
-- iteration 11 --
array(1) {
[0]=>
string(1) "0"
string(2) "0
"
}
array(1) {
[0]=>
string(1) "1"
string(2) "1
"
}
array(1) {
[0]=>
string(2) "-1"
string(3) "-1
"
}
array(1) {
[0]=>
string(11) "-2147483648"
string(12) "-2147483648
"
}
array(1) {
[0]=>
string(11) "-2147483647"
string(12) "-2147483647
"
}
array(1) {
[0]=>
string(10) "2147483647"
string(11) "2147483647
"
}
array(1) {
[0]=>
string(10) "2147483640"
string(11) "2147483640
"
}
array(1) {
[0]=>
string(4) "4667"
string(5) "4667
"
}
array(1) {
[0]=>
string(4) "4779"
string(5) "4779
"
}
array(1) {
[0]=>
string(4) "4095"
string(5) "4095
"
}
array(1) {
[0]=>
string(3) "250"
string(4) "250
"
}
array(1) {
[0]=>
string(11) "-2147483648"
string(12) "-2147483648
"
}
array(1) {
[0]=>
string(10) "2147483647"
string(11) "2147483647
"
}
array(1) {
[0]=>
string(10) "2147483647"
string(11) "2147483647
"
}
array(1) {
[0]=>
string(2) "83"
string(3) "83
"
}
array(1) {
[0]=>
string(1) "1"
string(2) "1
"
}
array(1) {
[0]=>
string(11) "-2147483648"
string(12) "-2147483648
"
}
array(1) {
[0]=>
string(10) "2147483647"
string(11) "2147483647
"
}
bool(false)

Expand Down
54 changes: 36 additions & 18 deletions ext/standard/tests/file/fscanf_variation21.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -633,15 +633,17 @@ array(1) {
}
array(1) {
[0]=>
string(1) "0"
string(2) "0
"
}
array(1) {
[0]=>
string(4) "-0.1"
}
array(1) {
[0]=>
string(1) "1"
string(2) "1
"
}
array(1) {
[0]=>
Expand All @@ -661,7 +663,8 @@ array(1) {
}
array(1) {
[0]=>
string(2) "10"
string(3) "10
"
}
array(1) {
[0]=>
Expand All @@ -672,63 +675,78 @@ bool(false)
-- iteration 11 --
array(1) {
[0]=>
string(11) "-2147483649"
string(12) "-2147483649
"
}
array(1) {
[0]=>
string(10) "2147483648"
string(11) "2147483648
"
}
array(1) {
[0]=>
string(11) "-2147483649"
string(12) "-2147483649
"
}
array(1) {
[0]=>
string(11) "34359738369"
string(12) "34359738369
"
}
array(1) {
[0]=>
string(10) "2147483649"
string(11) "2147483649
"
}
array(1) {
[0]=>
string(11) "-2147483649"
string(12) "-2147483649
"
}
array(1) {
[0]=>
string(1) "0"
string(2) "0
"
}
array(1) {
[0]=>
string(4) "-0.1"
string(5) "-0.1
"
}
array(1) {
[0]=>
string(1) "1"
string(2) "1
"
}
array(1) {
[0]=>
string(6) "100000"
string(7) "100000
"
}
array(1) {
[0]=>
string(8) "-1000000"
string(9) "-1000000
"
}
array(1) {
[0]=>
string(9) "100000000"
string(10) "100000000
"
}
array(1) {
[0]=>
string(11) "-1000000000"
string(12) "-1000000000
"
}
array(1) {
[0]=>
string(2) "10"
string(3) "10
"
}
array(1) {
[0]=>
string(7) "1050000"
string(8) "1050000
"
}
bool(false)

Expand Down
8 changes: 5 additions & 3 deletions ext/standard/tests/file/fscanf_variation22.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ $file_path = __DIR__;
$filename = "$file_path/fscanf_variation22.tmp";
unlink($filename);
?>
--EXPECT--
--EXPECTF--
*** Test fscanf(): different char format types with resource ***

-- iteration 1 --
Expand Down Expand Up @@ -186,11 +186,13 @@ bool(false)
-- iteration 11 --
array(1) {
[0]=>
string(8) "Resource"
string(%d) "Resource id #%d
"
}
array(1) {
[0]=>
string(8) "Resource"
string(%d) "Resource id #%d
"
}
bool(false)

Expand Down
Loading
Loading