zval_copy_ctor(const_val);
INIT_PZVAL(const_val);
- /* FIXME: Unicode support??? */
- add_assoc_zval_ex(modules[module_number], val->name.s, val->name_len, const_val);
+ add_u_assoc_zval_ex(modules[module_number], UG(unicode)?IS_UNICODE:IS_STRING, val->name, val->name_len, const_val);
+
bad_module_id:
zend_hash_move_forward_ex(EG(zend_constants), &pos);
}
void copy_zend_constant(zend_constant *c)
{
- /* FIXME: Unicode support??? */
- c->name.s = zend_strndup(c->name.s, c->name_len - 1);
+ TSRMLS_FETCH();
+ if (UG(unicode)) {
+ c->name.u = zend_ustrndup(c->name.u, c->name_len - 1);
+ } else {
+ c->name.s = zend_strndup(c->name.s, c->name_len - 1);
+ }
if (!(c->flags & CONST_PERSISTENT)) {
zval_copy_ctor(&c->value);
}
ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
{
- return zend_u_register_constant(IS_STRING, c TSRMLS_CC);
+ if (UG(unicode)) {
+ UChar *ustr;
+
+ if (c->name.s) {
+ ustr = malloc(UBYTES(c->name_len));
+ u_charsToUChars(c->name.s, ustr, c->name_len);
+ free(c->name.s);
+ c->name.u = ustr;
+ }
+ if (Z_TYPE(c->value) == IS_STRING || Z_TYPE(c->value) == IS_CONSTANT) {
+ ustr = pemalloc(UBYTES(Z_STRLEN(c->value)+1), c->flags & CONST_PERSISTENT);
+ u_charsToUChars(Z_STRVAL(c->value), ustr, Z_STRLEN(c->value)+1);
+ pefree(Z_STRVAL(c->value), c->flags & CONST_PERSISTENT);
+ Z_USTRVAL(c->value) = ustr;
+ if (Z_TYPE(c->value) == IS_STRING) Z_TYPE(c->value) = IS_UNICODE;
+ }
+ return zend_u_register_constant(IS_UNICODE, c TSRMLS_CC);
+ } else {
+ return zend_u_register_constant(IS_STRING, c TSRMLS_CC);
+ }
}
/*
* Local variables: