diff options
Diffstat (limited to 'sapi')
182 files changed, 1457 insertions, 6166 deletions
diff --git a/sapi/apache2handler/README b/sapi/apache2handler/README deleted file mode 100644 index 15ef022d24..0000000000 --- a/sapi/apache2handler/README +++ /dev/null @@ -1,75 +0,0 @@ -WHAT IS THIS? - - This module exploits the layered I/O support in Apache 2.0. - -HOW DOES IT WORK? - - In Apache 2.0, you have handlers which generate content (like - reading a script from disk). The content goes then through - a chain of filters. PHP can be such a filter, so that it processes - your script and hands the output to the next filter (which will - usually cause a write to the network). - -DOES IT WORK? - - Currently the issues with the module are: - * Thread safety of external PHP modules - * The lack of re-entrancy of PHP. due to this I have disabled the 'virtual' - function, and tried to stop any method where a php script can run another php - script while it is being run. - - -HOW TO INSTALL - - This SAPI module is known to work with Apache 2.0.44. - - $ cd apache-2.x - $ cd src - $ ./configure --enable-so - $ make install - - For testing purposes, you might want to use --with-mpm=prefork. - (Albeit PHP also works with threaded MPMs. See Thread Safety note above) - - Configure PHP 4: - - $ cd php-4.x - $ ./configure --with-apxs2=/path/to/apache-2.0/bin/apxs - $ make install - - At the end of conf/httpd.conf, add: - - AddType application/x-httpd-php .php - - If you would like to enable source code highlighting functionality add: - - AddType application/x-httpd-php-source .phps - - That's it. Now start bin/httpd. - -HOW TO CONFIGURE - - The Apache 2.0 PHP module supports a new configuration directive that - allows an admin to override the php.ini search path. For example, - place your php.ini file in Apache's ServerRoot/conf directory and - add this to your httpd.conf file: - - PHPINIDir "conf" - -DEBUGGING APACHE AND PHP - - To debug Apache, we recommend: - - 1. Use the Prefork MPM (Apache 1.3-like process model) by - configuring Apache with '--with-mpm=prefork'. - 2. Start httpd using -DONE_PROCESS (e.g. (gdb) r -DONE_PROCESS). - - If you want to debug a part of the PHP startup procedure, set a - breakpoint on 'load_module'. Step through it until apr_dso_load() is - done. Then you can set a breakpoint on any PHP-related symbol. - -TODO - - PHP functions like apache_sub_req (see php_functions.c) - Source Code Highlighting - Protocol handlers diff --git a/sapi/apache2handler/apache_config.c b/sapi/apache2handler/apache_config.c index 4c9c80f942..d0913c250e 100644 --- a/sapi/apache2handler/apache_config.c +++ b/sapi/apache2handler/apache_config.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -233,12 +233,3 @@ void *create_php_config(apr_pool_t *p, char *dummy) apr_pool_cleanup_register(p, newx, destroy_php_config, apr_pool_cleanup_null); return (void *) newx; } - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4 index 44dee3fad5..55c16179b8 100644 --- a/sapi/apache2handler/config.m4 +++ b/sapi/apache2handler/config.m4 @@ -1,10 +1,11 @@ -dnl config.m4 for sapi apache2handler +PHP_ARG_WITH([apxs2],, + [AS_HELP_STRING([[--with-apxs2[=FILE]]], + [Build shared Apache 2 handler module. FILE is the optional pathname to + the Apache apxs tool [apxs]])], + [no], + [no]) -PHP_ARG_WITH(apxs2,, -[ --with-apxs2[=FILE] Build shared Apache 2.0 Handler module. FILE is the optional - pathname to the Apache apxs tool [apxs]], no, no) - -AC_MSG_CHECKING([for Apache 2.0 handler-module support via DSO through APXS]) +AC_MSG_CHECKING([for Apache 2 handler module support via DSO through APXS]) if test "$PHP_APXS2" != "no"; then if test "$PHP_APXS2" = "yes"; then @@ -39,7 +40,7 @@ if test "$PHP_APXS2" != "no"; then APU_BINDIR=`$APXS -q APU_BINDIR` APR_BINDIR=`$APXS -q APR_BINDIR` - # Pick up ap[ru]-N-config if using httpd >=2.1 + dnl Pick up ap[ru]-N-config if using httpd >=2.1 APR_CONFIG=`$APXS -q APR_CONFIG 2>/dev/null || echo $APR_BINDIR/apr-config` APU_CONFIG=`$APXS -q APU_CONFIG 2>/dev/null || @@ -56,11 +57,9 @@ if test "$PHP_APXS2" != "no"; then APACHE_CFLAGS="$APACHE_CPPFLAGS -I$APXS_INCLUDEDIR $APR_CFLAGS $APU_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" - # Test that we're trying to configure with apache 2.x + dnl Test that we're trying to configure with apache 2.x PHP_AP_EXTRACT_VERSION($APXS_HTTPD) - if test "$APACHE_VERSION" -le 2000000; then - AC_MSG_ERROR([You have enabled Apache 2 support while your server is Apache 1.3. Please use the appropriate switch --with-apxs (without the 2)]) - elif test "$APACHE_VERSION" -lt 2000044; then + if test "$APACHE_VERSION" -lt 2000044; then AC_MSG_ERROR([Please note that Apache version >= 2.0.44 is required]) fi @@ -85,10 +84,9 @@ if test "$PHP_APXS2" != "no"; then INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL" ;; *darwin*) - dnl When using bundles on Darwin, we must resolve all symbols. However, - dnl the linker does not recursively look at the bundle loader and - dnl pull in its dependencies. Therefore, we must pull in the APR - dnl and APR-util libraries. + dnl When using bundles on Darwin, we must resolve all symbols. However, the + dnl linker does not recursively look at the bundle loader and pull in its + dnl dependencies. Therefore, we must pull in the APR and APR-util libraries. if test -x "$APR_CONFIG"; then MH_BUNDLE_FLAGS="`$APR_CONFIG --ldflags --link-ld --libs`" fi @@ -113,7 +111,7 @@ if test "$PHP_APXS2" != "no"; then PHP_BUILD_THREAD_SAFE fi else - APACHE_THREADED_MPM=`$APXS_HTTPD -V | grep 'threaded:.*yes'` + APACHE_THREADED_MPM=`$APXS_HTTPD -V 2>/dev/null | grep 'threaded:.*yes'` if test -n "$APACHE_THREADED_MPM"; then PHP_BUILD_THREAD_SAFE fi @@ -123,7 +121,3 @@ if test "$PHP_APXS2" != "no"; then else AC_MSG_RESULT(no) fi - -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: diff --git a/sapi/apache2handler/mod_php7.c b/sapi/apache2handler/mod_php7.c index e2f96592cc..6c44dbaa2c 100644 --- a/sapi/apache2handler/mod_php7.c +++ b/sapi/apache2handler/mod_php7.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -32,12 +32,3 @@ AP_MODULE_DECLARE_DATA module php7_module = { php_dir_cmds, /* command apr_table_t */ php_ap2_register_hook /* register hooks */ }; - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/sapi/apache2handler/php_apache.h b/sapi/apache2handler/php_apache.h index ae5e5972cc..423ada1f9b 100644 --- a/sapi/apache2handler/php_apache.h +++ b/sapi/apache2handler/php_apache.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c index 6638fddda1..c82b93f965 100644 --- a/sapi/apache2handler/php_functions.c +++ b/sapi/apache2handler/php_functions.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -559,15 +559,6 @@ zend_module_entry php_apache_module = { NULL, NULL, PHP_MINFO(apache), - NULL, + PHP_VERSION, STANDARD_MODULE_PROPERTIES }; - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 23eef816a8..1cc5670eaa 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -474,15 +474,18 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp apache2_sapi_module.php_ini_path_override = apache2_php_ini_path_override; } #ifdef ZTS - tsrm_startup(1, 1, 0, NULL); - (void)ts_resource(0); + php_tsrm_startup(); +# ifdef PHP_WIN32 ZEND_TSRMLS_CACHE_UPDATE(); +# endif #endif zend_signal_startup(); sapi_startup(&apache2_sapi_module); - apache2_sapi_module.startup(&apache2_sapi_module); + if (apache2_sapi_module.startup(&apache2_sapi_module) != SUCCESS) { + return DONE; + } apr_pool_cleanup_register(pconf, NULL, php_apache_server_shutdown, apr_pool_cleanup_null); php_apache_add_version(pconf); @@ -572,7 +575,9 @@ static int php_handler(request_rec *r) #ifdef ZTS /* initial resource fetch */ (void)ts_resource(0); +# ifdef PHP_WIN32 ZEND_TSRMLS_CACHE_UPDATE(); +# endif #endif #define PHPAP_INI_OFF php_apache_ini_dtor(r, parent_req); @@ -689,11 +694,7 @@ zend_first_try { highlight_file((char *)r->filename, &syntax_highlighter_ini); } else { zend_file_handle zfd; - - zfd.type = ZEND_HANDLE_FILENAME; - zfd.filename = (char *) r->filename; - zfd.free_filename = 0; - zfd.opened_path = NULL; + zend_stream_init_filename(&zfd, (char *) r->filename); if (!parent_req) { php_execute_script(&zfd); @@ -751,12 +752,3 @@ void php_ap2_register_hook(apr_pool_t *p) #endif ap_hook_child_init(php_apache_child_init, NULL, NULL, APR_HOOK_MIDDLE); } - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/sapi/cgi/README.FastCGI b/sapi/cgi/README.FastCGI deleted file mode 100644 index 4d34ff3dac..0000000000 --- a/sapi/cgi/README.FastCGI +++ /dev/null @@ -1,151 +0,0 @@ -Credits: -Ben Mansell, Stephen Landamore, Daniel Silverstone, Shane Caraveo - -Building PHP ------------- - -You must add '--enable-fastcgi' to the configure command on Linux or -OSX based systems to get fastcgi support in the php-cgi binary. You -also must not use '--enable-discard-path'. - -Running the FastCGI PHP module ------------------------------- - -There are two ways to run the resulting 'php' binary after the fastcgi -version has been built: - -1) Configure your web server to run the PHP binary itself. - -This is the simplest method, obviously you will have to configure your -web server appropriately. Some web servers may also not support this method, -or may not be as efficient. - -2) Run PHP separately from the web server. - -In this setup, PHP is started as a separate process entirely from the web -server. It will listen on a socket for new FastCGI requests, and deliver -PHP pages as appropriate. This is the recommended way of running PHP-FastCGI. -To run this way, you must start the PHP binary running by giving it an IP -and a port number to listen to on the command line, e.g.: - - ./php -b 127.0.0.1:8002 - -The above line is the recommended way of running FastCGI. You usually -want the FastCGI server to provide services to the localhost, not -everyone on the Internet. - -If your web server sits on a remote host, you can make FastCGI listen -on all interfaces: - - ./php -b :8002 - ./php -b "*:8002" - -Note that hostnames are not supported. - -You must also configure your web server to connect to the appropriate port -in order to talk to the PHP FastCGI process. - -The advantage of running PHP in this way is that it entirely separates the -web server and PHP process, so that one cannot disrupt the other. It also -allows PHP to be on an entirely separate machine from the web server if need -be, you could even have several web servers utilising the same running PHP -process if required! - - -Using FastCGI PHP with Apache -============================= - -First of all, you may well ask 'Why?'. After all, Apache already has mod_php. -However, there are advantages to running PHP with FastCGI. Separating the -PHP code from the web server removes 'bloat' from the main server, and should -improve the performance of non-PHP requests. Secondly, having one permanent -PHP process as opposed to one per apache process means that shared resources -like persistent database connections are used more efficiently. - -First of all, make sure that the FastCGI module is enabled. You should have -a line in your config like: - - LoadModule fastcgi_module /usr/lib/apache/2.0/mod_fastcgi.so - -Don't load mod_php, by the way. Make sure it is commented out! - - #LoadModule php7_module /usr/lib/apache/2.0/libphp7.so - -Now, we'll create a fcgi-bin directory, just like you would do with normal -CGI scripts. You'll need to create a directory somewhere to store your -FastCGI binaries. We'll use /space/fcgi-bin/ for this example. Remember to -copy the FastCGI-PHP binary in there. (named 'php-cgi') This sets up -php to run under mod_fastcgi as a dynamic server. - - ScriptAlias /fcgi-bin/ /space/fcgi-bin/ - <Location /fcgi-bin/> - Options ExecCGI - SetHandler fastcgi-script - </Location> - -To setup a specific static configuration for php, you have to use -the FastCgiServer configuration for mod_fastcgi. For this, do not -use the above configuration, but rather the following. -(see mod_fastcgi docs for more configuration information): - - Alias /fcgi-bin/ /space/fcgi-bin/ - FastCgiServer /path/to/php-cgi -processes 5 - -For either of the above configurations, we need to tell Apache to -use the FastCGI binary /fcgi-bin/php to deliver PHP pages. -All that is needed is: - - AddType application/x-httpd-fastphp .php - Action application/x-httpd-fastphp /fcgi-bin/php-cgi - -Now, if you restart Apache, php pages should now be delivered! - -Using FastCGI PHP with IIS or iPlanet -===================================== - -FastCGI server plugins are available at www.caraveo.com/fastcgi/ -Documentation on these are sparse. iPlanet is not very tested, -and no makefile exists yet for unix based iPlanet servers. - - -Security --------- - -Be sure to run the php binary as an appropriate userid. Also, firewall out -the port that PHP is listening on. In addition, you can set the environment -variable FCGI_WEB_SERVER_ADDRS to control who can connect to the FastCGI. -Set it to a comma separated list of IP addresses, e.g.: - -export FCGI_WEB_SERVER_ADDRS=199.170.183.28,199.170.183.71 - - -Tuning ------- - -There are a few tuning parameters that can be tweaked to control the -performance of FastCGI PHP. The following are environment variables that can -be set before running the PHP binary: - -PHP_FCGI_CHILDREN (default value: 0) - -This controls how many child processes the PHP process spawns. When the -fastcgi starts, it creates a number of child processes which handle one -page request at a time. Value 0 means that PHP willnot start additional -processes and main process will handle FastCGI requests by itself. Note that -this process may die (because of PHP_FCGI_MAX_REQUESTS) and it willnot -respawned automatic. Values 1 and above force PHP start additioanl processes -those will handle requests. The main process will restart children in case of -their death. So by default, you will be able to handle 1 concurrent PHP page -requests. Further requests will be queued. Increasing this number will allow -for better concurrency, especially if you have pages that take a significant -time to create, or supply a lot of data (e.g. downloading huge files via PHP). -On the other hand, having more processes running will use more RAM, and letting -too many PHP pages be generated concurrently will mean that each request will -be slow. - -PHP_FCGI_MAX_REQUESTS (default value: 500) - -This controls how many requests each child process will handle before -exitting. When one process exits, another will be created. This tuning is -necessary because several PHP functions are known to have memory leaks. If the -PHP processes were left around forever, they would be become very inefficient. diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index fb16f2b577..c885f30677 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -45,13 +45,9 @@ # include <unistd.h> #endif -#if HAVE_SIGNAL_H -# include <signal.h> -#endif +#include <signal.h> -#if HAVE_SETLOCALE -# include <locale.h> -#endif +#include <locale.h> #if HAVE_SYS_TYPES_H # include <sys/types.h> @@ -183,7 +179,7 @@ typedef struct _php_cgi_globals_struct { * Key for each cache entry is dirname(PATH_TRANSLATED). * * NOTE: Each cache entry config_hash contains the combination from all user ini files found in - * the path starting from doc_root throught to dirname(PATH_TRANSLATED). There is no point + * the path starting from doc_root through to dirname(PATH_TRANSLATED). There is no point * storing per-file entries as it would not be possible to detect added / deleted entries * between separate files. */ @@ -244,13 +240,6 @@ static void fcgi_log(int type, const char *format, ...) { } #endif -static int print_module_info(zval *element) -{ - zend_module_entry *module = Z_PTR_P(element); - php_printf("%s\n", module->name); - return ZEND_HASH_APPLY_KEEP; -} - static int module_name_cmp(const void *a, const void *b) { Bucket *f = (Bucket *) a; @@ -263,11 +252,14 @@ static int module_name_cmp(const void *a, const void *b) static void print_modules(void) { HashTable sorted_registry; + zend_module_entry *module; zend_hash_init(&sorted_registry, 64, NULL, NULL, 1); zend_hash_copy(&sorted_registry, &module_registry, NULL); zend_hash_sort(&sorted_registry, module_name_cmp, 0); - zend_hash_apply(&sorted_registry, print_module_info); + ZEND_HASH_FOREACH_PTR(&sorted_registry, module) { + php_printf("%s\n", module->name); + } ZEND_HASH_FOREACH_END(); zend_hash_destroy(&sorted_registry); } @@ -1536,7 +1528,7 @@ PHP_INI_END() */ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals) { -#ifdef ZTS +#if defined(ZTS) && defined(PHP_WIN32) ZEND_TSRMLS_CACHE_UPDATE(); #endif php_cgi_globals->rfc2616_headers = 0; @@ -1738,7 +1730,7 @@ static zend_module_entry cgi_module_entry = { NULL, NULL, PHP_MINFO(cgi), - NO_VERSION_YET, + PHP_VERSION, STANDARD_MODULE_PROPERTIES }; @@ -1783,7 +1775,6 @@ int main(int argc, char *argv[]) char *decoded_query_string; int skip_getopt = 0; -#ifdef HAVE_SIGNAL_H #if defined(SIGPIPE) && defined(SIG_IGN) signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so that sockets created via fsockopen() @@ -1792,12 +1783,12 @@ int main(int argc, char *argv[]) does that for us! thies@thieso.net 20000419 */ #endif -#endif #ifdef ZTS - tsrm_startup(1, 1, 0, NULL); - (void)ts_resource(0); + php_tsrm_startup(); +# ifdef PHP_WIN32 ZEND_TSRMLS_CACHE_UPDATE(); +# endif #endif zend_signal_startup(); @@ -1926,6 +1917,7 @@ int main(int argc, char *argv[]) #ifdef ZTS tsrm_shutdown(); #endif + free(bindpath); return FAILURE; } @@ -1965,6 +1957,7 @@ consult the installation file that came with this distribution, or visit \n\ */ tsrm_shutdown(); #endif + free(bindpath); return FAILURE; } } @@ -2155,6 +2148,7 @@ consult the installation file that came with this distribution, or visit \n\ char *err_text = php_win32_error_to_msg(err); fprintf(stderr, "unable to get current command line: [0x%08lx]: %s\n", err, err_text); + php_win32_error_msg_free(err_text); goto parent_out; } @@ -2173,6 +2167,8 @@ consult the installation file that came with this distribution, or visit \n\ fprintf(stderr, "unable to create job object: [0x%08lx]: %s\n", err, err_text); + php_win32_error_msg_free(err_text); + goto parent_out; } @@ -2182,6 +2178,7 @@ consult the installation file that came with this distribution, or visit \n\ char *err_text = php_win32_error_to_msg(err); fprintf(stderr, "unable to configure job object: [0x%08lx]: %s\n", err, err_text); + php_win32_error_msg_free(err_text); } while (parent) { @@ -2228,6 +2225,7 @@ consult the installation file that came with this distribution, or visit \n\ char *err_text = php_win32_error_to_msg(err); fprintf(stderr, "unable to assign child process to job object: [0x%08lx]: %s\n", err, err_text); + php_win32_error_msg_free(err_text); } CloseHandle(pi.hThread); } else { @@ -2237,6 +2235,7 @@ consult the installation file that came with this distribution, or visit \n\ kid_cgi_ps[i] = NULL; fprintf(stderr, "unable to spawn: [0x%08lx]: %s\n", err, err_text); + php_win32_error_msg_free(err_text); } } @@ -2342,6 +2341,7 @@ parent_loop_end: if (php_request_startup() == FAILURE) { SG(server_context) = NULL; php_module_shutdown(); + free(bindpath); return FAILURE; } if (no_headers) { @@ -2386,14 +2386,15 @@ parent_loop_end: if (php_request_startup() == FAILURE) { SG(server_context) = NULL; php_module_shutdown(); + free(bindpath); return FAILURE; } SG(headers_sent) = 1; SG(request_info).no_headers = 1; #if ZEND_DEBUG - php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2018 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #else - php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2018 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #endif php_request_shutdown((void *) 0); fcgi_shutdown(); @@ -2476,18 +2477,11 @@ parent_loop_end: we need in the environment. */ if (SG(request_info).path_translated || cgi || fastcgi) { - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = SG(request_info).path_translated; - file_handle.handle.fp = NULL; + zend_stream_init_filename(&file_handle, SG(request_info).path_translated); } else { - file_handle.filename = "Standard input code"; - file_handle.type = ZEND_HANDLE_FP; - file_handle.handle.fp = stdin; + zend_stream_init_fp(&file_handle, stdin, "Standard input code"); } - file_handle.opened_path = NULL; - file_handle.free_filename = 0; - /* request startup only after we've done all we can to * get path_translated */ if (php_request_startup() == FAILURE) { @@ -2544,83 +2538,13 @@ parent_loop_end: #ifdef ZTS tsrm_shutdown(); #endif + free(bindpath); return FAILURE; } } if (CGIG(check_shebang_line)) { - /* #!php support */ - switch (file_handle.type) { - case ZEND_HANDLE_FD: - if (file_handle.handle.fd < 0) { - break; - } - file_handle.type = ZEND_HANDLE_FP; - file_handle.handle.fp = fdopen(file_handle.handle.fd, "rb"); - /* break missing intentionally */ - case ZEND_HANDLE_FP: - if (!file_handle.handle.fp || - (file_handle.handle.fp == stdin)) { - break; - } - c = fgetc(file_handle.handle.fp); - if (c == '#') { - while (c != '\n' && c != '\r' && c != EOF) { - c = fgetc(file_handle.handle.fp); /* skip to end of line */ - } - /* handle situations where line is terminated by \r\n */ - if (c == '\r') { - if (fgetc(file_handle.handle.fp) != '\n') { - zend_long pos = zend_ftell(file_handle.handle.fp); - zend_fseek(file_handle.handle.fp, pos - 1, SEEK_SET); - } - } - CG(start_lineno) = 2; - } else { - rewind(file_handle.handle.fp); - } - break; - case ZEND_HANDLE_STREAM: - c = php_stream_getc((php_stream*)file_handle.handle.stream.handle); - if (c == '#') { - while (c != '\n' && c != '\r' && c != EOF) { - c = php_stream_getc((php_stream*)file_handle.handle.stream.handle); /* skip to end of line */ - } - /* handle situations where line is terminated by \r\n */ - if (c == '\r') { - if (php_stream_getc((php_stream*)file_handle.handle.stream.handle) != '\n') { - zend_off_t pos = php_stream_tell((php_stream*)file_handle.handle.stream.handle); - php_stream_seek((php_stream*)file_handle.handle.stream.handle, pos - 1, SEEK_SET); - } - } - CG(start_lineno) = 2; - } else { - php_stream_rewind((php_stream*)file_handle.handle.stream.handle); - } - break; - case ZEND_HANDLE_MAPPED: - if (file_handle.handle.stream.mmap.buf[0] == '#') { - size_t i = 1; - - c = file_handle.handle.stream.mmap.buf[i++]; - while (c != '\n' && c != '\r' && i < file_handle.handle.stream.mmap.len) { - c = file_handle.handle.stream.mmap.buf[i++]; - } - if (c == '\r') { - if (i < file_handle.handle.stream.mmap.len && file_handle.handle.stream.mmap.buf[i] == '\n') { - i++; - } - } - if(i > file_handle.handle.stream.mmap.len) { - i = file_handle.handle.stream.mmap.len; - } - file_handle.handle.stream.mmap.buf += i; - file_handle.handle.stream.mmap.len -= i; - } - break; - default: - break; - } + CG(skip_shebang) = 1; } switch (behavior) { @@ -2713,9 +2637,7 @@ fastcgi_request_done: requests++; if (max_requests && (requests == max_requests)) { fcgi_finish_request(request, 1); - if (bindpath) { - free(bindpath); - } + free(bindpath); if (max_requests != 1) { /* no need to return exit_status of the last request */ exit_status = 0; @@ -2779,12 +2701,3 @@ parent_out: return exit_status; } /* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/sapi/cgi/config9.m4 b/sapi/cgi/config9.m4 index bdf9edbdc1..04bd70b269 100644 --- a/sapi/cgi/config9.m4 +++ b/sapi/cgi/config9.m4 @@ -1,20 +1,13 @@ -dnl config.m4 for sapi cgi +PHP_ARG_ENABLE([cgi],, + [AS_HELP_STRING([--disable-cgi], + [Disable building CGI version of PHP])], + [yes], + [no]) -PHP_ARG_ENABLE(cgi,, -[ --disable-cgi Disable building CGI version of PHP], yes, no) - -dnl -dnl CGI setup -dnl +dnl CGI setup. AC_MSG_CHECKING(for CGI build) if test "$PHP_CGI" != "no"; then AC_MSG_RESULT(yes) - AC_MSG_CHECKING([for socklen_t in sys/socket.h]) - AC_EGREP_HEADER([socklen_t], [sys/socket.h], - [AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_SOCKLEN_T], [1], - [Define if the socklen_t typedef is in sys/socket.h])], - AC_MSG_RESULT([no])) AC_MSG_CHECKING([for sun_len in sys/un.h]) AC_EGREP_HEADER([sun_len], [sys/un.h], @@ -37,7 +30,7 @@ if test "$PHP_CGI" != "no"; then PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/cgi/Makefile.frag) - dnl Set filename + dnl Set filename. case $host_alias in *cygwin* ) SAPI_CGI_PATH=sapi/cgi/php-cgi.exe @@ -47,7 +40,7 @@ if test "$PHP_CGI" != "no"; then ;; esac - dnl Select SAPI + dnl Select SAPI. PHP_SELECT_SAPI(cgi, program, cgi_main.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, '$(SAPI_CGI_PATH)') case $host_alias in @@ -62,11 +55,11 @@ if test "$PHP_CGI" != "no"; then BUILD_CGI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_FASTCGI_OBJS:.lo=.o) \$(PHP_CGI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)" ;; *) - BUILD_CGI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_CGI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)" + BUILD_CGI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_FASTCGI_OBJS:.lo=.o) \$(PHP_CGI_OBJS:.lo=.o) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)" ;; esac - dnl Expose to Makefile + dnl Expose to Makefile. PHP_SUBST(SAPI_CGI_PATH) PHP_SUBST(BUILD_CGI) diff --git a/sapi/cgi/tests/001.phpt b/sapi/cgi/tests/001.phpt index 74c694f7c0..948f4ce304 100644 --- a/sapi/cgi/tests/001.phpt +++ b/sapi/cgi/tests/001.phpt @@ -16,7 +16,7 @@ echo "Done\n"; ?> --EXPECTF-- string(%d) "PHP %s (cgi%s (built: %s -Copyright (c) 1997-20%s The PHP Group -Zend Engine v%s, Copyright (c) 1998-20%s Zend Technologies +Copyright (c) The PHP Group +Zend Engine v%s, Copyright (c) Zend Technologies " Done diff --git a/sapi/cgi/tests/002.phpt b/sapi/cgi/tests/002.phpt index 91db184fcb..b28c865659 100644 --- a/sapi/cgi/tests/002.phpt +++ b/sapi/cgi/tests/002.phpt @@ -11,7 +11,7 @@ include "include.inc"; $php = get_cgi_path(); reset_env_vars(); -$file = dirname(__FILE__)."/002.test.php"; +$file = __DIR__."/002.test.php"; file_put_contents($file, '<?php var_dump(ini_get("max_execution_time")); ?>'); diff --git a/sapi/cgi/tests/003.phpt b/sapi/cgi/tests/003.phpt index a4d3058624..4b4d29267d 100644 --- a/sapi/cgi/tests/003.phpt +++ b/sapi/cgi/tests/003.phpt @@ -17,7 +17,7 @@ include "include.inc"; $php = get_cgi_path(); reset_env_vars(); -$filename = dirname(__FILE__).'/003.test.php'; +$filename = __DIR__.'/003.test.php'; $code =' <?php /* some test script */ diff --git a/sapi/cgi/tests/004.phpt b/sapi/cgi/tests/004.phpt index 93c48c9ff4..b46dce7052 100644 --- a/sapi/cgi/tests/004.phpt +++ b/sapi/cgi/tests/004.phpt @@ -12,12 +12,12 @@ include "include.inc"; $php = get_cgi_path(); reset_env_vars(); -$filename = dirname(__FILE__).'/004.test.php'; +$filename = __DIR__.'/004.test.php'; $code =' <?php -class test { - private $pri; +class test { + private $pri; } var_dump(test::$pri); diff --git a/sapi/cgi/tests/006.phpt b/sapi/cgi/tests/006.phpt index bc98656b49..c78229880c 100644 --- a/sapi/cgi/tests/006.phpt +++ b/sapi/cgi/tests/006.phpt @@ -11,7 +11,7 @@ include "include.inc"; $php = get_cgi_path(); reset_env_vars(); -$filename = dirname(__FILE__)."/006.test.php"; +$filename = __DIR__."/006.test.php"; $code = ' <?php diff --git a/sapi/cgi/tests/008.phpt b/sapi/cgi/tests/008.phpt index f0df0bae42..be2fd578e7 100644 --- a/sapi/cgi/tests/008.phpt +++ b/sapi/cgi/tests/008.phpt @@ -10,7 +10,7 @@ include "include.inc"; $php = get_cgi_path(); reset_env_vars(); -$filename = dirname(__FILE__)."/008.test.php"; +$filename = __DIR__."/008.test.php"; $code = ' <?php $test = "var"; //var diff --git a/sapi/cgi/tests/apache_request_headers.phpt b/sapi/cgi/tests/apache_request_headers.phpt index 3750600671..bda9ef8b70 100644 --- a/sapi/cgi/tests/apache_request_headers.phpt +++ b/sapi/cgi/tests/apache_request_headers.phpt @@ -13,7 +13,7 @@ include "include.inc"; $php = get_cgi_path(); reset_env_vars(); -$file = dirname(__FILE__)."/012.test.php"; +$file = __DIR__."/012.test.php"; file_put_contents($file, '<?php print_r(apache_request_headers()); ?>'); diff --git a/sapi/cgi/tests/apache_response_headers.phpt b/sapi/cgi/tests/apache_response_headers.phpt index 2964ac7bc7..99b1352680 100644 --- a/sapi/cgi/tests/apache_response_headers.phpt +++ b/sapi/cgi/tests/apache_response_headers.phpt @@ -11,7 +11,7 @@ include "include.inc"; $php = get_cgi_path(); reset_env_vars(); -$test_file = dirname(__FILE__) . DIRECTORY_SEPARATOR ."apache_response_headers.test.php"; +$test_file = __DIR__ . DIRECTORY_SEPARATOR ."apache_response_headers.test.php"; $code = '<?php'; $code .= ' @@ -34,7 +34,7 @@ passthru( "$php -n -q " . escapeshellarg( $test_file ) ); ===DONE=== --CLEAN-- <?php -@unlink( dirname(__FILE__) . DIRECTORY_SEPARATOR ."apache_response_headers.test.php" ); +@unlink( __DIR__ . DIRECTORY_SEPARATOR ."apache_response_headers.test.php" ); ?> --EXPECTF-- array(3) { diff --git a/sapi/cgi/tests/bug60677.phpt b/sapi/cgi/tests/bug60677.phpt new file mode 100644 index 0000000000..bc68ba86bf --- /dev/null +++ b/sapi/cgi/tests/bug60677.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #60677: CGI doesn't properly validate shebang line contains #! +--CGI-- +--FILE-- +#<?php echo "Hello World\n"; ?> +Second line. +--EXPECT-- +#Hello World +Second line. diff --git a/sapi/tests/bug69487.phpt b/sapi/cgi/tests/bug69487.phpt index 3ac3796826..3ac3796826 100644 --- a/sapi/tests/bug69487.phpt +++ b/sapi/cgi/tests/bug69487.phpt diff --git a/sapi/cgi/tests/bug75574_utf8_win.phpt b/sapi/cgi/tests/bug75574_utf8.phpt index c6e33e54ed..d7f0e3e5ee 100644 --- a/sapi/cgi/tests/bug75574_utf8_win.phpt +++ b/sapi/cgi/tests/bug75574_utf8.phpt @@ -2,10 +2,6 @@ Bug #75574 putenv does not work properly if parameter contains non-ASCII unicode character, UTF-8 --SKIPIF-- <?php - -if (substr(PHP_OS, 0, 3) != 'WIN') { - die("skip Valid only on Windows"); -} include "skipif.inc"; ?> --FILE-- @@ -20,7 +16,7 @@ include "include.inc"; $php = get_cgi_path(); reset_env_vars(); -$fn = dirname(__FILE__) . DIRECTORY_SEPARATOR . md5(uniqid()); +$fn = __DIR__ . DIRECTORY_SEPARATOR . md5(uniqid()); file_put_contents($fn, "<?php\nvar_dump(putenv('FOO=啊'));\n//var_dump(`echo %FOO%`);\nvar_dump(getenv('FOO'));"); echo shell_exec("$php -n -f $fn"); diff --git a/sapi/cli/README b/sapi/cli/README deleted file mode 100644 index 5b303aa82d..0000000000 --- a/sapi/cli/README +++ /dev/null @@ -1,20 +0,0 @@ -The CLI (command line interface) SAPI has been introduced -with a goal of making PHP better at supporting the creation of -stand alone applications. - -It is based on CGI SAPI with all CGI specific things removed. - -The main differences between the two: - -* CLI is started up in quiet mode by default. - (-q switch kept for compatibility) -* It does not change the working directory to that of the script. - (-C switch kept for compatibility) -* Plain text error message -* $argc and $argv registered irrespective of the register_argc_argv - php.ini setting. -* implicit_flush always on -* -r option which allows execution of PHP code directly from - the command line (e.g. php -r 'echo md5("test");' ) -* Other more sophisticated command line switches (see: man php) -* max_execution_time is set to unlimited, overriding php.ini setting. diff --git a/sapi/cli/cli.h b/sapi/cli/cli.h index 5cc39ff00b..b4c2851791 100644 --- a/sapi/cli/cli.h +++ b/sapi/cli/cli.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -39,12 +39,3 @@ typedef struct { extern PHP_CLI_API cli_shell_callbacks_t *php_cli_get_shell_callbacks(); #endif /* CLI_H */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4 index 93c9e7b702..d17d531683 100644 --- a/sapi/cli/config.m4 +++ b/sapi/cli/config.m4 @@ -1,8 +1,8 @@ -dnl config.m4 for sapi cli - -PHP_ARG_ENABLE(cli,, -[ --disable-cli Disable building CLI version of PHP - (this forces --without-pear)], yes, no) +PHP_ARG_ENABLE([cli],, + [AS_HELP_STRING([--disable-cli], + [Disable building CLI version of PHP (this forces --without-pear)])], + [yes], + [no]) AC_CHECK_FUNCS(setproctitle) @@ -24,10 +24,10 @@ AC_MSG_CHECKING(for CLI build) if test "$PHP_CLI" != "no"; then PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/cli/Makefile.frag) - dnl Set filename + dnl Set filename. SAPI_CLI_PATH=sapi/cli/php - dnl Select SAPI + dnl Select SAPI. PHP_SELECT_SAPI(cli, program, php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, '$(SAPI_CLI_PATH)') case $host_alias in @@ -42,15 +42,15 @@ if test "$PHP_CLI" != "no"; then BUILD_CLI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_CLI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" ;; *) - BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" + BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_CLI_OBJS:.lo=.o) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" ;; esac - dnl Set executable for tests + dnl Set executable for tests. PHP_EXECUTABLE="\$(top_builddir)/\$(SAPI_CLI_PATH)" PHP_SUBST(PHP_EXECUTABLE) - dnl Expose to Makefile + dnl Expose to Makefile. PHP_SUBST(SAPI_CLI_PATH) PHP_SUBST(BUILD_CLI) diff --git a/sapi/cli/generate_mime_type_map.php b/sapi/cli/generate_mime_type_map.php index 0cea031e37..b0176bb524 100644..100755 --- a/sapi/cli/generate_mime_type_map.php +++ b/sapi/cli/generate_mime_type_map.php @@ -45,7 +45,7 @@ foreach($additional_mime_maps as $ext => $mime) { +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -78,12 +78,3 @@ static const php_cli_server_ext_mime_type_pair mime_type_map[] = { }; #endif /* PHP_CLI_SERVER_MIME_TYPE_MAP_H */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/sapi/cli/mime_type_map.h b/sapi/cli/mime_type_map.h index 2b880b4c7f..0c559d635f 100644 --- a/sapi/cli/mime_type_map.h +++ b/sapi/cli/mime_type_map.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -1017,12 +1017,3 @@ static const php_cli_server_ext_mime_type_pair mime_type_map[] = { }; #endif /* PHP_CLI_SERVER_MIME_TYPE_MAP_H */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/sapi/cli/php.1.in b/sapi/cli/php.1.in index 88a43d30cb..400f7b000f 100644 --- a/sapi/cli/php.1.in +++ b/sapi/cli/php.1.in @@ -1,4 +1,4 @@ -.TH @program_prefix@php 1 "2018" "The PHP Group" "Scripting Language" +.TH @program_prefix@php 1 "2019" "The PHP Group" "Scripting Language" .SH NAME @program_prefix@php \- PHP Command Line Interface 'CLI' .P @@ -454,7 +454,7 @@ contributors all around the world. .SH VERSION INFORMATION This manpage describes \fBphp\fP, version @PHP_VERSION@. .SH COPYRIGHT -Copyright \(co 1997\-2018 The PHP Group +Copyright \(co The PHP Group .LP 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 diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 3b053e223a..a305c36ade 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -46,12 +46,9 @@ #if HAVE_UNISTD_H #include <unistd.h> #endif -#if HAVE_SIGNAL_H + #include <signal.h> -#endif -#if HAVE_SETLOCALE #include <locale.h> -#endif #include "zend.h" #include "zend_extensions.h" #include "php_ini.h" @@ -66,10 +63,6 @@ #include "win32/php_registry.h" #endif -#if HAVE_SIGNAL_H -#include <signal.h> -#endif - #ifdef __riscos__ #include <unixlib/local.h> #endif @@ -182,14 +175,6 @@ const opt_struct OPTIONS[] = { {'-', 0, NULL} /* end of args */ }; -static int print_module_info(zval *element) /* {{{ */ -{ - zend_module_entry *module = (zend_module_entry*)Z_PTR_P(element); - php_printf("%s\n", module->name); - return ZEND_HASH_APPLY_KEEP; -} -/* }}} */ - static int module_name_cmp(const void *a, const void *b) /* {{{ */ { Bucket *f = (Bucket *) a; @@ -203,11 +188,14 @@ static int module_name_cmp(const void *a, const void *b) /* {{{ */ static void print_modules(void) /* {{{ */ { HashTable sorted_registry; + zend_module_entry *module; zend_hash_init(&sorted_registry, 50, NULL, NULL, 0); zend_hash_copy(&sorted_registry, &module_registry, NULL); zend_hash_sort(&sorted_registry, module_name_cmp, 0); - zend_hash_apply(&sorted_registry, print_module_info); + ZEND_HASH_FOREACH_PTR(&sorted_registry, module) { + php_printf("%s\n", module->name); + } ZEND_HASH_FOREACH_END(); zend_hash_destroy(&sorted_registry); } /* }}} */ @@ -248,19 +236,18 @@ static void print_extensions(void) /* {{{ */ static inline int sapi_cli_select(php_socket_t fd) { - fd_set wfd, dfd; + fd_set wfd; struct timeval tv; int ret; FD_ZERO(&wfd); - FD_ZERO(&dfd); PHP_SAFE_FD_SET(fd, &wfd); tv.tv_sec = (long)FG(default_socket_timeout); tv.tv_usec = 0; - ret = php_select(fd+1, &dfd, &wfd, &dfd, &tv); + ret = php_select(fd+1, NULL, &wfd, NULL, &tv); return ret != -1; } @@ -599,39 +586,15 @@ static const char *param_mode_conflict = "Either execute direct code, process st /* {{{ cli_seek_file_begin */ -static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file, int *lineno) +static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file) { - int c; - - *lineno = 1; - - file_handle->type = ZEND_HANDLE_FP; - file_handle->opened_path = NULL; - file_handle->free_filename = 0; - if (!(file_handle->handle.fp = VCWD_FOPEN(script_file, "rb"))) { + FILE *fp = VCWD_FOPEN(script_file, "rb"); + if (!fp) { php_printf("Could not open input file: %s\n", script_file); return FAILURE; } - file_handle->filename = script_file; - - /* #!php support */ - c = fgetc(file_handle->handle.fp); - if (c == '#' && (c = fgetc(file_handle->handle.fp)) == '!') { - while (c != '\n' && c != '\r' && c != EOF) { - c = fgetc(file_handle->handle.fp); /* skip to end of line */ - } - /* handle situations where line is terminated by \r\n */ - if (c == '\r') { - if (fgetc(file_handle->handle.fp) != '\n') { - zend_long pos = zend_ftell(file_handle->handle.fp); - zend_fseek(file_handle->handle.fp, pos - 1, SEEK_SET); - } - } - *lineno = 2; - } else { - rewind(file_handle->handle.fp); - } + zend_stream_init_fp(file_handle, fp, script_file); return SUCCESS; } /* }}} */ @@ -661,7 +624,6 @@ static int do_cli(int argc, char **argv) /* {{{ */ char *arg_free=NULL, **arg_excp=&arg_free; char *script_file=NULL, *translated_path = NULL; int interactive=0; - int lineno = 0; const char *param_error=NULL; int hide_argv = 0; @@ -683,7 +645,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ goto out; case 'v': /* show php version & quit */ - php_printf("PHP %s (%s) (built: %s %s) ( %s)\nCopyright (c) 1997-2018 The PHP Group\n%s", + php_printf("PHP %s (%s) (built: %s %s) ( %s)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, cli_sapi_module.name, __DATE__, __TIME__, #if ZTS "ZTS " @@ -934,7 +896,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ php_optind++; } if (script_file) { - if (cli_seek_file_begin(&file_handle, script_file, &lineno) != SUCCESS) { + if (cli_seek_file_begin(&file_handle, script_file) != SUCCESS) { goto err; } else { char real_path[MAXPATHLEN]; @@ -948,12 +910,8 @@ static int do_cli(int argc, char **argv) /* {{{ */ /* here but this would make things only more complicated. And it */ /* is consitent with the way -R works where the stdin file handle*/ /* is also accessible. */ - file_handle.filename = "Standard input code"; - file_handle.handle.fp = stdin; + zend_stream_init_fp(&file_handle, stdin, "Standard input code"); } - file_handle.type = ZEND_HANDLE_FP; - file_handle.opened_path = NULL; - file_handle.free_filename = 0; php_self = (char*)file_handle.filename; /* before registering argv to module exchange the *new* argv[0] */ @@ -972,7 +930,13 @@ static int do_cli(int argc, char **argv) /* {{{ */ goto err; } request_started = 1; - CG(start_lineno) = lineno; + CG(skip_shebang) = 1; + + zend_register_bool_constant( + ZEND_STRL("PHP_CLI_PROCESS_TITLE"), + is_ps_title_available() == PS_TITLE_SUCCESS, + CONST_CS, 0); + *arg_excp = arg_free; /* reconstuct argv */ if (hide_argv) { @@ -1056,10 +1020,10 @@ static int do_cli(int argc, char **argv) /* {{{ */ } } else { if (script_file) { - if (cli_seek_file_begin(&file_handle, script_file, &lineno) != SUCCESS) { + if (cli_seek_file_begin(&file_handle, script_file) != SUCCESS) { exit_status = 1; } else { - CG(start_lineno) = lineno; + CG(skip_shebang) = 1; php_execute_script(&file_handle); exit_status = EG(exit_status); } @@ -1120,7 +1084,8 @@ static int do_cli(int argc, char **argv) /* {{{ */ zval_ptr_dtor(&tmp); EG(exception) = NULL; } else { - zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, &ref); + zend_print_zval(&ref, 0); + zend_write("\n", 1); } zval_ptr_dtor(&ref); zval_ptr_dtor(&arg); @@ -1238,7 +1203,6 @@ int main(int argc, char *argv[]) } #endif -#ifdef HAVE_SIGNAL_H #if defined(SIGPIPE) && defined(SIG_IGN) signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so that sockets created via fsockopen() @@ -1247,13 +1211,12 @@ int main(int argc, char *argv[]) does that for us! thies@thieso.net 20000419 */ #endif -#endif - #ifdef ZTS - tsrm_startup(1, 1, 0, NULL); - (void)ts_resource(0); + php_tsrm_startup(); +# ifdef PHP_WIN32 ZEND_TSRMLS_CACHE_UPDATE(); +# endif #endif zend_signal_startup(); @@ -1427,12 +1390,3 @@ out: exit(exit_status); } /* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/sapi/cli/php_cli_process_title.c b/sapi/cli/php_cli_process_title.c index a85370cbd5..1b82104ca6 100644 --- a/sapi/cli/php_cli_process_title.c +++ b/sapi/cli/php_cli_process_title.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -67,12 +67,3 @@ PHP_FUNCTION(cli_get_process_title) RETURN_STRINGL(title, length); } /* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/sapi/cli/php_cli_process_title.h b/sapi/cli/php_cli_process_title.h index 8882e3cd0e..c2fed7b817 100644 --- a/sapi/cli/php_cli_process_title.h +++ b/sapi/cli/php_cli_process_title.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -30,12 +30,3 @@ PHP_FUNCTION(cli_set_process_title); PHP_FUNCTION(cli_get_process_title); #endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 38cc094954..f00d8dee54 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -37,22 +37,16 @@ #include <unixlib/local.h> #endif - -#if HAVE_TIME_H -#include <time.h> -#endif #if HAVE_SYS_TIME_H #include <sys/time.h> #endif #if HAVE_UNISTD_H #include <unistd.h> #endif -#if HAVE_SIGNAL_H + #include <signal.h> -#endif -#if HAVE_SETLOCALE #include <locale.h> -#endif + #if HAVE_DLFCN_H #include <dlfcn.h> #endif @@ -107,6 +101,13 @@ #define OUTPUT_IS_TTY 1 #define OUTPUT_NOT_TTY 0 +#if HAVE_FORK +# include <sys/wait.h> +static pid_t php_cli_server_master; +static pid_t *php_cli_server_workers; +static zend_long php_cli_server_workers_max; +#endif + typedef struct php_cli_server_poller { fd_set rfds, wfds; struct { @@ -208,6 +209,12 @@ static php_cli_server_http_response_status_code_pair template_map[] = { { 501, "<h1>%s</h1><p>Request method not supported.</p>" } }; +#define PHP_CLI_SERVER_LOG_PROCESS 1 +#define PHP_CLI_SERVER_LOG_ERROR 2 +#define PHP_CLI_SERVER_LOG_MESSAGE 3 + +static int php_cli_server_log_level = 3; + #if HAVE_UNISTD_H static int php_cli_output_is_tty = OUTPUT_NOT_CHECKED; #endif @@ -217,7 +224,7 @@ static const char php_cli_server_request_error_unexpected_eof[] = "Unexpected EO static size_t php_cli_server_client_send_through(php_cli_server_client *client, const char *str, size_t str_len); static php_cli_server_chunk *php_cli_server_chunk_heap_new_self_contained(size_t len); static void php_cli_server_buffer_append(php_cli_server_buffer *buffer, php_cli_server_chunk *chunk); -static void php_cli_server_logf(const char *format, ...); +static void php_cli_server_logf(int type, const char *format, ...); static void php_cli_server_log_response(php_cli_server_client *client, int status, const char *message); ZEND_DECLARE_MODULE_GLOBALS(cli_server); @@ -489,9 +496,57 @@ const zend_function_entry server_additional_functions[] = { static int sapi_cli_server_startup(sapi_module_struct *sapi_module) /* {{{ */ { + char *workers; + if (php_module_startup(sapi_module, &cli_server_module_entry, 1) == FAILURE) { return FAILURE; } + + if ((workers = getenv("PHP_CLI_SERVER_WORKERS"))) { +#ifndef SO_REUSEPORT + fprintf(stderr, "platform does not support SO_REUSEPORT, cannot create workers\n"); +#elif HAVE_FORK + ZEND_ATOL(php_cli_server_workers_max, workers); + + if (php_cli_server_workers_max > 1) { + zend_long php_cli_server_worker; + + php_cli_server_workers = calloc( + php_cli_server_workers_max, sizeof(pid_t)); + if (!php_cli_server_workers) { + php_cli_server_workers_max = 1; + + return SUCCESS; + } + + php_cli_server_master = getpid(); + + for (php_cli_server_worker = 0; + php_cli_server_worker < php_cli_server_workers_max; + php_cli_server_worker++) { + pid_t pid = fork(); + + if (pid == FAILURE) { + /* no more forks allowed, work with what we have ... */ + php_cli_server_workers_max = + php_cli_server_worker + 1; + return SUCCESS; + } else if (pid == SUCCESS) { + return SUCCESS; + } else { + php_cli_server_workers[ + php_cli_server_worker + ] = pid; + } + } + } else { + fprintf(stderr, "number of workers must be larger than 1\n"); + } +#else + fprintf(stderr, "forking is not supported on this platform\n"); +#endif + } + return SUCCESS; } /* }}} */ @@ -695,10 +750,14 @@ static void sapi_cli_server_register_variables(zval *track_vars_array) /* {{{ */ zend_hash_apply_with_arguments(&client->request.headers, (apply_func_args_t)sapi_cli_server_register_entry_cb, 1, track_vars_array); } /* }}} */ -static void sapi_cli_server_log_message(char *msg, int syslog_type_int) /* {{{ */ +static void sapi_cli_server_log_write(int type, char *msg) /* {{{ */ { char buf[52]; + if (php_cli_server_log_level < type) { + return; + } + if (php_cli_server_get_system_time(buf) != 0) { memmove(buf, "unknown time, can't be fetched", sizeof("unknown time, can't be fetched")); } else { @@ -709,7 +768,20 @@ static void sapi_cli_server_log_message(char *msg, int syslog_type_int) /* {{{ * memmove(buf, "unknown", sizeof("unknown")); } } +#ifdef HAVE_FORK + if (php_cli_server_workers_max > 1) { + fprintf(stderr, "[%ld] [%s] %s\n", (long) getpid(), buf, msg); + } else { + fprintf(stderr, "[%s] %s\n", buf, msg); + } +#else fprintf(stderr, "[%s] %s\n", buf, msg); +#endif +} /* }}} */ + +static void sapi_cli_server_log_message(char *msg, int syslog_type_int) /* {{{ */ +{ + sapi_cli_server_log_write(PHP_CLI_SERVER_LOG_MESSAGE, msg); } /* }}} */ /* {{{ sapi_module_struct cli_server_sapi_module @@ -844,14 +916,14 @@ static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, v for (fd=0 ; fd<=max_fd ; fd++) { if (PHP_SAFE_FD_ISSET(fd, &poller->active.rfds)) { - if (SUCCESS != callback(opaque, fd, POLLIN)) { - retval = FAILURE; - } + if (SUCCESS != callback(opaque, fd, POLLIN)) { + retval = FAILURE; + } } if (PHP_SAFE_FD_ISSET(fd, &poller->active.wfds)) { - if (SUCCESS != callback(opaque, fd, POLLOUT)) { - retval = FAILURE; - } + if (SUCCESS != callback(opaque, fd, POLLOUT)) { + retval = FAILURE; + } } } #endif @@ -1064,9 +1136,11 @@ static int php_cli_server_content_sender_pull(php_cli_server_content_sender *sen _nbytes_read = read(fd, chunk->data.heap.p, chunk->data.heap.len); #endif if (_nbytes_read < 0) { - char *errstr = get_last_error(); - php_cli_server_logf("%s", errstr); - pefree(errstr, 1); + if (php_cli_server_log_level >= PHP_CLI_SERVER_LOG_ERROR) { + char *errstr = get_last_error(); + php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "%s", errstr); + pefree(errstr, 1); + } php_cli_server_chunk_dtor(chunk); pefree(chunk, 1); return 1; @@ -1126,7 +1200,7 @@ static void php_cli_server_log_response(php_cli_server_client *client, int statu #endif /* basic */ - spprintf(&basic_buf, 0, "%s [%d]: %s", client->addr_str, status, client->request.request_uri); + spprintf(&basic_buf, 0, "%s [%d]: %s %s", client->addr_str, status, SG(request_info).request_method, client->request.request_uri); if (!basic_buf) { return; } @@ -1153,9 +1227,9 @@ static void php_cli_server_log_response(php_cli_server_client *client, int statu } if (color) { - php_cli_server_logf("\x1b[3%dm%s%s%s\x1b[0m", color, basic_buf, message_buf, error_buf); + php_cli_server_logf(PHP_CLI_SERVER_LOG_MESSAGE, "\x1b[3%dm%s%s%s\x1b[0m", color, basic_buf, message_buf, error_buf); } else { - php_cli_server_logf("%s%s%s", basic_buf, message_buf, error_buf); + php_cli_server_logf(PHP_CLI_SERVER_LOG_MESSAGE, "%s%s%s", basic_buf, message_buf, error_buf); } efree(basic_buf); @@ -1167,11 +1241,15 @@ static void php_cli_server_log_response(php_cli_server_client *client, int statu } } /* }}} */ -static void php_cli_server_logf(const char *format, ...) /* {{{ */ +static void php_cli_server_logf(int type, const char *format, ...) /* {{{ */ { char *buf = NULL; va_list ap; + if (php_cli_server_log_level < type) { + return; + } + va_start(ap, format); vspprintf(&buf, 0, format, ap); va_end(ap); @@ -1180,9 +1258,7 @@ static void php_cli_server_logf(const char *format, ...) /* {{{ */ return; } - if (sapi_module.log_message) { - sapi_module.log_message(buf, -1); - } + sapi_cli_server_log_write(type, buf); efree(buf); } /* }}} */ @@ -1237,6 +1313,13 @@ static php_socket_t php_network_listen_socket(const char *host, int *port, int s } #endif +#if defined(HAVE_FORK) && defined(SO_REUSEPORT) + if (php_cli_server_workers_max > 1) { + int val = 1; + setsockopt(retval, SOL_SOCKET, SO_REUSEPORT, (char*)&val, sizeof(val)); + } +#endif + if (bind(retval, sa, *socklen) == SOCK_CONN_ERR) { err = php_socket_errno(); if (err == SOCK_EINVAL || err == SOCK_EADDRINUSE) { @@ -1299,9 +1382,6 @@ out: static int php_cli_server_request_ctor(php_cli_server_request *req) /* {{{ */ { -#ifdef ZTS -ZEND_TSRMLS_CACHE_UPDATE(); -#endif req->protocol_version = 0; req->request_uri = NULL; req->request_uri_len = 0; @@ -1457,6 +1537,7 @@ static void normalize_vpath(char **retval, size_t *retval_len, const char *vpath char *p; *retval = NULL; + *retval_len = 0; decoded_vpath = pestrndup(vpath, vpath_len, persistent); if (!decoded_vpath) { @@ -1736,20 +1817,30 @@ static int php_cli_server_client_read_request(php_cli_server_client *client, cha if (err == SOCK_EAGAIN) { return 0; } - *errstr = php_socket_strerror(err, NULL, 0); + + if (php_cli_server_log_level >= PHP_CLI_SERVER_LOG_ERROR) { + *errstr = php_socket_strerror(err, NULL, 0); + } + return -1; } else if (nbytes_read == 0) { - *errstr = estrdup(php_cli_server_request_error_unexpected_eof); + if (php_cli_server_log_level >= PHP_CLI_SERVER_LOG_ERROR) { + *errstr = estrdup(php_cli_server_request_error_unexpected_eof); + } + return -1; } client->parser.data = client; nbytes_consumed = php_http_parser_execute(&client->parser, &settings, buf, nbytes_read); if (nbytes_consumed != (size_t)nbytes_read) { - if (buf[0] & 0x80 /* SSLv2 */ || buf[0] == 0x16 /* SSLv3/TLSv1 */) { - *errstr = estrdup("Unsupported SSL request"); - } else { - *errstr = estrdup("Malformed HTTP request"); + if (php_cli_server_log_level >= PHP_CLI_SERVER_LOG_ERROR) { + if (buf[0] & 0x80 /* SSLv2 */ || buf[0] == 0x16 /* SSLv3/TLSv1 */) { + *errstr = estrdup("Unsupported SSL request"); + } else { + *errstr = estrdup("Malformed HTTP request"); + } } + return -1; } if (client->current_header_name) { @@ -1873,9 +1964,8 @@ static void php_cli_server_client_dtor(php_cli_server_client *client) /* {{{ */ static void php_cli_server_close_connection(php_cli_server *server, php_cli_server_client *client) /* {{{ */ { -#if PHP_DEBUG - php_cli_server_logf("%s Closing", client->addr_str); -#endif + php_cli_server_logf(PHP_CLI_SERVER_LOG_MESSAGE, "%s Closing", client->addr_str); + zend_hash_index_del(&server->clients, client->sock); } /* }}} */ @@ -1982,11 +2072,7 @@ static int php_cli_server_dispatch_script(php_cli_server *server, php_cli_server } { zend_file_handle zfd; - zfd.type = ZEND_HANDLE_FILENAME; - zfd.filename = SG(request_info).path_translated; - zfd.handle.fp = NULL; - zfd.free_filename = 0; - zfd.opened_path = NULL; + zend_stream_init_filename(&zfd, SG(request_info).path_translated); zend_try { php_execute_script(&zfd); } zend_end_try(); @@ -2107,11 +2193,7 @@ static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server old_cwd[0] = '\0'; php_ignore_value(VCWD_GETCWD(old_cwd, MAXPATHLEN - 1)); - zfd.type = ZEND_HANDLE_FILENAME; - zfd.filename = server->router; - zfd.handle.fp = NULL; - zfd.free_filename = 0; - zfd.opened_path = NULL; + zend_stream_init_filename(&zfd, server->router); zend_try { zval retval; @@ -2176,12 +2258,12 @@ static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client static int (*send_header_func)(sapi_headers_struct *); send_header_func = sapi_module.send_headers; /* do not generate default content type header */ - SG(sapi_headers).send_default_content_type = 0; + SG(sapi_headers).send_default_content_type = 0; /* we don't want headers to be sent */ sapi_module.send_headers = sapi_cli_server_discard_headers; php_request_shutdown(0); sapi_module.send_headers = send_header_func; - SG(sapi_headers).send_default_content_type = 1; + SG(sapi_headers).send_default_content_type = 1; SG(rfc1867_uploaded_files) = NULL; } if (SUCCESS != php_cli_server_begin_send_static(server, client)) { @@ -2227,12 +2309,39 @@ static void php_cli_server_dtor(php_cli_server *server) /* {{{ */ if (server->router) { pefree(server->router, 1); } +#if HAVE_FORK + if (php_cli_server_workers_max > 1 && + php_cli_server_workers && + getpid() == php_cli_server_master) { + zend_long php_cli_server_worker; + + for (php_cli_server_worker = 0; + php_cli_server_worker < php_cli_server_workers_max; + php_cli_server_worker++) { + int php_cli_server_worker_status; + + do { + if (waitpid(php_cli_server_workers[php_cli_server_worker], + &php_cli_server_worker_status, + 0) == FAILURE) { + /* an extremely bad thing happened */ + break; + } + + } while (!WIFEXITED(php_cli_server_worker_status) && + !WIFSIGNALED(php_cli_server_worker_status)); + } + + free(php_cli_server_workers); + } +#endif } /* }}} */ static void php_cli_server_client_dtor_wrapper(zval *zv) /* {{{ */ { php_cli_server_client *p = Z_PTR_P(zv); + shutdown(p->sock, SHUT_RDWR); closesocket(p->sock); php_cli_server_poller_remove(&p->server->poller, POLLIN | POLLOUT, p->sock); php_cli_server_client_dtor(p); @@ -2290,7 +2399,7 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c server_sock = php_network_listen_socket(host, &port, SOCK_STREAM, &server->address_family, &server->socklen, &errstr); if (server_sock == SOCK_ERR) { - php_cli_server_logf("Failed to listen on %s:%d (reason: %s)", host, port, errstr ? ZSTR_VAL(errstr) : "?"); + php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "Failed to listen on %s:%d (reason: %s)", host, port, errstr ? ZSTR_VAL(errstr) : "?"); if (errstr) { zend_string_release_ex(errstr, 0); } @@ -2365,14 +2474,15 @@ static int php_cli_server_recv_event_read_request(php_cli_server *server, php_cl char *errstr = NULL; int status = php_cli_server_client_read_request(client, &errstr); if (status < 0) { - if (strcmp(errstr, php_cli_server_request_error_unexpected_eof) == 0 && client->parser.state == s_start_req) { -#if PHP_DEBUG - php_cli_server_logf("%s Closed without sending a request; it was probably just an unused speculative preconnection", client->addr_str); -#endif - } else { - php_cli_server_logf("%s Invalid request (%s)", client->addr_str, errstr); + if (errstr) { + if (strcmp(errstr, php_cli_server_request_error_unexpected_eof) == 0 && client->parser.state == s_start_req) { + php_cli_server_logf(PHP_CLI_SERVER_LOG_MESSAGE, + "%s Closed without sending a request; it was probably just an unused speculative preconnection", client->addr_str); + } else { + php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "%s Invalid request (%s)", client->addr_str, errstr); + } + efree(errstr); } - efree(errstr); php_cli_server_close_connection(server, client); return FAILURE; } else if (status == 1 && client->request.request_method == PHP_HTTP_NOT_IMPLEMENTED) { @@ -2434,10 +2544,12 @@ static int php_cli_server_do_event_for_each_fd_callback(void *_params, php_socke struct sockaddr *sa = pemalloc(server->socklen, 1); client_sock = accept(server->server_sock, sa, &socklen); if (!ZEND_VALID_SOCKET(client_sock)) { - char *errstr; - errstr = php_socket_strerror(php_socket_errno(), NULL, 0); - php_cli_server_logf("Failed to accept a client (reason: %s)", errstr); - efree(errstr); + if (php_cli_server_log_level >= PHP_CLI_SERVER_LOG_ERROR) { + char *errstr = php_socket_strerror(php_socket_errno(), NULL, 0); + php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, + "Failed to accept a client (reason: %s)", errstr); + efree(errstr); + } pefree(sa, 1); return SUCCESS; } @@ -2448,16 +2560,17 @@ static int php_cli_server_do_event_for_each_fd_callback(void *_params, php_socke } client = pemalloc(sizeof(php_cli_server_client), 1); if (FAILURE == php_cli_server_client_ctor(client, server, client_sock, sa, socklen)) { - php_cli_server_logf("Failed to create a new request object"); + php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "Failed to create a new request object"); pefree(sa, 1); closesocket(client_sock); return SUCCESS; } -#if PHP_DEBUG - php_cli_server_logf("%s Accepted", client->addr_str); -#endif + + php_cli_server_logf(PHP_CLI_SERVER_LOG_MESSAGE, "%s Accepted", client->addr_str); + zend_hash_index_update_ptr(&server->clients, client_sock, client); - php_cli_server_recv_event_read_request(server, client); + + php_cli_server_poller_add(&server->poller, POLLIN, client->sock); } else { php_cli_server_client *client; if (NULL != (client = zend_hash_index_find_ptr(&server->clients, fd))) { @@ -2498,9 +2611,11 @@ static int php_cli_server_do_event_loop(php_cli_server *server) /* {{{ */ } else { int err = php_socket_errno(); if (err != SOCK_EINTR) { - char *errstr = php_socket_strerror(err, NULL, 0); - php_cli_server_logf("%s", errstr); - efree(errstr); + if (php_cli_server_log_level >= PHP_CLI_SERVER_LOG_ERROR) { + char *errstr = php_socket_strerror(err, NULL, 0); + php_cli_server_logf(PHP_CLI_SERVER_LOG_ERROR, "%s", errstr); + efree(errstr); + } retval = FAILURE; goto out; } @@ -2557,6 +2672,11 @@ int do_cli_server(int argc, char **argv) /* {{{ */ document_root = document_root_tmp; #endif break; + case 'q': + if (php_cli_server_log_level > 1) { + php_cli_server_log_level--; + } + break; } } @@ -2595,33 +2715,23 @@ int do_cli_server(int argc, char **argv) /* {{{ */ sapi_module.phpinfo_as_text = 0; { - char buf[52]; - - if (php_cli_server_get_system_time(buf) != 0) { - memmove(buf, "unknown time, can't be fetched", sizeof("unknown time, can't be fetched")); - } - - printf("PHP %s Development Server started at %s" - "Listening on http://%s\n" - "Document root is %s\n" - "Press Ctrl-C to quit.\n", - PHP_VERSION, buf, server_bind_address, document_root); + php_cli_server_logf( + PHP_CLI_SERVER_LOG_PROCESS, + "PHP %s Development Server (http://%s) started", + PHP_VERSION, server_bind_address); } -#if defined(HAVE_SIGNAL_H) && defined(SIGINT) +#if defined(SIGINT) signal(SIGINT, php_cli_server_sigint_handler); - zend_signal_init(); #endif + +#if defined(SIGPIPE) + signal(SIGPIPE, SIG_IGN); +#endif + + zend_signal_init(); + php_cli_server_do_event_loop(&server); php_cli_server_dtor(&server); return 0; } /* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/sapi/cli/php_cli_server.h b/sapi/cli/php_cli_server.h index 2a68894479..4d57f1b922 100644 --- a/sapi/cli/php_cli_server.h +++ b/sapi/cli/php_cli_server.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -37,12 +37,3 @@ ZEND_TSRMLS_CACHE_EXTERN() #endif #endif /* PHP_CLI_SERVER_H */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/sapi/cli/ps_title.h b/sapi/cli/ps_title.h index bc18470ce1..540609c85d 100644 --- a/sapi/cli/ps_title.h +++ b/sapi/cli/ps_title.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/cli/tests/001.phpt b/sapi/cli/tests/001.phpt index 744918a373..ede63ffb03 100644 --- a/sapi/cli/tests/001.phpt +++ b/sapi/cli/tests/001.phpt @@ -13,7 +13,7 @@ echo "Done\n"; ?> --EXPECTF-- string(%d) "PHP %s (cli) (built: %s)%s -Copyright (c) 1997-20%d The PHP Group -Zend Engine v%s, Copyright (c) 1998-20%d Zend Technologies +Copyright (c) The PHP Group +Zend Engine v%s, Copyright (c) Zend Technologies " Done diff --git a/sapi/cli/tests/002-win32.phpt b/sapi/cli/tests/002-unix.phpt index 2895d15211..2be668f188 100644 --- a/sapi/cli/tests/002-win32.phpt +++ b/sapi/cli/tests/002-unix.phpt @@ -3,8 +3,8 @@ running code with -r --SKIPIF-- <?php include "skipif.inc"; -if (substr(PHP_OS, 0, 3) != 'WIN') { - die ("skip only for Windows"); +if (substr(PHP_OS, 0, 3) == 'WIN') { + die ("skip not for Windows"); } ?> --FILE-- @@ -12,7 +12,7 @@ if (substr(PHP_OS, 0, 3) != 'WIN') { $php = getenv('TEST_PHP_EXECUTABLE'); -var_dump(`$php -n -r "var_dump('hello');"`); +var_dump(`$php -n -r 'var_dump("hello");'`); echo "Done\n"; ?> diff --git a/sapi/cli/tests/002.phpt b/sapi/cli/tests/002.phpt index 2be668f188..9fb2465ee4 100644 --- a/sapi/cli/tests/002.phpt +++ b/sapi/cli/tests/002.phpt @@ -3,16 +3,13 @@ running code with -r --SKIPIF-- <?php include "skipif.inc"; -if (substr(PHP_OS, 0, 3) == 'WIN') { - die ("skip not for Windows"); -} ?> --FILE-- <?php $php = getenv('TEST_PHP_EXECUTABLE'); -var_dump(`$php -n -r 'var_dump("hello");'`); +var_dump(`$php -n -r "var_dump('hello');"`); echo "Done\n"; ?> diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt index 6a980b8c45..54d1a96a88 100644 --- a/sapi/cli/tests/006.phpt +++ b/sapi/cli/tests/006.phpt @@ -97,21 +97,23 @@ string(%d) "Extension [ <persistent> extension #%d pcre version %s ] { } Function [ <internal:pcre> function preg_replace_callback ] { - - Parameters [5] { + - Parameters [6] { Parameter #0 [ <required> $regex ] Parameter #1 [ <required> $callback ] Parameter #2 [ <required> $subject ] Parameter #3 [ <optional> $limit ] Parameter #4 [ <optional> &$count ] + Parameter #5 [ <optional> $flags ] } } Function [ <internal:pcre> function preg_replace_callback_array ] { - - Parameters [4] { + - Parameters [5] { Parameter #0 [ <required> $pattern ] Parameter #1 [ <required> $subject ] Parameter #2 [ <optional> $limit ] Parameter #3 [ <optional> &$count ] + Parameter #4 [ <optional> $flags ] } } Function [ <internal:pcre> function preg_filter ] { diff --git a/sapi/cli/tests/007.phpt b/sapi/cli/tests/007.phpt index dd8e17163c..51858bae48 100644 --- a/sapi/cli/tests/007.phpt +++ b/sapi/cli/tests/007.phpt @@ -12,7 +12,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { $php = getenv('TEST_PHP_EXECUTABLE'); -$filename = dirname(__FILE__).'/007.test.php'; +$filename = __DIR__.'/007.test.php'; $code =' <?php /* some test script */ diff --git a/sapi/cli/tests/008.phpt b/sapi/cli/tests/008.phpt index 429254f4d6..fb8518535a 100644 --- a/sapi/cli/tests/008.phpt +++ b/sapi/cli/tests/008.phpt @@ -12,12 +12,12 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { $php = getenv('TEST_PHP_EXECUTABLE'); -$filename = dirname(__FILE__).'/008.test.php'; +$filename = __DIR__.'/008.test.php'; $code =' <?php -class test { - private $pri; +class test { + private $pri; } var_dump(test::$pri); diff --git a/sapi/cli/tests/010-2.phpt b/sapi/cli/tests/010-2.phpt index 73198ad28b..af998351bb 100644 --- a/sapi/cli/tests/010-2.phpt +++ b/sapi/cli/tests/010-2.phpt @@ -12,7 +12,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { $php = getenv('TEST_PHP_EXECUTABLE'); -$filename_txt = dirname(__FILE__)."/010.test.txt"; +$filename_txt = __DIR__."/010.test.txt"; $txt = ' test diff --git a/sapi/cli/tests/011.phpt b/sapi/cli/tests/011.phpt index 1fbe93d703..3ada7c53bf 100644 --- a/sapi/cli/tests/011.phpt +++ b/sapi/cli/tests/011.phpt @@ -7,7 +7,7 @@ syntax check $php = getenv('TEST_PHP_EXECUTABLE'); -$filename = dirname(__FILE__)."/011.test.php"; +$filename = __DIR__."/011.test.php"; $code = ' <?php diff --git a/sapi/cli/tests/013.phpt b/sapi/cli/tests/013.phpt index 9e17c009c2..3ca2ba833c 100644 --- a/sapi/cli/tests/013.phpt +++ b/sapi/cli/tests/013.phpt @@ -12,7 +12,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { $php = getenv('TEST_PHP_EXECUTABLE'); -$filename_txt = dirname(__FILE__)."/013.test.txt"; +$filename_txt = __DIR__."/013.test.txt"; file_put_contents($filename_txt, "test\nfile\ncontents\n"); var_dump(`cat "$filename_txt" | "$php" -n -B 'var_dump("start");'`); diff --git a/sapi/cli/tests/014.phpt b/sapi/cli/tests/014.phpt index 1794d78b54..1ee72e05f6 100644 --- a/sapi/cli/tests/014.phpt +++ b/sapi/cli/tests/014.phpt @@ -7,7 +7,7 @@ syntax highlighting $php = getenv('TEST_PHP_EXECUTABLE'); -$filename = dirname(__FILE__)."/014.test.php"; +$filename = __DIR__."/014.test.php"; $code = ' <?php $test = "var"; //var diff --git a/sapi/cli/tests/022.phpt b/sapi/cli/tests/022.phpt index 0110220bee..3b97016b58 100644 --- a/sapi/cli/tests/022.phpt +++ b/sapi/cli/tests/022.phpt @@ -9,7 +9,7 @@ if (substr(PHP_OS, 0, 3) == "WIN") die("skip non windows test"); <?php $php = getenv("TEST_PHP_EXECUTABLE"); $socket_file = tempnam(sys_get_temp_dir(), pathinfo(__FILE__, PATHINFO_FILENAME) . '.sock'); -$test_file = dirname(__FILE__) . '/' . pathinfo(__FILE__, PATHINFO_FILENAME) . '.inc'; +$test_file = __DIR__ . '/' . pathinfo(__FILE__, PATHINFO_FILENAME) . '.inc'; if (file_exists($socket_file)) { unlink($socket_file); } diff --git a/sapi/cli/tests/CONFLICTS b/sapi/cli/tests/CONFLICTS new file mode 100644 index 0000000000..254defddb5 --- /dev/null +++ b/sapi/cli/tests/CONFLICTS @@ -0,0 +1 @@ +server diff --git a/sapi/cli/tests/argv_mb.phpt b/sapi/cli/tests/argv_mb.phpt index 2e14b1a192..868b1a857f 100644 --- a/sapi/cli/tests/argv_mb.phpt +++ b/sapi/cli/tests/argv_mb.phpt @@ -3,16 +3,13 @@ Test basic argv multibyte API integration --SKIPIF-- <?php include "skipif.inc"; -if (substr(PHP_OS, 0, 3) != 'WIN') { - die ("skip only for Windows"); -} ?> --FILE-- <?php $php = getenv('TEST_PHP_EXECUTABLE'); -$argv_fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "argv_test.php"; +$argv_fl = __DIR__ . DIRECTORY_SEPARATOR . "argv_test.php"; file_put_contents($argv_fl, "<?php var_dump(\$argv); ?>"); var_dump(`$php -n $argv_fl 多字节字符串 マルチバイト文字列 многобайтоваястрока flerbytesträng`); diff --git a/sapi/cli/tests/argv_mb_bug77111.phpt b/sapi/cli/tests/argv_mb_bug77111.phpt index e21cc07678..45913b841f 100644 --- a/sapi/cli/tests/argv_mb_bug77111.phpt +++ b/sapi/cli/tests/argv_mb_bug77111.phpt @@ -19,9 +19,9 @@ if (!file_exists($php)) { $php = dirname(getenv('TEST_PHP_EXECUTABLE')) . DIRECTORY_SEPARATOR . "php-win.exe"; -$out_fl = dirname(__FILE__) . "\\argv_bug77111.txt"; +$out_fl = __DIR__ . "\\argv_bug77111.txt"; -$argv_fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "argv_test.php"; +$argv_fl = __DIR__ . DIRECTORY_SEPARATOR . "argv_test.php"; file_put_contents($argv_fl, "<?php file_put_contents('$out_fl', implode(' ', array_slice(\$argv, 1))); ?>"); `$php -n $argv_fl Ästhetik Æstetik Esthétique Estética Эстетика`; @@ -31,8 +31,8 @@ var_dump(file_get_contents($out_fl)); ==DONE== --CLEAN-- <?php -$out_fl = dirname(__FILE__) . "\\argv_bug77111.txt"; -$argv_fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "argv_test.php"; +$out_fl = __DIR__ . "\\argv_bug77111.txt"; +$argv_fl = __DIR__ . DIRECTORY_SEPARATOR . "argv_test.php"; unlink($argv_fl); unlink($out_fl); ?> diff --git a/sapi/cli/tests/bug66606_1.phpt b/sapi/cli/tests/bug66606_1.phpt index b58db6cfdd..cd278dad42 100644 --- a/sapi/cli/tests/bug66606_1.phpt +++ b/sapi/cli/tests/bug66606_1.phpt @@ -9,9 +9,9 @@ include "skipif.inc"; --FILE-- <?php include "php_cli_server.inc"; -php_cli_server_start('var_dump($_SERVER["CONTENT_TYPE"], $_SERVER["CONTENT_LENGTH"])'); +php_cli_server_start('var_dump(isset($_SERVER["CONTENT_TYPE"]), isset($_SERVER["CONTENT_LENGTH"]))'); echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS); ?> --EXPECT-- -NULL -NULL +bool(false) +bool(false) diff --git a/sapi/cli/tests/bug67429.phpt b/sapi/cli/tests/bug67429.phpt deleted file mode 100644 index a047de6e31..0000000000 --- a/sapi/cli/tests/bug67429.phpt +++ /dev/null @@ -1,55 +0,0 @@ ---TEST-- -FR #67429 (CLI server is missing some new HTTP response codes) ---SKIPIF-- -<?php -include "skipif.inc"; -?> ---FILE-- -<?php -include "php_cli_server.inc"; - -// This creates a new server for each response code -foreach ([308, 426] as $code) { - $proc_handle = php_cli_server_start(<<<PHP -http_response_code($code); -PHP - ); - - list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); - $port = intval($port)?:80; - - $fp = fsockopen($host, $port, $errno, $errstr, 0.5); - if (!$fp) { - die("connect failed"); - } - - if(fwrite($fp, <<<HEADER -GET / HTTP/1.1 - - -HEADER - )) { - while (!feof($fp)) { - echo fgets($fp); - } - } - - fclose($fp); - // Shutdown the servers or another server may not be able to start - // because of the this server still being bound to the port - - php_cli_server_stop($proc_handle); -} -?> ---EXPECTF-- -HTTP/1.1 308 Permanent Redirect -Date: %s -Connection: close -X-Powered-By: %s -Content-type: text/html; charset=UTF-8 - -HTTP/1.1 426 Upgrade Required -Date: %s -Connection: close -X-Powered-By: %s -Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug67429_1.phpt b/sapi/cli/tests/bug67429_1.phpt new file mode 100644 index 0000000000..8f3d6c79bc --- /dev/null +++ b/sapi/cli/tests/bug67429_1.phpt @@ -0,0 +1,42 @@ +--TEST-- +FR #67429 (CLI server is missing some new HTTP response codes) +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php +include "php_cli_server.inc"; + +$proc_handle = php_cli_server_start(<<<PHP +http_response_code(308); +PHP +); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)?:80; + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +if(fwrite($fp, <<<HEADER +GET / HTTP/1.1 + + +HEADER +)) { + while (!feof($fp)) { + echo fgets($fp); + } +} + +fclose($fp); +?> +--EXPECTF-- +HTTP/1.1 308 Permanent Redirect +Date: %s +Connection: close +X-Powered-By: %s +Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug67429_2.phpt b/sapi/cli/tests/bug67429_2.phpt new file mode 100644 index 0000000000..77447686a4 --- /dev/null +++ b/sapi/cli/tests/bug67429_2.phpt @@ -0,0 +1,42 @@ +--TEST-- +FR #67429 (CLI server is missing some new HTTP response codes) +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php +include "php_cli_server.inc"; + +$proc_handle = php_cli_server_start(<<<PHP +http_response_code(426); +PHP +); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)?:80; + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +if(fwrite($fp, <<<HEADER +GET / HTTP/1.1 + + +HEADER +)) { + while (!feof($fp)) { + echo fgets($fp); + } +} + +fclose($fp); +?> +--EXPECTF-- +HTTP/1.1 426 Upgrade Required +Date: %s +Connection: close +X-Powered-By: %s +Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug71624.phpt b/sapi/cli/tests/bug71624.phpt index aa4c69da12..67e3e8f343 100644 --- a/sapi/cli/tests/bug71624.phpt +++ b/sapi/cli/tests/bug71624.phpt @@ -9,7 +9,7 @@ include "skipif.inc"; $php = getenv('TEST_PHP_EXECUTABLE'); -$filename_txt = dirname(__FILE__) . DIRECTORY_SEPARATOR . "bug71624.test.txt"; +$filename_txt = __DIR__ . DIRECTORY_SEPARATOR . "bug71624.test.txt"; $txt = 'foo test diff --git a/sapi/cli/tests/cli_get_process_title_basic.phpt b/sapi/cli/tests/cli_get_process_title_basic.phpt index 66d1d4f3a7..3709095da0 100644 --- a/sapi/cli/tests/cli_get_process_title_basic.phpt +++ b/sapi/cli/tests/cli_get_process_title_basic.phpt @@ -6,7 +6,9 @@ Patrick Allaert patrickallaert@php.net --SKIPIF-- <?php if (PHP_SAPI !== "cli") - die("skip"); + die("skip cli process title not available in non-cli SAPI"); +if (!PHP_CLI_PROCESS_TITLE) + die("skip process title not available (disabled or unsupported)"); ?> --FILE-- <?php diff --git a/sapi/cli/tests/cli_get_process_title_error.phpt b/sapi/cli/tests/cli_get_process_title_error.phpt deleted file mode 100644 index 67274db26c..0000000000 --- a/sapi/cli/tests/cli_get_process_title_error.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -cli_get_process_title() function : error conditions ---CREDITS-- -Patrick Allaert patrickallaert@php.net -@nephp #nephp17 ---SKIPIF-- -<?php -if (PHP_SAPI !== "cli") - die("skip"); -?> ---FILE-- -<?php -cli_get_process_title("foo"); -?> ---EXPECTF-- -Warning: cli_get_process_title() expects exactly 0 parameters, 1 given in %scli_get_process_title_error.php on line 2 diff --git a/sapi/cli/tests/cli_process_title_unix.phpt b/sapi/cli/tests/cli_process_title_unix.phpt index 418433d8f2..d6e49a2221 100644 --- a/sapi/cli/tests/cli_process_title_unix.phpt +++ b/sapi/cli/tests/cli_process_title_unix.phpt @@ -2,6 +2,10 @@ Check cli_process_title support on Unix --SKIPIF-- <?php +if (PHP_SAPI !== "cli") + die("skip cli process title not available in non-cli SAPI"); +if (!PHP_CLI_PROCESS_TITLE) + die("skip process title not available (disabled or unsupported)"); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("skip"); ?> diff --git a/sapi/cli/tests/cli_set_process_title_basic.phpt b/sapi/cli/tests/cli_set_process_title_basic.phpt index 9899f3456b..32b8f85a82 100644 --- a/sapi/cli/tests/cli_set_process_title_basic.phpt +++ b/sapi/cli/tests/cli_set_process_title_basic.phpt @@ -6,7 +6,9 @@ Patrick Allaert patrickallaert@php.net --SKIPIF-- <?php if (PHP_SAPI !== "cli") - die("skip"); + die("skip cli process title not available in non-cli SAPI"); +if (!PHP_CLI_PROCESS_TITLE) + die("skip process title not available (disabled or unsupported)"); ?> --FILE-- <?php diff --git a/sapi/cli/tests/cli_set_process_title_error.phpt b/sapi/cli/tests/cli_set_process_title_error.phpt deleted file mode 100644 index 025c73015b..0000000000 --- a/sapi/cli/tests/cli_set_process_title_error.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -cli_set_process_title() function : error conditions ---CREDITS-- -Patrick Allaert patrickallaert@php.net -@nephp #nephp17 ---SKIPIF-- -<?php -if (PHP_SAPI !== "cli") - die("skip"); -?> ---FILE-- -<?php -cli_set_process_title(); -cli_set_process_title("foo", "bar"); -?> ---EXPECTF-- -Warning: cli_set_process_title() expects exactly 1 parameter, 0 given in %scli_set_process_title_error.php on line 2 - -Warning: cli_set_process_title() expects exactly 1 parameter, 2 given in %scli_set_process_title_error.php on line 3 diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc index ff4eef0e12..679a55eed4 100644 --- a/sapi/cli/tests/php_cli_server.inc +++ b/sapi/cli/tests/php_cli_server.inc @@ -3,66 +3,83 @@ define ("PHP_CLI_SERVER_HOSTNAME", "localhost"); define ("PHP_CLI_SERVER_PORT", 8964); define ("PHP_CLI_SERVER_ADDRESS", PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT); -function php_cli_server_start($code = 'echo "Hello world";', $router = 'index.php', $cmd_args = null) { +function php_cli_server_start( + ?string $code = 'echo "Hello world";', + ?string $router = 'index.php', + array $cmd_args = [] +) { $php_executable = getenv('TEST_PHP_EXECUTABLE'); $doc_root = __DIR__; + $error = null; if ($code) { file_put_contents($doc_root . '/' . ($router ?: 'index.php'), '<?php ' . $code . ' ?>'); } - if (substr(PHP_OS, 0, 3) == 'WIN') { - $descriptorspec = array( - 0 => STDIN, - 1 => STDOUT, - 2 => array("pipe", "w"), - ); - - $cmd = "{$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS; - if (!is_null($router)) { - $cmd .= " {$router}"; - } - - $handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true)); - } else { - $descriptorspec = array( - 0 => STDIN, - 1 => STDOUT, - 2 => STDERR, - ); - - $cmd = "exec {$php_executable} -t {$doc_root} -n {$cmd_args} -S " . PHP_CLI_SERVER_ADDRESS; - if (!is_null($router)) { - $cmd .= " {$router}"; - } - $cmd .= " 2>/dev/null"; - - $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root); + $cmd = [$php_executable, '-t', $doc_root, '-n', ...$cmd_args, '-S', PHP_CLI_SERVER_ADDRESS]; + if (!is_null($router)) { + $cmd[] = $router; } - // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' - // it might not be listening yet...need to wait until fsockopen() call returns - $error = "Unable to connect to server\n"; - for ($i=0; $i < 60; $i++) { - usleep(50000); // 50ms per try + $descriptorspec = array( + 0 => STDIN, + 1 => STDOUT, + 2 => array("null"), + ); + $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root, null, array("suppress_errors" => true)); + + // note: here we check the process is running + for ($i=0; $i < 120; $i++) { $status = proc_get_status($handle); - $fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT); - // Failure, the server is no longer running - if (!($status && $status['running'])) { - $error = "Server is not running\n"; + + if (!$status || !$status['running']) { + if ($status && + ($status['running'] == false && $status['exitcode'] != 0)) { + $error = + "Server could not be started\n"; + break; + } + + usleep(50000); // 50ms per try + continue; + } + + if ($status['signaled']) { + $error = + "Server was terminated with {$status['termsig']}\n"; break; } - // Success, Connected to servers - if ($fp) { - $error = ''; + + if ($status['stopped']) { + $error = + "Server was stopped with {$status['stopsig']}\n"; break; } - } - if ($fp) { - fclose($fp); + // note: here we check the server is listening, even when the server prints + // listening on %s:%d + // it may not be ready to accept connections + $start = time(); + + for ($try = 0; $try < 120; $try++) { + $error = @fsockopen( + PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT) ? + null : + sprintf( + "Server is not accepting connections after %d seconds\n", + time() - $start); + + if (!$error) { + break 2; + } + + usleep(50000); + } + + break; } +php_cli_server_start_error: if ($error) { echo $error; proc_terminate($handle); @@ -79,21 +96,4 @@ function php_cli_server_start($code = 'echo "Hello world";', $router = 'index.ph return $handle; } - -function php_cli_server_stop($handle) { - $success = FALSE; - if ($handle) { - proc_terminate($handle); - /* Wait for server to shutdown */ - for ($i = 0; $i < 60; $i++) { - $status = proc_get_status($handle); - if (!($status && $status['running'])) { - $success = TRUE; - break; - } - usleep(50000); - } - } - return $success; -} ?> diff --git a/sapi/cli/tests/php_cli_server_015.phpt b/sapi/cli/tests/php_cli_server_015.phpt index 42000adbb9..990a3db97e 100644 --- a/sapi/cli/tests/php_cli_server_015.phpt +++ b/sapi/cli/tests/php_cli_server_015.phpt @@ -10,7 +10,7 @@ display_errors=1 <?php include "php_cli_server.inc"; php_cli_server_start('require("syntax_error.php");'); -$dir = realpath(dirname(__FILE__)); +$dir = realpath(__DIR__); file_put_contents($dir . "/syntax_error.php", "<?php non_exists_function(); ?>"); diff --git a/sapi/cli/tests/sapi_windows_set_ctrl_handler.phpt b/sapi/cli/tests/sapi_windows_set_ctrl_handler.phpt new file mode 100644 index 0000000000..1505281dd3 --- /dev/null +++ b/sapi/cli/tests/sapi_windows_set_ctrl_handler.phpt @@ -0,0 +1,85 @@ +--TEST-- +sapi_windows_set_ctrl_handler() +--SKIPIF-- +<?php + +include "skipinf.inc"; + +if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') + die("skip this test is for Windows platforms only"); +?> +--FILE-- +<?php + +$is_child = isset($argv[1]); + + +if ($is_child) { + function handler($evt) + { + exit(3); + } + + sapi_windows_set_ctrl_handler('handler'); + + while(1) usleep(100); +} else { + $cmd = PHP_BINARY . " -n " . $argv[0] . " 1"; + $spec = [0 => ["pipe", "r"], 1 => ["pipe", "w"]]; + + $proc = proc_open($cmd, $spec, $pipes, NULL, NULL, ["bypass_shell" => true, "create_process_group" => true]); + + if (!is_resource($proc)) { + die("Failed to start child. "); + } + + $child_pid = proc_get_status($proc)["pid"]; + echo "Started child $child_pid\n"; + usleep(300); + + $cmd = "tasklist /FI \"PID eq $child_pid\" /NH"; + echo "Running `$cmd` to check the process indeed exists:\n"; + echo trim(shell_exec($cmd)) . "\n"; + + $evt = PHP_WINDOWS_EVENT_CTRL_C; + echo "Sending ", get_evt_name($evt), " to child $child_pid\n"; + $ret = sapi_windows_generate_ctrl_event($evt, $child_pid); + + echo ($ret ? "Successfully" : "Unsuccessfuly"), " sent ", get_evt_name($evt), " to child $child_pid\n"; + + $max = 5000; $total = 0; $step = 100; + while(proc_get_status($proc)["running"] && $max > $total) { + usleep($step); + $total += $step; + } + + $status = proc_get_status($proc); + if ($status["running"]) { + echo "Child $child_pid didn't exit after ${max}us\n"; + } else { + echo "Child $child_pid exit with status ", $status["exitcode"], " after ${total}us\n"; + } + + proc_close($proc); +} + +function get_evt_name(int $evt) : ?string +{ + if (PHP_WINDOWS_EVENT_CTRL_C == $evt) { + return "CTRL+C"; + } if (PHP_WINDOWS_EVENT_CTRL_BREAK == $evt) { + return "CTRL+BREAK"; + } + + return NULL; +} + +?> +--EXPECTF-- +Started child %d +Running `tasklist /FI "PID eq %d" /NH` to check the process indeed exists: +php.exe%w%d%s1%s +Sending CTRL+C to child %d +Successfully sent CTRL+C to child %d +Child %d exit with status 3 after %dus + diff --git a/sapi/cli/tests/std_streams.phpt b/sapi/cli/tests/std_streams.phpt new file mode 100644 index 0000000000..623cedaed1 --- /dev/null +++ b/sapi/cli/tests/std_streams.phpt @@ -0,0 +1,31 @@ +--TEST-- +Testing ftell() on std streams +--SKIPIF-- +<?php +if (getenv("SKIP_IO_CAPTURE_TESTS")) { + die("skip I/O capture test"); +} +?> +--CAPTURE_STDIO-- +STDOUT +--FILE-- +<?php + +// These have proc_open pipes attached +var_dump(ftell(STDIN)); +var_dump(ftell(STDERR)); +var_dump(ftell(fopen("php://stdin", "r"))); +var_dump(ftell(fopen("php://stderr", "w"))); + +// These have a tty attached +var_dump(ftell(STDOUT)); +var_dump(ftell(fopen("php://stdout", "w"))); + +?> +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/sapi/cli/tests/upload_2G.phpt b/sapi/cli/tests/upload_2G.phpt index 34e3a7c288..44d2da4a81 100644 --- a/sapi/cli/tests/upload_2G.phpt +++ b/sapi/cli/tests/upload_2G.phpt @@ -25,6 +25,10 @@ if (empty($enough_free_ram)) { if (getenv('TRAVIS')) { die("skip Fails intermittently on travis"); } + +if (getenv('SKIP_PERF_SENSITIVE')) { + die("skip Test may be very slow if PHP is instrumented"); +} ?> --FILE-- <?php @@ -33,8 +37,8 @@ echo "Test\n"; include "php_cli_server.inc"; -php_cli_server_start("var_dump(\$_FILES);", false, - "-d post_max_size=3G -d upload_max_filesize=3G"); +php_cli_server_start("var_dump(\$_FILES);", null, + ["-d", "post_max_size=3G", "-d", "upload_max_filesize=3G"]); list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); $port = intval($port)?:80; diff --git a/sapi/embed/config.m4 b/sapi/embed/config.m4 index 78e2d15775..069f4dcd0c 100644 --- a/sapi/embed/config.m4 +++ b/sapi/embed/config.m4 @@ -1,8 +1,9 @@ -dnl config.m4 for sapi embed - -PHP_ARG_ENABLE(embed,, -[ --enable-embed[=TYPE] EXPERIMENTAL: Enable building of embedded SAPI library - TYPE is either 'shared' or 'static'. [TYPE=shared]], no, no) +PHP_ARG_ENABLE([embed],, + [AS_HELP_STRING([[--enable-embed[=TYPE]]], + [EXPERIMENTAL: Enable building of embedded SAPI library TYPE is either + 'shared' or 'static'. [TYPE=shared]])], + [no], + [no]) AC_MSG_CHECKING([for embedded SAPI library support]) diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c index d93149b462..4c7dec6dd0 100644 --- a/sapi/embed/php_embed.c +++ b/sapi/embed/php_embed.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -159,7 +159,6 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv) { zend_llist global_vars; -#ifdef HAVE_SIGNAL_H #if defined(SIGPIPE) && defined(SIG_IGN) signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so that sockets created via fsockopen() @@ -168,12 +167,12 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv) does that for us! thies@thieso.net 20000419 */ #endif -#endif #ifdef ZTS - tsrm_startup(1, 1, 0, NULL); - (void)ts_resource(0); + php_tsrm_startup(); +# ifdef PHP_WIN32 ZEND_TSRMLS_CACHE_UPDATE(); +# endif #endif zend_signal_startup(); @@ -232,12 +231,3 @@ EMBED_SAPI_API void php_embed_shutdown(void) php_embed_module.ini_entries = NULL; } } - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/sapi/embed/php_embed.h b/sapi/embed/php_embed.h index 15c311e2b3..855872fed8 100644 --- a/sapi/embed/php_embed.h +++ b/sapi/embed/php_embed.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 44d842b285..f71fa710dd 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -1,20 +1,16 @@ -dnl config.m4 for sapi fpm +PHP_ARG_ENABLE([fpm],, + [AS_HELP_STRING([--enable-fpm], + [Enable building of the fpm SAPI executable])], + [no], + [no]) -PHP_ARG_ENABLE(fpm,, -[ --enable-fpm Enable building of the fpm SAPI executable], no, no) - -dnl configure checks {{{ +dnl Configure checks. AC_DEFUN([AC_FPM_STDLIBS], [ - AC_CHECK_FUNCS(setenv clearenv setproctitle setproctitle_fast) + AC_CHECK_FUNCS(clearenv setproctitle setproctitle_fast) AC_SEARCH_LIBS(socket, socket) AC_SEARCH_LIBS(inet_addr, nsl) - - AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/uio.h]) - AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/time.h]) - AC_CHECK_HEADERS([arpa/inet.h netinet/in.h]) - AC_CHECK_HEADERS([sysexits.h]) ]) AC_DEFUN([AC_FPM_PRCTL], @@ -338,7 +334,6 @@ AC_DEFUN([AC_FPM_LQ], fi fi ]) -dnl }}} AC_DEFUN([AC_FPM_SYSCONF], [ @@ -351,7 +346,6 @@ AC_DEFUN([AC_FPM_SYSCONF], AC_MSG_RESULT([no]) ]) ]) -dnl }}} AC_DEFUN([AC_FPM_TIMES], [ @@ -364,7 +358,6 @@ AC_DEFUN([AC_FPM_TIMES], AC_MSG_RESULT([no]) ]) ]) -dnl }}} AC_DEFUN([AC_FPM_KQUEUE], [ @@ -387,7 +380,6 @@ AC_DEFUN([AC_FPM_KQUEUE], AC_MSG_RESULT([no]) ]) ]) -dnl }}} AC_DEFUN([AC_FPM_PORT], [ @@ -409,7 +401,6 @@ AC_DEFUN([AC_FPM_PORT], AC_MSG_RESULT([no]) ]) ]) -dnl }}} AC_DEFUN([AC_FPM_DEVPOLL], [ @@ -433,7 +424,6 @@ AC_DEFUN([AC_FPM_DEVPOLL], AC_MSG_RESULT([no]) ]) ]) -dnl }}} AC_DEFUN([AC_FPM_EPOLL], [ @@ -468,32 +458,6 @@ AC_DEFUN([AC_FPM_EPOLL], AC_MSG_RESULT([no]) ]) ]) -dnl }}} - -AC_DEFUN([AC_FPM_POLL], -[ - AC_MSG_CHECKING([for poll]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include <poll.h> - ]], [[ - struct pollfd fds[2]; - - fds[0].fd = 0; - fds[0].events = POLLIN; - - fds[1].fd = 0; - fds[1].events = POLLIN; - - poll(fds, 2, 1); - ]])], [ - AC_DEFINE([HAVE_POLL], 1, [do we have poll?]) - AC_MSG_RESULT([yes]) - ], [ - AC_MSG_RESULT([no]) - ]) -]) -dnl }}} AC_DEFUN([AC_FPM_SELECT], [ @@ -523,7 +487,6 @@ AC_DEFUN([AC_FPM_SELECT], AC_MSG_RESULT([no]) ]) ]) -dnl }}} AC_DEFUN([AC_FPM_APPARMOR], [ @@ -541,7 +504,6 @@ AC_DEFUN([AC_FPM_APPARMOR], ]) ]) - AC_MSG_CHECKING(for FPM build) if test "$PHP_FPM" != "no"; then AC_MSG_RESULT($PHP_FPM) @@ -558,59 +520,45 @@ if test "$PHP_FPM" != "no"; then AC_FPM_PORT AC_FPM_DEVPOLL AC_FPM_EPOLL - AC_FPM_POLL AC_FPM_SELECT AC_FPM_APPARMOR - PHP_ARG_WITH(fpm-user,, - [ --with-fpm-user[=USER] Set the user for php-fpm to run as. (default: nobody)], nobody, no) - - PHP_ARG_WITH(fpm-group,, - [ --with-fpm-group[=GRP] Set the group for php-fpm to run as. For a system user, this - should usually be set to match the fpm username (default: nobody)], nobody, no) - - PHP_ARG_WITH(fpm-systemd,, - [ --with-fpm-systemd Activate systemd integration], no, no) - - PHP_ARG_WITH(fpm-acl,, - [ --with-fpm-acl Use POSIX Access Control Lists], no, no) + PHP_ARG_WITH([fpm-user],, + [AS_HELP_STRING([[--with-fpm-user[=USER]]], + [Set the user for php-fpm to run as. (default: nobody)])], + [nobody], + [no]) + + PHP_ARG_WITH([fpm-group],, + [AS_HELP_STRING([[--with-fpm-group[=GRP]]], + [Set the group for php-fpm to run as. For a system user, this should + usually be set to match the fpm username (default: nobody)])], + [nobody], + [no]) + + PHP_ARG_WITH([fpm-systemd],, + [AS_HELP_STRING([--with-fpm-systemd], + [Activate systemd integration])], + [no], + [no]) + + PHP_ARG_WITH([fpm-acl],, + [AS_HELP_STRING([--with-fpm-acl], + [Use POSIX Access Control Lists])], + [no], + [no]) if test "$PHP_FPM_SYSTEMD" != "no" ; then - if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) - fi - unset SYSTEMD_LIBS - unset SYSTEMD_INCS - - if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libsystemd; then - dnl systemd version >= 209 provides libsystemd - AC_MSG_CHECKING([for libsystemd]) - SYSTEMD_LIBS=`$PKG_CONFIG --libs libsystemd` - SYSTEMD_INCS=`$PKG_CONFIG --cflags-only-I libsystemd` - SYSTEMD_VERS=`$PKG_CONFIG --modversion libsystemd` - AC_MSG_RESULT([version $SYSTEMD_VERS]) - - elif test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libsystemd-daemon; then - dnl systemd version < 209 provides libsystemd-daemon - AC_MSG_CHECKING([for libsystemd-daemon]) - SYSTEMD_LIBS=`$PKG_CONFIG --libs libsystemd-daemon` - SYSTEMD_INCS=`$PKG_CONFIG --cflags-only-I libsystemd-daemon` - SYSTEMD_VERS=`$PKG_CONFIG --modversion libsystemd-daemon` - AC_MSG_RESULT([version $SYSTEMD_VERS]) - - else - dnl failback when no pkg-config - AC_CHECK_LIB(systemd-daemon, sd_notify, SYSTEMD_LIBS="-lsystemd-daemon") - fi + PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 209]) AC_CHECK_HEADERS(systemd/sd-daemon.h, [HAVE_SD_DAEMON_H="yes"], [HAVE_SD_DAEMON_H="no"]) - if test $HAVE_SD_DAEMON_H = "no" || test -z "${SYSTEMD_LIBS}"; then + if test $HAVE_SD_DAEMON_H = "no"; then AC_MSG_ERROR([Your system does not support systemd.]) else AC_DEFINE(HAVE_SYSTEMD, 1, [FPM use systemd integration]) PHP_FPM_SD_FILES="fpm/fpm_systemd.c" PHP_EVAL_LIBLINE($SYSTEMD_LIBS) - PHP_EVAL_INCLINE($SYSTEMD_INCS) + PHP_EVAL_INCLINE($SYSTEMD_CFLAGS) php_fpm_systemd=notify fi else @@ -619,7 +567,7 @@ if test "$PHP_FPM" != "no"; then if test "$PHP_FPM_ACL" != "no" ; then AC_CHECK_HEADERS([sys/acl.h]) - dnl *BSD has acl_* built into libc + dnl *BSD has acl_* built into libc. AC_CHECK_FUNC(acl_free, [ AC_DEFINE(HAVE_FPM_ACL, 1, [ POSIX Access Control List ]) ],[ @@ -670,7 +618,7 @@ if test "$PHP_FPM" != "no"; then PHP_FPM_TRACE_FILES="fpm/fpm_trace.c fpm/fpm_trace_$fpm_trace_type.c" fi - PHP_FPM_CFLAGS="-I$abs_srcdir/sapi/fpm" + PHP_FPM_CFLAGS="-I$abs_srcdir/sapi/fpm -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" PHP_FPM_FILES="fpm/fpm.c \ fpm/fpm_children.c \ @@ -712,7 +660,7 @@ if test "$PHP_FPM" != "no"; then BUILD_FPM="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_FASTCGI_OBJS:.lo=.o) \$(PHP_FPM_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(FPM_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)" ;; *) - BUILD_FPM="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_FASTCGI_OBJS) \$(PHP_FPM_OBJS) \$(EXTRA_LIBS) \$(FPM_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)" + BUILD_FPM="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_FASTCGI_OBJS:.lo=.o) \$(PHP_FPM_OBJS:.lo=.o) \$(EXTRA_LIBS) \$(FPM_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)" ;; esac diff --git a/sapi/fpm/fpm/events/devpoll.c b/sapi/fpm/fpm/events/devpoll.c index e3f73bf126..68cc8dd615 100644 --- a/sapi/fpm/fpm/events/devpoll.c +++ b/sapi/fpm/fpm/events/devpoll.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -166,7 +166,7 @@ static int fpm_event_devpoll_wait(struct fpm_event_queue_s *queue, unsigned long } } - /* iterate throught triggered events */ + /* iterate through triggered events */ for (i = 0; i < ret; i++) { /* find the corresponding event */ @@ -200,7 +200,7 @@ static int fpm_event_devpoll_add(struct fpm_event_s *ev) /* {{{ */ { struct pollfd pollfd; - /* fill pollfd with event informations */ + /* fill pollfd with event information */ pollfd.fd = ev->fd; pollfd.events = POLLIN; pollfd.revents = 0; @@ -225,7 +225,7 @@ static int fpm_event_devpoll_remove(struct fpm_event_s *ev) /* {{{ */ { struct pollfd pollfd; - /* fill pollfd with the same informations as fpm_event_devpoll_add */ + /* fill pollfd with the same information as fpm_event_devpoll_add */ pollfd.fd = ev->fd; pollfd.events = POLLIN | POLLREMOVE; pollfd.revents = 0; diff --git a/sapi/fpm/fpm/events/devpoll.h b/sapi/fpm/fpm/events/devpoll.h index 08730744ab..d8ff66bf95 100644 --- a/sapi/fpm/fpm/events/devpoll.h +++ b/sapi/fpm/fpm/events/devpoll.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/events/epoll.c b/sapi/fpm/fpm/events/epoll.c index e4a3300e4d..4701339e78 100644 --- a/sapi/fpm/fpm/events/epoll.c +++ b/sapi/fpm/fpm/events/epoll.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/events/epoll.h b/sapi/fpm/fpm/events/epoll.h index 4896178a58..783a2d25af 100644 --- a/sapi/fpm/fpm/events/epoll.h +++ b/sapi/fpm/fpm/events/epoll.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/events/kqueue.c b/sapi/fpm/fpm/events/kqueue.c index f0bb98ec21..c5d1b4f003 100644 --- a/sapi/fpm/fpm/events/kqueue.c +++ b/sapi/fpm/fpm/events/kqueue.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/events/kqueue.h b/sapi/fpm/fpm/events/kqueue.h index abb329e980..a09651b3b3 100644 --- a/sapi/fpm/fpm/events/kqueue.h +++ b/sapi/fpm/fpm/events/kqueue.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/events/poll.c b/sapi/fpm/fpm/events/poll.c index 28bcf0c403..ced32d0215 100644 --- a/sapi/fpm/fpm/events/poll.c +++ b/sapi/fpm/fpm/events/poll.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/events/poll.h b/sapi/fpm/fpm/events/poll.h index c8cac2b367..1a89f31102 100644 --- a/sapi/fpm/fpm/events/poll.h +++ b/sapi/fpm/fpm/events/poll.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/events/port.c b/sapi/fpm/fpm/events/port.c index bb9441369c..1ffcd20a0d 100644 --- a/sapi/fpm/fpm/events/port.c +++ b/sapi/fpm/fpm/events/port.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/events/port.h b/sapi/fpm/fpm/events/port.h index 28aee47f02..7329b2dff5 100644 --- a/sapi/fpm/fpm/events/port.h +++ b/sapi/fpm/fpm/events/port.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/events/select.c b/sapi/fpm/fpm/events/select.c index c0fd8bc085..d69ac7f5dd 100644 --- a/sapi/fpm/fpm/events/select.c +++ b/sapi/fpm/fpm/events/select.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/events/select.h b/sapi/fpm/fpm/events/select.h index 6490fe2c18..3b8445537f 100644 --- a/sapi/fpm/fpm/events/select.h +++ b/sapi/fpm/fpm/events/select.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/fpm/fpm/fpm_children.c b/sapi/fpm/fpm/fpm_children.c index 82c749fc81..fc05cab82b 100644 --- a/sapi/fpm/fpm/fpm_children.c +++ b/sapi/fpm/fpm/fpm_children.c @@ -195,7 +195,7 @@ void fpm_children_bury() /* {{{ */ snprintf(buf, sizeof(buf), "with code %d", WEXITSTATUS(status)); /* if it's been killed because of dynamic process management - * don't restart it automaticaly + * don't restart it automatically */ if (child && child->idle_kill) { restart_child = 0; @@ -220,7 +220,7 @@ void fpm_children_bury() /* {{{ */ snprintf(buf, sizeof(buf), "on signal %d (%s%s)", WTERMSIG(status), signame, have_core); /* if it's been killed because of dynamic process management - * don't restart it automaticaly + * don't restart it automatically */ if (child && child->idle_kill && WTERMSIG(status) == SIGQUIT) { restart_child = 0; diff --git a/sapi/fpm/fpm/fpm_env.c b/sapi/fpm/fpm/fpm_env.c index ef7c980efb..9931ab480c 100644 --- a/sapi/fpm/fpm/fpm_env.c +++ b/sapi/fpm/fpm/fpm_env.c @@ -199,9 +199,6 @@ static int fpm_env_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */ int fpm_env_init_main() /* {{{ */ { struct fpm_worker_pool_s *wp; - int i; - char *first = NULL; - char *last = NULL; char *title; for (wp = fpm_worker_all_pools; wp; wp = wp->next) { @@ -211,6 +208,9 @@ int fpm_env_init_main() /* {{{ */ } #ifndef HAVE_SETPROCTITLE #ifdef __linux__ + int i; + char *first = NULL; + char *last = NULL; /* * This piece of code has been inspirated from nginx and pureftpd code, which * are under BSD licence. diff --git a/sapi/fpm/fpm/fpm_events.c b/sapi/fpm/fpm/fpm_events.c index 81db9f8867..86592050c6 100644 --- a/sapi/fpm/fpm/fpm_events.c +++ b/sapi/fpm/fpm/fpm_events.c @@ -433,17 +433,16 @@ void fpm_event_loop(int err) /* {{{ */ /* trigger timers */ q = fpm_event_queue_timer; while (q) { + struct fpm_event_queue_s *next = q->next; fpm_clock_get(&now); if (q->ev) { if (timercmp(&now, &q->ev->timeout, >) || timercmp(&now, &q->ev->timeout, ==)) { - fpm_event_fire(q->ev); - /* sanity check */ - if (fpm_globals.parent_pid != getpid()) { - return; - } - if (q->ev->flags & FPM_EV_PERSIST) { - fpm_event_set_timeout(q->ev, now); - } else { /* delete the event */ + struct fpm_event_s *ev = q->ev; + if (ev->flags & FPM_EV_PERSIST) { + fpm_event_set_timeout(ev, now); + } else { + /* Delete the event. Make sure this happens before it is fired, + * so that the event callback may register the same timer again. */ q2 = q; if (q->prev) { q->prev->next = q->next; @@ -457,13 +456,18 @@ void fpm_event_loop(int err) /* {{{ */ fpm_event_queue_timer->prev = NULL; } } - q = q->next; free(q2); - continue; + } + + fpm_event_fire(ev); + + /* sanity check */ + if (fpm_globals.parent_pid != getpid()) { + return; } } } - q = q->next; + q = next; } } } diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 483fabe9d8..9916b8bf7c 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -43,13 +43,9 @@ # include <unistd.h> #endif -#if HAVE_SIGNAL_H -# include <signal.h> -#endif +#include <signal.h> -#if HAVE_SETLOCALE -# include <locale.h> -#endif +#include <locale.h> #if HAVE_SYS_TYPES_H # include <sys/types.h> @@ -162,7 +158,7 @@ typedef struct _php_cgi_globals_struct { * Key for each cache entry is dirname(PATH_TRANSLATED). * * NOTE: Each cache entry config_hash contains the combination from all user ini files found in - * the path starting from doc_root throught to dirname(PATH_TRANSLATED). There is no point + * the path starting from doc_root through to dirname(PATH_TRANSLATED). There is no point * storing per-file entries as it would not be possible to detect added / deleted entries * between separate files. */ @@ -182,20 +178,12 @@ static void user_config_cache_entry_dtor(zval *el) #ifdef ZTS static int php_cgi_globals_id; -#define CGIG(v) TSRMG(php_cgi_globals_id, php_cgi_globals_struct *, v) +#define CGIG(v) ZEND_TSRMG(php_cgi_globals_id, php_cgi_globals_struct *, v) #else static php_cgi_globals_struct php_cgi_globals; #define CGIG(v) (php_cgi_globals.v) #endif -static int print_module_info(zval *zv) /* {{{ */ -{ - zend_module_entry *module = Z_PTR_P(zv); - php_printf("%s\n", module->name); - return 0; -} -/* }}} */ - static int module_name_cmp(const void *a, const void *b) /* {{{ */ { Bucket *f = (Bucket *) a; @@ -209,11 +197,14 @@ static int module_name_cmp(const void *a, const void *b) /* {{{ */ static void print_modules(void) /* {{{ */ { HashTable sorted_registry; + zend_module_entry *module; zend_hash_init(&sorted_registry, 50, NULL, NULL, 1); zend_hash_copy(&sorted_registry, &module_registry, NULL); zend_hash_sort(&sorted_registry, module_name_cmp, 0); - zend_hash_apply(&sorted_registry, print_module_info); + ZEND_HASH_FOREACH_PTR(&sorted_registry, module) { + php_printf("%s\n", module->name); + } ZEND_HASH_FOREACH_END(); zend_hash_destroy(&sorted_registry); } /* }}} */ @@ -1537,7 +1528,7 @@ static zend_module_entry cgi_module_entry = { NULL, NULL, PHP_MINFO(cgi), - NO_VERSION_YET, + PHP_VERSION, STANDARD_MODULE_PROPERTIES }; @@ -1555,10 +1546,6 @@ int main(int argc, char *argv[]) int ini_entries_len = 0; /* end of temporary locals */ -#ifdef ZTS - void ***tsrm_ls; -#endif - int max_requests = 0; int requests = 0; int fcgi_fd = 0; @@ -1576,7 +1563,6 @@ int main(int argc, char *argv[]) zend_bool old_rc_debug; #endif -#ifdef HAVE_SIGNAL_H #if defined(SIGPIPE) && defined(SIG_IGN) signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so that sockets created via fsockopen() @@ -1585,11 +1571,9 @@ int main(int argc, char *argv[]) does that for us! thies@thieso.net 20000419 */ #endif -#endif #ifdef ZTS - tsrm_startup(1, 1, 0, NULL); - tsrm_ls = ts_resource(0); + php_tsrm_startup(); #endif zend_signal_startup(); @@ -1728,9 +1712,9 @@ int main(int argc, char *argv[]) SG(request_info).no_headers = 1; #if ZEND_DEBUG - php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2018 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #else - php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2018 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #endif php_request_shutdown((void *) 0); fcgi_shutdown(); @@ -2014,12 +1998,3 @@ out: return exit_status; } /* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c index ab3c5af18e..d940ba661c 100644 --- a/sapi/fpm/fpm/fpm_php.c +++ b/sapi/fpm/fpm/fpm_php.c @@ -197,6 +197,9 @@ static void fpm_php_cleanup(int which, void *arg) /* {{{ */ { php_module_shutdown(); sapi_shutdown(); + if (limit_extensions) { + fpm_worker_pool_free_limit_extensions(limit_extensions); + } } /* }}} */ @@ -223,7 +226,9 @@ int fpm_php_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ } if (wp->limit_extensions) { + /* Take ownership of limit_extensions. */ limit_extensions = wp->limit_extensions; + wp->limit_extensions = NULL; } return 0; } diff --git a/sapi/fpm/fpm/fpm_php_trace.c b/sapi/fpm/fpm/fpm_php_trace.c index 3174eef2fb..cfdcf65094 100644 --- a/sapi/fpm/fpm/fpm_php_trace.c +++ b/sapi/fpm/fpm/fpm_php_trace.c @@ -99,9 +99,9 @@ static int fpm_php_trace_dump(struct fpm_child_s *child, FILE *slowlog) /* {{{ * return -1; } - if (ZEND_CALL_KIND_EX((*call_info) >> ZEND_CALL_INFO_SHIFT) == ZEND_CALL_TOP_CODE) { + if (ZEND_CALL_KIND_EX(*call_info) == ZEND_CALL_TOP_CODE) { return 0; - } else if (ZEND_CALL_KIND_EX(*(call_info) >> ZEND_CALL_INFO_SHIFT) == ZEND_CALL_NESTED_CODE) { + } else if (ZEND_CALL_KIND_EX(*call_info) == ZEND_CALL_NESTED_CODE) { memcpy(buf, "[INCLUDE_OR_EVAL]", sizeof("[INCLUDE_OR_EVAL]")); } else { ZEND_ASSERT(0); diff --git a/sapi/fpm/fpm/fpm_request.c b/sapi/fpm/fpm/fpm_request.c index 83401f1553..e480256a01 100644 --- a/sapi/fpm/fpm/fpm_request.c +++ b/sapi/fpm/fpm/fpm_request.c @@ -25,7 +25,7 @@ static const char *requests_stages[] = { [FPM_REQUEST_ACCEPTING] = "Idle", [FPM_REQUEST_READING_HEADERS] = "Reading headers", - [FPM_REQUEST_INFO] = "Getting request informations", + [FPM_REQUEST_INFO] = "Getting request information", [FPM_REQUEST_EXECUTING] = "Running", [FPM_REQUEST_END] = "Ending", [FPM_REQUEST_FINISHED] = "Finishing", diff --git a/sapi/fpm/fpm/fpm_worker_pool.c b/sapi/fpm/fpm/fpm_worker_pool.c index e4ad73169d..d04528f4e0 100644 --- a/sapi/fpm/fpm/fpm_worker_pool.c +++ b/sapi/fpm/fpm/fpm_worker_pool.c @@ -17,6 +17,15 @@ struct fpm_worker_pool_s *fpm_worker_all_pools; +void fpm_worker_pool_free_limit_extensions(char **limit_extensions) { + char **ext = limit_extensions; + while (*ext) { + free(*ext); + ext++; + } + free(limit_extensions); +} + void fpm_worker_pool_free(struct fpm_worker_pool_s *wp) /* {{{ */ { if (wp->config) { @@ -28,6 +37,9 @@ void fpm_worker_pool_free(struct fpm_worker_pool_s *wp) /* {{{ */ if (wp->home) { free(wp->home); } + if (wp->limit_extensions) { + fpm_worker_pool_free_limit_extensions(wp->limit_extensions); + } fpm_unix_free_socket_premissions(wp); free(wp); } diff --git a/sapi/fpm/fpm/fpm_worker_pool.h b/sapi/fpm/fpm/fpm_worker_pool.h index 37f4e51994..8f4f440a84 100644 --- a/sapi/fpm/fpm/fpm_worker_pool.h +++ b/sapi/fpm/fpm/fpm_worker_pool.h @@ -50,6 +50,8 @@ struct fpm_worker_pool_s *fpm_worker_pool_alloc(); void fpm_worker_pool_free(struct fpm_worker_pool_s *wp); int fpm_worker_pool_init_main(); +void fpm_worker_pool_free_limit_extensions(char **limit_extensions); + extern struct fpm_worker_pool_s *fpm_worker_all_pools; #endif diff --git a/sapi/fpm/php-fpm.8.in b/sapi/fpm/php-fpm.8.in index 86edaa894f..edff796061 100644 --- a/sapi/fpm/php-fpm.8.in +++ b/sapi/fpm/php-fpm.8.in @@ -1,4 +1,4 @@ -.TH PHP-FPM 8 "2018" "The PHP Group" "Scripting Language" +.TH PHP-FPM 8 "2019" "The PHP Group" "Scripting Language" .SH NAME .TP 15 php-fpm \- PHP FastCGI Process Manager 'PHP-FPM' @@ -213,7 +213,7 @@ contributors all around the world. .SH VERSION INFORMATION This manpage describes \fBphp-fpm\fP, version @PHP_VERSION@. .SH COPYRIGHT -Copyright \(co 1997\-2018 The PHP Group +Copyright \(co The PHP Group .PD 0 .P Copyright (c) 2007-2009, Andrei Nigmatulin diff --git a/sapi/fpm/php-fpm.service.in b/sapi/fpm/php-fpm.service.in index 8a541c0865..857cb0e8f1 100644 --- a/sapi/fpm/php-fpm.service.in +++ b/sapi/fpm/php-fpm.service.in @@ -11,7 +11,61 @@ Type=@php_fpm_systemd@ PIDFile=@EXPANDED_LOCALSTATEDIR@/run/php-fpm.pid ExecStart=@EXPANDED_SBINDIR@/php-fpm --nodaemonize --fpm-config @EXPANDED_SYSCONFDIR@/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID + +# Set up a new file system namespace and mounts private /tmp and /var/tmp directories +# so this service cannot access the global directories and other processes cannot +# access this service's directories. PrivateTmp=true +# The directories /home, /root and /run/user are made inaccessible and empty for processes +# invoked by this unit. +ProtectHome=true + +# Mounts the /usr, /boot, and /etc directories read-only for processes invoked by this unit. +ProtectSystem=full + +# Ensures that the service process and all its children can never gain new privileges +NoNewPrivileges=true + +# Sets up a new /dev namespace for the executed processes and only adds API pseudo devices +# such as /dev/null, /dev/zero or /dev/random (as well as the pseudo TTY subsystem) to it, +# but no physical devices such as /dev/sda. +PrivateDevices=true + +# Required for dropping privileges and running as a different user +CapabilityBoundingSet=CAP_SETGID CAP_SETUID + +# Attempts to create memory mappings that are writable and executable at the same time, +# or to change existing memory mappings to become executable are prohibited. +MemoryDenyWriteExecute=true + +# Explicit module loading will be denied. This allows to turn off module load and unload +# operations on modular kernels. It is recommended to turn this on for most services that +# do not need special file systems or extra kernel modules to work. +ProtectKernelModules=true + +# Kernel variables accessible through /proc/sys, /sys, /proc/sysrq-trigger, /proc/latency_stats, +# /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq will be made read-only to all processes +# of the unit. Usually, tunable kernel variables should only be written at boot-time, with the +# sysctl.d(5) mechanism. Almost no services need to write to these at runtime; it is hence +# recommended to turn this on for most services. +ProtectKernelTunables=true + +# The Linux Control Groups (cgroups(7)) hierarchies accessible through /sys/fs/cgroup will be +# made read-only to all processes of the unit. Except for container managers no services should +# require write access to the control groups hierarchies; it is hence recommended to turn this on +# for most services +ProtectControlGroups=true + +# Any attempts to enable realtime scheduling in a process of the unit are refused. +RestrictRealtime=true + +# Restricts the set of socket address families accessible to the processes of this unit. +# Protects against vulnerabilities such as CVE-2016-8655 +RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX + +# Takes away the ability to create or manage any kind of namespace +RestrictNamespaces=true + [Install] WantedBy=multi-user.target diff --git a/sapi/fpm/tests/CONFLICTS b/sapi/fpm/tests/CONFLICTS new file mode 100644 index 0000000000..14c2e0b65a --- /dev/null +++ b/sapi/fpm/tests/CONFLICTS @@ -0,0 +1 @@ +fpm diff --git a/sapi/fpm/tests/bug68381-log-level-warning.phpt b/sapi/fpm/tests/bug68381-log-level-warning.phpt index 8d4a9af4cc..b9066cd051 100644 --- a/sapi/fpm/tests/bug68381-log-level-warning.phpt +++ b/sapi/fpm/tests/bug68381-log-level-warning.phpt @@ -3,6 +3,7 @@ FPM: bug68381 - Log messages with warning level only --SKIPIF-- <?php include "skipif.inc"; +if (getenv("SKIP_ASAN")) die("skip Often fails on azure with asan for unknown reason"); ?> --FILE-- <?php diff --git a/sapi/fpm/tests/fcgi.inc b/sapi/fpm/tests/fcgi.inc index 07603a808e..721b94b504 100644 --- a/sapi/fpm/tests/fcgi.inc +++ b/sapi/fpm/tests/fcgi.inc @@ -362,19 +362,19 @@ class Client while ($p != $length) { - $nlen = ord($data{$p++}); + $nlen = ord($data[$p++]); if ($nlen >= 128) { $nlen = ($nlen & 0x7F << 24); - $nlen |= (ord($data{$p++}) << 16); - $nlen |= (ord($data{$p++}) << 8); - $nlen |= (ord($data{$p++})); + $nlen |= (ord($data[$p++]) << 16); + $nlen |= (ord($data[$p++]) << 8); + $nlen |= (ord($data[$p++])); } - $vlen = ord($data{$p++}); + $vlen = ord($data[$p++]); if ($vlen >= 128) { $vlen = ($nlen & 0x7F << 24); - $vlen |= (ord($data{$p++}) << 16); - $vlen |= (ord($data{$p++}) << 8); - $vlen |= (ord($data{$p++})); + $vlen |= (ord($data[$p++]) << 16); + $vlen |= (ord($data[$p++]) << 8); + $vlen |= (ord($data[$p++])); } $array[substr($data, $p, $nlen)] = substr($data, $p+$nlen, $vlen); $p += ($nlen + $vlen); @@ -392,12 +392,12 @@ class Client private function decodePacketHeader($data) { $ret = array(); - $ret['version'] = ord($data{0}); - $ret['type'] = ord($data{1}); - $ret['requestId'] = (ord($data{2}) << 8) + ord($data{3}); - $ret['contentLength'] = (ord($data{4}) << 8) + ord($data{5}); - $ret['paddingLength'] = ord($data{6}); - $ret['reserved'] = ord($data{7}); + $ret['version'] = ord($data[0]); + $ret['type'] = ord($data[1]); + $ret['requestId'] = (ord($data[2]) << 8) + ord($data[3]); + $ret['contentLength'] = (ord($data[4]) << 8) + ord($data[5]); + $ret['paddingLength'] = ord($data[6]); + $ret['reserved'] = ord($data[7]); return $ret; } @@ -428,7 +428,7 @@ class Client } /** - * Get Informations on the FastCGI application + * Get Information on the FastCGI application * * @param array $requestedInfo information to retrieve * @return array @@ -589,9 +589,7 @@ class Client // but still not get the response requested $startTime = microtime(true); - do { - $resp = $this->readPacket(); - + while ($resp = $this->readPacket()) { if ($resp['type'] == self::STDOUT || $resp['type'] == self::STDERR) { if ($resp['type'] == self::STDERR) { $this->_requests[$resp['requestId']]['state'] = self::REQ_STATE_ERR; @@ -612,7 +610,7 @@ class Client $this->set_ms_timeout($this->_readWriteTimeout); throw new \Exception('Timed out'); } - } while ($resp); + } if (!is_array($resp)) { $info = stream_get_meta_data($this->_sock); @@ -636,7 +634,7 @@ class Client // Reset timeout $this->set_ms_timeout($this->_readWriteTimeout); - switch (ord($resp['content']{4})) { + switch (ord($resp['content'][4])) { case self::CANT_MPX_CONN: throw new \Exception('This app can\'t multiplex [CANT_MPX_CONN]'); break; diff --git a/sapi/fpm/tests/log-bwd-multiple-msgs-stdout-stderr.phpt b/sapi/fpm/tests/log-bwd-multiple-msgs-stdout-stderr.phpt index 376a972bac..22f2dd1600 100644 --- a/sapi/fpm/tests/log-bwd-multiple-msgs-stdout-stderr.phpt +++ b/sapi/fpm/tests/log-bwd-multiple-msgs-stdout-stderr.phpt @@ -2,6 +2,8 @@ FPM: Buffered worker output decorated log with multiple continuous messages (stdout/stderr mixed) --SKIPIF-- <?php include "skipif.inc"; ?> +--XFAIL-- +Fails regularly due to log line termination bug --FILE-- <?php diff --git a/sapi/fpm/tests/log-bwd-multiple-msgs.phpt b/sapi/fpm/tests/log-bwd-multiple-msgs.phpt index 1517f4a554..2541febed7 100644 --- a/sapi/fpm/tests/log-bwd-multiple-msgs.phpt +++ b/sapi/fpm/tests/log-bwd-multiple-msgs.phpt @@ -38,7 +38,6 @@ $tester->terminate(); $tester->expectLogLine('msg 1 - msg 2 - msg 3'); $tester->expectLogLine('msg 1 - msg 2 - msg 3'); $tester->close(); - ?> Done --EXPECT-- @@ -48,3 +47,5 @@ Done require_once "tester.inc"; FPM\Tester::clean(); ?> +--XFAIL-- +There are bugs in FPM diff --git a/sapi/fpm/tests/main-global-prefix.phpt b/sapi/fpm/tests/main-global-prefix.phpt index 710e688c40..44486e4ed3 100644 --- a/sapi/fpm/tests/main-global-prefix.phpt +++ b/sapi/fpm/tests/main-global-prefix.phpt @@ -27,7 +27,7 @@ EOT; $prefix = __DIR__; $tester = new FPM\Tester($cfg); -$tester->start('--prefix ' . $prefix); +$tester->start(['--prefix', $prefix]); $tester->expectLogStartNotices(); $tester->expectFile(FPM\Tester::FILE_EXT_LOG_ACC, $prefix); $tester->expectFile(FPM\Tester::FILE_EXT_LOG_ERR, $prefix); diff --git a/sapi/fpm/tests/main-version.phpt b/sapi/fpm/tests/main-version.phpt index 6e42aae48f..40ea45ef01 100644 --- a/sapi/fpm/tests/main-version.phpt +++ b/sapi/fpm/tests/main-version.phpt @@ -15,7 +15,7 @@ echo "Done\n"; ?> --EXPECTF-- string(%d) "PHP %s (fpm%s (built: %s -Copyright (c) 1997-20%s The PHP Group -Zend Engine v%s, Copyright (c) 1998-20%s Zend Technologies +Copyright (c) The PHP Group +Zend Engine v%s, Copyright (c) Zend Technologies " Done diff --git a/sapi/fpm/tests/reload-uses-sigkill-as-last-measure.phpt b/sapi/fpm/tests/reload-uses-sigkill-as-last-measure.phpt new file mode 100644 index 0000000000..25c2cf25e2 --- /dev/null +++ b/sapi/fpm/tests/reload-uses-sigkill-as-last-measure.phpt @@ -0,0 +1,56 @@ +--TEST-- +If SIGQUIT and SIGTERM during reloading fail, SIGKILL should be sent +--SKIPIF-- +<?php +include "skipif.inc"; +if (!function_exists('pcntl_sigprocmask')) die('skip Requires pcntl_sigprocmask()'); +?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +pid = {{FILE:PID}} +process_control_timeout=1 +[unconfined] +listen = {{ADDR}} +ping.path = /ping +ping.response = pong +pm = dynamic +pm.max_children = 5 +pm.start_servers = 1 +pm.min_spare_servers = 1 +pm.max_spare_servers = 1 +EOT; + +$code = <<<EOT +<?php +pcntl_sigprocmask(SIG_BLOCK, [SIGQUIT, SIGTERM]); +EOT; + +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +$tester->signal('USR2'); +$tester->expectLogNotice('Reloading in progress ...'); +$tester->expectLogNotice('reloading: .*'); +$tester->expectLogNotice('using inherited socket fd=\d+, "127.0.0.1:\d+"'); +$tester->expectLogStartNotices(); +$tester->ping('{{ADDR}}'); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/tester.inc b/sapi/fpm/tests/tester.inc index 001b7d6a54..0bbf0c5100 100644 --- a/sapi/fpm/tests/tester.inc +++ b/sapi/fpm/tests/tester.inc @@ -320,25 +320,21 @@ class Tester /** * Start PHP-FPM master process * - * @param string $extraArgs + * @param array $extraArgs * @return bool * @throws \Exception */ - public function start(string $extraArgs = '') + public function start(array $extraArgs = []) { $configFile = $this->createConfig(); - $desc = $this->outDesc ? [] : [1 => array('pipe', 'w')]; - $asRoot = getenv('TEST_FPM_RUN_AS_ROOT') ? '--allow-to-run-as-root' : ''; - $cmd = self::findExecutable() . " $asRoot -F -O -y $configFile $extraArgs"; - /* Since it's not possible to spawn a process under linux without using a - * shell in php (why?!?) we need a little shell trickery, so that we can - * actually kill php-fpm */ - $this->masterProcess = proc_open( - "killit () { kill \$child 2> /dev/null; }; " . - "trap killit TERM; $cmd 2>&1 & child=\$!; wait", - $desc, - $pipes - ); + $desc = $this->outDesc ? [] : [1 => array('pipe', 'w'), 2 => array('redirect', 1)]; + $cmd = [self::findExecutable(), '-F', '-O', '-y', $configFile]; + if (getenv('TEST_FPM_RUN_AS_ROOT')) { + $cmd[] = '--allow-to-run-as-root'; + } + $cmd = array_merge($cmd, $extraArgs); + + $this->masterProcess = proc_open($cmd, $desc, $pipes); register_shutdown_function( function($masterProcess) use($configFile) { @unlink($configFile); @@ -627,7 +623,7 @@ class Tester $read = [$this->outDesc]; $write = null; $except = null; - if (stream_select($read, $write, $except, 2 )) { + if (stream_select($read, $write, $except, 3)) { return fgets($this->outDesc); } else { return null; diff --git a/sapi/fpm/www.conf.in b/sapi/fpm/www.conf.in index 092dec4fff..169d19568c 100644 --- a/sapi/fpm/www.conf.in +++ b/sapi/fpm/www.conf.in @@ -114,7 +114,7 @@ pm.max_children = 5 ; The number of child processes created on startup. ; Note: Used only when pm is set to 'dynamic' -; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 +; Default Value: (min_spare_servers + max_spare_servers) / 2 pm.start_servers = 2 ; The desired minimum number of idle server processes. diff --git a/sapi/litespeed/README.md b/sapi/litespeed/README.md index 3f5b7ad14f..19283f182e 100644 --- a/sapi/litespeed/README.md +++ b/sapi/litespeed/README.md @@ -1,221 +1,204 @@ -Introduction -============ +# Introduction LiteSpeed SAPI module is a dedicated interface for PHP integration with -LiteSpeed Web Server. LiteSpeed SAPI has similar architecture to the -FastCGI SAPI with there major enhancements: better performance, dynamic -spawning and PHP configuration modification through web server -configuration and .htaccess files. +LiteSpeed Web Server. LiteSpeed SAPI has similar architecture to the FastCGI +SAPI with there major enhancements: better performance, dynamic spawning and PHP +configuration modification through web server configuration and `.htaccess` +files. -Our simple benchmark test ("hello world") shows that PHP with -LiteSpeed SAPI has 30% better performance over PHP with FastCGI SAPI, -which is nearly twice the performance that Apache mod_php can deliver. +A simple benchmark test ("hello world") shows that PHP with LiteSpeed SAPI has +30% better performance over PHP with FastCGI SAPI, which is nearly twice the +performance that Apache mod_php can deliver. -A major drawback of FastCGI PHP comparing to Apache mod_php is lacking -the flexibilities in PHP configurations. PHP configurations cannot be -changed at runtime via configuration files like .htaccess files or web -server's virtual host configuration. In shared hosting environment, -each hosting account will has its own "open_basedir" overridden in -server configuration to enhance server security when mod_php is used. -usually, FastCGI PHP is not an option in shared hosting environment -due to lacking of this flexibility. LiteSpeed SAPI is carefully designed -to address this issue. PHP configurations can be modified the same way -as that in mod_php with the same configuration directives. +A major drawback of FastCGI PHP comparing to Apache mod_php is lacking the +flexibilities in PHP configurations. PHP configurations cannot be changed at +runtime via configuration files like `.htaccess` files or web server's virtual +host configuration. In shared hosting environment, each hosting account will has +its own `open_basedir` overridden in server configuration to enhance server +security when mod_php is used. Usually, FastCGI PHP is not an option in shared +hosting environment due to lacking of this flexibility. LiteSpeed SAPI is +carefully designed to address this issue. PHP configurations can be modified the +same way as that in mod_php with the same configuration directives. -PHP with LiteSpeed SAPI is highly recommended over FastCGI PHP for -PHP scripting with LiteSpeed web server. +PHP with LiteSpeed SAPI is highly recommended over FastCGI PHP for PHP scripting +with LiteSpeed web server. +## Building PHP with LiteSpeed SAPI -Building PHP with LiteSpeed SAPI -================================ - -You need to add "--with-litespeed" to the configure command to build -PHP with LiteSpeed SAPI, all other SAPI related configure options -should be removed. +You need to add `--enable-litespeed` to the configure command to build PHP with +LiteSpeed SAPI, all other SAPI related configure options should be removed. For example: - ./configure --with-litespeed - make -You should find an executable called 'php' under sapi/litespeed/ -directory after the compilation succeeds. Copy it to -'lsws/fcgi-bin/lsphp' or wherever you prefer, if LiteSpeed web server -has been configured to run PHP with LiteSpeed SAPI already, you just -need to overwrite the old executable with this one and you are all -set. +```bash +./configure --enable-litespeed +make +``` -Start PHP from command line -=========================== +You should find an executable called `lsphp` under `sapi/litespeed/` directory +after the compilation succeeds. Copy it to `lsws/fcgi-bin/lsphp` or wherever you +prefer, if LiteSpeed web server has been configured to run PHP with LiteSpeed +SAPI already, you just need to overwrite the old executable with this one and +you are all set. -Usually, lsphp is managed by LiteSpeed web server in a single server -installation. lsphp can be used in clustered environment with one -LiteSpeed web server at the front, load balancing lsphp processes -running on multiple backend servers. In such environment, lsphp can be -start manually from command with option "-b <socket_address>", socket -address can be IPv4, IPv6 or Unix Domain Socket address. -for example: +## Start PHP from command line - ./lsphp -b [::]:3000 +Usually, `lsphp` is managed by LiteSpeed web server in a single server +installation. lsphp can be used in clustered environment with one LiteSpeed web +server at the front, load balancing lsphp processes running on multiple backend +servers. In such environment, lsphp can be start manually from command with +option `-b <socket_address>`, socket address can be IPv4, IPv6 or Unix Domain +Socket address. -have lsphp bind to port 3000 on all IPv4 and IPv6 address, +For example: - ./lsphp -b *:3000 +```bash +./lsphp -b [::]:3000 +``` -have lsphp bind to port 300 on all IPv4 address. +have lsphp bind to port 3000 on all IPv4 and IPv6 address, - ./lsphp -b 192.168.0.2:3000 +```bash +./lsphp -b *:3000 +``` -have lsphp bind to address 192.168.0.2:3000. +have lsphp bind to port 300 on all IPv4 address, - ./lsphp -b /tmp/lsphp_manual.sock +```bash +./lsphp -b 192.168.0.2:3000 +``` -have lsphp accept request on Unix domain socket "/tmp/lsphp_manual.sock" +have lsphp bind to address 192.168.0.2:3000, +```bash +./lsphp -b /tmp/lsphp_manual.sock +``` -Using LiteSpeed PHP with LiteSpeed Web Server -============================================= +have lsphp accept request on Unix domain socket `/tmp/lsphp_manual.sock`. -Detailed information about how to configure LiteSpeed web server with -PHP support is available from our website, at: +## Using LiteSpeed PHP with LiteSpeed Web Server -https://www.litespeedtech.com/docs/webserver +Detailed information about how to configure LiteSpeed web server with PHP +support is available from +[LiteSpeed website](https://www.litespeedtech.com/docs/webserver). -Usually, PHP support has been configured out of box, you don't need to -change it unless you want to change PHP interface from FastCGI to -LiteSpeed SAPI or vice versa. +Usually, PHP support has been configured out of box, you don't need to change it +unless you want to change PHP interface from FastCGI to LiteSpeed SAPI or vice +versa. Brief instructions are as follow: -1) Login to web administration interface, go to 'Server'->'Ext App' tab, - add an external application of type "LSAPI app", "Command" should be - set to a shell command that executes the PHP binary you just built. - "Instances" should be set to "1". Add "LSAPI_CHILDREN" environment - variable to match the value of "Max Connections". More tunable - environment variable described below can be added. +1. Login to web administration interface, go to 'Server'->'Ext App' tab, add an + external application of type "LSAPI app", "Command" should be set to a shell + command that executes the PHP binary you just built. "Instances" should be + set to "1". Add "LSAPI_CHILDREN" environment variable to match the value of + "Max Connections". More tunable environment variable described below can be + added. -2) Go to 'Server'->'Script Handler' tab, add a script handler - configuration: set 'suffix' to 'php', 'Handler Type' to 'LiteSpeed - API', 'Handler Name' should be the name of external application - just defined. +2. Go to 'Server'->'Script Handler' tab, add a script handler configuration: set + 'suffix' to 'php', 'Handler Type' to 'LiteSpeed API', 'Handler Name' should + be the name of external application just defined. - -3) Click 'Apply Changes' link on the top left of the page, then click +3. Click 'Apply Changes' link on the top left of the page, then click 'graceful restart'. Now PHP is running with LiteSpeed SAPI. -Tunings -------- +## Tunings There are a few environment variables that can be tweaked to control the behavior of LSAPI application. -* LSAPI_CHILDREN or PHP_LSAPI_CHILDREN (default: 0) - -There are two ways to let PHP handle multiple requests concurrently, -Server Managed Mode and Self Managed Mode. In Server Managed Mode, -LiteSpeed web server dynamically spawn/stop PHP processes, in this mode -"Instances" should match "Max Connections" configuration for PHP -external application. To start PHP in Self Managed Mode, "Instances" -should be set to "1", while "LSAPI_CHILDREN" environment variable should -be set to match the value of "Max Connections" and >1. Web Server will -start one PHP process, this process will start/stop children PHP processes -dynamically based on on demand. If "LSAPI_CHILDREN" <=1, PHP will be -started in server managed mode. - -Self Managed Mode is preferred because all PHP processes can share one -shared memory block for the opcode cache. - -Usually, there is no need to set value of LSAPI_CHILDREN over 100 in -most server environment. +* `LSAPI_CHILDREN` or `PHP_LSAPI_CHILDREN` (default: 0) + There are two ways to let PHP handle multiple requests concurrently, Server + Managed Mode and Self Managed Mode. In Server Managed Mode, LiteSpeed web + server dynamically spawn/stop PHP processes, in this mode "Instances" should + match "Max Connections" configuration for PHP external application. To start + PHP in Self Managed Mode, "Instances" should be set to "1", while + `LSAPI_CHILDREN` environment variable should be set to match the value of "Max + Connections" and greater than 1. Web Server will start one PHP process, this + process will start/stop children PHP processes dynamically based on on demand. + If `LSAPI_CHILDREN` less or equal to 1, PHP will be started in server managed + mode. -* LSAPI_AVOID_FORK (default: 0) + Self Managed Mode is preferred because all PHP processes can share one shared + memory block for the opcode cache. -LSAPI_AVOID_FORK specifies the policy of the internal process manager in -"Self Managed Mode". When set to 0, the internal process manager will stop -and start children process on demand to save system resource. This is -preferred in a shared hosting environment. When set to 1, the internal -process manager will try to avoid freqently stopping and starting children -process. This might be preferred in a dedicate hosting environment. + Usually, there is no need to set value of `LSAPI_CHILDREN` over 100 in most + server environments. +* `LSAPI_AVOID_FORK` (default: 0) -* LSAPI_EXTRA_CHILDREN (default: 1/3 of LSAPI_CHILDREN or 0) + `LSAPI_AVOID_FORK` specifies the policy of the internal process manager in + "Self Managed Mode". When set to 0, the internal process manager will stop and + start children process on demand to save system resource. This is preferred in + a shared hosting environment. When set to 1, the internal process manager will + try to avoid freqently stopping and starting children process. This might be + preferred in a dedicate hosting environment. -LSAPI_EXTRA_CHILDREN controls the maximum number of extra children processes -can be started when some or all existing children processes are in -malfunctioning state. Total number of children processes will be reduced to -LSAPI_CHILDREN level as soon as service is back to normal. -When LSAPI_AVOID_FORK is set to 0, the default value is 1/3 of -LSAPI_CHIDLREN, When LSAPI_AVOID_FORK is set to 1, the default value is 0. +* `LSAPI_EXTRA_CHILDREN` (default: 1/3 of `LSAPI_CHILDREN` or 0) + `LSAPI_EXTRA_CHILDREN` controls the maximum number of extra children processes + can be started when some or all existing children processes are in + malfunctioning state. Total number of children processes will be reduced to + `LSAPI_CHILDREN` level as soon as service is back to normal. When + `LSAPI_AVOID_FORK` is set to 0, the default value is 1/3 of `LSAPI_CHILDREN`, + When `LSAPI_AVOID_FORK` is set to 1, the default value is 0. -* LSAPI_MAX_REQS or PHP_LSAPI_MAX_REQUESTS (default value: 10000) +* `LSAPI_MAX_REQS` or `PHP_LSAPI_MAX_REQUESTS` (default value: 10000) -This controls how many requests each child process will handle before -it exits automatically. Several PHP functions have been identified -having memory leaks. This parameter can help reducing memory usage -of leaky PHP functions. + This controls how many requests each child process will handle before it exits + automatically. Several PHP functions have been identified having memory leaks. + This parameter can help reducing memory usage of leaky PHP functions. +* `LSAPI_MAX_IDLE` (default value: 300 seconds) -* LSAPI_MAX_IDLE (default value: 300 seconds) + In Self Managed Mode, LSAPI_MAX_IDLE controls how long a idle child process + will wait for a new request before it exits. This option help releasing system + resources taken by idle processes. -In Self Managed Mode, LSAPI_MAX_IDLE controls how long a idle child -process will wait for a new request before it exits. This option help -releasing system resources taken by idle processes. +* `LSAPI_MAX_IDLE_CHILDREN` (default value: 1/3 of `LSAPI_CHILDREN` or + `LSAPI_CHILDREN`) + In Self Managed Mode, `LSAI_MAX_IDLE_CHILDREN` controls how many idle children + processes are allowed. Excessive idle children processes will be killed by the + parent process immediately. When `LSAPI_AVOID_FORK` is set to 0, the default + value is 1/3 of `LSAPI_CHIDLREN`, When `LSAPI_AVOID_FORK` is set to 1, the + default value is `LSAPI_CHILDREN`. -* LSAPI_MAX_IDLE_CHILDREN - (default value: 1/3 of LSAPI_CHILDREN or LSAPI_CHILDREN) +* `LSAPI_MAX_PROCESS_TIME` (default value: 300 seconds) -In Self Managed Mode, LSAI_MAX_IDLE_CHILDREN controls how many idle -children processes are allowed. Excessive idle children processes -will be killed by the parent process immediately. -When LSAPI_AVOID_FORK is set to 0, the default value is 1/3 of -LSAPI_CHIDLREN, When LSAPI_AVOID_FORK is set to 1, the default value -is LSAPI_CHILDREN. + In Self Managed Mode, `LSAPI_MAX_PROCESS_TIME` controls the maximum processing + time allowed when processing a request. If a child process can not finish + processing of a request in the given time period, it will be killed by the + parent process. This option can help getting rid of dead or runaway child + process. +* `LSAPI_PGRP_MAX_IDLE` (default value: FOREVER) -* LSAPI_MAX_PROCESS_TIME (default value: 300 seconds) + In Self Managed Mode, `LSAPI_PGRP_MAX_IDLE` controls how long the parent + process will wait before exiting when there is no child process. This option + helps releasing system resources taken by an idle parent process. -In Self Managed Mode, LSAPI_MAX_PROCESS_TIME controls the maximum -processing time allowed when processing a request. If a child process -can not finish processing of a request in the given time period, it -will be killed by the parent process. This option can help getting rid -of dead or runaway child process. +* `LSAPI_PPID_NO_CHECK` + By default a LSAPI application check the existence of its parent process and + exits automatically if the parent process died. This is to reduce orphan + process when web server is restarted. However, it is desirable to disable this + feature, such as when a LSAPI process was started manually from command line. + `LSAPI_PPID_NO_CHECK` should be set when you want to disable the checking of + existence of parent process. When PHP is started by `-b` option, it is + disabled automatically. -* LSAPI_PGRP_MAX_IDLE (default value: FOREVER ) - -In Self Managed Mode, LSAPI_PGRP_MAX_IDLE controls how long the parent -process will wait before exiting when there is no child process. -This option help releasing system resources taken by an idle parent -process. - - -* LSAPI_PPID_NO_CHECK - -By default a LSAPI application check the existence of its parent process -and exits automatically if the parent process died. This is to reduce -orphan process when web server is restarted. However, it is desirable -to disable this feature, such as when a LSAPI process was started -manually from command line. LSAPI_PPID_NO_CHECK should be set when -you want to disable the checking of existence of parent process. -When PHP started by "-b" option, it is disabled automatically. - - -Compatibility with Apache mod_php -================================= +## Compatibility with Apache mod_php LSAPI PHP supports PHP configuration overridden via web server configuration -as well as .htaccess. -Since 4.0 release "apache_response_headers" function is supported. - - +as well as `.htaccess`. -Contact -======= +Since 4.0 release `apache_response_headers` function is supported. -For support questions, please post to our free support forum, at: +## Contact -https://www.litespeedtech.com/support/forum/ +For support questions, please post to the free support +[forum](https://www.litespeedtech.com/support/forum/): For bug report, please send bug report to bug [at] litespeedtech.com. diff --git a/sapi/litespeed/config.m4 b/sapi/litespeed/config.m4 index eba8642eb4..8907405385 100644 --- a/sapi/litespeed/config.m4 +++ b/sapi/litespeed/config.m4 @@ -1,9 +1,9 @@ -dnl config.m4 for sapi litespeed - AC_MSG_CHECKING(for LiteSpeed support) -PHP_ARG_WITH(litespeed,, -[ --with-litespeed Build PHP as litespeed module], no) +PHP_ARG_ENABLE([litespeed],, + [AS_HELP_STRING([--enable-litespeed], + [Build PHP as litespeed module])], + [no]) if test "$PHP_LITESPEED" != "no"; then PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/litespeed/Makefile.frag,$abs_srcdir/sapi/litespeed,sapi/litespeed) @@ -18,7 +18,7 @@ if test "$PHP_LITESPEED" != "no"; then BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_LITESPEED_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)" ;; *) - BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_LITESPEED_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)" + BUILD_LITESPEED="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_LITESPEED_OBJS:.lo=.o) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)" ;; esac diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index d3ac79eb7b..f7d4b1a84c 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -28,10 +28,7 @@ #include "lsapilib.h" #include <stdio.h> - -#if HAVE_STDLIB_H #include <stdlib.h> -#endif #if HAVE_UNISTD_H #include <unistd.h> @@ -46,12 +43,7 @@ #endif -#if HAVE_SIGNAL_H - #include <signal.h> - -#endif - #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> @@ -66,7 +58,7 @@ /* Key for each cache entry is dirname(PATH_TRANSLATED). * * NOTE: Each cache entry config_hash contains the combination from all user ini files found in - * the path starting from doc_root throught to dirname(PATH_TRANSLATED). There is no point + * the path starting from doc_root through to dirname(PATH_TRANSLATED). There is no point * storing per-file entries as it would not be possible to detect added / deleted entries * between separate files. */ @@ -90,7 +82,6 @@ zend_compiler_globals *compiler_globals; zend_executor_globals *executor_globals; php_core_globals *core_globals; sapi_globals_struct *sapi_globals; -void ***tsrm_ls; #endif zend_module_entry litespeed_module_entry; @@ -249,6 +240,7 @@ static void litespeed_php_import_environment_variables(zval *array_ptr) return; } + tsrm_env_lock(); for (env = environ; env != NULL && *env != NULL; env++) { p = strchr(*env, '='); if (!p) { /* malformed entry? */ @@ -263,6 +255,7 @@ static void litespeed_php_import_environment_variables(zval *array_ptr) t[nlen] = '\0'; add_variable(t, nlen, p + 1, strlen( p + 1 ), array_ptr); } + tsrm_env_unlock(); if (t != buf && t != NULL) { efree(t); } @@ -665,11 +658,7 @@ static int lsapi_execute_script( zend_file_handle * file_handle) { char *p; int len; - file_handle->type = ZEND_HANDLE_FILENAME; - file_handle->handle.fd = 0; - file_handle->filename = SG(request_info).path_translated; - file_handle->free_filename = 0; - file_handle->opened_path = NULL; + zend_stream_init_filename(file_handle, SG(request_info).path_translated); p = argv0; *p++ = ':'; @@ -1295,9 +1284,9 @@ static int cli_main( int argc, char * argv[] ) case 'v': if (php_request_startup() != FAILURE) { #if ZEND_DEBUG - php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2018 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #else - php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2018 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #endif #ifdef PHP_OUTPUT_NEWAPI php_output_end_all(); @@ -1328,9 +1317,7 @@ static int cli_main( int argc, char * argv[] ) if ( ret == -1 ) { if ( *p ) { zend_file_handle file_handle; - memset(&file_handle, 0, sizeof(file_handle)); - file_handle.type = ZEND_HANDLE_FP; - file_handle.handle.fp = VCWD_FOPEN(*p, "rb"); + zend_stream_init_fp(&file_handle, VCWD_FOPEN(*p, "rb"), NULL); if ( file_handle.handle.fp ) { script_filename = *p; @@ -1485,14 +1472,12 @@ int main( int argc, char * argv[] ) char time_buf[40]; -#ifdef HAVE_SIGNAL_H #if defined(SIGPIPE) && defined(SIG_IGN) signal(SIGPIPE, SIG_IGN); #endif -#endif #ifdef ZTS - tsrm_startup(1, 1, 0, NULL); + php_tsrm_startup(); #endif #if PHP_MAJOR_VERSION >= 7 @@ -1520,7 +1505,6 @@ int main( int argc, char * argv[] ) executor_globals = ts_resource(executor_globals_id); core_globals = ts_resource(core_globals_id); sapi_globals = ts_resource(sapi_globals_id); - tsrm_ls = ts_resource(0); SG(request_info).path_translated = NULL; #endif @@ -1687,7 +1671,7 @@ zend_module_entry litespeed_module_entry = { NULL, NULL, NULL, - NO_VERSION_YET, + PHP_VERSION, STANDARD_MODULE_PROPERTIES }; @@ -1799,12 +1783,3 @@ PHP_FUNCTION(litespeed_finish_request) RETURN_FALSE; } /* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/sapi/litespeed/lsapidef.h b/sapi/litespeed/lsapidef.h index ee87a01053..c909b5f986 100644 --- a/sapi/litespeed/lsapidef.h +++ b/sapi/litespeed/lsapidef.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index 926a832cea..c0c486cb15 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -93,6 +93,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define uint32 uint32_t #endif +#include <Zend/zend_portability.h> + struct lsapi_MD5Context { uint32 buf[4]; uint32 bits[2]; @@ -779,7 +781,7 @@ static int (*fp_lve_leave)(struct liblve *, uint32_t *) = NULL; static int (*fp_lve_jail)( struct passwd *, char *) = NULL; static int lsapi_load_lve_lib(void) { - s_liblve = dlopen("liblve.so.0", RTLD_LAZY); + s_liblve = DL_LOAD("liblve.so.0"); if (s_liblve) { fp_lve_is_available = dlsym(s_liblve, "lve_is_available"); diff --git a/sapi/litespeed/lsapilib.h b/sapi/litespeed/lsapilib.h index 9e1a9e1494..76f936700d 100644 --- a/sapi/litespeed/lsapilib.h +++ b/sapi/litespeed/lsapilib.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/litespeed/lscriu.c b/sapi/litespeed/lscriu.c index 1318214f58..7c5bda7e88 100644 --- a/sapi/litespeed/lscriu.c +++ b/sapi/litespeed/lscriu.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -51,10 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "lsapilib.h" #include <stdio.h> - -#if HAVE_STDLIB_H #include <stdlib.h> -#endif #if HAVE_UNISTD_H #include <unistd.h> @@ -91,6 +88,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <unistd.h> #include "lscriu.h" +#include <Zend/zend_portability.h> + #define LSCRIU_PATH 256 // Begin CRIU inclusion @@ -143,12 +142,6 @@ typedef struct char m_chServiceAddress[SUN_PATH_MAX]; } criu_native_dump_t; -typedef struct -{ - int m_iDumpResult; - char m_chDumpResponseMessage[1024]; -} criu_native_dump_response_t; - typedef sem_t * (*psem_open_t) (const char *__name, int __oflag, ...); typedef int (*psem_post_t) (sem_t *__sem); typedef int (*psem_close_t) (sem_t *__sem); @@ -265,8 +258,8 @@ static int LSCRIU_load_liblscapi(void) int error = 1; char *last; - if (!(lib_handle = dlopen(last = "liblscapi.so", RTLD_LAZY)) /*|| - !(pthread_lib_handle = dlopen(last = "libpthread.so", RTLD_LAZY))*/) + if (!(lib_handle = DL_LOAD(last = "liblscapi.so")) /*|| + !(pthread_lib_handle = DL_LOAD(last = "libpthread.so"))*/) fprintf(stderr, "LSCRIU (%d): failed to dlopen %s: %s - ignore CRIU\n", s_pid, last, dlerror()); else if (!(s_lscapi_dump_me = dlsym(lib_handle, last = "lscapi_dump_me")) || @@ -422,7 +415,6 @@ static int LSCRIU_Native_Dump(pid_t iPid, int iFdNative) { criu_native_dump_t criu_native_dump; char *pchLastSlash; - criu_native_dump_response_t criu_native_dump_response; memset(&criu_native_dump, 0, sizeof(criu_native_dump)); criu_native_dump.m_iPidToDump = iPid; @@ -442,18 +434,6 @@ static int LSCRIU_Native_Dump(pid_t iPid, return(-1); } return 0; - /* do not wait response. - //while (sleep(7200)); - if (read(iFdNative, - &criu_native_dump_response, - sizeof(criu_native_dump_response)) == -1) { - // The test will actually fail it! - //LSCRIU_Restored_Error(1, "Error reading dump socket #%d from parent: %s", - // iFdNative, strerror(errno)); - //return(-1); - } - return(-1); - */ } diff --git a/sapi/litespeed/lscriu.h b/sapi/litespeed/lscriu.h index 02fc9b880a..e7618114cc 100644 --- a/sapi/litespeed/lscriu.h +++ b/sapi/litespeed/lscriu.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/Changelog.md b/sapi/phpdbg/Changelog.md deleted file mode 100644 index c5d8b51514..0000000000 --- a/sapi/phpdbg/Changelog.md +++ /dev/null @@ -1,52 +0,0 @@ -ChangeLog for phpdbg -==================== - -Version 0.3.0 2013-00-00 ------------------------- - -1. Added ability to disable an enable a single breakpoint -2. Added ability to override SAPI name -3. Added extended conditional breakpoint support "break at" -4. Fix loading of zend extnsions with -z -5. Fix crash when loading .phpdbginit with command line switch -6. Fix crash on startup errors -7. Added init.d for remote console (redhat) -8. Added phpdbg_exec userland function -9. Added testing facilities -10. Added break on n-th opline support -11. Improved trace output - -Version 0.2.0 2013-11-31 ------------------------- - -1. Added "break delete <id>" command -2. Added "break opcode <opcode>" command -3. Added "set" command - control prompt and console colors -4. .phpdbginit now searched in (additional) ini dirs -5. Added source command - load additional .phpdbginit script during session -6. Added remote console mode -7. Added info memory command - -Version 0.1.0 2013-11-23 ------------------------- - -1. New commands: - - until (continue until the current line is executed) - - frame (switch to a frame in the current stack for inspection) - - info (quick access to useful information on the console) - - finish (continue until the current function has returned) - - leave (continue until the current function is returning) - - shell (shell a command) - - register (register a function for use as a command) -2. Added printers for class and method -3. Make uniform commands and aliases where possible -4. Include all alias information and sub-command information in help -5. Added signal handling to break execution (ctrl-c) -6. Fixed #13 (Output Buffering Control seems fail) -7. Fixed #14 (Fixed typo in Makefile.frag) - - -Version 0.0.1 2013-11-15 ------------------------- - -1. Initial features diff --git a/sapi/phpdbg/README.md b/sapi/phpdbg/README.md index 6eccb512de..68d9766f0a 100644 --- a/sapi/phpdbg/README.md +++ b/sapi/phpdbg/README.md @@ -1,81 +1,78 @@ -The interactive PHP debugger -============================ +# The interactive PHP debugger -Implemented as a SAPI module, phpdbg can exert complete control over the environment without impacting the functionality or performance of your code. +Implemented as a SAPI module, phpdbg can exert complete control over the +environment without impacting the functionality or performance of your code. -phpdbg aims to be a lightweight, powerful, easy to use debugging platform for PHP 5.4+ +phpdbg aims to be a lightweight, powerful, easy to use debugging platform for +PHP 5.4+. -Features -======== +## Features - - Stepthrough Debugging - - Flexible Breakpoints (Class Method, Function, File:Line, Address, Opcode) - - Easy Access to PHP with built-in eval() - - Easy Access to Currently Executing Code - - Userland API - - SAPI Agnostic - Easily Integrated - - PHP Configuration File Support - - JIT Super Globals - Set Your Own!! - - Optional readline Support - Comfortable Terminal Operation - - Remote Debugging Support - Bundled Java GUI - - Easy Operation - See Help :) +* Stepthrough Debugging +* Flexible Breakpoints (Class Method, Function, File:Line, Address, Opcode) +* Easy Access to PHP with built-in eval() +* Easy Access to Currently Executing Code +* Userland API +* SAPI Agnostic - Easily Integrated +* PHP Configuration File Support +* JIT Super Globals - Set Your Own!! +* Optional readline Support - Comfortable Terminal Operation +* Remote Debugging Support - Bundled Java GUI +* Easy Operation - See Help -Planned -======= +## Planned - - Improve Everything :) +* Improve Everything :) -Installation -============ +## Installation -To install **phpdbg**, you must compile the source against your PHP installation sources, and enable the SAPI with the configure command. +To install **phpdbg**, you must compile the source against your PHP installation +sources, and enable the SAPI with the configure command. It is enabled by +default: -``` -cd /usr/src/php-src/sapi -git clone https://github.com/krakjoe/phpdbg -cd ../ +```bash +cd /path/to/php-src ./buildconf --force -./configure --enable-phpdbg +./configure make -j8 -make install-phpdbg +./sapi/phpdbg/phpdbg --version ``` -Where the source directory has been used previously to build PHP, there exists a file named *config.nice* which can be used to invoke configure with the same -parameters as were used by the last execution of *configure*. +Where the source directory has been used previously to build PHP, there exists a +file named `config.nice` which can be used to invoke configure with the same +parameters as were used by the last execution of `configure`. -**Note:** PHP must be configured with the switch --with-readline for phpdbg to support history, autocompletion, tab-listing etc. +**Note:** PHP must be configured with the switch `--with-readline` for phpdbg to +support history, autocompletion, tab-listing etc. -Command Line Options -==================== +## Command line options The following switches are implemented (just like cli SAPI): - - -n ignore php ini - - -c search for php ini in path - - -z load zend extension - - -d define php ini entry +* `-n` ignore php ini +* `-c` search for php ini in path +* `-z` load zend extension +* `-d` define php ini entry The following switches change the default behaviour of phpdbg: - - -v disables quietness - - -s enabled stepping - - -e sets execution context - - -b boring - disables use of colour on the console - - -I ignore .phpdbginit (default init file) - - -i override .phpgdbinit location (implies -I) - - -O set oplog output file - - -q do not print banner on startup - - -r jump straight to run - - -E enable step through eval() - - -l listen ports for remote mode - - -a listen address for remote mode - - -S override SAPI name - -**Note:** Passing -rr will cause phpdbg to quit after execution, rather than returning to the console. - -Getting Started -=============== - -See the website for tutorials/documentation - -https://phpdbg.room11.org +* `-v` disables quietness +* `-s` enabled stepping +* `-e` sets execution context +* `-b` boring - disables use of colour on the console +* `-I` ignore .phpdbginit (default init file) +* `-i` override .phpgdbinit location (implies -I) +* `-O` set oplog output file +* `-q` do not print banner on startup +* `-r` jump straight to run +* `-E` enable step through eval() +* `-l` listen ports for remote mode +* `-a` listen address for remote mode +* `-S` override SAPI name + +**Note:** Passing `-rr` will cause phpdbg to quit after execution, rather than +returning to the console. + +## Getting started + +See the [website](https://phpdbg.room11.org) for tutorials/documentation. diff --git a/sapi/phpdbg/config.m4 b/sapi/phpdbg/config.m4 index 24bc557c8b..e78c012e88 100644 --- a/sapi/phpdbg/config.m4 +++ b/sapi/phpdbg/config.m4 @@ -1,17 +1,29 @@ -dnl config.m4 for sapi phpdbg - -PHP_ARG_ENABLE(phpdbg, for phpdbg support, -[ --enable-phpdbg Build phpdbg], yes, yes) - -PHP_ARG_ENABLE(phpdbg-webhelper, for phpdbg web SAPI support, -[ --enable-phpdbg-webhelper - Build phpdbg web SAPI support], no) - -PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build, -[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no) - -PHP_ARG_ENABLE(phpdbg-readline, for phpdbg readline support, -[ --enable-phpdbg-readline Enable readline support in phpdbg (depends on static ext/readline)], no, no) +PHP_ARG_ENABLE([phpdbg], + [for phpdbg support], + [AS_HELP_STRING([--enable-phpdbg], + [Build phpdbg])], + [yes], + [yes]) + +PHP_ARG_ENABLE([phpdbg-webhelper], + [for phpdbg web SAPI support], + [AS_HELP_STRING([--enable-phpdbg-webhelper], + [Build phpdbg web SAPI support])], + [no]) + +PHP_ARG_ENABLE([phpdbg-debug], + [for phpdbg debug build], + [AS_HELP_STRING([--enable-phpdbg-debug], + [Build phpdbg in debug mode])], + [no], + [no]) + +PHP_ARG_ENABLE([phpdbg-readline], + [for phpdbg readline support], + [AS_HELP_STRING([--enable-phpdbg-readline], + [Enable readline support in phpdbg (depends on static ext/readline)])], + [no], + [no]) if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then AC_HEADER_TIOCGWINSZ @@ -51,9 +63,9 @@ if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then BUILD_PHPDBG="\$(LIBTOOL) --mode=link \ \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \ - \$(PHP_GLOBAL_OBJS) \ - \$(PHP_BINARY_OBJS) \ - \$(PHP_PHPDBG_OBJS) \ + \$(PHP_GLOBAL_OBJS:.lo=.o) \ + \$(PHP_BINARY_OBJS:.lo=.o) \ + \$(PHP_PHPDBG_OBJS:.lo=.o) \ \$(EXTRA_LIBS) \ \$(PHPDBG_EXTRA_LIBS) \ \$(ZEND_EXTRA_LIBS) \ @@ -82,7 +94,3 @@ fi if test "$PHP_PHPDBG_WEBHELPER" != "no"; then PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared) fi - -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: diff --git a/sapi/phpdbg/create-test.php b/sapi/phpdbg/create-test.php index 3388165d86..e5f7cfe2e9 100644..100755 --- a/sapi/phpdbg/create-test.php +++ b/sapi/phpdbg/create-test.php @@ -5,7 +5,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg.1.in b/sapi/phpdbg/phpdbg.1.in index 80c14941d3..357a50b727 100644 --- a/sapi/phpdbg/phpdbg.1.in +++ b/sapi/phpdbg/phpdbg.1.in @@ -1,4 +1,4 @@ -.TH @program_prefix@phpdbg 1 "2018" "The PHP Group" "Scripting Language" +.TH @program_prefix@phpdbg 1 "2019" "The PHP Group" "Scripting Language" .SH NAME @program_prefix@phpdbg \- The interactive PHP debugger .SH SYNOPSIS @@ -134,7 +134,7 @@ contributors all around the world. .SH VERSION INFORMATION This manpage describes \fBphpdbg\fP, for PHP version @PHP_VERSION@. .SH COPYRIGHT -Copyright \(co 1997\-2018 The PHP Group +Copyright \(co The PHP Group .LP 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 diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 03aaf54431..8b01acdfe2 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -181,6 +181,7 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ pg->stdin_file = NULL; pg->cur_command = NULL; + pg->last_line = 0; } /* }}} */ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ @@ -218,18 +219,6 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ static PHP_MSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ { - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); - zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]); - zend_hash_destroy(&PHPDBG_G(seek)); zend_hash_destroy(&PHPDBG_G(registered)); phpdbg_destroy_watchpoints(); @@ -249,7 +238,7 @@ static PHP_MSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ } if (PHPDBG_G(exec)) { - efree(PHPDBG_G(exec)); + free(PHPDBG_G(exec)); PHPDBG_G(exec) = NULL; } @@ -258,12 +247,6 @@ static PHP_MSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ PHPDBG_G(oplog) = NULL; } - if (PHPDBG_G(ops)) { - destroy_op_array(PHPDBG_G(ops)); - efree(PHPDBG_G(ops)); - PHPDBG_G(ops) = NULL; - } - if (PHPDBG_G(oplog_list)) { phpdbg_oplog_list *cur = PHPDBG_G(oplog_list); do { @@ -289,7 +272,7 @@ static PHP_MSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ { /* deactivate symbol table caching to have these properly destroyed upon stack leaving (especially important for watchpoints) */ - EG(symtable_cache_limit) = EG(symtable_cache) - 1; + EG(symtable_cache_limit) = EG(symtable_cache); return SUCCESS; } /* }}} */ @@ -325,11 +308,11 @@ static PHP_FUNCTION(phpdbg_exec) if (sb.st_mode & (S_IFREG|S_IFLNK)) { if (PHPDBG_G(exec)) { ZVAL_STRINGL(return_value, PHPDBG_G(exec), PHPDBG_G(exec_len)); - efree(PHPDBG_G(exec)); + free(PHPDBG_G(exec)); result = 0; } - PHPDBG_G(exec) = estrndup(ZSTR_VAL(exec), ZSTR_LEN(exec)); + PHPDBG_G(exec) = zend_strndup(ZSTR_VAL(exec), ZSTR_LEN(exec)); PHPDBG_G(exec_len) = ZSTR_LEN(exec); if (result) { @@ -467,22 +450,20 @@ static PHP_FUNCTION(phpdbg_start_oplog) if (!prev) { PHPDBG_G(oplog_arena) = zend_arena_create(64 * 1024); - - PHPDBG_G(oplog_cur) = ((phpdbg_oplog_entry *) zend_arena_alloc(&PHPDBG_G(oplog_arena), sizeof(phpdbg_oplog_entry))) + 1; - PHPDBG_G(oplog_cur)->next = NULL; } PHPDBG_G(oplog_list) = emalloc(sizeof(phpdbg_oplog_list)); PHPDBG_G(oplog_list)->prev = prev; - PHPDBG_G(oplog_list)->start = PHPDBG_G(oplog_cur); + PHPDBG_G(oplog_cur) = &PHPDBG_G(oplog_list)->start; + PHPDBG_G(oplog_cur)->next = NULL; } static zend_always_inline zend_bool phpdbg_is_ignored_opcode(zend_uchar opcode) { return opcode == ZEND_NOP || opcode == ZEND_OP_DATA || opcode == ZEND_FE_FREE || opcode == ZEND_FREE || opcode == ZEND_ASSERT_CHECK || opcode == ZEND_VERIFY_RETURN_TYPE - || opcode == ZEND_DECLARE_CONST || opcode == ZEND_DECLARE_CLASS || opcode == ZEND_DECLARE_INHERITED_CLASS || opcode == ZEND_DECLARE_FUNCTION - || opcode == ZEND_DECLARE_INHERITED_CLASS_DELAYED || opcode == ZEND_VERIFY_ABSTRACT_CLASS || opcode == ZEND_ADD_TRAIT || opcode == ZEND_BIND_TRAITS - || opcode == ZEND_DECLARE_ANON_CLASS || opcode == ZEND_DECLARE_ANON_INHERITED_CLASS || opcode == ZEND_FAST_RET || opcode == ZEND_TICKS + || opcode == ZEND_DECLARE_CONST || opcode == ZEND_DECLARE_CLASS || opcode == ZEND_DECLARE_FUNCTION + || opcode == ZEND_DECLARE_CLASS_DELAYED + || opcode == ZEND_DECLARE_ANON_CLASS || opcode == ZEND_FAST_RET || opcode == ZEND_TICKS || opcode == ZEND_EXT_STMT || opcode == ZEND_EXT_FCALL_BEGIN || opcode == ZEND_EXT_FCALL_END || opcode == ZEND_EXT_NOP || opcode == ZEND_BIND_GLOBAL ; } @@ -651,7 +632,7 @@ static PHP_FUNCTION(phpdbg_end_oplog) return; } - cur = PHPDBG_G(oplog_list)->start; + cur = PHPDBG_G(oplog_list)->start.next; prev = PHPDBG_G(oplog_list)->prev; efree(PHPDBG_G(oplog_list)); @@ -671,11 +652,11 @@ static PHP_FUNCTION(phpdbg_end_oplog) { zend_string *last_file = NULL; - HashTable *file_ht; + HashTable *file_ht = NULL; zend_string *last_function = (void *)~(uintptr_t)0; zend_class_entry *last_scope = NULL; - HashTable *insert_ht; + HashTable *insert_ht = NULL; zend_long insert_idx; do { @@ -717,6 +698,7 @@ static PHP_FUNCTION(phpdbg_end_oplog) insert_idx = cur->op->lineno; } + ZEND_ASSERT(insert_ht && file_ht); { zval *num = zend_hash_index_find(insert_ht, insert_idx); if (!num) { @@ -901,6 +883,27 @@ static int php_sapi_phpdbg_activate(void) /* {{{ */ static int php_sapi_phpdbg_deactivate(void) /* {{{ */ { + /* Everything using ZMM should be freed here... */ + zend_hash_destroy(&PHPDBG_G(file_sources)); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]); + zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]); + zend_hash_destroy(&PHPDBG_G(seek)); + + if (PHPDBG_G(ops)) { + destroy_op_array(PHPDBG_G(ops)); + efree(PHPDBG_G(ops)); + PHPDBG_G(ops) = NULL; + } + return SUCCESS; } @@ -952,7 +955,7 @@ typedef struct { int fd; } php_stdio_stream_data; -static size_t phpdbg_stdiop_write(php_stream *stream, const char *buf, size_t count) { +static ssize_t phpdbg_stdiop_write(php_stream *stream, const char *buf, size_t count) { php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract; while (data->fd >= 0) { @@ -1416,9 +1419,10 @@ int main(int argc, char **argv) /* {{{ */ phpdbg_main: #ifdef ZTS - tsrm_startup(1, 1, 0, NULL); - (void)ts_resource(0); + php_tsrm_startup(); +# ifdef PHP_WIN32 ZEND_TSRMLS_CACHE_UPDATE(); +# endif #endif zend_signal_startup(); @@ -1659,16 +1663,17 @@ phpdbg_main: phpdbg_set_color_ex(PHPDBG_COLOR_ERROR, PHPDBG_STRL("red-bold")); phpdbg_set_color_ex(PHPDBG_COLOR_NOTICE, PHPDBG_STRL("green")); - /* set default prompt */ - phpdbg_set_prompt(PHPDBG_DEFAULT_PROMPT); - if (settings > (zend_phpdbg_globals *) 0x2) { #ifdef ZTS - *((zend_phpdbg_globals *) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(phpdbg_globals_id)]) = *settings; + zend_phpdbg_globals *ptr = TSRMG_BULK_STATIC(phpdbg_globals_id, zend_phpdbg_globals *); + *ptr = *settings; #else phpdbg_globals = *settings; #endif free(settings); + } else { + /* set default prompt */ + phpdbg_set_prompt(PHPDBG_DEFAULT_PROMPT); } /* set flags from command line */ @@ -1690,7 +1695,7 @@ phpdbg_main: phpdbg_do_help_cmd(exec); } else if (show_version) { phpdbg_out( - "phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) 1997-2018 The PHP Group\n%s", + "phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) The PHP Group\n%s", PHPDBG_VERSION, __DATE__, __TIME__, @@ -2092,10 +2097,6 @@ phpdbg_out: zend_objects_store_mark_destructed(&EG(objects_store)); } - zend_try { - php_request_shutdown(NULL); - } zend_end_try(); - if (PHPDBG_G(exec) && strcmp("Standard input code", PHPDBG_G(exec)) == SUCCESS) { /* i.e. execution context has been read from stdin - back it up */ phpdbg_file_source *data = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), PHPDBG_G(exec), PHPDBG_G(exec_len)); backup_phpdbg_compile = zend_string_alloc(data->len + 2, 1); @@ -2103,6 +2104,10 @@ phpdbg_out: sprintf(ZSTR_VAL(backup_phpdbg_compile), "?>%.*s", (int) data->len, data->buf); } + zend_try { + php_request_shutdown(NULL); + } zend_end_try(); + /* backup globals when cleaning */ if ((cleaning > 0 || remote) && !quit_immediately) { settings = calloc(1, sizeof(zend_phpdbg_globals)); @@ -2155,12 +2160,6 @@ phpdbg_out: Z_PTR_P(zv) = (void*)PHPDBG_G(orig_url_wrap_php); } - zend_hash_destroy(&PHPDBG_G(file_sources)); - - zend_try { - php_module_shutdown(); - } zend_end_try(); - #ifndef _WIN32 /* force override (no zend_signals) to prevent crashes due to signal recursion in SIGSEGV/SIGBUS handlers */ signal(SIGSEGV, SIG_DFL); @@ -2171,6 +2170,8 @@ phpdbg_out: #endif } + php_module_shutdown(); + sapi_shutdown(); if (sapi_name) { diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 72501bffb4..d0e316c78b 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -46,7 +46,7 @@ #include "zend_ini_scanner.h" #include "zend_stream.h" #include "zend_signal.h" -#if !defined(_WIN32) && !defined(ZEND_SIGNALS) && defined(HAVE_SIGNAL_H) +#if !defined(_WIN32) && !defined(ZEND_SIGNALS) # include <signal.h> #elif defined(PHP_WIN32) # include "win32/signal.h" @@ -106,7 +106,7 @@ #define PHPDBG_NAME "phpdbg" #define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */ #define PHPDBG_ISSUES "http://bugs.php.net/report.php" -#define PHPDBG_VERSION "0.5.0" +#define PHPDBG_VERSION PHP_VERSION #define PHPDBG_INIT_FILENAME ".phpdbginit" #define PHPDBG_DEFAULT_PROMPT "prompt>" /* }}} */ @@ -121,7 +121,7 @@ #if !defined(PHPDBG_WEBDATA_TRANSFER_H) && !defined(PHPDBG_WEBHELPER_H) #ifdef ZTS -# define PHPDBG_G(v) TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v) +# define PHPDBG_G(v) ZEND_TSRMG(phpdbg_globals_id, zend_phpdbg_globals *, v) #else # define PHPDBG_G(v) (phpdbg_globals.v) #endif @@ -290,7 +290,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) int fd; } io[PHPDBG_IO_FDS]; /* io */ int eol; /* type of line ending to use */ - size_t (*php_stdiop_write)(php_stream *, const char *, size_t); + ssize_t (*php_stdiop_write)(php_stream *, const char *, size_t); int in_script_xml; /* in <stream> output mode */ struct { zend_bool active; diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index c0053005ad..3a47c78470 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_bp.h b/sapi/phpdbg/phpdbg_bp.h index 761b0430a7..7e038bb10e 100644 --- a/sapi/phpdbg/phpdbg_bp.h +++ b/sapi/phpdbg/phpdbg_bp.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_break.c b/sapi/phpdbg/phpdbg_break.c index 7e07da996a..719d93d166 100644 --- a/sapi/phpdbg/phpdbg_break.c +++ b/sapi/phpdbg/phpdbg_break.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_break.h b/sapi/phpdbg/phpdbg_break.h index c0a2d45b05..0aafa592e9 100644 --- a/sapi/phpdbg/phpdbg_break.h +++ b/sapi/phpdbg/phpdbg_break.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_btree.c b/sapi/phpdbg/phpdbg_btree.c index 4f5b1e7526..c174920836 100644 --- a/sapi/phpdbg/phpdbg_btree.c +++ b/sapi/phpdbg/phpdbg_btree.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_btree.h b/sapi/phpdbg/phpdbg_btree.h index 196e130305..4ffb72697a 100644 --- a/sapi/phpdbg/phpdbg_btree.h +++ b/sapi/phpdbg/phpdbg_btree.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c index e93e92190e..b736481089 100644 --- a/sapi/phpdbg/phpdbg_cmd.c +++ b/sapi/phpdbg/phpdbg_cmd.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -573,7 +573,7 @@ PHPDBG_API const phpdbg_command_t *phpdbg_stack_resolve(const phpdbg_command_t * const phpdbg_command_t *command = commands; phpdbg_param_t *name = *top; const phpdbg_command_t *matched[3] = {NULL, NULL, NULL}; - ulong matches = 0L; + zend_ulong matches = 0L; while (command && command->name && command->handler) { if (name->len == 1 || command->name_len >= name->len) { @@ -645,7 +645,7 @@ PHPDBG_API const phpdbg_command_t *phpdbg_stack_resolve(const phpdbg_command_t * } /* ", " separated matches */ - phpdbg_error("command", "type=\"ambiguous\" command=\"%s\" matches=\"%lu\" matched=\"%s\"", "The command \"%s\" is ambigious, matching %lu commands (%s)", name->str, matches, list); + phpdbg_error("command", "type=\"ambiguous\" command=\"%s\" matches=\"%lu\" matched=\"%s\"", "The command \"%s\" is ambiguous, matching %lu commands (%s)", name->str, matches, list); efree(list); return NULL; diff --git a/sapi/phpdbg/phpdbg_cmd.h b/sapi/phpdbg/phpdbg_cmd.h index f5d5a8d465..b82ed9aceb 100644 --- a/sapi/phpdbg/phpdbg_cmd.h +++ b/sapi/phpdbg/phpdbg_cmd.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_eol.c b/sapi/phpdbg/phpdbg_eol.c index 25ab833c51..4115ea449b 100644 --- a/sapi/phpdbg/phpdbg_eol.c +++ b/sapi/phpdbg/phpdbg_eol.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -36,11 +36,11 @@ struct phpdbg_eol_rep phpdbg_eol_list[EOL_LIST_LEN] = { int phpdbg_eol_global_update(char *name) { - if (0 == memcmp(name, "CRLF", 4) || 0 == memcmp(name, "crlf", 4) || 0 == memcmp(name, "DOS", 3) || 0 == memcmp(name, "dos", 3)) { + if (0 == strcmp(name, "CRLF") || 0 == strcmp(name, "crlf") || 0 == strcmp(name, "DOS") || 0 == strcmp(name, "dos")) { PHPDBG_G(eol) = PHPDBG_EOL_CRLF; - } else if (0 == memcmp(name, "LF", 2) || 0 == memcmp(name, "lf", 2) || 0 == memcmp(name, "UNIX", 4) || 0 == memcmp(name, "unix", 4)) { + } else if (0 == strcmp(name, "LF") || 0 == strcmp(name, "lf") || 0 == strcmp(name, "UNIX") || 0 == strcmp(name, "unix")) { PHPDBG_G(eol) = PHPDBG_EOL_LF; - } else if (0 == memcmp(name, "CR", 2) || 0 == memcmp(name, "cr", 2) || 0 == memcmp(name, "MAC", 3) || 0 == memcmp(name, "mac", 3)) { + } else if (0 == strcmp(name, "CR") || 0 == strcmp(name, "cr") || 0 == strcmp(name, "MAC") || 0 == strcmp(name, "mac")) { PHPDBG_G(eol) = PHPDBG_EOL_CR; } else { return FAILURE; @@ -81,27 +81,30 @@ char *phpdbg_eol_rep(int id) return NULL; } +/* Marked as never_inline to work around a -Walloc-size-larger-than bug in GCC. */ +static zend_never_inline int count_lf_and_cr(const char *in, int in_len) { + int i, count = 0; + for (i = 0; i < in_len; i++) { + if (0x0a == in[i] || 0x0d == in[i]) { + count++; + } + } + return count; +} /* Inspired by https://ccrma.stanford.edu/~craig/utility/flip/flip.cpp */ void phpdbg_eol_convert(char **str, int *len) { - char *in = *str, *out ; - int in_len = *len, out_len, cursor, i; + char *in = *str, *out; + int in_len = *len, cursor, i; char last, cur; if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) != PHPDBG_IS_REMOTE) { return; } - out_len = *len; if (PHPDBG_EOL_CRLF == PHPDBG_G(eol)) { /* XXX add LFCR case if it's gonna be needed */ - /* depending on the source EOL the out str will have all CR/LF duplicated */ - for (i = 0; i < in_len; i++) { - if (0x0a == in[i] || 0x0d == in[i]) { - out_len++; - } - } - out = (char *)emalloc(out_len); + out = (char *)emalloc(in_len + count_lf_and_cr(in, in_len)); last = cur = in[0]; i = cursor = 0; @@ -142,7 +145,7 @@ void phpdbg_eol_convert(char **str, int *len) } /* We gonna have a smaller or equally long string, estimation is almost neglecting */ - out = (char *)emalloc(out_len); + out = (char *)emalloc(in_len); last = cur = in[0]; i = cursor = 0; diff --git a/sapi/phpdbg/phpdbg_eol.h b/sapi/phpdbg/phpdbg_eol.h index 8d6ee8278e..46141c62cd 100644 --- a/sapi/phpdbg/phpdbg_eol.h +++ b/sapi/phpdbg/phpdbg_eol.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c index 2065277dfe..912089ea23 100644 --- a/sapi/phpdbg/phpdbg_frame.c +++ b/sapi/phpdbg/phpdbg_frame.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -171,7 +171,7 @@ void phpdbg_switch_frame(int frame) /* {{{ */ static void phpdbg_dump_prototype(zval *tmp) /* {{{ */ { - zval *funcname, *class, class_zv, *type, *args, *argstmp; + zval *funcname, *class, class_zv, *args, *argstmp; funcname = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("function")); @@ -183,21 +183,22 @@ static void phpdbg_dump_prototype(zval *tmp) /* {{{ */ } if (class) { - type = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("type")); + zval *type = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("type")); + + phpdbg_xml(" symbol=\"%s%s%s\"", Z_STRVAL_P(class), Z_STRVAL_P(type), Z_STRVAL_P(funcname)); + phpdbg_out("%s%s%s(", Z_STRVAL_P(class), Z_STRVAL_P(type), Z_STRVAL_P(funcname)); + } else { + phpdbg_xml(" symbol=\"%s\"", Z_STRVAL_P(funcname)); + phpdbg_out("%s(", Z_STRVAL_P(funcname)); } args = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("args")); - - phpdbg_xml(" symbol=\"%s%s%s\"", class ? Z_STRVAL_P(class) : "", class ? Z_STRVAL_P(type) : "", Z_STRVAL_P(funcname)); - if (args) { phpdbg_xml(">"); } else { phpdbg_xml(" />"); } - phpdbg_out("%s%s%s(", class ? Z_STRVAL_P(class) : "", class ? Z_STRVAL_P(type) : "", Z_STRVAL_P(funcname)); - if (args) { const zend_function *func = NULL; const zend_arg_info *arginfo = NULL; diff --git a/sapi/phpdbg/phpdbg_frame.h b/sapi/phpdbg/phpdbg_frame.h index 05655314c4..d7d9534b1f 100644 --- a/sapi/phpdbg/phpdbg_frame.h +++ b/sapi/phpdbg/phpdbg_frame.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_help.c b/sapi/phpdbg/phpdbg_help.c index b328906d3c..32d2485ff9 100644 --- a/sapi/phpdbg/phpdbg_help.c +++ b/sapi/phpdbg/phpdbg_help.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -924,7 +924,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " Enable refcount display when hitting watchpoints" CR CR " $P S b 4 off" CR -" Temporarily disable breakpoint 4. This can be subsequently reenabled by a **S b 4 on**." CR +" Temporarily disable breakpoint 4. This can be subsequently re-enabled by a **S b 4 on**." CR //*********** check oplog syntax }, diff --git a/sapi/phpdbg/phpdbg_help.h b/sapi/phpdbg/phpdbg_help.h index b34d84e538..420e6fb014 100644 --- a/sapi/phpdbg/phpdbg_help.h +++ b/sapi/phpdbg/phpdbg_help.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c index 146a45681b..bcec3361fc 100644 --- a/sapi/phpdbg/phpdbg_info.c +++ b/sapi/phpdbg/phpdbg_info.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -343,11 +343,11 @@ PHPDBG_INFO(literal) /* {{{ */ PHPDBG_INFO(memory) /* {{{ */ { size_t used, real, peak_used, peak_real; - zend_mm_heap *heap; + zend_mm_heap *orig_heap = NULL; zend_bool is_mm; if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) { - heap = zend_mm_set_heap(phpdbg_original_heap_sigsafe_mem()); + orig_heap = zend_mm_set_heap(phpdbg_original_heap_sigsafe_mem()); } if ((is_mm = is_zend_mm())) { used = zend_memory_usage(0); @@ -355,8 +355,8 @@ PHPDBG_INFO(memory) /* {{{ */ peak_used = zend_memory_peak_usage(0); peak_real = zend_memory_peak_usage(1); } - if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) { - zend_mm_set_heap(heap); + if (orig_heap) { + zend_mm_set_heap(orig_heap); } if (is_mm) { diff --git a/sapi/phpdbg/phpdbg_info.h b/sapi/phpdbg/phpdbg_info.h index 38137fec14..faf0090bd3 100644 --- a/sapi/phpdbg/phpdbg_info.h +++ b/sapi/phpdbg/phpdbg_info.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_io.c b/sapi/phpdbg/phpdbg_io.c index 1f26f7983b..6917daa9d9 100644 --- a/sapi/phpdbg/phpdbg_io.c +++ b/sapi/phpdbg/phpdbg_io.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -208,7 +208,7 @@ static int phpdbg_output_pager(int sock, const char *ptr, int len) { if (*buf == 'q') { break; } - write(sock, "\r", 1); + zend_quiet_write(sock, "\r", 1); } else break; } } diff --git a/sapi/phpdbg/phpdbg_io.h b/sapi/phpdbg/phpdbg_io.h index deda272da2..d875d276cb 100644 --- a/sapi/phpdbg/phpdbg_io.h +++ b/sapi/phpdbg/phpdbg_io.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_lexer.c b/sapi/phpdbg/phpdbg_lexer.c deleted file mode 100644 index 2ab0b5ac67..0000000000 --- a/sapi/phpdbg/phpdbg_lexer.c +++ /dev/null @@ -1,2085 +0,0 @@ -/* Generated by re2c 1.0.3 */ -#line 1 "sapi/phpdbg/phpdbg_lexer.l" -/* - * phpdbg_lexer.l - */ - -#include "phpdbg.h" -#include "phpdbg_cmd.h" - -#include "phpdbg_parser.h" - -#define LEX(v) (PHPDBG_G(lexer).v) - -#define YYCTYPE unsigned char -#define YYSETCONDITION(x) LEX(state) = x; -#define YYGETCONDITION() LEX(state) -#define YYCURSOR LEX(cursor) -#define YYMARKER LEX(marker) -#define YYCTXMARKER LEX(ctxmarker) -#define yyleng LEX(len) -#define yytext ((char*) LEX(text)) -#undef YYDEBUG -#define YYDEBUG(a, b) -#define YYFILL(n) - -#define NORMAL 0 -#define PRE_RAW 1 -#define RAW 2 -#define INITIAL 3 - -ZEND_EXTERN_MODULE_GLOBALS(phpdbg) - -void phpdbg_init_lexer (phpdbg_param_t *stack, char *input) { - PHPDBG_G(parser_stack) = stack; - - YYSETCONDITION(INITIAL); - - LEX(text) = YYCURSOR = (unsigned char *) input; - LEX(len) = strlen(input); -} - -static int unescape_string(char *s) { - switch (*s) { - case '\'': - case '\"': { - char start = *s; - size_t off = 1; - do { - if (s[off] == '\\') { - off++; - } - *s = s[off]; - } while ((++s)[off] != start); - return off + 1; - } - } - - return 0; -} - -int phpdbg_lex (phpdbg_param_t* yylval) { - -restart: - LEX(text) = YYCURSOR; - - -#line 68 "sapi/phpdbg/phpdbg_lexer.c" -{ - YYCTYPE yych; - unsigned int yyaccept = 0; - if (YYGETCONDITION() < 2) { - if (YYGETCONDITION() < 1) { - goto yyc_NORMAL; - } else { - goto yyc_PRE_RAW; - } - } else { - if (YYGETCONDITION() < 3) { - goto yyc_RAW; - } else { - goto yyc_INITIAL; - } - } -/* *********************************** */ -yyc_NORMAL: - { - static const unsigned char yybm[] = { - /* table 1 .. 8: 0 */ - 0, 62, 62, 62, 62, 62, 62, 62, - 62, 40, 0, 62, 62, 40, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 40, 62, 50, 40, 62, 62, 62, 14, - 62, 62, 62, 62, 62, 62, 63, 62, - 127, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 40, 62, 62, 62, 62, 62, - 62, 254, 254, 254, 254, 254, 254, 190, - 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 62, 2, 62, 62, 62, - 62, 254, 254, 254, 254, 254, 254, 190, - 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 190, 190, 190, 190, 190, - 190, 190, 190, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 62, - /* table 9 .. 10: 256 */ - 0, 64, 64, 64, 64, 64, 64, 64, - 64, 128, 0, 64, 64, 128, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 128, 64, 0, 0, 64, 64, 64, 0, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 0, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - 64, 64, 64, 64, 64, 64, 64, 64, - }; - YYDEBUG(1, *YYCURSOR); - YYFILL(11); - yych = *YYCURSOR; - if (yybm[256+yych] & 128) { - goto yy8; - } - switch (yych) { - case 0x00: - case '\t': - case '\n': goto yy3; - case '"': goto yy11; - case '#': goto yy13; - case '\'': goto yy15; - case '-': goto yy16; - case '.': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy17; - case '0': goto yy20; - case ':': goto yy21; - case 'D': - case 'd': goto yy22; - case 'E': - case 'e': goto yy23; - case 'F': - case 'f': goto yy24; - case 'I': - case 'i': goto yy25; - case 'N': - case 'n': goto yy26; - case 'O': - case 'o': goto yy27; - case 'T': - case 't': goto yy28; - case 'Y': - case 'y': goto yy29; - case 'Z': goto yy30; - case 'z': goto yy31; - default: goto yy5; - } -yy3: - YYDEBUG(3, *YYCURSOR); - ++YYCURSOR; - YYDEBUG(4, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 89 "sapi/phpdbg/phpdbg_lexer.l" - { - return 0; -} -#line 211 "sapi/phpdbg/phpdbg_lexer.c" -yy5: - YYDEBUG(5, *YYCURSOR); - yyaccept = 0; - YYMARKER = ++YYCURSOR; - YYFILL(3); - yych = *YYCURSOR; -yy6: - YYDEBUG(6, *YYCURSOR); - if (yybm[256+yych] & 64) { - goto yy5; - } - if (yych <= ' ') goto yy7; - if (yych == '#') goto yy7; - if (yych <= '\'') goto yy32; - goto yy34; -yy7: - YYDEBUG(7, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 161 "sapi/phpdbg/phpdbg_lexer.l" - { - phpdbg_init_param(yylval, STR_PARAM); - yylval->str = estrndup(yytext, yyleng - unescape_string(yytext)); - yylval->len = yyleng; - return T_ID; -} -#line 237 "sapi/phpdbg/phpdbg_lexer.c" -yy8: - YYDEBUG(8, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(9, *YYCURSOR); - if (yybm[256+yych] & 128) { - goto yy8; - } - YYDEBUG(10, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 175 "sapi/phpdbg/phpdbg_lexer.l" - { - /* ignore whitespace */ - - goto restart; -} -#line 255 "sapi/phpdbg/phpdbg_lexer.c" -yy11: - YYDEBUG(11, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '"') goto yy32; - goto yy36; -yy12: - YYDEBUG(12, *YYCURSOR); - YYCURSOR = YYMARKER; - if (yyaccept <= 3) { - if (yyaccept <= 1) { - if (yyaccept == 0) { - goto yy7; - } else { - goto yy14; - } - } else { - if (yyaccept == 2) { - goto yy19; - } else { - goto yy83; - } - } - } else { - if (yyaccept <= 5) { - if (yyaccept == 4) { - goto yy86; - } else { - goto yy102; - } - } else { - goto yy119; - } - } -yy13: - YYDEBUG(13, *YYCURSOR); - yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '.') { - if (yych <= ',') goto yy14; - if (yych <= '-') { - YYCTXMARKER = YYCURSOR; - goto yy41; - } - YYCTXMARKER = YYCURSOR; - goto yy42; - } else { - if (yych <= '/') goto yy14; - if (yych <= '9') { - YYCTXMARKER = YYCURSOR; - goto yy42; - } - } -yy14: - YYDEBUG(14, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 110 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(INITIAL); - return T_SEPARATOR; -} -#line 316 "sapi/phpdbg/phpdbg_lexer.c" -yy15: - YYDEBUG(15, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '\'') goto yy32; - goto yy46; -yy16: - YYDEBUG(16, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 1) { - goto yy17; - } - if (yych == 'r') goto yy51; - goto yy6; -yy17: - YYDEBUG(17, *YYCURSOR); - yyaccept = 2; - YYMARKER = ++YYCURSOR; - YYFILL(3); - yych = *YYCURSOR; - YYDEBUG(18, *YYCURSOR); - if (yybm[0+yych] & 1) { - goto yy17; - } - if (yych <= ' ') { - if (yych <= '\n') { - if (yych <= 0x00) goto yy19; - if (yych <= 0x08) goto yy5; - } else { - if (yych == '\r') goto yy19; - if (yych <= 0x1F) goto yy5; - } - } else { - if (yych <= '&') { - if (yych <= '!') goto yy5; - if (yych <= '"') goto yy32; - if (yych >= '$') goto yy5; - } else { - if (yych <= '\'') goto yy32; - if (yych <= '/') goto yy5; - if (yych <= ':') goto yy34; - goto yy5; - } - } -yy19: - YYDEBUG(19, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 142 "sapi/phpdbg/phpdbg_lexer.l" - { - phpdbg_init_param(yylval, NUMERIC_PARAM); - yylval->num = atoi(yytext); - return T_DIGITS; -} -#line 370 "sapi/phpdbg/phpdbg_lexer.c" -yy20: - YYDEBUG(20, *YYCURSOR); - yyaccept = 2; - yych = *(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 1) { - goto yy17; - } - if (yych <= 0x1F) { - if (yych <= '\n') { - if (yych <= 0x00) goto yy19; - if (yych <= 0x08) goto yy6; - goto yy19; - } else { - if (yych == '\r') goto yy19; - goto yy6; - } - } else { - if (yych <= '#') { - if (yych <= ' ') goto yy19; - if (yych <= '"') goto yy6; - goto yy19; - } else { - if (yych == 'x') goto yy52; - goto yy6; - } - } -yy21: - YYDEBUG(21, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == ':') goto yy55; - if (yych == '\\') goto yy57; - goto yy53; -yy22: - YYDEBUG(22, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'I') goto yy59; - if (yych == 'i') goto yy59; - goto yy6; -yy23: - YYDEBUG(23, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'N') goto yy60; - if (yych == 'n') goto yy60; - goto yy6; -yy24: - YYDEBUG(24, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy61; - if (yych == 'a') goto yy61; - goto yy6; -yy25: - YYDEBUG(25, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'F') goto yy62; - if (yych == 'f') goto yy62; - goto yy6; -yy26: - YYDEBUG(26, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'O') goto yy63; - if (yych == 'o') goto yy63; - goto yy6; -yy27: - YYDEBUG(27, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 'N') { - if (yych == 'F') goto yy64; - if (yych <= 'M') goto yy6; - goto yy65; - } else { - if (yych <= 'f') { - if (yych <= 'e') goto yy6; - goto yy64; - } else { - if (yych == 'n') goto yy65; - goto yy6; - } - } -yy28: - YYDEBUG(28, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'R') goto yy66; - if (yych == 'r') goto yy66; - goto yy6; -yy29: - YYDEBUG(29, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy67; - if (yych == 'e') goto yy67; - goto yy6; -yy30: - YYDEBUG(30, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy68; - goto yy6; -yy31: - YYDEBUG(31, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'e') goto yy69; - goto yy6; -yy32: - YYDEBUG(32, *YYCURSOR); - ++YYCURSOR; - YYFILL(3); - yych = *YYCURSOR; -yy33: - YYDEBUG(33, *YYCURSOR); - if (yybm[0+yych] & 2) { - goto yy32; - } - if (yych <= '#') goto yy12; - goto yy70; -yy34: - YYDEBUG(34, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '/') goto yy71; - if (yych == '\\') goto yy57; - goto yy12; -yy35: - YYDEBUG(35, *YYCURSOR); - ++YYCURSOR; - YYFILL(4); - yych = *YYCURSOR; -yy36: - YYDEBUG(36, *YYCURSOR); - if (yybm[0+yych] & 4) { - goto yy35; - } - if (yych <= ' ') { - if (yych <= 0x00) goto yy12; - if (yych == '\n') goto yy12; - } else { - if (yych <= '"') goto yy72; - if (yych <= '#') goto yy37; - if (yych <= ':') goto yy39; - goto yy40; - } -yy37: - YYDEBUG(37, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; -yy38: - YYDEBUG(38, *YYCURSOR); - if (yybm[0+yych] & 8) { - goto yy37; - } - if (yych <= '\n') goto yy12; - if (yych <= '"') goto yy73; - goto yy74; -yy39: - YYDEBUG(39, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '/') goto yy75; - goto yy38; -yy40: - YYDEBUG(40, *YYCURSOR); - ++YYCURSOR; - YYFILL(3); - yych = *YYCURSOR; - if (yych <= ' ') { - if (yych <= '\n') { - if (yych <= 0x00) goto yy12; - if (yych <= 0x08) goto yy32; - goto yy12; - } else { - if (yych == '\r') goto yy12; - if (yych <= 0x1F) goto yy32; - goto yy12; - } - } else { - if (yych <= '9') { - if (yych <= '!') goto yy32; - if (yych <= '"') goto yy35; - if (yych <= '#') goto yy12; - goto yy32; - } else { - if (yych <= ':') goto yy70; - if (yych == '\\') goto yy35; - goto yy32; - } - } -yy41: - YYDEBUG(41, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '.') goto yy42; - if (yych <= '/') goto yy12; - if (yych >= ':') goto yy12; -yy42: - YYDEBUG(42, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(43, *YYCURSOR); - if (yych == '.') goto yy42; - if (yych <= '/') goto yy44; - if (yych <= '9') goto yy42; -yy44: - YYDEBUG(44, *YYCURSOR); - YYCURSOR = YYCTXMARKER; - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 106 "sapi/phpdbg/phpdbg_lexer.l" - { - return T_POUND; -} -#line 586 "sapi/phpdbg/phpdbg_lexer.c" -yy45: - YYDEBUG(45, *YYCURSOR); - ++YYCURSOR; - YYFILL(4); - yych = *YYCURSOR; -yy46: - YYDEBUG(46, *YYCURSOR); - if (yybm[0+yych] & 16) { - goto yy45; - } - if (yych <= '\n') { - if (yych <= 0x00) goto yy12; - if (yych >= '\n') goto yy12; - } else { - if (yych <= '#') goto yy47; - if (yych <= '\'') goto yy72; - if (yych <= ':') goto yy49; - goto yy50; - } -yy47: - YYDEBUG(47, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; -yy48: - YYDEBUG(48, *YYCURSOR); - if (yybm[0+yych] & 32) { - goto yy47; - } - if (yych <= '\n') goto yy12; - if (yych <= '\'') goto yy73; - goto yy76; -yy49: - YYDEBUG(49, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '/') goto yy77; - goto yy48; -yy50: - YYDEBUG(50, *YYCURSOR); - ++YYCURSOR; - YYFILL(3); - yych = *YYCURSOR; - if (yych <= '"') { - if (yych <= '\f') { - if (yych <= 0x00) goto yy12; - if (yych <= 0x08) goto yy32; - if (yych <= '\n') goto yy12; - goto yy32; - } else { - if (yych <= '\r') goto yy12; - if (yych == ' ') goto yy12; - goto yy32; - } - } else { - if (yych <= '9') { - if (yych <= '#') goto yy12; - if (yych == '\'') goto yy45; - goto yy32; - } else { - if (yych <= ':') goto yy70; - if (yych == '\\') goto yy45; - goto yy32; - } - } -yy51: - YYDEBUG(51, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= ' ') { - if (yych <= '\f') { - if (yych == '\t') goto yy78; - goto yy6; - } else { - if (yych <= '\r') goto yy78; - if (yych <= 0x1F) goto yy6; - goto yy78; - } - } else { - if (yych <= '.') { - if (yych <= ',') goto yy6; - if (yych <= '-') goto yy80; - goto yy81; - } else { - if (yych <= '/') goto yy6; - if (yych <= '9') goto yy81; - goto yy6; - } - } -yy52: - YYDEBUG(52, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 64) { - goto yy84; - } - goto yy6; -yy53: - YYDEBUG(53, *YYCURSOR); - ++YYCURSOR; - YYDEBUG(54, *YYCURSOR); - YYCURSOR -= 1; - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 119 "sapi/phpdbg/phpdbg_lexer.l" - { - return T_COLON; -} -#line 693 "sapi/phpdbg/phpdbg_lexer.c" -yy55: - YYDEBUG(55, *YYCURSOR); - ++YYCURSOR; - YYDEBUG(56, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 115 "sapi/phpdbg/phpdbg_lexer.l" - { - return T_DCOLON; -} -#line 703 "sapi/phpdbg/phpdbg_lexer.c" -yy57: - YYDEBUG(57, *YYCURSOR); - yyaccept = 0; - YYMARKER = ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(58, *YYCURSOR); - if (yych <= ' ') { - if (yych <= '\n') { - if (yych <= 0x00) goto yy7; - if (yych <= 0x08) goto yy57; - goto yy7; - } else { - if (yych == '\r') goto yy7; - if (yych <= 0x1F) goto yy57; - goto yy7; - } - } else { - if (yych <= '&') { - if (yych <= '!') goto yy57; - if (yych <= '#') goto yy7; - goto yy57; - } else { - if (yych <= '\'') goto yy7; - if (yych == ':') goto yy87; - goto yy57; - } - } -yy59: - YYDEBUG(59, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy88; - if (yych == 's') goto yy88; - goto yy6; -yy60: - YYDEBUG(60, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy89; - if (yych == 'a') goto yy89; - goto yy6; -yy61: - YYDEBUG(61, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy90; - if (yych == 'l') goto yy90; - goto yy6; -yy62: - YYDEBUG(62, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '\f') { - if (yych == '\t') goto yy91; - goto yy6; - } else { - if (yych <= '\r') goto yy91; - if (yych == ' ') goto yy91; - goto yy6; - } -yy63: - YYDEBUG(63, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '\f') { - if (yych <= 0x00) goto yy94; - if (yych <= 0x08) goto yy6; - if (yych <= '\n') goto yy94; - goto yy6; - } else { - if (yych <= '\r') goto yy94; - if (yych == ' ') goto yy94; - goto yy6; - } -yy64: - YYDEBUG(64, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'F') goto yy63; - if (yych == 'f') goto yy63; - goto yy6; -yy65: - YYDEBUG(65, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '\f') { - if (yych <= 0x00) goto yy96; - if (yych <= 0x08) goto yy6; - if (yych <= '\n') goto yy96; - goto yy6; - } else { - if (yych <= '\r') goto yy96; - if (yych == ' ') goto yy96; - goto yy6; - } -yy66: - YYDEBUG(66, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'U') goto yy98; - if (yych == 'u') goto yy98; - goto yy6; -yy67: - YYDEBUG(67, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy65; - if (yych == 's') goto yy65; - goto yy6; -yy68: - YYDEBUG(68, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'N') goto yy99; - goto yy6; -yy69: - YYDEBUG(69, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'n') goto yy100; - goto yy6; -yy70: - YYDEBUG(70, *YYCURSOR); - yych = *++YYCURSOR; - if (yych != '/') goto yy12; -yy71: - YYDEBUG(71, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '/') goto yy101; - goto yy12; -yy72: - YYDEBUG(72, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= '\r') { - if (yych <= 0x08) { - if (yych <= 0x00) goto yy7; - goto yy33; - } else { - if (yych <= '\n') goto yy7; - if (yych <= '\f') goto yy33; - goto yy7; - } - } else { - if (yych <= ' ') { - if (yych <= 0x1F) goto yy33; - goto yy7; - } else { - if (yych == '#') goto yy7; - goto yy33; - } - } -yy73: - YYDEBUG(73, *YYCURSOR); - ++YYCURSOR; - goto yy7; -yy74: - YYDEBUG(74, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yych == '"') goto yy37; - if (yych == '\\') goto yy37; - goto yy12; -yy75: - YYDEBUG(75, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '/') goto yy103; - goto yy38; -yy76: - YYDEBUG(76, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yych == '\'') goto yy47; - if (yych == '\\') goto yy47; - goto yy12; -yy77: - YYDEBUG(77, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '/') goto yy104; - goto yy48; -yy78: - YYDEBUG(78, *YYCURSOR); - ++YYCURSOR; - YYFILL(2); - yych = *YYCURSOR; - YYDEBUG(79, *YYCURSOR); - if (yych <= ' ') { - if (yych <= '\f') { - if (yych == '\t') goto yy78; - goto yy12; - } else { - if (yych <= '\r') goto yy78; - if (yych <= 0x1F) goto yy12; - goto yy78; - } - } else { - if (yych <= '.') { - if (yych <= ',') goto yy12; - if (yych <= '-') goto yy105; - goto yy106; - } else { - if (yych <= '/') goto yy12; - if (yych <= '9') goto yy106; - goto yy12; - } - } -yy80: - YYDEBUG(80, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == '.') goto yy81; - if (yych <= '/') goto yy6; - if (yych >= ':') goto yy6; -yy81: - YYDEBUG(81, *YYCURSOR); - yyaccept = 3; - YYMARKER = ++YYCURSOR; - YYFILL(3); - yych = *YYCURSOR; - YYDEBUG(82, *YYCURSOR); - if (yych <= '"') { - if (yych <= '\f') { - if (yych <= 0x00) goto yy83; - if (yych <= 0x08) goto yy5; - if (yych >= '\v') goto yy5; - } else { - if (yych <= 0x1F) { - if (yych >= 0x0E) goto yy5; - } else { - if (yych <= ' ') goto yy83; - if (yych <= '!') goto yy5; - goto yy32; - } - } - } else { - if (yych <= '-') { - if (yych <= '#') goto yy83; - if (yych == '\'') goto yy32; - goto yy5; - } else { - if (yych <= '/') { - if (yych <= '.') goto yy81; - goto yy5; - } else { - if (yych <= '9') goto yy81; - if (yych <= ':') goto yy34; - goto yy5; - } - } - } -yy83: - YYDEBUG(83, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 93 "sapi/phpdbg/phpdbg_lexer.l" - { - char *text = yytext + 2; - while (*++text < '0'); - yylval->num = atoi(text); - return T_REQ_ID; -} -#line 967 "sapi/phpdbg/phpdbg_lexer.c" -yy84: - YYDEBUG(84, *YYCURSOR); - yyaccept = 4; - YYMARKER = ++YYCURSOR; - YYFILL(3); - yych = *YYCURSOR; - YYDEBUG(85, *YYCURSOR); - if (yybm[0+yych] & 64) { - goto yy84; - } - if (yych <= ' ') { - if (yych <= '\n') { - if (yych <= 0x00) goto yy86; - if (yych <= 0x08) goto yy5; - } else { - if (yych == '\r') goto yy86; - if (yych <= 0x1F) goto yy5; - } - } else { - if (yych <= '&') { - if (yych <= '!') goto yy5; - if (yych <= '"') goto yy32; - if (yych >= '$') goto yy5; - } else { - if (yych <= '\'') goto yy32; - if (yych <= '/') goto yy5; - if (yych <= ':') goto yy34; - goto yy5; - } - } -yy86: - YYDEBUG(86, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 148 "sapi/phpdbg/phpdbg_lexer.l" - { - phpdbg_init_param(yylval, ADDR_PARAM); - yylval->addr = strtoul(yytext, 0, 16); - return T_ADDR; -} -#line 1007 "sapi/phpdbg/phpdbg_lexer.c" -yy87: - YYDEBUG(87, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yych == '\\') goto yy57; - goto yy12; -yy88: - YYDEBUG(88, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'A') goto yy108; - if (yych == 'a') goto yy108; - goto yy6; -yy89: - YYDEBUG(89, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'B') goto yy109; - if (yych == 'b') goto yy109; - goto yy6; -yy90: - YYDEBUG(90, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'S') goto yy110; - if (yych == 's') goto yy110; - goto yy6; -yy91: - YYDEBUG(91, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(92, *YYCURSOR); - if (yych <= '\f') { - if (yych == '\t') goto yy91; - } else { - if (yych <= '\r') goto yy91; - if (yych == ' ') goto yy91; - } - YYDEBUG(93, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 100 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_IF; -} -#line 1056 "sapi/phpdbg/phpdbg_lexer.c" -yy94: - YYDEBUG(94, *YYCURSOR); - ++YYCURSOR; - YYDEBUG(95, *YYCURSOR); - YYCURSOR -= 1; - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 136 "sapi/phpdbg/phpdbg_lexer.l" - { - phpdbg_init_param(yylval, NUMERIC_PARAM); - yylval->num = 0; - return T_FALSY; -} -#line 1069 "sapi/phpdbg/phpdbg_lexer.c" -yy96: - YYDEBUG(96, *YYCURSOR); - ++YYCURSOR; - YYDEBUG(97, *YYCURSOR); - YYCURSOR -= 1; - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 130 "sapi/phpdbg/phpdbg_lexer.l" - { - phpdbg_init_param(yylval, NUMERIC_PARAM); - yylval->num = 1; - return T_TRUTHY; -} -#line 1082 "sapi/phpdbg/phpdbg_lexer.c" -yy98: - YYDEBUG(98, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy65; - if (yych == 'e') goto yy65; - goto yy6; -yy99: - YYDEBUG(99, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'D') goto yy111; - goto yy6; -yy100: - YYDEBUG(100, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'd') goto yy111; - goto yy6; -yy101: - YYDEBUG(101, *YYCURSOR); - ++YYCURSOR; -yy102: - YYDEBUG(102, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 123 "sapi/phpdbg/phpdbg_lexer.l" - { - phpdbg_init_param(yylval, STR_PARAM); - yylval->str = estrndup(yytext, yyleng); - yylval->len = yyleng; - return T_PROTO; -} -#line 1115 "sapi/phpdbg/phpdbg_lexer.c" -yy103: - YYDEBUG(103, *YYCURSOR); - yyaccept = 5; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x00) goto yy102; - if (yych == '\n') goto yy102; - goto yy38; -yy104: - YYDEBUG(104, *YYCURSOR); - yyaccept = 5; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x00) goto yy102; - if (yych == '\n') goto yy102; - goto yy48; -yy105: - YYDEBUG(105, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == '.') goto yy106; - if (yych <= '/') goto yy12; - if (yych >= ':') goto yy12; -yy106: - YYDEBUG(106, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(107, *YYCURSOR); - if (yych == '.') goto yy106; - if (yych <= '/') goto yy83; - if (yych <= '9') goto yy106; - goto yy83; -yy108: - YYDEBUG(108, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'B') goto yy112; - if (yych == 'b') goto yy112; - goto yy6; -yy109: - YYDEBUG(109, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy113; - if (yych == 'l') goto yy113; - goto yy6; -yy110: - YYDEBUG(110, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy63; - if (yych == 'e') goto yy63; - goto yy6; -yy111: - YYDEBUG(111, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == '_') goto yy114; - goto yy6; -yy112: - YYDEBUG(112, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'L') goto yy115; - if (yych == 'l') goto yy115; - goto yy6; -yy113: - YYDEBUG(113, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy116; - if (yych == 'e') goto yy116; - goto yy6; -yy114: - YYDEBUG(114, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy117; - } - goto yy6; -yy115: - YYDEBUG(115, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy120; - if (yych == 'e') goto yy120; - goto yy6; -yy116: - YYDEBUG(116, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'D') goto yy65; - if (yych == 'd') goto yy65; - goto yy6; -yy117: - YYDEBUG(117, *YYCURSOR); - yyaccept = 6; - YYMARKER = ++YYCURSOR; - YYFILL(3); - yych = *YYCURSOR; - YYDEBUG(118, *YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy117; - } - if (yych <= ' ') { - if (yych <= '\n') { - if (yych <= 0x00) goto yy119; - if (yych <= 0x08) goto yy5; - } else { - if (yych == '\r') goto yy119; - if (yych <= 0x1F) goto yy5; - } - } else { - if (yych <= '&') { - if (yych <= '!') goto yy5; - if (yych <= '"') goto yy32; - if (yych >= '$') goto yy5; - } else { - if (yych <= '\'') goto yy32; - if (yych == ':') goto yy34; - goto yy5; - } - } -yy119: - YYDEBUG(119, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 154 "sapi/phpdbg/phpdbg_lexer.l" - { - phpdbg_init_param(yylval, OP_PARAM); - yylval->str = estrndup(yytext, yyleng); - yylval->len = yyleng; - return T_OPCODE; -} -#line 1248 "sapi/phpdbg/phpdbg_lexer.c" -yy120: - YYDEBUG(120, *YYCURSOR); - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'D') goto yy63; - if (yych == 'd') goto yy63; - goto yy6; - } -/* *********************************** */ -yyc_PRE_RAW: - { - static const unsigned char yybm[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 64, 0, 0, 0, 64, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 128, 0, - 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - }; - YYDEBUG(121, *YYCURSOR); - YYFILL(2); - yych = *YYCURSOR; - if (yych <= '\r') { - if (yych == '\t') goto yy125; - if (yych >= '\r') goto yy125; - } else { - if (yych <= ' ') { - if (yych >= ' ') goto yy126; - } else { - if (yych == '-') goto yy129; - } - } - YYDEBUG(123, *YYCURSOR); - ++YYCURSOR; -yy124: - YYDEBUG(124, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 199 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(RAW); - - YYCURSOR = LEX(text); - goto restart; -} -#line 1319 "sapi/phpdbg/phpdbg_lexer.c" -yy125: - YYDEBUG(125, *YYCURSOR); - yych = *++YYCURSOR; - if (yybm[0+yych] & 64) { - goto yy126; - } - goto yy124; -yy126: - YYDEBUG(126, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(127, *YYCURSOR); - if (yybm[0+yych] & 64) { - goto yy126; - } - YYDEBUG(128, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 175 "sapi/phpdbg/phpdbg_lexer.l" - { - /* ignore whitespace */ - - goto restart; -} -#line 1344 "sapi/phpdbg/phpdbg_lexer.c" -yy129: - YYDEBUG(129, *YYCURSOR); - yych = *(YYMARKER = ++YYCURSOR); - if (yych != 'r') goto yy124; -yy130: - YYDEBUG(130, *YYCURSOR); - ++YYCURSOR; - YYFILL(2); - yych = *YYCURSOR; - YYDEBUG(131, *YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy134; - } - if (yych <= '\r') { - if (yych == '\t') goto yy130; - if (yych >= '\r') goto yy130; - } else { - if (yych <= ' ') { - if (yych >= ' ') goto yy130; - } else { - if (yych == '-') goto yy133; - } - } -yy132: - YYDEBUG(132, *YYCURSOR); - YYCURSOR = YYMARKER; - goto yy124; -yy133: - YYDEBUG(133, *YYCURSOR); - yych = *++YYCURSOR; - if (yybm[0+yych] & 128) { - goto yy134; - } - goto yy132; -yy134: - YYDEBUG(134, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(135, *YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy134; - } - YYDEBUG(136, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 93 "sapi/phpdbg/phpdbg_lexer.l" - { - char *text = yytext + 2; - while (*++text < '0'); - yylval->num = atoi(text); - return T_REQ_ID; -} -#line 1397 "sapi/phpdbg/phpdbg_lexer.c" - } -/* *********************************** */ -yyc_RAW: - { - static const unsigned char yybm[] = { - 0, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 0, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 64, 224, 232, 232, 232, 32, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 16, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 232, 232, 232, 232, - }; - YYDEBUG(137, *YYCURSOR); - YYFILL(1); - yych = *YYCURSOR; - if (yybm[0+yych] & 8) { - goto yy141; - } - if (yych <= '\n') goto yy139; - if (yych <= '"') goto yy144; - if (yych <= '#') goto yy146; - if (yych <= '\'') goto yy148; - goto yy149; -yy139: - YYDEBUG(139, *YYCURSOR); - ++YYCURSOR; - YYDEBUG(140, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 89 "sapi/phpdbg/phpdbg_lexer.l" - { - return 0; -} -#line 1456 "sapi/phpdbg/phpdbg_lexer.c" -yy141: - YYDEBUG(141, *YYCURSOR); - YYMARKER = ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(142, *YYCURSOR); - if (yybm[0+yych] & 8) { - goto yy141; - } - if (yych <= '\n') goto yy143; - if (yych <= '"') goto yy144; - if (yych <= '#') goto yy143; - if (yych <= '\'') goto yy148; - goto yy149; -yy143: - YYDEBUG(143, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 168 "sapi/phpdbg/phpdbg_lexer.l" - { - phpdbg_init_param(yylval, STR_PARAM); - yylval->str = estrdup(yytext); - yylval->len = yyleng; - return T_INPUT; -} -#line 1481 "sapi/phpdbg/phpdbg_lexer.c" -yy144: - YYDEBUG(144, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yybm[0+yych] & 32) { - goto yy151; - } - if (yych >= '#') goto yy153; -yy145: - YYDEBUG(145, *YYCURSOR); - YYCURSOR = YYMARKER; - goto yy143; -yy146: - YYDEBUG(146, *YYCURSOR); - ++YYCURSOR; - YYDEBUG(147, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 110 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(INITIAL); - return T_SEPARATOR; -} -#line 1505 "sapi/phpdbg/phpdbg_lexer.c" -yy148: - YYDEBUG(148, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yybm[0+yych] & 64) { - goto yy155; - } - if (yych <= '\'') goto yy145; - goto yy157; -yy149: - YYDEBUG(149, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(150, *YYCURSOR); - if (yybm[0+yych] & 16) { - goto yy149; - } - if (yych <= '!') { - if (yych <= 0x00) goto yy143; - if (yych == '\n') goto yy143; - goto yy141; - } else { - if (yych <= '"') goto yy159; - if (yych == '\'') goto yy160; - goto yy141; - } -yy151: - YYDEBUG(151, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(152, *YYCURSOR); - if (yybm[0+yych] & 32) { - goto yy151; - } - if (yych <= '\n') goto yy145; - if (yych <= '"') goto yy141; -yy153: - YYDEBUG(153, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(154, *YYCURSOR); - if (yybm[0+yych] & 32) { - goto yy151; - } - if (yych <= '\n') goto yy145; - if (yych <= '"') goto yy161; - goto yy153; -yy155: - YYDEBUG(155, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(156, *YYCURSOR); - if (yybm[0+yych] & 64) { - goto yy155; - } - if (yych <= '\n') goto yy145; - if (yych <= '\'') goto yy141; -yy157: - YYDEBUG(157, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(158, *YYCURSOR); - if (yybm[0+yych] & 64) { - goto yy155; - } - if (yych <= '\n') goto yy145; - if (yych <= '\'') goto yy163; - goto yy157; -yy159: - YYDEBUG(159, *YYCURSOR); - YYMARKER = ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yych <= '"') { - if (yych <= '\t') { - if (yych <= 0x00) goto yy143; - goto yy161; - } else { - if (yych <= '\n') goto yy143; - if (yych <= '!') goto yy161; - goto yy144; - } - } else { - if (yych <= '\'') { - if (yych <= '#') goto yy151; - if (yych <= '&') goto yy161; - goto yy165; - } else { - if (yych == '\\') goto yy166; - goto yy161; - } - } -yy160: - YYDEBUG(160, *YYCURSOR); - YYMARKER = ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yych <= '"') { - if (yych <= '\t') { - if (yych <= 0x00) goto yy143; - goto yy163; - } else { - if (yych <= '\n') goto yy143; - if (yych <= '!') goto yy163; - goto yy168; - } - } else { - if (yych <= '\'') { - if (yych <= '#') goto yy155; - if (yych <= '&') goto yy163; - goto yy148; - } else { - if (yych == '\\') goto yy169; - goto yy163; - } - } -yy161: - YYDEBUG(161, *YYCURSOR); - YYMARKER = ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(162, *YYCURSOR); - if (yych <= '"') { - if (yych <= '\t') { - if (yych <= 0x00) goto yy143; - goto yy161; - } else { - if (yych <= '\n') goto yy143; - if (yych <= '!') goto yy161; - goto yy159; - } - } else { - if (yych <= '\'') { - if (yych <= '#') goto yy151; - if (yych <= '&') goto yy161; - goto yy165; - } else { - if (yych == '\\') goto yy166; - goto yy161; - } - } -yy163: - YYDEBUG(163, *YYCURSOR); - YYMARKER = ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(164, *YYCURSOR); - if (yych <= '"') { - if (yych <= '\t') { - if (yych <= 0x00) goto yy143; - goto yy163; - } else { - if (yych <= '\n') goto yy143; - if (yych <= '!') goto yy163; - goto yy168; - } - } else { - if (yych <= '\'') { - if (yych <= '#') goto yy155; - if (yych <= '&') goto yy163; - goto yy160; - } else { - if (yych == '\\') goto yy169; - goto yy163; - } - } -yy165: - YYDEBUG(165, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yybm[0+yych] & 128) { - goto yy171; - } - if (yych <= '\n') goto yy145; - if (yych <= '"') goto yy163; - if (yych <= '\'') goto yy151; - goto yy173; -yy166: - YYDEBUG(166, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(167, *YYCURSOR); - if (yych <= '&') { - if (yych <= 0x00) goto yy143; - if (yych == '\n') goto yy143; - goto yy161; - } else { - if (yych <= '\'') goto yy175; - if (yych == '\\') goto yy166; - goto yy161; - } -yy168: - YYDEBUG(168, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yybm[0+yych] & 128) { - goto yy171; - } - if (yych <= '\n') goto yy145; - if (yych <= '"') goto yy155; - if (yych <= '\'') goto yy161; - goto yy173; -yy169: - YYDEBUG(169, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(170, *YYCURSOR); - if (yych <= '!') { - if (yych <= 0x00) goto yy143; - if (yych == '\n') goto yy143; - goto yy163; - } else { - if (yych <= '"') goto yy176; - if (yych == '\\') goto yy169; - goto yy163; - } -yy171: - YYDEBUG(171, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(172, *YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy171; - } - if (yych <= '\n') goto yy145; - if (yych <= '"') goto yy163; - if (yych <= '\'') goto yy161; -yy173: - YYDEBUG(173, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(174, *YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy171; - } - if (yych <= '\n') goto yy145; - if (yych <= '\'') goto yy177; - goto yy173; -yy175: - YYDEBUG(175, *YYCURSOR); - YYMARKER = ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yych <= '"') { - if (yych <= '\t') { - if (yych <= 0x00) goto yy143; - goto yy177; - } else { - if (yych <= '\n') goto yy143; - if (yych <= '!') goto yy177; - } - } else { - if (yych <= '\'') { - if (yych <= '#') goto yy171; - if (yych <= '&') goto yy177; - goto yy165; - } else { - if (yych == '\\') goto yy179; - goto yy177; - } - } -yy176: - YYDEBUG(176, *YYCURSOR); - YYMARKER = ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - if (yych <= '"') { - if (yych <= '\t') { - if (yych <= 0x00) goto yy143; - } else { - if (yych <= '\n') goto yy143; - if (yych >= '"') goto yy168; - } - } else { - if (yych <= '\'') { - if (yych <= '#') goto yy171; - if (yych >= '\'') goto yy175; - } else { - if (yych == '\\') goto yy179; - } - } -yy177: - YYDEBUG(177, *YYCURSOR); - YYMARKER = ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(178, *YYCURSOR); - if (yych <= '"') { - if (yych <= '\t') { - if (yych <= 0x00) goto yy143; - goto yy177; - } else { - if (yych <= '\n') goto yy143; - if (yych <= '!') goto yy177; - goto yy176; - } - } else { - if (yych <= '\'') { - if (yych <= '#') goto yy171; - if (yych <= '&') goto yy177; - goto yy175; - } else { - if (yych != '\\') goto yy177; - } - } -yy179: - YYDEBUG(179, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(180, *YYCURSOR); - if (yych <= '\n') { - if (yych <= 0x00) goto yy143; - if (yych <= '\t') goto yy177; - goto yy143; - } else { - if (yych == '\\') goto yy179; - goto yy177; - } - } -/* *********************************** */ -yyc_INITIAL: - { - static const unsigned char yybm[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 128, 0, 0, 0, 128, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 128, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - }; - YYDEBUG(181, *YYCURSOR); - YYFILL(4); - yych = *YYCURSOR; - if (yych <= 'E') { - if (yych <= '\r') { - if (yych == '\t') goto yy185; - if (yych >= '\r') goto yy185; - } else { - if (yych == ' ') goto yy186; - if (yych >= 'E') goto yy189; - } - } else { - if (yych <= 'd') { - if (yych <= 'Q') goto yy183; - if (yych <= 'R') goto yy190; - if (yych <= 'S') goto yy191; - } else { - if (yych <= 'q') { - if (yych <= 'e') goto yy189; - } else { - if (yych <= 'r') goto yy192; - if (yych <= 's') goto yy191; - } - } - } -yy183: - YYDEBUG(183, *YYCURSOR); - ++YYCURSOR; -yy184: - YYDEBUG(184, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 206 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(NORMAL); - - YYCURSOR = LEX(text); - goto restart; -} -#line 1913 "sapi/phpdbg/phpdbg_lexer.c" -yy185: - YYDEBUG(185, *YYCURSOR); - yych = *++YYCURSOR; - if (yybm[0+yych] & 128) { - goto yy186; - } - goto yy184; -yy186: - YYDEBUG(186, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(187, *YYCURSOR); - if (yybm[0+yych] & 128) { - goto yy186; - } - YYDEBUG(188, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 175 "sapi/phpdbg/phpdbg_lexer.l" - { - /* ignore whitespace */ - - goto restart; -} -#line 1938 "sapi/phpdbg/phpdbg_lexer.c" -yy189: - YYDEBUG(189, *YYCURSOR); - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'V') goto yy193; - if (yych == 'v') goto yy193; - goto yy184; -yy190: - YYDEBUG(190, *YYCURSOR); - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'U') goto yy195; - if (yych == 'u') goto yy195; - goto yy184; -yy191: - YYDEBUG(191, *YYCURSOR); - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'H') goto yy196; - if (yych == 'h') goto yy196; - goto yy184; -yy192: - YYDEBUG(192, *YYCURSOR); - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x1F) { - if (yych <= '\t') { - if (yych <= 0x08) goto yy184; - goto yy197; - } else { - if (yych == '\r') goto yy197; - goto yy184; - } - } else { - if (yych <= 'U') { - if (yych <= ' ') goto yy197; - if (yych <= 'T') goto yy184; - goto yy195; - } else { - if (yych == 'u') goto yy195; - goto yy184; - } - } -yy193: - YYDEBUG(193, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= '\f') { - if (yych == '\t') goto yy200; - } else { - if (yych <= '\r') goto yy200; - if (yych == ' ') goto yy200; - } -yy194: - YYDEBUG(194, *YYCURSOR); - YYCURSOR = YYMARKER; - goto yy184; -yy195: - YYDEBUG(195, *YYCURSOR); - yych = *++YYCURSOR; - if (yych == 'N') goto yy203; - if (yych == 'n') goto yy203; - goto yy194; -yy196: - YYDEBUG(196, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= '\f') { - if (yych == '\t') goto yy204; - goto yy194; - } else { - if (yych <= '\r') goto yy204; - if (yych == ' ') goto yy204; - goto yy194; - } -yy197: - YYDEBUG(197, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(198, *YYCURSOR); - if (yych <= '\f') { - if (yych == '\t') goto yy197; - } else { - if (yych <= '\r') goto yy197; - if (yych == ' ') goto yy197; - } - YYDEBUG(199, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 193 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(PRE_RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_RUN; -} -#line 2028 "sapi/phpdbg/phpdbg_lexer.c" -yy200: - YYDEBUG(200, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(201, *YYCURSOR); - if (yych <= '\f') { - if (yych == '\t') goto yy200; - } else { - if (yych <= '\r') goto yy200; - if (yych == ' ') goto yy200; - } - YYDEBUG(202, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 181 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(PRE_RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_EVAL; -} -#line 2049 "sapi/phpdbg/phpdbg_lexer.c" -yy203: - YYDEBUG(203, *YYCURSOR); - yych = *++YYCURSOR; - if (yych <= '\f') { - if (yych == '\t') goto yy197; - goto yy194; - } else { - if (yych <= '\r') goto yy197; - if (yych == ' ') goto yy197; - goto yy194; - } -yy204: - YYDEBUG(204, *YYCURSOR); - ++YYCURSOR; - YYFILL(1); - yych = *YYCURSOR; - YYDEBUG(205, *YYCURSOR); - if (yych <= '\f') { - if (yych == '\t') goto yy204; - } else { - if (yych <= '\r') goto yy204; - if (yych == ' ') goto yy204; - } - YYDEBUG(206, *YYCURSOR); - yyleng = (size_t) YYCURSOR - (size_t) yytext; -#line 187 "sapi/phpdbg/phpdbg_lexer.l" - { - YYSETCONDITION(PRE_RAW); - phpdbg_init_param(yylval, EMPTY_PARAM); - return T_SHELL; -} -#line 2081 "sapi/phpdbg/phpdbg_lexer.c" - } -} -#line 213 "sapi/phpdbg/phpdbg_lexer.l" - -} diff --git a/sapi/phpdbg/phpdbg_lexer.h b/sapi/phpdbg/phpdbg_lexer.h index 90f9963b3c..e1cc55ccf3 100644 --- a/sapi/phpdbg/phpdbg_lexer.h +++ b/sapi/phpdbg/phpdbg_lexer.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c index a9b0f4b815..03b4c3526e 100644 --- a/sapi/phpdbg/phpdbg_list.c +++ b/sapi/phpdbg/phpdbg_list.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_list.h b/sapi/phpdbg/phpdbg_list.h index 474bfdf4f5..68cbee8c16 100644 --- a/sapi/phpdbg/phpdbg_list.h +++ b/sapi/phpdbg/phpdbg_list.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_opcode.c b/sapi/phpdbg/phpdbg_opcode.c index b14a1c23e2..2d6bcd4f78 100644 --- a/sapi/phpdbg/phpdbg_opcode.c +++ b/sapi/phpdbg/phpdbg_opcode.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_opcode.h b/sapi/phpdbg/phpdbg_opcode.h index 1bb861ed6f..b9e2fa506c 100644 --- a/sapi/phpdbg/phpdbg_opcode.h +++ b/sapi/phpdbg/phpdbg_opcode.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -40,7 +40,7 @@ struct _phpdbg_oplog_entry { typedef struct _phpdbg_oplog_list phpdbg_oplog_list; struct _phpdbg_oplog_list { phpdbg_oplog_list *prev; - phpdbg_oplog_entry *start; + phpdbg_oplog_entry start; /* Only "next" member used. */ }; #endif /* PHPDBG_OPCODE_H */ diff --git a/sapi/phpdbg/phpdbg_out.c b/sapi/phpdbg/phpdbg_out.c index 545e1c951d..665df6d08b 100644 --- a/sapi/phpdbg/phpdbg_out.c +++ b/sapi/phpdbg/phpdbg_out.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -114,13 +114,8 @@ typedef struct buf_area buffy; */ #define PREFIX( str, length, ch ) *--str = ch ; length++ ; has_prefix = YES - -#ifdef HAVE_LOCALE_H #include <locale.h> #define LCONV_DECIMAL_POINT (*lconv->decimal_point) -#else -#define LCONV_DECIMAL_POINT '.' -#endif #define NUL '\0' #define S_NULL "(null)" #define S_NULL_LEN 6 @@ -155,9 +150,7 @@ static int format_converter(register buffy *odp, const char *fmt, zend_bool esca char num_buf[NUM_BUF_SIZE]; char char_buf[2]; /* for printing %% and %<unknown> */ -#ifdef HAVE_LOCALE_H struct lconv *lconv = NULL; -#endif /* * Flag variables @@ -621,11 +614,10 @@ static int format_converter(register buffy *odp, const char *fmt, zend_bool esca s = "INF"; s_len = 3; } else { -#ifdef HAVE_LOCALE_H if (!lconv) { lconv = localeconv(); } -#endif + s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form, (adjust_precision == NO) ? FLOAT_DIGITS : precision, (*fmt == 'f')?LCONV_DECIMAL_POINT:'.', @@ -678,11 +670,10 @@ static int format_converter(register buffy *odp, const char *fmt, zend_bool esca /* * * We use &num_buf[ 1 ], so that we have room for the sign */ -#ifdef HAVE_LOCALE_H if (!lconv) { lconv = localeconv(); } -#endif + s = php_gcvt(fp_num, precision, (*fmt=='H' || *fmt == 'k') ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt == 'H')?'E':'e', &num_buf[1]); if (*s == '-') { prefix_char = *s++; @@ -872,17 +863,6 @@ PHPDBG_API int phpdbg_xml_vasprintf(char **buf, const char *format, zend_bool es } /* copy end */ -PHPDBG_API int _phpdbg_xml_asprintf(char **buf, const char *format, zend_bool escape_xml, ...) { - int ret; - va_list va; - - va_start(va, escape_xml); - ret = phpdbg_xml_vasprintf(buf, format, escape_xml, va); - va_end(va); - - return ret; -} - PHPDBG_API int _phpdbg_asprintf(char **buf, const char *format, ...) { int ret; va_list va; @@ -1039,9 +1019,8 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m } else { phpdbg_mixed_write(fd, msg, msglen); } - return msglen; } - break; + return msglen; /* no formatting on logging output */ case P_LOG: @@ -1055,6 +1034,7 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m } } break; + EMPTY_SWITCH_DEFAULT_CASE() } if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) { diff --git a/sapi/phpdbg/phpdbg_out.h b/sapi/phpdbg/phpdbg_out.h index da5cb0c4f8..09f4815d85 100644 --- a/sapi/phpdbg/phpdbg_out.h +++ b/sapi/phpdbg/phpdbg_out.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -67,9 +67,6 @@ PHPDBG_API int phpdbg_rlog_internal(int fd, const char *fmt, ...) PHPDBG_ATTRIBU #define phpdbg_rlog(fd, fmt, ...) phpdbg_rlog_internal(fd, fmt, ##__VA_ARGS__) -#define phpdbg_xml_asprintf(buf, ...) _phpdbg_xml_asprintf(buf, ##__VA_ARGS__) -PHPDBG_API int _phpdbg_xml_asprintf(char **buf, const char *format, zend_bool escape_xml, ...); - #define phpdbg_asprintf(buf, ...) _phpdbg_asprintf(buf, ##__VA_ARGS__) PHPDBG_API int _phpdbg_asprintf(char **buf, const char *format, ...); diff --git a/sapi/phpdbg/phpdbg_parser.c b/sapi/phpdbg/phpdbg_parser.c deleted file mode 100644 index ae7533abe4..0000000000 --- a/sapi/phpdbg/phpdbg_parser.c +++ /dev/null @@ -1,1953 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.7.12-4996. */ - -/* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.7.12-4996" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 1 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - - -/* Substitute the variable and function names. */ -#define yyparse phpdbg_parse -#define yylex phpdbg_lex -#define yyerror phpdbg_error -#define yylval phpdbg_lval -#define yychar phpdbg_char -#define yydebug phpdbg_debug -#define yynerrs phpdbg_nerrs - -/* Copy the first part of user declarations. */ -/* Line 371 of yacc.c */ -#line 1 "sapi/phpdbg/phpdbg_parser.y" - - -/* - * phpdbg_parser.y - * (from php-src root) - */ - -#include "phpdbg.h" -#include "phpdbg_cmd.h" -#include "phpdbg_utils.h" -#include "phpdbg_cmd.h" -#include "phpdbg_prompt.h" - -#define YYSTYPE phpdbg_param_t - -#include "phpdbg_parser.h" -#include "phpdbg_lexer.h" - -#undef yyerror -static int yyerror(const char *msg); - -ZEND_EXTERN_MODULE_GLOBALS(phpdbg) - -#ifdef _MSC_VER -#define YYMALLOC malloc -#define YYFREE free -#endif - - -/* Line 371 of yacc.c */ -#line 107 "sapi/phpdbg/phpdbg_parser.c" - -# ifndef YY_NULL -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr -# else -# define YY_NULL 0 -# endif -# endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 1 -#endif - -/* In a future release of Bison, this section will be replaced - by #include "phpdbg_parser.h". */ -#ifndef YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED -# define YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int phpdbg_debug; -#endif -/* "%code requires" blocks. */ -/* Line 387 of yacc.c */ -#line 36 "sapi/phpdbg/phpdbg_parser.y" - -#include "phpdbg.h" -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - - -/* Line 387 of yacc.c */ -#line 148 "sapi/phpdbg/phpdbg_parser.c" - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - T_EVAL = 258, - T_RUN = 259, - T_SHELL = 260, - T_IF = 261, - T_TRUTHY = 262, - T_FALSY = 263, - T_STRING = 264, - T_COLON = 265, - T_DCOLON = 266, - T_POUND = 267, - T_SEPARATOR = 268, - T_PROTO = 269, - T_DIGITS = 270, - T_LITERAL = 271, - T_ADDR = 272, - T_OPCODE = 273, - T_ID = 274, - T_INPUT = 275, - T_UNEXPECTED = 276, - T_REQ_ID = 277 - }; -#endif -/* Tokens. */ -#define T_EVAL 258 -#define T_RUN 259 -#define T_SHELL 260 -#define T_IF 261 -#define T_TRUTHY 262 -#define T_FALSY 263 -#define T_STRING 264 -#define T_COLON 265 -#define T_DCOLON 266 -#define T_POUND 267 -#define T_SEPARATOR 268 -#define T_PROTO 269 -#define T_DIGITS 270 -#define T_LITERAL 271 -#define T_ADDR 272 -#define T_OPCODE 273 -#define T_ID 274 -#define T_INPUT 275 -#define T_UNEXPECTED 276 -#define T_REQ_ID 277 - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - - -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int phpdbg_parse (void *YYPARSE_PARAM); -#else -int phpdbg_parse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int phpdbg_parse (void); -#else -int phpdbg_parse (); -#endif -#endif /* ! YYPARSE_PARAM */ - -#endif /* !YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ - -/* Copy the second part of user declarations. */ - -/* Line 390 of yacc.c */ -#line 229 "sapi/phpdbg/phpdbg_parser.c" - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ -# define YY_(Msgid) dgettext ("bison-runtime", Msgid) -# endif -# endif -# ifndef YY_ -# define YY_(Msgid) Msgid -# endif -#endif - -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) -# define __attribute__(Spec) /* empty */ -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(E) ((void) (E)) -#else -# define YYUSE(E) /* empty */ -#endif - - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(N) (N) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int yyi) -#else -static int -YYID (yyi) - int yyi; -#endif -{ - return yyi; -} -#endif - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ - /* Use EXIT_SUCCESS as a witness for stdlib.h. */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -# define YYCOPY_NEEDED 1 - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from SRC to DST. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) -# else -# define YYCOPY(Dst, Src, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (Dst)[yyi] = (Src)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif -#endif /* !YYCOPY_NEEDED */ - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 27 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 50 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 23 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 7 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 30 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 46 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 277 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint8 yyprhs[] = -{ - 0, 0, 3, 5, 9, 10, 12, 14, 16, 19, - 22, 26, 31, 36, 42, 46, 52, 56, 59, 61, - 63, 65, 67, 69, 71, 73, 75, 76, 80, 84, - 87 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = -{ - 24, 0, -1, 25, -1, 24, 13, 25, -1, -1, - 26, -1, 29, -1, 27, -1, 26, 27, -1, 26, - 28, -1, 19, 10, 15, -1, 19, 10, 12, 15, - -1, 14, 19, 10, 15, -1, 14, 19, 10, 12, - 15, -1, 19, 11, 19, -1, 19, 11, 19, 12, - 15, -1, 19, 12, 15, -1, 6, 20, -1, 18, - -1, 17, -1, 16, -1, 7, -1, 8, -1, 15, - -1, 19, -1, 22, -1, -1, 3, 28, 20, -1, - 5, 28, 20, -1, 4, 28, -1, 4, 28, 20, - -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint8 yyrline[] = -{ - 0, 71, 71, 72, 73, 77, 78, 82, 83, 84, - 88, 93, 98, 108, 118, 123, 129, 135, 140, 141, - 142, 143, 144, 145, 146, 150, 151, 155, 160, 165, - 169 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || 1 -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "\"eval\"", "\"run\"", "\"shell\"", - "\"if (condition)\"", "\"truthy (true, on, yes or enabled)\"", - "\"falsy (false, off, no or disabled)\"", - "\"string (some input, perhaps)\"", "\": (colon)\"", - "\":: (double colon)\"", "\"# (pound sign followed by digits)\"", - "\"# (pound sign)\"", "\"protocol (file://)\"", "\"digits (numbers)\"", - "\"literal (string)\"", "\"address\"", "\"opcode\"", - "\"identifier (command or function name)\"", - "\"input (input string or data)\"", "\"input\"", - "\"request id (-r %d)\"", "$accept", "input", "command", "parameters", - "parameter", "req_id", "full_expression", YY_NULL -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 23, 24, 24, 24, 25, 25, 26, 26, 26, - 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 28, 28, 29, 29, 29, - 29 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 3, 0, 1, 1, 1, 2, 2, - 3, 4, 4, 5, 3, 5, 3, 2, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 3, 3, 2, - 3 -}; - -/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 4, 26, 26, 26, 0, 21, 22, 0, 23, 20, - 19, 18, 24, 0, 2, 5, 7, 6, 25, 0, - 29, 0, 17, 0, 0, 0, 0, 1, 0, 8, - 9, 27, 30, 28, 0, 0, 10, 14, 16, 3, - 0, 12, 11, 0, 13, 15 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - -1, 13, 14, 15, 16, 19, 17 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -17 -static const yytype_int8 yypact[] = -{ - -3, -16, -16, -16, -10, -17, -17, 2, -17, -17, - -17, -17, 26, 9, -17, 11, -17, -17, -17, 3, - 4, 21, -17, 29, 19, 23, 25, -17, -3, -17, - -17, -17, -17, -17, 20, 28, -17, 32, -17, -17, - 30, -17, -17, 31, -17, -17 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = -{ - -17, -17, 22, -17, 33, 5, -17 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 -static const yytype_uint8 yytable[] = -{ - 1, 2, 3, 4, 5, 6, 18, 20, 21, 27, - 22, 7, 8, 9, 10, 11, 12, 4, 5, 6, - 30, 23, 28, 31, 32, 7, 8, 9, 10, 11, - 12, 35, 40, 18, 36, 41, 24, 25, 26, 34, - 38, 33, 37, 42, 43, 44, 45, 0, 29, 0, - 39 -}; - -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-17))) - -#define yytable_value_is_error(Yytable_value) \ - YYID (0) - -static const yytype_int8 yycheck[] = -{ - 3, 4, 5, 6, 7, 8, 22, 2, 3, 0, - 20, 14, 15, 16, 17, 18, 19, 6, 7, 8, - 15, 19, 13, 20, 20, 14, 15, 16, 17, 18, - 19, 12, 12, 22, 15, 15, 10, 11, 12, 10, - 15, 20, 19, 15, 12, 15, 15, -1, 15, -1, - 28 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 3, 4, 5, 6, 7, 8, 14, 15, 16, - 17, 18, 19, 24, 25, 26, 27, 29, 22, 28, - 28, 28, 20, 19, 10, 11, 12, 0, 13, 27, - 28, 20, 20, 20, 10, 12, 15, 19, 15, 25, - 12, 15, 15, 12, 15, 15 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ - -#define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - FILE *yyo = yyoutput; - YYUSE (yyo); - if (!yyvaluep) - return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - YYUSE (yytype); -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -#else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULL; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - Assume YYFAIL is not used. It's too flawed to consider. See - <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> - for details. YYERROR is fine as it does not invoke this - function. - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - YYUSE (yyvaluep); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - YYUSE (yytype); -} - - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ -/* The lookahead symbol. */ -int yychar; - - -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") -#else -/* Default value used for initialization, for pacifying older GCCs - or non-GCC compilers. */ -static YYSTYPE yyval_default; -# define YY_INITIAL_VALUE(Value) = Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END -#endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ -#endif - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); - - /* Number of syntax errors so far. */ - int yynerrs; - - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; - - int yyn; - int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yytable_value_is_error (yyn)) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - - yystate = yyn; - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END - - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: -/* Line 1802 of yacc.c */ -#line 71 "sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 3: -/* Line 1802 of yacc.c */ -#line 72 "sapi/phpdbg/phpdbg_parser.y" - { phpdbg_stack_separate((yyvsp[(1) - (3)]).top); (yyval) = (yyvsp[(3) - (3)]); } - break; - - case 5: -/* Line 1802 of yacc.c */ -#line 77 "sapi/phpdbg/phpdbg_parser.y" - { (yyval).top = PHPDBG_G(parser_stack)->top; } - break; - - case 6: -/* Line 1802 of yacc.c */ -#line 78 "sapi/phpdbg/phpdbg_parser.y" - { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); (yyval).top = PHPDBG_G(parser_stack)->top; } - break; - - case 7: -/* Line 1802 of yacc.c */ -#line 82 "sapi/phpdbg/phpdbg_parser.y" - { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(1) - (1)])); (yyval).top = PHPDBG_G(parser_stack)->top; } - break; - - case 8: -/* Line 1802 of yacc.c */ -#line 83 "sapi/phpdbg/phpdbg_parser.y" - { phpdbg_stack_push(PHPDBG_G(parser_stack), &(yyvsp[(2) - (2)])); (yyval).top = PHPDBG_G(parser_stack)->top; } - break; - - case 9: -/* Line 1802 of yacc.c */ -#line 84 "sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (2)]); } - break; - - case 10: -/* Line 1802 of yacc.c */ -#line 88 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = FILE_PARAM; - (yyval).file.name = (yyvsp[(2) - (3)]).str; - (yyval).file.line = (yyvsp[(3) - (3)]).num; - } - break; - - case 11: -/* Line 1802 of yacc.c */ -#line 93 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = NUMERIC_FILE_PARAM; - (yyval).file.name = (yyvsp[(1) - (4)]).str; - (yyval).file.line = (yyvsp[(4) - (4)]).num; - } - break; - - case 12: -/* Line 1802 of yacc.c */ -#line 98 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = FILE_PARAM; - (yyval).file.name = malloc((yyvsp[(1) - (4)]).len + (yyvsp[(2) - (4)]).len + 1); - if ((yyval).file.name) { - memcpy(&(yyval).file.name[0], (yyvsp[(1) - (4)]).str, (yyvsp[(1) - (4)]).len); - memcpy(&(yyval).file.name[(yyvsp[(1) - (4)]).len], (yyvsp[(2) - (4)]).str, (yyvsp[(2) - (4)]).len); - (yyval).file.name[(yyvsp[(1) - (4)]).len + (yyvsp[(2) - (4)]).len] = '\0'; - } - (yyval).file.line = (yyvsp[(4) - (4)]).num; - } - break; - - case 13: -/* Line 1802 of yacc.c */ -#line 108 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = NUMERIC_FILE_PARAM; - (yyval).file.name = malloc((yyvsp[(1) - (5)]).len + (yyvsp[(2) - (5)]).len + 1); - if ((yyval).file.name) { - memcpy(&(yyval).file.name[0], (yyvsp[(1) - (5)]).str, (yyvsp[(1) - (5)]).len); - memcpy(&(yyval).file.name[(yyvsp[(1) - (5)]).len], (yyvsp[(2) - (5)]).str, (yyvsp[(2) - (5)]).len); - (yyval).file.name[(yyvsp[(1) - (5)]).len + (yyvsp[(2) - (5)]).len] = '\0'; - } - (yyval).file.line = (yyvsp[(5) - (5)]).num; - } - break; - - case 14: -/* Line 1802 of yacc.c */ -#line 118 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = METHOD_PARAM; - (yyval).method.class = (yyvsp[(1) - (3)]).str; - (yyval).method.name = (yyvsp[(3) - (3)]).str; - } - break; - - case 15: -/* Line 1802 of yacc.c */ -#line 123 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = NUMERIC_METHOD_PARAM; - (yyval).method.class = (yyvsp[(1) - (5)]).str; - (yyval).method.name = (yyvsp[(3) - (5)]).str; - (yyval).num = (yyvsp[(5) - (5)]).num; - } - break; - - case 16: -/* Line 1802 of yacc.c */ -#line 129 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = NUMERIC_FUNCTION_PARAM; - (yyval).str = (yyvsp[(1) - (3)]).str; - (yyval).len = (yyvsp[(1) - (3)]).len; - (yyval).num = (yyvsp[(3) - (3)]).num; - } - break; - - case 17: -/* Line 1802 of yacc.c */ -#line 135 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = COND_PARAM; - (yyval).str = (yyvsp[(2) - (2)]).str; - (yyval).len = (yyvsp[(2) - (2)]).len; - } - break; - - case 18: -/* Line 1802 of yacc.c */ -#line 140 "sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 19: -/* Line 1802 of yacc.c */ -#line 141 "sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 20: -/* Line 1802 of yacc.c */ -#line 142 "sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 21: -/* Line 1802 of yacc.c */ -#line 143 "sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 22: -/* Line 1802 of yacc.c */ -#line 144 "sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 23: -/* Line 1802 of yacc.c */ -#line 145 "sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 24: -/* Line 1802 of yacc.c */ -#line 146 "sapi/phpdbg/phpdbg_parser.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 25: -/* Line 1802 of yacc.c */ -#line 150 "sapi/phpdbg/phpdbg_parser.y" - { PHPDBG_G(req_id) = (yyvsp[(1) - (1)]).num; } - break; - - case 27: -/* Line 1802 of yacc.c */ -#line 155 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = EVAL_PARAM; - (yyval).str = (yyvsp[(3) - (3)]).str; - (yyval).len = (yyvsp[(3) - (3)]).len; - } - break; - - case 28: -/* Line 1802 of yacc.c */ -#line 160 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = SHELL_PARAM; - (yyval).str = (yyvsp[(3) - (3)]).str; - (yyval).len = (yyvsp[(3) - (3)]).len; - } - break; - - case 29: -/* Line 1802 of yacc.c */ -#line 165 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = RUN_PARAM; - (yyval).len = 0; - } - break; - - case 30: -/* Line 1802 of yacc.c */ -#line 169 "sapi/phpdbg/phpdbg_parser.y" - { - (yyval).type = RUN_PARAM; - (yyval).str = (yyvsp[(3) - (3)]).str; - (yyval).len = (yyvsp[(3) - (3)]).len; - } - break; - - -/* Line 1802 of yacc.c */ -#line 1694 "sapi/phpdbg/phpdbg_parser.c" - default: break; - } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END - - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#if !defined yyoverflow || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - } - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - /* Make sure YYID is used. */ - return YYID (yyresult); -} - - -/* Line 2050 of yacc.c */ -#line 176 "sapi/phpdbg/phpdbg_parser.y" - - -static int yyerror(const char *msg) { - phpdbg_error("command", "type=\"parseerror\" msg=\"%s\"", "Parse Error: %s", msg); - - { - const phpdbg_param_t *top = PHPDBG_G(parser_stack); - - while (top) { - phpdbg_param_debug(top, "--> "); - top = top->next; - } - } - return 0; -} - -int phpdbg_do_parse(phpdbg_param_t *stack, char *input) { - if (!*input) { - return 0; - } - - if (PHPDBG_G(cur_command)) { - free(PHPDBG_G(cur_command)); - } - PHPDBG_G(cur_command) = strdup(input); - - phpdbg_init_lexer(stack, input); - - return yyparse(); -} diff --git a/sapi/phpdbg/phpdbg_parser.h b/sapi/phpdbg/phpdbg_parser.h deleted file mode 100644 index 2a27a4e7df..0000000000 --- a/sapi/phpdbg/phpdbg_parser.h +++ /dev/null @@ -1,130 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.7.12-4996. */ - -/* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -#ifndef YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED -# define YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif -#if YYDEBUG -extern int phpdbg_debug; -#endif -/* "%code requires" blocks. */ -/* Line 2060 of yacc.c */ -#line 36 "sapi/phpdbg/phpdbg_parser.y" - -#include "phpdbg.h" -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - - -/* Line 2060 of yacc.c */ -#line 55 "sapi/phpdbg/phpdbg_parser.h" - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - T_EVAL = 258, - T_RUN = 259, - T_SHELL = 260, - T_IF = 261, - T_TRUTHY = 262, - T_FALSY = 263, - T_STRING = 264, - T_COLON = 265, - T_DCOLON = 266, - T_POUND = 267, - T_SEPARATOR = 268, - T_PROTO = 269, - T_DIGITS = 270, - T_LITERAL = 271, - T_ADDR = 272, - T_OPCODE = 273, - T_ID = 274, - T_INPUT = 275, - T_UNEXPECTED = 276, - T_REQ_ID = 277 - }; -#endif -/* Tokens. */ -#define T_EVAL 258 -#define T_RUN 259 -#define T_SHELL 260 -#define T_IF 261 -#define T_TRUTHY 262 -#define T_FALSY 263 -#define T_STRING 264 -#define T_COLON 265 -#define T_DCOLON 266 -#define T_POUND 267 -#define T_SEPARATOR 268 -#define T_PROTO 269 -#define T_DIGITS 270 -#define T_LITERAL 271 -#define T_ADDR 272 -#define T_OPCODE 273 -#define T_ID 274 -#define T_INPUT 275 -#define T_UNEXPECTED 276 -#define T_REQ_ID 277 - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - - -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int phpdbg_parse (void *YYPARSE_PARAM); -#else -int phpdbg_parse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int phpdbg_parse (void); -#else -int phpdbg_parse (); -#endif -#endif /* ! YYPARSE_PARAM */ - -#endif /* !YY_PHPDBG_SAPI_PHPDBG_PHPDBG_PARSER_H_INCLUDED */ diff --git a/sapi/phpdbg/phpdbg_parser.y b/sapi/phpdbg/phpdbg_parser.y index b61c9c0a26..3031ce5a80 100644 --- a/sapi/phpdbg/phpdbg_parser.y +++ b/sapi/phpdbg/phpdbg_parser.y @@ -28,8 +28,8 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg) %} -%pure-parser -%error-verbose +%define api.pure full +%define parse.error verbose %code requires { #include "phpdbg.h" @@ -39,9 +39,6 @@ typedef void* yyscan_t; #endif } -%output "sapi/phpdbg/phpdbg_parser.c" -%defines "sapi/phpdbg/phpdbg_parser.h" - %token T_EVAL "eval" %token T_RUN "run" %token T_SHELL "shell" @@ -68,7 +65,7 @@ typedef void* yyscan_t; input : command { $$ = $1; } | input T_SEPARATOR command { phpdbg_stack_separate($1.top); $$ = $3; } - | /* nothing */ + | /* empty */ ; command @@ -79,7 +76,7 @@ command parameters : parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); $$.top = PHPDBG_G(parser_stack)->top; } | parameters parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$2); $$.top = PHPDBG_G(parser_stack)->top; } - | parameters req_id { $$ = $1; } + | parameters T_REQ_ID { $$ = $1; PHPDBG_G(req_id) = $2.num; } ; parameter diff --git a/sapi/phpdbg/phpdbg_print.c b/sapi/phpdbg/phpdbg_print.c index bc1ac22f26..5f48bd6a59 100644 --- a/sapi/phpdbg/phpdbg_print.c +++ b/sapi/phpdbg/phpdbg_print.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_print.h b/sapi/phpdbg/phpdbg_print.h index 1a7d5e87a4..66eae7bceb 100644 --- a/sapi/phpdbg/phpdbg_print.h +++ b/sapi/phpdbg/phpdbg_print.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index db56476905..24155a7860 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -81,7 +81,7 @@ const phpdbg_command_t phpdbg_prompt_commands[] = { PHPDBG_COMMAND_D(back, "show trace", 't', NULL, "|n", PHPDBG_ASYNC_SAFE), PHPDBG_COMMAND_D(frame, "switch to a frame", 'f', NULL, "|n", PHPDBG_ASYNC_SAFE), PHPDBG_COMMAND_D(list, "lists some code", 'l', phpdbg_list_commands, "*", PHPDBG_ASYNC_SAFE), - PHPDBG_COMMAND_D(info, "displays some informations", 'i', phpdbg_info_commands, "|s", PHPDBG_ASYNC_SAFE), + PHPDBG_COMMAND_D(info, "displays some information", 'i', phpdbg_info_commands, "|s", PHPDBG_ASYNC_SAFE), PHPDBG_COMMAND_D(clean, "clean the execution environment", 'X', NULL, 0, 0), PHPDBG_COMMAND_D(clear, "clear breakpoints", 'C', NULL, 0, 0), PHPDBG_COMMAND_D(help, "show help menu", 'h', phpdbg_help_commands, "|s", PHPDBG_ASYNC_SAFE), @@ -373,6 +373,7 @@ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default) / ZEND_IGNORE_VALUE(asprintf(&init_file, "%s/%s", scan_dir, PHPDBG_INIT_FILENAME)); phpdbg_try_file_init(init_file, strlen(init_file), 1); + free(init_file); if (i == -1) { break; } @@ -421,7 +422,7 @@ PHPDBG_COMMAND(exec) /* {{{ */ if (PHPDBG_G(exec)) { phpdbg_notice("exec", "type=\"unset\" context=\"%s\"", "Unsetting old execution context: %s", PHPDBG_G(exec)); - efree(PHPDBG_G(exec)); + free(PHPDBG_G(exec)); PHPDBG_G(exec) = NULL; PHPDBG_G(exec_len) = 0L; } @@ -436,7 +437,7 @@ PHPDBG_COMMAND(exec) /* {{{ */ VCWD_CHDIR_FILE(res); - *SG(request_info).argv = PHPDBG_G(exec); + *SG(request_info).argv = estrndup(PHPDBG_G(exec), PHPDBG_G(exec_len)); php_build_argv(NULL, &PG(http_globals)[TRACK_VARS_SERVER]); phpdbg_notice("exec", "type=\"set\" context=\"%s\"", "Set execution context: %s", PHPDBG_G(exec)); @@ -534,9 +535,9 @@ int phpdbg_compile_stdin(zend_string *code) { } if (PHPDBG_G(exec)) { - efree(PHPDBG_G(exec)); + free(PHPDBG_G(exec)); } - PHPDBG_G(exec) = estrdup("Standard input code"); + PHPDBG_G(exec) = strdup("Standard input code"); PHPDBG_G(exec_len) = sizeof("Standard input code") - 1; { /* remove leading ?> from source */ int i; @@ -566,10 +567,7 @@ int phpdbg_compile(void) /* {{{ */ { zend_file_handle fh; char *buf; - char *start_line = NULL; size_t len; - size_t start_line_len; - int i; if (!PHPDBG_G(exec)) { phpdbg_error("inactive", "type=\"nocontext\"", "No execution context"); @@ -577,53 +575,8 @@ int phpdbg_compile(void) /* {{{ */ } if (php_stream_open_for_zend_ex(PHPDBG_G(exec), &fh, USE_PATH|STREAM_OPEN_FOR_INCLUDE) == SUCCESS && zend_stream_fixup(&fh, &buf, &len) == SUCCESS) { - /* Skip #! line */ - if (len >= 3 && buf[0] == '#' && buf[1] == '!') { - char *end = buf + len; - do { - switch (fh.handle.stream.mmap.buf++[0]) { - case '\r': - if (fh.handle.stream.mmap.buf[0] == '\n') { - fh.handle.stream.mmap.buf++; - } - case '\n': - CG(start_lineno) = 2; - start_line_len = fh.handle.stream.mmap.buf - buf; - start_line = emalloc(start_line_len); - memcpy(start_line, buf, start_line_len); - fh.handle.stream.mmap.len -= start_line_len; - end = fh.handle.stream.mmap.buf; - } - } while (fh.handle.stream.mmap.buf + 1 < end); - } - + CG(skip_shebang) = 1; PHPDBG_G(ops) = zend_compile_file(&fh, ZEND_INCLUDE); - - /* prepend shebang line to file_source */ - if (start_line) { - phpdbg_file_source *data = zend_hash_find_ptr(&PHPDBG_G(file_sources), PHPDBG_G(ops)->filename); - - dtor_func_t dtor = PHPDBG_G(file_sources).pDestructor; - PHPDBG_G(file_sources).pDestructor = NULL; - zend_hash_del(&PHPDBG_G(file_sources), PHPDBG_G(ops)->filename); - PHPDBG_G(file_sources).pDestructor = dtor; - - data = erealloc(data, sizeof(phpdbg_file_source) + sizeof(uint32_t) * ++data->lines); - memmove(data->line + 1, data->line, sizeof(uint32_t) * data->lines); - data->line[0] = 0; - data->buf = erealloc(data->buf, data->len + start_line_len); - memmove(data->buf + start_line_len, data->buf, data->len); - memcpy(data->buf, start_line, start_line_len); - efree(start_line); - data->len += start_line_len; - for (i = 1; i <= data->lines; i++) { - data->line[i] += start_line_len; - } - zend_hash_update_ptr(&PHPDBG_G(file_sources), PHPDBG_G(ops)->filename, data); - } - - fh.handle.stream.mmap.buf = buf; - fh.handle.stream.mmap.len = len; zend_destroy_file_handle(&fh); if (EG(exception)) { zend_exception_error(EG(exception), E_ERROR); @@ -838,7 +791,7 @@ PHPDBG_COMMAND(run) /* {{{ */ while (*p == ' ') p++; while (*p) { char sep = ' '; - char *buf = emalloc(end - p + 1), *q = buf; + char *buf = emalloc(end - p + 2), *q = buf; if (*p == '<') { /* use as STDIN */ @@ -1315,7 +1268,7 @@ PHPDBG_API const char *phpdbg_load_module_or_extension(char **path, char **name) char *err = GET_DL_ERROR(); if (err && err[0]) { phpdbg_error("dl", "type=\"unknown\"", "%s", err); - LocalFree(err); + php_win32_error_msg_free(err); } else { phpdbg_error("dl", "type=\"unknown\"", "Unknown reason"); } @@ -1632,7 +1585,14 @@ int phpdbg_interactive(zend_bool allow_async_unsafe, char *input) /* {{{ */ sigio_watcher_start(); } #endif - switch (ret = phpdbg_stack_execute(&stack, allow_async_unsafe)) { + zend_try { + ret = phpdbg_stack_execute(&stack, allow_async_unsafe); + } zend_catch { + phpdbg_stack_free(&stack); + zend_bailout(); + } zend_end_try(); + + switch (ret) { case FAILURE: if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { if (!allow_async_unsafe || phpdbg_call_register(&stack) == FAILURE) { @@ -1687,33 +1647,33 @@ int phpdbg_interactive(zend_bool allow_async_unsafe, char *input) /* {{{ */ return ret; } /* }}} */ +static inline void list_code() { + if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { + const char *file_char = zend_get_executed_filename(); + zend_string *file = zend_string_init(file_char, strlen(file_char), 0); + phpdbg_list_file(file, 3, zend_get_executed_lineno()-1, zend_get_executed_lineno()); + efree(file); + } +} + /* code may behave weirdly if EG(exception) is set; thus backup it */ #define DO_INTERACTIVE(allow_async_unsafe) do { \ - const zend_op *backup_opline; \ - const zend_op *before_ex; \ if (exception) { \ + const zend_op *before_ex = EG(opline_before_exception); \ + const zend_op *backup_opline = NULL; \ if (EG(current_execute_data) && EG(current_execute_data)->func && ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) { \ backup_opline = EG(current_execute_data)->opline; \ } \ - before_ex = EG(opline_before_exception); \ GC_ADDREF(exception); \ zend_clear_exception(); \ - } \ - if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { \ - const char *file_char = zend_get_executed_filename(); \ - zend_string *file = zend_string_init(file_char, strlen(file_char), 0); \ - phpdbg_list_file(file, 3, zend_get_executed_lineno()-1, zend_get_executed_lineno()); \ - efree(file); \ - } \ - \ - switch (phpdbg_interactive(allow_async_unsafe, NULL)) { \ - zval zv; \ - case PHPDBG_LEAVE: \ - case PHPDBG_FINISH: \ - case PHPDBG_UNTIL: \ - case PHPDBG_NEXT: \ - if (exception) { \ - if (EG(current_execute_data) && EG(current_execute_data)->func && ZEND_USER_CODE(EG(current_execute_data)->func->common.type) \ + list_code(); \ + switch (phpdbg_interactive(allow_async_unsafe, NULL)) { \ + zval zv; \ + case PHPDBG_LEAVE: \ + case PHPDBG_FINISH: \ + case PHPDBG_UNTIL: \ + case PHPDBG_NEXT: \ + if (backup_opline \ && (backup_opline->opcode == ZEND_HANDLE_EXCEPTION || backup_opline->opcode == ZEND_CATCH)) { \ EG(current_execute_data)->opline = backup_opline; \ EG(exception) = exception; \ @@ -1722,11 +1682,12 @@ int phpdbg_interactive(zend_bool allow_async_unsafe, char *input) /* {{{ */ zend_throw_exception_internal(&zv); \ } \ EG(opline_before_exception) = before_ex; \ - } \ - /* fallthrough */ \ - default: \ - goto next; \ + } \ + } else { \ + list_code(); \ + phpdbg_interactive(allow_async_unsafe, NULL); \ } \ + goto next; \ } while (0) void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */ diff --git a/sapi/phpdbg/phpdbg_prompt.h b/sapi/phpdbg/phpdbg_prompt.h index cac69c0120..142581783a 100644 --- a/sapi/phpdbg/phpdbg_prompt.h +++ b/sapi/phpdbg/phpdbg_prompt.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_rinit_hook.c b/sapi/phpdbg/phpdbg_rinit_hook.c index d923f7c1d2..2bc1c59b90 100644 --- a/sapi/phpdbg/phpdbg_rinit_hook.c +++ b/sapi/phpdbg/phpdbg_rinit_hook.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_rinit_hook.h b/sapi/phpdbg/phpdbg_rinit_hook.h index adc3f1c681..a350ddec54 100644 --- a/sapi/phpdbg/phpdbg_rinit_hook.h +++ b/sapi/phpdbg/phpdbg_rinit_hook.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -27,7 +27,7 @@ extern zend_module_entry phpdbg_webhelper_module_entry; #define phpext_phpdbg_webhelper_ptr &phpdbg_webhelper_module_entry #ifdef ZTS -# define PHPDBG_WG(v) TSRMG(phpdbg_webhelper_globals_id, zend_phpdbg_webhelper_globals *, v) +# define PHPDBG_WG(v) ZEND_TSRMG(phpdbg_webhelper_globals_id, zend_phpdbg_webhelper_globals *, v) #else # define PHPDBG_WG(v) (phpdbg_webhelper_globals.v) #endif diff --git a/sapi/phpdbg/phpdbg_set.c b/sapi/phpdbg/phpdbg_set.c index dc69221a50..da3ec4cf19 100644 --- a/sapi/phpdbg/phpdbg_set.c +++ b/sapi/phpdbg/phpdbg_set.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_set.h b/sapi/phpdbg/phpdbg_set.h index c4b0dd9523..7f89d9182d 100644 --- a/sapi/phpdbg/phpdbg_set.h +++ b/sapi/phpdbg/phpdbg_set.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_sigio_win32.c b/sapi/phpdbg/phpdbg_sigio_win32.c index 3ca0ad8d37..f3221d09cb 100644 --- a/sapi/phpdbg/phpdbg_sigio_win32.c +++ b/sapi/phpdbg/phpdbg_sigio_win32.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 2014-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_sigio_win32.h b/sapi/phpdbg/phpdbg_sigio_win32.h index d5d6383a8f..af7b9f10cb 100644 --- a/sapi/phpdbg/phpdbg_sigio_win32.h +++ b/sapi/phpdbg/phpdbg_sigio_win32.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 2014-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c index e10eb60d4a..857b5e3311 100644 --- a/sapi/phpdbg/phpdbg_utils.c +++ b/sapi/phpdbg/phpdbg_utils.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -154,7 +154,7 @@ PHPDBG_API char *phpdbg_resolve_path(const char *path) /* {{{ */ return NULL; } - return estrdup(resolved_name); + return strdup(resolved_name); } /* }}} */ PHPDBG_API const char *phpdbg_current_file(void) /* {{{ */ @@ -430,7 +430,7 @@ PHPDBG_API int phpdbg_parse_variable(char *input, size_t len, HashTable *parent, PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_with_arg_func callback, phpdbg_parse_var_with_arg_func step_cb, zend_bool silent, void *arg) { int ret = FAILURE; zend_bool new_index = 1; - char *last_index; + char *last_index = NULL; size_t index_len = 0; zval *zv; @@ -660,8 +660,6 @@ PHPDBG_API void phpdbg_xml_var_dump(zval *zv) { int (*element_dump_func)(zval *zv, zend_string *key, zend_ulong num); zend_bool is_ref = 0; - int is_temp; - phpdbg_try_access { is_ref = Z_ISREF_P(zv) && GC_REFCOUNT(Z_COUNTED_P(zv)) > 1; ZVAL_DEREF(zv); @@ -696,10 +694,9 @@ PHPDBG_API void phpdbg_xml_var_dump(zval *zv) { } phpdbg_xml("<array refstatus=\"%s\" num=\"%d\">", COMMON, zend_hash_num_elements(myht)); element_dump_func = phpdbg_xml_array_element_dump; - is_temp = 0; goto head_done; case IS_OBJECT: - myht = Z_OBJDEBUG_P(zv, is_temp); + myht = zend_get_properties_for(zv, ZEND_PROP_PURPOSE_DEBUG); if (myht && GC_IS_RECURSIVE(myht)) { phpdbg_xml("<recursion />"); break; @@ -717,9 +714,8 @@ head_done: } ZEND_HASH_FOREACH_END(); zend_hash_apply_with_arguments(myht, (apply_func_args_t) element_dump_func, 0); GC_UNPROTECT_RECURSION(myht); - if (is_temp) { - zend_hash_destroy(myht); - efree(myht); + if (Z_TYPE_P(zv) == IS_OBJECT) { + zend_release_properties(myht); } } if (Z_TYPE_P(zv) == IS_ARRAY) { @@ -765,7 +761,7 @@ PHPDBG_API zend_bool phpdbg_check_caught_ex(zend_execute_data *execute_data, zen zend_class_entry *ce; if (!(ce = CACHED_PTR(cur->extended_value & ~ZEND_LAST_CATCH))) { - ce = zend_fetch_class_by_name(Z_STR_P(RT_CONSTANT(cur, cur->op1)), RT_CONSTANT(cur, cur->op1) + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD); + ce = zend_fetch_class_by_name(Z_STR_P(RT_CONSTANT(cur, cur->op1)), Z_STR_P(RT_CONSTANT(cur, cur->op1) + 1), ZEND_FETCH_CLASS_NO_AUTOLOAD); CACHE_PTR(cur->extended_value & ~ZEND_LAST_CATCH, ce); } diff --git a/sapi/phpdbg/phpdbg_utils.h b/sapi/phpdbg/phpdbg_utils.h index c8a9554d0e..c212056670 100644 --- a/sapi/phpdbg/phpdbg_utils.h +++ b/sapi/phpdbg/phpdbg_utils.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -111,7 +111,7 @@ static zend_always_inline zend_execute_data *phpdbg_user_execute_data(zend_execu #define PHPDBG_OUTPUT_BACKUP_DEFINES() \ zend_output_globals *output_globals_ptr; \ zend_output_globals original_output_globals; \ - output_globals_ptr = (zend_output_globals *) (*((void ***) tsrm_get_ls_cache()))[TSRM_UNSHUFFLE_RSRC_ID(output_globals_id)]; + output_globals_ptr = TSRMG_BULK_STATIC(output_globals_id, zend_output_globals *); #else #define PHPDBG_OUTPUT_BACKUP_DEFINES() \ zend_output_globals *output_globals_ptr; \ diff --git a/sapi/phpdbg/phpdbg_wait.c b/sapi/phpdbg/phpdbg_wait.c index 96504c7d7e..69be24a953 100644 --- a/sapi/phpdbg/phpdbg_wait.c +++ b/sapi/phpdbg/phpdbg_wait.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -243,7 +243,7 @@ void phpdbg_webdata_decompress(char *msg, int len) { zend_extension *extension; zend_llist_position pos; zval *name = NULL; - zend_string *strkey; + zend_string *strkey = NULL; extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos); while (extension) { @@ -257,6 +257,7 @@ void phpdbg_webdata_decompress(char *msg, int len) { break; } name = NULL; + strkey = NULL; } ZEND_HASH_FOREACH_END(); if (name) { @@ -283,6 +284,7 @@ void phpdbg_webdata_decompress(char *msg, int len) { pefree(elm, zend_extensions.persistent); zend_extensions.count--; } else { + ZEND_ASSERT(strkey); zend_hash_del(Z_ARRVAL_P(zvp), strkey); } } @@ -377,21 +379,25 @@ PHPDBG_COMMAND(wait) /* {{{ */ return FAILURE; } - char msglen[5]; - int recvd = 4; + unsigned char msglen_buf[4]; + int needed = 4; do { - recvd -= recv(sr, &(msglen[4 - recvd]), recvd, 0); - } while (recvd > 0); + needed -= recv(sr, &msglen_buf[4 - needed], needed, 0); + } while (needed > 0); - recvd = *(size_t *) msglen; - char *data = emalloc(recvd); + uint32_t msglen = (msglen_buf[3] << 24) + | (msglen_buf[2] << 16) + | (msglen_buf[1] << 8) + | (msglen_buf[0] << 0); + char *data = emalloc(msglen); + needed = msglen; do { - recvd -= recv(sr, &(data[(*(int *) msglen) - recvd]), recvd, 0); - } while (recvd > 0); + needed -= recv(sr, &(data[msglen - needed]), needed, 0); + } while (needed > 0); - phpdbg_webdata_decompress(data, *(int *) msglen); + phpdbg_webdata_decompress(data, msglen); if (PHPDBG_G(socket_fd) != -1) { close(PHPDBG_G(socket_fd)); diff --git a/sapi/phpdbg/phpdbg_wait.h b/sapi/phpdbg/phpdbg_wait.h index 71c6ace543..b748e162bb 100644 --- a/sapi/phpdbg/phpdbg_wait.h +++ b/sapi/phpdbg/phpdbg_wait.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c index 1d7f33ff6f..d9f9f8673f 100644 --- a/sapi/phpdbg/phpdbg_watch.c +++ b/sapi/phpdbg/phpdbg_watch.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | @@ -31,7 +31,7 @@ * Watch elements are either simple, recursive or implicit (PHPDBG_WATCH_* flags) * Simple means that a particular watchpoint was explicitly defined * Recursive watch elements are created recursively (recursive root flag is to distinguish the root element easily from its children recursive elements) - * Implicit watch elements are implicitely created on all ancestors of simple or recursive watch elements + * Implicit watch elements are implicitly created on all ancestors of simple or recursive watch elements * Recursive and (simple or implicit) watch elements are mutually exclusive * Array/Object to distinguish watch elements on arrays * @@ -1014,13 +1014,14 @@ void phpdbg_check_watchpoint(phpdbg_watchpoint_t *watch) { } if (watch->type == WATCH_ON_BUCKET) { if (watch->backup.bucket.key != watch->addr.bucket->key || (watch->backup.bucket.key != NULL && watch->backup.bucket.h != watch->addr.bucket->h)) { - phpdbg_watch_element *element; + phpdbg_watch_element *element = NULL; zval *new; ZEND_HASH_FOREACH_PTR(&watch->elements, element) { break; } ZEND_HASH_FOREACH_END(); + ZEND_ASSERT(element); /* elements must be non-empty */ new = zend_symtable_find(element->parent_container, element->name_in_parent); if (!new) { diff --git a/sapi/phpdbg/phpdbg_watch.h b/sapi/phpdbg/phpdbg_watch.h index 4d5e2153ae..313df624ea 100644 --- a/sapi/phpdbg/phpdbg_watch.h +++ b/sapi/phpdbg/phpdbg_watch.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_webdata_transfer.c b/sapi/phpdbg/phpdbg_webdata_transfer.c index a543f98ba7..36d327f56f 100644 --- a/sapi/phpdbg/phpdbg_webdata_transfer.c +++ b/sapi/phpdbg/phpdbg_webdata_transfer.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_webdata_transfer.h b/sapi/phpdbg/phpdbg_webdata_transfer.h index aa736a78b9..c08c6e8f93 100644 --- a/sapi/phpdbg/phpdbg_webdata_transfer.h +++ b/sapi/phpdbg/phpdbg_webdata_transfer.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_win.c b/sapi/phpdbg/phpdbg_win.c index 964aed0194..6bf79981e0 100644 --- a/sapi/phpdbg/phpdbg_win.c +++ b/sapi/phpdbg/phpdbg_win.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/phpdbg_win.h b/sapi/phpdbg/phpdbg_win.h index ee9191b1ad..ba83062301 100644 --- a/sapi/phpdbg/phpdbg_win.h +++ b/sapi/phpdbg/phpdbg_win.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 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 | diff --git a/sapi/phpdbg/tests/phpdbg_get_executable_stream_wrapper.phpt b/sapi/phpdbg/tests/phpdbg_get_executable_stream_wrapper.phpt index 0ddbd6f527..560fac35f8 100644 --- a/sapi/phpdbg/tests/phpdbg_get_executable_stream_wrapper.phpt +++ b/sapi/phpdbg/tests/phpdbg_get_executable_stream_wrapper.phpt @@ -59,6 +59,7 @@ final class StreamWrapper public function stream_close() : bool { return \fclose($this->stream); } public function stream_eof() : bool { return \feof($this->stream); } public function stream_stat() { return \fstat($this->stream); } + public function stream_set_option($option, $arg1, $arg2) { return false; } private $stream = false; } diff --git a/sapi/phpdbg/tests/phpdbg_oplog_001.phpt b/sapi/phpdbg/tests/phpdbg_oplog_001.phpt index 5a5e9ba61c..9fc112a3f7 100644 --- a/sapi/phpdbg/tests/phpdbg_oplog_001.phpt +++ b/sapi/phpdbg/tests/phpdbg_oplog_001.phpt @@ -26,7 +26,7 @@ prompt> halloarray(2) { [4]=> int(1) [5]=> - int(3) + int(2) [8]=> int(2) } diff --git a/sapi/phpdbg/tests/print_001.phpt b/sapi/phpdbg/tests/print_001.phpt index 93a000528f..0025d5c071 100644 --- a/sapi/phpdbg/tests/print_001.phpt +++ b/sapi/phpdbg/tests/print_001.phpt @@ -30,19 +30,17 @@ L5-7 Foo\Bar::Foo() %s - %s + 5 ops L9-9 Foo\Bar::baz() %s - %s + 1 ops L9 #0 RETURN<-1> null prompt> [Not Executing!] -prompt> [Context %s (11 ops)] -L1-21 {main}() %s - %s + 11 ops - L4 #0 NOP - L14 #1 NOP - L18 #2 NEW "Foo\\Bar" @1 - L18 #3 DO_FCALL - L18 #4 INIT_METHOD_CALL<1> @1 "Foo" - L18 #5 SEND_VAL_EX "test" 1 - L18 #6 DO_FCALL - L19 #7 INIT_FCALL%s %d %s "foo" - L19 #8 SEND_VAL "test" 1 - L19 #9 DO_FCALL - L21 #10 RETURN<-1> 1 +prompt> [Context %s (9 ops)] +L1-21 {main}() %s - %s + 9 ops + L18 #0 NEW "Foo\\Bar" @0 + L18 #1 DO_FCALL + L18 #2 INIT_METHOD_CALL<1> @0 "Foo" + L18 #3 SEND_VAL_EX "test" 1 + L18 #4 DO_FCALL + L19 #5 INIT_FCALL%s %d %s "foo" + L19 #6 SEND_VAL "test" 1 + L19 #7 DO_FCALL + L21 #8 RETURN<-1> 1 prompt> --FILE-- <?php diff --git a/sapi/phpdbg/tests/stepping_001.phpt b/sapi/phpdbg/tests/stepping_001.phpt index 90b2e5573a..27084c6ef7 100644 --- a/sapi/phpdbg/tests/stepping_001.phpt +++ b/sapi/phpdbg/tests/stepping_001.phpt @@ -34,7 +34,7 @@ prompt> [L10 %s ECHO "ok" 00011: } finally { 00012: echo " ... ok"; prompt> ok -[L11 %s FAST_CALL J8 ~%d %s] +[L11 %s FAST_CALL J7 ~%d %s] >00011: } finally { 00012: echo " ... ok"; 00013: } @@ -44,7 +44,7 @@ prompt> [L12 %s ECHO " ... ok" 00014: prompt> ... ok [L12 %s FAST_RET ~%d %s] -[L11 %s JMP J10 %s] +[L11 %s JMP J9 %s] >00011: } finally { 00012: echo " ... ok"; 00013: } diff --git a/sapi/phpdbg/tests/watch_001.phpt b/sapi/phpdbg/tests/watch_001.phpt index e16681bf7c..90ede3f952 100644 --- a/sapi/phpdbg/tests/watch_001.phpt +++ b/sapi/phpdbg/tests/watch_001.phpt @@ -1,5 +1,14 @@ --TEST-- Test simple recursive watchpoint +--SKIPIF-- +<?php +if (PHP_INT_SIZE == 4) { + die("xfail There may be flaws in the implementation of watchpoints that cause failures"); +} +if (getenv('SKIP_ASAN')) { + die("skip intentionally causes segfaults"); +} +?> --INI-- opcache.optimization_level=0 --PHPDBG-- diff --git a/sapi/phpdbg/tests/watch_002.phpt b/sapi/phpdbg/tests/watch_002.phpt index b57ca0a1d4..ba2cad1abe 100644 --- a/sapi/phpdbg/tests/watch_002.phpt +++ b/sapi/phpdbg/tests/watch_002.phpt @@ -1,5 +1,14 @@ --TEST-- Test simple array watchpoint with replace +--SKIPIF-- +<?php +if (PHP_INT_SIZE == 4) { + die("xfail There may be flaws in the implementation of watchpoints that cause failures"); +} +if (getenv('SKIP_ASAN')) { + die("skip intentionally causes segfaults"); +} +?> --PHPDBG-- b 6 r diff --git a/sapi/phpdbg/tests/watch_003.phpt b/sapi/phpdbg/tests/watch_003.phpt index 08868aedc3..ab6dc317a8 100644 --- a/sapi/phpdbg/tests/watch_003.phpt +++ b/sapi/phpdbg/tests/watch_003.phpt @@ -1,5 +1,14 @@ --TEST-- Test simple watchpoint with replace +--SKIPIF-- +<?php +if (PHP_INT_SIZE == 4) { + die("xfail There may be flaws in the implementation of watchpoints that cause failures"); +} +if (getenv('SKIP_ASAN')) { + die("skip intentionally causes segfaults"); +} +?> --PHPDBG-- b 6 r diff --git a/sapi/phpdbg/tests/watch_004.phpt b/sapi/phpdbg/tests/watch_004.phpt index 878542937b..42e3fd3b26 100644 --- a/sapi/phpdbg/tests/watch_004.phpt +++ b/sapi/phpdbg/tests/watch_004.phpt @@ -1,5 +1,14 @@ --TEST-- Test detection of inline string manipulations on zval watch +--SKIPIF-- +<?php +if (PHP_INT_SIZE == 4) { + die("xfail There may be flaws in the implementation of watchpoints that cause failures"); +} +if (getenv('SKIP_ASAN')) { + die("skip intentionally causes segfaults"); +} +?> --INI-- opcache.optimization_level=0 --PHPDBG-- diff --git a/sapi/phpdbg/tests/watch_005.phpt b/sapi/phpdbg/tests/watch_005.phpt index d6bae9d3f3..aacc158f61 100644 --- a/sapi/phpdbg/tests/watch_005.phpt +++ b/sapi/phpdbg/tests/watch_005.phpt @@ -1,5 +1,14 @@ --TEST-- Test proper watch comparisons when having multiple levels of indirection from a zval to its value +--SKIPIF-- +<?php +if (PHP_INT_SIZE == 4) { + die("xfail There may be flaws in the implementation of watchpoints that cause failures"); +} +if (getenv('SKIP_ASAN')) { + die("skip intentionally causes segfaults"); +} +?> --PHPDBG-- b 3 r diff --git a/sapi/phpdbg/tests/watch_006.phpt b/sapi/phpdbg/tests/watch_006.phpt index bf38b8eff1..5b5ca9ee57 100644 --- a/sapi/phpdbg/tests/watch_006.phpt +++ b/sapi/phpdbg/tests/watch_006.phpt @@ -1,5 +1,14 @@ --TEST-- Test multiple watch elements pointing to the same watchpoint +--SKIPIF-- +<?php +if (PHP_INT_SIZE == 4) { + die("xfail There may be flaws in the implementation of watchpoints that cause failures"); +} +if (getenv('SKIP_ASAN')) { + die("skip intentionally causes segfaults"); +} +?> --PHPDBG-- b 4 r diff --git a/sapi/phpdbg/web-bootstrap.php b/sapi/phpdbg/web-bootstrap.php index 046062997e..fa634ee8d7 100644 --- a/sapi/phpdbg/web-bootstrap.php +++ b/sapi/phpdbg/web-bootstrap.php @@ -30,7 +30,7 @@ $_SERVER = array 'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8', 'HTTP_COOKIE' => 'tz=Europe%2FLondon; __utma=1.347100075.1384196523.1384196523.1384196523.1; __utmc=1; __utmz=1.1384196523.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)', 'PATH' => '/usr/local/bin:/usr/bin:/bin', - 'SERVER_SIGNATURE' => '<address>Apache/2.4.6 (Ubuntu) Server at phpdbg.com Port 80</address>', + 'SERVER_SIGNATURE' => '<address>Apache/2.4.6 (Ubuntu) Server at localhost Port 80</address>', 'SERVER_SOFTWARE' => 'Apache/2.4.6 (Ubuntu)', 'SERVER_NAME' => 'localhost', 'SERVER_ADDR' => '127.0.0.1', diff --git a/sapi/phpdbg/xml.md b/sapi/phpdbg/xml.md index c02f80f2ca..3fff8d2bc1 100644 --- a/sapi/phpdbg/xml.md +++ b/sapi/phpdbg/xml.md @@ -633,7 +633,7 @@ Other tags - <watchhit variable="" />: when ever a watched variable is changed, followed by a <watchdata> container - <watchdata> may contain - for watchpoints on variables: - - each of these <watch*> tags conatins a type attribute whose value is either "old" or "new") + - each of these <watch*> tags contains a type attribute whose value is either "old" or "new") - <watchvalue type="" inaccessible="inaccessible" />: old value is inaccessible - <watchvalue type=""> may contain a <stream> element which indicates the old/new (type attribute) value of the variable - <watchrefcount type="" refcount="" isref="" />: old/new (type attribute) refcount and isref, both numbers diff --git a/sapi/tests/test001.phpt b/sapi/tests/test001.phpt deleted file mode 100644 index 318ab7a90f..0000000000 --- a/sapi/tests/test001.phpt +++ /dev/null @@ -1,16 +0,0 @@ ---TEST-- -IIS style CGI missing SCRIPT_FILENAME ---DESCRIPTION-- -This would be similar to what IIS produces for a simple query. ---ENV-- -return <<<END -PATH_TRANSLATED=$filename -PATH_INFO=$scriptname -SCRIPT_NAME=$scriptname -END; ---FILE-- -<?php - echo "HELLO"; -?> ---EXPECT-- -HELLO diff --git a/sapi/tests/test002.phpt b/sapi/tests/test002.phpt deleted file mode 100644 index 4afd8e276f..0000000000 --- a/sapi/tests/test002.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Apache style CGI ---DESCRIPTION-- -Apache likes to set SCRIPT_FILENAME to the php executable -if you use ScriptAlias configurations, and the proper -path is in PATH_TRANSLATED. SCRIPT_NAME in this is faked, -but that is ok, Apache sets SCRIPT_NAME to the ScriptAlias -of the executable. ---ENV-- -return <<<END -REDIRECT_URL=$scriptname -PATH_TRANSLATED=$filename -PATH_INFO=$scriptname -SCRIPT_NAME=/scriptalias/php -SCRIPT_FILENAME=$this->conf['TEST_PHP_EXECUTABLE'] -END; ---FILE-- -<?php - echo "HELLO"; -?> ---EXPECT-- -HELLO diff --git a/sapi/tests/test003.phpt b/sapi/tests/test003.phpt deleted file mode 100644 index 24abdbbf41..0000000000 --- a/sapi/tests/test003.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -IIS style CGI missing SCRIPT_FILENAME, has PATH_INFO ---DESCRIPTION-- -This would be similar to what IIS produces for a simple query -that also has PATH_INFO. ---REQUEST-- -return <<<END -PATH_INFO=/path/info -END; ---ENV-- -return <<<END -PATH_TRANSLATED=/path/bla -PATH_INFO=/path/info -SCRIPT_NAME=path -END; ---FILE-- -<?php - echo $_SERVER['PATH_INFO']; -?> ---EXPECT-- -/path/info diff --git a/sapi/tests/test004.phpt b/sapi/tests/test004.phpt deleted file mode 100644 index d1da1db6ed..0000000000 --- a/sapi/tests/test004.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Apache style CGI with PATH_INFO ---DESCRIPTION-- -Apache likes to set SCRIPT_FILENAME to the php executable -if you use ScriptAlias configurations, and the proper -path is in PATH_TRANSLATED. SCRIPT_NAME in this is faked, -but that is ok, Apache sets SCRIPT_NAME to the ScriptAlias -of the executable. ---REQUEST-- -return <<<END -PATH_INFO=/path/info -END; ---ENV-- -return <<<END -REDIRECT_URL=/path -PATH_TRANSLATED=/path/info/fpp -PATH_INFO=/path/info -SCRIPT_NAME=/scriptalias/php -SCRIPT_FILENAME=$this->conf['TEST_PHP_EXECUTABLE'] -END; ---FILE-- -<?php - echo $_SERVER['PATH_INFO']; -?> ---EXPECT-- -/path/info diff --git a/sapi/tests/test005.phpt b/sapi/tests/test005.phpt deleted file mode 100644 index 85143d5228..0000000000 --- a/sapi/tests/test005.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -QUERY_STRING Security Bug ---DESCRIPTION-- -This bug was present in PHP 4.3.0 only. -A failure should print HELLO. ---REQUEST-- -return <<<END -SCRIPT_NAME=/nothing.php -QUERY_STRING=$filename -END; ---ENV-- -return <<<END -REDIRECT_URL=$scriptname -PATH_TRANSLATED=c:\apache\1.3.27\htdocs\nothing.php -QUERY_STRING=$filename -PATH_INFO=/nothing.php -SCRIPT_NAME=/phpexe/php.exe/nothing.php -SCRIPT_FILENAME=c:\apache\1.3.27\htdocs\nothing.php -END; ---FILE-- -<?php - echo "HELLO"; -?> ---EXPECTHEADERS-- -Status: 404 Not Found ---EXPECT-- -No input file specified. diff --git a/sapi/tests/test006.phpt b/sapi/tests/test006.phpt deleted file mode 100644 index c43fe493c3..0000000000 --- a/sapi/tests/test006.phpt +++ /dev/null @@ -1,72 +0,0 @@ ---TEST-- -Multipart Form POST Data ---HEADERS-- -return <<<END -Content-Type=multipart/form-data; boundary=---------------------------240723202011929 -Content-Length=862 -END; ---ENV-- -return <<<END -CONTENT_TYPE=multipart/form-data; boundary=---------------------------240723202011929 -CONTENT_LENGTH=862 -END; ---POST-- ------------------------------240723202011929 -Content-Disposition: form-data; name="entry" - -entry box ------------------------------240723202011929 -Content-Disposition: form-data; name="password" - -password box ------------------------------240723202011929 -Content-Disposition: form-data; name="radio1" - -test 1 ------------------------------240723202011929 -Content-Disposition: form-data; name="checkbox1" - -test 1 ------------------------------240723202011929 -Content-Disposition: form-data; name="choices" - -Choice 1 ------------------------------240723202011929 -Content-Disposition: form-data; name="choices" - -Choice 2 ------------------------------240723202011929 -Content-Disposition: form-data; name="file"; filename="info.php" -Content-Type: application/octet-stream - -<?php -phpinfo(); -?> ------------------------------240723202011929-- ---FILE-- -<?php -error_reporting(0); -print_r($_POST); -print_r($_FILES); -?> ---EXPECTF-- -Array -( - [entry] => entry box - [password] => password box - [radio1] => test 1 - [checkbox1] => test 1 - [choices] => Choice 2 -) -Array -( - [file] => Array - ( - [name] => info.php - [type] => application/octet-stream - [tmp_name] => %s - [error] => 0 - [size] => 19 - ) - -) diff --git a/sapi/tests/test007.phpt b/sapi/tests/test007.phpt deleted file mode 100644 index 76fca8fcd6..0000000000 --- a/sapi/tests/test007.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -Multipart Form POST Data, incorrect content length ---HEADERS-- -return <<<END -Content-Type=multipart/form-data; boundary=---------------------------240723202011929 -Content-Length=100 -END; ---POST-- ------------------------------240723202011929 -Content-Disposition: form-data; name="entry" - -entry box ------------------------------240723202011929 -Content-Disposition: form-data; name="password" - -password box ------------------------------240723202011929 -Content-Disposition: form-data; name="radio1" - -test 1 ------------------------------240723202011929 -Content-Disposition: form-data; name="checkbox1" - -test 1 ------------------------------240723202011929 -Content-Disposition: form-data; name="choices" - -Choice 1 ------------------------------240723202011929 -Content-Disposition: form-data; name="choices" - -Choice 2 ------------------------------240723202011929 -Content-Disposition: form-data; name="file"; filename="info.php" -Content-Type: application/octet-stream - -<?php -phpinfo(); -?> ------------------------------240723202011929-- ---FILE-- -<?php -print @$_POST['choices']; -?> ---EXPECT-- |