summaryrefslogtreecommitdiff
path: root/ext/ereg
diff options
context:
space:
mode:
authorKalle Sommer Nielsen <kalle@php.net>2010-05-24 07:44:00 +0000
committerKalle Sommer Nielsen <kalle@php.net>2010-05-24 07:44:00 +0000
commit1cabc8cd3a3bf5c12a8ece9efb59e3f5381f1ae5 (patch)
treee743a14505e462e952bfb5dc3c3a4b951de59845 /ext/ereg
parentab9de550e2726011c81f868484622bd9924ddea2 (diff)
downloadphp-git-1cabc8cd3a3bf5c12a8ece9efb59e3f5381f1ae5.tar.gz
Allow ereg to be built as shared on Windows
## I know that we may remove ereg in trunk, but since the core doesn't depend on ## ereg, then I don't see any reason not to allow this
Diffstat (limited to 'ext/ereg')
-rw-r--r--ext/ereg/config.w322
-rw-r--r--ext/ereg/ereg.c49
-rw-r--r--ext/ereg/php_ereg.h16
3 files changed, 39 insertions, 28 deletions
diff --git a/ext/ereg/config.w32 b/ext/ereg/config.w32
index 59cdb04685..8b383ddfeb 100644
--- a/ext/ereg/config.w32
+++ b/ext/ereg/config.w32
@@ -4,7 +4,7 @@
ARG_WITH("ereg", "POSIX extended regular expressions", "yes");
if (PHP_EREG != "no") {
- EXTENSION("ereg", "ereg.c", false /* never shared */, "-Dregexec=php_regexec -Dregerror=php_regerror -Dregfree=php_regfree -Dregcomp=php_regcomp -Iext/ereg/regex");
+ EXTENSION("ereg", "ereg.c", PHP_EREG_SHARED, "-Dregexec=php_regexec -Dregerror=php_regerror -Dregfree=php_regfree -Dregcomp=php_regcomp -Iext/ereg/regex");
ADD_SOURCES("ext/ereg/regex", "regcomp.c regexec.c regerror.c regfree.c", "ereg");
AC_DEFINE('REGEX', 1, 'Bundled regex');
AC_DEFINE('HSREGEX', 1, 'Bundled regex');
diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c
index e1726cbeef..e0c1ce3798 100644
--- a/ext/ereg/ereg.c
+++ b/ext/ereg/ereg.c
@@ -74,22 +74,34 @@ static int reg_magic = 0;
/* }}} */
ZEND_DECLARE_MODULE_GLOBALS(ereg)
+static PHP_GINIT_FUNCTION(ereg);
+static PHP_GSHUTDOWN_FUNCTION(ereg);
/* {{{ Module entry */
zend_module_entry ereg_module_entry = {
STANDARD_MODULE_HEADER,
"ereg",
ereg_functions,
- PHP_MINIT(ereg),
- PHP_MSHUTDOWN(ereg),
+ NULL,
+ NULL,
NULL,
NULL,
PHP_MINFO(ereg),
NO_VERSION_YET,
- STANDARD_MODULE_PROPERTIES
+ PHP_MODULE_GLOBALS(ereg),
+ PHP_GINIT(ereg),
+ PHP_GSHUTDOWN(ereg),
+ NULL,
+ STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
+/* {{{ COMPILE_DL_EREG */
+#ifdef COMPILE_DL_EREG
+ZEND_GET_MODULE(ereg)
+#endif
+/* }}} */
+
/* {{{ ereg_lru_cmp */
static int ereg_lru_cmp(const void *a, const void *b TSRMLS_DC)
{
@@ -201,32 +213,23 @@ static void _free_ereg_cache(reg_cache *rc)
#define regfree(a);
#undef regcomp
#define regcomp(a, b, c) _php_regcomp(a, b, c TSRMLS_CC)
-
-static void php_ereg_init_globals(zend_ereg_globals *ereg_globals TSRMLS_DC)
+
+/* {{{ PHP_GINIT_FUNCTION
+ */
+static PHP_GINIT_FUNCTION(ereg)
{
zend_hash_init(&ereg_globals->ht_rc, 0, NULL, (void (*)(void *)) _free_ereg_cache, 1);
ereg_globals->lru_counter = 0;
}
+/* }}} */
-static void php_ereg_destroy_globals(zend_ereg_globals *ereg_globals TSRMLS_DC)
+/* {{{ PHP_GSHUTDOWN_FUNCTION
+ */
+static PHP_GSHUTDOWN_FUNCTION(ereg)
{
zend_hash_destroy(&ereg_globals->ht_rc);
}
-
-PHP_MINIT_FUNCTION(ereg)
-{
- ZEND_INIT_MODULE_GLOBALS(ereg, php_ereg_init_globals, php_ereg_destroy_globals);
- return SUCCESS;
-}
-
-PHP_MSHUTDOWN_FUNCTION(ereg)
-{
-#ifndef ZTS
- php_ereg_destroy_globals(&ereg_globals TSRMLS_CC);
-#endif
-
- return SUCCESS;
-}
+/* }}} */
PHP_MINFO_FUNCTION(ereg)
{
@@ -399,7 +402,7 @@ PHP_FUNCTION(eregi)
/* {{{ php_ereg_replace
* this is the meat and potatoes of regex replacement! */
-PHPAPI char *php_ereg_replace(const char *pattern, const char *replace, const char *string, int icase, int extended TSRMLS_DC)
+PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, const char *string, int icase, int extended TSRMLS_DC)
{
regex_t re;
regmatch_t *subs;
@@ -726,7 +729,7 @@ PHP_FUNCTION(spliti)
/* {{{ proto string sql_regcase(string string)
Make regular expression for case insensitive match */
-PHPAPI PHP_FUNCTION(sql_regcase)
+PHP_EREG_API PHP_FUNCTION(sql_regcase)
{
char *string, *tmp;
int string_len;
diff --git a/ext/ereg/php_ereg.h b/ext/ereg/php_ereg.h
index ad7d546338..9c489d742a 100644
--- a/ext/ereg/php_ereg.h
+++ b/ext/ereg/php_ereg.h
@@ -27,7 +27,15 @@
extern zend_module_entry ereg_module_entry;
#define phpext_ereg_ptr &ereg_module_entry
-PHPAPI char *php_ereg_replace(const char *pattern, const char *replace, const char *string, int icase, int extended TSRMLS_DC);
+#ifdef PHP_WIN32
+# define PHP_EREG_API __declspec(dllexport)
+#elif defined(__GNUC__) && __GNUC__ >= 4
+# define PHP_EREG_API __attribute__ ((visibility("default")))
+#else
+# define PHP_EREG_API
+#endif
+
+PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, const char *string, int icase, int extended TSRMLS_DC);
PHP_FUNCTION(ereg);
PHP_FUNCTION(eregi);
@@ -35,7 +43,7 @@ PHP_FUNCTION(eregi_replace);
PHP_FUNCTION(ereg_replace);
PHP_FUNCTION(split);
PHP_FUNCTION(spliti);
-PHPAPI PHP_FUNCTION(sql_regcase);
+PHP_EREG_API PHP_FUNCTION(sql_regcase);
ZEND_BEGIN_MODULE_GLOBALS(ereg)
HashTable ht_rc;
@@ -43,8 +51,6 @@ ZEND_BEGIN_MODULE_GLOBALS(ereg)
ZEND_END_MODULE_GLOBALS(ereg)
/* Module functions */
-PHP_MINIT_FUNCTION(ereg);
-PHP_MSHUTDOWN_FUNCTION(ereg);
PHP_MINFO_FUNCTION(ereg);
#ifdef ZTS
@@ -53,4 +59,6 @@ PHP_MINFO_FUNCTION(ereg);
#define EREG(v) (ereg_globals.v)
#endif
+ZEND_EXTERN_MODULE_GLOBALS(ereg)
+
#endif /* REG_H */