Changeset 103 for trunk/utils.c
- Timestamp:
- 08/27/2006 07:09:02 AM (7 years ago)
- Files:
-
- 1 modified
-
trunk/utils.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/utils.c
r95 r103 266 266 267 267 #ifdef HAVE_XCACHE_CONSTANT 268 void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, void *key, uint len TSRMLS_DC) /* {{{ */268 void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, zstr key, uint len TSRMLS_DC) /* {{{ */ 269 269 { 270 270 if (zend_u_hash_add(EG(zend_constants), type, key, len, … … 275 275 CG(compiled_filename) = filename; 276 276 CG(zend_lineno) = 0; 277 #ifdef IS_UNICODE 278 zend_error(E_NOTICE, "Constant %R already defined", type, key); 279 #else 277 280 zend_error(E_NOTICE, "Constant %s already defined", key); 278 free(constant->name); 281 #endif 282 free(ZSTR_V(constant->name)); 279 283 if (!(constant->flags & CONST_PERSISTENT)) { 280 284 zval_dtor(&constant->value); … … 284 288 /* }}} */ 285 289 #endif 286 void xc_install_function(char *filename, zend_function *func, zend_uchar type, void *key, uint len TSRMLS_DC) /* {{{ */ 287 { 290 void xc_install_function(char *filename, zend_function *func, zend_uchar type, zstr key, uint len TSRMLS_DC) /* {{{ */ 291 { 292 zend_bool istmpkey; 293 288 294 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) { 290 301 zend_u_hash_update(CG(function_table), type, key, len, 291 302 func, sizeof(zend_op_array), … … 300 311 CG(compiled_filename) = filename; 301 312 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 302 316 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 /* }}} */ 322 ZESW(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; 309 325 zend_class_entry *cep = CestToCePtr(*cest); 310 326 ZESW(void *stored_ce_ptr, NOTHING); 311 327 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) { 313 334 zend_u_hash_update(CG(class_table), type, key, len, 314 335 cest, sizeof(xc_cest_t), … … 323 344 CG(compiled_filename) = filename; 324 345 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 326 351 } 327 352 ZESW(return (xc_cest_t *) stored_ce_ptr, NOTHING); … … 338 363 static void xc_constant_copy_ctor(zend_constant *c) /* {{{ */ 339 364 { 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 } 341 374 if (!(c->flags & CONST_PERSISTENT)) { 342 375 zval_copy_ctor(&c->value); … … 401 434 zend_constant *c = (zend_constant*) b->pData; 402 435 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); 404 437 b = b->pListNext; 405 438 } … … 411 444 zend_function *func = (zend_function*) b->pData; 412 445 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); 414 447 b = b->pListNext; 415 448 } … … 419 452 while (b != NULL) { 420 453 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); 422 455 b = b->pListNext; 423 456 }

