summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_compile.c20
-rw-r--r--Zend/zend_language_scanner.h2
-rw-r--r--Zend/zend_language_scanner.l4
3 files changed, 16 insertions, 10 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 5f7aa873b5..c3cb01e97f 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -62,29 +62,29 @@ static void zend_destroy_property_info_internal(zend_property_info *property_inf
free(property_info->name);
}
-static void build_runtime_defined_function_key(zval *result, char *name, int name_length, zend_op *opline TSRMLS_DC)
+static void build_runtime_defined_function_key(zval *result, char *name, int name_length TSRMLS_DC)
{
- char lineno_buf[32];
- uint lineno_len;
+ char char_pos_buf[32];
+ uint char_pos_len;
char *filename;
- lineno_len = zend_sprintf(lineno_buf, "%d", opline->lineno);
+ char_pos_len = zend_sprintf(char_pos_buf, "%x", zend_get_last_accepting_character_position());
if (CG(active_op_array)->filename) {
filename = CG(active_op_array)->filename;
} else {
filename = "-";
}
- /* NULL, name length, filename length, line number length */
- result->value.str.len = 1+name_length+strlen(filename)+lineno_len;
+ /* NULL, name length, filename length, last accepting char position length */
+ result->value.str.len = 1+name_length+strlen(filename)+char_pos_len;
result->value.str.val = (char *) emalloc(result->value.str.len+1);
#ifdef ZEND_MULTIBYTE
/* must be binary safe */
result->value.str.val[0] = '\0';
memcpy(result->value.str.val+1, name, name_length);
- sprintf(result->value.str.val+1+name_length, "%s%s", filename, lineno_buf);
+ sprintf(result->value.str.val+1+name_length, "%s%s", filename, char_pos_buf);
#else
- sprintf(result->value.str.val, "%c%s%s%s", '\0', name, filename, lineno_buf);
+ sprintf(result->value.str.val, "%c%s%s%s", '\0', name, filename, char_pos_buf);
#endif /* ZEND_MULTIBYTE */
result->type = IS_STRING;
result->refcount = 1;
@@ -1052,7 +1052,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
opline->opcode = ZEND_DECLARE_FUNCTION;
opline->op1.op_type = IS_CONST;
- build_runtime_defined_function_key(&opline->op1.u.constant, lcname, name_len, opline TSRMLS_CC);
+ build_runtime_defined_function_key(&opline->op1.u.constant, lcname, name_len TSRMLS_CC);
opline->op2.op_type = IS_CONST;
opline->op2.u.constant.type = IS_STRING;
opline->op2.u.constant.value.str.val = lcname;
@@ -2337,7 +2337,7 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znod
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, lcname, new_class_entry->name_length, opline TSRMLS_CC);
+ build_runtime_defined_function_key(&opline->op1.u.constant, lcname, new_class_entry->name_length TSRMLS_CC);
opline->op2.op_type = IS_CONST;
opline->op2.u.constant.type = IS_STRING;
diff --git a/Zend/zend_language_scanner.h b/Zend/zend_language_scanner.h
index f7a8d64dbe..ba95000d3d 100644
--- a/Zend/zend_language_scanner.h
+++ b/Zend/zend_language_scanner.h
@@ -53,6 +53,8 @@ int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2);
ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC);
ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC);
ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC);
+char *zend_get_last_accepting_character_position();
+
END_EXTERN_C()
#endif
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index d7412995f0..e02adb6a3a 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -178,6 +178,10 @@ ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
#endif /* ZEND_MULTIBYTE */
}
+char *zend_get_last_accepting_character_position()
+{
+ return SCNG(_yy_last_accepting_cpos);
+}
ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
{