Index: apc_iterator.c =================================================================== RCS file: /repository/pecl/apc/apc_iterator.c,v retrieving revision 3.3 diff -u -r3.3 apc_iterator.c --- apc_iterator.c 15 Aug 2008 22:23:52 -0000 3.3 +++ apc_iterator.c 18 Aug 2008 12:58:44 -0000 @@ -215,7 +215,7 @@ } else if ((*slot)->key.type == APC_CACHE_KEY_FPFILE) { key = (char*)(*slot)->key.data.fpfile.fullpath; } - if (!iterator->regex || regexec(&iterator->c_regex, key, 0, NULL, 0) == 0) { + if (!iterator->regex || pcre_exec(iterator->c_regex, NULL, key, strlen(key), 0, 0, NULL, 0) >= 0) { count++; item = apc_iterator_item_ctor(iterator, slot); if (item) { @@ -254,7 +254,7 @@ } else if ((*slot)->key.type == APC_CACHE_KEY_FPFILE) { key = (char*)(*slot)->key.data.fpfile.fullpath; } - if (!iterator->regex || regexec(&iterator->c_regex, key, 0, NULL, 0) == 0) { + if (!iterator->regex || pcre_exec(iterator->c_regex, NULL, key, strlen(key), 0, 0, NULL, 0) >= 0) { count++; item = apc_iterator_item_ctor(iterator, slot); if (item) { @@ -287,7 +287,7 @@ } else if ((*slot)->key.type == APC_CACHE_KEY_FPFILE) { key = (char*)(*slot)->key.data.fpfile.fullpath; } - if (!iterator->regex || regexec(&iterator->c_regex, key, 0, NULL, 0) == 0) { + if (!iterator->regex || pcre_exec(iterator->c_regex, NULL, key, strlen(key), 0, 0, NULL, 0) >= 0) { iterator->size += (*slot)->value->mem_size; iterator->hits += (*slot)->num_hits; iterator->count++; @@ -350,9 +350,17 @@ iterator->size = 0; iterator->hits = 0; if (regex_len) { + smart_str reg = {0,}; iterator->regex = estrndup(regex, regex_len); iterator->regex_len = regex_len; - if(regcomp(&iterator->c_regex, regex, REG_EXTENDED | REG_NOSUB) != 0) { + smart_str_appendc(®, '/'); + smart_str_appends(®, regex); + smart_str_appendc(®, '/'); + smart_str_0(®); + iterator->c_regex = pcre_get_compiled_regex(reg.c, NULL, NULL TSRMLS_CC); + smart_str_free(®); + + if(!iterator->c_regex) { apc_eprint("Could not compile regular expression: %s", regex); } } else { Index: apc_iterator.h =================================================================== RCS file: /repository/pecl/apc/apc_iterator.h,v retrieving revision 3.1 diff -u -r3.1 apc_iterator.h --- apc_iterator.h 15 Aug 2008 07:52:33 -0000 3.1 +++ apc_iterator.h 18 Aug 2008 12:58:44 -0000 @@ -25,6 +25,12 @@ #include "apc.h" #include "apc_stack.h" +#if HAVE_PCRE || HAVE_BUNDLED_PCRE +#include "ext/pcre/php_pcre.h" +#include "ext/standard/php_smart_str.h" +#endif + + #define APC_ITERATOR_NAME "APCIterator" #define APC_DEFAULT_CHUNK_SIZE 100 @@ -52,7 +58,7 @@ long chunk_size; /* number of entries to pull down per fetch */ apc_stack_t *stack; /* stack of entries pulled from cache */ int stack_idx; /* index into the current stack */ - regex_t c_regex; /* regex filter on entry identifiers */ + pcre *c_regex; /* regex filter on entry identifiers */ char *regex; /* original regex expression or NULL */ int regex_len; /* regex length */ long key_idx; /* incrementing index for numerical keys */