Merge branch 'PHP-7.4'

* PHP-7.4:
  Apply tidy formatting
This commit is contained in:
Nikita Popov 2020-02-03 13:41:45 +01:00
commit 169805777c
41 changed files with 6875 additions and 6875 deletions

View file

@ -1,6 +1,6 @@
<?php <?php
if (function_exists("date_default_timezone_set")) { if (function_exists("date_default_timezone_set")) {
date_default_timezone_set("UTC"); date_default_timezone_set("UTC");
} }
function simple() { function simple() {
@ -220,30 +220,30 @@ function heapsort_r($n, &$ra) {
$ir = $n; $ir = $n;
while (1) { while (1) {
if ($l > 1) { if ($l > 1) {
$rra = $ra[--$l]; $rra = $ra[--$l];
} else { } else {
$rra = $ra[$ir]; $rra = $ra[$ir];
$ra[$ir] = $ra[1]; $ra[$ir] = $ra[1];
if (--$ir == 1) { if (--$ir == 1) {
$ra[1] = $rra; $ra[1] = $rra;
return; return;
} }
} }
$i = $l; $i = $l;
$j = $l << 1; $j = $l << 1;
while ($j <= $ir) { while ($j <= $ir) {
if (($j < $ir) && ($ra[$j] < $ra[$j+1])) { if (($j < $ir) && ($ra[$j] < $ra[$j+1])) {
$j++; $j++;
} }
if ($rra < $ra[$j]) { if ($rra < $ra[$j]) {
$ra[$i] = $ra[$j]; $ra[$i] = $ra[$j];
$j += ($i = $j); $j += ($i = $j);
} else { } else {
$j = $ir + 1; $j = $ir + 1;
} }
} }
$ra[$i] = $rra; $ra[$i] = $rra;
} }
} }
@ -268,9 +268,9 @@ function mkmatrix ($rows, $cols) {
$count = 1; $count = 1;
$mx = array(); $mx = array();
for ($i=0; $i<$rows; $i++) { for ($i=0; $i<$rows; $i++) {
for ($j=0; $j<$cols; $j++) { for ($j=0; $j<$cols; $j++) {
$mx[$i][$j] = $count++; $mx[$i][$j] = $count++;
} }
} }
return($mx); return($mx);
} }
@ -278,13 +278,13 @@ function mkmatrix ($rows, $cols) {
function mmult ($rows, $cols, $m1, $m2) { function mmult ($rows, $cols, $m1, $m2) {
$m3 = array(); $m3 = array();
for ($i=0; $i<$rows; $i++) { for ($i=0; $i<$rows; $i++) {
for ($j=0; $j<$cols; $j++) { for ($j=0; $j<$cols; $j++) {
$x = 0; $x = 0;
for ($k=0; $k<$cols; $k++) { for ($k=0; $k<$cols; $k++) {
$x += $m1[$i][$k] * $m2[$k][$j]; $x += $m1[$i][$k] * $m2[$k][$j];
} }
$m3[$i][$j] = $x; $m3[$i][$j] = $x;
} }
} }
return($m3); return($m3);
} }
@ -353,7 +353,7 @@ function gethrtime()
function start_test() function start_test()
{ {
ob_start(); ob_start();
return gethrtime(); return gethrtime();
} }
@ -367,7 +367,7 @@ function end_test($start, $name)
$pad = str_repeat(" ", 24-strlen($name)-strlen($num)); $pad = str_repeat(" ", 24-strlen($name)-strlen($num));
echo $name.$pad.$num."\n"; echo $name.$pad.$num."\n";
ob_start(); ob_start();
return gethrtime(); return gethrtime();
} }

View file

@ -22,220 +22,220 @@ function simpleicall($n) {
} }
class Foo { class Foo {
static $a = 0; static $a = 0;
public $b = 0; public $b = 0;
const TEST = 0; const TEST = 0;
static function read_static($n) { static function read_static($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = self::$a; $x = self::$a;
} }
} }
static function write_static($n) { static function write_static($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
self::$a = 0; self::$a = 0;
} }
} }
static function isset_static($n) { static function isset_static($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = isset(self::$a); $x = isset(self::$a);
} }
} }
static function empty_static($n) { static function empty_static($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = empty(self::$a); $x = empty(self::$a);
} }
} }
static function f() { static function f() {
} }
static function call_static($n) { static function call_static($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
self::f(); self::f();
} }
} }
function read_prop($n) { function read_prop($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = $this->b; $x = $this->b;
} }
} }
function write_prop($n) { function write_prop($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$this->b = 0; $this->b = 0;
} }
} }
function assign_add_prop($n) { function assign_add_prop($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$this->b += 2; $this->b += 2;
} }
} }
function pre_inc_prop($n) { function pre_inc_prop($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
++$this->b; ++$this->b;
} }
} }
function pre_dec_prop($n) { function pre_dec_prop($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
--$this->b; --$this->b;
} }
} }
function post_inc_prop($n) { function post_inc_prop($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$this->b++; $this->b++;
} }
} }
function post_dec_prop($n) { function post_dec_prop($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$this->b--; $this->b--;
} }
} }
function isset_prop($n) { function isset_prop($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = isset($this->b); $x = isset($this->b);
} }
} }
function empty_prop($n) { function empty_prop($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = empty($this->b); $x = empty($this->b);
} }
} }
function g() { function g() {
} }
function call($n) { function call($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$this->g(); $this->g();
} }
} }
function read_const($n) { function read_const($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = $this::TEST; $x = $this::TEST;
} }
} }
} }
function read_static($n) { function read_static($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = Foo::$a; $x = Foo::$a;
} }
} }
function write_static($n) { function write_static($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
Foo::$a = 0; Foo::$a = 0;
} }
} }
function isset_static($n) { function isset_static($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = isset(Foo::$a); $x = isset(Foo::$a);
} }
} }
function empty_static($n) { function empty_static($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = empty(Foo::$a); $x = empty(Foo::$a);
} }
} }
function call_static($n) { function call_static($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
Foo::f(); Foo::f();
} }
} }
function create_object($n) { function create_object($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = new Foo(); $x = new Foo();
} }
} }
define('TEST', null); define('TEST', null);
function read_const($n) { function read_const($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = TEST; $x = TEST;
} }
} }
function read_auto_global($n) { function read_auto_global($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = $_GET; $x = $_GET;
} }
} }
$g_var = 0; $g_var = 0;
function read_global_var($n) { function read_global_var($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = $GLOBALS['g_var']; $x = $GLOBALS['g_var'];
} }
} }
function read_hash($n) { function read_hash($n) {
$hash = array('test' => 0); $hash = array('test' => 0);
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = $hash['test']; $x = $hash['test'];
} }
} }
function read_str_offset($n) { function read_str_offset($n) {
$str = "test"; $str = "test";
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = $str[1]; $x = $str[1];
} }
} }
function issetor($n) { function issetor($n) {
$val = array(0,1,2,3,4,5,6,7,8,9); $val = array(0,1,2,3,4,5,6,7,8,9);
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = $val ?: null; $x = $val ?: null;
} }
} }
function issetor2($n) { function issetor2($n) {
$f = false; $j = 0; $f = false; $j = 0;
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = $f ?: $j + 1; $x = $f ?: $j + 1;
} }
} }
function ternary($n) { function ternary($n) {
$val = array(0,1,2,3,4,5,6,7,8,9); $val = array(0,1,2,3,4,5,6,7,8,9);
$f = false; $f = false;
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = $f ? null : $val; $x = $f ? null : $val;
} }
} }
function ternary2($n) { function ternary2($n) {
$f = false; $j = 0; $f = false; $j = 0;
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
$x = $f ? $f : $j + 1; $x = $f ? $f : $j + 1;
} }
} }
/*****/ /*****/
function empty_loop($n) { function empty_loop($n) {
for ($i = 0; $i < $n; ++$i) { for ($i = 0; $i < $n; ++$i) {
} }
} }
function gethrtime() function gethrtime()

View file

