]> granicus.if.org Git - php/commitdiff
Fixed constant substitution (Matt)
authorDmitry Stogov <dmitry@php.net>
Mon, 28 Jul 2008 14:12:19 +0000 (14:12 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 28 Jul 2008 14:12:19 +0000 (14:12 +0000)
Zend/tests/constants_005.phpt [new file with mode: 0755]
Zend/zend_compile.c
Zend/zend_constants.c

diff --git a/Zend/tests/constants_005.phpt b/Zend/tests/constants_005.phpt
new file mode 100755 (executable)
index 0000000..097be97
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Persistent case insensetive and user defined constants
+--FILE--
+<?php
+var_dump(ZEND_THREAD_safe);
+define("ZEND_THREAD_safe", 123);
+var_dump(ZEND_THREAD_safe);
+?>
+--EXPECTF--
+bool(%s)
+int(123)
index 789b4f708484a73dac08333a2633466ed132afea..13edf258c44e3d84590996b14305c5dd95e41eb1 100644 (file)
@@ -3767,15 +3767,13 @@ static zend_constant* zend_get_ct_const(zval *const_name TSRMLS_DC) /* {{{ */
                char *lookup_name = zend_str_tolower_dup(Z_STRVAL_P(const_name), Z_STRLEN_P(const_name));
                 
                if (zend_hash_find(EG(zend_constants), lookup_name, Z_STRLEN_P(const_name)+1, (void **) &c)==SUCCESS) {
-                       if ((c->flags & CONST_CS) && memcmp(c->name, Z_STRVAL_P(const_name), Z_STRLEN_P(const_name))!=0) {
+                       if ((c->flags & CONST_CT_SUBST) && !(c->flags & CONST_CS)) {
                                efree(lookup_name);
-                               return NULL;
+                               return c;
                        }
-               } else {
-                       efree(lookup_name);
-                       return NULL;
                }
                efree(lookup_name);
+               return NULL;
        }
        if (c->flags & CONST_CT_SUBST) {
                return c;
index c672b5e4c6bfc0e56fb052156a95c97a2a2d5041..bc4e7edf1b6a1f7d432bbaf46adc087e822c99eb 100644 (file)
@@ -231,7 +231,7 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC
                lookup_name = zend_str_tolower_dup(name, name_len);
 
                if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) {
-                       if ((c->flags & CONST_CS) && memcmp(c->name, name, name_len) != 0) {
+                       if (c->flags & CONST_CS) {
                                retval=0;
                        }
                } else {