]> granicus.if.org Git - php/commitdiff
- Fix bug in class constants
authorAndi Gutmans <andi@php.net>
Sun, 16 Jun 2002 18:25:05 +0000 (18:25 +0000)
committerAndi Gutmans <andi@php.net>
Sun, 16 Jun 2002 18:25:05 +0000 (18:25 +0000)
- Start centralizing main class lookups. This will help implement
- __autload()

Zend/zend_execute.c
Zend/zend_execute.h
Zend/zend_execute_API.c

index 5e85195630f248661f9f0ac742e4d47d98540056..70cff0085b31a0ccd9581081d62675db83f0c851 100644 (file)
@@ -1555,7 +1555,7 @@ binary_assign_op_addr_obj:
                                {
                                        zval **value_ptr_ptr = get_zval_ptr_ptr(&EX(opline)->op2, EX(Ts), BP_VAR_W);
 
-                                       if (value_ptr_ptr = &EX(Ts)[EX(opline)->op2.u.var].var.ptr) {
+                                       if (value_ptr_ptr = EX(Ts)[EX(opline)->op2.u.var].var.ptr_ptr) {
                                                if (!(*value_ptr_ptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(*value_ptr_ptr) || (*value_ptr_ptr)->refcount == 1)))
                                                {
                                                        zend_error(E_ERROR, "Can't assign by reference non-referencable value!");
@@ -1850,7 +1850,7 @@ binary_assign_op_addr_obj:
                                                        class_name_strlen = tmp.value.str.len;
                                                }
                                        
-                                               if (zend_hash_find(EG(class_table), class_name_strval, class_name_strlen+1, (void **) &pce) == FAILURE) {
+                                               if (zend_lookup_class(class_name_strval, class_name_strlen, &pce TSRMLS_CC) == FAILURE) {
                                                        zend_error(E_ERROR, "Class '%s' not found", class_name_strval);
                                                } else {
                                                        EX(Ts)[EX(opline)->result.u.var].EA.class_entry = *pce;
index 686f1a6640a370a7379fc71736905c3fca8b7085..e578842231bfde48fb48a95222d225bc62a396c2 100644 (file)
@@ -64,7 +64,7 @@ static inline void safe_free_zval_ptr(zval *p)
                FREE_ZVAL(p);
        }
 }
-
+ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
 ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
 
 static inline int i_zend_is_true(zval *op)
index c007ee8bb5de7842df9fc5c531a80639f02a5569..36596e022887e691225c6c32e2c1344bb8d95902 100644 (file)
@@ -331,12 +331,12 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
                if (strchr(p->value.str.val, ':')) {
                        char *cur, *temp;
                        char *last;
-                       zend_class_entry *ce;
+                       zend_class_entry **ce;
                        zval **value;
 
                        last = tsrm_strtok_r(p->value.str.val, ":", &temp);
 
-                       if (zend_hash_find(EG(class_table), last, strlen(last)+1, (void **)&ce) == FAILURE) {
+                       if (zend_lookup_class(last, strlen(last), &ce TSRMLS_CC) == FAILURE) {
                                zend_error(E_ERROR, "Invalid class! Improve this error message");
                        }
                        
@@ -347,12 +347,12 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
                                if (!cur) {
                                        break;
                                }
-                               if (zend_hash_find(&ce->class_table, last, strlen(last)+1, (void **)&ce) == FAILURE) {
+                               if (zend_hash_find(&(*ce)->class_table, last, strlen(last)+1, (void **)&ce) == FAILURE) {
                                        zend_error(E_ERROR, "Invalid class! Improve this error message");
                                }
                                last = cur;
                        }
-                       if (zend_hash_find(&ce->constants_table, last, strlen(last)+1, (void **) &value) == FAILURE) {
+                       if (zend_hash_find(&(*ce)->constants_table, last, strlen(last)+1, (void **) &value) == FAILURE) {
                                zend_error(E_ERROR, "Invalid class! Improve this error message");
                        }
                        const_value = **value;
@@ -500,7 +500,7 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun
 
                        lc_class = estrndup(Z_STRVAL_PP(object_pp), Z_STRLEN_PP(object_pp));
                        zend_str_tolower(lc_class, Z_STRLEN_PP(object_pp));
-                       found = zend_hash_find(EG(class_table), lc_class, Z_STRLEN_PP(object_pp) + 1, (void **) &ce);
+                       found = zend_lookup_class(lc_class, Z_STRLEN_PP(object_pp), &ce TSRMLS_CC);
                        efree(lc_class);
                        if (found == FAILURE)
                                return FAILURE;
@@ -637,6 +637,11 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun
        return SUCCESS;
 }
 
+ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC)
+{
+       return zend_hash_find(EG(class_table), name, name_length+1, (void **) ce);
+}
+
 
 ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC)
 {