@ -962,7 +962,7 @@ void zend_register_standard_ini_entries(void) /* {{{ */
} }
/* }}} */ /* }}} */
static zend_class_entry *resolve_type_name(zend_string *type_name) { static zend_class_entry *resolve_type_name(zend_string *type_name) {
zend_string *lc_type_name = zend_string_tolower(type_name); zend_string *lc_type_name = zend_string_tolower(type_name);
zend_class_entry *ce = zend_hash_find_ptr(CG(class_table), lc_type_name); zend_class_entry *ce = zend_hash_find_ptr(CG(class_table), lc_type_name);

View file

@ -1597,7 +1597,7 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
string_len = Z_STRLEN_P(value); string_len = Z_STRLEN_P(value);
c = (zend_uchar)Z_STRVAL_P(value)[0]; c = (zend_uchar)Z_STRVAL_P(value)[0];
} }
if (string_len != 1) { if (string_len != 1) {
if (string_len == 0) { if (string_len == 0) {
/* Error on empty input string */ /* Error on empty input string */

File diff suppressed because it is too large Load diff

View file

@ -21,8 +21,8 @@
/* {{{ error /* {{{ error
*/ */
function error($message) { function error($message) {
printf('Error: %s%s', $message, PHP_EOL); printf('Error: %s%s', $message, PHP_EOL);
exit; exit;
} }
/* }}} */ /* }}} */
@ -114,152 +114,152 @@ OPTIONS
--help This help --help This help
HELP; HELP;
exit; exit;
} }
/* }}} */ /* }}} */
/* {{{ task /* {{{ task
*/ */
function task($label, $callback) { function task($label, $callback) {
printf('%s... ', $label); printf('%s... ', $label);
$callback(); $callback();
printf('done%s', PHP_EOL); printf('done%s', PHP_EOL);
} }
/* }}} */ /* }}} */
/* {{{ print_success /* {{{ print_success
*/ */
function print_success() { function print_success() {
global $options; global $options;
if (PHP_OS_FAMILY != 'Windows') { if (PHP_OS_FAMILY != 'Windows') {
$file_prefix = './'; $file_prefix = './';
$make_prefix = ''; $make_prefix = '';
} else { } else {
$file_prefix = ''; $file_prefix = '';
$make_prefix = 'n'; $make_prefix = 'n';
} }
printf('%1$sSuccess. The extension is now ready to be compiled. To do so, use the%s', PHP_EOL); printf('%1$sSuccess. The extension is now ready to be compiled. To do so, use the%s', PHP_EOL);
printf('following steps:%1$s%1$s', PHP_EOL); printf('following steps:%1$s%1$s', PHP_EOL);
printf('cd /path/to/php-src/ext/%s%s', $options['ext'], PHP_EOL); printf('cd /path/to/php-src/ext/%s%s', $options['ext'], PHP_EOL);
printf('phpize%s', PHP_EOL); printf('phpize%s', PHP_EOL);
printf('%sconfigure%s', $file_prefix, PHP_EOL); printf('%sconfigure%s', $file_prefix, PHP_EOL);
printf('%smake%2$s%2$s', $make_prefix, PHP_EOL); printf('%smake%2$s%2$s', $make_prefix, PHP_EOL);
printf('Don\'t forget to run tests once the compilation is done:%s', PHP_EOL); printf('Don\'t forget to run tests once the compilation is done:%s', PHP_EOL);
printf('%smake test%2$s%2$s', $make_prefix, PHP_EOL); printf('%smake test%2$s%2$s', $make_prefix, PHP_EOL);
printf('Thank you for using PHP!%s', PHP_EOL); printf('Thank you for using PHP!%s', PHP_EOL);
} }
/* }}} */ /* }}} */
/* {{{ process_args /* {{{ process_args
*/ */
function process_args($argv, $argc) { function process_args($argv, $argc) {
$options = [ $options = [
'unix' => true, 'unix' => true,
'windows' => true, 'windows' => true,
'ext' => '', 'ext' => '',
'dir' => __DIR__ . DIRECTORY_SEPARATOR, 'dir' => __DIR__ . DIRECTORY_SEPARATOR,
'skel' => __DIR__ . DIRECTORY_SEPARATOR . 'skeleton' . DIRECTORY_SEPARATOR, 'skel' => __DIR__ . DIRECTORY_SEPARATOR . 'skeleton' . DIRECTORY_SEPARATOR,
'author' => false, 'author' => false,
'experimental' => false, 'experimental' => false,
'std' => false 'std' => false
]; ];
for($i = 1; $i < $argc; ++$i) for($i = 1; $i < $argc; ++$i)
{ {
$val = $argv[$i]; $val = $argv[$i];
if($val[0] != '-' || $val[1] != '-') if($val[0] != '-' || $val[1] != '-')
{ {
continue; continue;
} }
switch($opt = strtolower(substr($val, 2))) switch($opt = strtolower(substr($val, 2)))
{ {
case 'help': { case 'help': {
print_help(); print_help();
} }
case 'onlyunix': { case 'onlyunix': {
$options['windows'] = false; $options['windows'] = false;
} }
break; break;
case 'onlywindows': { case 'onlywindows': {
$options['unix'] = false; $options['unix'] = false;
} }
break; break;
case 'experimental': { case 'experimental': {
$options['experimental'] = true; $options['experimental'] = true;
} }
break; break;
case 'std': { case 'std': {
$options['std'] = true; $options['std'] = true;
} }
break; break;
case 'ext': case 'ext':
case 'dir': case 'dir':
case 'author': { case 'author': {
if (!isset($argv[$i + 1]) || ($argv[$i + 1][0] == '-' && $argv[$i + 1][1] == '-')) { if (!isset($argv[$i + 1]) || ($argv[$i + 1][0] == '-' && $argv[$i + 1][1] == '-')) {
error('Argument "' . $val . '" expects a value, none passed'); error('Argument "' . $val . '" expects a value, none passed');
} else if ($opt == 'dir' && empty($argv[$i + 1])) { } else if ($opt == 'dir' && empty($argv[$i + 1])) {
continue 2; continue 2;
} }
$options[$opt] = ($opt == 'dir' ? realpath($argv[$i + 1]) . DIRECTORY_SEPARATOR : $argv[$i + 1]); $options[$opt] = ($opt == 'dir' ? realpath($argv[$i + 1]) . DIRECTORY_SEPARATOR : $argv[$i + 1]);
} }
break; break;
default: { default: {
error('Unsupported argument "' . $val . '" passed'); error('Unsupported argument "' . $val . '" passed');
} }
} }
} }
if (empty($options['ext'])) { if (empty($options['ext'])) {
error('No extension name passed, use "--ext <name>"'); error('No extension name passed, use "--ext <name>"');
} else if (!$options['unix'] && !$options['windows']) { } else if (!$options['unix'] && !$options['windows']) {
error('Cannot pass both --onlyunix and --onlywindows'); error('Cannot pass both --onlyunix and --onlywindows');
} else if (!is_dir($options['skel'])) { } else if (!is_dir($options['skel'])) {
error('The skeleton directory was not found'); error('The skeleton directory was not found');
} }
// Validate extension name // Validate extension name
if (!preg_match('/^[a-z][a-z0-9_]+$/i', $options['ext'])) { if (!preg_match('/^[a-z][a-z0-9_]+$/i', $options['ext'])) {
error('Invalid extension name. Valid names start with a letter,' error('Invalid extension name. Valid names start with a letter,'
.' followed by any number of letters, numbers, or underscores.' .' followed by any number of letters, numbers, or underscores.'
.' Using only lower case letters is preferred.'); .' Using only lower case letters is preferred.');
} }
$options['ext'] = str_replace(['\\', '/'], '', strtolower($options['ext'])); $options['ext'] = str_replace(['\\', '/'], '', strtolower($options['ext']));
return $options; return $options;
} }
/* }}} */ /* }}} */
/* {{{ process_source_tags /* {{{ process_source_tags
*/ */
function process_source_tags($file, $short_name) { function process_source_tags($file, $short_name) {
global $options; global $options;
$source = file_get_contents($file); $source = file_get_contents($file);
if ($source === false) { if ($source === false) {
error('Unable to open file for reading: ' . $short_name); error('Unable to open file for reading: ' . $short_name);
} }
$source = str_replace('%EXTNAME%', $options['ext'], $source); $source = str_replace('%EXTNAME%', $options['ext'], $source);
$source = str_replace('%EXTNAMECAPS%', strtoupper($options['ext']), $source); $source = str_replace('%EXTNAMECAPS%', strtoupper($options['ext']), $source);
if (strpos($short_name, '.c') !== false || strpos($short_name, '.h') !== false) { if (strpos($short_name, '.c') !== false || strpos($short_name, '.h') !== false) {
static $header; static $header;
if (!$header) { if (!$header) {
if ($options['std']) { if ($options['std']) {
$author_len = strlen($options['author']); $author_len = strlen($options['author']);
$credits = $options['author'] . ($author_len && $author_len <= 60 ? str_repeat(' ', 60 - $author_len) : ''); $credits = $options['author'] . ($author_len && $author_len <= 60 ? str_repeat(' ', 60 - $author_len) : '');
$header = <<<"HEADER" $header = <<<"HEADER"
/* /*
+----------------------------------------------------------------------+ +----------------------------------------------------------------------+
| Copyright (c) The PHP Group | | Copyright (c) The PHP Group |
@ -276,141 +276,141 @@ function process_source_tags($file, $short_name) {
+----------------------------------------------------------------------+ +----------------------------------------------------------------------+
*/ */
HEADER; HEADER;
} else { } else {
if ($options['author']) { if ($options['author']) {
$header = sprintf('/* %s extension for PHP (c) %d %s */', $options['ext'], date('Y'), $options['author']); $header = sprintf('/* %s extension for PHP (c) %d %s */', $options['ext'], date('Y'), $options['author']);
} else { } else {
$header = sprintf('/* %s extension for PHP */', $options['ext']); $header = sprintf('/* %s extension for PHP */', $options['ext']);
} }
} }
} }
$source = str_replace('%HEADER%', $header, $source); $source = str_replace('%HEADER%', $header, $source);
} }
if (!file_put_contents($file, $source)) { if (!file_put_contents($file, $source)) {
error('Unable to save contents to file: ' . $short_name); error('Unable to save contents to file: ' . $short_name);
} }
} }
/* }}} */ /* }}} */
/* {{{ copy_config_scripts /* {{{ copy_config_scripts
*/ */
function copy_config_scripts() { function copy_config_scripts() {
global $options; global $options;
$files = []; $files = [];
if ($options['unix']) { if ($options['unix']) {
$files[] = 'config.m4'; $files[] = 'config.m4';
} }
if ($options['windows']) { if ($options['windows']) {
$files[] = 'config.w32'; $files[] = 'config.w32';
} }
$files[] = '.gitignore'; $files[] = '.gitignore';
foreach($files as $config_script) { foreach($files as $config_script) {
$new_config_script = $options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $config_script; $new_config_script = $options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $config_script;
if (!copy($options['skel'] . $config_script . '.in', $new_config_script)) { if (!copy($options['skel'] . $config_script . '.in', $new_config_script)) {
error('Unable to copy config script: ' . $config_script); error('Unable to copy config script: ' . $config_script);
} }
process_source_tags($new_config_script, $config_script); process_source_tags($new_config_script, $config_script);
} }
} }
/* }}} */ /* }}} */
/* {{{ copy_sources /* {{{ copy_sources
*/ */
function copy_sources() { function copy_sources() {
global $options; global $options;
$files = [ $files = [
'skeleton.c' => $options['ext'] . '.c', 'skeleton.c' => $options['ext'] . '.c',
'skeleton.stub.php' => $options['ext'] . '.stub.php', 'skeleton.stub.php' => $options['ext'] . '.stub.php',
'php_skeleton.h' => 'php_' . $options['ext'] . '.h' 'php_skeleton.h' => 'php_' . $options['ext'] . '.h'
]; ];
foreach ($files as $src_file => $dst_file) { foreach ($files as $src_file => $dst_file) {
if (!copy($options['skel'] . $src_file, $options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $dst_file)) { if (!copy($options['skel'] . $src_file, $options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $dst_file)) {
error('Unable to copy source file: ' . $src_file); error('Unable to copy source file: ' . $src_file);
} }
process_source_tags($options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $dst_file, $dst_file); process_source_tags($options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $dst_file, $dst_file);
} }
} }
/* }}} */ /* }}} */
/* {{{ copy_tests /* {{{ copy_tests
*/ */
function copy_tests() { function copy_tests() {
global $options; global $options;
$test_files = glob($options['skel'] . 'tests/*', GLOB_MARK); $test_files = glob($options['skel'] . 'tests/*', GLOB_MARK);
if (!$test_files) { if (!$test_files) {
return; return;
} }
foreach ($test_files as $test) { foreach ($test_files as $test) {
if (is_dir($test)) { if (is_dir($test)) {
continue; continue;
} }
$new_test = str_replace([$options['skel'], '/'], ['', DIRECTORY_SEPARATOR], $test); $new_test = str_replace([$options['skel'], '/'], ['', DIRECTORY_SEPARATOR], $test);
if (!copy($test, $options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $new_test)) { if (!copy($test, $options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $new_test)) {
error('Unable to copy file: ' . $new_test); error('Unable to copy file: ' . $new_test);
} }
process_source_tags($options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $new_test, $new_test); process_source_tags($options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $new_test, $new_test);
} }
} }
/* }}} */ /* }}} */
if (PHP_SAPI != 'cli') { if (PHP_SAPI != 'cli') {
error('This script is only suited for CLI'); error('This script is only suited for CLI');
} }
if ($argc < 1) { if ($argc < 1) {
print_help(); print_help();
exit; exit;
} }
$options = process_args($argv, $argc); $options = process_args($argv, $argc);
if (!$options['dir'] || !is_dir($options['dir'])) { if (!$options['dir'] || !is_dir($options['dir'])) {
error('The selected output directory does not exist'); error('The selected output directory does not exist');
} else if (is_dir($options['dir'] . $options['ext'])) { } else if (is_dir($options['dir'] . $options['ext'])) {
error('There is already a folder named "' . $options['ext'] . '" in the output directory'); error('There is already a folder named "' . $options['ext'] . '" in the output directory');
} else if (!mkdir($options['dir'] . $options['ext'])) { } else if (!mkdir($options['dir'] . $options['ext'])) {
error('Unable to create extension directory in the output directory'); error('Unable to create extension directory in the output directory');
} else if (!mkdir($options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . 'tests')) { } else if (!mkdir($options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . 'tests')) {
error('Unable to create the tests directory'); error('Unable to create the tests directory');
} }
if ($options['experimental']) { if ($options['experimental']) {
print('Creating EXPERIMENTAL... '); print('Creating EXPERIMENTAL... ');
if (file_put_contents($options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . 'EXPERIMENTAL', '') === false) { if (file_put_contents($options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . 'EXPERIMENTAL', '') === false) {
error('Unable to create the EXPERIMENTAL file'); error('Unable to create the EXPERIMENTAL file');
} }
printf('done%s', PHP_EOL); printf('done%s', PHP_EOL);
} }
if (!empty($options['author'])) { if (!empty($options['author'])) {
print('Creating CREDITS... '); print('Creating CREDITS... ');
if (!file_put_contents($options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . 'CREDITS', $options['ext'] . PHP_EOL . $options['author'])) { if (!file_put_contents($options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . 'CREDITS', $options['ext'] . PHP_EOL . $options['author'])) {
error('Unable to create the CREDITS file'); error('Unable to create the CREDITS file');
} }
printf('done%s', PHP_EOL); printf('done%s', PHP_EOL);
} }
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');

View file

@ -17,13 +17,13 @@ class FFI
*/ */
static function new($type, bool $owned = true, bool $persistent = false) {} static function new($type, bool $owned = true, bool $persistent = false) {}
/** /**
* @prefer-ref $ptr * @prefer-ref $ptr
* @return void * @return void
*/ */
static function free(FFI\CData $ptr) {} static function free(FFI\CData $ptr) {}
/** /**
* @param FFI\CType|string $type * @param FFI\CType|string $type
* @prefer-ref $ptr * @prefer-ref $ptr
* @return ?FFI\CData * @return ?FFI\CData

View file

@ -2,17 +2,17 @@
/* This is a generated file, do not modify */ /* This is a generated file, do not modify */
/* Usage: php create_data_file.php /path/to/magic.mgc > data_file.c */ /* Usage: php create_data_file.php /path/to/magic.mgc > data_file.c */
<?php <?php
$dta = file_get_contents( $argv[1] ); $dta = file_get_contents( $argv[1] );
$dta_l = strlen($dta); $dta_l = strlen($dta);
$j = 0; $j = 0;
echo "const unsigned char php_magic_database[$dta_l] = {\n"; echo "const unsigned char php_magic_database[$dta_l] = {\n";
for ($i = 0; $i < $dta_l; $i++) { for ($i = 0; $i < $dta_l; $i++) {
printf("0x%02X, ", ord($dta[$i])); printf("0x%02X, ", ord($dta[$i]));
if ($j % 16 == 15) { if ($j % 16 == 15) {
echo "\n"; echo "\n";
} }
$j++; $j++;
} }
echo "};\n"; echo "};\n";
?> ?>

View file

@ -5,68 +5,68 @@
This gives rather interesting results :) This gives rather interesting results :)
Measures on a Notebook P4M-1.7 256MB Windows 2000: Measures on a Notebook P4M-1.7 256MB Windows 2000:
sha1 0.556691 sha1 0.556691
tiger160,3 0.774469 tiger160,3 0.774469
tiger192,3 0.776314 tiger192,3 0.776314
tiger128,3 0.777004 tiger128,3 0.777004
ripemd128 0.896674 ripemd128 0.896674
sha256 1.011164 sha256 1.011164
md5 1.016032 md5 1.016032
tiger160,4 1.056617 tiger160,4 1.056617
tiger128,4 1.063101 tiger128,4 1.063101
tiger192,4 1.069258 tiger192,4 1.069258
haval160,3 1.125099 haval160,3 1.125099
haval128,3 1.125679 haval128,3 1.125679
haval224,3 1.128017 haval224,3 1.128017
haval192,3 1.130026 haval192,3 1.130026
haval256,3 1.134846 haval256,3 1.134846
ripemd160 1.150693 ripemd160 1.150693
haval128,4 1.686261 haval128,4 1.686261
haval192,4 1.687274 haval192,4 1.687274
haval160,4 1.693091 haval160,4 1.693091
haval256,4 1.699323 haval256,4 1.699323
haval224,4 1.743094 haval224,4 1.743094
haval160,5 2.003452 haval160,5 2.003452
haval192,5 2.008341 haval192,5 2.008341
haval256,5 2.009048 haval256,5 2.009048
haval128,5 2.009555 haval128,5 2.009555
haval224,5 2.015539 haval224,5 2.015539
sha384 3.370734 sha384 3.370734
sha512 3.381121 sha512 3.381121
whirlpool 6.912327 whirlpool 6.912327
snefru 9.268168 snefru 9.268168
Measures on a Desktop P4-2.4 512MB Debian (Linux-2.4): Measures on a Desktop P4-2.4 512MB Debian (Linux-2.4):
md5 0.147739 md5 0.147739
haval128,3 0.317006 haval128,3 0.317006
haval192,3 0.317524 haval192,3 0.317524
haval256,3 0.317526 haval256,3 0.317526
haval160,3 0.323035 haval160,3 0.323035
haval224,3 0.333318 haval224,3 0.333318
ripemd128 0.353447 ripemd128 0.353447
sha1 0.376200 sha1 0.376200
ripemd160 0.413758 ripemd160 0.413758
sha256 0.435957 sha256 0.435957
haval160,4 0.452357 haval160,4 0.452357
haval224,4 0.454531 haval224,4 0.454531
haval128,4 0.458026 haval128,4 0.458026
haval256,4 0.459051 haval256,4 0.459051
haval192,4 0.468094 haval192,4 0.468094
haval128,5 0.524262 haval128,5 0.524262
haval160,5 0.529573 haval160,5 0.529573
haval224,5 0.533655 haval224,5 0.533655
haval256,5 0.534446 haval256,5 0.534446
haval192,5 0.543726 haval192,5 0.543726
tiger128,3 0.577975 tiger128,3 0.577975
tiger160,3 0.579951 tiger160,3 0.579951
tiger192,3 0.597111 tiger192,3 0.597111
tiger192,4 0.781408 tiger192,4 0.781408
tiger160,4 0.801243 tiger160,4 0.801243
tiger128,4 0.812239 tiger128,4 0.812239
sha512 1.298627 sha512 1.298627
sha384 1.313607 sha384 1.313607
whirlpool 1.556159 whirlpool 1.556159
snefru 5.703742 snefru 5.703742
*/ */
@ -76,17 +76,17 @@ $data = file_get_contents(__FILE__);
$time = array(); $time = array();
for ($j = 0; $j < 10; $j++) { for ($j = 0; $j < 10; $j++) {
foreach (hash_algos() as $algo) { foreach (hash_algos() as $algo) {
$start = microtime(true); $start = microtime(true);
for ($i = 0; $i < 1000; $i++) { for ($i = 0; $i < 1000; $i++) {
hash($algo, $data); hash($algo, $data);
} }
$time[$algo] += microtime(true)-$start; $time[$algo] += microtime(true)-$start;
} }
} }
asort($time, SORT_NUMERIC); asort($time, SORT_NUMERIC);
foreach ($time as $a => $t) { foreach ($time as $a => $t) {
printf("%-12s %02.6f\n", $a, $t); printf("%-12s %02.6f\n", $a, $t);
} }
?> ?>

View file

