Hi Derick, Here's version 2, which frees the def_file during class_entry destruction... Also, I changed that line you mentioned like this:
CG(class_entry).def_file = estrdup(zend_get_compiled_filename(TSRMLS_C)); Since the various things I tested (such as eval and php -r) didn't seem to set the filename to NULL. What would be nice is to tell the user that the original was an internal or built-in class, because for code like this: foo.php: <?php class Directory {} ?> we are reporting that Directory was originally declared in foo.php:2, which is slightly misleading :-) --Wez. On 09/18/02, [EMAIL PROTECTED] wrote: > Hey, > > looks okay (and it works too :). Only one little thing: > > + if (CG(class_entry).def_file) > + CG(class_entry).def_file = estrdup(CG(class_entry).def_file); > > Should really be: > > + if (CG(class_entry).def_file) { > + CG(class_entry).def_file = estrdup(CG(class_entry).def_file); > + } > >
Index: zend.h =================================================================== RCS file: /repository/Zend/zend.h,v retrieving revision 1.160 diff -u -r1.160 zend.h --- zend.h 17 Sep 2002 09:06:07 -0000 1.160 +++ zend.h 18 Sep 2002 10:55:45 -0000 @@ -275,6 +275,10 @@ void (*handle_function_call)(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference); zval (*handle_property_get)(zend_property_reference *property_reference); int (*handle_property_set)(zend_property_reference *property_reference, zval *value); + + /* location of definition of this class */ + char *def_file; + int def_lineno; }; Index: zend_compile.c =================================================================== RCS file: /repository/Zend/zend_compile.c,v retrieving revision 1.236 diff -u -r1.236 zend_compile.c --- zend_compile.c 20 Aug 2002 14:26:31 -0000 1.236 +++ zend_compile.c 18 Sep 2002 10:55:47 -0000 @@ -1190,7 +1190,10 @@ if (zend_hash_add(class_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, ce, sizeof(zend_class_entry), NULL)==FAILURE) { (*ce->refcount)--; if (!compile_time) { - zend_error(E_ERROR, "Cannot redeclare class %s", opline->op2.u.constant.value.str.val); + zend_error(E_ERROR, "Cannot redeclare +class %s (previously declared in %s:%d)", + +opline->op2.u.constant.value.str.val, + ce->def_file, + ce->def_lineno); } return FAILURE; } else { @@ -1581,6 +1584,9 @@ CG(class_entry).handle_property_set = NULL; CG(class_entry).handle_property_get = NULL; + CG(class_entry).def_file = estrdup(zend_get_compiled_filename(TSRMLS_C)); + CG(class_entry).def_lineno = CG(zend_lineno); + /* code for inheritance from parent class */ if (parent_class_name) { zend_class_entry *parent_class; Index: zend_opcode.c =================================================================== RCS file: /repository/Zend/zend_opcode.c,v retrieving revision 1.56 diff -u -r1.56 zend_opcode.c --- zend_opcode.c 6 Jan 2002 15:21:09 -0000 1.56 +++ zend_opcode.c 18 Sep 2002 10:55:47 -0000 @@ -115,6 +115,7 @@ case ZEND_USER_CLASS: efree(ce->name); efree(ce->refcount); + efree(ce->def_file); zend_hash_destroy(&ce->function_table); zend_hash_destroy(&ce->default_properties); break;
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php