mirror of
https://github.com/php/php-src.git
synced 2026-04-21 15:08:16 +02:00
b746e69887
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
150 lines
3.0 KiB
PHP
150 lines
3.0 KiB
PHP
--TEST--
|
|
Test mb_ereg() function : usage variations - pass different character classes as pattern for multibyte string
|
|
--SKIPIF--
|
|
<?php
|
|
extension_loaded('mbstring') or die('skip');
|
|
function_exists('mb_ereg') or die("skip mb_ereg() is not available in this build");
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
/* Prototype : int mb_ereg(string $pattern, string $string [, array $registers])
|
|
* Description: Regular expression match for multibyte string
|
|
* Source code: ext/mbstring/php_mbregex.c
|
|
*/
|
|
|
|
/*
|
|
* Test how character classes match a multibyte string
|
|
*/
|
|
|
|
echo "*** Testing mb_ereg() : usage variations ***\n";
|
|
|
|
mb_regex_encoding('utf-8');
|
|
|
|
//contains japanese characters, ASCII digits and different, UTF-8 encoded digits
|
|
$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
|
|
|
|
$character_classes = array ('[[:alnum:]]+', /*1*/
|
|
'[[:alpha:]]+',
|
|
'[[:ascii:]]+',
|
|
'[[:blank:]]+',
|
|
'[[:cntrl:]]+',/*5*/
|
|
'[[:digit:]]+',
|
|
'[[:graph:]]+',
|
|
'[[:lower:]]+',
|
|
'[[:print:]]+',
|
|
'[[:punct:]]+', /*10*/
|
|
'[[:space:]]+',
|
|
'[[:upper:]]+',
|
|
'[[:xdigit:]]+'); /*13*/
|
|
|
|
$iterator = 1;
|
|
foreach ($character_classes as $pattern) {
|
|
if (is_array(@$regs)) {
|
|
$regs = null;
|
|
}
|
|
echo "\n-- Iteration $iterator --\n";
|
|
var_dump(mb_ereg($pattern, $string_mb, $regs));
|
|
if ($regs) {
|
|
base64_encode_var_dump($regs);
|
|
}
|
|
$iterator++;
|
|
}
|
|
/**
|
|
* replicate a var dump of an array but outputted string values are base64 encoded
|
|
*
|
|
* @param array $regs
|
|
*/
|
|
function base64_encode_var_dump($regs) {
|
|
if ($regs) {
|
|
echo "array(" . count($regs) . ") {\n";
|
|
foreach ($regs as $key => $value) {
|
|
echo " [$key]=>\n ";
|
|
if (is_string($value)) {
|
|
var_dump(base64_encode($value));
|
|
} else {
|
|
var_dump($value);
|
|
}
|
|
}
|
|
echo "}\n";
|
|
} else {
|
|
echo "NULL\n";
|
|
}
|
|
}
|
|
echo "Done";
|
|
|
|
?>
|
|
--EXPECT--
|
|
*** Testing mb_ereg() : usage variations ***
|
|
|
|
-- Iteration 1 --
|
|
int(47)
|
|
array(1) {
|
|
[0]=>
|
|
string(64) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZMDEyMzTvvJXvvJbvvJfvvJjvvJk="
|
|
}
|
|
|
|
-- Iteration 2 --
|
|
int(27)
|
|
array(1) {
|
|
[0]=>
|
|
string(36) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ"
|
|
}
|
|
|
|
-- Iteration 3 --
|
|
int(5)
|
|
array(1) {
|
|
[0]=>
|
|
string(8) "MDEyMzQ="
|
|
}
|
|
|
|
-- Iteration 4 --
|
|
bool(false)
|
|
|
|
-- Iteration 5 --
|
|
bool(false)
|
|
|
|
-- Iteration 6 --
|
|
int(20)
|
|
array(1) {
|
|
[0]=>
|
|
string(28) "MDEyMzTvvJXvvJbvvJfvvJjvvJk="
|
|
}
|
|
|
|
-- Iteration 7 --
|
|
int(50)
|
|
array(1) {
|
|
[0]=>
|
|
string(68) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII="
|
|
}
|
|
|
|
-- Iteration 8 --
|
|
bool(false)
|
|
|
|
-- Iteration 9 --
|
|
int(50)
|
|
array(1) {
|
|
[0]=>
|
|
string(68) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII="
|
|
}
|
|
|
|
-- Iteration 10 --
|
|
int(3)
|
|
array(1) {
|
|
[0]=>
|
|
string(4) "44CC"
|
|
}
|
|
|
|
-- Iteration 11 --
|
|
bool(false)
|
|
|
|
-- Iteration 12 --
|
|
bool(false)
|
|
|
|
-- Iteration 13 --
|
|
int(5)
|
|
array(1) {
|
|
[0]=>
|
|
string(8) "MDEyMzQ="
|
|
}
|
|
Done
|