andrei Wed Oct 1 17:24:20 2003 EDT
Modified files: (Branch: PHP_4_3)
/php-src/main main.c
Log:
@- Made $argc and $argv always available as globals in CLI. No more
@ silliness. (Andrei)
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.512.2.47 php-src/main/main.c:1.512.2.48
--- php-src/main/main.c:1.512.2.47 Wed Sep 24 19:22:32 2003
+++ php-src/main/main.c Wed Oct 1 17:24:19 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.512.2.47 2003/09/24 23:22:32 iliaa Exp $ */
+/* $Id: main.c,v 1.512.2.48 2003/10/01 21:24:19 andrei Exp $ */
/* {{{ includes
*/
@@ -1316,11 +1316,6 @@
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 @@
}
}
+ /* argv/argc support */
+ if (PG(register_argc_argv)) {
+ php_build_argv(SG(request_info).query_string TSRMLS_CC);
+ }
+
for (i=0; i<NUM_TRACK_VARS; i++) {
if (!PG(http_globals)[i]) {
if (!initialized_dummy_track_vars_array) {
@@ -1549,10 +1549,15 @@
pval *arr, *argc, *tmp;
int count = 0;
char *ss, *space;
+
+ if (! (PG(register_globals) || SG(request_info).argc ||
+ PG(http_globals)[TRACK_VARS_SERVER]) ) {
+ return;
+ }
ALLOC_ZVAL(arr);
array_init(arr);
- INIT_PZVAL(arr);
+ arr->is_ref = 0;
/* Prepare argv */
if (SG(request_info).argc) { /* are we in cli sapi? */
@@ -1605,7 +1610,7 @@
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 @@
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);
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php