Changeset 103 in svn for trunk/utils.c


Ignore:
Timestamp:
2006-08-27T07:09:02+02:00 (9 years ago)
Author:
Xuefer
Message:

PHP_6: builds again with php6. update UChar/void ptr to zstr.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils.c

    r95 r103  
    266266
    267267#ifdef HAVE_XCACHE_CONSTANT
    268 void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, void *key, uint len TSRMLS_DC) /* {{{ */
     268void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, zstr key, uint len TSRMLS_DC) /* {{{ */
    269269{
    270270    if (zend_u_hash_add(EG(zend_constants), type, key, len,
     
    275275        CG(compiled_filename) = filename;
    276276        CG(zend_lineno) = 0;
     277#ifdef IS_UNICODE
     278        zend_error(E_NOTICE, "Constant %R already defined", type, key);
     279#else
    277280        zend_error(E_NOTICE, "Constant %s already defined", key);
    278         free(constant->name);
     281#endif
     282        free(ZSTR_V(constant->name));
    279283        if (!(constant->flags & CONST_PERSISTENT)) {
    280284            zval_dtor(&constant->value);
     
    284288/* }}} */
    285289#endif
    286 void xc_install_function(char *filename, zend_function *func, zend_uchar type, void *key, uint len TSRMLS_DC) /* {{{ */
    287 {
     290void xc_install_function(char *filename, zend_function *func, zend_uchar type, zstr key, uint len TSRMLS_DC) /* {{{ */
     291{
     292    zend_bool istmpkey;
     293
    288294    if (func->type == ZEND_USER_FUNCTION) {
    289         if (*(char *) key == '\0') {
     295#ifdef IS_UNICODE
     296        istmpkey = (type == IS_STRING && ZSTR_S(key)[0] == 0) || ZSTR_U(key)[0] == 0;
     297#else
     298        istmpkey = ZSTR_S(key)[0] == 0;
     299#endif
     300        if (istmpkey) {
    290301            zend_u_hash_update(CG(function_table), type, key, len,
    291302                        func, sizeof(zend_op_array),
     
    300311            CG(compiled_filename) = filename;
    301312            CG(zend_lineno) = ZESW(func->op_array.opcodes[0].lineno, func->op_array.line_start);
     313#ifdef IS_UNICODE
     314            zend_error(E_ERROR, "Cannot redeclare %R()", type, key);
     315#else
    302316            zend_error(E_ERROR, "Cannot redeclare %s()", key);
    303         }
    304     }
    305 }
    306 /* }}} */
    307 ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, zend_uchar type, void *key, uint len TSRMLS_DC) /* {{{ */
    308 {
     317#endif
     318        }
     319    }
     320}
     321/* }}} */
     322ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, zend_uchar type, zstr key, uint len TSRMLS_DC) /* {{{ */
     323{
     324    zend_bool istmpkey;
    309325    zend_class_entry *cep = CestToCePtr(*cest);
    310326    ZESW(void *stored_ce_ptr, NOTHING);
    311327
    312     if (*(char *) key == '\0') {
     328#ifdef IS_UNICODE
     329    istmpkey = (type == IS_STRING && ZSTR_S(key)[0] == 0) || ZSTR_U(key)[0] == 0;
     330#else
     331    istmpkey = ZSTR_S(key)[0] == 0;
     332#endif
     333    if (istmpkey) {
    313334        zend_u_hash_update(CG(class_table), type, key, len,
    314335                    cest, sizeof(xc_cest_t),
     
    323344        CG(compiled_filename) = filename;
    324345        CG(zend_lineno) = ZESW(0, cep->line_start);
    325         zend_error(E_ERROR, "Cannot redeclare class %s", (char *) cep->name);
     346#ifdef IS_UNICODE
     347        zend_error(E_ERROR, "Cannot redeclare class %R", type, cep->name);
     348#else
     349        zend_error(E_ERROR, "Cannot redeclare class %s", cep->name);
     350#endif
    326351    }
    327352    ZESW(return (xc_cest_t *) stored_ce_ptr, NOTHING);
     
    338363static void xc_constant_copy_ctor(zend_constant *c) /* {{{ */
    339364{
    340     c->name = zend_strndup(c->name, c->name_len - 1);
     365#ifdef IS_UNICODE
     366    if (UG(unicode)) {
     367        ZSTR_U(c->name) = zend_ustrndup(ZSTR_U(c->name), c->name_len - 1);
     368    }
     369    else
     370#endif
     371    {
     372        ZSTR_S(c->name) = zend_strndup(ZSTR_S(c->name), c->name_len - 1);
     373    }
    341374    if (!(c->flags & CONST_PERSISTENT)) {
    342375        zval_copy_ctor(&c->value);
     
    401434        zend_constant *c = (zend_constant*) b->pData;
    402435        xc_install_constant(sandbox->filename, c,
    403                 BUCKET_KEY_TYPE(b), BUCKET_KEY(b), b->nKeyLength TSRMLS_CC);
     436                BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY(b)), b->nKeyLength TSRMLS_CC);
    404437        b = b->pListNext;
    405438    }
     
    411444        zend_function *func = (zend_function*) b->pData;
    412445        xc_install_function(sandbox->filename, func,
    413                 BUCKET_KEY_TYPE(b), BUCKET_KEY(b), b->nKeyLength TSRMLS_CC);
     446                BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY(b)), b->nKeyLength TSRMLS_CC);
    414447        b = b->pListNext;
    415448    }
     
    419452    while (b != NULL) {
    420453        xc_install_class(sandbox->filename, (xc_cest_t*)b->pData,
    421                 BUCKET_KEY_TYPE(b), BUCKET_KEY(b), b->nKeyLength TSRMLS_CC);
     454                BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY(b)), b->nKeyLength TSRMLS_CC);
    422455        b = b->pListNext;
    423456    }
Note: See TracChangeset for help on using the changeset viewer.