[PHP-CVS] svn: /php/php-src/trunk/sapi/cli/ php_cli_readline.c php_cli_readline.h
pajoye Tue, 22 Feb 2011 12:59:50 + Revision: http://svn.php.net/viewvc?view=revisionrevision=308565 Log: - missing files Changed paths: A php/php-src/trunk/sapi/cli/php_cli_readline.c A php/php-src/trunk/sapi/cli/php_cli_readline.h Added: php/php-src/trunk/sapi/cli/php_cli_readline.c === --- php/php-src/trunk/sapi/cli/php_cli_readline.c (rev 0) +++ php/php-src/trunk/sapi/cli/php_cli_readline.c 2011-02-22 12:59:50 UTC (rev 308565) @@ -0,0 +1,448 @@ +/* + +--+ + | PHP Version 5| + +--+ + | Copyright (c) 1997-2011 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| + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | lice...@php.net so we can mail you a copy immediately. | + +--+ + | Author: Marcus Boerger he...@php.net | + | Johannes Schlueter johan...@php.net| + +--+ +*/ + +/* $Id: php_cli_readline.c 306939 2011-01-01 02:19:59Z felipe $ */ + +#include php.h + +#if (HAVE_LIBREADLINE || HAVE_LIBEDIT) !defined(COMPILE_DL_READLINE) + +#ifndef HAVE_RL_COMPLETION_MATCHES +#define rl_completion_matches completion_matches +#endif + +#include php_globals.h +#include php_variables.h +#include zend_hash.h +#include zend_modules.h + +#include SAPI.h + +#if HAVE_SETLOCALE +#include locale.h +#endif +#include zend.h +#include zend_extensions.h +#include php_ini.h +#include php_globals.h +#include php_main.h +#include fopen_wrappers.h +#include ext/standard/php_standard.h + +#ifdef __riscos__ +#include unixlib/local.h +#endif + +#if HAVE_LIBEDIT +#include editline/readline.h +#else +#include readline/readline.h +#include readline/history.h +#endif + +#include zend_compile.h +#include zend_execute.h +#include zend_highlight.h +#include zend_indent.h + +typedef enum { + body, + sstring, + dstring, + sstring_esc, + dstring_esc, + comment_line, + comment_block, + heredoc_start, + heredoc, + outside, +} php_code_type; + +int cli_is_valid_code(char *code, int len, char **prompt TSRMLS_DC) /* {{{ */ +{ + int valid_end = 1, last_valid_end; + int brackets_count = 0; + int brace_count = 0; + int i; + php_code_type code_type = body; + char *heredoc_tag; + int heredoc_len; + + for (i = 0; i len; ++i) { + switch(code_type) { + default: +switch(code[i]) { + case '{': + brackets_count++; + valid_end = 0; + break; + case '}': + if (brackets_count 0) { + brackets_count--; + } + valid_end = brackets_count ? 0 : 1; + break; + case '(': + brace_count++; + valid_end = 0; + break; + case ')': + if (brace_count 0) { + brace_count--; + } + valid_end = 0; + break; + case ';': + valid_end = brace_count == 0 brackets_count == 0; + break; + case ' ': + case '\r': + case '\n': + case '\t': + break; + case '\'': + code_type = sstring; + break; + case '': + code_type = dstring; + break; + case '#': + code_type = comment_line; + break; + case '/': + if (code[i+1] == '/') { + i++; + code_type = comment_line; + break; + } + if (code[i+1] == '*') { + last_valid_end = valid_end; + valid_end = 0; + code_type = comment_block; + i++; + break; + } + valid_end = 0; + break; + case '%': + if (!CG(asp_tags)) { + valid_end = 0; + break; + } + /* no break */ + case '?': + if (code[i+1] == '') { + i++; + code_type = outside; + break; + } + valid_end = 0; + break; + case '': + valid_end = 0; + if (i + 2 len code[i+1] == '' code[i+2] == '') { + i += 2; + code_type = heredoc_start; + heredoc_len = 0; + } + break; + default: + valid_end = 0; + break; +} +break; + case sstring: +if (code[i] == '\\') { + code_type = sstring_esc; +} else { + if (code[i] == '\'') { + code_type = body; + } +} +break; + case
[PHP-CVS] svn: /php/php-src/trunk/sapi/cli/ php_cli_readline.c php_cli_readline.h
pajoye Tue, 22 Feb 2011 13:09:15 + Revision: http://svn.php.net/viewvc?view=revisionrevision=308566 Log: -not needed, buildconf helps... Changed paths: D php/php-src/trunk/sapi/cli/php_cli_readline.c D php/php-src/trunk/sapi/cli/php_cli_readline.h Deleted: php/php-src/trunk/sapi/cli/php_cli_readline.c === --- php/php-src/trunk/sapi/cli/php_cli_readline.c 2011-02-22 12:59:50 UTC (rev 308565) +++ php/php-src/trunk/sapi/cli/php_cli_readline.c 2011-02-22 13:09:15 UTC (rev 308566) @@ -1,448 +0,0 @@ -/* - +--+ - | PHP Version 5| - +--+ - | Copyright (c) 1997-2011 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| - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | lice...@php.net so we can mail you a copy immediately. | - +--+ - | Author: Marcus Boerger he...@php.net | - | Johannes Schlueter johan...@php.net| - +--+ -*/ - -/* $Id: php_cli_readline.c 306939 2011-01-01 02:19:59Z felipe $ */ - -#include php.h - -#if (HAVE_LIBREADLINE || HAVE_LIBEDIT) !defined(COMPILE_DL_READLINE) - -#ifndef HAVE_RL_COMPLETION_MATCHES -#define rl_completion_matches completion_matches -#endif - -#include php_globals.h -#include php_variables.h -#include zend_hash.h -#include zend_modules.h - -#include SAPI.h - -#if HAVE_SETLOCALE -#include locale.h -#endif -#include zend.h -#include zend_extensions.h -#include php_ini.h -#include php_globals.h -#include php_main.h -#include fopen_wrappers.h -#include ext/standard/php_standard.h - -#ifdef __riscos__ -#include unixlib/local.h -#endif - -#if HAVE_LIBEDIT -#include editline/readline.h -#else -#include readline/readline.h -#include readline/history.h -#endif - -#include zend_compile.h -#include zend_execute.h -#include zend_highlight.h -#include zend_indent.h - -typedef enum { - body, - sstring, - dstring, - sstring_esc, - dstring_esc, - comment_line, - comment_block, - heredoc_start, - heredoc, - outside, -} php_code_type; - -int cli_is_valid_code(char *code, int len, char **prompt TSRMLS_DC) /* {{{ */ -{ - int valid_end = 1, last_valid_end; - int brackets_count = 0; - int brace_count = 0; - int i; - php_code_type code_type = body; - char *heredoc_tag; - int heredoc_len; - - for (i = 0; i len; ++i) { - switch(code_type) { - default: -switch(code[i]) { - case '{': - brackets_count++; - valid_end = 0; - break; - case '}': - if (brackets_count 0) { - brackets_count--; - } - valid_end = brackets_count ? 0 : 1; - break; - case '(': - brace_count++; - valid_end = 0; - break; - case ')': - if (brace_count 0) { - brace_count--; - } - valid_end = 0; - break; - case ';': - valid_end = brace_count == 0 brackets_count == 0; - break; - case ' ': - case '\r': - case '\n': - case '\t': - break; - case '\'': - code_type = sstring; - break; - case '': - code_type = dstring; - break; - case '#': - code_type = comment_line; - break; - case '/': - if (code[i+1] == '/') { - i++; - code_type = comment_line; - break; - } - if (code[i+1] == '*') { - last_valid_end = valid_end; - valid_end = 0; - code_type = comment_block; - i++; - break; - } - valid_end = 0; - break; - case '%': - if (!CG(asp_tags)) { - valid_end = 0; - break; - } - /* no break */ - case '?': - if (code[i+1] == '') { - i++; - code_type = outside; - break; - } - valid_end = 0; - break; - case '': - valid_end = 0; - if (i + 2 len code[i+1] == '' code[i+2] == '') { - i += 2; - code_type = heredoc_start; - heredoc_len = 0; - } - break; - default: - valid_end = 0; - break; -} -break; - case sstring: -if (code[i] == '\\') { - code_type = sstring_esc; -} else { - if (code[i] == '\'') { - code_type = body; - } -}