From a3c09d611caac49bd0b1322dc74c0b2fb94f0318 Mon Sep 17 00:00:00 2001 From: David Coallier Date: Sat, 19 Jan 2008 19:27:22 +0000 Subject: [PATCH] - MFH (lcfirst()) - Initial test for lcfirst --- ext/standard/basic_functions.c | 6 +++++ ext/standard/php_string.h | 1 + ext/standard/string.c | 30 ++++++++++++++++++++++++ ext/standard/tests/strings/lcfirst.phpt | Bin 0 -> 6877 bytes 4 files changed, 37 insertions(+) create mode 100644 ext/standard/tests/strings/lcfirst.phpt diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 2639070e558..46c073d7a4e 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -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) diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h index 6e95503e358..e74609d79bf 100644 --- a/ext/standard/php_string.h +++ b/ext/standard/php_string.h @@ -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); diff --git a/ext/standard/string.c b/ext/standard/string.c index 5b0d029d4fe..17ebd14f847 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -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) diff --git a/ext/standard/tests/strings/lcfirst.phpt b/ext/standard/tests/strings/lcfirst.phpt new file mode 100644 index 0000000000000000000000000000000000000000..4c5bec898dd5dbce9d6189a4850975c3887b5006 GIT binary patch literal 6877 zcmeHLZFAc;627nIuUONvMfog8vfVc~PTV%mBr}fFiJkW5>{LUMkj0uJ6@s*+W|H6D zX90qwA~I2D(z`F^OymIjf(O9j*#)}YtFz0iZr8FyZxkdlbvibUvdBw=II_Ck=NHc* zoF>8xBzjKzN9cU|{QL~P4RaYxg^shh;G}Glq2%SZsK~WNGO|5MdG-Jn^BJd^<(z;53nRhNA=RDKb&8l)r)K;YZ%O?Mu9pi^)B1P z<&fb+Te|@5n>5!H(sQSRqUIfw;VJITOR2D?jEUnO3Zqw~{$rvay zlZ37c%@rhPKZCQ_-Xr@lW*CAH$lh#i@9sJs{9M1ezP{c$-TJVJe$9#NXyk@c0BLCnf1s&>^U1uSC9gM)4CH2 zhRQKk1;cRF#tfh^5Od&`Mp=)_3$=>BlwGsyH&{yTd~H;>IjS#!CJ||tM3gTR1JLQSnBuD|rNJPLFBKcn#JvsXG!aP5K7pl1F$iHMk5wI|aclSLAXW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