cvs: ZendEngine2 / zend_compile.c
| From: | Dmitry Stogov | Date: | Wed, 05 Sep 2007 07:24:52 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-5986@lists.php.net to get a copy of this message | ||
dmitry Wed Sep 5 07:24:52 2007 UTC
Modified files:
/ZendEngine2 zend_compile.c
Log:
Bug #42541 (Check for namespace decl. on first line doesn't work when extended info is on)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.766&r2=1.767&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.766 ZendEngine2/zend_compile.c:1.767
--- ZendEngine2/zend_compile.c:1.766 Sat Aug 25 23:28:10 2007
+++ ZendEngine2/zend_compile.c Wed Sep 5 07:24:52 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.766 2007/08/25 23:28:10 hirokawa Exp $ */
+/* $Id: zend_compile.c,v 1.767 2007/09/05 07:24:52 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -4478,7 +4478,15 @@
* want to tell them to put declare() at the top.
*/
if (CG(active_op_array)->last > 0) {
- zend_error(E_COMPILE_ERROR, "Encoding declaration pragma has to be the very first statement
in the script");
+ /* ignore ZEND_EXT_STMT */
+ int num = CG(active_op_array)->last;
+ while (num > 0 &&
+ CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT) {
+ --num;
+ }
+ if (num > 0) {
+ zend_error(E_COMPILE_ERROR, "Encoding declaration pragma has to be the very first
statement in the script");
+ }
}
convert_to_string(&val->u.constant);
if (zend_prepare_scanner_converters(Z_STRVAL(val->u.constant), 1 TSRMLS_CC) == FAILURE) {
@@ -5046,7 +5054,15 @@
zstr lcname;
if (CG(active_op_array)->last > 0) {
- zend_error(E_COMPILE_ERROR, "Namespace declaration statement has to be the very first
statement in the script");
+ /* ignore ZEND_EXT_STMT */
+ int num = CG(active_op_array)->last;
+ while (num > 0 &&
+ CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT) {
+ --num;
+ }
+ if (num > 0) {
+ zend_error(E_COMPILE_ERROR, "Namespace declaration statement has to be the very first
statement in the script");
+ }
}
if (CG(current_namespace)) {
zend_error(E_COMPILE_ERROR, "Namespace cannot be declared twice");