Skip to content

Commit 50a41d4

Browse files
committed
ext/standard/scanf: add format_arg_num param
In preparation for better format parsing
1 parent a4cdd52 commit 50a41d4

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

ext/spl/spl_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2494,7 +2494,7 @@ PHP_METHOD(SplFileObject, fscanf)
24942494
RETURN_THROWS();
24952495
}
24962496

2497-
php_sscanf_internal(ZSTR_VAL(intern->u.file.current_line), format_str, num_varargs, varargs, return_value);
2497+
php_sscanf_internal(ZSTR_VAL(intern->u.file.current_line), format_str, 1, num_varargs, varargs, return_value);
24982498
}
24992499
/* }}} */
25002500

ext/standard/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ PHP_FUNCTION(fscanf)
956956
RETURN_FALSE;
957957
}
958958

959-
php_sscanf_internal(buf, format, argc, args, return_value);
959+
php_sscanf_internal(buf, format, 2, argc, args, return_value);
960960

961961
efree(buf);
962962
}

ext/standard/scanf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static void ReleaseCharSet(CharSet *cset)
299299
*
300300
*----------------------------------------------------------------------
301301
*/
302-
static int ValidateFormat(const zend_string *zstr_format, uint32_t numVars, uint32_t *totalSubs)
302+
static int ValidateFormat(const zend_string *zstr_format, uint32_t format_arg_num, uint32_t numVars, uint32_t *totalSubs)
303303
{
304304
#define STATIC_LIST_SIZE 16
305305
int flags;
@@ -571,7 +571,7 @@ static int ValidateFormat(const zend_string *zstr_format, uint32_t numVars, uint
571571
* return_value set with the results of the scan
572572
*/
573573

574-
PHPAPI int php_sscanf_internal(const char *string, const zend_string *zstr_format,
574+
PHPAPI int php_sscanf_internal(const char *string, const zend_string *zstr_format, uint32_t format_arg_num,
575575
uint32_t argCount, zval *args,
576576
zval *return_value)
577577
{
@@ -602,7 +602,7 @@ PHPAPI int php_sscanf_internal(const char *string, const zend_string *zstr_forma
602602
* Check for errors in the format string.
603603
*/
604604
uint32_t totalVars = 0;
605-
if (ValidateFormat(zstr_format, numVars, &totalVars) != SCAN_SUCCESS) {
605+
if (ValidateFormat(zstr_format, format_arg_num, numVars, &totalVars) != SCAN_SUCCESS) {
606606
scan_set_error_return( assignToVariables, return_value );
607607
return SCAN_ERROR_INVALID_FORMAT;
608608
}

ext/standard/scanf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* The following are here solely for the benefit of the scanf type functions
3434
* e.g. fscanf
3535
*/
36-
PHPAPI int php_sscanf_internal(const char *string, const zend_string *format, uint32_t argCount, zval *args,
36+
PHPAPI int php_sscanf_internal(const char *string, const zend_string *format, uint32_t format_arg_num, uint32_t argCount, zval *args,
3737
zval *return_value);
3838

3939

ext/standard/string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5871,7 +5871,7 @@ PHP_FUNCTION(sscanf)
58715871
Z_PARAM_VARIADIC('*', args, num_args)
58725872
ZEND_PARSE_PARAMETERS_END();
58735873

5874-
php_sscanf_internal(str, format, num_args, args, return_value);
5874+
php_sscanf_internal(str, format, 2, num_args, args, return_value);
58755875

58765876
}
58775877
/* }}} */

0 commit comments

Comments
 (0)