Skip to content

Commit fc94fb3

Browse files
committed
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: updated NEWS added missing GLOB_BRACE support check added SKIPIF section to test to make sure that GLOB_BRACE is supported fix #69628: complex GLOB_BRACE fails on Windows added PHPT to check for bug #69628
2 parents ad4d022 + c507c53 commit fc94fb3

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

ext/standard/tests/file/bug69628.phpt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
Bug #69628: GLOB_BRACE with multiple brackets within the braces fails
3+
--SKIPIF--
4+
<?php
5+
if (!defined('GLOB_BRACE')) {
6+
die('skip this test requires GLOB_BRACE support');
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
12+
$file_path = dirname(__FILE__);
13+
14+
// temp dirname used here
15+
$dirname = "$file_path/bug69628";
16+
17+
// temp dir created
18+
mkdir($dirname);
19+
20+
// temp files created
21+
file_put_contents("$dirname/image.jPg", '');
22+
file_put_contents("$dirname/image.gIf", '');
23+
file_put_contents("$dirname/image.png", '');
24+
25+
sort_var_dump(glob("$dirname/*.{[jJ][pP][gG],[gG][iI][fF]}", GLOB_BRACE));
26+
27+
function sort_var_dump($results) {
28+
sort($results);
29+
var_dump($results);
30+
}
31+
32+
?>
33+
--CLEAN--
34+
<?php
35+
36+
$file_path = dirname(__FILE__);
37+
unlink("$file_path/bug69628/image.jPg");
38+
unlink("$file_path/bug69628/image.gIf");
39+
unlink("$file_path/bug69628/image.png");
40+
rmdir("$file_path/bug69628/");
41+
42+
?>
43+
--EXPECTF--
44+
array(2) {
45+
[0]=>
46+
string(%d) "%s/bug69628/image.gIf"
47+
[1]=>
48+
string(%d) "%s/bug69628/image.jPg"
49+
}

ext/standard/tests/file/glob_variation.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Test glob() function: usage variations
55
if (substr(PHP_OS, 0, 3) == 'WIN') {
66
die('skip.. Not valid for Windows');
77
}
8+
if (!defined('GLOB_BRACE')) {
9+
die('skip this test requires GLOB_BRACE support');
10+
}
811
?>
912
--FILE--
1013
<?php

win32/glob.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,19 @@ globexp2(ptr, pattern, pglob, rv)
293293
}
294294

295295
for (i = 0, pl = pm = ptr; pm <= pe; pm++) {
296+
const Char *pb;
297+
296298
switch (*pm) {
297299
case LBRACKET:
298300
/* Ignore everything between [] */
299-
for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++)
301+
for (pb = pm++; *pm != RBRACKET && *pm != EOS; pm++)
300302
;
301303
if (*pm == EOS) {
302304
/*
303305
* We could not find a matching RBRACKET.
304306
* Ignore and just look for RBRACE
305307
*/
306-
pm = pl;
308+
pm = pb;
307309
}
308310
break;
309311

0 commit comments

Comments
 (0)