felipe                                   Sat, 13 Nov 2010 18:46:11 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=305327

Log:
- Fixed bug #53305 (E_NOTICE when defining a constant starts with  
__COMPILER_HALT_OFFSET__)
- Fixed a part of bug #53260 (the __COMPILER_HALT_OFFSET__ name is not shown in 
the E_NOTICE)

Bugs: http://bugs.php.net/53305 (Assigned) E_NOTICE when defining a constant 
starts with __COMPILER_HALT_OFFSET__
      http://bugs.php.net/53260 (Open) Notice message when running file 
containing __halt_compiler() more than once
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    A   php/php-src/branches/PHP_5_3/Zend/tests/bug53305.phpt
    U   php/php-src/branches/PHP_5_3/Zend/zend_constants.c
    A   php/php-src/trunk/Zend/tests/bug53305.phpt
    U   php/php-src/trunk/Zend/zend_constants.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2010-11-13 18:39:41 UTC (rev 305326)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-11-13 18:46:11 UTC (rev 305327)
@@ -62,6 +62,8 @@
 - Fixed the filter extension accepting IPv4 octets with a leading 0 as that
   belongs to the unsupported "dotted octal" representation. (Gustavo)

+- Fixed bug #53305 (E_NOTICE when defining a constant starts with
+  __COMPILER_HALT_OFFSET__). (Felipe)
 - Fixed bug #53297 (gettimeofday implementation in php/win32/time.c can return
   1 million microsecs). (ped at 7gods dot org)
 - Fixed bug #53279 (SplFileObject doesn't initialise default CSV escape

Added: php/php-src/branches/PHP_5_3/Zend/tests/bug53305.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/tests/bug53305.phpt                       
        (rev 0)
+++ php/php-src/branches/PHP_5_3/Zend/tests/bug53305.phpt       2010-11-13 
18:46:11 UTC (rev 305327)
@@ -0,0 +1,19 @@
+--TEST--
+Bug #53305 (E_NOTICE when defining a constant starts with 
__COMPILER_HALT_OFFSET__)
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+define('__COMPILER_HALT_OFFSET__1', 1);
+define('__COMPILER_HALT_OFFSET__2', 2);
+define('__COMPILER_HALT_OFFSET__', 3);
+define('__COMPILER_HALT_OFFSET__1'.chr(0), 4);
+
+var_dump(__COMPILER_HALT_OFFSET__1);
+var_dump(constant('__COMPILER_HALT_OFFSET__1'.chr(0)));
+
+?>
+--EXPECTF--
+Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d
+int(1)
+int(4)


Property changes on: php/php-src/branches/PHP_5_3/Zend/tests/bug53305.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/branches/PHP_5_3/Zend/zend_constants.c
===================================================================
--- php/php-src/branches/PHP_5_3/Zend/zend_constants.c  2010-11-13 18:39:41 UTC 
(rev 305326)
+++ php/php-src/branches/PHP_5_3/Zend/zend_constants.c  2010-11-13 18:46:11 UTC 
(rev 305327)
@@ -434,8 +434,15 @@
                }
        }

-       if ((strncmp(name, "__COMPILER_HALT_OFFSET__", 
sizeof("__COMPILER_HALT_OFFSET__") - 1) == 0) ||
-                       zend_hash_add(EG(zend_constants), name, c->name_len, 
(void *) c, sizeof(zend_constant), NULL)==FAILURE) {
+       /* Check if the user is trying to define the internal pseudo constant 
name __COMPILER_HALT_OFFSET__ */
+       if ((c->name_len == sizeof("__COMPILER_HALT_OFFSET__")
+               && !memcmp(name, "__COMPILER_HALT_OFFSET__", 
sizeof("__COMPILER_HALT_OFFSET__")-1))
+               || zend_hash_add(EG(zend_constants), name, c->name_len, (void 
*) c, sizeof(zend_constant), NULL)==FAILURE) {
+
+               /* The internal __COMPILER_HALT_OFFSET__ is prefixed by NULL 
byte */
+               if (strncmp(name+1, "__COMPILER_HALT_OFFSET__", 
sizeof("__COMPILER_HALT_OFFSET__")) == 0) {
+                       name++;
+               }
                zend_error(E_NOTICE,"Constant %s already defined", name);
                free(c->name);
                if (!(c->flags & CONST_PERSISTENT)) {

Added: php/php-src/trunk/Zend/tests/bug53305.phpt
===================================================================
--- php/php-src/trunk/Zend/tests/bug53305.phpt                          (rev 0)
+++ php/php-src/trunk/Zend/tests/bug53305.phpt  2010-11-13 18:46:11 UTC (rev 
305327)
@@ -0,0 +1,19 @@
+--TEST--
+Bug #53305 (E_NOTICE when defining a constant starts with 
__COMPILER_HALT_OFFSET__)
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+define('__COMPILER_HALT_OFFSET__1', 1);
+define('__COMPILER_HALT_OFFSET__2', 2);
+define('__COMPILER_HALT_OFFSET__', 3);
+define('__COMPILER_HALT_OFFSET__1'.chr(0), 4);
+
+var_dump(__COMPILER_HALT_OFFSET__1);
+var_dump(constant('__COMPILER_HALT_OFFSET__1'.chr(0)));
+
+?>
+--EXPECTF--
+Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d
+int(1)
+int(4)


Property changes on: php/php-src/trunk/Zend/tests/bug53305.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/trunk/Zend/zend_constants.c
===================================================================
--- php/php-src/trunk/Zend/zend_constants.c     2010-11-13 18:39:41 UTC (rev 
305326)
+++ php/php-src/trunk/Zend/zend_constants.c     2010-11-13 18:46:11 UTC (rev 
305327)
@@ -473,8 +473,15 @@
                }
        }

-       if ((strncmp(name, "__COMPILER_HALT_OFFSET__", 
sizeof("__COMPILER_HALT_OFFSET__") - 1) == 0) ||
-                       zend_hash_add(EG(zend_constants), name, c->name_len, 
(void *) c, sizeof(zend_constant), NULL)==FAILURE) {
+       /* Check if the user is trying to define the internal pseudo constant 
name __COMPILER_HALT_OFFSET__ */
+       if ((c->name_len == sizeof("__COMPILER_HALT_OFFSET__")
+               && !memcmp(name, "__COMPILER_HALT_OFFSET__", 
sizeof("__COMPILER_HALT_OFFSET__")-1))
+               || zend_hash_add(EG(zend_constants), name, c->name_len, (void 
*) c, sizeof(zend_constant), NULL)==FAILURE) {
+
+               /* The internal __COMPILER_HALT_OFFSET__ is prefixed by NULL 
byte */
+               if (strncmp(name+1, "__COMPILER_HALT_OFFSET__", 
sizeof("__COMPILER_HALT_OFFSET__")) == 0) {
+                       name++;
+               }
                zend_error(E_NOTICE,"Constant %s already defined", name);
                str_free(c->name);
                if (!(c->flags & CONST_PERSISTENT)) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to