cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_globals.h zend_language_scanner.h zend_language_scanner.l zend_opcode.c zend_vm_def.h
zend_vm_execute.h zend_vm_opcodes.h
| From: | Andrei Zmievski | Date: | Wed, 24 Aug 2005 20:42:12 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_globals.h zend_language_scanner.h zend_language_scanner.l zend_opcode.c zend_vm_def.h zend_vm_execute.h zend_vm_opcodes.h |
||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4071@lists.php.net to get a copy of this message | ||
andrei Wed Aug 24 16:42:12 2005 EDT
Modified files:
/ZendEngine2 zend_compile.c zend_compile.h zend_globals.h
zend_language_scanner.h zend_language_scanner.l
zend_opcode.c zend_vm_def.h zend_vm_execute.h
zend_vm_opcodes.h
Log:
- Require declare(encoding=...) to come before any opcodes. Read source
comments for more info.
- Op arrays now know which script encoding they were compiled from.
- Use this information to intelligently convert inline HTML blocks to
the output encoding. Currently it opens and closes a new converter for
each block, but we can optimize it.
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.657&r2=1.658&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.657 ZendEngine2/zend_compile.c:1.658 --- ZendEngine2/zend_compile.c:1.657 Fri Aug 19 09:20:14 2005 +++ ZendEngine2/zend_compile.c Wed Aug 24 16:42:05 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.657 2005/08/19 13:20:14 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.658 2005/08/24 20:42:05 andrei Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -156,6 +156,7 @@ zend_init_compiler_data_structures(TSRMLS_C); zend_init_rsrc_list(TSRMLS_C); zend_hash_init(&CG(filenames_table), 5, NULL, (dtor_func_t) free_estring, 0); + zend_hash_init(&CG(script_encodings_table), 5, NULL, (dtor_func_t) free_estring, 0); zend_llist_init(&CG(open_files), sizeof(zend_file_handle), (void (*)(void *)) zend_file_handle_dtor, 0); CG(unclean_shutdown) = 0; } @@ -170,6 +171,7 @@ zend_stack_destroy(&CG(object_stack)); zend_stack_destroy(&CG(declare_stack)); zend_stack_destroy(&CG(list_stack)); + zend_hash_destroy(&CG(script_encodings_table)); zend_hash_destroy(&CG(filenames_table)); zend_llist_destroy(&CG(open_files)); } @@ -215,6 +217,34 @@ } +ZEND_API char *zend_set_compiled_script_encoding(char *new_script_enc TSRMLS_DC) +{ + char **pp, *p; + int length = strlen(new_script_enc); + + if (zend_hash_find(&CG(script_encodings_table), new_script_enc, length+1, (void **) &pp) == SUCCESS) { + CG(script_encoding) = *pp; + return *pp; + } + p = estrndup(new_script_enc, length); + zend_hash_update(&CG(script_encodings_table), new_script_enc, length+1, &p, sizeof(char *), (void **) &pp); + CG(script_encoding) = p; + return p; +} + + +ZEND_API void zend_restore_compiled_script_encoding(char *original_script_enc TSRMLS_DC) +{ + CG(script_encoding) = original_script_enc; +} + + +ZEND_API char *zend_get_compiled_script_encoding(TSRMLS_D) +{ + return CG(script_encoding); +} + + static zend_uint get_temporary_variable(zend_op_array *op_array) { return (op_array->T)++ * sizeof(temp_variable); @@ -3764,14 +3794,30 @@ convert_to_long(&val->u.constant); CG(declarables).ticks = val->u.constant; } else if (UG(unicode) && ZEND_U_EQUAL(Z_TYPE(var->u.constant), Z_UNIVAL(var->u.constant), Z_UNILEN(var->u.constant), "encoding", sizeof("encoding")-1)) { + UErrorCode status = U_ZERO_ERROR; if (val->u.constant.type == IS_CONSTANT) { zend_error(E_COMPILE_ERROR, "Cannot use constants as encoding"); } + /* + * Check that the pragma comes before any opcodes. If the compilation + * got as far as this, the previous portion of the script must have been + * parseable according to the .ini script_encoding setting. We still + * want to tell them to put declare() at the top. + */ + if (CG(active_op_array)->last > 0) { + zend_error(E_COMPILE_ERROR, "Encoding declaration pragma has to be the very first statement in the script"); + } convert_to_string(&val->u.constant); if (zend_prepare_scanner_converters(Z_STRVAL(val->u.constant), 1 TSRMLS_CC) == FAILURE) { zend_error(E_COMPILE_WARNING, "Unsupported encoding [%s]", Z_STRVAL(val->u.constant)); } + zend_set_compiled_script_encoding((char*)ucnv_getName(LANG_SCNG(output_conv), &status) TSRMLS_CC); + /* + * Because we require declare(encoding=...) to be the very first thing, + * we can safely cache the script encoding in the op array here. + */ + CG(active_op_array)->script_encoding = zend_get_compiled_script_encoding(TSRMLS_C); efree(val->u.constant.value.str.val); } zval_dtor(&var->u.constant); http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.320&r2=1.321&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.320 ZendEngine2/zend_compile.h:1.321 --- ZendEngine2/zend_compile.h:1.320 Fri Aug 19 04:11:16 2005 +++ ZendEngine2/zend_compile.h Wed Aug 24 16:42:06 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.320 2005/08/19 08:11:16 dmitry Exp $ */ +/* $Id: zend_compile.h,v 1.321 2005/08/24 20:42:06 andrei Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -209,6 +209,7 @@ zend_bool uses_this; char *filename; + char *script_encoding; zend_uint line_start; zend_uint line_end; char *doc_comment; @@ -329,6 +330,9 @@ ZEND_API char *zend_get_compiled_filename(TSRMLS_D); ZEND_API int zend_get_compiled_lineno(TSRMLS_D); ZEND_API int zend_get_scanned_file_offset(TSRMLS_D); +ZEND_API char *zend_set_compiled_script_encoding(char *new_script_enc TSRMLS_DC); +ZEND_API void zend_restore_compiled_script_encoding(char *original_script_enc TSRMLS_DC); +ZEND_API char *zend_get_compiled_script_encoding(TSRMLS_D); ZEND_API char* zend_get_compiled_variable_name(zend_op_array *op_array, zend_uint var, int* name_len); http://cvs.php.net/diff.php/ZendEngine2/zend_globals.h?r1=1.142&r2=1.143&ty=u Index: ZendEngine2/zend_globals.h diff -u ZendEngine2/zend_globals.h:1.142 ZendEngine2/zend_globals.h:1.143 --- ZendEngine2/zend_globals.h:1.142 Thu Aug 11 19:34:57 2005 +++ ZendEngine2/zend_globals.h Wed Aug 24 16:42:07 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_globals.h,v 1.142 2005/08/11 23:34:57 andrei Exp $ */ +/* $Id: zend_globals.h,v 1.143 2005/08/24 20:42:07 andrei Exp $ */ #ifndef ZEND_GLOBALS_H #define ZEND_GLOBALS_H @@ -133,6 +133,9 @@ zend_uchar literal_type; + HashTable script_encodings_table; + char *script_encoding; + #ifdef ZTS HashTable *global_function_table; HashTable *global_class_table; http://cvs.php.net/diff.php/ZendEngine2/zend_language_scanner.h?r1=1.20&r2=1.21&ty=u Index: ZendEngine2/zend_language_scanner.h diff -u ZendEngine2/zend_language_scanner.h:1.20 ZendEngine2/zend_language_scanner.h:1.21 --- ZendEngine2/zend_language_scanner.h:1.20 Thu Aug 11 19:34:57 2005 +++ ZendEngine2/zend_language_scanner.h Wed Aug 24 16:42:07 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_language_scanner.h,v 1.20 2005/08/11 23:34:57 andrei Exp $ */ +/* $Id: zend_language_scanner.h,v 1.21 2005/08/24 20:42:07 andrei Exp $ */ #ifndef ZEND_SCANNER_H #define ZEND_SCANNER_H @@ -28,6 +28,7 @@ zend_file_handle *in; uint lineno; char *filename; + char *script_encoding; UConverter *input_conv; /* converter for flex input */ UConverter *output_conv; /* converter for data from flex output */ http://cvs.php.net/diff.php/ZendEngine2/zend_language_scanner.l?r1=1.133&r2=1.134&ty=u Index: ZendEngine2/zend_language_scanner.l diff -u ZendEngine2/zend_language_scanner.l:1.133 ZendEngine2/zend_language_scanner.l:1.134 --- ZendEngine2/zend_language_scanner.l:1.133 Fri Aug 19 06:54:24 2005 +++ ZendEngine2/zend_language_scanner.l Wed Aug 24 16:42:07 2005 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_language_scanner.l,v 1.133 2005/08/19 10:54:24 dmitry Exp $ */ +/* $Id: zend_language_scanner.l,v 1.134 2005/08/24 20:42:07 andrei Exp $ */ #define yyleng SCNG(yy_leng) #define yytext SCNG(yy_text) @@ -209,6 +209,7 @@ BEGIN(lex_state->state); CG(zend_lineno) = lex_state->lineno; zend_restore_compiled_filename(lex_state->filename TSRMLS_CC); + zend_restore_compiled_script_encoding(lex_state->script_encoding TSRMLS_CC); if (SCNG(input_conv)) { ucnv_close(SCNG(input_conv)); @@ -758,6 +759,7 @@ } zend_set_compiled_filename(file_path TSRMLS_CC); + zend_set_compiled_script_encoding((char*)ucnv_getName(SCNG(output_conv), &status) TSRMLS_CC); if (CG(start_lineno)) { CG(zend_lineno) = CG(start_lineno); @@ -875,6 +877,7 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC) { const char *encoding; + UErrorCode status = U_ZERO_ERROR; if (Z_TYPE_P(str) == IS_UNICODE) { convert_to_string_with_converter(str, UG(utf8_conv)); @@ -895,6 +898,7 @@ yy_scan_buffer(str->value.str.val, str->value.str.len+2 TSRMLS_CC); zend_set_compiled_filename(filename TSRMLS_CC); + zend_set_compiled_script_encoding((char*)ucnv_getName(SCNG(output_conv), &status) TSRMLS_CC); CG(zend_lineno) = 1; CG(increment_lineno) = 0; return SUCCESS; @@ -1937,7 +1941,7 @@ if (func_name) { len += u_strlen((UChar*)func_name); } else { - func_name = EMPTY_STR; + func_name = (char*)EMPTY_STR; } zendlval->value.str.len = len; Z_USTRVAL_P(zendlval) = eumalloc(len+1); http://cvs.php.net/diff.php/ZendEngine2/zend_opcode.c?r1=1.112&r2=1.113&ty=u Index: ZendEngine2/zend_opcode.c diff -u ZendEngine2/zend_opcode.c:1.112 ZendEngine2/zend_opcode.c:1.113 --- ZendEngine2/zend_opcode.c:1.112 Fri Aug 12 21:31:14 2005 +++ ZendEngine2/zend_opcode.c Wed Aug 24 16:42:07 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_opcode.c,v 1.112 2005/08/13 01:31:14 helly Exp $ */ +/* $Id: zend_opcode.c,v 1.113 2005/08/24 20:42:07 andrei Exp $ */ #include <stdio.h> @@ -77,6 +77,7 @@ op_array->function_name = NULL; op_array->filename = zend_get_compiled_filename(TSRMLS_C); + op_array->script_encoding = zend_get_compiled_script_encoding(TSRMLS_C); op_array->doc_comment = NULL; op_array->doc_comment_len = 0; http://cvs.php.net/diff.php/ZendEngine2/zend_vm_def.h?r1=1.69&r2=1.70&ty=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.69 ZendEngine2/zend_vm_def.h:1.70 --- ZendEngine2/zend_vm_def.h:1.69 Wed Aug 24 06:41:50 2005 +++ ZendEngine2/zend_vm_def.h Wed Aug 24 16:42:08 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.69 2005/08/24 10:41:50 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.70 2005/08/24 20:42:08 andrei Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -894,9 +894,13 @@ /* Convert inline HTML blocks to the output encoding, but only if necessary. */ if (opline->extended_value && strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - ucnv_getName(ZEND_U_CONVERTER(UG(script_encoding_conv)), &status))) { + EG(active_op_array)->script_encoding)) { zval z_conv; - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_U_CONVERTER(UG(script_encoding_conv)), &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); z_conv.type = IS_BINARY; if (U_SUCCESS(status)) { zend_print_variable(&z_conv); @@ -904,6 +908,7 @@ zend_error(E_WARNING, "Could not convert inline HTML for output"); } zval_dtor(&z_conv); + ucnv_close(script_enc_conv); } else { zend_print_variable(z); } http://cvs.php.net/diff.php/ZendEngine2/zend_vm_execute.h?r1=1.72&r2=1.73&ty=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.72 ZendEngine2/zend_vm_execute.h:1.73 --- ZendEngine2/zend_vm_execute.h:1.72 Wed Aug 24 06:41:51 2005 +++ ZendEngine2/zend_vm_execute.h Wed Aug 24 16:42:08 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_execute.h,v 1.72 2005/08/24 10:41:51 dmitry Exp $ */ +/* $Id: zend_vm_execute.h,v 1.73 2005/08/24 20:42:08 andrei Exp $ */ static opcode_handler_t zend_user_opcode_handlers[256] = {(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL}; @@ -1357,9 +1357,14 @@ /* Convert inline HTML blocks to the output encoding, but only if necessary. */ if (opline->extended_value && strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - ucnv_getName(ZEND_U_CONVERTER(UG(script_encoding_conv)), &status))) { + EG(active_op_array)->script_encoding)) { zval z_conv; - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_U_CONVERTER(UG(script_encoding_conv)), &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + printf("converting %d bytes of T_INLINE_HTML\n", z->value.str.len); + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); z_conv.type = IS_BINARY; if (U_SUCCESS(status)) { zend_print_variable(&z_conv); @@ -1367,6 +1372,7 @@ zend_error(E_WARNING, "Could not convert inline HTML for output"); } zval_dtor(&z_conv); + ucnv_close(script_enc_conv); } else { zend_print_variable(z); } @@ -3864,9 +3870,14 @@ /* Convert inline HTML blocks to the output encoding, but only if necessary. */ if (opline->extended_value && strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - ucnv_getName(ZEND_U_CONVERTER(UG(script_encoding_conv)), &status))) { + EG(active_op_array)->script_encoding)) { zval z_conv; - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_U_CONVERTER(UG(script_encoding_conv)), &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + printf("converting %d bytes of T_INLINE_HTML\n", z->value.str.len); + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); z_conv.type = IS_BINARY; if (U_SUCCESS(status)) { zend_print_variable(&z_conv); @@ -3874,6 +3885,7 @@ zend_error(E_WARNING, "Could not convert inline HTML for output"); } zval_dtor(&z_conv); + ucnv_close(script_enc_conv); } else { zend_print_variable(z); } @@ -6907,9 +6919,14 @@ /* Convert inline HTML blocks to the output encoding, but only if necessary. */ if (opline->extended_value && strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - ucnv_getName(ZEND_U_CONVERTER(UG(script_encoding_conv)), &status))) { + EG(active_op_array)->script_encoding)) { zval z_conv; - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_U_CONVERTER(UG(script_encoding_conv)), &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + printf("converting %d bytes of T_INLINE_HTML\n", z->value.str.len); + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); z_conv.type = IS_BINARY; if (U_SUCCESS(status)) { zend_print_variable(&z_conv); @@ -6917,6 +6934,7 @@ zend_error(E_WARNING, "Could not convert inline HTML for output"); } zval_dtor(&z_conv); + ucnv_close(script_enc_conv); } else { zend_print_variable(z); } @@ -19602,9 +19620,14 @@ /* Convert inline HTML blocks to the output encoding, but only if necessary. */ if (opline->extended_value && strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - ucnv_getName(ZEND_U_CONVERTER(UG(script_encoding_conv)), &status))) { + EG(active_op_array)->script_encoding)) { zval z_conv; - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_U_CONVERTER(UG(script_encoding_conv)), &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + printf("converting %d bytes of T_INLINE_HTML\n", z->value.str.len); + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); z_conv.type = IS_BINARY; if (U_SUCCESS(status)) { zend_print_variable(&z_conv); @@ -19612,6 +19635,7 @@ zend_error(E_WARNING, "Could not convert inline HTML for output"); } zval_dtor(&z_conv); + ucnv_close(script_enc_conv); } else { zend_print_variable(z); } http://cvs.php.net/diff.php/ZendEngine2/zend_vm_opcodes.h?r1=1.50&r2=1.51&ty=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.50 ZendEngine2/zend_vm_opcodes.h:1.51 --- ZendEngine2/zend_vm_opcodes.h:1.50 Wed Aug 24 06:41:51 2005 +++ ZendEngine2/zend_vm_opcodes.h Wed Aug 24 16:42:09 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_opcodes.h,v 1.50 2005/08/24 10:41:51 dmitry Exp $ */ +/* $Id: zend_vm_opcodes.h,v 1.51 2005/08/24 20:42:09 andrei Exp $ */ #define ZEND_NOP 0 #define ZEND_ADD 1
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.657&r2=1.658&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.657 ZendEngine2/zend_compile.c:1.658 --- ZendEngine2/zend_compile.c:1.657 Fri Aug 19 09:20:14 2005 +++ ZendEngine2/zend_compile.c Wed Aug 24 16:42:05 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.657 2005/08/19 13:20:14 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.658 2005/08/24 20:42:05 andrei Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -156,6 +156,7 @@ zend_init_compiler_data_structures(TSRMLS_C); zend_init_rsrc_list(TSRMLS_C); zend_hash_init(&CG(filenames_table), 5, NULL, (dtor_func_t) free_estring, 0); + zend_hash_init(&CG(script_encodings_table), 5, NULL, (dtor_func_t) free_estring, 0); zend_llist_init(&CG(open_files), sizeof(zend_file_handle), (void (*)(void *)) zend_file_handle_dtor, 0); CG(unclean_shutdown) = 0; } @@ -170,6 +171,7 @@ zend_stack_destroy(&CG(object_stack)); zend_stack_destroy(&CG(declare_stack)); zend_stack_destroy(&CG(list_stack)); + zend_hash_destroy(&CG(script_encodings_table)); zend_hash_destroy(&CG(filenames_table)); zend_llist_destroy(&CG(open_files)); } @@ -215,6 +217,34 @@ } +ZEND_API char *zend_set_compiled_script_encoding(char *new_script_enc TSRMLS_DC) +{ + char **pp, *p; + int length = strlen(new_script_enc); + + if (zend_hash_find(&CG(script_encodings_table), new_script_enc, length+1, (void **) &pp) == SUCCESS) { + CG(script_encoding) = *pp; + return *pp; + } + p = estrndup(new_script_enc, length); + zend_hash_update(&CG(script_encodings_table), new_script_enc, length+1, &p, sizeof(char *), (void **) &pp); + CG(script_encoding) = p; + return p; +} + + +ZEND_API void zend_restore_compiled_script_encoding(char *original_script_enc TSRMLS_DC) +{ + CG(script_encoding) = original_script_enc; +} + + +ZEND_API char *zend_get_compiled_script_encoding(TSRMLS_D) +{ + return CG(script_encoding); +} + + static zend_uint get_temporary_variable(zend_op_array *op_array) { return (op_array->T)++ * sizeof(temp_variable); @@ -3764,14 +3794,30 @@ convert_to_long(&val->u.constant); CG(declarables).ticks = val->u.constant; } else if (UG(unicode) && ZEND_U_EQUAL(Z_TYPE(var->u.constant), Z_UNIVAL(var->u.constant), Z_UNILEN(var->u.constant), "encoding", sizeof("encoding")-1)) { + UErrorCode status = U_ZERO_ERROR; if (val->u.constant.type == IS_CONSTANT) { zend_error(E_COMPILE_ERROR, "Cannot use constants as encoding"); } + /* + * Check that the pragma comes before any opcodes. If the compilation + * got as far as this, the previous portion of the script must have been + * parseable according to the .ini script_encoding setting. We still + * want to tell them to put declare() at the top. + */ + if (CG(active_op_array)->last > 0) { + zend_error(E_COMPILE_ERROR, "Encoding declaration pragma has to be the very first statement in the script"); + } convert_to_string(&val->u.constant); if (zend_prepare_scanner_converters(Z_STRVAL(val->u.constant), 1 TSRMLS_CC) == FAILURE) { zend_error(E_COMPILE_WARNING, "Unsupported encoding [%s]", Z_STRVAL(val->u.constant)); } + zend_set_compiled_script_encoding((char*)ucnv_getName(LANG_SCNG(output_conv), &status) TSRMLS_CC); + /* + * Because we require declare(encoding=...) to be the very first thing, + * we can safely cache the script encoding in the op array here. + */ + CG(active_op_array)->script_encoding = zend_get_compiled_script_encoding(TSRMLS_C); efree(val->u.constant.value.str.val); } zval_dtor(&var->u.constant); http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.320&r2=1.321&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.320 ZendEngine2/zend_compile.h:1.321 --- ZendEngine2/zend_compile.h:1.320 Fri Aug 19 04:11:16 2005 +++ ZendEngine2/zend_compile.h Wed Aug 24 16:42:06 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.320 2005/08/19 08:11:16 dmitry Exp $ */ +/* $Id: zend_compile.h,v 1.321 2005/08/24 20:42:06 andrei Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -209,6 +209,7 @@ zend_bool uses_this; char *filename; + char *script_encoding; zend_uint line_start; zend_uint line_end; char *doc_comment; @@ -329,6 +330,9 @@ ZEND_API char *zend_get_compiled_filename(TSRMLS_D); ZEND_API int zend_get_compiled_lineno(TSRMLS_D); ZEND_API int zend_get_scanned_file_offset(TSRMLS_D); +ZEND_API char *zend_set_compiled_script_encoding(char *new_script_enc TSRMLS_DC); +ZEND_API void zend_restore_compiled_script_encoding(char *original_script_enc TSRMLS_DC); +ZEND_API char *zend_get_compiled_script_encoding(TSRMLS_D); ZEND_API char* zend_get_compiled_variable_name(zend_op_array *op_array, zend_uint var, int* name_len); http://cvs.php.net/diff.php/ZendEngine2/zend_globals.h?r1=1.142&r2=1.143&ty=u Index: ZendEngine2/zend_globals.h diff -u ZendEngine2/zend_globals.h:1.142 ZendEngine2/zend_globals.h:1.143 --- ZendEngine2/zend_globals.h:1.142 Thu Aug 11 19:34:57 2005 +++ ZendEngine2/zend_globals.h Wed Aug 24 16:42:07 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_globals.h,v 1.142 2005/08/11 23:34:57 andrei Exp $ */ +/* $Id: zend_globals.h,v 1.143 2005/08/24 20:42:07 andrei Exp $ */ #ifndef ZEND_GLOBALS_H #define ZEND_GLOBALS_H @@ -133,6 +133,9 @@ zend_uchar literal_type; + HashTable script_encodings_table; + char *script_encoding; + #ifdef ZTS HashTable *global_function_table; HashTable *global_class_table; http://cvs.php.net/diff.php/ZendEngine2/zend_language_scanner.h?r1=1.20&r2=1.21&ty=u Index: ZendEngine2/zend_language_scanner.h diff -u ZendEngine2/zend_language_scanner.h:1.20 ZendEngine2/zend_language_scanner.h:1.21 --- ZendEngine2/zend_language_scanner.h:1.20 Thu Aug 11 19:34:57 2005 +++ ZendEngine2/zend_language_scanner.h Wed Aug 24 16:42:07 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_language_scanner.h,v 1.20 2005/08/11 23:34:57 andrei Exp $ */ +/* $Id: zend_language_scanner.h,v 1.21 2005/08/24 20:42:07 andrei Exp $ */ #ifndef ZEND_SCANNER_H #define ZEND_SCANNER_H @@ -28,6 +28,7 @@ zend_file_handle *in; uint lineno; char *filename; + char *script_encoding; UConverter *input_conv; /* converter for flex input */ UConverter *output_conv; /* converter for data from flex output */ http://cvs.php.net/diff.php/ZendEngine2/zend_language_scanner.l?r1=1.133&r2=1.134&ty=u Index: ZendEngine2/zend_language_scanner.l diff -u ZendEngine2/zend_language_scanner.l:1.133 ZendEngine2/zend_language_scanner.l:1.134 --- ZendEngine2/zend_language_scanner.l:1.133 Fri Aug 19 06:54:24 2005 +++ ZendEngine2/zend_language_scanner.l Wed Aug 24 16:42:07 2005 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_language_scanner.l,v 1.133 2005/08/19 10:54:24 dmitry Exp $ */ +/* $Id: zend_language_scanner.l,v 1.134 2005/08/24 20:42:07 andrei Exp $ */ #define yyleng SCNG(yy_leng) #define yytext SCNG(yy_text) @@ -209,6 +209,7 @@ BEGIN(lex_state->state); CG(zend_lineno) = lex_state->lineno; zend_restore_compiled_filename(lex_state->filename TSRMLS_CC); + zend_restore_compiled_script_encoding(lex_state->script_encoding TSRMLS_CC); if (SCNG(input_conv)) { ucnv_close(SCNG(input_conv)); @@ -758,6 +759,7 @@ } zend_set_compiled_filename(file_path TSRMLS_CC); + zend_set_compiled_script_encoding((char*)ucnv_getName(SCNG(output_conv), &status) TSRMLS_CC); if (CG(start_lineno)) { CG(zend_lineno) = CG(start_lineno); @@ -875,6 +877,7 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC) { const char *encoding; + UErrorCode status = U_ZERO_ERROR; if (Z_TYPE_P(str) == IS_UNICODE) { convert_to_string_with_converter(str, UG(utf8_conv)); @@ -895,6 +898,7 @@ yy_scan_buffer(str->value.str.val, str->value.str.len+2 TSRMLS_CC); zend_set_compiled_filename(filename TSRMLS_CC); + zend_set_compiled_script_encoding((char*)ucnv_getName(SCNG(output_conv), &status) TSRMLS_CC); CG(zend_lineno) = 1; CG(increment_lineno) = 0; return SUCCESS; @@ -1937,7 +1941,7 @@ if (func_name) { len += u_strlen((UChar*)func_name); } else { - func_name = EMPTY_STR; + func_name = (char*)EMPTY_STR; } zendlval->value.str.len = len; Z_USTRVAL_P(zendlval) = eumalloc(len+1); http://cvs.php.net/diff.php/ZendEngine2/zend_opcode.c?r1=1.112&r2=1.113&ty=u Index: ZendEngine2/zend_opcode.c diff -u ZendEngine2/zend_opcode.c:1.112 ZendEngine2/zend_opcode.c:1.113 --- ZendEngine2/zend_opcode.c:1.112 Fri Aug 12 21:31:14 2005 +++ ZendEngine2/zend_opcode.c Wed Aug 24 16:42:07 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_opcode.c,v 1.112 2005/08/13 01:31:14 helly Exp $ */ +/* $Id: zend_opcode.c,v 1.113 2005/08/24 20:42:07 andrei Exp $ */ #include <stdio.h> @@ -77,6 +77,7 @@ op_array->function_name = NULL; op_array->filename = zend_get_compiled_filename(TSRMLS_C); + op_array->script_encoding = zend_get_compiled_script_encoding(TSRMLS_C); op_array->doc_comment = NULL; op_array->doc_comment_len = 0; http://cvs.php.net/diff.php/ZendEngine2/zend_vm_def.h?r1=1.69&r2=1.70&ty=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.69 ZendEngine2/zend_vm_def.h:1.70 --- ZendEngine2/zend_vm_def.h:1.69 Wed Aug 24 06:41:50 2005 +++ ZendEngine2/zend_vm_def.h Wed Aug 24 16:42:08 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.69 2005/08/24 10:41:50 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.70 2005/08/24 20:42:08 andrei Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -894,9 +894,13 @@ /* Convert inline HTML blocks to the output encoding, but only if necessary. */ if (opline->extended_value && strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - ucnv_getName(ZEND_U_CONVERTER(UG(script_encoding_conv)), &status))) { + EG(active_op_array)->script_encoding)) { zval z_conv; - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_U_CONVERTER(UG(script_encoding_conv)), &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); z_conv.type = IS_BINARY; if (U_SUCCESS(status)) { zend_print_variable(&z_conv); @@ -904,6 +908,7 @@ zend_error(E_WARNING, "Could not convert inline HTML for output"); } zval_dtor(&z_conv); + ucnv_close(script_enc_conv); } else { zend_print_variable(z); } http://cvs.php.net/diff.php/ZendEngine2/zend_vm_execute.h?r1=1.72&r2=1.73&ty=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.72 ZendEngine2/zend_vm_execute.h:1.73 --- ZendEngine2/zend_vm_execute.h:1.72 Wed Aug 24 06:41:51 2005 +++ ZendEngine2/zend_vm_execute.h Wed Aug 24 16:42:08 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_execute.h,v 1.72 2005/08/24 10:41:51 dmitry Exp $ */ +/* $Id: zend_vm_execute.h,v 1.73 2005/08/24 20:42:08 andrei Exp $ */ static opcode_handler_t zend_user_opcode_handlers[256] = {(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL,(opcode_handler_t)NULL}; @@ -1357,9 +1357,14 @@ /* Convert inline HTML blocks to the output encoding, but only if necessary. */ if (opline->extended_value && strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - ucnv_getName(ZEND_U_CONVERTER(UG(script_encoding_conv)), &status))) { + EG(active_op_array)->script_encoding)) { zval z_conv; - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_U_CONVERTER(UG(script_encoding_conv)), &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + printf("converting %d bytes of T_INLINE_HTML\n", z->value.str.len); + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); z_conv.type = IS_BINARY; if (U_SUCCESS(status)) { zend_print_variable(&z_conv); @@ -1367,6 +1372,7 @@ zend_error(E_WARNING, "Could not convert inline HTML for output"); } zval_dtor(&z_conv); + ucnv_close(script_enc_conv); } else { zend_print_variable(z); } @@ -3864,9 +3870,14 @@ /* Convert inline HTML blocks to the output encoding, but only if necessary. */ if (opline->extended_value && strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - ucnv_getName(ZEND_U_CONVERTER(UG(script_encoding_conv)), &status))) { + EG(active_op_array)->script_encoding)) { zval z_conv; - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_U_CONVERTER(UG(script_encoding_conv)), &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + printf("converting %d bytes of T_INLINE_HTML\n", z->value.str.len); + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); z_conv.type = IS_BINARY; if (U_SUCCESS(status)) { zend_print_variable(&z_conv); @@ -3874,6 +3885,7 @@ zend_error(E_WARNING, "Could not convert inline HTML for output"); } zval_dtor(&z_conv); + ucnv_close(script_enc_conv); } else { zend_print_variable(z); } @@ -6907,9 +6919,14 @@ /* Convert inline HTML blocks to the output encoding, but only if necessary. */ if (opline->extended_value && strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - ucnv_getName(ZEND_U_CONVERTER(UG(script_encoding_conv)), &status))) { + EG(active_op_array)->script_encoding)) { zval z_conv; - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_U_CONVERTER(UG(script_encoding_conv)), &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + printf("converting %d bytes of T_INLINE_HTML\n", z->value.str.len); + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); z_conv.type = IS_BINARY; if (U_SUCCESS(status)) { zend_print_variable(&z_conv); @@ -6917,6 +6934,7 @@ zend_error(E_WARNING, "Could not convert inline HTML for output"); } zval_dtor(&z_conv); + ucnv_close(script_enc_conv); } else { zend_print_variable(z); } @@ -19602,9 +19620,14 @@ /* Convert inline HTML blocks to the output encoding, but only if necessary. */ if (opline->extended_value && strcmp(ucnv_getName(ZEND_U_CONVERTER(UG(output_encoding_conv)), &status), - ucnv_getName(ZEND_U_CONVERTER(UG(script_encoding_conv)), &status))) { + EG(active_op_array)->script_encoding)) { zval z_conv; - zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), ZEND_U_CONVERTER(UG(script_encoding_conv)), &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); + UConverter *script_enc_conv = NULL; + if (zend_set_converter_encoding(&script_enc_conv, EG(active_op_array)->script_encoding) == FAILURE) { + zend_error(E_ERROR, "Unsupported encoding [%d]", EG(active_op_array)->script_encoding); + } + printf("converting %d bytes of T_INLINE_HTML\n", z->value.str.len); + zend_convert_encodings(ZEND_U_CONVERTER(UG(output_encoding_conv)), script_enc_conv, &z_conv.value.str.val, &z_conv.value.str.len, z->value.str.val, z->value.str.len, &status); z_conv.type = IS_BINARY; if (U_SUCCESS(status)) { zend_print_variable(&z_conv); @@ -19612,6 +19635,7 @@ zend_error(E_WARNING, "Could not convert inline HTML for output"); } zval_dtor(&z_conv); + ucnv_close(script_enc_conv); } else { zend_print_variable(z); } http://cvs.php.net/diff.php/ZendEngine2/zend_vm_opcodes.h?r1=1.50&r2=1.51&ty=u Index: ZendEngine2/zend_vm_opcodes.h diff -u ZendEngine2/zend_vm_opcodes.h:1.50 ZendEngine2/zend_vm_opcodes.h:1.51 --- ZendEngine2/zend_vm_opcodes.h:1.50 Wed Aug 24 06:41:51 2005 +++ ZendEngine2/zend_vm_opcodes.h Wed Aug 24 16:42:09 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_opcodes.h,v 1.50 2005/08/24 10:41:51 dmitry Exp $ */ +/* $Id: zend_vm_opcodes.h,v 1.51 2005/08/24 20:42:09 andrei Exp $ */ #define ZEND_NOP 0 #define ZEND_ADD 1