diff options
Diffstat (limited to 'zend/constantimpl.h')
-rw-r--r-- | zend/constantimpl.h | 24 |
1 files 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 |