moriyoshi               Thu Nov 14 13:54:42 2002 EDT

  Modified files:              
    /php4/ext/mbstring  mbstring.c php_mbregex.c php_mbregex.h 
  Log:
  Moved some mbregex related portions from mbstring.c to php_mbregex.c
  # No need to merge this change to PHP_4_3 branch
  
  
Index: php4/ext/mbstring/mbstring.c
diff -u php4/ext/mbstring/mbstring.c:1.143 php4/ext/mbstring/mbstring.c:1.144
--- php4/ext/mbstring/mbstring.c:1.143  Wed Nov 13 18:11:14 2002
+++ php4/ext/mbstring/mbstring.c        Thu Nov 14 13:54:42 2002
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: mbstring.c,v 1.143 2002/11/13 23:11:14 edink Exp $ */
+/* $Id: mbstring.c,v 1.144 2002/11/14 18:54:42 moriyoshi Exp $ */
 
 /*
  * PHP4 Multibyte String module "mbstring" (currently only for Japanese)
@@ -78,10 +78,6 @@
 #endif
 /* }}} */
 
-#ifdef ZTS
-MUTEX_T mbregex_locale_mutex = NULL;
-#endif
-
 /* {{{ php_mbstr_default_identify_list[] */
 #if defined(HAVE_MBSTR_JA)
 static const enum mbfl_no_encoding php_mbstr_default_identify_list[] = {
@@ -244,35 +240,7 @@
        PHP_FALIAS(i18n_mime_header_decode,     mb_decode_mimeheader,   NULL)
        PHP_FALIAS(i18n_ja_jp_hantozen,         mb_convert_kana,                NULL)
 #if HAVE_MBREGEX
-       PHP_FE(mb_regex_encoding,       NULL)
-       PHP_FE(mb_regex_set_options,    NULL)
-       PHP_FE(mb_ereg,                 (unsigned char *)third_argument_force_ref)
-       PHP_FE(mb_eregi,                        (unsigned char 
*)third_argument_force_ref)
-       PHP_FE(mb_ereg_replace,                 NULL)
-       PHP_FE(mb_eregi_replace,                        NULL)
-       PHP_FE(mb_split,                                        NULL)
-       PHP_FE(mb_ereg_match,                   NULL)
-       PHP_FE(mb_ereg_search,                  NULL)
-       PHP_FE(mb_ereg_search_pos,              NULL)
-       PHP_FE(mb_ereg_search_regs,             NULL)
-       PHP_FE(mb_ereg_search_init,             NULL)
-       PHP_FE(mb_ereg_search_getregs,  NULL)
-       PHP_FE(mb_ereg_search_getpos,   NULL)
-       PHP_FE(mb_ereg_search_setpos,   NULL)
-       PHP_FALIAS(mbregex_encoding,    mb_regex_encoding,      NULL)
-       PHP_FALIAS(mbereg,      mb_ereg,        NULL)
-       PHP_FALIAS(mberegi,     mb_eregi,       NULL)
-       PHP_FALIAS(mbereg_replace,      mb_ereg_replace,        NULL)
-       PHP_FALIAS(mberegi_replace,     mb_eregi_replace,       NULL)
-       PHP_FALIAS(mbsplit,     mb_split,       NULL)
-       PHP_FALIAS(mbereg_match,        mb_ereg_match,  NULL)
-       PHP_FALIAS(mbereg_search,       mb_ereg_search, NULL)
-       PHP_FALIAS(mbereg_search_pos,   mb_ereg_search_pos,     NULL)
-       PHP_FALIAS(mbereg_search_regs,  mb_ereg_search_regs,    NULL)
-       PHP_FALIAS(mbereg_search_init,  mb_ereg_search_init,    NULL)
-       PHP_FALIAS(mbereg_search_getregs,       mb_ereg_search_getregs, NULL)
-       PHP_FALIAS(mbereg_search_getpos,        mb_ereg_search_getpos,  NULL)
-       PHP_FALIAS(mbereg_search_setpos,        mb_ereg_search_setpos,  NULL)
+       PHP_MBREGEX_FUNCTION_ENTRIES
 #endif
        { NULL, NULL, NULL }
 };
@@ -502,16 +470,6 @@
 }
 /* }}} */
 
