Skip to content

Commit f677889

Browse files
committed
Merge sapi/phpdbg into PHP-5.6
2 parents da3ef17 + e9c2e7d commit f677889

File tree

6 files changed

+52
-16
lines changed

6 files changed

+52
-16
lines changed

sapi/phpdbg/.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
language: c
22

3-
script: ./travis/ci.sh
3+
env:
4+
- PHP="PHP-5.4"
5+
- PHP="PHP-5.5"
6+
- PHP="PHP-5.6"
7+
- PHP="master"
8+
9+
before_script: ./travis/ci.sh
10+
11+
script:
12+
- ./php-src/sapi/cli/php php-src/sapi/phpdbg/tests/run-tests.php -diff2stdout --phpdbg php-src/sapi/phpdbg/phpdbg

sapi/phpdbg/config.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build,
99
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
1010

1111
if test "$PHP_PHPDBG" != "no"; then
12+
AC_HEADER_TIOCGWINSZ
1213
AC_DEFINE(HAVE_PHPDBG, 1, [ ])
1314

1415
if test "$PHP_PHPDBG_DEBUG" != "no"; then

sapi/phpdbg/phpdbg_utils.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
# include "win32/time.h"
3333
#elif defined(HAVE_SYS_IOCTL_H)
3434
# include "sys/ioctl.h"
35+
# ifndef GWINSZ_IN_SYS_IOCTL
36+
# include <termios.h>
37+
# endif
3538
#endif
3639

3740
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
@@ -437,12 +440,12 @@ PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */
437440

438441
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
439442
columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
440-
#elif defined(HAVE_SYS_IOCTL_H)
443+
#elif defined(HAVE_SYS_IOCTL_H) && defined (TIOCGWINSZ)
441444
struct winsize w;
442445

443-
columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 100;
446+
columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 80;
444447
#else
445-
columns = 100;
448+
columns = 80;
446449
#endif
447450
return columns;
448451
} /* }}} */

sapi/phpdbg/phpdbg_utils.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,24 @@ PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D); /* }}} */
124124

125125
int phpdbg_rebuild_symtable(TSRMLS_D);
126126

127+
#if PHP_VERSION_ID < 50500
128+
/* copy from zend_hash.c PHP 5.5 for 5.4 compatibility */
129+
static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos) {
130+
Bucket *p;
131+
132+
p = pos ? (*pos) : ht->pInternalPointer;
133+
134+
if (!p) {
135+
Z_TYPE_P(key) = IS_NULL;
136+
} else if (p->nKeyLength) {
137+
Z_TYPE_P(key) = IS_STRING;
138+
Z_STRVAL_P(key) = IS_INTERNED(p->arKey) ? (char*)p->arKey : estrndup(p->arKey, p->nKeyLength - 1);
139+
Z_STRLEN_P(key) = p->nKeyLength - 1;
140+
} else {
141+
Z_TYPE_P(key) = IS_LONG;
142+
Z_LVAL_P(key) = p->h;
143+
}
144+
}
145+
#endif
146+
127147
#endif /* PHPDBG_UTILS_H */

sapi/phpdbg/tests/run-tests.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ class Tests {
135135
* @param array basic configuration
136136
* @param array command line
137137
*/
138-
public function __construct(TestsConfiguration &$config) {
139-
$this->config = &$config;
138+
public function __construct(TestsConfiguration $config) {
139+
$this->config = $config;
140140

141141
if ($this->config->hasFlag('help') ||
142142
$this->config->hasFlag('h')) {
@@ -153,7 +153,7 @@ public function findPaths($in = null) {
153153
$paths = array();
154154
$where = ($in != null) ? array($in) : $this->config['path'];
155155

156-
foreach ($where as &$path) {
156+
foreach ($where as $path) {
157157
if ($path) {
158158
if (is_dir($path)) {
159159
$paths[] = $path;
@@ -243,6 +243,7 @@ protected function showUsage() {
243243
printf("\t--options\toptions to pass to phpdbg%s", PHP_EOL);
244244
printf("\t--phpdbg\tpath to phpdbg binary%s", PHP_EOL);
245245
printf('[flags]:%s', PHP_EOL);
246+
printf("\t-diff2stdout\t\twrite diff to stdout instead of files%s", PHP_EOL);
246247
printf("\t-nodiff\t\tdo not write diffs on failure%s", PHP_EOL);
247248
printf("\t-nolog\t\tdo not write logs on failure%s", PHP_EOL);
248249
printf('[examples]:%s', PHP_EOL);
@@ -266,9 +267,11 @@ public function findTests($path) {
266267
$test = sprintf('%s/%s', $path, $file);
267268

268269
if (preg_match('~\.test$~', $test)) {
269-
yield new Test($this->config, $test);
270+
$tests[] = new Test($this->config, $test);
270271
}
271272
}
273+
274+
return $tests;
272275
}
273276

274277
/**
@@ -354,7 +357,7 @@ class Test {
354357
* @param array configuration
355358
* @param string file
356359
*/
357-
public function __construct(TestsConfiguration &$config, &$file) {
360+
public function __construct(TestsConfiguration $config, $file) {
358361
if (($handle = fopen($file, 'r'))) {
359362
while (($line = fgets($handle))) {
360363
$trim = trim($line);
@@ -417,8 +420,8 @@ public function __construct(TestsConfiguration &$config, &$file) {
417420
}
418421
fclose($handle);
419422

420-
$this->config = &$config;
421-
$this->file = &$file;
423+
$this->config = $config;
424+
$this->file = $file;
422425
}
423426
}
424427

@@ -427,8 +430,7 @@ public function __construct(TestsConfiguration &$config, &$file) {
427430
*
428431
*/
429432
public function getResult() {
430-
$options = sprintf(
431-
'-i%s -nqb', $this->file);
433+
$options = sprintf('-i%s -nqb', $this->file);
432434

433435
if ($this->options) {
434436
$options = sprintf(
@@ -526,7 +528,7 @@ protected function writeDiff() {
526528
* Write log to disk if configuration allows it
527529
*
528530
*/
529-
protected function writeLog(&$result = null) {
531+
protected function writeLog($result = null) {
530532
$log = sprintf(
531533
'%s/%s.log',
532534
dirname($this->file), basename($this->file));

sapi/phpdbg/travis/ci.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env sh
22
git clone https://github.com/php/php-src
3-
cd php-src/sapi
3+
cd php-src
4+
git checkout $PHP
5+
cd sapi
46
rm -rf phpdbg
57
git clone https://github.com/krakjoe/phpdbg.git
68
cd ../
79
./buildconf --force
810
./configure --disable-all --enable-phpdbg --enable-maintainer-zts
911
make
10-
make test-phpdbg

0 commit comments

Comments
 (0)