cvs: /php4/ext/pcre php_pcre.c php_pcre.h
| From: | Andrey Zmievski | Date: | Tue, 20 Jul 1999 16:57:04 +0000 |
| Subject: | cvs: /php4/ext/pcre php_pcre.c php_pcre.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-2349@lists.php.net to get a copy of this message | ||
andrey Tue Jul 20 16:57:04 1999 EDT
Modified files:
/php4/ext/pcre php_pcre.c php_pcre.h
Log:
Added locale support.
Index: php4/ext/pcre/php_pcre.c
diff -u php4/ext/pcre/php_pcre.c:1.8 php4/ext/pcre/php_pcre.c:1.9
--- php4/ext/pcre/php_pcre.c:1.8 Sat Jul 17 16:03:10 1999
+++ php4/ext/pcre/php_pcre.c Tue Jul 20 16:57:04 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcre.c,v 1.8 1999/07/17 20:03:10 andrey Exp $ */
+/* $Id: php_pcre.c,v 1.9 1999/07/20 20:57:04 andrey Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -77,6 +77,9 @@
{
pcre_cache_entry *pce = (pcre_cache_entry *) data;
pefree(pce->re, 1);
+#if HAVE_SETLOCALE
+ pefree((void*)pce->tables, 1);
+#endif
return 1;
}
@@ -163,6 +166,10 @@
int regex_len;
int do_study = 0;
int poptions = 0;
+ unsigned const char *tables = NULL;
+#if HAVE_SETLOCALE
+ char *locale = setlocale(LC_CTYPE, NULL);
+#endif
pcre_cache_entry *pce;
pcre_cache_entry new_entry;
PCRE_LS_FETCH();
@@ -171,9 +178,15 @@
back the compiled pattern, otherwise go on and compile it. */
regex_len = strlen(regex);
if (zend_hash_find(&PCRE_G(pcre_cache), regex, regex_len+1, (void **)&pce) == SUCCESS) {
- extra = pce->extra;
- *preg_options = pce->preg_options;
- return pce->re;
+#if HAVE_SETLOCALE
+ if (!strcmp(pce->locale, locale)) {
+#endif
+ extra = pce->extra;
+ *preg_options = pce->preg_options;
+ return pce->re;
+#if HAVE_SETLOCALE
+ }
+#endif
}
p = regex;
@@ -247,13 +260,18 @@
return NULL;
}
}
+
+#if HAVE_SETLOCALE
+ if (strcmp(locale, "C"))
+ tables = pcre_maketables();
+#endif
/* Compile pattern and display a warning if compilation failed. */
re = pcre_compile(pattern,
coptions,
&error,
&erroffset,
- NULL);
+ tables);
if (re == NULL) {
zend_error(E_WARNING, "Compilation failed: %s at offset %d\n", error, erroffset);
@@ -278,6 +296,10 @@
new_entry.re = re;
new_entry.extra = extra;
new_entry.preg_options = poptions;
+#if HAVE_SETLOCALE
+ new_entry.locale = locale;
+ new_entry.tables = tables;
+#endif
zend_hash_update(&PCRE_G(pcre_cache), regex, regex_len+1, (void *)&new_entry,
sizeof(pcre_cache_entry), NULL);
Index: php4/ext/pcre/php_pcre.h
diff -u php4/ext/pcre/php_pcre.h:1.10 php4/ext/pcre/php_pcre.h:1.11
--- php4/ext/pcre/php_pcre.h:1.10 Mon Jul 5 11:25:51 1999
+++ php4/ext/pcre/php_pcre.h Tue Jul 20 16:57:04 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pcre.h,v 1.10 1999/07/05 15:25:51 andrey Exp $ */
+/* $Id: php_pcre.h,v 1.11 1999/07/20 20:57:04 andrey Exp $ */
#ifndef _PHP_PCRE_H
#define _PHP_PCRE_H
@@ -35,6 +35,9 @@
#if HAVE_PCRE
#include "pcrelib/pcre.h"
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
extern void php_info_pcre(ZEND_MODULE_INFO_FUNC_ARGS);
extern int php_minit_pcre(INIT_FUNC_ARGS);
@@ -55,6 +58,10 @@
pcre *re;
pcre_extra *extra;
int preg_options;
+#if HAVE_SETLOCALE
+ char *locale;
+ unsigned const char *tables;
+#endif
} pcre_cache_entry;
typedef struct {