- MFH (lcfirst())

- Initial test for lcfirst
This commit is contained in:
David Coallier 2008-01-19 19:27:22 +00:00
parent 89871ecc54
commit a3c09d611c
4 changed files with 37 additions and 0 deletions

View File

@ -2623,6 +2623,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_ucfirst, 0)
ZEND_ARG_INFO(0, str)
ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO(arginfo_lcfirst, 0)
ZEND_ARG_INFO(0, str)
ZEND_END_ARG_INFO()
static
ZEND_BEGIN_ARG_INFO(arginfo_ucwords, 0)
ZEND_ARG_INFO(0, str)
@ -3148,6 +3153,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */
PHP_FE(substr_replace, arginfo_substr_replace)
PHP_FE(quotemeta, arginfo_quotemeta)
PHP_FE(ucfirst, arginfo_ucfirst)
PHP_FE(lcfirst, arginfo_lcfirst)
PHP_FE(ucwords, arginfo_ucwords)
PHP_FE(strtr, arginfo_strtr)
PHP_FE(addslashes, arginfo_addslashes)

View File

@ -53,6 +53,7 @@ PHP_FUNCTION(strrchr);
PHP_FUNCTION(substr);
PHP_FUNCTION(quotemeta);
PHP_FUNCTION(ucfirst);
PHP_FUNCTION(lcfirst);
PHP_FUNCTION(ucwords);
PHP_FUNCTION(strtr);
PHP_FUNCTION(strrev);

View File

@ -2646,6 +2646,36 @@ PHP_FUNCTION(ucfirst)
}
/* }}} */
/* {{{
Lowercase the first character of the word in a native string */
static void php_lcfirst(char *str)
{
register char *r;
r = str;
*r = tolower((unsigned char) *r);
}
/* }}} */
/* {{{ proto string ucfirst(string str)
Make a string's first character lowercase */
PHP_FUNCTION(lcfirst)
{
char *str;
int str_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
return;
}
if (!str_len) {
RETURN_EMPTY_STRING();
}
ZVAL_STRINGL(return_value, str, str_len, 1);
php_lcfirst(Z_STRVAL_P(return_value));
}
/* }}} */
/* {{{ proto string ucwords(string str)
Uppercase the first character of every word in a string */
PHP_FUNCTION(ucwords)

Binary file not shown.