Browse Source

Unicode support: fixed internal constants usage and get_defined_constants()

migration/RELEASE_1_0_0
Dmitry Stogov 21 years ago
parent
commit
1f4d9fa4a7
  1. 4
      Zend/zend_builtin_functions.c
  2. 29
      Zend/zend_constants.c

4
Zend/zend_builtin_functions.c

@ -1663,8 +1663,8 @@ ZEND_FUNCTION(get_defined_constants)
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);
}

29
Zend/zend_constants.c

@ -38,8 +38,12 @@ void free_zend_constant(zend_constant *c)
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);
}
@ -358,7 +362,26 @@ ZEND_API int zend_u_register_constant(zend_uchar type, zend_constant *c TSRMLS_D
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:

Loading…
Cancel
Save