cvs: php4 /ext/mbstring mbstring.c mbstring.h
| From: | Rui Hirokawa | Date: | Wed, 26 Dec 2001 15:21:14 +0000 |
| Subject: | cvs: php4 /ext/mbstring mbstring.c mbstring.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-8829@lists.php.net to get a copy of this message | ||
hirokawa Wed Dec 26 10:21:14 2001 EDT
Modified files:
/php4/ext/mbstring mbstring.c mbstring.h
Log:
added code to remove overloaded function in RSHUTDOWN.
Index: php4/ext/mbstring/mbstring.c
diff -u php4/ext/mbstring/mbstring.c:1.38 php4/ext/mbstring/mbstring.c:1.39
--- php4/ext/mbstring/mbstring.c:1.38 Sun Dec 23 10:32:08 2001
+++ php4/ext/mbstring/mbstring.c Wed Dec 26 10:21:13 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.c,v 1.38 2001/12/23 15:32:08 hirokawa Exp $ */
+/* $Id: mbstring.c,v 1.39 2001/12/26 15:21:13 hirokawa Exp $ */
/*
* PHP4 Multibyte String module "mbstring" (currently only for Japanese)
@@ -90,11 +90,11 @@
#endif
static struct mb_overload_def mb_ovld[] = {
- {MB_OVERLOAD_MAIL, "mail", "mb_send_mail", NULL},
- {MB_OVERLOAD_STRING, "strlen", "mb_strlen", NULL},
- {MB_OVERLOAD_STRING, "strpos", "mb_strpos", NULL},
- {MB_OVERLOAD_STRING, "strrpos", "mb_strrpos", NULL},
- {MB_OVERLOAD_STRING, "substr", "mb_substr", NULL},
+ {MB_OVERLOAD_MAIL, "mail", "mb_send_mail", "mb_orig_mail"},
+ {MB_OVERLOAD_STRING, "strlen", "mb_strlen", "mb_orig_strlen"},
+ {MB_OVERLOAD_STRING, "strpos", "mb_strpos", "mb_orig_strrpos"},
+ {MB_OVERLOAD_STRING, "strrpos", "mb_strrpos", "mb_orig_strrpos"},
+ {MB_OVERLOAD_STRING, "substr", "mb_substr", "mb_orig_substr"},
{0, NULL, NULL, NULL}
};
@@ -452,7 +452,7 @@
PHP_RINIT_FUNCTION(mbstring)
{
int n, *list, *entry;
- zend_function *func;
+ zend_function *func, *orig;
struct mb_overload_def *p;
TSRMLS_FETCH();
@@ -486,17 +486,15 @@
p = &(mb_ovld[0]);
while (p->type > 0) {
- if ((MBSTRG(func_overload) & p->type) == p->type && !(p->orig)){
- if(zend_hash_find(EG(function_table), p->ovld_func, strlen(p->ovld_func)+1 ,
- (void **)&func) != SUCCESS) {
- php_error(E_ERROR, "mbstring couldn't found function %s.", p->ovld_func);
- }
-
+ if ((MBSTRG(func_overload) & p->type) == p->type &&
+ zend_hash_find(EG(function_table), p->save_func, strlen(p->save_func)+1 , (void
**)&orig) != SUCCESS) {
+ zend_hash_find(EG(function_table), p->ovld_func, strlen(p->ovld_func)+1 , (void
**)&func);
+
if (zend_hash_find(EG(function_table), p->orig_func,
- strlen(p->orig_func)+1, (void **)&(p->orig)) != SUCCESS) {
+ strlen(p->orig_func)+1, (void **)&orig) != SUCCESS) {
php_error(E_ERROR, "mbstring couldn't found function %s.", p->orig_func);
}
-
+ zend_hash_add(EG(function_table), p->save_func, strlen(p->save_func)+1, orig,
sizeof(zend_function), NULL);
if (zend_hash_update(EG(function_table), p->orig_func, strlen(p->orig_func)+1,
func, sizeof(zend_function), NULL) == FAILURE){
php_error(E_ERROR, "mbstring couldn't replace function %s.", p->orig_func);
@@ -512,6 +510,10 @@
PHP_RSHUTDOWN_FUNCTION(mbstring)
{
+ struct mb_overload_def *p;
+ zend_function *orig;
+ TSRMLS_FETCH();
+
if (MBSTRG(current_detect_order_list) != NULL) {
efree(MBSTRG(current_detect_order_list));
MBSTRG(current_detect_order_list) = NULL;
@@ -528,6 +530,16 @@
MBSTRG(http_input_identify_get) = mbfl_no_encoding_invalid;
MBSTRG(http_input_identify_cookie) = mbfl_no_encoding_invalid;
MBSTRG(http_input_identify_string) = mbfl_no_encoding_invalid;
+
+ /* clear overloaded function. */
+ if (MBSTRG(func_overload)){
+ p = &(mb_ovld[0]);
+ while (p->type > 0 && zend_hash_find(EG(function_table), p->save_func,
strlen(p->save_func)+1 , (void **)&orig) == SUCCESS) {
+ zend_hash_update(EG(function_table), p->orig_func, strlen(p->orig_func)+1, orig,
sizeof(zend_function), NULL);
+ zend_hash_del(EG(function_table), p->save_func, strlen(p->save_func)+1);
+ p++;
+ }
+ }
return SUCCESS;
}
Index: php4/ext/mbstring/mbstring.h
diff -u php4/ext/mbstring/mbstring.h:1.10 php4/ext/mbstring/mbstring.h:1.11
--- php4/ext/mbstring/mbstring.h:1.10 Sun Dec 23 10:32:08 2001
+++ php4/ext/mbstring/mbstring.h Wed Dec 26 10:21:13 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.h,v 1.10 2001/12/23 15:32:08 hirokawa Exp $ */
+/* $Id: mbstring.h,v 1.11 2001/12/26 15:21:13 hirokawa Exp $ */
/*
* PHP4 Multibyte String module "mbstring" (currently only for Japanese)
@@ -124,7 +124,7 @@
int type;
char *orig_func;
char *ovld_func;
- zend_function *orig;
+ char *save_func;
};
#ifdef ZTS