From 79230e5561588be7e63f3ee93c06e7065e5038a9 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sun, 15 Jun 2014 15:47:14 +0200 Subject: [PATCH] Merge sapi/phpdbg into PHP-5.6 --- .travis.yml | 11 ++++++++++- config.m4 | 1 + phpdbg_utils.c | 9 ++++++--- phpdbg_utils.h | 20 ++++++++++++++++++++ tests/run-tests.php | 22 ++++++++++++---------- travis/ci.sh | 5 +++-- 6 files changed, 52 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 353402858e..d5b492e7cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,12 @@ language: c -script: ./travis/ci.sh +env: +- PHP="PHP-5.4" +- PHP="PHP-5.5" +- PHP="PHP-5.6" +- PHP="master" + +before_script: ./travis/ci.sh + +script: +- ./php-src/sapi/cli/php php-src/sapi/phpdbg/tests/run-tests.php -diff2stdout --phpdbg php-src/sapi/phpdbg/phpdbg diff --git a/config.m4 b/config.m4 index ecac171506..1a6640eaca 100644 --- a/config.m4 +++ b/config.m4 @@ -9,6 +9,7 @@ PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build, [ --enable-phpdbg-debug Build phpdbg in debug mode], no, no) if test "$PHP_PHPDBG" != "no"; then + AC_HEADER_TIOCGWINSZ AC_DEFINE(HAVE_PHPDBG, 1, [ ]) if test "$PHP_PHPDBG_DEBUG" != "no"; then diff --git a/phpdbg_utils.c b/phpdbg_utils.c index c9b22a2039..98748b202a 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -32,6 +32,9 @@ # include "win32/time.h" #elif defined(HAVE_SYS_IOCTL_H) # include "sys/ioctl.h" +# ifndef GWINSZ_IN_SYS_IOCTL +# include +# endif #endif ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -437,12 +440,12 @@ PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */ GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); columns = csbi.srWindow.Right - csbi.srWindow.Left + 1; -#elif defined(HAVE_SYS_IOCTL_H) +#elif defined(HAVE_SYS_IOCTL_H) && defined (TIOCGWINSZ) struct winsize w; - columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 100; + columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 80; #else - columns = 100; + columns = 80; #endif return columns; } /* }}} */ diff --git a/phpdbg_utils.h b/phpdbg_utils.h index 68ae7e44a3..56bacfc459 100644 --- a/phpdbg_utils.h +++ b/phpdbg_utils.h @@ -124,4 +124,24 @@ PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D); /* }}} */ int phpdbg_rebuild_symtable(TSRMLS_D); +#if PHP_VERSION_ID < 50500 +/* copy from zend_hash.c PHP 5.5 for 5.4 compatibility */ +static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos) { + Bucket *p; + + p = pos ? (*pos) : ht->pInternalPointer; + + if (!p) { + Z_TYPE_P(key) = IS_NULL; + } else if (p->nKeyLength) { + Z_TYPE_P(key) = IS_STRING; + Z_STRVAL_P(key) = IS_INTERNED(p->arKey) ? (char*)p->arKey : estrndup(p->arKey, p->nKeyLength - 1); + Z_STRLEN_P(key) = p->nKeyLength - 1; + } else { + Z_TYPE_P(key) = IS_LONG; + Z_LVAL_P(key) = p->h; + } +} +#endif + #endif /* PHPDBG_UTILS_H */ diff --git a/tests/run-tests.php b/tests/run-tests.php index 47a998ccae..1cc31d815e 100644 --- a/tests/run-tests.php +++ b/tests/run-tests.php @@ -135,8 +135,8 @@ namespace phpdbg\testing { * @param array basic configuration * @param array command line */ - public function __construct(TestsConfiguration &$config) { - $this->config = &$config; + public function __construct(TestsConfiguration $config) { + $this->config = $config; if ($this->config->hasFlag('help') || $this->config->hasFlag('h')) { @@ -153,7 +153,7 @@ namespace phpdbg\testing { $paths = array(); $where = ($in != null) ? array($in) : $this->config['path']; - foreach ($where as &$path) { + foreach ($where as $path) { if ($path) { if (is_dir($path)) { $paths[] = $path; @@ -243,6 +243,7 @@ namespace phpdbg\testing { printf("\t--options\toptions to pass to phpdbg%s", PHP_EOL); printf("\t--phpdbg\tpath to phpdbg binary%s", PHP_EOL); printf('[flags]:%s', PHP_EOL); + printf("\t-diff2stdout\t\twrite diff to stdout instead of files%s", PHP_EOL); printf("\t-nodiff\t\tdo not write diffs on failure%s", PHP_EOL); printf("\t-nolog\t\tdo not write logs on failure%s", PHP_EOL); printf('[examples]:%s', PHP_EOL); @@ -266,9 +267,11 @@ namespace phpdbg\testing { $test = sprintf('%s/%s', $path, $file); if (preg_match('~\.test$~', $test)) { - yield new Test($this->config, $test); + $tests[] = new Test($this->config, $test); } } + + return $tests; } /** @@ -354,7 +357,7 @@ namespace phpdbg\testing { * @param array configuration * @param string file */ - public function __construct(TestsConfiguration &$config, &$file) { + public function __construct(TestsConfiguration $config, $file) { if (($handle = fopen($file, 'r'))) { while (($line = fgets($handle))) { $trim = trim($line); @@ -417,8 +420,8 @@ namespace phpdbg\testing { } fclose($handle); - $this->config = &$config; - $this->file = &$file; + $this->config = $config; + $this->file = $file; } } @@ -427,8 +430,7 @@ namespace phpdbg\testing { * */ public function getResult() { - $options = sprintf( - '-i%s -nqb', $this->file); + $options = sprintf('-i%s -nqb', $this->file); if ($this->options) { $options = sprintf( @@ -526,7 +528,7 @@ namespace phpdbg\testing { * Write log to disk if configuration allows it * */ - protected function writeLog(&$result = null) { + protected function writeLog($result = null) { $log = sprintf( '%s/%s.log', dirname($this->file), basename($this->file)); diff --git a/travis/ci.sh b/travis/ci.sh index d9f3ac6a02..206b158b9b 100755 --- a/travis/ci.sh +++ b/travis/ci.sh @@ -1,10 +1,11 @@ #!/usr/bin/env sh git clone https://github.com/php/php-src -cd php-src/sapi +cd php-src +git checkout $PHP +cd sapi rm -rf phpdbg git clone https://github.com/krakjoe/phpdbg.git cd ../ ./buildconf --force ./configure --disable-all --enable-phpdbg --enable-maintainer-zts make -make test-phpdbg -- 2.50.0