Skip to content

Commit 1cf188a

Browse files
author
Andrei Zmievski
committed
Fix compilation when PCRE is disabled.
1 parent a15c9a3 commit 1cf188a

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

ext/standard/aggregation.c

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,25 @@ static void aggregate_methods(zend_class_entry *ce, zend_class_entry *from_ce, i
8686
uint func_name_len;
8787
ulong num_key;
8888
zval *list_hash = NULL;
89+
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
8990
pcre *re = NULL;
9091
pcre_extra *re_extra = NULL;
9192
int re_options = 0;
93+
#endif
9294

9395
/*
9496
* Flip the array for easy lookup, or compile the regexp.
9597
*/
9698
if (aggr_type == AGGREGATE_BY_LIST) {
9799
list_hash = array_to_hash(aggr_filter);
98-
} else if (aggr_type == AGGREGATE_BY_REGEXP) {
100+
}
101+
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
102+
else if (aggr_type == AGGREGATE_BY_REGEXP) {
99103
if ((re = pcre_get_compiled_regex(Z_STRVAL_P(aggr_filter), &re_extra, &re_options)) == NULL) {
100104
return;
101105
}
102106
}
107+
#endif
103108

104109
/*
105110
* "Just because it's not nice doesn't mean it's not miraculous."
@@ -122,9 +127,13 @@ static void aggregate_methods(zend_class_entry *ce, zend_class_entry *from_ce, i
122127
/* 2. private methods (heh, like we really have them) */
123128
func_name[0] == '_' ||
124129
/* 3. explicitly excluded methods */
125-
(aggr_type == AGGREGATE_BY_LIST && zend_hash_exists(Z_ARRVAL_P(list_hash), func_name, func_name_len)) ||
130+
(aggr_type == AGGREGATE_BY_LIST && zend_hash_exists(Z_ARRVAL_P(list_hash), func_name, func_name_len))
131+
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
132+
||
126133
/* 4. methods matching regexp as modified by the exclusion flag */
127-
(aggr_type == AGGREGATE_BY_REGEXP && (pcre_exec(re, re_extra, func_name, func_name_len-1, 0, 0, NULL, 0) < 0) ^ exclude) == 1) {
134+
(aggr_type == AGGREGATE_BY_REGEXP && (pcre_exec(re, re_extra, func_name, func_name_len-1, 0, 0, NULL, 0) < 0) ^ exclude) == 1
135+
#endif
136+
) {
128137
zend_hash_move_forward_ex(&from_ce->function_table, &pos);
129138
continue;
130139
}
@@ -178,9 +187,11 @@ static void aggregate_properties(zval *obj, zend_class_entry *from_ce, int aggr_
178187
uint prop_name_len;
179188
ulong num_key;
180189
zval *list_hash = NULL;
190+
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
181191
pcre *re = NULL;
182192
pcre_extra *re_extra = NULL;
183193
int re_options = 0;
194+
#endif
184195

185196
if (!from_ce->constants_updated) {
186197
zend_hash_apply_with_argument(&from_ce->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
@@ -192,11 +203,14 @@ static void aggregate_properties(zval *obj, zend_class_entry *from_ce, int aggr_
192203
*/
193204
if (aggr_type == AGGREGATE_BY_LIST) {
194205
list_hash = array_to_hash(aggr_filter);
195-
} else if (aggr_type == AGGREGATE_BY_REGEXP) {
206+
}
207+
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
208+
else if (aggr_type == AGGREGATE_BY_REGEXP) {
196209
if ((re = pcre_get_compiled_regex(Z_STRVAL_P(aggr_filter), &re_extra, &re_options)) == NULL) {
197210
return;
198211
}
199212
}
213+
#endif
200214

201215
/*
202216
* "Just because it's not nice doesn't mean it's not miraculous."
@@ -217,9 +231,13 @@ static void aggregate_properties(zval *obj, zend_class_entry *from_ce, int aggr_
217231
* 1. private properties (heh, like we really have them) */
218232
if (prop_name[0] == '_' ||
219233
/* 2. explicitly excluded properties */
220-
(aggr_type == AGGREGATE_BY_LIST && zend_hash_exists(Z_ARRVAL_P(list_hash), prop_name, prop_name_len)) ||
234+
(aggr_type == AGGREGATE_BY_LIST && zend_hash_exists(Z_ARRVAL_P(list_hash), prop_name, prop_name_len))
235+
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
236+
||
221237
/* 3. properties matching regexp as modified by the exclusion flag */
222-
(aggr_type == AGGREGATE_BY_REGEXP && (pcre_exec(re, re_extra, prop_name, prop_name_len-1, 0, 0, NULL, 0) < 0) ^ exclude) == 1) {
238+
(aggr_type == AGGREGATE_BY_REGEXP && (pcre_exec(re, re_extra, prop_name, prop_name_len-1, 0, 0, NULL, 0) < 0) ^ exclude) == 1
239+
#endif
240+
) {
223241
zend_hash_move_forward_ex(&from_ce->default_properties, &pos);
224242
continue;
225243
}
@@ -478,15 +496,6 @@ PHP_FUNCTION(aggregate_methods_by_list)
478496
/* }}} */
479497

480498

481-
/* {{{ proto void aggregate_methods_by_regexp(object obj, string class, string regexp [, bool exclude])
482-
*/
483-
PHP_FUNCTION(aggregate_methods_by_regexp)
484-
{
485-
aggregate(INTERNAL_FUNCTION_PARAM_PASSTHRU, AGGREGATE_METHODS, AGGREGATE_BY_REGEXP);
486-
}
487-
/* }}} */
488-
489-
490499
/* {{{ proto void aggregate_properties(object obj, string class)
491500
*/
492501
PHP_FUNCTION(aggregate_properties)
@@ -504,6 +513,15 @@ PHP_FUNCTION(aggregate_properties_by_list)
504513
}
505514
/* }}} */
506515

516+
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
517+
/* {{{ proto void aggregate_methods_by_regexp(object obj, string class, string regexp [, bool exclude])
518+
*/
519+
PHP_FUNCTION(aggregate_methods_by_regexp)
520+
{
521+
aggregate(INTERNAL_FUNCTION_PARAM_PASSTHRU, AGGREGATE_METHODS, AGGREGATE_BY_REGEXP);
522+
}
523+
/* }}} */
524+
507525

508526
/* {{{ proto void aggregate_properties_by_regexp(object obj, string class, string regexp [, bool exclude])
509527
*/
@@ -512,6 +530,7 @@ PHP_FUNCTION(aggregate_properties_by_regexp)
512530
aggregate(INTERNAL_FUNCTION_PARAM_PASSTHRU, AGGREGATE_PROPERTIES, AGGREGATE_BY_REGEXP);
513531
}
514532
/* }}} */
533+
#endif
515534

516535

517536
/* {{{ proto array aggregation_info(object obj)

ext/standard/basic_functions.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,10 +819,12 @@ function_entry basic_functions[] = {
819819
PHP_FE(aggregate, first_arg_force_ref)
820820
PHP_FE(aggregate_methods, first_arg_force_ref)
821821
PHP_FE(aggregate_methods_by_list, first_arg_force_ref)
822-
PHP_FE(aggregate_methods_by_regexp, first_arg_force_ref)
823822
PHP_FE(aggregate_properties, first_arg_force_ref)
824823
PHP_FE(aggregate_properties_by_list, first_arg_force_ref)
824+
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
825+
PHP_FE(aggregate_methods_by_regexp, first_arg_force_ref)
825826
PHP_FE(aggregate_properties_by_regexp, first_arg_force_ref)
827+
#endif
826828
PHP_FE(deaggregate, first_arg_force_ref)
827829
PHP_FE(aggregation_info, first_arg_force_ref)
828830
{NULL, NULL, NULL}

0 commit comments

Comments
 (0)