mirror of
https://github.com/php/php-src.git
synced 2026-03-30 20:22:36 +02:00
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
85 lines
2.0 KiB
PHP
85 lines
2.0 KiB
PHP
--TEST--
|
|
Test vsprintf() function : usage variations - octal formats with octal values
|
|
--SKIPIF--
|
|
<?php
|
|
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
/* Prototype : string vsprintf(string format, array args)
|
|
* Description: Return a formatted string
|
|
* Source code: ext/standard/formatted_print.c
|
|
*/
|
|
|
|
/*
|
|
* Test vsprintf() when different octal formats and octal values are passed to
|
|
* the '$format' and '$args' arguments of the function
|
|
*/
|
|
|
|
echo "*** Testing vsprintf() : octal formats with octal values ***\n";
|
|
|
|
// defining array of octal formats
|
|
$formats = array(
|
|
"%o",
|
|
"%+o %-o %O",
|
|
"%lo %Lo, %4o %-4o",
|
|
"%10.4o %-10.4o %04o %04.4o",
|
|
"%'#2o %'2o %'$2o %'_2o",
|
|
"%o %o %o %o",
|
|
"%% %%o %10 o%",
|
|
'%3$o %4$o %1$o %2$o'
|
|
);
|
|
|
|
// Arrays of octal values for the format defined in $format.
|
|
// Each sub array contains octal values which correspond to each format string in $format
|
|
$args_array = array(
|
|
array(00),
|
|
array(-01, 01, +022),
|
|
array(-020000000000, 020000000000, 017777777777, -017777777777),
|
|
array(0123456, 01234567, -01234567, 01234567),
|
|
array(0111, 02222, -0333333, -044444444),
|
|
array(0x123b, 0xfAb, 0123, 012),
|
|
array(01234, 0567, -01234, 02345),
|
|
array(03, 04, 01, 02)
|
|
|
|
);
|
|
|
|
// looping to test vsprintf() with different octal formats from the above $formats array
|
|
// and with octal values from the above $args_array array
|
|
$counter = 1;
|
|
foreach($formats as $format) {
|
|
echo "\n-- Iteration $counter --\n";
|
|
var_dump( vsprintf($format, $args_array[$counter-1]) );
|
|
$counter++;
|
|
}
|
|
|
|
echo "Done";
|
|
?>
|
|
--EXPECT--
|
|
*** Testing vsprintf() : octal formats with octal values ***
|
|
|
|
-- Iteration 1 --
|
|
string(1) "0"
|
|
|
|
-- Iteration 2 --
|
|
string(14) "37777777777 1 "
|
|
|
|
-- Iteration 3 --
|
|
string(38) "20000000000 o, 17777777777 20000000001"
|
|
|
|
-- Iteration 4 --
|
|
string(38) " 37776543211 0000"
|
|
|
|
-- Iteration 5 --
|
|
string(32) "111 2222 37777444445 37733333334"
|
|
|
|
-- Iteration 6 --
|
|
string(17) "11073 7653 123 12"
|
|
|
|
-- Iteration 7 --
|
|
string(6) "% %o o"
|
|
|
|
-- Iteration 8 --
|
|
string(7) "1 2 3 4"
|
|
Done
|