cvs: ZendEngine2 / zend_compile.c
| From: | Dmitry Stogov | Date: | Mon, 27 Mar 2006 09:44:03 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4775@lists.php.net to get a copy of this message | ||
dmitry Mon Mar 27 09:44:03 2006 UTC
Modified files:
/ZendEngine2 zend_compile.c
Log:
Fixed bug during function/class declaration in unicode mode
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_compile.c?r1=1.702&r2=1.703&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.702 ZendEngine2/zend_compile.c:1.703
--- ZendEngine2/zend_compile.c:1.702 Mon Mar 27 08:09:08 2006
+++ ZendEngine2/zend_compile.c Mon Mar 27 09:44:03 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.702 2006/03/27 08:09:08 dmitry Exp $ */
+/* $Id: zend_compile.c,v 1.703 2006/03/27 09:44:03 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -76,11 +76,12 @@
free(property_info->name.v);
}
-static void build_runtime_defined_function_key(zval *result, zend_uchar type, char *name, int
name_length TSRMLS_DC)
+static void build_runtime_defined_function_key(zval *result, zend_uchar type, zstr name, int
name_length TSRMLS_DC)
{
char char_pos_buf[32];
uint char_pos_len;
char *filename;
+ uint filename_length;
char_pos_len = zend_sprintf(char_pos_buf, "%p", LANG_SCNG(_yy_last_accepting_cpos));
if (CG(active_op_array)->filename) {
@@ -90,17 +91,26 @@
}
/* NULL, name length, filename length, last accepting char position length */
+ filename_length = strlen(filename);
+ Z_UNILEN_P(result) = 1+name_length+filename_length+char_pos_len;
if (type == IS_UNICODE) {
- name_length *= sizeof(UChar);
+ Z_USTRVAL_P(result) = (UChar *) eumalloc(Z_STRLEN_P(result)+1);
+ Z_USTRVAL_P(result)[0] = 0;
+ memcpy(Z_USTRVAL_P(result)+1, name.u, UBYTES(name_length));
+
+ /* FIXME: Support for non-ascii filenames */
+ u_charsToUChars(filename, Z_USTRVAL_P(result)+1+name_length, filename_length);
+ u_charsToUChars(char_pos_buf, Z_USTRVAL_P(result)+1+name_length+filename_length, char_pos_len);
+ Z_USTRVAL_P(result)[1+name_length+filename_length+char_pos_len] = 0;
+ Z_TYPE_P(result) = IS_UNICODE;
+ } else {
+ Z_STRVAL_P(result) = (char *) emalloc(Z_STRLEN_P(result)+1);
+ Z_STRVAL_P(result)[0] = '\0';
+ memcpy(Z_STRVAL_P(result)+1, name.s, name_length);
+ memcpy(Z_STRVAL_P(result)+1+name_length, filename, filename_length);
+ memcpy(Z_STRVAL_P(result)+1+name_length+filename_length, char_pos_buf, char_pos_len+1);
+ Z_TYPE_P(result) = IS_STRING;
}
- Z_STRLEN_P(result) = 1+name_length+strlen(filename)+char_pos_len;
- Z_STRVAL_P(result) = (char *) emalloc(Z_STRLEN_P(result)+1);
- /* UTODO: function key should probably store UTF-16 value instead of converting to
- runtime encoding */
- Z_STRVAL_P(result)[0] = '\0';
- memcpy(Z_STRVAL_P(result)+1, name, name_length);
- sprintf(Z_STRVAL_P(result)+1+name_length, "%s%s", filename, char_pos_buf);
- Z_TYPE_P(result) = IS_STRING;
result->refcount = 1;
}
@@ -1198,7 +1208,7 @@
opline->opcode = ZEND_DECLARE_FUNCTION;
opline->op1.op_type = IS_CONST;
- build_runtime_defined_function_key(&opline->op1.u.constant,
Z_TYPE(function_name->u.constant), lcname.s, lcname_len TSRMLS_CC);
+ build_runtime_defined_function_key(&opline->op1.u.constant,
Z_TYPE(function_name->u.constant), lcname, lcname_len TSRMLS_CC);
opline->op2.op_type = IS_CONST;
Z_TYPE(opline->op2.u.constant) = Z_TYPE(function_name->u.constant);
Z_STRVAL(opline->op2.u.constant) = lcname.s;
@@ -2878,7 +2888,7 @@
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->op1.op_type = IS_CONST;
- build_runtime_defined_function_key(&opline->op1.u.constant,
Z_TYPE(class_name->u.constant), lcname.s, lcname_len TSRMLS_CC);
+ build_runtime_defined_function_key(&opline->op1.u.constant,
Z_TYPE(class_name->u.constant), lcname, lcname_len TSRMLS_CC);
opline->op2.op_type = IS_CONST;
Z_TYPE(opline->op2.u.constant) = Z_TYPE(class_name->u.constant);