diff options
| author | Moriyoshi Koizumi <moriyoshi@php.net> | 2008-07-28 07:01:54 +0000 |
|---|---|---|
| committer | Moriyoshi Koizumi <moriyoshi@php.net> | 2008-07-28 07:01:54 +0000 |
| commit | b9eaa80150bc46c021f0fcaae7a347d7521ade4c (patch) | |
| tree | 8cf9975e86eec7b582c51c43b1d0e335e93c5469 | |
| parent | cc8145d14ff74ef89c8895a3f73a7bb14a5d8e9f (diff) | |
| download | php-git-b9eaa80150bc46c021f0fcaae7a347d7521ade4c.tar.gz | |
- SCNG(input_filter) can be null if the script encoding is idential to
the internal encoding.
| -rw-r--r-- | Zend/zend_language_scanner.l | 31 | ||||
| -rw-r--r-- | ext/mbstring/tests/zend_multibyte-14.phpt | 22 |
2 files changed, 38 insertions, 15 deletions
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 5a0ca023f7..11449ad411 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -448,20 +448,21 @@ ZEND_API size_t zend_get_scanned_file_offset(TSRMLS_D) { size_t offset = SCNG(yy_cursor) - SCNG(yy_start); #ifdef ZEND_MULTIBYTE - size_t original_offset = offset, length = 0; - do { - unsigned char *p = NULL; - SCNG(input_filter)(&p, &length, SCNG(script_org), offset TSRMLS_CC); - if (!p) { - break; - } - efree(p); - if (length > original_offset) { - offset--; - } else if (length < original_offset) { - offset++; - } - } while (original_offset != length); + if (SCNG(input_filter)) { + size_t original_offset = offset, length = 0; do { + unsigned char *p = NULL; + SCNG(input_filter)(&p, &length, SCNG(script_org), offset TSRMLS_CC); + if (!p) { + break; + } + efree(p); + if (length > original_offset) { + offset--; + } else if (length < original_offset) { + offset++; + } + } while (original_offset != length); + } #endif return offset; } @@ -607,7 +608,7 @@ ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter zend_encoding *new_encoding = SCNG(script_encoding); zend_encoding_filter new_filter = SCNG(input_filter); SCNG(script_encoding) = old_encoding; - SCNG(input_filter) = new_filter; + SCNG(input_filter) = old_input_filter; offset = zend_get_scanned_file_offset(TSRMLS_C); SCNG(script_encoding) = new_encoding; SCNG(input_filter) = new_filter; diff --git a/ext/mbstring/tests/zend_multibyte-14.phpt b/ext/mbstring/tests/zend_multibyte-14.phpt new file mode 100644 index 0000000000..dc968d78b0 --- /dev/null +++ b/ext/mbstring/tests/zend_multibyte-14.phpt @@ -0,0 +1,22 @@ +--TEST-- +zend multibyte (13) +--SKIPIF-- +<?php +ini_set("mbstring.script_encoding", "SJIS"); +ini_set("mbstring.script_encoding", "***") != "SJIS" and + die("skip zend-multibyte is not available"); +?> +--INI-- +mbstring.script_encoding=UTF-8 +mbstring.internal_encoding=UTF-8 +--FILE-- +<?php +var_dump(substr(file_get_contents(__FILE__), __COMPILER_HALT_OFFSET__)); +var_dump(bin2hex("äëüáéú")); +__halt_compiler();test +test +--EXPECT-- +string(10) "test +test +" +string(24) "c3a4c3abc3bcc3a1c3a9c3ba" |
