mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
implemented again zend-multibyte for PHP 5.3
This commit is contained in:
14
Zend/Zend.m4
14
Zend/Zend.m4
@@ -154,6 +154,13 @@ AC_ARG_ENABLE(inline-optimization,
|
||||
ZEND_INLINE_OPTIMIZATION=yes
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(zend-multibyte,
|
||||
[ --enable-zend-multibyte Compile with zend multibyte support], [
|
||||
ZEND_MULTIBYTE=$enableval
|
||||
],[
|
||||
ZEND_MULTIBYTE=no
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([virtual machine dispatch method])
|
||||
AC_MSG_RESULT($PHP_ZEND_VM)
|
||||
|
||||
@@ -166,6 +173,9 @@ AC_MSG_RESULT($ZEND_INLINE_OPTIMIZATION)
|
||||
AC_MSG_CHECKING(whether to enable Zend debugging)
|
||||
AC_MSG_RESULT($ZEND_DEBUG)
|
||||
|
||||
AC_MSG_CHECKING(whether to enable Zend multibyte)
|
||||
AC_MSG_RESULT($ZEND_MULTIBYTE)
|
||||
|
||||
case $PHP_ZEND_VM in
|
||||
SWITCH)
|
||||
AC_DEFINE(ZEND_VM_KIND,ZEND_VM_KIND_SWITCH,[virtual machine dispatch method])
|
||||
@@ -200,6 +210,10 @@ if test "$ZEND_MAINTAINER_ZTS" = "yes"; then
|
||||
LIBZEND_CPLUSPLUS_CHECKS
|
||||
fi
|
||||
|
||||
if test "$ZEND_MULTIBYTE" = "yes"; then
|
||||
AC_DEFINE(ZEND_MULTIBYTE, 1, [ ])
|
||||
fi
|
||||
|
||||
changequote({,})
|
||||
if test -n "$GCC" && test "$ZEND_INLINE_OPTIMIZATION" != "yes"; then
|
||||
INLINE_CFLAGS=`echo $ac_n "$CFLAGS $ac_c" | sed s/-O[0-9s]*//`
|
||||
|
||||
@@ -91,6 +91,9 @@ static ZEND_INI_MH(OnUpdateGCEnabled) /* {{{ */
|
||||
ZEND_INI_BEGIN()
|
||||
ZEND_INI_ENTRY("error_reporting", NULL, ZEND_INI_ALL, OnUpdateErrorReporting)
|
||||
STD_ZEND_INI_BOOLEAN("zend.enable_gc", "1", ZEND_INI_ALL, OnUpdateGCEnabled, gc_enabled, zend_gc_globals, gc_globals)
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
STD_ZEND_INI_BOOLEAN("detect_unicode", "1", ZEND_INI_ALL, OnUpdateBool, detect_unicode, zend_compiler_globals, compiler_globals)
|
||||
#endif
|
||||
ZEND_INI_END()
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
#include "zend_exceptions.h"
|
||||
#include "tsrm_virtual_cwd.h"
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
#include "zend_multibyte.h"
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
|
||||
ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
|
||||
ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename TSRMLS_DC);
|
||||
|
||||
@@ -80,7 +84,14 @@ static void build_runtime_defined_function_key(zval *result, char *name, int nam
|
||||
|
||||
/* NULL, name length, filename length, last accepting char position length */
|
||||
result->value.str.len = 1+name_length+strlen(filename)+char_pos_len;
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
/* must be binary safe */
|
||||
result->value.str.val = (char *) safe_emalloc(result->value.str.len, 1, 1);
|
||||
result->value.str.val[0] = '\0';
|
||||
sprintf(result->value.str.val+1, "%s%s%s", name, filename, char_pos_buf);
|
||||
#else
|
||||
zend_spprintf(&result->value.str.val, 0, "%c%s%s%s", '\0', name, filename, char_pos_buf);
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
result->type = IS_STRING;
|
||||
Z_SET_REFCOUNT_P(result, 1);
|
||||
}
|
||||
@@ -132,6 +143,15 @@ void zend_init_compiler_data_structures(TSRMLS_D)
|
||||
zend_hash_apply(CG(auto_globals), (apply_func_t) zend_auto_global_arm TSRMLS_CC);
|
||||
zend_stack_init(&CG(labels_stack));
|
||||
CG(labels) = NULL;
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
CG(script_encoding_list) = NULL;
|
||||
CG(script_encoding_list_size) = 0;
|
||||
CG(internal_encoding) = NULL;
|
||||
CG(encoding_detector) = NULL;
|
||||
CG(encoding_converter) = NULL;
|
||||
CG(encoding_oddlen) = NULL;
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
}
|
||||
|
||||
|
||||
@@ -166,6 +186,12 @@ void shutdown_compiler(TSRMLS_D)
|
||||
zend_hash_destroy(&CG(filenames_table));
|
||||
zend_llist_destroy(&CG(open_files));
|
||||
zend_stack_destroy(&CG(labels_stack));
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
if (CG(script_encoding_list)) {
|
||||
efree(CG(script_encoding_list));
|
||||
}
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
}
|
||||
|
||||
|
||||
@@ -4512,9 +4538,55 @@ void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC)
|
||||
if (!zend_binary_strcasecmp(var->u.constant.value.str.val, var->u.constant.value.str.len, "ticks", sizeof("ticks")-1)) {
|
||||
convert_to_long(&val->u.constant);
|
||||
CG(declarables).ticks = val->u.constant;
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
} else if (!zend_binary_strcasecmp(var->u.constant.value.str.val, var->u.constant.value.str.len, "encoding", sizeof("encoding")-1)) {
|
||||
zend_encoding *new_encoding, *old_encoding;
|
||||
zend_encoding_filter old_input_filter;
|
||||
|
||||
if (Z_TYPE(val->u.constant) == 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) {
|
||||
/* ignore ZEND_EXT_STMT and ZEND_TICKS */
|
||||
int num = CG(active_op_array)->last;
|
||||
while (num > 0 &&
|
||||
(CG(active_op_array)->opcodes[num-1].opcode == ZEND_EXT_STMT ||
|
||||
CG(active_op_array)->opcodes[num-1].opcode == ZEND_TICKS)) {
|
||||
--num;
|
||||
}
|
||||
if (num > 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);
|
||||
new_encoding = zend_multibyte_fetch_encoding(val->u.constant.value.str.val);
|
||||
if (!new_encoding) {
|
||||
zend_error(E_COMPILE_WARNING, "Unsupported encoding [%s]", val->u.constant.value.str.val);
|
||||
} else {
|
||||
old_input_filter = LANG_SCNG(input_filter);
|
||||
old_encoding = LANG_SCNG(script_encoding);
|
||||
zend_multibyte_set_filter(new_encoding TSRMLS_CC);
|
||||
|
||||
/* need to re-scan if input filter changed */
|
||||
if (old_input_filter != LANG_SCNG(input_filter) ||
|
||||
((old_input_filter == zend_multibyte_script_encoding_filter) &&
|
||||
(new_encoding != old_encoding))) {
|
||||
zend_multibyte_yyinput_again(old_input_filter, old_encoding TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
#else /* !ZEND_MULTIBYTE */
|
||||
} else if (!zend_binary_strcasecmp(var->u.constant.value.str.val, var->u.constant.value.str.len, "encoding", sizeof("encoding")-1)) {
|
||||
/* Do not generate any kind of warning for encoding declares */
|
||||
/* zend_error(E_COMPILE_WARNING, "Declare encoding [%s] not supported", val->u.constant.value.str.val); */
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
efree(val->u.constant.value.str.val);
|
||||
} else {
|
||||
zend_error(E_COMPILE_WARNING, "Unsupported declare '%s'", var->u.constant.value.str.val);
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
#include "zend_objects_API.h"
|
||||
#include "zend_modules.h"
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
#include "zend_multibyte.h"
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
|
||||
/* Define ZTS if you want a thread-safe Zend */
|
||||
/*#undef ZTS*/
|
||||
|
||||
@@ -134,6 +138,19 @@ struct _zend_compiler_globals {
|
||||
HashTable *labels;
|
||||
zend_stack labels_stack;
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
zend_encoding **script_encoding_list;
|
||||
int script_encoding_list_size;
|
||||
zend_bool detect_unicode;
|
||||
|
||||
zend_encoding *internal_encoding;
|
||||
|
||||
/* multibyte utility functions */
|
||||
zend_encoding_detector encoding_detector;
|
||||
zend_encoding_converter encoding_converter;
|
||||
zend_encoding_oddlen encoding_oddlen;
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
|
||||
#ifdef ZTS
|
||||
HashTable **static_members;
|
||||
int last_static_member;
|
||||
@@ -271,6 +288,22 @@ struct _zend_php_scanner_globals {
|
||||
zend_stack state_stack;
|
||||
|
||||
zend_llist used_state_stacks;
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
/* original (unfiltered) script */
|
||||
char *script_org;
|
||||
int script_org_size;
|
||||
|
||||
/* filtered script */
|
||||
char *script_filtered;
|
||||
int script_filtered_size;
|
||||
|
||||
/* input/ouput filters */
|
||||
zend_encoding_filter input_filter;
|
||||
zend_encoding_filter output_filter;
|
||||
zend_encoding *script_encoding;
|
||||
zend_encoding *internal_encoding;
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
};
|
||||
|
||||
#endif /* ZEND_GLOBALS_H */
|
||||
|
||||
@@ -58,6 +58,17 @@ ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC)
|
||||
{
|
||||
const char *ptr=s, *end=s+len;
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
char *filtered;
|
||||
int filtered_len;
|
||||
|
||||
if (LANG_SCNG(output_filter)) {
|
||||
LANG_SCNG(output_filter)(&filtered, &filtered_len, s, len TSRMLS_CC);
|
||||
ptr = filtered;
|
||||
end = filtered + filtered_len;
|
||||
}
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
|
||||
while (ptr<end) {
|
||||
if (*ptr==' ') {
|
||||
do {
|
||||
@@ -67,6 +78,12 @@ ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC)
|
||||
zend_html_putc(*ptr++);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
if (LANG_SCNG(output_filter)) {
|
||||
efree(filtered);
|
||||
}
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,6 +35,22 @@ typedef struct _zend_lex_state {
|
||||
zend_file_handle *in;
|
||||
uint lineno;
|
||||
char *filename;
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
/* original (unfiltered) script */
|
||||
char *script_org;
|
||||
int script_org_size;
|
||||
|
||||
/* filtered script */
|
||||
char *script_filtered;
|
||||
int script_filtered_size;
|
||||
|
||||
/* input/ouput filters */
|
||||
zend_encoding_filter input_filter;
|
||||
zend_encoding_filter output_filter;
|
||||
zend_encoding *script_encoding;
|
||||
zend_encoding *internal_encoding;
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
} zend_lex_state;
|
||||
|
||||
|
||||
|
||||
@@ -180,6 +180,17 @@ ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
|
||||
lex_state->yy_state = YYSTATE;
|
||||
lex_state->filename = zend_get_compiled_filename(TSRMLS_C);
|
||||
lex_state->lineno = CG(zend_lineno);
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
lex_state->script_org = SCNG(script_org);
|
||||
lex_state->script_org_size = SCNG(script_org_size);
|
||||
lex_state->script_filtered = SCNG(script_filtered);
|
||||
lex_state->script_filtered_size = SCNG(script_filtered_size);
|
||||
lex_state->input_filter = SCNG(input_filter);
|
||||
lex_state->output_filter = SCNG(output_filter);
|
||||
lex_state->script_encoding = SCNG(script_encoding);
|
||||
lex_state->internal_encoding = SCNG(internal_encoding);
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
}
|
||||
|
||||
ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
|
||||
@@ -198,6 +209,24 @@ ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state TSRMLS_DC)
|
||||
YYSETCONDITION(lex_state->yy_state);
|
||||
CG(zend_lineno) = lex_state->lineno;
|
||||
zend_restore_compiled_filename(lex_state->filename TSRMLS_CC);
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
if (SCNG(script_org)) {
|
||||
efree(SCNG(script_org));
|
||||
SCNG(script_org) = NULL;
|
||||
}
|
||||
if (SCNG(script_filtered)) {
|
||||
efree(SCNG(script_filtered));
|
||||
SCNG(script_filtered) = NULL;
|
||||
}
|
||||
SCNG(script_org) = lex_state->script_org;
|
||||
SCNG(script_org_size) = lex_state->script_org_size;
|
||||
SCNG(script_filtered) = lex_state->script_filtered;
|
||||
SCNG(script_filtered_size) = lex_state->script_filtered_size;
|
||||
SCNG(input_filter) = lex_state->input_filter;
|
||||
SCNG(output_filter) = lex_state->output_filter;
|
||||
SCNG(script_encoding) = lex_state->script_encoding;
|
||||
SCNG(internal_encoding) = lex_state->internal_encoding;
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
}
|
||||
|
||||
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC)
|
||||
@@ -232,8 +261,27 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
|
||||
SCNG(yy_in) = file_handle;
|
||||
|
||||
if (size != -1) {
|
||||
/* TODO: For MULTIBYTE we need to do some clever re-encoding */
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
if (zend_multibyte_read_script(buf, size TSRMLS_CC) != 0) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
SCNG(yy_in) = NULL;
|
||||
|
||||
zend_multibyte_set_filter(NULL TSRMLS_CC);
|
||||
|
||||
if (!SCNG(input_filter)) {
|
||||
SCNG(script_filtered) = (char*)emalloc(SCNG(script_org_size)+1);
|
||||
memcpy(SCNG(script_filtered), SCNG(script_org), SCNG(script_org_size)+1);
|
||||
SCNG(script_filtered_size) = SCNG(script_org_size);
|
||||
} else {
|
||||
SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC);
|
||||
}
|
||||
|
||||
yy_scan_buffer(SCNG(script_filtered), SCNG(script_filtered_size) TSRMLS_CC);
|
||||
#else /* !ZEND_MULTIBYTE */
|
||||
yy_scan_buffer(buf, size TSRMLS_CC);
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
} else {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed");
|
||||
}
|
||||
@@ -370,8 +418,24 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_D
|
||||
|
||||
SCNG(yy_in)=NULL;
|
||||
|
||||
/* TODO: For MULTIBYTE we need to do some clever re-encoding */
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
SCNG(script_org) = estrdup(str->value.str.val);
|
||||
SCNG(script_org_size) = str->value.str.len;
|
||||
|
||||
zend_multibyte_set_filter(CG(internal_encoding) TSRMLS_CC);
|
||||
|
||||
if (!SCNG(input_filter)) {
|
||||
SCNG(script_filtered) = (char*)emalloc(SCNG(script_org_size)+1);
|
||||
memcpy(SCNG(script_filtered), SCNG(script_org), SCNG(script_org_size)+1);
|
||||
SCNG(script_filtered_size) = SCNG(script_org_size);
|
||||
} else {
|
||||
SCNG(input_filter)(&SCNG(script_filtered), &SCNG(script_filtered_size), SCNG(script_org), SCNG(script_org_size) TSRMLS_CC);
|
||||
}
|
||||
|
||||
yy_scan_buffer(SCNG(script_filtered), SCNG(script_filtered_size) TSRMLS_CC);
|
||||
#else /* !ZEND_MULTIBYTE */
|
||||
yy_scan_buffer(str->value.str.val, str->value.str.len TSRMLS_CC);
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
|
||||
zend_set_compiled_filename(filename TSRMLS_CC);
|
||||
CG(zend_lineno) = 1;
|
||||
@@ -422,6 +486,17 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
|
||||
BEGIN(ST_IN_SCRIPTING);
|
||||
compiler_result = zendparse(TSRMLS_C);
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
if (SCNG(script_org)) {
|
||||
efree(SCNG(script_org));
|
||||
SCNG(script_org) = NULL;
|
||||
}
|
||||
if (SCNG(script_filtered)) {
|
||||
efree(SCNG(script_filtered));
|
||||
SCNG(script_filtered) = NULL;
|
||||
}
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
|
||||
if (compiler_result==1) {
|
||||
CG(active_op_array) = original_active_op_array;
|
||||
CG(unclean_shutdown)=1;
|
||||
@@ -457,6 +532,16 @@ int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlight
|
||||
return FAILURE;
|
||||
}
|
||||
zend_highlight(syntax_highlighter_ini TSRMLS_CC);
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
if (SCNG(script_org)) {
|
||||
efree(SCNG(script_org));
|
||||
SCNG(script_org) = NULL;
|
||||
}
|
||||
if (SCNG(script_filtered)) {
|
||||
efree(SCNG(script_filtered));
|
||||
SCNG(script_filtered) = NULL;
|
||||
}
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
zend_destroy_file_handle(&file_handle TSRMLS_CC);
|
||||
zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
@@ -475,15 +560,147 @@ int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_
|
||||
}
|
||||
BEGIN(INITIAL);
|
||||
zend_highlight(syntax_highlighter_ini TSRMLS_CC);
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
if (SCNG(script_org)) {
|
||||
efree(SCNG(script_org));
|
||||
SCNG(script_org) = NULL;
|
||||
}
|
||||
if (SCNG(script_filtered)) {
|
||||
efree(SCNG(script_filtered));
|
||||
SCNG(script_filtered) = NULL;
|
||||
}
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
|
||||
zval_dtor(str);
|
||||
return SUCCESS;
|
||||
}
|
||||
END_EXTERN_C()
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, zend_encoding *old_encoding TSRMLS_DC)
|
||||
{
|
||||
int offset, original_offset, length, free_flag, new_len;
|
||||
char *p;
|
||||
zend_encoding *new_encoding;
|
||||
unsigned char *yy_c_buf_p;
|
||||
|
||||
/* calculate current position */
|
||||
offset = original_offset = YYCURSOR - SCNG(yy_start);
|
||||
if (old_input_filter && original_offset > 0) {
|
||||
new_encoding = SCNG(script_encoding);
|
||||
SCNG(script_encoding) = old_encoding;
|
||||
do {
|
||||
(old_input_filter)(&p, &length, SCNG(script_org), offset TSRMLS_CC);
|
||||
if (!p) {
|
||||
SCNG(script_encoding) = new_encoding;
|
||||
return;
|
||||
}
|
||||
efree(p);
|
||||
if (length > original_offset) {
|
||||
offset--;
|
||||
} else if (length < original_offset) {
|
||||
offset++;
|
||||
}
|
||||
} while (original_offset != length);
|
||||
SCNG(script_encoding) = new_encoding;
|
||||
}
|
||||
|
||||
/* convert and set */
|
||||
if (!SCNG(input_filter)) {
|
||||
length = SCNG(script_org_size)-offset-1;
|
||||
p = SCNG(script_org)+offset+1;
|
||||
free_flag = 0;
|
||||
} else {
|
||||
SCNG(input_filter)(&p, &length, SCNG(script_org)+offset+1, SCNG(script_org_size)-offset-1 TSRMLS_CC);
|
||||
free_flag = 1;
|
||||
}
|
||||
|
||||
new_len = original_offset+length+1;
|
||||
|
||||
if (new_len > YYLIMIT-SCNG(yy_start)) {
|
||||
YYLIMIT = SCNG(yy_start) + new_len;
|
||||
SCNG(yy_start) = erealloc(SCNG(yy_start), new_len);
|
||||
SCNG(script_filtered) = SCNG(yy_start);
|
||||
SCNG(script_filtered_size) = new_len;
|
||||
}
|
||||
|
||||
yy_c_buf_p = SCNG(yy_start) + original_offset;
|
||||
strncpy(yy_c_buf_p+1, p, length);
|
||||
|
||||
if (free_flag) {
|
||||
efree(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_multibyte_yyinput(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC)
|
||||
{
|
||||
int c = '*', n;
|
||||
|
||||
if (CG(interactive) == 0) {
|
||||
if (zend_stream_fixup(file_handle, &buf, &len TSRMLS_CC) == FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
n = len;
|
||||
return n;
|
||||
}
|
||||
|
||||
/* interactive */
|
||||
if (SCNG(script_org)) {
|
||||
efree(SCNG(script_org));
|
||||
}
|
||||
if (SCNG(script_filtered)) {
|
||||
efree(SCNG(script_filtered));
|
||||
}
|
||||
SCNG(script_org) = NULL;
|
||||
SCNG(script_org_size) = 0;
|
||||
|
||||
/* TODO: support widechars */
|
||||
if (zend_stream_fixup(file_handle, &buf, &len TSRMLS_CC) == FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
n = len;
|
||||
|
||||
SCNG(script_org_size) = n;
|
||||
SCNG(script_org) = (char*)emalloc(SCNG(script_org_size) + 1);
|
||||
memcpy(SCNG(script_org), buf, n);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_multibyte_read_script(char *buf, int n TSRMLS_DC)
|
||||
{
|
||||
if (SCNG(script_org)) {
|
||||
efree(SCNG(script_org));
|
||||
}
|
||||
if (n<0) {
|
||||
return -1;
|
||||
}
|
||||
SCNG(script_org_size) = n;
|
||||
SCNG(script_org) = (char*)erealloc(SCNG(script_org), SCNG(script_org_size));
|
||||
memcpy(SCNG(script_org) + SCNG(script_org_size) - n, buf, n);
|
||||
|
||||
SCNG(script_org) = (char*)erealloc(SCNG(script_org), SCNG(script_org_size) + 1);
|
||||
*(SCNG(script_org)+SCNG(script_org_size)) = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
# define zend_copy_value(zendlval, yytext, yyleng) \
|
||||
if (SCNG(output_filter)) { \
|
||||
SCNG(output_filter)(&(zendlval->value.str.val), &(zendlval->value.str.len), yytext, yyleng TSRMLS_CC); \
|
||||
} else { \
|
||||
zendlval->value.str.val = (char *) estrndup(yytext, yyleng); \
|
||||
zendlval->value.str.len = yyleng; \
|
||||
}
|
||||
#else /* ZEND_MULTIBYTE */
|
||||
# define zend_copy_value(zendlval, yytext, yyleng) \
|
||||
zendlval->value.str.val = (char *)estrndup(yytext, yyleng); \
|
||||
zendlval->value.str.len = yyleng;
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
|
||||
static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quote_type TSRMLS_DC)
|
||||
{
|
||||
@@ -587,6 +804,13 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
|
||||
s++;
|
||||
}
|
||||
*t = 0;
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
if (SCNG(output_filter)) {
|
||||
s = zendlval->value.str.val;
|
||||
SCNG(output_filter)(&(zendlval->value.str.val), &(zendlval->value.str.len), s, zendlval->value.str.len TSRMLS_CC);
|
||||
efree(s);
|
||||
}
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
}
|
||||
|
||||
|
||||
@@ -1423,8 +1647,21 @@ NOWDOC_CHARS ({NEWLINE}*(([^a-zA-Z_\x7f-\xff\n\r][^\n\r]*)|({LABEL}[^a-zA-Z0-9_
|
||||
|
||||
inline_char_handler:
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
if (SCNG(output_filter)) {
|
||||
int readsize;
|
||||
readsize = SCNG(output_filter)(&(zendlval->value.str.val), &(zendlval->value.str.len), yytext, yyleng TSRMLS_CC);
|
||||
if (readsize < yyleng) {
|
||||
yyless(readsize);
|
||||
}
|
||||
} else {
|
||||
zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
|
||||
zendlval->value.str.len = yyleng;
|
||||
}
|
||||
#else /* !ZEND_MULTIBYTE */
|
||||
zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
|
||||
zendlval->value.str.len = yyleng;
|
||||
zendlval->value.str.len = yyleng;
|
||||
#endif
|
||||
zendlval->type = IS_STRING;
|
||||
HANDLE_NEWLINES(yytext, yyleng);
|
||||
return T_INLINE_HTML;
|
||||
@@ -1637,6 +1874,13 @@ inline_char_handler:
|
||||
}
|
||||
*t = 0;
|
||||
|
||||
#ifdef ZEND_MULTIBYTE
|
||||
if (SCNG(output_filter)) {
|
||||
s = zendlval->value.str.val;
|
||||
SCNG(output_filter)(&(zendlval->value.str.val), &(zendlval->value.str.len), s, zendlval->value.str.len TSRMLS_CC);
|
||||
efree(s);
|
||||
}
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
return T_CONSTANT_ENCAPSED_STRING;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Generated by re2c 0.13.5.dev on Thu Apr 10 20:01:41 2008 */
|
||||
/* Generated by re2c 0.13.5 on Sun Jun 29 17:06:51 2008 */
|
||||
#line 3 "Zend/zend_language_scanner_defs.h"
|
||||
|
||||
enum YYCONDTYPE {
|
||||
|
||||
@@ -62,7 +62,7 @@ ZEND_API int zend_multibyte_internal_encoding_filter(char **to, int *to_length,
|
||||
/* in zend_language_scanner.l */
|
||||
ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, zend_encoding *old_encoding TSRMLS_DC);
|
||||
ZEND_API int zend_multibyte_yyinput(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC);
|
||||
ZEND_API int zend_multibyte_read_script(TSRMLS_D);
|
||||
ZEND_API int zend_multibyte_read_script(char *buf, int n TSRMLS_DC);
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
|
||||
@@ -351,6 +351,12 @@ AC_DEFINE('HAVE_IPV6', main_network_has_ipv6);
|
||||
ARG_ENABLE('fd-setsize', "Set maximum number of sockets for select(2)", "256");
|
||||
ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + parseInt(PHP_FD_SETSIZE));
|
||||
|
||||
ARG_ENABLE("zend-multibyte", "Enable Zend multibyte encoding support", "no");
|
||||
if (PHP_ZEND_MULTIBYTE == "yes") {
|
||||
STDOUT.WriteLine("Enabling Zend multibyte encoding support");
|
||||
AC_DEFINE('ZEND_MULTIBYTE', 1);
|
||||
}
|
||||
|
||||
AC_DEFINE('HAVE_USLEEP', 1);
|
||||
AC_DEFINE('HAVE_STRCOLL', 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user