mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
ext/standard: Let is_numeric_str parse the int value for us in getopt()
This commit is contained in:
parent
f3655100b8
commit
72ff9077a5
1 changed files with 4 additions and 4 deletions
|
@ -1071,16 +1071,16 @@ PHP_FUNCTION(getopt)
|
|||
|
||||
/* Add this option / argument pair to the result hash. */
|
||||
optname_len = strlen(optname);
|
||||
if (!(optname_len > 1 && optname[0] == '0') && is_numeric_string(optname, optname_len, NULL, NULL, 0) == IS_LONG) {
|
||||
zend_long opt_name_as_long = 0;
|
||||
if (!(optname_len > 1 && optname[0] == '0') && is_numeric_string(optname, optname_len, &opt_name_as_long, NULL, 0) == IS_LONG) {
|
||||
/* numeric string */
|
||||
int optname_int = atoi(optname);
|
||||
if ((args = zend_hash_index_find(Z_ARRVAL_P(return_value), optname_int)) != NULL) {
|
||||
if ((args = zend_hash_index_find(Z_ARRVAL_P(return_value), opt_name_as_long)) != NULL) {
|
||||
if (Z_TYPE_P(args) != IS_ARRAY) {
|
||||
convert_to_array(args);
|
||||
}
|
||||
zend_hash_next_index_insert(Z_ARRVAL_P(args), &val);
|
||||
} else {
|
||||
zend_hash_index_update(Z_ARRVAL_P(return_value), optname_int, &val);
|
||||
zend_hash_index_update(Z_ARRVAL_P(return_value), opt_name_as_long, &val);
|
||||
}
|
||||
} else {
|
||||
/* other strings */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue