Skip to content

Commit f8a1b0f

Browse files
committed
Stop including php_pcre.h from spl_iterators.h
This fixes GH-7774. spl_iterators.h was including php_pcre.h so that one object intern struct could reference a pcre_cache_entry. These object interns should not be public, so they can be moved out of the header file. This change moves the object interns ouf of spl_iterators.h so that php_pcre.h doesn't need to be included from there.
1 parent 53c6619 commit f8a1b0f

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

ext/spl/spl_iterators.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "ext/standard/info.h"
2424
#include "zend_exceptions.h"
2525
#include "zend_interfaces.h"
26+
#include "ext/pcre/php_pcre.h"
2627

2728
#include "php_spl.h"
2829
#include "spl_functions.h"
@@ -113,6 +114,53 @@ typedef struct _spl_recursive_it_iterator {
113114
zend_object_iterator intern;
114115
} spl_recursive_it_iterator;
115116

117+
typedef struct _spl_cbfilter_it_intern {
118+
zend_fcall_info fci;
119+
zend_fcall_info_cache fcc;
120+
zend_object *object;
121+
} _spl_cbfilter_it_intern;
122+
123+
typedef struct _spl_dual_it_object {
124+
struct {
125+
zval zobject;
126+
zend_class_entry *ce;
127+
zend_object *object;
128+
zend_object_iterator *iterator;
129+
} inner;
130+
struct {
131+
zval data;
132+
zval key;
133+
zend_long pos;
134+
} current;
135+
dual_it_type dit_type;
136+
union {
137+
struct {
138+
zend_long offset;
139+
zend_long count;
140+
} limit;
141+
struct {
142+
zend_long flags; /* CIT_* */
143+
zend_string *zstr;
144+
zval zchildren;
145+
zval zcache;
146+
} caching;
147+
struct {
148+
zval zarrayit;
149+
zend_object_iterator *iterator;
150+
} append;
151+
struct {
152+
zend_long flags;
153+
zend_long preg_flags;
154+
pcre_cache_entry *pce;
155+
zend_string *regex;
156+
regex_mode mode;
157+
int use_flags;
158+
} regex;
159+
_spl_cbfilter_it_intern *cbfilter;
160+
} u;
161+
zend_object std;
162+
} spl_dual_it_object;
163+
116164
static zend_object_handlers spl_handlers_rec_it_it;
117165
static zend_object_handlers spl_handlers_dual_it;
118166

@@ -123,6 +171,12 @@ static inline spl_recursive_it_object *spl_recursive_it_from_obj(zend_object *ob
123171

124172
#define Z_SPLRECURSIVE_IT_P(zv) spl_recursive_it_from_obj(Z_OBJ_P((zv)))
125173

174+
static inline spl_dual_it_object *spl_dual_it_from_obj(zend_object *obj) /* {{{ */ {
175+
return (spl_dual_it_object*)((char*)(obj) - XtOffsetOf(spl_dual_it_object, std));
176+
} /* }}} */
177+
178+
#define Z_SPLDUAL_IT_P(zv) spl_dual_it_from_obj(Z_OBJ_P((zv)))
179+
126180
#define SPL_FETCH_AND_CHECK_DUAL_IT(var, objzval) \
127181
do { \
128182
spl_dual_it_object *it = Z_SPLDUAL_IT_P(objzval); \

ext/spl/spl_iterators.h

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "php.h"
2121
#include "php_spl.h"
22-
#include "ext/pcre/php_pcre.h"
2322

2423
extern PHPAPI zend_class_entry *spl_ce_AppendIterator;
2524
extern PHPAPI zend_class_entry *spl_ce_CachingIterator;
@@ -99,59 +98,6 @@ typedef enum {
9998
REGIT_MODE_MAX
10099
} regex_mode;
101100

102-
typedef struct _spl_cbfilter_it_intern {
103-
zend_fcall_info fci;
104-
zend_fcall_info_cache fcc;
105-
zend_object *object;
106-
} _spl_cbfilter_it_intern;
107-
108-
typedef struct _spl_dual_it_object {
109-
struct {
110-
zval zobject;
111-
zend_class_entry *ce;
112-
zend_object *object;
113-
zend_object_iterator *iterator;
114-
} inner;
115-
struct {
116-
zval data;
117-
zval key;
118-
zend_long pos;
119-
} current;
120-
dual_it_type dit_type;
121-
union {
122-
struct {
123-
zend_long offset;
124-
zend_long count;
125-
} limit;
126-
struct {
127-
zend_long flags; /* CIT_* */
128-
zend_string *zstr;
129-
zval zchildren;
130-
zval zcache;
131-
} caching;
132-
struct {
133-
zval zarrayit;
134-
zend_object_iterator *iterator;
135-
} append;
136-
struct {
137-
zend_long flags;
138-
zend_long preg_flags;
139-
pcre_cache_entry *pce;
140-
zend_string *regex;
141-
regex_mode mode;
142-
int use_flags;
143-
} regex;
144-
_spl_cbfilter_it_intern *cbfilter;
145-
} u;
146-
zend_object std;
147-
} spl_dual_it_object;
148-
149-
static inline spl_dual_it_object *spl_dual_it_from_obj(zend_object *obj) /* {{{ */ {
150-
return (spl_dual_it_object*)((char*)(obj) - XtOffsetOf(spl_dual_it_object, std));
151-
} /* }}} */
152-
153-
#define Z_SPLDUAL_IT_P(zv) spl_dual_it_from_obj(Z_OBJ_P((zv)))
154-
155101
typedef int (*spl_iterator_apply_func_t)(zend_object_iterator *iter, void *puser);
156102

157103
PHPAPI int spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser);

0 commit comments

Comments
 (0)