diff options
Diffstat (limited to 'main/php_variables.c')
-rw-r--r-- | main/php_variables.c | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/main/php_variables.c b/main/php_variables.c index 1a40c2a19f..89b3dbf2d6 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -1,7 +1,5 @@ /* +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | @@ -27,21 +25,18 @@ #include "php_content_types.h" #include "SAPI.h" #include "zend_globals.h" -#ifdef PHP_WIN32 -# include "win32/php_inttypes.h" -#endif /* for systems that need to override reading of environment variables */ void _php_import_environment_variables(zval *array_ptr); PHPAPI void (*php_import_environment_variables)(zval *array_ptr) = _php_import_environment_variables; -PHPAPI void php_register_variable(char *var, char *strval, zval *track_vars_array) +PHPAPI void php_register_variable(const char *var, const char *strval, zval *track_vars_array) { php_register_variable_safe(var, strval, strlen(strval), track_vars_array); } /* binary-safe version */ -PHPAPI void php_register_variable_safe(char *var, char *strval, size_t str_len, zval *track_vars_array) +PHPAPI void php_register_variable_safe(const char *var, const char *strval, size_t str_len, zval *track_vars_array) { zval new_entry; assert(strval != NULL); @@ -65,7 +60,7 @@ static zend_always_inline void php_register_variable_quick(const char *name, siz zend_string_release_ex(key, 0); } -PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars_array) +PHPAPI void php_register_variable_ex(const char *var_name, zval *val, zval *track_vars_array) { char *p = NULL; char *ip = NULL; /* index pointer */ @@ -573,21 +568,15 @@ static zend_always_inline void import_environment_variable(HashTable *ht, char * void _php_import_environment_variables(zval *array_ptr) { -#ifndef PHP_WIN32 - char **env; -#else - char *environment, *env; -#endif - tsrm_env_lock(); #ifndef PHP_WIN32 - for (env = environ; env != NULL && *env != NULL; env++) { + for (char **env = environ; env != NULL && *env != NULL; env++) { import_environment_variable(Z_ARRVAL_P(array_ptr), *env); } #else - environment = GetEnvironmentStringsA(); - for (env = environment; env != NULL && *env; env += strlen(env) + 1) { + char *environment = GetEnvironmentStringsA(); + for (char *env = environment; env != NULL && *env; env += strlen(env) + 1) { import_environment_variable(Z_ARRVAL_P(array_ptr), env); } FreeEnvironmentStringsA(environment); @@ -604,11 +593,10 @@ zend_bool php_std_auto_global_callback(char *name, uint32_t name_len) /* {{{ php_build_argv */ -PHPAPI void php_build_argv(char *s, zval *track_vars_array) +PHPAPI void php_build_argv(const char *s, zval *track_vars_array) { zval arr, argc, tmp; int count = 0; - char *ss, *space; if (!(SG(request_info).argc || track_vars_array)) { return; @@ -626,24 +614,18 @@ PHPAPI void php_build_argv(char *s, zval *track_vars_array) } } } else if (s && *s) { - ss = s; - while (ss) { - space = strchr(ss, '+'); - if (space) { - *space = '\0'; - } + while (1) { + const char *space = strchr(s, '+'); /* auto-type */ - ZVAL_STRING(&tmp, ss); + ZVAL_STRINGL(&tmp, s, space ? space - s : strlen(s)); count++; if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) { zend_string_efree(Z_STR(tmp)); } - if (space) { - *space = '+'; - ss = space + 1; - } else { - ss = space; + if (!space) { + break; } + s = space + 1; } } |