mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
f1d7e3ca0b
This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines in all *.phpt sections. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
82 lines
1.9 KiB
PHP
82 lines
1.9 KiB
PHP
--TEST--
|
|
mb_ereg_search() stuff
|
|
--SKIPIF--
|
|
<?php
|
|
extension_loaded('mbstring') or die('skip mbstring not available');
|
|
function_exists('mb_ereg_search') or die("skip\n");
|
|
?>
|
|
--INI--
|
|
output_handler=
|
|
--FILE--
|
|
<?php
|
|
mb_regex_set_options( '' );
|
|
|
|
$encs = array( 'EUC-JP', 'Shift_JIS', 'SJIS', 'UTF-8' );
|
|
|
|
function test_search( $test_enc, $str, $look_for, $opt, $in_enc = 'EUC-JP' ) {
|
|
mb_regex_encoding( $test_enc );
|
|
$str = mb_convert_encoding( $str, $test_enc, $in_enc );
|
|
$look_for = mb_convert_encoding( $look_for, $test_enc, $in_enc );
|
|
mb_ereg_search_init( $str, $look_for, $opt );
|
|
while ( mb_ereg_search_pos() ) {
|
|
$regs = mb_ereg_search_getregs();
|
|
array_shift( $regs );
|
|
printf( "(%s) (%d) %s\n", $test_enc, mb_ereg_search_getpos(), mb_convert_encoding( ( is_array( $regs ) ? implode( '-', $regs ): '' ), $in_enc, $test_enc ) );
|
|
}
|
|
}
|
|
function do_tests( $enc, $opt ) {
|
|
test_search( $enc, "∀・ ・∀\n", ' (・?∀・?)[[:space:]]', $opt );
|
|
test_search( $enc, 'abcde abdeabcf anvfabc odu abcd ', '(ab[a-z]+)', $opt );
|
|
}
|
|
|
|
foreach( $encs as $enc ) {
|
|
do_tests( $enc, '' );
|
|
do_tests( $enc, 'x' );
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
(EUC-JP) (10) ・∀
|
|
(EUC-JP) (5) abcde
|
|
(EUC-JP) (14) abdeabcf
|
|
(EUC-JP) (22) abc
|
|
(EUC-JP) (31) abcd
|
|
(EUC-JP) (5) ∀・
|
|
(EUC-JP) (10) ・∀
|
|
(EUC-JP) (5) abcde
|
|
(EUC-JP) (14) abdeabcf
|
|
(EUC-JP) (22) abc
|
|
(EUC-JP) (31) abcd
|
|
(Shift_JIS) (10) ・∀
|
|
(Shift_JIS) (5) abcde
|
|
(Shift_JIS) (14) abdeabcf
|
|
(Shift_JIS) (22) abc
|
|
(Shift_JIS) (31) abcd
|
|
(Shift_JIS) (5) ∀・
|
|
(Shift_JIS) (10) ・∀
|
|
(Shift_JIS) (5) abcde
|
|
(Shift_JIS) (14) abdeabcf
|
|
(Shift_JIS) (22) abc
|
|
(Shift_JIS) (31) abcd
|
|
(SJIS) (10) ・∀
|
|
(SJIS) (5) abcde
|
|
(SJIS) (14) abdeabcf
|
|
(SJIS) (22) abc
|
|
(SJIS) (31) abcd
|
|
(SJIS) (5) ∀・
|
|
(SJIS) (10) ・∀
|
|
(SJIS) (5) abcde
|
|
(SJIS) (14) abdeabcf
|
|
(SJIS) (22) abc
|
|
(SJIS) (31) abcd
|
|
(UTF-8) (14) ・∀
|
|
(UTF-8) (5) abcde
|
|
(UTF-8) (14) abdeabcf
|
|
(UTF-8) (22) abc
|
|
(UTF-8) (31) abcd
|
|
(UTF-8) (7) ∀・
|
|
(UTF-8) (14) ・∀
|
|
(UTF-8) (5) abcde
|
|
(UTF-8) (14) abdeabcf
|
|
(UTF-8) (22) abc
|
|
(UTF-8) (31) abcd
|