mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
Converted getenv to use zend_parse_parameters
This commit is contained in:
parent
427019cc76
commit
2f6ffb545e
1 changed files with 6 additions and 12 deletions
|
@ -1178,21 +1178,15 @@ PHP_FUNCTION(long2ip)
|
||||||
Get the value of an environment variable */
|
Get the value of an environment variable */
|
||||||
PHP_FUNCTION(getenv)
|
PHP_FUNCTION(getenv)
|
||||||
{
|
{
|
||||||
pval **str;
|
char *ptr, *str;
|
||||||
char *ptr;
|
int str_len;
|
||||||
|
|
||||||
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
|
||||||
WRONG_PARAM_COUNT;
|
|
||||||
}
|
|
||||||
convert_to_string_ex(str);
|
|
||||||
|
|
||||||
if (Z_TYPE_PP(str) != IS_STRING) {
|
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
ptr = sapi_getenv(str, str_len TSRMLS_CC);
|
||||||
ptr = sapi_getenv(Z_STRVAL_PP(str), Z_STRLEN_PP(str) TSRMLS_CC);
|
if (! ptr) {
|
||||||
if (!ptr) {
|
ptr = getenv(str);
|
||||||
ptr = getenv(Z_STRVAL_PP(str));
|
|
||||||
}
|
}
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
RETURN_STRING(ptr, 1);
|
RETURN_STRING(ptr, 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue