Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
570c2eb
ext/standard: Delete fscanf test cases that write arrays to file via …
Girgias Dec 11, 2025
a7dff9c
ext/standard: Delete fscanf test cases that write resources to file v…
Girgias Dec 11, 2025
ec67bbd
ext/standard: Delete fscanf test cases that write objects to file via…
Girgias Dec 11, 2025
e0378f6
ext/standard: Delete fscanf test cases that write bools to file via f…
Girgias Dec 11, 2025
2f13db4
ext/standard: Remove invalid specifier tests for fscanf
Girgias Dec 11, 2025
3889123
ext/standard: Move fscanf tests to subfolder
Girgias Dec 11, 2025
58d7495
ext/standard: Refactor fscanf test using strings
Girgias Dec 11, 2025
a1e9a9a
ext/standard: Move sscanf tests to subfolder
Girgias Dec 9, 2025
6c16086
ext/standard: Add some sscanf tests
Girgias Dec 9, 2025
d80fff2
ext/standard/scanf.h: use 0 instead of SUCCESS to define scan success…
Girgias Dec 4, 2025
878fb75
ext/standard/scanf: drop checking of php_sscanf_internal as it always…
Girgias Dec 4, 2025
86a447d
ext/standard/scanf: use uint32_t type instead of int for argCount arg…
Girgias Dec 4, 2025
2e5d64a
ext/standard/scanf: use zend_ulong type instead of int for objIndex v…
Girgias Dec 4, 2025
acf692c
ext/standard/scanf: make ValidateFormat function private
Girgias Dec 4, 2025
41d4456
ext/standard/scanf: remove varStart parameter which is always 0
Girgias Dec 4, 2025
45ba2fb
ext/standard/scanf: add assignToVariables variable and parameter
Girgias Dec 4, 2025
fe61460
ext/standard/scanf: use type uint32_t instead of int for totalSubs pa…
Girgias Dec 4, 2025
a431568
ext/standard/scanf: use type bool instead of int for variables in Val…
Girgias Dec 5, 2025
9003847
ext/standard/scanf: use type uint32_t instead of int for variables in…
Girgias Dec 4, 2025
57025bd
ext/standard/scanf: use memset to initialize array of 0s
Girgias Dec 4, 2025
6772c8f
ext/standard/scanf: remove unused includes
Girgias Dec 5, 2025
8eea8e6
ext/standard/scanf: refactor CharInSet()
Girgias Dec 5, 2025
9209efd
ext/standard/scanf: add const qualifiers in BuildCharSet() and Valida…
Girgias Dec 5, 2025
b75745f
unsigned vars
Girgias Dec 5, 2025
a9a9401
ext/standard/scanf: add const qualifiers for format param
Girgias Dec 5, 2025
89ac4f5
ext/standard/scanf: add const qualifiers for string param
Girgias Dec 5, 2025
a4cdd52
ext/standard/scanf: convert format param to zend_string
Girgias Dec 5, 2025
50a41d4
ext/standard/scanf: add format_arg_num param
Girgias Dec 5, 2025
3182b2e
Refactor string format parsing
Girgias Dec 7, 2025
4730501
ext/standard: pass string length
Girgias Dec 10, 2025
ab81474
ext/standard/scanf.c: Refactor parsing and scanning
Girgias Dec 11, 2025
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
7 changes: 1 addition & 6 deletions ext/spl/spl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2494,12 +2494,7 @@ PHP_METHOD(SplFileObject, fscanf)
RETURN_THROWS();
}

int result = php_sscanf_internal(ZSTR_VAL(intern->u.file.current_line), ZSTR_VAL(format_str), (int)num_varargs, varargs, 0, return_value);

if (SCAN_ERROR_WRONG_PARAM_COUNT == result) {
zend_wrong_param_count();
RETURN_THROWS();
}
php_sscanf_internal(ZSTR_VAL(intern->u.file.current_line), ZSTR_LEN(intern->u.file.current_line), format_str, 1, num_varargs, varargs, return_value);
}
/* }}} */

Expand Down
15 changes: 5 additions & 10 deletions ext/standard/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,17 +928,17 @@ PHPAPI PHP_FUNCTION(fgetc)
/* {{{ Implements a mostly ANSI compatible fscanf() */
PHP_FUNCTION(fscanf)
{
int result, argc = 0;
size_t format_len;
uint32_t argc = 0;
zval *args = NULL;
zval *file_handle;
char *buf, *format;
char *buf;
zend_string *format;
size_t len;
void *what;

ZEND_PARSE_PARAMETERS_START(2, -1)
Z_PARAM_RESOURCE(file_handle)
Z_PARAM_STRING(format, format_len)
Z_PARAM_STR(format)
Z_PARAM_VARIADIC('*', args, argc)
ZEND_PARSE_PARAMETERS_END();

Expand All @@ -956,14 +956,9 @@ PHP_FUNCTION(fscanf)
RETURN_FALSE;
}

result = php_sscanf_internal(buf, format, argc, args, 0, return_value);
php_sscanf_internal(buf, len, format, 2, argc, args, return_value);

efree(buf);

if (SCAN_ERROR_WRONG_PARAM_COUNT == result) {
zend_wrong_param_count();
RETURN_THROWS();
}
}
/* }}} */

Expand Down
Loading
Loading