From: Andrei Zmievski Date: Wed, 1 Oct 2003 21:24:19 +0000 (+0000) Subject: @- Made $argc and $argv always available as globals in CLI. No more X-Git-Tag: php-4.3.4RC2~86 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d59c975a07b477857b29920be803b116b4872fb;p=php @- Made $argc and $argv always available as globals in CLI. No more @ silliness. (Andrei) --- diff --git a/main/main.c b/main/main.c index 92170395ea..9439a3dcdf 100644 --- a/main/main.c +++ b/main/main.c @@ -1316,11 +1316,6 @@ static inline void php_register_server_variables(TSRMLS_D) sapi_module.register_server_variables(array_ptr TSRMLS_CC); } - /* argv/argc support */ - if (PG(register_argc_argv)) { - php_build_argv(SG(request_info).query_string TSRMLS_CC); - } - /* PHP Authentication support */ if (SG(request_info).auth_user) { php_register_variable("PHP_AUTH_USER", SG(request_info).auth_user, array_ptr TSRMLS_CC); @@ -1482,6 +1477,11 @@ static int php_hash_environment(TSRMLS_D) } } + /* argv/argc support */ + if (PG(register_argc_argv)) { + php_build_argv(SG(request_info).query_string TSRMLS_CC); + } + for (i=0; iis_ref = 0; /* Prepare argv */ if (SG(request_info).argc) { /* are we in cli sapi? */ @@ -1605,7 +1610,7 @@ static void php_build_argv(char *s TSRMLS_DC) Z_LVAL_P(argc) = count; } Z_TYPE_P(argc) = IS_LONG; - INIT_PZVAL(argc); + argc->is_ref = 0; if (PG(register_globals) || SG(request_info).argc) { arr->refcount++; @@ -1614,7 +1619,9 @@ static void php_build_argv(char *s TSRMLS_DC) zend_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL); } - if ( PG(http_globals)[TRACK_VARS_SERVER] != NULL ) { + if (PG(http_globals)[TRACK_VARS_SERVER] != NULL) { + arr->refcount++; + argc->refcount++; zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), &arr, sizeof(pval *), NULL); zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argc", sizeof("argc"), &argc, sizeof(pval *), NULL); }