kalle                                    Mon, 24 May 2010 07:44:00 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=299681

Log:
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

Changed paths:
    U   php/php-src/trunk/ext/ereg/config.w32
    U   php/php-src/trunk/ext/ereg/ereg.c
    U   php/php-src/trunk/ext/ereg/php_ereg.h

Modified: php/php-src/trunk/ext/ereg/config.w32
===================================================================
--- php/php-src/trunk/ext/ereg/config.w32       2010-05-24 05:19:47 UTC (rev 
299680)
+++ php/php-src/trunk/ext/ereg/config.w32       2010-05-24 07:44:00 UTC (rev 
299681)
@@ -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');

Modified: php/php-src/trunk/ext/ereg/ereg.c
===================================================================
--- php/php-src/trunk/ext/ereg/ereg.c   2010-05-24 05:19:47 UTC (rev 299680)
+++ php/php-src/trunk/ext/ereg/ereg.c   2010-05-24 07:44:00 UTC (rev 299681)
@@ -74,22 +74,34 @@
 /* }}} */

 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,33 +213,24 @@
 #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)
 {
        php_info_print_table_start();
@@ -399,7 +402,7 @@

 /* {{{ 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 @@

 /* {{{ 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;

Modified: php/php-src/trunk/ext/ereg/php_ereg.h
===================================================================
--- php/php-src/trunk/ext/ereg/php_ereg.h       2010-05-24 05:19:47 UTC (rev 
299680)
+++ php/php-src/trunk/ext/ereg/php_ereg.h       2010-05-24 07:44:00 UTC (rev 
299681)
@@ -27,15 +27,23 @@
 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);
 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_END_MODULE_GLOBALS(ereg)

 /* Module functions */
-PHP_MINIT_FUNCTION(ereg);
-PHP_MSHUTDOWN_FUNCTION(ereg);
 PHP_MINFO_FUNCTION(ereg);

 #ifdef ZTS
@@ -53,4 +59,6 @@
 #define EREG(v) (ereg_globals.v)
 #endif

+ZEND_EXTERN_MODULE_GLOBALS(ereg)
+
 #endif /* REG_H */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to