From: Andrei Zmievski Date: Fri, 19 Oct 2001 19:21:58 +0000 (+0000) Subject: Converting to use new parameter parsing API. X-Git-Tag: POST_PARAMETER_PARSING_API~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ed249ddbc15ab33d67ea8ac2650c9347be0d803;p=php Converting to use new parameter parsing API. --- diff --git a/ext/standard/levenshtein.c b/ext/standard/levenshtein.c index 129044128c..984b37044e 100644 --- a/ext/standard/levenshtein.c +++ b/ext/standard/levenshtein.c @@ -102,8 +102,7 @@ PHP_FUNCTION(levenshtein) convert_to_string_ex(str2); distance = reference_levdist(Z_STRVAL_PP(str1), Z_STRLEN_PP(str1), - Z_STRVAL_PP(str2), Z_STRLEN_PP(str2), - 1, 1, 1); + Z_STRVAL_PP(str2), Z_STRLEN_PP(str2), 1, 1, 1); break; @@ -117,12 +116,10 @@ PHP_FUNCTION(levenshtein) convert_to_long_ex(cost_rep); convert_to_long_ex(cost_del); - distance = reference_levdist(Z_STRVAL_PP(str1), Z_STRLEN_PP(str1), - Z_STRVAL_PP(str2), Z_STRLEN_PP(str2), - Z_LVAL_PP(cost_ins), - Z_LVAL_PP(cost_rep), - Z_LVAL_PP(cost_del) - ); + distance = reference_levdist(Z_STRVAL_PP(str1), Z_STRLEN_PP(str1), + Z_STRVAL_PP(str2), Z_STRLEN_PP(str2), + Z_LVAL_PP(cost_ins), Z_LVAL_PP(cost_rep), + Z_LVAL_PP(cost_del)); break; @@ -134,10 +131,8 @@ PHP_FUNCTION(levenshtein) convert_to_string_ex(str2); convert_to_string_ex(callback_name); - distance = custom_levdist(Z_STRVAL_PP(str1) - , Z_STRVAL_PP(str2) - , Z_STRVAL_PP(callback_name) - ); + distance = custom_levdist(Z_STRVAL_PP(str1), Z_STRVAL_PP(str2), + Z_STRVAL_PP(callback_name)); break; default: diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c index 5d1648dfd2..d46a7464d2 100644 --- a/ext/standard/metaphone.c +++ b/ext/standard/metaphone.c @@ -33,20 +33,16 @@ PHP_FUNCTION(metaphone); Break english phrases down into their phonemes */ PHP_FUNCTION(metaphone) { - pval **pstr, **pphones; + char *str; char *result = 0; - int phones = 0; + int phones = 0, str_len; - if (zend_get_parameters_ex(2, &pstr, &pphones) == SUCCESS) { - convert_to_long_ex(pphones); - phones = Z_LVAL_PP(pphones); - } else if (zend_get_parameters_ex(1, &pstr) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len, + &phones) == FAILURE) { + return; } - convert_to_string_ex(pstr); - - if (metaphone(Z_STRVAL_PP(pstr), phones, &result, 1) == 0) { + if (metaphone(str, phones, &result, 1) == 0) { RETVAL_STRING(result, 0); } else { if (result) { diff --git a/ext/standard/soundex.c b/ext/standard/soundex.c index bea945117b..c827e9614c 100644 --- a/ext/standard/soundex.c +++ b/ext/standard/soundex.c @@ -28,9 +28,8 @@ Calculate the soundex key of a string */ PHP_FUNCTION(soundex) { - char *somestring; - int i, _small, len, code, last; - pval *arg, **parg; + char *str; + int i, _small, str_len, code, last; char soundex[4 + 1]; static char soundex_table[26] = @@ -61,25 +60,21 @@ PHP_FUNCTION(soundex) 0, /* Y */ '2'}; /* Z */ - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &parg) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) { + return; } - convert_to_string_ex(parg); - arg = *parg; - if (Z_STRLEN_P(arg)==0) { + if (str_len == 0) { RETURN_FALSE; } - somestring = Z_STRVAL_P(arg); - len = Z_STRLEN_P(arg); /* build soundex string */ last = -1; - for (i = 0, _small = 0; i < len && _small < 4; i++) { + for (i = 0, _small = 0; i < str_len && _small < 4; i++) { /* convert chars to upper case and strip non-letter chars */ /* BUG: should also map here accented letters used in non */ /* English words or names (also found in English text!): */ /* esstsett, thorn, n-tilde, c-cedilla, s-caron, ... */ - code = toupper(somestring[i]); + code = toupper(str[i]); if (code >= 'A' && code <= 'Z') { if (_small == 0) { /* remember first valid char */ @@ -106,9 +101,7 @@ PHP_FUNCTION(soundex) } soundex[_small] = '\0'; - Z_STRVAL_P(return_value) = estrndup(soundex, _small); - Z_STRLEN_P(return_value) = _small; - Z_TYPE_P(return_value) = IS_STRING; + RETURN_STRINGL(soundex, _small, 1); } /* }}} */