]> granicus.if.org Git - php/commitdiff
Moved some mbregex related portions from mbstring.c to php_mbregex.c
authorMoriyoshi Koizumi <moriyoshi@php.net>
Thu, 14 Nov 2002 18:54:42 +0000 (18:54 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Thu, 14 Nov 2002 18:54:42 +0000 (18:54 +0000)
# No need to merge this change to PHP_4_3 branch

ext/mbstring/mbstring.c
ext/mbstring/php_mbregex.c
ext/mbstring/php_mbregex.h

index bbbf9b6df0abba81e959c06e70a09438a1d7114e..47084ccc91ea123fa274f9ed604908513376ec95 100644 (file)
 #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 @@ function_entry mbstring_functions[] = {
        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 @@ php_mb_parse_encoding_array(zval *array, int **return_list, int *return_size, in
 }
 /* }}} */
 
-#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 @@ php_mb_init_globals(zend_mbstring_globals *pglobals TSRMLS_DC)
        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 @@ static void
 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 @@ PHP_MINIT_FUNCTION(mbstring)
        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 @@ PHP_MSHUTDOWN_FUNCTION(mbstring)
        }
 
 #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 @@ PHP_RINIT_FUNCTION(mbstring)
                }
        }
 #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 @@ PHP_RSHUTDOWN_FUNCTION(mbstring)
        }
 
 #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 8d4dd20ccb6c432fd21018ec1d3628582eb565e7..2332a0ab0b1d88404f7eddbfb82baf6c1bfe9fda 100644 (file)
 
 ZEND_EXTERN_MODULE_GLOBALS(mbstring)
 
+#ifdef ZTS
+static MUTEX_T mbregex_locale_mutex = NULL;
+#endif
+
 /*
  * string buffer
  */
@@ -80,6 +84,94 @@ _php_mb_regex_strbuf_ncat(struct strbuf *pd, const unsigned char *psrc, int len)
        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 e0620a2a83d674e1d7c42e5ffbfe17d74b9168ce..da7030ed63f733c6753ca66061d426fe325a034e 100644 (file)
        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_FUNCTION(mb_eregi);