Skip to content

Commit 878fb75

Browse files
committed
ext/standard/scanf: drop checking of php_sscanf_internal as it always throws on error
1 parent d80fff2 commit 878fb75

File tree

4 files changed

+5
-20
lines changed

4 files changed

+5
-20
lines changed

ext/spl/spl_directory.c

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

2497-
int result = php_sscanf_internal(ZSTR_VAL(intern->u.file.current_line), ZSTR_VAL(format_str), (int)num_varargs, varargs, 0, return_value);
2498-
2499-
if (SCAN_ERROR_WRONG_PARAM_COUNT == result) {
2500-
zend_wrong_param_count();
2501-
RETURN_THROWS();
2502-
}
2497+
php_sscanf_internal(ZSTR_VAL(intern->u.file.current_line), ZSTR_VAL(format_str), (int)num_varargs, varargs, 0, return_value);
25032498
}
25042499
/* }}} */
25052500

ext/standard/file.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ PHPAPI PHP_FUNCTION(fgetc)
928928
/* {{{ Implements a mostly ANSI compatible fscanf() */
929929
PHP_FUNCTION(fscanf)
930930
{
931-
int result, argc = 0;
931+
int argc = 0;
932932
size_t format_len;
933933
zval *args = NULL;
934934
zval *file_handle;
@@ -956,14 +956,9 @@ PHP_FUNCTION(fscanf)
956956
RETURN_FALSE;
957957
}
958958

959-
result = php_sscanf_internal(buf, format, argc, args, 0, return_value);
959+
php_sscanf_internal(buf, format, argc, args, 0, return_value);
960960

961961
efree(buf);
962-
963-
if (SCAN_ERROR_WRONG_PARAM_COUNT == result) {
964-
zend_wrong_param_count();
965-
RETURN_THROWS();
966-
}
967962
}
968963
/* }}} */
969964

ext/standard/scanf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
/* can be caused by bad parameters or format*/
2929
/* string. */
3030
#define SCAN_ERROR_INVALID_FORMAT (SCAN_ERROR_EOF - 1)
31-
#define SCAN_ERROR_WRONG_PARAM_COUNT (SCAN_ERROR_INVALID_FORMAT - 1)
3231

3332
/*
3433
* The following are here solely for the benefit of the scanf type functions

ext/standard/string.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5862,20 +5862,16 @@ PHP_FUNCTION(sscanf)
58625862
zval *args = NULL;
58635863
char *str, *format;
58645864
size_t str_len, format_len;
5865-
int result, num_args = 0;
5865+
int num_args = 0;
58665866

58675867
ZEND_PARSE_PARAMETERS_START(2, -1)
58685868
Z_PARAM_STRING(str, str_len)
58695869
Z_PARAM_STRING(format, format_len)
58705870
Z_PARAM_VARIADIC('*', args, num_args)
58715871
ZEND_PARSE_PARAMETERS_END();
58725872

5873-
result = php_sscanf_internal(str, format, num_args, args, 0, return_value);
5873+
php_sscanf_internal(str, format, num_args, args, 0, return_value);
58745874

5875-
if (SCAN_ERROR_WRONG_PARAM_COUNT == result) {
5876-
zend_wrong_param_count();
5877-
RETURN_THROWS();
5878-
}
58795875
}
58805876
/* }}} */
58815877

0 commit comments

Comments
 (0)