From 1433dec2d0c00fcda5bebaeebefca8264deb912a Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Thu, 12 Dec 2013 22:09:38 +0100 Subject: Kill another TSRMLS_FETCH() in zend_indent() --- sapi/cli/php_cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 9f3fc4b5b7..eec117ab1f 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -1024,7 +1024,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ /* Zeev might want to do something with this one day */ case PHP_MODE_INDENT: open_file_for_scanning(&file_handle TSRMLS_CC); - zend_indent(); + zend_indent(TSRMLS_C); zend_file_handle_dtor(file_handle.handle TSRMLS_CC); goto out; break; -- cgit v1.2.1 From bd58146ad664431464e42f654b58fc92270f3484 Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Wed, 18 Dec 2013 07:59:47 +0100 Subject: Kill another TSRMLS_FETCH() in the zend extension loading code --- sapi/cli/php_cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index eec117ab1f..2fd3dbed10 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -870,7 +870,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ break; case 'z': /* load extension file */ - zend_load_extension(php_optarg); + zend_load_extension(php_optarg TSRMLS_CC); break; case 'H': hide_argv = 1; -- cgit v1.2.1 From ed5a8d510f6e4ae865008fe711efbbc5452adf42 Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Wed, 18 Dec 2013 09:06:39 +0100 Subject: Pass the TSRMLS parameters to the sapi flush hook, this shaves off a few TSRMLS_FETCH() calls in our various SAPIs --- sapi/cli/php_cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 2fd3dbed10..cb52cd7072 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -320,7 +320,7 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ } /* }}} */ -static void sapi_cli_flush(void *server_context) /* {{{ */ +static void sapi_cli_flush(void *server_context TSRMLS_DC) /* {{{ */ { /* Ignore EBADF here, it's caused by the fact that STDIN/STDOUT/STDERR streams * are/could be closed before fflush() is called. -- cgit v1.2.1 From c081ce628f0d76d44784d7bb8e06428b06142ac0 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 3 Jan 2014 11:08:10 +0800 Subject: Bump year --- sapi/cli/php_cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 9f3fc4b5b7..9daa382eec 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -693,7 +693,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ goto out; case 'v': /* show php version & quit */ - php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2013 The PHP Group\n%s", + php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2014 The PHP Group\n%s", PHP_VERSION, cli_sapi_module.name, __DATE__, __TIME__, #if ZEND_DEBUG && defined(HAVE_GCOV) "(DEBUG GCOV)", -- cgit v1.2.1 From f4cfaf36e23ca47da3e352e1c60909104c059647 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 10 Feb 2014 10:04:30 +0400 Subject: Use better data structures (incomplete) --- sapi/cli/php_cli.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 7c971176b6..fd3881fd06 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -182,11 +182,11 @@ static int print_module_info(zend_module_entry *module TSRMLS_DC) /* {{{ */ static int module_name_cmp(const void *a, const void *b TSRMLS_DC) /* {{{ */ { - Bucket *f = *((Bucket **) a); - Bucket *s = *((Bucket **) b); + Bucket *f = (Bucket *) a; + Bucket *s = (Bucket *) b; - return strcasecmp(((zend_module_entry *)f->pData)->name, - ((zend_module_entry *)s->pData)->name); + return strcasecmp(((zend_module_entry *)f->xData)->name, + ((zend_module_entry *)s->xData)->name); } /* }}} */ @@ -1087,6 +1087,8 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ break; } +//??? +#if 0 case PHP_MODE_REFLECTION_FUNCTION: case PHP_MODE_REFLECTION_CLASS: case PHP_MODE_REFLECTION_EXTENSION: @@ -1161,6 +1163,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ efree(lcname); break; } +#endif case PHP_MODE_SHOW_INI_CONFIG: { zend_printf("Configuration File (php.ini) Path: %s\n", PHP_CONFIG_FILE_PATH); -- cgit v1.2.1 From a52817eb027f2f90973888f35578d7b9eaf51d10 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 14 Feb 2014 14:11:52 +0400 Subject: Use better data structures (incomplete) --- sapi/cli/php_cli.c | 73 +++++++++++++++++++----------------------------------- 1 file changed, 26 insertions(+), 47 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index fd3881fd06..f5fa168dc5 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -185,18 +185,18 @@ static int module_name_cmp(const void *a, const void *b TSRMLS_DC) /* {{{ */ Bucket *f = (Bucket *) a; Bucket *s = (Bucket *) b; - return strcasecmp(((zend_module_entry *)f->xData)->name, - ((zend_module_entry *)s->xData)->name); + return strcasecmp(((zend_module_entry *)Z_PTR(f->val))->name, + ((zend_module_entry *)Z_PTR(s->val))->name); } /* }}} */ static void print_modules(TSRMLS_D) /* {{{ */ { HashTable sorted_registry; - zend_module_entry tmp; zend_hash_init(&sorted_registry, 50, NULL, NULL, 1); - zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry)); +//??? zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry)); + zend_hash_copy(&sorted_registry, &module_registry, NULL); zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC); zend_hash_apply(&sorted_registry, (apply_func_t) print_module_info TSRMLS_CC); zend_hash_destroy(&sorted_registry); @@ -425,10 +425,8 @@ static int php_cli_startup(sapi_module_struct *sapi_module) /* {{{ */ /* overwriteable ini defaults must be set in sapi_cli_ini_defaults() */ #define INI_DEFAULT(name,value)\ - Z_SET_REFCOUNT(tmp, 0);\ - Z_UNSET_ISREF(tmp); \ - ZVAL_STRINGL(&tmp, zend_strndup(value, sizeof(value)-1), sizeof(value)-1, 0);\ - zend_hash_update(configuration_hash, name, sizeof(name), &tmp, sizeof(zval), NULL);\ + ZVAL_STR(&tmp, STR_INIT(value, sizeof(value)-1, 1));\ + zend_hash_str_update(configuration_hash, name, sizeof(name)-1, &tmp);\ static void sapi_cli_ini_defaults(HashTable *configuration_hash) { @@ -553,23 +551,16 @@ static php_stream *s_in_process = NULL; static void cli_register_file_handles(TSRMLS_D) /* {{{ */ { - zval *zin, *zout, *zerr; + zval zin, zout, zerr; php_stream *s_in, *s_out, *s_err; php_stream_context *sc_in=NULL, *sc_out=NULL, *sc_err=NULL; zend_constant ic, oc, ec; - MAKE_STD_ZVAL(zin); - MAKE_STD_ZVAL(zout); - MAKE_STD_ZVAL(zerr); - s_in = php_stream_open_wrapper_ex("php://stdin", "rb", 0, NULL, sc_in); s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out); s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err); if (s_in==NULL || s_out==NULL || s_err==NULL) { - FREE_ZVAL(zin); - FREE_ZVAL(zout); - FREE_ZVAL(zerr); if (s_in) php_stream_close(s_in); if (s_out) php_stream_close(s_out); if (s_err) php_stream_close(s_err); @@ -584,34 +575,27 @@ static void cli_register_file_handles(TSRMLS_D) /* {{{ */ s_in_process = s_in; - php_stream_to_zval(s_in, zin); - php_stream_to_zval(s_out, zout); - php_stream_to_zval(s_err, zerr); + php_stream_to_zval(s_in, &zin); + php_stream_to_zval(s_out, &zout); + php_stream_to_zval(s_err, &zerr); - ic.value = *zin; + ZVAL_COPY_VALUE(&ic.value, &zin); ic.flags = CONST_CS; - ic.name = zend_strndup(ZEND_STRL("STDIN")); - ic.name_len = sizeof("STDIN"); + ic.name = STR_INIT("STDIN", sizeof("STDIN")-1, 1); ic.module_number = 0; zend_register_constant(&ic TSRMLS_CC); - oc.value = *zout; + ZVAL_COPY_VALUE(&oc.value, &zout); oc.flags = CONST_CS; - oc.name = zend_strndup(ZEND_STRL("STDOUT")); - oc.name_len = sizeof("STDOUT"); + oc.name = STR_INIT("STDOUT", sizeof("STDOUT")-1, 1); oc.module_number = 0; zend_register_constant(&oc TSRMLS_CC); - ec.value = *zerr; + ZVAL_COPY_VALUE(&ec.value, &zerr); ec.flags = CONST_CS; - ec.name = zend_strndup(ZEND_STRL("STDERR")); - ec.name_len = sizeof("STDERR"); + ec.name = STR_INIT("STDERR", sizeof("STDERR")-1, 1); ec.module_number = 0; zend_register_constant(&ec TSRMLS_CC); - - FREE_ZVAL(zin); - FREE_ZVAL(zout); - FREE_ZVAL(zerr); } /* }}} */ @@ -673,11 +657,11 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ int lineno = 0; const char *param_error=NULL; int hide_argv = 0; + zend_string *key; zend_try { CG(in_compilation) = 0; /* not initialized but needed for several options */ - EG(uninitialized_zval_ptr) = NULL; while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (c) { @@ -979,7 +963,9 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ } } - zend_is_auto_global("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); + key = STR_INIT("_SERVER", sizeof("_SERVER")-1, 0); + zend_is_auto_global(key TSRMLS_CC); + STR_RELEASE(key); PG(during_request_startup) = 0; switch (behavior) { @@ -1040,30 +1026,23 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ { char *input; size_t len, index = 0; - zval *argn, *argi; + zval argn, argi; cli_register_file_handles(TSRMLS_C); if (exec_begin && zend_eval_string_ex(exec_begin, NULL, "Command line begin code", 1 TSRMLS_CC) == FAILURE) { exit_status=254; } - ALLOC_ZVAL(argi); - Z_TYPE_P(argi) = IS_LONG; - Z_LVAL_P(argi) = index; - INIT_PZVAL(argi); - zend_hash_update(&EG(symbol_table), "argi", sizeof("argi"), &argi, sizeof(zval *), NULL); + ZVAL_LONG(&argi, index); + zend_hash_str_update(&EG(symbol_table).ht, "argi", sizeof("argi")-1, &argi); while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) { len = strlen(input); while (len-- && (input[len]=='\n' || input[len]=='\r')) { input[len] = '\0'; } - ALLOC_ZVAL(argn); - Z_TYPE_P(argn) = IS_STRING; - Z_STRLEN_P(argn) = ++len; - Z_STRVAL_P(argn) = estrndup(input, len); - INIT_PZVAL(argn); - zend_hash_update(&EG(symbol_table), "argn", sizeof("argn"), &argn, sizeof(zval *), NULL); - Z_LVAL_P(argi) = ++index; + ZVAL_STRINGL(&argn, input, len); + zend_hash_str_update(&EG(symbol_table).ht, "argn", sizeof("argn")-1, &argn); + Z_LVAL(argi) = ++index; if (exec_run) { if (zend_eval_string_ex(exec_run, NULL, "Command line run code", 1 TSRMLS_CC) == FAILURE) { exit_status=254; -- cgit v1.2.1 From fb825a95d0ff0106beb4b2957aad10fb08f90a22 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 28 Feb 2014 13:02:28 +0800 Subject: Fixed module name printing --- sapi/cli/php_cli.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index f5fa168dc5..190f09f912 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -173,8 +173,9 @@ const opt_struct OPTIONS[] = { {'-', 0, NULL} /* end of args */ }; -static int print_module_info(zend_module_entry *module TSRMLS_DC) /* {{{ */ +static int print_module_info(zval *element TSRMLS_DC) /* {{{ */ { + zend_module_entry *module = (zend_module_entry*)Z_PTR_P(element); php_printf("%s\n", module->name); return ZEND_HASH_APPLY_KEEP; } -- cgit v1.2.1 From 232f3e915cf7499663d6f404e8f3dbf4985523fb Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 14 Mar 2014 18:00:42 +0400 Subject: Fixed various CLI problems --- sapi/cli/php_cli.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 190f09f912..b85aded875 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -195,8 +195,7 @@ static void print_modules(TSRMLS_D) /* {{{ */ { HashTable sorted_registry; - zend_hash_init(&sorted_registry, 50, NULL, NULL, 1); -//??? zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry)); + zend_hash_init(&sorted_registry, 50, NULL, NULL, 0); zend_hash_copy(&sorted_registry, &module_registry, NULL); zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC); zend_hash_apply(&sorted_registry, (apply_func_t) print_module_info TSRMLS_CC); @@ -1038,7 +1037,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ zend_hash_str_update(&EG(symbol_table).ht, "argi", sizeof("argi")-1, &argi); while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) { len = strlen(input); - while (len-- && (input[len]=='\n' || input[len]=='\r')) { + while (len > 0 && len-- && (input[len]=='\n' || input[len]=='\r')) { input[len] = '\0'; } ZVAL_STRINGL(&argn, input, len); @@ -1067,15 +1066,14 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ break; } -//??? -#if 0 + case PHP_MODE_REFLECTION_FUNCTION: case PHP_MODE_REFLECTION_CLASS: case PHP_MODE_REFLECTION_EXTENSION: case PHP_MODE_REFLECTION_ZEND_EXTENSION: { zend_class_entry *pce = NULL; - zval *arg, *ref; + zval arg, ref; zend_execute_data execute_data; switch (behavior) { @@ -1099,24 +1097,24 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ break; } - MAKE_STD_ZVAL(arg); - ZVAL_STRING(arg, reflection_what, 1); - ALLOC_ZVAL(ref); - object_init_ex(ref, pce); - INIT_PZVAL(ref); + ZVAL_STRING(&arg, reflection_what); + object_init_ex(&ref, pce); memset(&execute_data, 0, sizeof(zend_execute_data)); EG(current_execute_data) = &execute_data; EX(function_state).function = pce->constructor; - zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, arg); + zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, &arg); if (EG(exception)) { - zval *msg = zend_read_property(zend_exception_get_default(TSRMLS_C), EG(exception), "message", sizeof("message")-1, 0 TSRMLS_CC); + zval tmp, *msg; + + ZVAL_OBJ(&tmp, EG(exception)); + msg = zend_read_property(zend_exception_get_default(TSRMLS_C), &tmp, "message", sizeof("message")-1, 0 TSRMLS_CC); zend_printf("Exception: %s\n", Z_STRVAL_P(msg)); - zval_ptr_dtor(&EG(exception)); + zval_ptr_dtor(&tmp); EG(exception) = NULL; } else { - zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, ref); + zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, &ref); } zval_ptr_dtor(&ref); zval_ptr_dtor(&arg); @@ -1129,7 +1127,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ char *lcname = zend_str_tolower_dup(reflection_what, len); zend_module_entry *module; - if (zend_hash_find(&module_registry, lcname, len+1, (void**)&module) == FAILURE) { + if ((module = zend_hash_str_find_ptr(&module_registry, lcname, len)) == NULL) { if (!strcmp(reflection_what, "main")) { display_ini_entries(NULL); } else { @@ -1143,7 +1141,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ efree(lcname); break; } -#endif + case PHP_MODE_SHOW_INI_CONFIG: { zend_printf("Configuration File (php.ini) Path: %s\n", PHP_CONFIG_FILE_PATH); -- cgit v1.2.1 From 76cc99fe60d1e446a0250b4d778f02bcdbd7fc09 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 3 Apr 2014 15:26:23 +0400 Subject: Refactored ZVAL flags usage to simplify various checks (e.g. Z_REFCOUNTED(), candidate for GC, etc) --- sapi/cli/php_cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index b85aded875..2156cb14fc 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -425,7 +425,7 @@ static int php_cli_startup(sapi_module_struct *sapi_module) /* {{{ */ /* overwriteable ini defaults must be set in sapi_cli_ini_defaults() */ #define INI_DEFAULT(name,value)\ - ZVAL_STR(&tmp, STR_INIT(value, sizeof(value)-1, 1));\ + ZVAL_NEW_STR(&tmp, STR_INIT(value, sizeof(value)-1, 1));\ zend_hash_str_update(configuration_hash, name, sizeof(name)-1, &tmp);\ static void sapi_cli_ini_defaults(HashTable *configuration_hash) -- cgit v1.2.1 From c2082ece52bcb5343ae0feb460807596cd79d691 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sun, 25 May 2014 18:32:35 +0800 Subject: Fixed apply_func_t (they should be broken before) --- sapi/cli/php_cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 2156cb14fc..d353b00a06 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -198,7 +198,7 @@ static void print_modules(TSRMLS_D) /* {{{ */ zend_hash_init(&sorted_registry, 50, NULL, NULL, 0); zend_hash_copy(&sorted_registry, &module_registry, NULL); zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC); - zend_hash_apply(&sorted_registry, (apply_func_t) print_module_info TSRMLS_CC); + zend_hash_apply(&sorted_registry, print_module_info TSRMLS_CC); zend_hash_destroy(&sorted_registry); } /* }}} */ -- cgit v1.2.1 From b7715c7e8a6166f84d9c4d6e35bffef853cabc5c Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 30 Jun 2014 15:43:45 +0400 Subject: Refactored parameter passing mechanism. In PHP-5.6 and below each argument passed to user function was copies on VM stack twice. Now we always have ZEND_INIT_FCALL (or simular) opcode that pushes "call frame" on top of VM stack. "Call frame" is actually the same zend_execute_data structure. All the following ZEND_SEND instructions push arguments on top of the stack in a way that they directly comes into corresponding CV variables of the called frame. Extra arguments are copied at the end of stack frame (after all CV and TMP variables) on function enterance. There are two minor incompatibilities: 1) It's not allowed to decalre functions redefining arguments e.g. "function foo($a,$a) {}". 2) func_get_arg() and func_get args() return the current value of argument and not the original value that was sent. --- sapi/cli/php_cli.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index d353b00a06..ec76f37715 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -1102,7 +1102,6 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ memset(&execute_data, 0, sizeof(zend_execute_data)); EG(current_execute_data) = &execute_data; - EX(function_state).function = pce->constructor; zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, &arg); if (EG(exception)) { -- cgit v1.2.1 From cb25136f4ef1042295650475b2c20ace81e2b9b7 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 16 Aug 2014 11:37:14 +0200 Subject: fix macros in the 5 basic extensions --- sapi/cli/php_cli.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index ec76f37715..92ec58b25f 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -252,16 +252,16 @@ static inline int sapi_cli_select(int fd TSRMLS_DC) return ret != -1; } -PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */ +PHP_CLI_API php_size_t sapi_cli_single_write(const char *str, php_size_t str_length TSRMLS_DC) /* {{{ */ { #ifdef PHP_WRITE_STDOUT long ret; #else - size_t ret; + php_size_t ret; #endif if (cli_shell_callbacks.cli_shell_write) { - size_t shell_wrote; + php_size_t shell_wrote; shell_wrote = cli_shell_callbacks.cli_shell_write(str, str_length TSRMLS_CC); if (shell_wrote > -1) { return shell_wrote; @@ -285,10 +285,10 @@ PHP_CLI_API size_t sapi_cli_single_write(const char *str, uint str_length TSRMLS } /* }}} */ -static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ */ +static php_size_t sapi_cli_ub_write(const char *str, php_size_t str_length TSRMLS_DC) /* {{{ */ { const char *ptr = str; - uint remaining = str_length; + php_size_t remaining = str_length; size_t ret; if (!str_length) { @@ -296,7 +296,7 @@ static int sapi_cli_ub_write(const char *str, uint str_length TSRMLS_DC) /* {{{ } if (cli_shell_callbacks.cli_shell_ub_write) { - int ub_wrote; + php_size_t ub_wrote; ub_wrote = cli_shell_callbacks.cli_shell_ub_write(str, str_length TSRMLS_CC); if (ub_wrote > -1) { return ub_wrote; @@ -338,7 +338,7 @@ static char *script_filename = ""; static void sapi_cli_register_variables(zval *track_vars_array TSRMLS_DC) /* {{{ */ { - unsigned int len; + php_size_t len; char *docroot = ""; /* In CGI mode, we consider the environment to be a part of the server @@ -1033,7 +1033,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ if (exec_begin && zend_eval_string_ex(exec_begin, NULL, "Command line begin code", 1 TSRMLS_CC) == FAILURE) { exit_status=254; } - ZVAL_LONG(&argi, index); + ZVAL_INT(&argi, index); zend_hash_str_update(&EG(symbol_table).ht, "argi", sizeof("argi")-1, &argi); while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) { len = strlen(input); @@ -1042,7 +1042,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ } ZVAL_STRINGL(&argn, input, len); zend_hash_str_update(&EG(symbol_table).ht, "argn", sizeof("argn")-1, &argn); - Z_LVAL(argi) = ++index; + Z_IVAL(argi) = ++index; if (exec_run) { if (zend_eval_string_ex(exec_run, NULL, "Command line run code", 1 TSRMLS_CC) == FAILURE) { exit_status=254; -- cgit v1.2.1 From 41115d3d9dc1f7116ac2d1bb7087a24098885a03 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sun, 17 Aug 2014 21:05:20 +0200 Subject: regenerated parser files --- sapi/cli/php_cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 92ec58b25f..bdc4629c08 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -252,10 +252,10 @@ static inline int sapi_cli_select(int fd TSRMLS_DC) return ret != -1; } -PHP_CLI_API php_size_t sapi_cli_single_write(const char *str, php_size_t str_length TSRMLS_DC) /* {{{ */ +PHP_CLI_API size_t sapi_cli_single_write(const char *str, php_size_t str_length TSRMLS_DC) /* {{{ */ { #ifdef PHP_WRITE_STDOUT - long ret; + php_int_t ret; #else php_size_t ret; #endif -- cgit v1.2.1 From c3e3c98ec666812daaaca896cf5ef758a8a6df14 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 25 Aug 2014 19:24:55 +0200 Subject: master renames phase 1 --- sapi/cli/php_cli.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index bdc4629c08..c51e5a8ce2 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -255,7 +255,7 @@ static inline int sapi_cli_select(int fd TSRMLS_DC) PHP_CLI_API size_t sapi_cli_single_write(const char *str, php_size_t str_length TSRMLS_DC) /* {{{ */ { #ifdef PHP_WRITE_STDOUT - php_int_t ret; + zend_long ret; #else php_size_t ret; #endif @@ -425,7 +425,7 @@ static int php_cli_startup(sapi_module_struct *sapi_module) /* {{{ */ /* overwriteable ini defaults must be set in sapi_cli_ini_defaults() */ #define INI_DEFAULT(name,value)\ - ZVAL_NEW_STR(&tmp, STR_INIT(value, sizeof(value)-1, 1));\ + ZVAL_NEW_STR(&tmp, zend_string_init(value, sizeof(value)-1, 1));\ zend_hash_str_update(configuration_hash, name, sizeof(name)-1, &tmp);\ static void sapi_cli_ini_defaults(HashTable *configuration_hash) @@ -581,19 +581,19 @@ static void cli_register_file_handles(TSRMLS_D) /* {{{ */ ZVAL_COPY_VALUE(&ic.value, &zin); ic.flags = CONST_CS; - ic.name = STR_INIT("STDIN", sizeof("STDIN")-1, 1); + ic.name = zend_string_init("STDIN", sizeof("STDIN")-1, 1); ic.module_number = 0; zend_register_constant(&ic TSRMLS_CC); ZVAL_COPY_VALUE(&oc.value, &zout); oc.flags = CONST_CS; - oc.name = STR_INIT("STDOUT", sizeof("STDOUT")-1, 1); + oc.name = zend_string_init("STDOUT", sizeof("STDOUT")-1, 1); oc.module_number = 0; zend_register_constant(&oc TSRMLS_CC); ZVAL_COPY_VALUE(&ec.value, &zerr); ec.flags = CONST_CS; - ec.name = STR_INIT("STDERR", sizeof("STDERR")-1, 1); + ec.name = zend_string_init("STDERR", sizeof("STDERR")-1, 1); ec.module_number = 0; zend_register_constant(&ec TSRMLS_CC); } @@ -963,9 +963,9 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ } } - key = STR_INIT("_SERVER", sizeof("_SERVER")-1, 0); + key = zend_string_init("_SERVER", sizeof("_SERVER")-1, 0); zend_is_auto_global(key TSRMLS_CC); - STR_RELEASE(key); + zend_string_release(key); PG(during_request_startup) = 0; switch (behavior) { @@ -1033,7 +1033,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ if (exec_begin && zend_eval_string_ex(exec_begin, NULL, "Command line begin code", 1 TSRMLS_CC) == FAILURE) { exit_status=254; } - ZVAL_INT(&argi, index); + ZVAL_LONG(&argi, index); zend_hash_str_update(&EG(symbol_table).ht, "argi", sizeof("argi")-1, &argi); while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) { len = strlen(input); @@ -1042,7 +1042,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ } ZVAL_STRINGL(&argn, input, len); zend_hash_str_update(&EG(symbol_table).ht, "argn", sizeof("argn")-1, &argn); - Z_IVAL(argi) = ++index; + Z_LVAL(argi) = ++index; if (exec_run) { if (zend_eval_string_ex(exec_run, NULL, "Command line run code", 1 TSRMLS_CC) == FAILURE) { exit_status=254; -- cgit v1.2.1 From 4d997f63d98c663b2d9acccd3655572652f61c7d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 25 Aug 2014 20:22:49 +0200 Subject: master renames phase 3 --- sapi/cli/php_cli.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index c51e5a8ce2..5847849e89 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -252,16 +252,16 @@ static inline int sapi_cli_select(int fd TSRMLS_DC) return ret != -1; } -PHP_CLI_API size_t sapi_cli_single_write(const char *str, php_size_t str_length TSRMLS_DC) /* {{{ */ +PHP_CLI_API size_t sapi_cli_single_write(const char *str, size_t str_length TSRMLS_DC) /* {{{ */ { #ifdef PHP_WRITE_STDOUT zend_long ret; #else - php_size_t ret; + size_t ret; #endif if (cli_shell_callbacks.cli_shell_write) { - php_size_t shell_wrote; + size_t shell_wrote; shell_wrote = cli_shell_callbacks.cli_shell_write(str, str_length TSRMLS_CC); if (shell_wrote > -1) { return shell_wrote; @@ -285,10 +285,10 @@ PHP_CLI_API size_t sapi_cli_single_write(const char *str, php_size_t str_length } /* }}} */ -static php_size_t sapi_cli_ub_write(const char *str, php_size_t str_length TSRMLS_DC) /* {{{ */ +static size_t sapi_cli_ub_write(const char *str, size_t str_length TSRMLS_DC) /* {{{ */ { const char *ptr = str; - php_size_t remaining = str_length; + size_t remaining = str_length; size_t ret; if (!str_length) { @@ -296,7 +296,7 @@ static php_size_t sapi_cli_ub_write(const char *str, php_size_t str_length TSRML } if (cli_shell_callbacks.cli_shell_ub_write) { - php_size_t ub_wrote; + size_t ub_wrote; ub_wrote = cli_shell_callbacks.cli_shell_ub_write(str, str_length TSRMLS_CC); if (ub_wrote > -1) { return ub_wrote; @@ -338,7 +338,7 @@ static char *script_filename = ""; static void sapi_cli_register_variables(zval *track_vars_array TSRMLS_DC) /* {{{ */ { - php_size_t len; + size_t len; char *docroot = ""; /* In CGI mode, we consider the environment to be a part of the server -- cgit v1.2.1 From 59848e3fbbcab3144c4d711df5d5be39cca51269 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 25 Aug 2014 23:45:02 +0200 Subject: Remove ZEND_ACC_INTERACTIVE and CG(interactive) As far as I can discern these are leftovers of the interactive shell implementation that was used before PHP 5.4. Now the readline ext makes use of normal eval calls for this. So, dropping these until there is evidence to the contrary, as they currently wouldn't work anyway. --- sapi/cli/php_cli.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 5847849e89..2e714c4a90 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -902,8 +902,6 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ fflush(stdout); } - CG(interactive) = interactive; - /* only set script_file if not set already and not in direct mode and not at end of parameter list */ if (argc > php_optind && !script_file -- cgit v1.2.1 From 534ee969649fc0a4d9c9a9467a616a6fab7acdbe Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sun, 14 Sep 2014 23:03:13 +0200 Subject: fix ftell/fseek calls --- sapi/cli/php_cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 2e714c4a90..f3eec80283 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -627,8 +627,8 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file, /* handle situations where line is terminated by \r\n */ if (c == '\r') { if (fgetc(file_handle->handle.fp) != '\n') { - long pos = ftell(file_handle->handle.fp); - fseek(file_handle->handle.fp, pos - 1, SEEK_SET); + zend_long pos = zend_ftell(file_handle->handle.fp); + zend_fseek(file_handle->handle.fp, pos - 1, SEEK_SET); } } *lineno = 2; -- cgit v1.2.1 From d0cb715373c3fbe9dc095378ec5ed8c71f799f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schl=C3=BCter?= Date: Fri, 19 Sep 2014 18:33:14 +0200 Subject: s/PHP 5/PHP 7/ --- sapi/cli/php_cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index f3eec80283..04cbdeb8f1 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | PHP Version 5 | + | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ -- cgit v1.2.1 From 65eb8ef8d040976e81b5f7b11e74013218cd1428 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 13 Oct 2014 18:42:30 +0200 Subject: fix several datatype mismatch warnings --- sapi/cli/php_cli.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sapi/cli/php_cli.c') diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 04cbdeb8f1..ef45ef6ef9 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -244,7 +244,7 @@ static inline int sapi_cli_select(int fd TSRMLS_DC) PHP_SAFE_FD_SET(fd, &wfd); - tv.tv_sec = FG(default_socket_timeout); + tv.tv_sec = (long)FG(default_socket_timeout); tv.tv_usec = 0; ret = php_select(fd+1, &dfd, &wfd, &dfd, &tv); @@ -1120,7 +1120,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */ } case PHP_MODE_REFLECTION_EXT_INFO: { - int len = strlen(reflection_what); + int len = (int)strlen(reflection_what); char *lcname = zend_str_tolower_dup(reflection_what, len); zend_module_entry *module; @@ -1258,7 +1258,7 @@ int main(int argc, char *argv[]) break; case 'd': { /* define ini entries on command line */ - int len = strlen(php_optarg); + int len = (int)strlen(php_optarg); char *val; if ((val = strchr(php_optarg, '='))) { @@ -1266,11 +1266,11 @@ int main(int argc, char *argv[]) if (!isalnum(*val) && *val != '"' && *val != '\'' && *val != '\0') { ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("\"\"\n\0")); memcpy(ini_entries + ini_entries_len, php_optarg, (val - php_optarg)); - ini_entries_len += (val - php_optarg); + ini_entries_len += (int)(val - php_optarg); memcpy(ini_entries + ini_entries_len, "\"", 1); ini_entries_len++; memcpy(ini_entries + ini_entries_len, val, len - (val - php_optarg)); - ini_entries_len += len - (val - php_optarg); + ini_entries_len += len - (int)(val - php_optarg); memcpy(ini_entries + ini_entries_len, "\"\n\0", sizeof("\"\n\0")); ini_entries_len += sizeof("\n\0\"") - 2; } else { -- cgit v1.2.1