From a4968eb347bb53f9f5467336425c6472f3cc298b Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Sun, 18 Jan 2015 10:34:11 +0100 Subject: when constants are added to a namespace, they now have the correct name with a namespace prefix --- zend/constantimpl.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/zend/constantimpl.h b/zend/constantimpl.h index 0545253..af4ecde 100644 --- a/zend/constantimpl.h +++ b/zend/constantimpl.h @@ -48,12 +48,30 @@ public: // we have to call the copy constructor to copy the entire other zval zval_copy_ctor(&constant.value); - // @todo include prefix + // is there a namespace name involved? + if (prefix.size() > 0) + { + // size of the name + auto namelen = ::strlen(_name); + + // include prefix in the full name + constant.name_len = prefix.size() + 1 + namelen; + constant.name = (char *)emalloc(constant.name_len); + + // copy the entire namespace name, separator and constant name + ::strncpy(constant.name, prefix.c_str(), prefix.size()); + ::strncpy(constant.name + prefix.size(), "\\", 1); + ::strncpy(constant.name + prefix.size() + 1, _name, namelen); + } + else + { + // no namespace, we simply copy the name + constant.name_len = ::strlen(_name); + constant.name = zend_strndup(_name, constant.name_len); + } // set all the other constant properties constant.flags = CONST_CS | CONST_PERSISTENT; - constant.name_len = ::strlen(_name); - constant.name = zend_strndup(_name, constant.name_len); constant.module_number = module_number; // register the zval -- cgit v1.2.3