Implements an ANSI C compatible sscanf */
PHP_FUNCTION(sscanf)
{
- zval **format;
- zval **literal;
- int result;
- zval ***args;
- int argCount;
-
- argCount = ZEND_NUM_ARGS();
- if (argCount < 2) {
+ zval ***args;
+ int result;
+ int argc = ZEND_NUM_ARGS();
+
+ if (argc < 2) {
WRONG_PARAM_COUNT;
}
- args = (zval ***)emalloc(argCount * sizeof(zval **));
- if (!args || (zend_get_parameters_array_ex(argCount, args) == FAILURE)) {
- efree( args );
+
+ args = (zval ***) emalloc(argc * sizeof(zval **));
+ if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
+ efree(args);
WRONG_PARAM_COUNT;
}
-
- literal = args[0];
- format = args[1];
- convert_to_string_ex( format );
- convert_to_string_ex( literal );
+ convert_to_string_ex(args[0]);
+ convert_to_string_ex(args[1]);
- result = php_sscanf_internal( (*literal)->value.str.val,
- (*format)->value.str.val,
- argCount, args,
- 2, &return_value TSRMLS_CC);
+ result = php_sscanf_internal(Z_STRVAL_PP(args[0]),
+ Z_STRVAL_PP(args[1]),
+ argc, args,
+ 2, &return_value TSRMLS_CC);
efree(args);
if (SCAN_ERROR_WRONG_PARAM_COUNT == result) {
WRONG_PARAM_COUNT;
}
-
}
/* }}} */