Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40483 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21319 invoked from network); 12 Sep 2008 19:11:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Sep 2008 19:11:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 208.83.222.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 208.83.222.18 unknown Linux 2.6 Received: from [208.83.222.18] ([208.83.222.18:35420] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/56-22777-EEEBAC84 for ; Fri, 12 Sep 2008 15:11:43 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id BB6D2C0F7AE for ; Fri, 12 Sep 2008 12:10:52 -0700 (MST) Received: from [192.168.223.130] (pcp041247pcs.unl.edu [129.93.124.186]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 7641EC0F7AD for ; Fri, 12 Sep 2008 12:10:52 -0700 (MST) Message-ID: <48CABEEB.9070201@chiaraquartet.net> Date: Fri, 12 Sep 2008 14:11:39 -0500 User-Agent: Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: internals@lists.php.net Content-Type: multipart/mixed; boundary="------------090009070101070906020807" X-Virus-Scanned: ClamAV using ClamSMTP Subject: [PATCH] allow T_INLINE_HTML before T_NAMESPACE From: greg@chiaraquartet.net (Greg Beaver) --------------090009070101070906020807 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, This is a simple patch that allows files like this: main.php: template example to work without parse error. Greg P.S. this is the last outstanding namespace issue that I'm aware of aside from the bracket wars, which is 100% philosophical, all the issues fixed by my patches are functional problems in namespaces. --------------090009070101070906020807 Content-Type: text/plain; name="inline_html.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="inline_html.patch.txt" Index: Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.647.2.27.2.41.2.85 diff -u -u -r1.647.2.27.2.41.2.85 zend_compile.c --- Zend/zend_compile.c 29 Aug 2008 10:17:08 -0000 1.647.2.27.2.41.2.85 +++ Zend/zend_compile.c 12 Sep 2008 19:07:42 -0000 @@ -504,13 +504,17 @@ } -void zend_do_echo(const znode *arg TSRMLS_DC) +void zend_do_echo(const znode *arg, int is_html TSRMLS_DC) { zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_ECHO; opline->op1 = *arg; - SET_UNUSED(opline->op2); + if (is_html) { + opline->op2.op_type = IS_CONST; /* tell zend_do_namespace that INLINE_HTML is OK */ + } else { + SET_UNUSED(opline->op2); + } } void zend_do_abstract_method(const znode *function_name, znode *modifiers, const znode *body TSRMLS_DC) @@ -5040,10 +5044,11 @@ char *lcname; if (CG(active_op_array)->last > 0) { - /* ignore ZEND_EXT_STMT and ZEND_TICKS */ + /* ignore ZEND_EXT_STMT and ZEND_TICKS and T_INLINE_HTML */ int num = CG(active_op_array)->last; while (num > 0 && (CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT || + (CG(active_op_array)->opcodes[num-1].opcode == ZEND_ECHO && CG(active_op_array)->opcodes[num-1].op2.op_type == IS_CONST) || CG(active_op_array)->opcodes[num-1].opcode == ZEND_TICKS)) { --num; } Index: Zend/zend_compile.h =================================================================== RCS file: /repository/ZendEngine2/zend_compile.h,v retrieving revision 1.316.2.8.2.12.2.33 diff -u -u -r1.316.2.8.2.12.2.33 zend_compile.h --- Zend/zend_compile.h 29 Aug 2008 18:12:47 -0000 1.316.2.8.2.12.2.33 +++ Zend/zend_compile.h 12 Sep 2008 19:07:42 -0000 @@ -385,7 +385,7 @@ void fetch_string_offset(znode *result, const znode *parent, const znode *offset TSRMLS_DC); void zend_do_fetch_static_member(znode *result, znode *class_znode TSRMLS_DC); void zend_do_print(znode *result, const znode *arg TSRMLS_DC); -void zend_do_echo(const znode *arg TSRMLS_DC); +void zend_do_echo(const znode *arg, int is_html TSRMLS_DC); typedef int (*unary_op_type)(zval *, zval * TSRMLS_DC); typedef int (*binary_op_type)(zval *, zval *, zval * TSRMLS_DC); ZEND_API unary_op_type get_unary_op(int opcode); Index: Zend/zend_language_parser.y =================================================================== RCS file: /repository/ZendEngine2/zend_language_parser.y,v retrieving revision 1.160.2.4.2.8.2.26 diff -u -u -r1.160.2.4.2.8.2.26 zend_language_parser.y --- Zend/zend_language_parser.y 29 Aug 2008 17:54:29 -0000 1.160.2.4.2.8.2.26 +++ Zend/zend_language_parser.y 12 Sep 2008 19:07:42 -0000 @@ -236,7 +236,7 @@ | T_GLOBAL global_var_list ';' | T_STATIC static_var_list ';' | T_ECHO echo_expr_list ';' - | T_INLINE_HTML { zend_do_echo(&$1 TSRMLS_CC); } + | T_INLINE_HTML { zend_do_echo(&$1, 1 TSRMLS_CC); } | expr ';' { zend_do_free(&$1 TSRMLS_CC); } | T_UNSET '(' unset_variables ')' ';' | T_FOREACH '(' variable T_AS @@ -556,8 +556,8 @@ ; echo_expr_list: - echo_expr_list ',' expr { zend_do_echo(&$3 TSRMLS_CC); } - | expr { zend_do_echo(&$1 TSRMLS_CC); } + echo_expr_list ',' expr { zend_do_echo(&$3, 0 TSRMLS_CC); } + | expr { zend_do_echo(&$1, 0 TSRMLS_CC); } ; Index: Zend/tests/ns_076.phpt =================================================================== RCS file: Zend/tests/ns_076.phpt diff -N Zend/tests/ns_076.phpt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Zend/tests/ns_076.phpt 12 Sep 2008 19:07:42 -0000 @@ -0,0 +1,26 @@ +--TEST-- +076: T_INLINE_HTML prior to namespace declaration +--FILE-- +hi there + +===DONE=== +--EXPECT-- +hi there +string(3) "foo" +string(0) "" +string(3) "foo" +===DONE=== Index: Zend/tests/ns_077.phpt =================================================================== RCS file: Zend/tests/ns_077.phpt diff -N Zend/tests/ns_077.phpt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Zend/tests/ns_077.phpt 12 Sep 2008 19:07:42 -0000 @@ -0,0 +1,21 @@ +--TEST-- +076: T_ECHO prior to namespace declaration +--FILE-- + +===DONE=== +--EXPECTF-- +Fatal error: Namespace declaration statement has to be the very first statement in the script in %sns_077.php on line %d \ No newline at end of file --------------090009070101070906020807--