Skip to content

Commit c4a0046

Browse files
committed
Allow using the system glob with --enable-system-glob
1 parent a3653bf commit c4a0046

File tree

3 files changed

+84
-6
lines changed

3 files changed

+84
-6
lines changed

configure.ac

+11
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,17 @@ AC_CHECK_FUNCS(m4_normalize([
593593
vasprintf
594594
]))
595595

596+
PHP_ARG_ENABLE([system-glob],
597+
[whether to use the system glob function],
598+
[AS_HELP_STRING([--enable-system-glob],
599+
[Use the system glob function instead of the PHP provided replacement.])],
600+
[no],
601+
[no])
602+
603+
AS_VAR_IF([PHP_SYSTEM_GLOB], [yes],
604+
[AC_DEFINE([PHP_SYSTEM_GLOB], [1],
605+
[Define to 1 if PHP will use the system glob function instead of php_glob.])])
606+
596607
AC_CHECK_FUNC([inet_ntop],, [AC_MSG_FAILURE([Required inet_ntop not found.])])
597608
AC_CHECK_FUNC([inet_pton],, [AC_MSG_FAILURE([Required inet_pton not found.])])
598609

main/php_glob.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
* Number of matches in the current invocation of glob.
5656
*/
5757

58+
#include "php_glob.h"
59+
5860
#if defined(HAVE_GLOB) && defined(PHP_SYSTEM_GLOB)
5961
#else
6062

@@ -98,7 +100,6 @@
98100
#include <unistd.h>
99101
#endif
100102
#include <errno.h>
101-
#include "php_glob.h"
102103
#include <limits.h>
103104
#include <stdint.h>
104105
#include <stdio.h>

main/php_glob.h

+71-5
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,82 @@
3535
* @(#)glob.h 8.1 (Berkeley) 6/2/93
3636
*/
3737

38+
#ifdef PHP_WIN32
39+
#include "config.w32.h"
40+
#else
41+
#include <php_config.h>
42+
#endif
43+
44+
#ifndef _PHP_GLOB_H_
45+
#define _PHP_GLOB_H_
46+
3847
#if defined(HAVE_GLOB) && defined(PHP_SYSTEM_GLOB)
3948
#include <glob.h>
4049

50+
#ifdef GLOB_APPEND
51+
#define PHP_GLOB_APPEND GLOB_APPEND
52+
#endif
53+
#ifdef GLOB_DOOFFS
54+
#define PHP_GLOB_DOOFFS GLOB_DOOFFS
55+
#endif
56+
#ifdef GLOB_ERR
57+
#define PHP_GLOB_ERR GLOB_ERR
58+
#endif
59+
#ifdef GLOB_MARK
60+
#define PHP_GLOB_MARK GLOB_MARK
61+
#endif
62+
#ifdef GLOB_NOCHECK
63+
#define PHP_GLOB_NOCHECK GLOB_NOCHECK
64+
#endif
65+
#ifdef GLOB_NOSORT
66+
#define PHP_GLOB_NOSORT GLOB_NOSORT
67+
#endif
68+
#ifdef GLOB_NOESCAPE
69+
#define PHP_GLOB_NOESCAPE GLOB_NOESCAPE
70+
#endif
71+
#ifdef GLOB_NOSPACE
72+
#define PHP_GLOB_NOSPACE GLOB_NOSPACE
73+
#endif
74+
#ifdef GLOB_ABORTED
75+
#define PHP_GLOB_ABORTED GLOB_ABORTED
76+
#endif
77+
#ifdef GLOB_NOMATCH
78+
#define PHP_GLOB_NOMATCH GLOB_NOMATCH
79+
#endif
80+
#ifdef GLOB_NOSYS
81+
#define PHP_GLOB_NOSYS GLOB_NOSYS
82+
#endif
83+
#ifdef GLOB_ALTDIRFUNC
84+
#define PHP_GLOB_ALTDIRFUNC GLOB_ALTDIRFUNC
85+
#endif
86+
#ifdef GLOB_BRACE
87+
#define PHP_GLOB_BRACE GLOB_BRACE
88+
#endif
89+
#ifdef GLOB_MAGCHAR
90+
#define PHP_GLOB_MAGCHAR GLOB_MAGCHAR
91+
#endif
92+
#ifdef GLOB_NOMAGIC
93+
#define PHP_GLOB_NOMAGIC GLOB_NOMAGIC
94+
#endif
95+
#ifdef GLOB_QUOTE
96+
#define PHP_GLOB_QUOTE GLOB_QUOTE
97+
#endif
98+
#ifdef GLOB_TILDE
99+
#define PHP_GLOB_TILDE GLOB_TILDE
100+
#endif
101+
#ifdef GLOB_LIMIT
102+
#define PHP_GLOB_LIMIT GLOB_LIMIT
103+
#endif
104+
#ifdef GLOB_KEEPSTAT
105+
#define PHP_GLOB_KEEPSTAT GLOB_KEEPSTAT
106+
#endif
107+
41108
#define php_glob_t glob_t
42109
#define php_glob glob
43-
#define php_globfree
110+
#define php_globfree globfree
44111
#else
45112

46-
#ifndef _PHP_GLOB_H_
47-
#define _PHP_GLOB_H_
113+
#include "php.h"
48114

49115
#ifndef PHP_WIN32
50116
# include <sys/cdefs.h>
@@ -102,7 +168,7 @@ PHPAPI int php_glob(const char *__restrict, int, int (*)(const char *, int),
102168
PHPAPI void php_globfree(php_glob_t *);
103169
END_EXTERN_C()
104170

105-
#endif /* !_GLOB_H_ */
171+
#endif /* defined(HAVE_GLOB) */
106172

107173
/* These were copied from dir and zip */
108174

@@ -115,4 +181,4 @@ END_EXTERN_C()
115181

116182
#define PHP_GLOB_AVAILABLE_FLAGS (0 | PHP_GLOB_BRACE | PHP_GLOB_MARK | PHP_GLOB_NOSORT | PHP_GLOB_NOCHECK | PHP_GLOB_NOESCAPE | PHP_GLOB_ERR | PHP_GLOB_ONLYDIR)
117183

118-
#endif /* defined(HAVE_GLOB) */
184+
#endif /* !_GLOB_H_ */

0 commit comments

Comments
 (0)