diff options
author | Marcus Boerger <helly@php.net> | 2008-03-16 21:06:55 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2008-03-16 21:06:55 +0000 |
commit | af316021e8f69896cd0d246114962e48b973972f (patch) | |
tree | 7bf0e294155631040c03c6b76ab3b96dce967b94 /sapi | |
parent | eb8f83a98e7fbfa206601fa5016cc211eb78e024 (diff) | |
download | php-git-af316021e8f69896cd0d246114962e48b973972f.tar.gz |
- Rewrite scanner to be based on re2c instead of flex
The full patch is available as:
http://php.net/~helly/php-re2c-5.3-20080316.diff.txt
This is against php-re2c repository version 98
An older patch against version 97 is available under:
http://php.net/~helly/php-re2c-97-20080316.diff.txt
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/apache/mod_php5.c | 8 | ||||
-rw-r--r-- | sapi/apache_hooks/mod_php5.c | 8 | ||||
-rw-r--r-- | sapi/cgi/cgi_main.c | 6 | ||||
-rw-r--r-- | sapi/cgi/tests/007.phpt | 4 | ||||
-rw-r--r-- | sapi/cli/php_cli.c | 5 | ||||
-rw-r--r-- | sapi/cli/tests/010.phpt | 23 | ||||
-rw-r--r-- | sapi/cli/tests/016.phpt | 105 | ||||
-rw-r--r-- | sapi/cli/tests/017.phpt | 106 | ||||
-rw-r--r-- | sapi/tests/test003.phpt | 6 | ||||
-rw-r--r-- | sapi/tests/test004.phpt | 6 |
10 files changed, 237 insertions, 40 deletions
diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c index 2763d75c0e..d84b11e548 100644 --- a/sapi/apache/mod_php5.c +++ b/sapi/apache/mod_php5.c @@ -26,10 +26,6 @@ #define SIGPIPE SIGINT #endif -#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) -#include "ext/mbstring/mbstring.h" -#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */ - #undef shutdown /* {{{ Prototypes @@ -589,10 +585,6 @@ static int send_php(request_rec *r, int display_source_mode, char *filename) fh.free_filename = 0; fh.type = ZEND_HANDLE_FILENAME; -#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) - php_mb_set_zend_encoding(TSRMLS_C); -#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */ - zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &fh); return OK; } diff --git a/sapi/apache_hooks/mod_php5.c b/sapi/apache_hooks/mod_php5.c index 7e73c9902d..91de95929c 100644 --- a/sapi/apache_hooks/mod_php5.c +++ b/sapi/apache_hooks/mod_php5.c @@ -25,10 +25,6 @@ #define SIGPIPE SIGINT #endif -#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) -#include "ext/mbstring/mbstring.h" -#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */ - #undef shutdown /* {{{ Prototypes @@ -645,10 +641,6 @@ static int send_php(request_rec *r, int display_source_mode, char *filename) fh.free_filename = 0; fh.type = ZEND_HANDLE_FILENAME; -#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) - php_mbstring_set_zend_encoding(TSRMLS_C); -#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */ - zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &fh); return OK; } diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 86efb43b2a..22463ad55c 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -1960,7 +1960,7 @@ consult the installation file that came with this distribution, or visit \n\ case PHP_MODE_STRIP: if (open_file_for_scanning(&file_handle TSRMLS_CC) == SUCCESS) { zend_strip(TSRMLS_C); - fclose(file_handle.handle.fp); + zend_file_handle_dtor(&file_handle TSRMLS_CC); php_end_ob_buffers(1 TSRMLS_CC); } return SUCCESS; @@ -1975,7 +1975,7 @@ consult the installation file that came with this distribution, or visit \n\ if (fastcgi) { goto fastcgi_request_done; } - fclose(file_handle.handle.fp); + zend_file_handle_dtor(&file_handle TSRMLS_CC); php_end_ob_buffers(1 TSRMLS_CC); } return SUCCESS; @@ -1986,7 +1986,7 @@ consult the installation file that came with this distribution, or visit \n\ case PHP_MODE_INDENT: open_file_for_scanning(&file_handle TSRMLS_CC); zend_indent(); - fclose(file_handle.handle.fp); + zend_file_handle_dtor(&file_handle TSRMLS_CC); return SUCCESS; break; #endif diff --git a/sapi/cgi/tests/007.phpt b/sapi/cgi/tests/007.phpt index c0f8df1bff..aa2067d513 100644 --- a/sapi/cgi/tests/007.phpt +++ b/sapi/cgi/tests/007.phpt @@ -12,11 +12,11 @@ reset_env_vars(); var_dump(`"$php" -n -f some.php -f some.php`); var_dump(`"$php" -s -w -l`); -echo "Done\n"; ?> +===DONE=== --EXPECTF-- string(25) "No input file specified. " string(31) "No syntax errors detected in - " -Done +===DONE=== diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 806cc214c2..3392fb0b22 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -550,6 +550,9 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file, *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"))) { php_printf("Could not open input file: %s\n", script_file); return FAILURE; @@ -1166,7 +1169,7 @@ int main(int argc, char *argv[]) case PHP_MODE_INDENT: open_file_for_scanning(&file_handle TSRMLS_CC); zend_indent(); - fclose(file_handle.handle.fp); + zend_file_handle_dtor(file_handle.handle TSRMLS_CC); goto out; break; #endif diff --git a/sapi/cli/tests/010.phpt b/sapi/cli/tests/010.phpt index e465e37973..77c76c1940 100644 --- a/sapi/cli/tests/010.phpt +++ b/sapi/cli/tests/010.phpt @@ -12,8 +12,8 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { $php = getenv('TEST_PHP_EXECUTABLE'); -$filename = dirname(__FILE__)."/010.test.php"; -$filename_txt = dirname(__FILE__)."/010.test.txt"; +$filename = __DIR__."/010.test.php"; +$filename_txt = __DIR__."/010.test.txt"; $code = ' <?php @@ -25,23 +25,22 @@ file_put_contents($filename, $code); $txt = ' test -hello -'; +hello'; file_put_contents($filename_txt, $txt); var_dump(`cat "$filename_txt" | "$php" -n -F "$filename"`); -@unlink($filename); -@unlink($filename_txt); - -echo "Done\n"; +?> +===DONE=== +--CLEAN-- +<?php +@unlink(__DIR__."/010.test.php"); +@unlink(__DIR__."/010.test.txt"); ?> --EXPECTF-- -string(39) " +string(25) " string(10) "test hello" - -string(0) "" " -Done +===DONE=== diff --git a/sapi/cli/tests/016.phpt b/sapi/cli/tests/016.phpt index 0b90844f37..937ff62ccd 100644 --- a/sapi/cli/tests/016.phpt +++ b/sapi/cli/tests/016.phpt @@ -103,3 +103,108 @@ php > php { php { php > I was called! php > Done +--TEST-- +CLI -a and readline +--SKIPIF-- +<?php +include "skipif.inc"; +if (!extension_loaded('readline') || readline_info('done') === NULL) { + die ("skip need readline support"); +} +?> +--FILE-- +<?php +$php = getenv('TEST_PHP_EXECUTABLE'); + +$codes = array(); + +$codes[1] = <<<EOT +echo 'Hello world'; +exit +EOT; + +$codes[] = <<<EOT +echo 'multine +single +quote'; +exit +EOT; + +$codes[] = <<<EOT +echo <<<HEREDOC +Here +comes +the +doc +HEREDOC; +EOT; + +$codes[] = <<<EOT +if (0) { + echo "I'm not there"; +} +echo "Done"; +EOT; + +$codes[] = <<<EOT +function a_function_with_some_name() { + echo "I was called!"; +} +a_function_w ); +EOT; + +foreach ($codes as $key => $code) { + echo "\n--------------\nSnippet no. $key:\n--------------\n"; + $code = escapeshellarg($code); + echo `echo $code | "$php" -a`, "\n"; +} + +echo "\nDone\n"; +?> +--EXPECTF-- +-------------- +Snippet no. 1: +-------------- +Interactive shell + +php > Hello world +php > + +-------------- +Snippet no. 2: +-------------- +Interactive shell + +php > php ' php ' multine +single +quote +php > + +-------------- +Snippet no. 3: +-------------- +Interactive shell + +php > <<< > <<< > <<< > <<< > <<< > Here +comes +the +doc +php > + +-------------- +Snippet no. 4: +-------------- +Interactive shell + +php > php { php { php > Done +php > + +-------------- +Snippet no. 5: +-------------- +Interactive shell + +php > php { php { php > I was called! +php > + +Done diff --git a/sapi/cli/tests/017.phpt b/sapi/cli/tests/017.phpt index efaf977db4..c8c7d5e445 100644 --- a/sapi/cli/tests/017.phpt +++ b/sapi/cli/tests/017.phpt @@ -104,3 +104,109 @@ Parse error: syntax error, unexpected ')' in php shell code on line 1 Done +--TEST-- +CLI -a and libedit +--SKIPIF-- +<?php +include "skipif.inc"; +if (!extension_loaded('readline') || readline_info('done') !== NULL) { + die ("skip need readline support using libedit"); +} +?> +--FILE-- +<?php +$php = getenv('TEST_PHP_EXECUTABLE'); + +$codes = array(); + +$codes[1] = <<<EOT +echo 'Hello world'; +exit +EOT; + +$codes[] = <<<EOT +echo 'multine +single +quote'; +exit +EOT; + +$codes[] = <<<EOT +echo <<<HEREDOC +Here +comes +the +doc +HEREDOC; +EOT; + +$codes[] = <<<EOT +if (0) { + echo "I'm not there"; +} +echo "Done"; +EOT; + +$codes[] = <<<EOT +function a_function_with_some_name() { + echo "I was called!"; +} +a_function_w ); +EOT; + +foreach ($codes as $key => $code) { + echo "\n--------------\nSnippet no. $key:\n--------------\n"; + $code = escapeshellarg($code); + echo `echo $code | "$php" -a`, "\n"; +} + +echo "\nDone\n"; +?> +--EXPECTF-- +-------------- +Snippet no. 1: +-------------- +Interactive shell + +Hello world + + +-------------- +Snippet no. 2: +-------------- +Interactive shell + +multine +single +quote + + +-------------- +Snippet no. 3: +-------------- +Interactive shell + +Here +comes +the +doc + + +-------------- +Snippet no. 4: +-------------- +Interactive shell + +Done + + +-------------- +Snippet no. 5: +-------------- +Interactive shell + + +Parse error: syntax error, unexpected ')' in php shell code on line 1 + + +Done diff --git a/sapi/tests/test003.phpt b/sapi/tests/test003.phpt index 522d78db41..5cabe66b32 100644 --- a/sapi/tests/test003.phpt +++ b/sapi/tests/test003.phpt @@ -9,9 +9,9 @@ PATH_INFO=/path/info END; --ENV-- return <<<END -PATH_TRANSLATED=$filename/path/info -PATH_INFO=$scriptname/path/info -SCRIPT_NAME=$scriptname +PATH_TRANSLATED=/path/bla +PATH_INFO=/path/info +SCRIPT_NAME=path END; --FILE-- <?php diff --git a/sapi/tests/test004.phpt b/sapi/tests/test004.phpt index dad0dd0eec..ef4377484e 100644 --- a/sapi/tests/test004.phpt +++ b/sapi/tests/test004.phpt @@ -12,9 +12,9 @@ PATH_INFO=/path/info END; --ENV-- return <<<END -REDIRECT_URL=$scriptname -PATH_TRANSLATED=$filename/path/info -PATH_INFO=$scriptname/path/info +REDIRECT_URL=/path +PATH_TRANSLATED=/path/info/fpp +PATH_INFO=/path/info SCRIPT_NAME=/scriptalias/php SCRIPT_FILENAME=$this->conf['TEST_PHP_EXECUTABLE'] END; |