@ -625,7 +625,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
{ {
zend_long lval; zend_long lval;
double dval; double dval;
if ((Z_STRLEN_P(parameter) == 0)) { if ((Z_STRLEN_P(parameter) == 0)) {
*(FB_BOOLEAN*)var->sqldata = FB_FALSE; *(FB_BOOLEAN*)var->sqldata = FB_FALSE;
break; break;
@ -663,7 +663,7 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
break; break;
} }
#endif #endif
/* check if a NULL should be inserted */ /* check if a NULL should be inserted */
switch (Z_TYPE_P(parameter)) { switch (Z_TYPE_P(parameter)) {

View file

@ -82,7 +82,7 @@ PHP_MINFO_FUNCTION(pdo_firebird) /* {{{ */
{ {
char version[64]; char version[64];
isc_get_client_version(version); isc_get_client_version(version);
php_info_print_table_start(); php_info_print_table_start();
php_info_print_table_header(2, "PDO Driver for Firebird", "enabled"); php_info_print_table_header(2, "PDO Driver for Firebird", "enabled");
php_info_print_table_row(2, "Client Library Version", version); php_info_print_table_row(2, "Client Library Version", version);

View file

@ -1,28 +1,28 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
$codes = array(); $codes = array();
$maxlen = 0; $maxlen = 0;
while (!feof(STDIN)) { while (!feof(STDIN)) {
$line = fgets(STDIN); $line = fgets(STDIN);
if (ereg('^\{[[:space:]]+(ER_.*)[[:space:]]+,[[:space:]]*"(.*)",[[:space:]]*"(.*)"', $line, $matches)) { if (ereg('^\{[[:space:]]+(ER_.*)[[:space:]]+,[[:space:]]*"(.*)",[[:space:]]*"(.*)"', $line, $matches)) {
$codes[$matches[1]] = $matches[2]; $codes[$matches[1]] = $matches[2];
$maxlen = max($maxlen, strlen($matches[1])); $maxlen = max($maxlen, strlen($matches[1]));
} }
} }
if (empty($codes)) { if (empty($codes)) {
fputs(STDERR, "input doesn't look like a MySQL sql_state.h file\n"); fputs(STDERR, "input doesn't look like a MySQL sql_state.h file\n");
exit(3); exit(3);
} }
echo "/* DO NOT EDIT THIS FILE!!! It is auto generated by get_error_codes.php */\n"; echo "/* DO NOT EDIT THIS FILE!!! It is auto generated by get_error_codes.php */\n";
foreach ($codes as $code => $state) { foreach ($codes as $code => $state) {
echo "#ifdef $code\n"; echo "#ifdef $code\n";
printf(" case %-{$maxlen}s: return \"%s\";\n", $code, $state); printf(" case %-{$maxlen}s: return \"%s\";\n", $code, $state);
echo "#endif\n"; echo "#endif\n";
} }
?> ?>

View file

@ -57,7 +57,7 @@ static void pdo_sqlite_stmt_set_column_count(pdo_stmt_t *stmt, int new_count)
} }
/* /*
* The column count has not changed : no need to reload columns description * The column count has not changed : no need to reload columns description
* Note: Do not handle attribute name change, without column count change * Note: Do not handle attribute name change, without column count change
*/ */
if (new_count == stmt->column_count) { if (new_count == stmt->column_count) {

View file

@ -10,44 +10,44 @@
* Phar Command * Phar Command
*/ */
foreach(array("SPL", "Reflection", "Phar") as $ext) { foreach(array("SPL", "Reflection", "Phar") as $ext) {
if (!extension_loaded($ext)) { if (!extension_loaded($ext)) {
echo "$argv[0] requires PHP extension $ext.\n"; echo "$argv[0] requires PHP extension $ext.\n";
exit(1); exit(1);
} }
} }
<?php <?php
$classes = array( $classes = array(
'DirectoryTreeIterator', 'DirectoryTreeIterator',
'DirectoryGraphIterator', 'DirectoryGraphIterator',
'InvertedRegexIterator', 'InvertedRegexIterator',
'CLICommand', 'CLICommand',
'PharCommand', 'PharCommand',
); );
foreach($classes as $name) { foreach($classes as $name) {
echo "if (!class_exists('$name', 0))\n{\n"; echo "if (!class_exists('$name', 0))\n{\n";
$f = file(dirname(__FILE__) . '/phar/' . strtolower($name) . '.inc'); $f = file(dirname(__FILE__) . '/phar/' . strtolower($name) . '.inc');
unset($f[0]); unset($f[0]);
$c = count($f); $c = count($f);
while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) { while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) {
unset($f[$c--]); unset($f[$c--]);
} }
if (substr($f[$c], -2) == "\r\n") { if (substr($f[$c], -2) == "\r\n") {
$f[$c] = substr($f[$c], 0, -2); $f[$c] = substr($f[$c], 0, -2);
} }
if (substr($f[$c], -1) == "\n") { if (substr($f[$c], -1) == "\n") {
$f[$c] = substr($f[$c], 0, -1); $f[$c] = substr($f[$c], 0, -1);
} }
if (substr($f[$c], -2) == '?>') { if (substr($f[$c], -2) == '?>') {
$f[$c] = substr($f[$c], 0,-2); $f[$c] = substr($f[$c], 0,-2);
} }
while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) { while ($c && (strlen($f[$c]) == 0 || $f[$c] == "\n" || $f[$c] == "\r\n")) {
unset($f[$c--]); unset($f[$c--]);
} }
echo join('', $f); echo join('', $f);
echo "\n}\n\n"; echo "\n}\n\n";
} }
echo 'new PharCommand($argc, $argv);'."\n"; echo 'new PharCommand($argc, $argv);'."\n";

View file

@ -4,18 +4,18 @@ $s = str_replace("\r", '', file_get_contents(dirname(__FILE__) . '/shortarc.php'
$s .= "\nExtract_Phar::go();\n__HALT_COMPILER();"; $s .= "\nExtract_Phar::go();\n__HALT_COMPILER();";
$news = ''; $news = '';
foreach (token_get_all($s) as $token) { foreach (token_get_all($s) as $token) {
if (is_array($token)) { if (is_array($token)) {
if ($token[0] == T_COMMENT) { if ($token[0] == T_COMMENT) {
$token[1] = ''; $token[1] = '';
} }
if ($token[0] == T_WHITESPACE) { if ($token[0] == T_WHITESPACE) {
$n = str_repeat("\n", substr_count($token[1], "\n")); $n = str_repeat("\n", substr_count($token[1], "\n"));
$token[1] = strlen($n) ? $n : ' '; $token[1] = strlen($n) ? $n : ' ';
} }
$news .= $token[1]; $news .= $token[1];
} else { } else {
$news .= $token; $news .= $token;
} }
} }
$s = $news . ' ?>'; $s = $news . ' ?>';
$slen = strlen($s) - strlen('index.php') - strlen("000"); $slen = strlen($s) - strlen('index.php') - strlen("000");
@ -55,50 +55,50 @@ $s1split = str_split($s1, 2046);
$s3split = str_split($s3, 2046); $s3split = str_split($s3, 2046);
$took = false; $took = false;
foreach ($s1split as $i => $chunk) { foreach ($s1split as $i => $chunk) {
if ($took) { if ($took) {
$s1split[$i] = substr($chunk, 1); $s1split[$i] = substr($chunk, 1);
$took = false; $took = false;
} }
if ($chunk[strlen($chunk) - 1] == '\\') { if ($chunk[strlen($chunk) - 1] == '\\') {
$s1split[$i] .= $s1split[$i + 1][0]; $s1split[$i] .= $s1split[$i + 1][0];
$took = true; $took = true;
} }
} }
foreach ($s3split as $i => $chunk) { foreach ($s3split as $i => $chunk) {
if ($took) { if ($took) {
$s3split[$i] = substr($chunk, 1); $s3split[$i] = substr($chunk, 1);
$took = false; $took = false;
} }
if ($chunk[strlen($chunk) - 1] == '\\') { if ($chunk[strlen($chunk) - 1] == '\\') {
$s3split[$i] .= $s3split[$i + 1][0]; $s3split[$i] .= $s3split[$i + 1][0];
$took = true; $took = true;
} }
} }
$stub .= "\tstatic const char newstub0[] = \"" . $webs . '"; $stub .= "\tstatic const char newstub0[] = \"" . $webs . '";
'; ';
foreach ($s1split as $i => $chunk) { foreach ($s1split as $i => $chunk) {
$s1count = $i + 1; $s1count = $i + 1;
$stub .= "\tstatic const char newstub1_" . $i . '[] = "' . $chunk . '"; $stub .= "\tstatic const char newstub1_" . $i . '[] = "' . $chunk . '";
'; ';
} }
$stub .= "\tstatic const char newstub2[] = \"" . $s2 . "\"; $stub .= "\tstatic const char newstub2[] = \"" . $s2 . "\";
"; ";
foreach ($s3split as $i => $chunk) { foreach ($s3split as $i => $chunk) {
$s3count = $i + 1; $s3count = $i + 1;
$stub .= "\tstatic const char newstub3_" . $i . '[] = "' . $chunk . '"; $stub .= "\tstatic const char newstub3_" . $i . '[] = "' . $chunk . '";
'; ';
} }
$stub .= "\n\tstatic const int newstub_len = " . $slen . "; $stub .= "\n\tstatic const int newstub_len = " . $slen . ";
\t*len = spprintf(stub, name_len + web_len + newstub_len, \"%s%s" . str_repeat('%s', $s1count) . '%s%s%d' \t*len = spprintf(stub, name_len + web_len + newstub_len, \"%s%s" . str_repeat('%s', $s1count) . '%s%s%d'
. str_repeat('%s', $s3count) . '", newstub0, web'; . str_repeat('%s', $s3count) . '", newstub0, web';
foreach ($s1split as $i => $unused) { foreach ($s1split as $i => $unused) {
$stub .= ', newstub1_' . $i; $stub .= ', newstub1_' . $i;
} }
$stub .= ', index_php, newstub2'; $stub .= ', index_php, newstub2';
$stub .= ", name_len + web_len + newstub_len"; $stub .= ", name_len + web_len + newstub_len";
foreach ($s3split as $i => $unused) { foreach ($s3split as $i => $unused) {
$stub .= ', newstub3_' . $i; $stub .= ', newstub3_' . $i;
} }
$stub .= "); $stub .= ");
}"; }";

View file

@ -12,37 +12,37 @@
if (!extension_loaded('phar')) if (!extension_loaded('phar'))
{ {
if (!class_exists('PHP_Archive', 0)) { if (!class_exists('PHP_Archive', 0)) {
echo "Neither Extension Phar nor class PHP_Archive are available.\n"; echo "Neither Extension Phar nor class PHP_Archive are available.\n";
exit(1); exit(1);
} }
if (!in_array('phar', stream_get_wrappers())) { if (!in_array('phar', stream_get_wrappers())) {
stream_wrapper_register('phar', 'PHP_Archive'); stream_wrapper_register('phar', 'PHP_Archive');
} }
if (!class_exists('Phar',0)) { if (!class_exists('Phar',0)) {
require 'phar://'.__FILE__.'/phar.inc'; require 'phar://'.__FILE__.'/phar.inc';
} }
} }
foreach(array("SPL", "Reflection") as $ext) foreach(array("SPL", "Reflection") as $ext)
{ {
if (!extension_loaded($ext)) { if (!extension_loaded($ext)) {
echo "$argv[0] requires PHP extension $ext.\n"; echo "$argv[0] requires PHP extension $ext.\n";
exit(1); exit(1);
} }
} }
function command_include($file) function command_include($file)
{ {
$file = 'phar://' . __FILE__ . '/' . $file; $file = 'phar://' . __FILE__ . '/' . $file;
if (file_exists($file)) { if (file_exists($file)) {
include($file); include($file);
} }
} }
function command_autoload($classname) function command_autoload($classname)
{ {
command_include(strtolower($classname) . '.inc'); command_include(strtolower($classname) . '.inc');
} }
Phar::mapPhar(); Phar::mapPhar();

View file

@ -96,7 +96,7 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess
*/ */
public function offsetExists($entry) {} public function offsetExists($entry) {}
/** /**
* @param string $entry * @param string $entry
* @return PharFileInfo * @return PharFileInfo
*/ */
@ -130,7 +130,7 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess
/** @return void */ /** @return void */
public function setSignatureAlgorithm(int $algorithm, string $privatekey = UNKNOWN) {} public function setSignatureAlgorithm(int $algorithm, string $privatekey = UNKNOWN) {}
/** /**
* @param resource $newstub * @param resource $newstub
* @return bool * @return bool
*/ */
@ -318,7 +318,7 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc
/** @return void */ /** @return void */
public function setSignatureAlgorithm(int $algorithm, string $privatekey = UNKNOWN) {} public function setSignatureAlgorithm(int $algorithm, string $privatekey = UNKNOWN) {}
/** /**
* @param resource $newstub * @param resource $newstub
* @return bool * @return bool
*/ */

View file

@ -78,43 +78,43 @@ function snmp_read_mib(string $filename): bool {}
class SNMP class SNMP
{ {
function __construct(int $version, string $host, string $community, int $timeout = UNKNOWN, int $retries = UNKNOWN) {} function __construct(int $version, string $host, string $community, int $timeout = UNKNOWN, int $retries = UNKNOWN) {}
/** @return bool */ /** @return bool */
function close() {} function close() {}
/** @return bool */ /** @return bool */
function setSecurity(string $sec_level, string $auth_protocol = '', string $auth_passphrase = '', string $priv_protocol = '', string $priv_passphrase = '', string $contextName = '', string $contextEngineID = '') {} function setSecurity(string $sec_level, string $auth_protocol = '', string $auth_passphrase = '', string $priv_protocol = '', string $priv_passphrase = '', string $contextName = '', string $contextEngineID = '') {}
/** /**
* @param array|string $object_id * @param array|string $object_id
* @return array|bool * @return array|bool
*/ */
function get($object_id, bool $use_orignames = false) {} function get($object_id, bool $use_orignames = false) {}
/** /**
* @param array|string $object_id * @param array|string $object_id
* @return array|bool * @return array|bool
*/ */
function getnext($object_id) {} function getnext($object_id) {}
/** /**
* @param array|string $object_id * @param array|string $object_id
* @return array|bool * @return array|bool
*/ */
function walk($object_id, bool $suffix_keys = false, int $max_repetitions = UNKNOWN, int $non_repeaters = UNKNOWN) {} function walk($object_id, bool $suffix_keys = false, int $max_repetitions = UNKNOWN, int $non_repeaters = UNKNOWN) {}
/** /**
* @param array|string $object_id * @param array|string $object_id
* @param array|string $type * @param array|string $type
* @param array|string $value * @param array|string $value
* @return array|bool * @return array|bool
*/ */
function set($object_id, $type, $value) {} function set($object_id, $type, $value) {}
/** @return int */ /** @return int */
function getErrno() {} function getErrno() {}
/** @return string */ /** @return string */
function getError() {} function getError() {}
} }

View file

@ -5,8 +5,8 @@ $z->open('a.zip', ZIPARCHIVE::CREATE);
/* or 'remove_all_path' => 0*/ /* or 'remove_all_path' => 0*/
$options = array( $options = array(
'remove_path' => '/home/francis/myimages', 'remove_path' => '/home/francis/myimages',
'add_path' => 'images/', 'add_path' => 'images/',
); );
$found = $z->addGlob("/home/pierre/cvs/gd/libgd/tests/*.png", 0, $options); $found = $z->addGlob("/home/pierre/cvs/gd/libgd/tests/*.png", 0, $options);
var_dump($found); var_dump($found);

View file

@ -9,9 +9,9 @@ $zip = new ZipArchive();
$filename = "./test112.zip"; $filename = "./test112.zip";
if (!$zip->open($filename, ZIPARCHIVE::CREATE)) { if (!$zip->open($filename, ZIPARCHIVE::CREATE)) {
exit("cannot open <$filename>\n"); exit("cannot open <$filename>\n");
} else { } else {
echo "file <$filename> OK\n"; echo "file <$filename> OK\n";
} }
$zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n"); $zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n");

View file

@ -15,7 +15,7 @@ echo "filename: " . $za->filename . "\n";
echo "comment: " . $za->comment . "\n"; echo "comment: " . $za->comment . "\n";
for ($i=0; $i<$za->numFiles;$i++) { for ($i=0; $i<$za->numFiles;$i++) {
echo "index: $i\n"; echo "index: $i\n";
print_r($za->statIndex($i)); print_r($za->statIndex($i));
} }
echo "numFile:" . $za->numFiles . "\n"; echo "numFile:" . $za->numFiles . "\n";

View file

@ -40,9 +40,9 @@ $zip->close();
echo "== Stream with context\n"; echo "== Stream with context\n";
$ctx = stream_context_create(array( $ctx = stream_context_create(array(
'zip' => array( 'zip' => array(
'password' => $pass 'password' => $pass
) )
)); ));
$text = file_get_contents("zip://$name#$file", false, $ctx); $text = file_get_contents("zip://$name#$file", false, $ctx);
printf("Size = %d\n", strlen($text)); printf("Size = %d\n", strlen($text));

View file

@ -19,9 +19,9 @@ echo $zip->filename . "\n";
var_dump($zip); var_dump($zip);
$files = array('test', 'testdir/test2'); $files = array('test', 'testdir/test2');
if (!$zip->extractTo("./testext/path/to", $files)) { if (!$zip->extractTo("./testext/path/to", $files)) {
echo "error!\n"; echo "error!\n";
echo $zip->status . "\n"; echo $zip->status . "\n";
echo $zip->statusSys . "\n"; echo $zip->statusSys . "\n";
} }

View file

@ -15,9 +15,9 @@ echo $zip->filename . "\n";
var_dump($zip); var_dump($zip);
$files = array('test', 'testdir/test2'); $files = array('test', 'testdir/test2');
if (!$zip->extractTo("./testext/path/to")) { if (!$zip->extractTo("./testext/path/to")) {
echo "error!\n"; echo "error!\n";
echo $zip->status . "\n"; echo $zip->status . "\n";
echo $zip->statusSys . "\n"; echo $zip->statusSys . "\n";
} }

View file

@ -6,11 +6,11 @@ if (!extension_loaded('zip')) {
$fp = fopen('zip://' . dirname(__FILE__) . '/test.zip#test', 'r'); $fp = fopen('zip://' . dirname(__FILE__) . '/test.zip#test', 'r');
if (!$fp) { if (!$fp) {
exit("cannot open\n"); exit("cannot open\n");
} }
while (!feof($fp)) { while (!feof($fp)) {
$contents .= fread($fp, 2); $contents .= fread($fp, 2);
echo "$contents\n"; echo "$contents\n";
} }
fclose($fp); fclose($fp);
@ -25,7 +25,7 @@ $fp = $z->getStream('test');
var_dump($fp); var_dump($fp);
if(!$fp) exit("\n"); if(!$fp) exit("\n");
while (!feof($fp)) { while (!feof($fp)) {
$contents .= fread($fp, 2); $contents .= fread($fp, 2);
} }
fclose($fp); fclose($fp);

View file

@ -7,9 +7,9 @@ $z->open('t.zip');
print_r($z); print_r($z);
for ($i=0; $i<$z->numFiles; $i++) { for ($i=0; $i<$z->numFiles; $i++) {
echo "index: $i\n"; echo "index: $i\n";
print_r($z->getCommentIndex($i)); print_r($z->getCommentIndex($i));
echo "\n\n"; echo "\n\n";
} }
echo "foobar/ " . $z->getCommentName('foobar/') . "\n"; echo "foobar/ " . $z->getCommentName('foobar/') . "\n";
@ -22,9 +22,9 @@ $z->setCommentName('foobar/', 'new comment foobar/');
$z->setArchiveComment( 'new archive comment'); $z->setArchiveComment( 'new archive comment');
for ($i=0; $i<$z->numFiles; $i++) { for ($i=0; $i<$z->numFiles; $i++) {
echo "index: $i\n"; echo "index: $i\n";
print_r($z->getCommentIndex($i)); print_r($z->getCommentIndex($i));
echo "\n\n"; echo "\n\n";
} }
echo $z->getCommentName('foobar/') . "\n"; echo $z->getCommentName('foobar/') . "\n";

View file

@ -5,16 +5,16 @@ $reader = new XMLReader();
$reader->open('zip://' . dirname(__FILE__) . '/test.odt#meta.xml'); $reader->open('zip://' . dirname(__FILE__) . '/test.odt#meta.xml');
$odt_meta = array(); $odt_meta = array();
while ($reader->read()) { while ($reader->read()) {
if ($reader->nodeType == XMLREADER::ELEMENT) { if ($reader->nodeType == XMLREADER::ELEMENT) {
$elm = $reader->name; $elm = $reader->name;
} else { } else {
if ($reader->nodeType == XMLREADER::END_ELEMENT && $reader->name == 'office:meta') { if ($reader->nodeType == XMLREADER::END_ELEMENT && $reader->name == 'office:meta') {
break; break;
} }
if (!trim($reader->value)) { if (!trim($reader->value)) {
continue; continue;
} }
$odt_meta[$elm] = $reader->value; $odt_meta[$elm] = $reader->value;
} }
} }
print_r($odt_meta); print_r($odt_meta);

View file

@ -4,14 +4,14 @@ $zip = zip_open('examples/test1.zip');
var_dump($zip); var_dump($zip);
if ($zip) { if ($zip) {
$i = 0; $i = 0;
while ($zip_entry = zip_read($zip)) { while ($zip_entry = zip_read($zip)) {
var_dump($zip_entry); var_dump($zip_entry);
$txt = zip_entry_read($zip_entry, 10); $txt = zip_entry_read($zip_entry, 10);
echo $i . ": " . $txt . "size: " . zip_entry_filesize($zip_entry) . echo $i . ": " . $txt . "size: " . zip_entry_filesize($zip_entry) .
"comp_method: " . zip_entry_compressionmethod($zip_entry) . "comp_method: " . zip_entry_compressionmethod($zip_entry) .
"\n"; "\n";
$i++; $i++;
} }
var_dump($zip_entry); var_dump($zip_entry);
} }

View file

@ -8,7 +8,7 @@ $zip = new ZipArchive();
$filename = "a.zip"; $filename = "a.zip";
if (!$zip->open($filename, ZIPARCHIVE::CREATE | ZipArchive::OVERWRITE)) { if (!$zip->open($filename, ZIPARCHIVE::CREATE | ZipArchive::OVERWRITE)) {
exit("cannot open <$filename>\n"); exit("cannot open <$filename>\n");
} }
$zip->addFromString("testfilephp.txt", "#1 This is a test string added as testfilephp.txt.\n"); $zip->addFromString("testfilephp.txt", "#1 This is a test string added as testfilephp.txt.\n");

View file

@ -571,7 +571,7 @@ void _php_import_environment_variables(zval *array_ptr)
php_register_variable_quick(*env, name_len, &val, Z_ARRVAL_P(array_ptr)); php_register_variable_quick(*env, name_len, &val, Z_ARRVAL_P(array_ptr));
} }
} }
tsrm_env_unlock(); tsrm_env_unlock();
} }

