summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2015-01-18 10:34:11 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2015-01-18 10:34:11 +0100
commita4968eb347bb53f9f5467336425c6472f3cc298b (patch)
treeaf5b6d2e6e32b1722106491b0efebfd9afaf740a
parent5fd8b29a1981d2d4f7c4e9925729fbe9f1c558bb (diff)
when constants are added to a namespace, they now have the correct name with a namespace prefix
-rw-r--r--zend/constantimpl.h24
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