-#if HAVE_MBREGEX
-/* {{{ static void php_mbregex_free_cache() */
-static void
-php_mbregex_free_cache(mb_regex_t *pre) 
-{
-       mbre_free_pattern(pre);
-}
-/* }}} */
-#endif
-
 /* {{{ php.ini directive handler */
 static PHP_INI_MH(OnUpdate_mbstring_language)
 {
@@ -772,14 +730,7 @@
        MBSTRG(encoding_translation) = 0;
        pglobals->outconv = NULL;
 #if HAVE_MBREGEX
-       MBSTRG(default_mbctype) = MBCTYPE_EUC;
-       MBSTRG(current_mbctype) = MBCTYPE_EUC;
-       zend_hash_init(&(MBSTRG(ht_rc)), 0, NULL, (void (*)(void *)) 
php_mbregex_free_cache, 1);
-       MBSTRG(search_str) = (zval**)0;
-       MBSTRG(search_str_val) = (zval*)0;
-       MBSTRG(search_re) = (mb_regex_t*)0;
-       MBSTRG(search_pos) = 0;
-       MBSTRG(search_regs) = (struct mbre_registers*)0;
+       php_mb_regex_globals_ctor(pglobals TSRMLS_CC);
 #endif
 }
 /* }}} */
@@ -789,7 +740,7 @@
 mbstring_globals_dtor(zend_mbstring_globals *pglobals TSRMLS_DC)
 {
 #if HAVE_MBREGEX
-       zend_hash_destroy(&MBSTRG(ht_rc));
+       php_mb_regex_globals_dtor(pglobals TSRMLS_CC);
 #endif
 }
 /* }}} */
@@ -823,9 +774,7 @@
        REGISTER_LONG_CONSTANT("MB_CASE_TITLE", PHP_UNICODE_CASE_TITLE, CONST_CS | 
CONST_PERSISTENT);
 
 #if HAVE_MBREGEX
-# ifdef ZTS
-       mbregex_locale_mutex = tsrm_mutex_alloc();
-# endif
+       PHP_MINIT(mb_regex) (INIT_FUNC_ARGS_PASSTHRU);
 #endif
        return SUCCESS;
 }
@@ -855,11 +804,7 @@
        }
 
 #if HAVE_MBREGEX
-# ifdef ZTS
-       if (mbregex_locale_mutex != NULL) {
-               tsrm_mutex_free(mbregex_locale_mutex);
-       }
-# endif
+       PHP_MSHUTDOWN(mb_regex) (INIT_FUNC_ARGS_PASSTHRU);
 #endif
 
 #ifdef ZTS
@@ -932,7 +877,7 @@
                }
        }
 #if HAVE_MBREGEX
-       MBSTRG(regex_default_options) = MBRE_OPTION_POSIXLINE;
+       PHP_RINIT(mb_regex) (INIT_FUNC_ARGS_PASSTHRU);
 #endif
 
        return SUCCESS;
@@ -973,28 +918,7 @@
        }
 
 #if HAVE_MBREGEX
-       MBSTRG(current_mbctype) = MBSTRG(default_mbctype);
-       if (MBSTRG(search_str)) {
-               if (ZVAL_REFCOUNT(*MBSTRG(search_str)) > 1) {
-                       ZVAL_DELREF(*MBSTRG(search_str));
-               } else {
-                       zval_dtor(*MBSTRG(search_str));
-                       FREE_ZVAL(*MBSTRG(search_str));
-               }
-               MBSTRG(search_str) = (zval **)0;
-               MBSTRG(search_str_val) = (zval *)0;
-       }
-       MBSTRG(search_pos) = 0;
-       if (MBSTRG(search_re)) {
-               efree(MBSTRG(search_re));
-               MBSTRG(search_re) = (mb_regex_t *)0;
-       }
-       if (MBSTRG(search_regs)) {
-               mbre_free_registers(MBSTRG(search_regs));
-               efree(MBSTRG(search_regs));
-               MBSTRG(search_regs) = (struct mbre_registers*)0;
-       }
-       zend_hash_clean(&MBSTRG(ht_rc));
+       PHP_RSHUTDOWN(mb_regex) (INIT_FUNC_ARGS_PASSTHRU);
 #endif
 
        return SUCCESS;