File diff suppressed because it is too large Load diff

View file

@ -8,36 +8,36 @@ $source = count($_SERVER['argv']) > 1 ? $_SERVER['argv'][1] : 'https://raw.githu
// See if we can actually load it. // See if we can actually load it.
$types = @file($source); $types = @file($source);
if ($types === false) { if ($types === false) {
fprintf(STDERR, "Error: unable to read $source\n"); fprintf(STDERR, "Error: unable to read $source\n");
exit(1); exit(1);
} }
// Remove comments and flip into an extensions array. // Remove comments and flip into an extensions array.
$extensions = []; $extensions = [];
array_walk($types, function ($line) use (&$extensions) { array_walk($types, function ($line) use (&$extensions) {
$line = trim($line); $line = trim($line);
if ($line && $line[0] != '#') { if ($line && $line[0] != '#') {
$fields = preg_split('/\s+/', $line); $fields = preg_split('/\s+/', $line);
if (count($fields) > 1) { if (count($fields) > 1) {
$mime = array_shift($fields); $mime = array_shift($fields);
foreach ($fields as $extension) { foreach ($fields as $extension) {
$extensions[$extension] = $mime; $extensions[$extension] = $mime;
} }
} }
} }
}); });
$additional_mime_maps = [ $additional_mime_maps = [
"map" => "application/json", // from commit: a0d62f08ae8cbebc88e5c92e08fca8d0cdc7309d "map" => "application/json", // from commit: a0d62f08ae8cbebc88e5c92e08fca8d0cdc7309d
"jsm" => "application/javascript", "jsm" => "application/javascript",
]; ];
foreach($additional_mime_maps as $ext => $mime) { foreach($additional_mime_maps as $ext => $mime) {
if (!isset($extensions[$ext])) { if (!isset($extensions[$ext])) {
$extensions[$ext] = $mime; $extensions[$ext] = $mime;
} else { } else {
printf(STDERR, "Ignored exist mime type: $ext => $mime\n"); printf(STDERR, "Ignored exist mime type: $ext => $mime\n");
} }
} }
?> ?>
@ -64,15 +64,15 @@ foreach($additional_mime_maps as $ext => $mime) {
#define PHP_CLI_SERVER_MIME_TYPE_MAP_H #define PHP_CLI_SERVER_MIME_TYPE_MAP_H
typedef struct php_cli_server_ext_mime_type_pair { typedef struct php_cli_server_ext_mime_type_pair {
const char *ext; const char *ext;
const char *mime_type; const char *mime_type;
} php_cli_server_ext_mime_type_pair; } php_cli_server_ext_mime_type_pair;
static const php_cli_server_ext_mime_type_pair mime_type_map[] = { static const php_cli_server_ext_mime_type_pair mime_type_map[] = {
<?php foreach ($extensions as $extension => $mime): ?> <?php foreach ($extensions as $extension => $mime): ?>
{ "<?= addcslashes($extension, "\0..\37!@\@\177..\377") ?>", "<?= addcslashes($mime, "\0..\37!@\@\177..\377") ?>" }, { "<?= addcslashes($extension, "\0..\37!@\@\177..\377") ?>", "<?= addcslashes($mime, "\0..\37!@\@\177..\377") ?>" },
<?php endforeach ?> <?php endforeach ?>
{ NULL, NULL } { NULL, NULL }
}; };
#endif /* PHP_CLI_SERVER_MIME_TYPE_MAP_H */ #endif /* PHP_CLI_SERVER_MIME_TYPE_MAP_H */

View file

@ -30,37 +30,37 @@ $file = "";
$cmdargv = ""; $cmdargv = "";
if (isset($argc) && $argc > 1) { if (isset($argc) && $argc > 1) {
$post_ddash = false; $post_ddash = false;
for ($i = 1; $i < $argc; $i++) { for ($i = 1; $i < $argc; $i++) {
if ($argv[$i][0] == "-" && !$post_ddash) { if ($argv[$i][0] == "-" && !$post_ddash) {
switch (substr($argv[$i], 1)) { switch (substr($argv[$i], 1)) {
case "p": case "p":
$phpdbg = $argv[++$i]; $phpdbg = $argv[++$i];
break; break;
case "n": case "n":
$pass_options .= " -n"; $pass_options .= " -n";
break; break;
case "d": case "d":
$pass_options .= " -d ".escapeshellarg($argv[++$i]); $pass_options .= " -d ".escapeshellarg($argv[++$i]);
$ini[] = $argv[$i]; $ini[] = $argv[$i];
break; break;
case "-": case "-":
$post_ddash = true; $post_ddash = true;
break; break;
} }
} else { } else {
$real_argv[] = $argv[$i]; $real_argv[] = $argv[$i];
} }
} }
if (isset($real_argv[0])) { if (isset($real_argv[0])) {
$file = realpath($real_argv[0]); $file = realpath($real_argv[0]);
$cmdargv = implode(" ", array_map("escapeshellarg", array_slice($real_argv, 1))); $cmdargv = implode(" ", array_map("escapeshellarg", array_slice($real_argv, 1)));
} }
} }
$proc = proc_open("$phpdbg $pass_options $file -- $cmdargv", [["pipe", "r"], ["pipe", "w"], ["pipe", "w"]], $pipes); $proc = proc_open("$phpdbg $pass_options $file -- $cmdargv", [["pipe", "r"], ["pipe", "w"], ["pipe", "w"]], $pipes);
if (!$proc) { if (!$proc) {
die("Couldn't start phpdbg\n"); die("Couldn't start phpdbg\n");
} }
$input = $output = ""; $input = $output = "";
@ -68,47 +68,47 @@ $input = $output = "";
stream_set_blocking(STDIN, false); stream_set_blocking(STDIN, false);
do { do {
$r = [$pipes[1], STDIN]; $r = [$pipes[1], STDIN];
$w = $e = null; $w = $e = null;
$n = @stream_select($r, $w, $e, null); $n = @stream_select($r, $w, $e, null);
if ($n > 0) { if ($n > 0) {
if ("" != $in = fread(STDIN, 1024)) { if ("" != $in = fread(STDIN, 1024)) {
$input .= $in; $input .= $in;
fwrite($pipes[0], $in); fwrite($pipes[0], $in);
continue; continue;
} }
if (feof(STDIN)) { if (feof(STDIN)) {
die("stdin closed?!\n"); die("stdin closed?!\n");
} }
if (feof($pipes[1])) { if (feof($pipes[1])) {
$n = false; $n = false;
} else { } else {
$output .= $c = fgetc($pipes[1]); $output .= $c = fgetc($pipes[1]);
echo $c; echo $c;
} }
} }
} while ($n !== false); } while ($n !== false);
stream_set_blocking(STDIN, true); stream_set_blocking(STDIN, true);
print "\n"; print "\n";
if (!isset($name)) { if (!isset($name)) {
print "Specify the test description: "; print "Specify the test description: ";
$desc = trim(fgets(STDIN)); $desc = trim(fgets(STDIN));
} }
while (!isset($testfile)) { while (!isset($testfile)) {
print "Specify the test file name (leave empty to write to stderr): "; print "Specify the test file name (leave empty to write to stderr): ";
$testfile = trim(fgets(STDIN)); $testfile = trim(fgets(STDIN));
if ($testfile != "" && file_exists($testfile)) { if ($testfile != "" && file_exists($testfile)) {
print "That file already exists. Type y or yes to overwrite: "; print "That file already exists. Type y or yes to overwrite: ";
$y = trim(fgets(STDIN)); $y = trim(fgets(STDIN));
if ($y !== "y" && $y !== "yes") { if ($y !== "y" && $y !== "yes") {
unset($testfile); unset($testfile);
} }
} }
} }
$output = str_replace("string(".strlen($file).") \"$file\"", 'string(%d) "%s"', $output); $output = str_replace("string(".strlen($file).") \"$file\"", 'string(%d) "%s"', $output);
@ -125,24 +125,24 @@ $output
TEST; TEST;
if (!empty($ini)) { if (!empty($ini)) {
$testdata .= "\n--INI--\n".implode("\n", $ini); $testdata .= "\n--INI--\n".implode("\n", $ini);
} }
if ($cmdargv != "") { if ($cmdargv != "") {
$testdata .= "\n--ARGS--\n$cmdargv"; $testdata .= "\n--ARGS--\n$cmdargv";
} }
if ($file != "") { if ($file != "") {
$testdata .= "\n--FILE--\n".file_get_contents($file); $testdata .= "\n--FILE--\n".file_get_contents($file);
} }
if ($testfile == "") { if ($testfile == "") {
print "\n"; print "\n";
} elseif (file_put_contents($testfile, $testdata)) { } elseif (file_put_contents($testfile, $testdata)) {
print "Test saved to $testfile\n"; print "Test saved to $testfile\n";
} else { } else {
print "The test could not be saved to $testfile; outputting on stderr now\n"; print "The test could not be saved to $testfile; outputting on stderr now\n";
$testfile = ""; $testfile = "";
} }
if ($testfile == "") { if ($testfile == "") {
fwrite(STDERR, $testdata); fwrite(STDERR, $testdata);
} }

View file

@ -196,19 +196,19 @@ PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str) /* {{{ */
"%sbreak at %s#%ld if %s\n", "%sbreak at %s#%ld if %s\n",
*str, conditional->param.str, conditional->param.num, conditional->code); *str, conditional->param.str, conditional->param.num, conditional->code);
break; break;
case NUMERIC_METHOD_PARAM: case NUMERIC_METHOD_PARAM:
phpdbg_asprintf(&new_str, phpdbg_asprintf(&new_str,
"%sbreak at %s::%s#%ld if %s\n", "%sbreak at %s::%s#%ld if %s\n",
*str, conditional->param.method.class, conditional->param.method.name, conditional->param.num, conditional->code); *str, conditional->param.method.class, conditional->param.method.name, conditional->param.num, conditional->code);
break; break;
case ADDR_PARAM: case ADDR_PARAM:
phpdbg_asprintf(&new_str, phpdbg_asprintf(&new_str,
"%sbreak at 0X%lx if %s\n", "%sbreak at 0X%lx if %s\n",
*str, conditional->param.addr, conditional->code); *str, conditional->param.addr, conditional->code);
break; break;
case STR_PARAM: case STR_PARAM:
phpdbg_asprintf(&new_str, phpdbg_asprintf(&new_str,
"%sbreak at %s if %s\n", *str, conditional->param.str, conditional->code); "%sbreak at %s if %s\n", *str, conditional->param.str, conditional->code);
@ -839,7 +839,7 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co
case ADDR_PARAM: case ADDR_PARAM:
/* do nothing */ /* do nothing */
break; break;
default: default:
phpdbg_error("eval", "type=\"invalidparameter\"", "Invalid parameter type for conditional breakpoint"); phpdbg_error("eval", "type=\"invalidparameter\"", "Invalid parameter type for conditional breakpoint");
return; return;
@ -855,10 +855,10 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co
if (new_break.param.type == FILE_PARAM || if (new_break.param.type == FILE_PARAM ||
new_break.param.type == NUMERIC_FILE_PARAM) { new_break.param.type == NUMERIC_FILE_PARAM) {
char realpath[MAXPATHLEN]; char realpath[MAXPATHLEN];
if (VCWD_REALPATH(new_break.param.file.name, realpath)) { if (VCWD_REALPATH(new_break.param.file.name, realpath)) {
efree(new_break.param.file.name); efree(new_break.param.file.name);
new_break.param.file.name = estrdup(realpath); new_break.param.file.name = estrdup(realpath);
} else { } else {
phpdbg_error("eval", "type=\"invalidparameter\"", "Invalid file for conditional break %s", new_break.param.file.name); phpdbg_error("eval", "type=\"invalidparameter\"", "Invalid file for conditional break %s", new_break.param.file.name);

View file

@ -1,35 +1,35 @@
<?php <?php
if (isset($include)) { if (isset($include)) {
include (sprintf("%s/web-bootstrap.php", dirname(__FILE__))); include (sprintf("%s/web-bootstrap.php", dirname(__FILE__)));
} }
$stdout = fopen("php://stdout", "w+"); $stdout = fopen("php://stdout", "w+");
class phpdbg { class phpdbg {
private $sprintf = "%s: %s\n"; private $sprintf = "%s: %s\n";
public function isGreat($greeting = null) { public function isGreat($greeting = null) {
printf($this->sprintf, __METHOD__, $greeting); printf($this->sprintf, __METHOD__, $greeting);
return $this; return $this;
} }
} }
function mine() { function mine() {
var_dump(func_get_args()); var_dump(func_get_args());
} }
function test($x, $y = 0) { function test($x, $y = 0) {
$var = $x + 1; $var = $x + 1;
$var += 2; $var += 2;
$var <<= 3; $var <<= 3;
$foo = function () { $foo = function () {
echo "bar!\n"; echo "bar!\n";
}; };
$foo(); $foo();
yield $var; yield $var;
} }
$dbg = new phpdbg(); $dbg = new phpdbg();
@ -38,43 +38,43 @@ var_dump(
$dbg->isGreat("PHP Rocks!!")); $dbg->isGreat("PHP Rocks!!"));
foreach (test(1,2) as $gen) foreach (test(1,2) as $gen)
continue; continue;
echo "it works!\n"; echo "it works!\n";
if (isset($dump)) if (isset($dump))
var_dump($_SERVER); var_dump($_SERVER);
function phpdbg_test_ob() function phpdbg_test_ob()
{ {
echo 'Start'; echo 'Start';
ob_start(); ob_start();
echo 'Hello'; echo 'Hello';
$b = ob_get_clean(); $b = ob_get_clean();
echo 'End'; echo 'End';
echo $b; echo $b;
} }
$array = [ $array = [
1, 1,
2, 2,
[3, 4], [3, 4],
[5, 6], [5, 6],
]; ];
$array[] = 7; $array[] = 7;
array_walk($array, function (&$item) { array_walk($array, function (&$item) {
if (is_array($item)) if (is_array($item))
$item[0] += 2; $item[0] += 2;
else else
$item -= 1; $item -= 1;
}); });
class testClass { class testClass {
public $a = 2; public $a = 2;
protected $b = [1, 3]; protected $b = [1, 3];
private $c = 7; private $c = 7;
} }
$obj = new testClass; $obj = new testClass;

View file

@ -29,349 +29,349 @@ ini_set('pcre.backtrack_limit', 10000000);
$API_params = array( $API_params = array(
'a' => array('zval**'), // array 'a' => array('zval**'), // array
'A' => array('zval**'), // array or object 'A' => array('zval**'), // array or object
'b' => array('zend_bool*'), // boolean 'b' => array('zend_bool*'), // boolean
'd' => array('double*'), // double 'd' => array('double*'), // double
'f' => array('zend_fcall_info*', 'zend_fcall_info_cache*'), // function 'f' => array('zend_fcall_info*', 'zend_fcall_info_cache*'), // function
'h' => array('HashTable**'), // array as an HashTable* 'h' => array('HashTable**'), // array as an HashTable*
'H' => array('HashTable**'), // array or HASH_OF(object) 'H' => array('HashTable**'), // array or HASH_OF(object)
'l' => array('zend_long*'), // long 'l' => array('zend_long*'), // long
//TODO 'L' => array('zend_long*, '), // long //TODO 'L' => array('zend_long*, '), // long
'o' => array('zval**'), //object 'o' => array('zval**'), //object
'O' => array('zval**', 'zend_class_entry*'), // object of given type 'O' => array('zval**', 'zend_class_entry*'), // object of given type
'P' => array('zend_string**'), // valid path 'P' => array('zend_string**'), // valid path
'r' => array('zval**'), // resource 'r' => array('zval**'), // resource
'S' => array('zend_string**'), // string 'S' => array('zend_string**'), // string
'z' => array('zval**'), // zval* 'z' => array('zval**'), // zval*
'Z' => array('zval***') // zval** 'Z' => array('zval***') // zval**
// 's', 'p', 'C' handled separately // 's', 'p', 'C' handled separately
); );
/** reports an error, according to its level */ /** reports an error, according to its level */
function error($str, $level = 0) function error($str, $level = 0)
{ {
global $current_file, $current_function, $line; global $current_file, $current_function, $line;
if ($level <= REPORT_LEVEL) { if ($level <= REPORT_LEVEL) {
if (strpos($current_file,PHPDIR) === 0) { if (strpos($current_file,PHPDIR) === 0) {
$filename = substr($current_file, strlen(PHPDIR)+1); $filename = substr($current_file, strlen(PHPDIR)+1);
} else { } else {
$filename = $current_file; $filename = $current_file;
} }
echo $filename , " [$line] $current_function : $str\n"; echo $filename , " [$line] $current_function : $str\n";
} }
} }
/** this updates the global var $line (for error reporting) */ /** this updates the global var $line (for error reporting) */
function update_lineno($offset) function update_lineno($offset)
{ {
global $lines_offset, $line; global $lines_offset, $line;
$left = 0; $left = 0;
$right = $count = count($lines_offset)-1; $right = $count = count($lines_offset)-1;
// a nice binary search :) // a nice binary search :)
do { do {
$mid = intval(($left + $right)/2); $mid = intval(($left + $right)/2);
$val = $lines_offset[$mid]; $val = $lines_offset[$mid];
if ($val < $offset) { if ($val < $offset) {
if (++$mid > $count || $lines_offset[$mid] > $offset) { if (++$mid > $count || $lines_offset[$mid] > $offset) {
$line = $mid; $line = $mid;
return; return;
} else { } else {
$left = $mid; $left = $mid;
} }
} else if ($val > $offset) { } else if ($val > $offset) {
if ($lines_offset[--$mid] < $offset) { if ($lines_offset[--$mid] < $offset) {
$line = $mid+1; $line = $mid+1;
return; return;
} else { } else {
$right = $mid; $right = $mid;
} }
} else { } else {
$line = $mid+1; $line = $mid+1;
return; return;
} }
} while (true); } while (true);
} }
/** parses the sources and fetches its vars name, type and if they are initialized or not */ /** parses the sources and fetches its vars name, type and if they are initialized or not */
function get_vars($txt) function get_vars($txt)
{ {
$ret = array(); $ret = array();
preg_match_all('/((?:(?:unsigned|struct)\s+)?\w+)(?:\s*(\*+)\s+|\s+(\**))(\w+(?:\[\s*\w*\s*\])?)\s*(?:(=)[^,;]+)?((?:\s*,\s*\**\s*\w+(?:\[\s*\w*\s*\])?\s*(?:=[^,;]+)?)*)\s*;/S', $txt, $m, PREG_SET_ORDER); preg_match_all('/((?:(?:unsigned|struct)\s+)?\w+)(?:\s*(\*+)\s+|\s+(\**))(\w+(?:\[\s*\w*\s*\])?)\s*(?:(=)[^,;]+)?((?:\s*,\s*\**\s*\w+(?:\[\s*\w*\s*\])?\s*(?:=[^,;]+)?)*)\s*;/S', $txt, $m, PREG_SET_ORDER);
foreach ($m as $x) { foreach ($m as $x) {
// the first parameter is special // the first parameter is special
if (!in_array($x[1], array('else', 'endif', 'return'))) // hack to skip reserved words if (!in_array($x[1], array('else', 'endif', 'return'))) // hack to skip reserved words
$ret[$x[4]] = array($x[1] . $x[2] . $x[3], $x[5]); $ret[$x[4]] = array($x[1] . $x[2] . $x[3], $x[5]);
// are there more vars? // are there more vars?
if ($x[6]) { if ($x[6]) {
preg_match_all('/(\**)\s*(\w+(?:\[\s*\w*\s*\])?)\s*(=?)/S', $x[6], $y, PREG_SET_ORDER); preg_match_all('/(\**)\s*(\w+(?:\[\s*\w*\s*\])?)\s*(=?)/S', $x[6], $y, PREG_SET_ORDER);
foreach ($y as $z) { foreach ($y as $z) {
$ret[$z[2]] = array($x[1] . $z[1], $z[3]); $ret[$z[2]] = array($x[1] . $z[1], $z[3]);
} }
} }
} }
// if ($GLOBALS['current_function'] == 'for_debugging') { print_r($m);print_r($ret); } // if ($GLOBALS['current_function'] == 'for_debugging') { print_r($m);print_r($ret); }
return $ret; return $ret;
} }
/** run diagnostic checks against one var. */ /** run diagnostic checks against one var. */
function check_param($db, $idx, $exp, $optional, $allow_uninit = false) function check_param($db, $idx, $exp, $optional, $allow_uninit = false)
{ {
global $error_few_vars_given; global $error_few_vars_given;
if ($idx >= count($db)) { if ($idx >= count($db)) {
if (!$error_few_vars_given) { if (!$error_few_vars_given) {
error("too few variables passed to function"); error("too few variables passed to function");
$error_few_vars_given = true; $error_few_vars_given = true;
} }
return; return;
} elseif ($db[$idx][0] === '**dummy**') { } elseif ($db[$idx][0] === '**dummy**') {
return; return;
} }
if ($db[$idx][1] != $exp) { if ($db[$idx][1] != $exp) {
error("{$db[$idx][0]}: expected '$exp' but got '{$db[$idx][1]}' [".($idx+1).']'); error("{$db[$idx][0]}: expected '$exp' but got '{$db[$idx][1]}' [".($idx+1).']');
} }
if (!$optional && $db[$idx][2]) { if (!$optional && $db[$idx][2]) {
error("not optional var is initialized: {$db[$idx][0]} [".($idx+1).']', 2); error("not optional var is initialized: {$db[$idx][0]} [".($idx+1).']', 2);
} }
if (!$allow_uninit && $optional && !$db[$idx][2]) { if (!$allow_uninit && $optional && !$db[$idx][2]) {
error("optional var not initialized: {$db[$idx][0]} [".($idx+1).']', 1); error("optional var not initialized: {$db[$idx][0]} [".($idx+1).']', 1);
} }
} }
/** fetch params passed to zend_parse_params*() */ /** fetch params passed to zend_parse_params*() */
function get_params($vars, $str) function get_params($vars, $str)
{ {
$ret = array(); $ret = array();
preg_match_all('/(?:\([^)]+\))?(&?)([\w>.()-]+(?:\[\w+\])?)\s*,?((?:\)*\s*=)?)/S', $str, $m, PREG_SET_ORDER); preg_match_all('/(?:\([^)]+\))?(&?)([\w>.()-]+(?:\[\w+\])?)\s*,?((?:\)*\s*=)?)/S', $str, $m, PREG_SET_ORDER);
foreach ($m as $x) { foreach ($m as $x) {
$name = $x[2]; $name = $x[2];
// little hack for last parameter // little hack for last parameter
if (strpos($name, '(') === false) { if (strpos($name, '(') === false) {
$name = rtrim($name, ')'); $name = rtrim($name, ')');
} }
if (empty($vars[$name][0])) { if (empty($vars[$name][0])) {
error("variable not found: '$name'", 3); error("variable not found: '$name'", 3);
$ret[][] = '**dummy**'; $ret[][] = '**dummy**';
} else { } else {
$ret[] = array($name, $vars[$name][0] . ($x[1] ? '*' : ''), $vars[$name][1]); $ret[] = array($name, $vars[$name][0] . ($x[1] ? '*' : ''), $vars[$name][1]);
} }
// the end (yes, this is a little hack :P) // the end (yes, this is a little hack :P)
if ($x[3]) { if ($x[3]) {
break; break;
} }
} }
// if ($GLOBALS['current_function'] == 'for_debugging') { var_dump($m); var_dump($ret); } // if ($GLOBALS['current_function'] == 'for_debugging') { var_dump($m); var_dump($ret); }
return $ret; return $ret;
} }
/** run tests on a function. the code is passed in $txt */ /** run tests on a function. the code is passed in $txt */
function check_function($name, $txt, $offset) function check_function($name, $txt, $offset)
{ {
global $API_params; global $API_params;
$regex = '/ $regex = '/
(?: zend_parse_parameters(?:_throw)? \s*\([^,]+ (?: zend_parse_parameters(?:_throw)? \s*\([^,]+
| zend_parse_(?:parameters_ex|method_parameters) \s*\([^,]+,[^,]+ | zend_parse_(?:parameters_ex|method_parameters) \s*\([^,]+,[^,]+
| zend_parse_method_parameters_ex \s*\([^,]+,[^,]+,[^,+] | zend_parse_method_parameters_ex \s*\([^,]+,[^,]+,[^,+]
) )
,\s*"([^"]*)"\s* ,\s*"([^"]*)"\s*
,\s*([^{;]*) ,\s*([^{;]*)
/Sx'; /Sx';
if (preg_match_all($regex, $txt, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { if (preg_match_all($regex, $txt, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
$GLOBALS['current_function'] = $name; $GLOBALS['current_function'] = $name;
foreach ($matches as $m) { foreach ($matches as $m) {
$GLOBALS['error_few_vars_given'] = false; $GLOBALS['error_few_vars_given'] = false;
update_lineno($offset + $m[2][1]); update_lineno($offset + $m[2][1]);
$vars = get_vars(substr($txt, 0, $m[0][1])); // limit var search to current location $vars = get_vars(substr($txt, 0, $m[0][1])); // limit var search to current location
$params = get_params($vars, $m[2][0]); $params = get_params($vars, $m[2][0]);
$optional = $varargs = false; $optional = $varargs = false;
$last_char = ''; $last_char = '';
$j = -1; $j = -1;
$spec = $m[1][0]; $spec = $m[1][0];
$len = strlen($spec); $len = strlen($spec);
for ($i = 0; $i < $len; ++$i) { for ($i = 0; $i < $len; ++$i) {
$char = $spec[$i]; $char = $spec[$i];
switch ($char = $spec[$i]) { switch ($char = $spec[$i]) {
// separator for optional parameters // separator for optional parameters
case '|': case '|':
if ($optional) { if ($optional) {
error("more than one optional separator at char #$i"); error("more than one optional separator at char #$i");
} else { } else {
$optional = true; $optional = true;
if ($i == $len-1) { if ($i == $len-1) {
error("unnecessary optional separator"); error("unnecessary optional separator");
} }
} }
break; break;
// separate_zval_if_not_ref // separate_zval_if_not_ref
case '/': case '/':
if (in_array($last_char, array('l', 'L', 'd', 'b'))) { if (in_array($last_char, array('l', 'L', 'd', 'b'))) {
error("the '/' specifier should not be applied to '$last_char'"); error("the '/' specifier should not be applied to '$last_char'");
} }
break; break;
// nullable arguments // nullable arguments
case '!': case '!':
if (in_array($last_char, array('l', 'L', 'd', 'b'))) { if (in_array($last_char, array('l', 'L', 'd', 'b'))) {
check_param($params, ++$j, 'zend_bool*', $optional); check_param($params, ++$j, 'zend_bool*', $optional);
} }
break; break;
// variadic arguments // variadic arguments
case '+': case '+':
case '*': case '*':
if ($varargs) { if ($varargs) {
error("A varargs specifier can only be used once. repeated char at column $i"); error("A varargs specifier can only be used once. repeated char at column $i");
} else { } else {
check_param($params, ++$j, 'zval**', $optional); check_param($params, ++$j, 'zval**', $optional);
check_param($params, ++$j, 'int*', $optional); check_param($params, ++$j, 'int*', $optional);
$varargs = true; $varargs = true;
} }
break; break;
case 's': case 's':
case 'p': case 'p':
check_param($params, ++$j, 'char**', $optional, $allow_uninit=true); check_param($params, ++$j, 'char**', $optional, $allow_uninit=true);
check_param($params, ++$j, 'size_t*', $optional, $allow_uninit=true); check_param($params, ++$j, 'size_t*', $optional, $allow_uninit=true);
if ($optional && !$params[$j-1][2] && !$params[$j][2] if ($optional && !$params[$j-1][2] && !$params[$j][2]
&& $params[$j-1][0] !== '**dummy**' && $params[$j][0] !== '**dummy**') { && $params[$j-1][0] !== '**dummy**' && $params[$j][0] !== '**dummy**') {
error("one of optional vars {$params[$j-1][0]} or {$params[$j][0]} must be initialized", 1); error("one of optional vars {$params[$j-1][0]} or {$params[$j][0]} must be initialized", 1);
} }
break; break;
case 'C': case 'C':
// C must always be initialized, independently of whether it's optional // C must always be initialized, independently of whether it's optional
check_param($params, ++$j, 'zend_class_entry**', false); check_param($params, ++$j, 'zend_class_entry**', false);
break; break;
default: default:
if (!isset($API_params[$char])) { if (!isset($API_params[$char])) {
error("unknown char ('$char') at column $i"); error("unknown char ('$char') at column $i");
} }
// If an is_null flag is in use, only that flag is required to be // If an is_null flag is in use, only that flag is required to be
// initialized // initialized
$allow_uninit = $i+1 < $len && $spec[$i+1] === '!' $allow_uninit = $i+1 < $len && $spec[$i+1] === '!'
&& in_array($char, array('l', 'L', 'd', 'b')); && in_array($char, array('l', 'L', 'd', 'b'));
foreach ($API_params[$char] as $exp) { foreach ($API_params[$char] as $exp) {
check_param($params, ++$j, $exp, $optional, $allow_uninit); check_param($params, ++$j, $exp, $optional, $allow_uninit);
} }
} }
$last_char = $char; $last_char = $char;
} }
} }
} }
} }
/** the main recursion function. splits files in functions and calls the other functions */ /** the main recursion function. splits files in functions and calls the other functions */
function recurse($path) function recurse($path)
{ {
foreach (scandir($path) as $file) { foreach (scandir($path) as $file) {
if ($file == '.' || $file == '..' || $file == 'CVS') continue; if ($file == '.' || $file == '..' || $file == 'CVS') continue;
$file = "$path/$file"; $file = "$path/$file";
if (is_dir($file)) { if (is_dir($file)) {
recurse($file); recurse($file);
continue; continue;
} }
// parse only .c and .cpp files // parse only .c and .cpp files
if (substr_compare($file, '.c', -2) && substr_compare($file, '.cpp', -4)) continue; if (substr_compare($file, '.c', -2) && substr_compare($file, '.cpp', -4)) continue;
$txt = file_get_contents($file); $txt = file_get_contents($file);
// remove comments (but preserve the number of lines) // remove comments (but preserve the number of lines)
$txt = preg_replace('@//.*@S', '', $txt); $txt = preg_replace('@//.*@S', '', $txt);
$txt = preg_replace_callback('@/\*.*\*/@SsU', function($matches) { $txt = preg_replace_callback('@/\*.*\*/@SsU', function($matches) {
return preg_replace("/[^\r\n]+/S", "", $matches[0]); return preg_replace("/[^\r\n]+/S", "", $matches[0]);
}, $txt); }, $txt);
$split = preg_split('/PHP_(?:NAMED_)?(?:FUNCTION|METHOD)\s*\((\w+(?:,\s*\w+)?)\)/S', $txt, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE); $split = preg_split('/PHP_(?:NAMED_)?(?:FUNCTION|METHOD)\s*\((\w+(?:,\s*\w+)?)\)/S', $txt, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE);
if (count($split) < 2) continue; // no functions defined on this file if (count($split) < 2) continue; // no functions defined on this file
array_shift($split); // the first part isn't relevant array_shift($split); // the first part isn't relevant
// generate the line offsets array // generate the line offsets array
$j = 0; $j = 0;
$lines = preg_split("/(\r\n?|\n)/S", $txt, -1, PREG_SPLIT_DELIM_CAPTURE); $lines = preg_split("/(\r\n?|\n)/S", $txt, -1, PREG_SPLIT_DELIM_CAPTURE);
$lines_offset = array(); $lines_offset = array();
for ($i = 0; $i < count($lines); ++$i) { for ($i = 0; $i < count($lines); ++$i) {
$j += strlen($lines[$i]) + strlen(@$lines[++$i]); $j += strlen($lines[$i]) + strlen(@$lines[++$i]);
$lines_offset[] = $j; $lines_offset[] = $j;
} }
$GLOBALS['lines_offset'] = $lines_offset; $GLOBALS['lines_offset'] = $lines_offset;
$GLOBALS['current_file'] = $file; $GLOBALS['current_file'] = $file;
for ($i = 0; $i < count($split); $i+=2) { for ($i = 0; $i < count($split); $i+=2) {
// if the /* }}} */ comment is found use it to reduce false positives // if the /* }}} */ comment is found use it to reduce false positives
// TODO: check the other indexes // TODO: check the other indexes
list($f) = preg_split('@/\*\s*}}}\s*\*/@S', $split[$i+1][0]); list($f) = preg_split('@/\*\s*}}}\s*\*/@S', $split[$i+1][0]);
check_function(preg_replace('/\s*,\s*/S', '::', $split[$i][0]), $f, $split[$i][1]); check_function(preg_replace('/\s*,\s*/S', '::', $split[$i][0]), $f, $split[$i][1]);
} }
} }
} }
$dirs = array(); $dirs = array();
if (isset($argc) && $argc > 1) { if (isset($argc) && $argc > 1) {
if ($argv[1] == '-h' || $argv[1] == '-help' || $argv[1] == '--help') { if ($argv[1] == '-h' || $argv[1] == '-help' || $argv[1] == '--help') {
echo <<<HELP echo <<<HELP
Synopsis: Synopsis:
php check_parameters.php [directories] php check_parameters.php [directories]
HELP; HELP;
exit(0); exit(0);
} }
for ($i = 1; $i < $argc; $i++) { for ($i = 1; $i < $argc; $i++) {
$dirs[] = $argv[$i]; $dirs[] = $argv[$i];
} }
} else { } else {
$dirs[] = PHPDIR; $dirs[] = PHPDIR;
} }
foreach($dirs as $dir) { foreach($dirs as $dir) {
if (is_dir($dir)) { if (is_dir($dir)) {
if (!is_readable($dir)) { if (!is_readable($dir)) {
echo "ERROR: directory '", $dir ,"' is not readable\n"; echo "ERROR: directory '", $dir ,"' is not readable\n";
exit(1); exit(1);
} }
} else { } else {
echo "ERROR: bogus directory '", $dir ,"'\n"; echo "ERROR: bogus directory '", $dir ,"'\n";
exit(1); exit(1);
} }
} }
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
recurse(realpath($dir)); recurse(realpath($dir));
} }

View file

@ -201,27 +201,27 @@ function get_phpt_files($dir, &$phpt_file_count, &$all_phpt)
* Extract tests from a specified file, returns an array of tested function tokens * Extract tests from a specified file, returns an array of tested function tokens
*/ */
function extract_tests($file) { function extract_tests($file) {
$code = file_get_contents($file); $code = file_get_contents($file);
if (!preg_match('/--FILE--\s*(.*)\s*--(EXPECTF|EXPECTREGEX|EXPECT)?--/is', $code, $r)) { if (!preg_match('/--FILE--\s*(.*)\s*--(EXPECTF|EXPECTREGEX|EXPECT)?--/is', $code, $r)) {
//print "Unable to get code in ".$file."\n"; //print "Unable to get code in ".$file."\n";
return array(); return array();
} }
$tokens = token_get_all($r[1]); $tokens = token_get_all($r[1]);
$functions = array_filter($tokens, 'filter_functions'); $functions = array_filter($tokens, 'filter_functions');
$functions = array_map( 'map_token_value',$functions); $functions = array_map( 'map_token_value',$functions);
$functions = array_unique($functions); $functions = array_unique($functions);
return $functions; return $functions;
} }
function filter_functions($x) { function filter_functions($x) {
return $x[0] == 307; return $x[0] == 307;
} }
function map_token_value($x) { function map_token_value($x) {
return $x[1]; return $x[1];
} }

View file

@ -32,38 +32,38 @@ $classes = array_merge(get_declared_classes(), get_declared_interfaces());
$extensions = array(); $extensions = array();
foreach(get_loaded_extensions() as $ext) { foreach(get_loaded_extensions() as $ext) {
$cnt_modules++; $cnt_modules++;
if (strpos($ext, "_") !== false) { if (strpos($ext, "_") !== false) {
$err++; $err++;
$extensions[$ext] = array(); $extensions[$ext] = array();
} }
} }
$cnt_classes = count($classes); $cnt_classes = count($classes);
foreach($classes as $c) { foreach($classes as $c) {
if (strpos($c, "_") !== false) { if (strpos($c, "_") !== false) {
$err++; $err++;
$ref = new ReflectionClass($c); $ref = new ReflectionClass($c);
if (!($ext = $ref->getExtensionName())) {; if (!($ext = $ref->getExtensionName())) {;
$ext = $ref->isInternal() ? "<internal>" : "<user>"; $ext = $ref->isInternal() ? "<internal>" : "<user>";
} }
if (!array_key_exists($ext, $extensions)) { if (!array_key_exists($ext, $extensions)) {
$extensions[$ext] = array(); $extensions[$ext] = array();
} }
$extensions[$ext][$c] = array(); $extensions[$ext][$c] = array();
foreach(get_class_methods($c) as $method) { foreach(get_class_methods($c) as $method) {
$cnt_methods++; $cnt_methods++;
if (strpos(substr($method, substr($method, 0, 2) != "__" ? 0 : 2), "_") !== false) { if (strpos(substr($method, substr($method, 0, 2) != "__" ? 0 : 2), "_") !== false) {
$err++; $err++;
$extensions[$ext][$c][] = $method; $extensions[$ext][$c][] = $method;
} }
} }
} }
else else
{ {
$cnt_methods += count(get_class_methods($c)); $cnt_methods += count(get_class_methods($c));
} }
} }
$cnt = $cnt_modules + $cnt_classes + $cnt_methods; $cnt = $cnt_modules + $cnt_classes + $cnt_methods;
@ -79,15 +79,15 @@ printf("\n");
ksort($extensions); ksort($extensions);
foreach($extensions as $ext => &$classes) { foreach($extensions as $ext => &$classes) {
echo "Extension: $ext\n"; echo "Extension: $ext\n";
ksort($classes); ksort($classes);
foreach($classes as $classname => &$methods) { foreach($classes as $classname => &$methods) {
echo " Class: $classname\n"; echo " Class: $classname\n";
ksort($methods); ksort($methods);
foreach($methods as $method) { foreach($methods as $method) {
echo " Method: $method\n"; echo " Method: $method\n";
} }
} }
} }
printf("\n"); printf("\n");

View file

@ -31,136 +31,136 @@ $pecl_dll_deps = array();
function get_depends($module) function get_depends($module)
{ {
static $no_dist = array( static $no_dist = array(
/* windows system dlls that should not be bundled */ /* windows system dlls that should not be bundled */
'advapi32.dll', 'comdlg32.dll', 'crypt32.dll', 'gdi32.dll', 'kernel32.dll', 'ntdll.dll', 'advapi32.dll', 'comdlg32.dll', 'crypt32.dll', 'gdi32.dll', 'kernel32.dll', 'ntdll.dll',
'odbc32.dll', 'ole32.dll', 'oleaut32.dll', 'rpcrt4.dll', 'odbc32.dll', 'ole32.dll', 'oleaut32.dll', 'rpcrt4.dll',
'shell32.dll', 'shlwapi.dll', 'user32.dll', 'ws2_32.dll', 'ws2help.dll', 'shell32.dll', 'shlwapi.dll', 'user32.dll', 'ws2_32.dll', 'ws2help.dll',
'comctl32.dll', 'winmm.dll', 'wsock32.dll', 'winspool.drv', 'msasn1.dll', 'comctl32.dll', 'winmm.dll', 'wsock32.dll', 'winspool.drv', 'msasn1.dll',
'secur32.dll', 'netapi32.dll', 'dnsapi.dll', 'psapi.dll', 'normaliz.dll', 'secur32.dll', 'netapi32.dll', 'dnsapi.dll', 'psapi.dll', 'normaliz.dll',
'iphlpapi.dll', 'bcrypt.dll', 'iphlpapi.dll', 'bcrypt.dll',
/* apache */ /* apache */
'apachecore.dll', 'apachecore.dll',
/* apache 2 */ /* apache 2 */
'libhttpd.dll', 'libapr.dll', 'libaprutil.dll','libapr-1.dll', 'libaprutil-1.dll', 'libhttpd.dll', 'libapr.dll', 'libaprutil.dll','libapr-1.dll', 'libaprutil-1.dll',
/* oracle */ /* oracle */
'oci.dll', 'ociw32.dll', 'oci.dll', 'ociw32.dll',
/* sybase */ /* sybase */
'libcs.dll', 'libct.dll', 'libcs.dll', 'libct.dll',
/* firebird */ /* firebird */
'fbclient.dll', 'fbclient.dll',
/* visual C++; mscvrt.dll is present on everyones system, /* visual C++; mscvrt.dll is present on everyones system,
* but the debug version (msvcrtd.dll) and those from visual studio.net * but the debug version (msvcrtd.dll) and those from visual studio.net
* (msvcrt7x.dll) are not */ * (msvcrt7x.dll) are not */
'msvcrt.dll', 'msvcrt.dll',
'msvcr90.dll', 'msvcr90.dll',
'wldap32.dll', 'wldap32.dll',
'vcruntime140.dll', 'vcruntime140.dll',
'msvcp140.dll', 'msvcp140.dll',
); );
static $no_dist_re = array( static $no_dist_re = array(
"api-ms-win-crt-.+\.dll", "api-ms-win-crt-.+\.dll",
); );
global $build_dir, $extra_dll_deps, $ext_targets, $sapi_targets, $pecl_targets, $phpdll, $per_module_deps, $pecl_dll_deps; global $build_dir, $extra_dll_deps, $ext_targets, $sapi_targets, $pecl_targets, $phpdll, $per_module_deps, $pecl_dll_deps;
$bd = strtolower(realpath($build_dir)); $bd = strtolower(realpath($build_dir));
$is_pecl = in_array($module, $pecl_targets); $is_pecl = in_array($module, $pecl_targets);
$cmd = "$GLOBALS[build_dir]\\deplister.exe \"$module\" \"$GLOBALS[build_dir]\""; $cmd = "$GLOBALS[build_dir]\\deplister.exe \"$module\" \"$GLOBALS[build_dir]\"";
$proc = proc_open($cmd, $proc = proc_open($cmd,
array(1 => array("pipe", "w")), array(1 => array("pipe", "w")),
$pipes); $pipes);
$n = 0; $n = 0;
while (($line = fgetcsv($pipes[1]))) { while (($line = fgetcsv($pipes[1]))) {
$n++; $n++;
$dep = strtolower($line[0]); $dep = strtolower($line[0]);
$depbase = basename($dep); $depbase = basename($dep);
/* ignore stuff in our build dir, but only if it is /* ignore stuff in our build dir, but only if it is
* one of our targets */ * one of our targets */
if (((in_array($depbase, $sapi_targets) || if (((in_array($depbase, $sapi_targets) ||
in_array($depbase, $ext_targets) || in_array($depbase, $pecl_targets)) || in_array($depbase, $ext_targets) || in_array($depbase, $pecl_targets)) ||
$depbase == $phpdll) && file_exists($GLOBALS['build_dir'] . "/$depbase")) { $depbase == $phpdll) && file_exists($GLOBALS['build_dir'] . "/$depbase")) {
continue; continue;
} }
/* ignore some well-known system dlls */ /* ignore some well-known system dlls */
if (in_array(basename($dep), $no_dist)) { if (in_array(basename($dep), $no_dist)) {
continue; continue;
} else { } else {
$skip = false; $skip = false;
foreach ($no_dist_re as $re) { foreach ($no_dist_re as $re) {
if (preg_match(",$re,", basename($dep)) > 0) { if (preg_match(",$re,", basename($dep)) > 0) {
$skip = true; $skip = true;
break; break;
} }
} }
if ($skip) { if ($skip) {
continue; continue;
} }
} }
if ($is_pecl) { if ($is_pecl) {
if (!in_array($dep, $pecl_dll_deps)) { if (!in_array($dep, $pecl_dll_deps)) {
$pecl_dll_deps[] = $dep; $pecl_dll_deps[] = $dep;
} }
} else { } else {
if (!in_array($dep, $extra_dll_deps)) { if (!in_array($dep, $extra_dll_deps)) {
$extra_dll_deps[] = $dep; $extra_dll_deps[] = $dep;
} }
} }
if (!isset($per_module_deps[basename($module)]) || !in_array($dep, $per_module_deps[basename($module)])) { if (!isset($per_module_deps[basename($module)]) || !in_array($dep, $per_module_deps[basename($module)])) {
$per_module_deps[basename($module)][] = $dep; $per_module_deps[basename($module)][] = $dep;
//recursively check dll dependencies //recursively check dll dependencies
get_depends($dep); get_depends($dep);
} }
} }
fclose($pipes[1]); fclose($pipes[1]);
proc_close($proc); proc_close($proc);
//echo "Module $module [$n lines]\n"; //echo "Module $module [$n lines]\n";
} }
function copy_file_list($source_dir, $dest_dir, $list) function copy_file_list($source_dir, $dest_dir, $list)
{ {
global $is_debug, $dist_dir; global $is_debug, $dist_dir;
foreach ($list as $item) { foreach ($list as $item) {
if (empty($item)) { if (empty($item)) {
continue; continue;
} elseif (!is_file($source_dir . DIRECTORY_SEPARATOR . $item)) { } elseif (!is_file($source_dir . DIRECTORY_SEPARATOR . $item)) {
echo "WARNING: $item not found\n"; echo "WARNING: $item not found\n";
continue; continue;
} }
echo "Copying $item from $source_dir to $dest_dir\n"; echo "Copying $item from $source_dir to $dest_dir\n";
copy($source_dir . DIRECTORY_SEPARATOR . $item, $dest_dir . DIRECTORY_SEPARATOR . $item); copy($source_dir . DIRECTORY_SEPARATOR . $item, $dest_dir . DIRECTORY_SEPARATOR . $item);
if ($is_debug) { if ($is_debug) {
$itemdb = preg_replace("/\.(exe|dll|lib)$/i", ".pdb", $item); $itemdb = preg_replace("/\.(exe|dll|lib)$/i", ".pdb", $item);
if (file_exists("$source_dir/$itemdb")) { if (file_exists("$source_dir/$itemdb")) {
copy("$source_dir/$itemdb", "$dist_dir/dev/$itemdb"); copy("$source_dir/$itemdb", "$dist_dir/dev/$itemdb");
} }
} }
if (preg_match("/\.(exe|dll)$/i", $item)) { if (preg_match("/\.(exe|dll)$/i", $item)) {
get_depends($source_dir . '/' . $item); get_depends($source_dir . '/' . $item);
} }
} }
} }
function copy_text_file($source, $dest) function copy_text_file($source, $dest)
{ {
$text = file_get_contents($source); $text = file_get_contents($source);
$text = preg_replace("/(\r\n?)|\n/", "\r\n", $text); $text = preg_replace("/(\r\n?)|\n/", "\r\n", $text);
$fp = fopen($dest, "w"); $fp = fopen($dest, "w");
fwrite($fp, $text); fwrite($fp, $text);
fclose($fp); fclose($fp);
} }
/* very light-weight function to extract a single named file from /* very light-weight function to extract a single named file from
@ -168,57 +168,57 @@ function copy_text_file($source, $dest)
* based on the PEAR info set in $packages. */ * based on the PEAR info set in $packages. */
function extract_file_from_tarball($pkg, $filename, $dest_dir) /* {{{ */ function extract_file_from_tarball($pkg, $filename, $dest_dir) /* {{{ */
{ {
global $packages; global $packages;
$name = $pkg . '-' . $packages[$pkg]; $name = $pkg . '-' . $packages[$pkg];
$tarball = $dest_dir . "/" . $name . '.tgz'; $tarball = $dest_dir . "/" . $name . '.tgz';
$filename = $name . '/' . $filename; $filename = $name . '/' . $filename;
$destfilename = $dest_dir . "/" . basename($filename); $destfilename = $dest_dir . "/" . basename($filename);
$fp = gzopen($tarball, 'rb'); $fp = gzopen($tarball, 'rb');
$done = false; $done = false;
do { do {
/* read the header */ /* read the header */
$hdr_data = gzread($fp, 512); $hdr_data = gzread($fp, 512);
if (strlen($hdr_data) == 0) if (strlen($hdr_data) == 0)
break; break;
$checksum = 0; $checksum = 0;
for ($i = 0; $i < 148; $i++) for ($i = 0; $i < 148; $i++)
$checksum += ord($hdr_data{$i}); $checksum += ord($hdr_data{$i});
for ($i = 148; $i < 156; $i++) for ($i = 148; $i < 156; $i++)
$checksum += 32; $checksum += 32;
for ($i = 156; $i < 512; $i++) for ($i = 156; $i < 512; $i++)
$checksum += ord($hdr_data{$i}); $checksum += ord($hdr_data{$i});
$hdr = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $hdr_data); $hdr = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $hdr_data);
$hdr['checksum'] = octdec(trim($hdr['checksum'])); $hdr['checksum'] = octdec(trim($hdr['checksum']));
if ($hdr['checksum'] != $checksum) { if ($hdr['checksum'] != $checksum) {
echo "Checksum for $tarball $hdr[filename] is invalid\n"; echo "Checksum for $tarball $hdr[filename] is invalid\n";
print_r($hdr); print_r($hdr);
return; return;
} }
$hdr['size'] = octdec(trim($hdr['size'])); $hdr['size'] = octdec(trim($hdr['size']));
echo "File: $hdr[filename] $hdr[size]\n"; echo "File: $hdr[filename] $hdr[size]\n";
if ($filename == $hdr['filename']) { if ($filename == $hdr['filename']) {
echo "Found the file we want\n"; echo "Found the file we want\n";
$dest = fopen($destfilename, 'wb'); $dest = fopen($destfilename, 'wb');
$x = stream_copy_to_stream($fp, $dest, $hdr['size']); $x = stream_copy_to_stream($fp, $dest, $hdr['size']);
fclose($dest); fclose($dest);
echo "Wrote $x bytes into $destfilename\n"; echo "Wrote $x bytes into $destfilename\n";
break; break;
} }
/* skip body of the file */ /* skip body of the file */
$size = 512 * ceil((int)$hdr['size'] / 512); $size = 512 * ceil((int)$hdr['size'] / 512);
echo "Skipping $size bytes\n"; echo "Skipping $size bytes\n";
gzseek($fp, gztell($fp) + $size); gzseek($fp, gztell($fp) + $size);
} while (!$done); } while (!$done);
} /* }}} */ } /* }}} */
@ -233,8 +233,8 @@ $phplib = str_replace(".dll", ".lib", $phpdll);
copy("$build_dir/$phplib", "$dist_dir/dev/$phplib"); copy("$build_dir/$phplib", "$dist_dir/dev/$phplib");
/* debug builds; copy the symbols too */ /* debug builds; copy the symbols too */
if ($is_debug) { if ($is_debug) {
$phppdb = str_replace(".dll", ".pdb", $phpdll); $phppdb = str_replace(".dll", ".pdb", $phpdll);
copy("$build_dir/$phppdb", "$dist_dir/dev/$phppdb"); copy("$build_dir/$phppdb", "$dist_dir/dev/$phppdb");
} }
/* copy the sapi */ /* copy the sapi */
copy_file_list($build_dir, "$dist_dir", $sapi_targets); copy_file_list($build_dir, "$dist_dir", $sapi_targets);
@ -244,30 +244,30 @@ copy_file_list($build_dir, "$dist_dir/ext", $ext_targets);
/* pecl sapi and extensions */ /* pecl sapi and extensions */
if(sizeof($pecl_targets)) { if(sizeof($pecl_targets)) {
copy_file_list($build_dir, $pecl_dir, $pecl_targets); copy_file_list($build_dir, $pecl_dir, $pecl_targets);
} }
/* populate reading material */ /* populate reading material */
$text_files = array( $text_files = array(
"LICENSE" => "license.txt", "LICENSE" => "license.txt",
"NEWS" => "news.txt", "NEWS" => "news.txt",
"README.md" => "README.md", "README.md" => "README.md",
"README.REDIST.BINS" => "readme-redist-bins.txt", "README.REDIST.BINS" => "readme-redist-bins.txt",
"php.ini-development" => "php.ini-development", "php.ini-development" => "php.ini-development",
"php.ini-production" => "php.ini-production" "php.ini-production" => "php.ini-production"
); );
foreach ($text_files as $src => $dest) { foreach ($text_files as $src => $dest) {
copy_text_file($src, $dist_dir . '/' . $dest); copy_text_file($src, $dist_dir . '/' . $dest);
} }
/* general other files */ /* general other files */
$general_files = array( $general_files = array(
"$GLOBALS[build_dir]\\deplister.exe" => "deplister.exe", "$GLOBALS[build_dir]\\deplister.exe" => "deplister.exe",
); );
foreach ($general_files as $src => $dest) { foreach ($general_files as $src => $dest) {
copy($src, $dist_dir . '/' . $dest); copy($src, $dist_dir . '/' . $dest);
} }
/* include a snapshot identifier */ /* include a snapshot identifier */
@ -289,40 +289,40 @@ $exts = get_loaded_extensions();
fprintf($fp, "\r\nBuilt-in Extensions\r\n"); fprintf($fp, "\r\nBuilt-in Extensions\r\n");
fwrite($fp, "===========================\r\n"); fwrite($fp, "===========================\r\n");
foreach ($exts as $ext) { foreach ($exts as $ext) {
fprintf($fp, "%s\r\n", $ext); fprintf($fp, "%s\r\n", $ext);
} }
fwrite($fp, "\r\n\r\n"); fwrite($fp, "\r\n\r\n");
/* list dependencies */ /* list dependencies */
fprintf($fp, "Dependency information:\r\n"); fprintf($fp, "Dependency information:\r\n");
foreach ($per_module_deps as $modulename => $deps) { foreach ($per_module_deps as $modulename => $deps) {
if (in_array($modulename, $pecl_targets)) if (in_array($modulename, $pecl_targets))
continue; continue;
fprintf($fp, "Module: %s\r\n", $modulename); fprintf($fp, "Module: %s\r\n", $modulename);
fwrite($fp, "===========================\r\n"); fwrite($fp, "===========================\r\n");
foreach ($deps as $dll) { foreach ($deps as $dll) {
fprintf($fp, "\t%s\r\n", basename($dll)); fprintf($fp, "\t%s\r\n", basename($dll));
} }
fwrite($fp, "\r\n"); fwrite($fp, "\r\n");
} }
fclose($fp); fclose($fp);
/* Now add those dependencies */ /* Now add those dependencies */
foreach ($extra_dll_deps as $dll) { foreach ($extra_dll_deps as $dll) {
if (!file_exists($dll)) { if (!file_exists($dll)) {
/* try template dir */ /* try template dir */
$tdll = $snapshot_template . "/dlls/" . basename($dll); $tdll = $snapshot_template . "/dlls/" . basename($dll);
if (!file_exists($tdll)) { if (!file_exists($tdll)) {
$tdll = $php_build_dir . '/bin/' . basename($dll); $tdll = $php_build_dir . '/bin/' . basename($dll);
if (!file_exists($tdll)) { if (!file_exists($tdll)) {
echo "WARNING: distro depends on $dll, but could not find it on your system\n"; echo "WARNING: distro depends on $dll, but could not find it on your system\n";
continue; continue;
} }
} }
$dll = $tdll; $dll = $tdll;
} }
copy($dll, "$dist_dir/" . basename($dll)); copy($dll, "$dist_dir/" . basename($dll));
} }
/* TODO: /* TODO:
@ -333,168 +333,168 @@ deps. For example, libenchant.dll loads libenchant_myspell.dll or
libenchant_ispell.dll libenchant_ispell.dll
*/ */
$ENCHANT_DLLS = array( $ENCHANT_DLLS = array(
array('', 'glib-2.dll'), array('', 'glib-2.dll'),
array('', 'gmodule-2.dll'), array('', 'gmodule-2.dll'),
array('lib/enchant', 'libenchant_myspell.dll'), array('lib/enchant', 'libenchant_myspell.dll'),
array('lib/enchant', 'libenchant_ispell.dll'), array('lib/enchant', 'libenchant_ispell.dll'),
); );
foreach ($ENCHANT_DLLS as $dll) { foreach ($ENCHANT_DLLS as $dll) {
$dest = "$dist_dir/$dll[0]"; $dest = "$dist_dir/$dll[0]";
$filename = $dll[1]; $filename = $dll[1];
if (!file_exists("$dest") || !is_dir("$dest")) { if (!file_exists("$dest") || !is_dir("$dest")) {
if (!mkdir("$dest", 0777, true)) { if (!mkdir("$dest", 0777, true)) {
echo "WARNING: couldn't create '$dest' for enchant plugins "; echo "WARNING: couldn't create '$dest' for enchant plugins ";
} }
} }
if (!copy($php_build_dir . '/bin/' . $filename, "$dest/" . basename($filename))) { if (!copy($php_build_dir . '/bin/' . $filename, "$dest/" . basename($filename))) {
echo "WARNING: couldn't copy $filename into the dist dir"; echo "WARNING: couldn't copy $filename into the dist dir";
} }
} }
$SASL_DLLS = $php_build_dir . "/bin/sasl2/sasl*.dll"; $SASL_DLLS = $php_build_dir . "/bin/sasl2/sasl*.dll";
$fls = glob($SASL_DLLS); $fls = glob($SASL_DLLS);
if (!empty($fls)) { if (!empty($fls)) {
$sasl_dest_dir = "$dist_dir/sasl2"; $sasl_dest_dir = "$dist_dir/sasl2";
if (!file_exists($sasl_dest_dir) || !is_dir($sasl_dest_dir)) { if (!file_exists($sasl_dest_dir) || !is_dir($sasl_dest_dir)) {
if (!mkdir("$sasl_dest_dir", 0777, true)) { if (!mkdir("$sasl_dest_dir", 0777, true)) {
echo "WARNING: couldn't create '$sasl_dest_dir' for SASL2 auth plugins "; echo "WARNING: couldn't create '$sasl_dest_dir' for SASL2 auth plugins ";
} }
} }
foreach ($fls as $fl) { foreach ($fls as $fl) {
if (!copy($fl, "$sasl_dest_dir/" . basename($fl))) { if (!copy($fl, "$sasl_dest_dir/" . basename($fl))) {
echo "WARNING: couldn't copy $fl into the $sasl_dest_dir"; echo "WARNING: couldn't copy $fl into the $sasl_dest_dir";
} }
} }
} }
/* and those for pecl */ /* and those for pecl */
foreach ($pecl_dll_deps as $dll) { foreach ($pecl_dll_deps as $dll) {
if (in_array($dll, $extra_dll_deps)) { if (in_array($dll, $extra_dll_deps)) {
/* already in main distro */ /* already in main distro */
continue; continue;
} }
if (!file_exists($dll)) { if (!file_exists($dll)) {
/* try template dir */ /* try template dir */
$tdll = $snapshot_template . "/dlls/" . basename($dll); $tdll = $snapshot_template . "/dlls/" . basename($dll);
if (!file_exists($tdll)) { if (!file_exists($tdll)) {
echo "WARNING: distro depends on $dll, but could not find it on your system\n"; echo "WARNING: distro depends on $dll, but could not find it on your system\n";
continue; continue;
} }
$dll = $tdll; $dll = $tdll;
} }
copy($dll, "$pecl_dir/" . basename($dll)); copy($dll, "$pecl_dir/" . basename($dll));
} }
function copy_dir($source, $dest) function copy_dir($source, $dest)
{ {
if (!is_dir($dest)) { if (!is_dir($dest)) {
if (!mkdir($dest)) { if (!mkdir($dest)) {
return false; return false;
} }
} }
$d = opendir($source); $d = opendir($source);
while (($f = readdir($d)) !== false) { while (($f = readdir($d)) !== false) {
if ($f == '.' || $f == '..' || $f == '.svn') { if ($f == '.' || $f == '..' || $f == '.svn') {
continue; continue;
} }
$fs = $source . '/' . $f; $fs = $source . '/' . $f;
$fd = $dest . '/' . $f; $fd = $dest . '/' . $f;
if (is_dir($fs)) { if (is_dir($fs)) {
copy_dir($fs, $fd); copy_dir($fs, $fd);
} else { } else {
copy($fs, $fd); copy($fs, $fd);
} }
} }
closedir($d); closedir($d);
} }
function copy_test_dir($directory, $dest) function copy_test_dir($directory, $dest)
{ {
if(substr($directory,-1) == '/') { if(substr($directory,-1) == '/') {
$directory = substr($directory,0,-1); $directory = substr($directory,0,-1);
} }
if ($directory == 'tests' || $directory == 'examples') { if ($directory == 'tests' || $directory == 'examples') {
if (!is_dir($dest . '/tests')) { if (!is_dir($dest . '/tests')) {
mkdir($dest . '/tests', 0775, true); mkdir($dest . '/tests', 0775, true);
} }
copy_dir($directory, $dest . '/tests/'); copy_dir($directory, $dest . '/tests/');
return false; return false;
} }
if(!file_exists($directory) || !is_dir($directory)) { if(!file_exists($directory) || !is_dir($directory)) {
echo "failed... $directory\n"; echo "failed... $directory\n";
return FALSE; return FALSE;
} }
$directory_list = opendir($directory); $directory_list = opendir($directory);
while (FALSE !== ($file = readdir($directory_list))) { while (FALSE !== ($file = readdir($directory_list))) {
$full_path = $directory . '/' . $file; $full_path = $directory . '/' . $file;
if($file != '.' && $file != '..' && $file != '.svn' && is_dir($full_path)) { if($file != '.' && $file != '..' && $file != '.svn' && is_dir($full_path)) {
if ($file == 'tests' || $file == 'examples') { if ($file == 'tests' || $file == 'examples') {
if (!is_dir($dest . '/' . $full_path)) { if (!is_dir($dest . '/' . $full_path)) {
mkdir($dest . '/' . $full_path , 0775, true); mkdir($dest . '/' . $full_path , 0775, true);
} }
copy_dir($full_path, $dest . '/' . $full_path . '/'); copy_dir($full_path, $dest . '/' . $full_path . '/');
continue; continue;
} else { } else {
copy_test_dir($full_path, $dest); copy_test_dir($full_path, $dest);
} }
} }
} }
closedir($directory_list); closedir($directory_list);
} }
function make_phar_dot_phar($dist_dir) function make_phar_dot_phar($dist_dir)
{ {
if (!extension_loaded('phar')) { if (!extension_loaded('phar')) {
return; return;
} }
$path_to_phar = realpath(__DIR__ . '/../../ext/phar'); $path_to_phar = realpath(__DIR__ . '/../../ext/phar');
echo "Generating pharcommand.phar\n"; echo "Generating pharcommand.phar\n";
$phar = new Phar($dist_dir . '/pharcommand.phar', 0, 'pharcommand'); $phar = new Phar($dist_dir . '/pharcommand.phar', 0, 'pharcommand');
foreach (new DirectoryIterator($path_to_phar . '/phar') as $file) { foreach (new DirectoryIterator($path_to_phar . '/phar') as $file) {
if ($file->isDir() || $file == 'phar.php') { if ($file->isDir() || $file == 'phar.php') {
continue; continue;
} }
echo 'adding ', $file, "\n"; echo 'adding ', $file, "\n";
$phar[(string) $file] = file_get_contents($path_to_phar. '/phar/' . $file); $phar[(string) $file] = file_get_contents($path_to_phar. '/phar/' . $file);
} }
$phar->setSignatureAlgorithm(Phar::SHA1); $phar->setSignatureAlgorithm(Phar::SHA1);
$stub = file($path_to_phar . '/phar/phar.php'); $stub = file($path_to_phar . '/phar/phar.php');
unset($stub[0]); // remove hashbang unset($stub[0]); // remove hashbang
$phar->setStub(implode('', $stub)); $phar->setStub(implode('', $stub));
echo "Creating phar.phar.bat\n"; echo "Creating phar.phar.bat\n";
file_put_contents($dist_dir . '/phar.phar.bat', "\"%~dp0php.exe\" \"%~dp0pharcommand.phar\" %*\r\n"); file_put_contents($dist_dir . '/phar.phar.bat', "\"%~dp0php.exe\" \"%~dp0pharcommand.phar\" %*\r\n");
} }
if (!is_dir($test_dir)) { if (!is_dir($test_dir)) {
mkdir($test_dir); mkdir($test_dir);
} }
$dirs = array( $dirs = array(
'ext', 'ext',
'Sapi', 'Sapi',
'Zend', 'Zend',
'tests' 'tests'
); );
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
copy_test_dir($dir, $test_dir); copy_test_dir($dir, $test_dir);
} }
copy('run-tests.php', $test_dir . '/run-tests.php'); copy('run-tests.php', $test_dir . '/run-tests.php');
@ -503,82 +503,82 @@ copy('run-tests.php', $test_dir . '/run-tests.php');
$use_pear_template = true; $use_pear_template = true;
if (!$use_pear_template) { if (!$use_pear_template) {
/* Let's do a PEAR-less pear setup */ /* Let's do a PEAR-less pear setup */
mkdir("$dist_dir/PEAR"); mkdir("$dist_dir/PEAR");
mkdir("$dist_dir/PEAR/go-pear-bundle"); mkdir("$dist_dir/PEAR/go-pear-bundle");
/* grab the bootstrap script */ /* grab the bootstrap script */
echo "Downloading go-pear\n"; echo "Downloading go-pear\n";
copy("https://pear.php.net/go-pear.phar", "$dist_dir/PEAR/go-pear.php"); copy("https://pear.php.net/go-pear.phar", "$dist_dir/PEAR/go-pear.php");
/* import the package list -- sets $packages variable */ /* import the package list -- sets $packages variable */
include "pear/go-pear-list.php"; include "pear/go-pear-list.php";
/* download the packages into the destination */ /* download the packages into the destination */
echo "Fetching packages\n"; echo "Fetching packages\n";
foreach ($packages as $name => $version) { foreach ($packages as $name => $version) {
$filename = "$name-$version.tgz"; $filename = "$name-$version.tgz";
$destfilename = "$dist_dir/PEAR/go-pear-bundle/$filename"; $destfilename = "$dist_dir/PEAR/go-pear-bundle/$filename";
if (file_exists($destfilename)) if (file_exists($destfilename))
continue; continue;
$url = "http://pear.php.net/get/$filename"; $url = "http://pear.php.net/get/$filename";
echo "Downloading $name from $url\n"; echo "Downloading $name from $url\n";
flush(); flush();
copy($url, $destfilename); copy($url, $destfilename);
} }
echo "Download complete. Extracting bootstrap files\n"; echo "Download complete. Extracting bootstrap files\n";
/* Now, we want PEAR.php, Getopt.php (Console_Getopt) and Tar.php (Archive_Tar) /* Now, we want PEAR.php, Getopt.php (Console_Getopt) and Tar.php (Archive_Tar)
* broken out of the tarballs */ * broken out of the tarballs */
extract_file_from_tarball('PEAR', 'PEAR.php', "$dist_dir/PEAR/go-pear-bundle"); extract_file_from_tarball('PEAR', 'PEAR.php', "$dist_dir/PEAR/go-pear-bundle");
extract_file_from_tarball('Archive_Tar', 'Archive/Tar.php', "$dist_dir/PEAR/go-pear-bundle"); extract_file_from_tarball('Archive_Tar', 'Archive/Tar.php', "$dist_dir/PEAR/go-pear-bundle");
extract_file_from_tarball('Console_Getopt', 'Console/Getopt.php', "$dist_dir/PEAR/go-pear-bundle"); extract_file_from_tarball('Console_Getopt', 'Console/Getopt.php', "$dist_dir/PEAR/go-pear-bundle");
} }
/* add extras from the template dir */ /* add extras from the template dir */
if (file_exists($snapshot_template)) { if (file_exists($snapshot_template)) {
$items = glob("$snapshot_template/*"); $items = glob("$snapshot_template/*");
print_r($items); print_r($items);
foreach ($items as $item) { foreach ($items as $item) {
$bi = basename($item); $bi = basename($item);
if (is_dir($item)) { if (is_dir($item)) {
if ($bi == 'dlls' || $bi == 'symbols') { if ($bi == 'dlls' || $bi == 'symbols') {
continue; continue;
} else if ($bi == 'PEAR') { } else if ($bi == 'PEAR') {
if ($use_pear_template) { if ($use_pear_template) {
/* copy to top level */ /* copy to top level */
copy_dir($item, "$dist_dir/$bi"); copy_dir($item, "$dist_dir/$bi");
} }
} else { } else {
/* copy that dir into extras */ /* copy that dir into extras */
copy_dir($item, "$dist_dir/extras/$bi"); copy_dir($item, "$dist_dir/extras/$bi");
} }
} else { } else {
if ($bi == 'go-pear.bat') { if ($bi == 'go-pear.bat') {
/* copy to top level */ /* copy to top level */
copy($item, "$dist_dir/$bi"); copy($item, "$dist_dir/$bi");
} else { } else {
/* copy to extras */ /* copy to extras */
copy($item, "$dist_dir/extras/$bi"); copy($item, "$dist_dir/extras/$bi");
} }
} }
} }
/* copy c++ runtime */ /* copy c++ runtime */
$items = glob("$snapshot_template/dlls/*.CRT"); $items = glob("$snapshot_template/dlls/*.CRT");
foreach ($items as $item) { foreach ($items as $item) {
$bi = basename($item); $bi = basename($item);
if (is_dir($item)) { if (is_dir($item)) {
copy_dir($item, "$dist_dir/$bi"); copy_dir($item, "$dist_dir/$bi");
copy_dir($item, "$dist_dir/ext/$bi"); copy_dir($item, "$dist_dir/ext/$bi");
} }
} }
} else { } else {
echo "WARNING: you don't have a snapshot template, your dist will not be complete\n"; echo "WARNING: you don't have a snapshot template, your dist will not be complete\n";
} }
make_phar_dot_phar($dist_dir); make_phar_dot_phar($dist_dir);

View file

@ -1161,8 +1161,8 @@ PW32IO ssize_t php_win32_ioutil_readlink_w(const wchar_t *path, wchar_t *buf, si
ret = php_win32_ioutil_readlink_int(h, buf, buf_len); ret = php_win32_ioutil_readlink_int(h, buf, buf_len);
if (ret < 0) { if (ret < 0) {
wchar_t target[PHP_WIN32_IOUTIL_MAXPATHLEN]; wchar_t target[PHP_WIN32_IOUTIL_MAXPATHLEN];
size_t target_len; size_t target_len;
size_t offset = 0; size_t offset = 0;

View file

@ -447,7 +447,7 @@ static zend_always_inline BOOL is_compatible(const char *name, BOOL is_smaller,
free(err_txt); free(err_txt);
return FALSE; return FALSE;
} }
DWORD major = img->FileHeader->OptionalHeader.MajorLinkerVersion; DWORD major = img->FileHeader->OptionalHeader.MajorLinkerVersion;
DWORD minor = img->FileHeader->OptionalHeader.MinorLinkerVersion; DWORD minor = img->FileHeader->OptionalHeader.MinorLinkerVersion;
@ -459,7 +459,7 @@ static zend_always_inline BOOL is_compatible(const char *name, BOOL is_smaller,
is used with a newer CRT, but not the other way round. is used with a newer CRT, but not the other way round.
Otherwise, if the linker major version is not same, it is an error, as Otherwise, if the linker major version is not same, it is an error, as
per the current knowledge. per the current knowledge.
This check is to be extended as new VS versions come out. */ This check is to be extended as new VS versions come out. */
DWORD core_minor = (DWORD)(PHP_LINKER_MINOR/10); DWORD core_minor = (DWORD)(PHP_LINKER_MINOR/10);
DWORD comp_minor = (DWORD)(minor/10); DWORD comp_minor = (DWORD)(minor/10);