Index: php4/ext/mbstring/php_mbregex.c
diff -u php4/ext/mbstring/php_mbregex.c:1.19 php4/ext/mbstring/php_mbregex.c:1.20
--- php4/ext/mbstring/php_mbregex.c:1.19        Wed Nov 13 18:11:14 2002
+++ php4/ext/mbstring/php_mbregex.c     Thu Nov 14 13:54:42 2002
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_mbregex.c,v 1.19 2002/11/13 23:11:14 edink Exp $ */
+/* $Id: php_mbregex.c,v 1.20 2002/11/14 18:54:42 moriyoshi Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -33,6 +33,10 @@
 
 ZEND_EXTERN_MODULE_GLOBALS(mbstring)
 
+#ifdef ZTS
+static MUTEX_T mbregex_locale_mutex = NULL;
+#endif
+
 /*
  * string buffer
  */
@@ -80,6 +84,94 @@
        return len;
 }
 
+/* {{{ static void php_mb_regex_free_cache() */
+static void php_mb_regex_free_cache(mb_regex_t *pre) 
+{
+       mbre_free_pattern(pre);
+}
+/* }}} */
+
+/* {{{ php_mb_regex_globals_ctor */
+void php_mb_regex_globals_ctor(zend_mbstring_globals *pglobals TSRMLS_DC)
+{
+       MBSTRG(default_mbctype) = MBCTYPE_EUC;
+       MBSTRG(current_mbctype) = MBCTYPE_EUC;
+       zend_hash_init(&(MBSTRG(ht_rc)), 0, NULL, (void (*)(void *)) 
+php_mb_regex_free_cache, 1);
+       MBSTRG(search_str) = (zval**)0;
+       MBSTRG(search_str_val) = (zval*)0;
+       MBSTRG(search_re) = (mb_regex_t*)0;
+       MBSTRG(search_pos) = 0;
+       MBSTRG(search_regs) = (struct mbre_registers*)0;
+}
+/* }}} */
+
+/* {{{ php_mb_regex_globals_dtor */
+void php_mb_regex_globals_dtor(zend_mbstring_globals *pglobals TSRMLS_DC) 
+{
+       zend_hash_destroy(&MBSTRG(ht_rc));
+}
+/* }}} */
+
+/* {{{ PHP_MINIT_FUNCTION(mb_regex) */
+PHP_MINIT_FUNCTION(mb_regex)
+{
+# ifdef ZTS
+       mbregex_locale_mutex = tsrm_mutex_alloc();
+# endif
+       return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_MSHUTDOWN_FUNCTION(mb_regex) */
+PHP_MSHUTDOWN_FUNCTION(mb_regex)
+{
+#ifdef ZTS
+       if (mbregex_locale_mutex != NULL) {
+               tsrm_mutex_free(mbregex_locale_mutex);
+       }
+#endif
+       return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_RINIT_FUNCTION(mb_regex) */
+PHP_RINIT_FUNCTION(mb_regex)
+{
+       MBSTRG(regex_default_options) = MBRE_OPTION_POSIXLINE;
+
+       return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_RSHUTDOWN_FUNCTION(mb_regex) */
+PHP_RSHUTDOWN_FUNCTION(mb_regex)
+{
+       MBSTRG(current_mbctype) = MBSTRG(default_mbctype);
+       if (MBSTRG(search_str)) {
+               if (ZVAL_REFCOUNT(*MBSTRG(search_str)) > 1) {
+                       ZVAL_DELREF(*MBSTRG(search_str));
+               } else {
+                       zval_dtor(*MBSTRG(search_str));
+                       FREE_ZVAL(*MBSTRG(search_str));
+               }
+               MBSTRG(search_str) = (zval **)0;
+               MBSTRG(search_str_val) = (zval *)0;
+       }
+       MBSTRG(search_pos) = 0;
+       if (MBSTRG(search_re)) {
+               efree(MBSTRG(search_re));
+               MBSTRG(search_re) = (mb_regex_t *)0;
+       }
+       if (MBSTRG(search_regs)) {
+               mbre_free_registers(MBSTRG(search_regs));
+               efree(MBSTRG(search_regs));
+               MBSTRG(search_regs) = (struct mbre_registers*)0;
+       }
+       zend_hash_clean(&MBSTRG(ht_rc));
+
+       return SUCCESS;
+}
+/* }}} */
 
 /*
  * encoding name resolver
Index: php4/ext/mbstring/php_mbregex.h
diff -u php4/ext/mbstring/php_mbregex.h:1.3 php4/ext/mbstring/php_mbregex.h:1.4
--- php4/ext/mbstring/php_mbregex.h:1.3 Wed Nov 13 18:11:14 2002
+++ php4/ext/mbstring/php_mbregex.h     Thu Nov 14 13:54:42 2002
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_mbregex.h,v 1.3 2002/11/13 23:11:14 edink Exp $ */
+/* $Id: php_mbregex.h,v 1.4 2002/11/14 18:54:42 moriyoshi Exp $ */
  
 #ifndef _PHP_MBREGEX_H
 #define _PHP_MBREGEX_H
@@ -40,11 +40,53 @@
        int regex_default_options;
 /* }}} */
 
+/* {{{ PHP_MBREGEX_FUNCTION_ENTRIES */
+#define PHP_MBREGEX_FUNCTION_ENTRIES \
+       PHP_FE(mb_regex_encoding,       NULL) \
+       PHP_FE(mb_regex_set_options,    NULL) \
+       PHP_FE(mb_ereg,                 (unsigned char *)third_argument_force_ref) \
+       PHP_FE(mb_eregi,                        (unsigned char 
+*)third_argument_force_ref) \
+       PHP_FE(mb_ereg_replace,                 NULL) \
+       PHP_FE(mb_eregi_replace,                        NULL) \
+       PHP_FE(mb_split,                                        NULL) \
+       PHP_FE(mb_ereg_match,                   NULL) \
+       PHP_FE(mb_ereg_search,                  NULL) \
+       PHP_FE(mb_ereg_search_pos,              NULL) \
+       PHP_FE(mb_ereg_search_regs,             NULL) \
+       PHP_FE(mb_ereg_search_init,             NULL) \
+       PHP_FE(mb_ereg_search_getregs,  NULL) \
+       PHP_FE(mb_ereg_search_getpos,   NULL) \
+       PHP_FE(mb_ereg_search_setpos,   NULL) \
+       PHP_FALIAS(mbregex_encoding,    mb_regex_encoding,      NULL) \
+       PHP_FALIAS(mbereg,      mb_ereg,        NULL) \
+       PHP_FALIAS(mberegi,     mb_eregi,       NULL) \
+       PHP_FALIAS(mbereg_replace,      mb_ereg_replace,        NULL) \
+       PHP_FALIAS(mberegi_replace,     mb_eregi_replace,       NULL) \
+       PHP_FALIAS(mbsplit,     mb_split,       NULL) \
+       PHP_FALIAS(mbereg_match,        mb_ereg_match,  NULL) \
+       PHP_FALIAS(mbereg_search,       mb_ereg_search, NULL) \
+       PHP_FALIAS(mbereg_search_pos,   mb_ereg_search_pos,     NULL) \
+       PHP_FALIAS(mbereg_search_regs,  mb_ereg_search_regs,    NULL) \
+       PHP_FALIAS(mbereg_search_init,  mb_ereg_search_init,    NULL) \
+       PHP_FALIAS(mbereg_search_getregs,       mb_ereg_search_getregs, NULL) \
+       PHP_FALIAS(mbereg_search_getpos,        mb_ereg_search_getpos,  NULL) \
+       PHP_FALIAS(mbereg_search_setpos,        mb_ereg_search_setpos,  NULL)
+/* }}} */
+
+typedef struct _zend_mbstring_globals * zend_mbstring_globals_ptr;
+
 #define PHP_MBREGEX_MAXCACHE 50
 
 int php_mb_regex_name2mbctype(const char *pname);
 int php_mb_regex_set_options(int options TSRMLS_DC);
 int php_mb_regex_set_options_by_string(const char *optstr, int len TSRMLS_DC);
+
+PHP_MINIT_FUNCTION(mb_regex);
+PHP_MSHUTDOWN_FUNCTION(mb_regex);
+PHP_RINIT_FUNCTION(mb_regex);
+PHP_RSHUTDOWN_FUNCTION(mb_regex);
+void php_mb_regex_globals_ctor(zend_mbstring_globals_ptr pglobals TSRMLS_DC);
+void php_mb_regex_globals_dtor(zend_mbstring_globals_ptr pglobals TSRMLS_DC);
 
 PHP_FUNCTION(mb_regex_encoding);
 PHP_FUNCTION(mb_ereg);

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

Reply via email to