cvs: php4 /ext/mbstring mbstring.c mbstring.h /ext/standard string.c /main SAPI.c SAPI.h main.c php_content_types.c php_main.h php_variables.c
rfc1867.c

From: Date: Fri, 02 Aug 2002 06:53:48 +0000
Subject: cvs: php4 /ext/mbstring mbstring.c mbstring.h /ext/standard string.c /main SAPI.c SAPI.h main.c php_content_types.c php_main.h php_variables.c
rfc1867.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-13088@lists.php.net to get a copy of this message
hirokawa Fri Aug 2 02:53:48 2002 EDT Modified files: /php4/ext/mbstring mbstring.c mbstring.h /php4/ext/standard string.c /php4/main SAPI.c SAPI.h main.c php_content_types.c php_main.h php_variables.c rfc1867.c Log: made sapi_register_treat_data() to support multibyte input encoding translation without MBSTR_ENC_TRANS and changed php_treat_data to php_default_treat_data.

Index: php4/ext/mbstring/mbstring.c diff -u php4/ext/mbstring/mbstring.c:1.84 php4/ext/mbstring/mbstring.c:1.85 --- php4/ext/mbstring/mbstring.c:1.84 Wed Jul 31 10:41:06 2002 +++ php4/ext/mbstring/mbstring.c Fri Aug 2 02:53:47 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.84 2002/07/31 14:41:06 zeev Exp $ */ +/* $Id: mbstring.c,v 1.85 2002/08/02 06:53:47 hirokawa Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -137,15 +137,12 @@ #if HAVE_MBREGEX static unsigned char third_argument_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE }; #endif -#if defined(MBSTR_ENC_TRANS) -SAPI_POST_HANDLER_FUNC(php_mbstr_post_handler); static sapi_post_entry mbstr_post_entries[] = { { DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data, php_mbstr_post_handler }, { MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, NULL, rfc1867_post_handler }, { NULL, 0, NULL, NULL } }; -#endif static struct mb_overload_def mb_ovld[] = { {MB_OVERLOAD_MAIL, "mail", "mb_send_mail", "mb_orig_mail"}, @@ -646,6 +643,9 @@ #endif /* ZEND_MULTIBYTE */ PHP_INI_ENTRY("mbstring.substitute_character", NULL, PHP_INI_ALL, OnUpdate_mbstring_substitute_character) STD_PHP_INI_ENTRY("mbstring.func_overload", "0", PHP_INI_SYSTEM, OnUpdateInt, func_overload, zend_mbstring_globals, mbstring_globals) +#if !defined(COMPILE_DL_MBSTRING) + STD_PHP_INI_BOOLEAN("mbstring.encoding_translation", "0", PHP_INI_SYSTEM, OnUpdateBool, encoding_translation, zend_mbstring_globals, mbstring_globals) +#endif /* !defined(COMPILE_DL_MBSTRING) */ PHP_INI_END() @@ -704,6 +704,7 @@ MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR; MBSTRG(current_filter_illegal_substchar) = 0x3f; /* '?' */ MBSTRG(func_overload) = 0; + MBSTRG(encoding_translation) = 0; pglobals->outconv = NULL; #if HAVE_MBREGEX MBSTRG(default_mbctype) = MBCTYPE_EUC; @@ -727,10 +728,12 @@ REGISTER_INI_ENTRIES(); -#if defined(MBSTR_ENC_TRANS) - sapi_unregister_post_entry(mbstr_post_entries); - sapi_register_post_entries(mbstr_post_entries); -#endif + + if(MBSTRG(encoding_translation)) { + sapi_unregister_post_entry(mbstr_post_entries); + sapi_register_post_entries(mbstr_post_entries); + sapi_register_treat_data(mbstr_treat_data); + } REGISTER_LONG_CONSTANT("MB_OVERLOAD_MAIL", MB_OVERLOAD_MAIL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MB_OVERLOAD_STRING", MB_OVERLOAD_STRING, CONST_CS | CONST_PERSISTENT); @@ -756,6 +759,10 @@ free(MBSTRG(detect_order_list)); } + if(MBSTRG(encoding_translation)) { + sapi_register_treat_data(php_default_treat_data); + } + #if HAVE_MBREGEX zend_hash_destroy(&MBSTRG(ht_rc)); #endif @@ -899,9 +906,9 @@ #if defined(HAVE_MBSTR_KR) php_info_print_table_row(2, "korean support", "enabled"); #endif -#if defined(MBSTR_ENC_TRANS) - php_info_print_table_row(2, "http input encoding translation", "enabled"); -#endif + if(MBSTRG(encoding_translation)) { + php_info_print_table_row(2, "http input encoding translation", "enabled"); + } #if defined(HAVE_MBREGEX) php_info_print_table_row(2, "multibyte (japanese) regex support", "enabled"); #endif @@ -1227,7 +1234,6 @@ } /* }}} */ -#if defined(MBSTR_ENC_TRANS) static void php_mbstr_encoding_handler(zval *arg, char *res, char *separator TSRMLS_DC) { @@ -1412,7 +1418,7 @@ } /* http input processing */ -void mbstr_treat_data(int arg, char *str, zval* destArray TSRMLS_DC) +SAPI_API SAPI_TREAT_DATA_FUNC(mbstr_treat_data) { char *res = NULL, *separator=NULL; const char *c_var; @@ -1526,7 +1532,6 @@ efree(res); } } -#endif /* {{{ proto bool mb_parse_str(string encoded_string [, array result]) Parses GET/POST/COOKIE data and sets global variables */ @@ -3335,6 +3340,9 @@ } /* }}} */ +PHPAPI int mbstr_encoding_translation(TSRMLS_DC) { + return MBSTRG(encoding_translation); +} #ifdef ZEND_MULTIBYTE PHPAPI int php_mbstring_set_zend_encoding(TSRMLS_D) @@ -3380,13 +3388,13 @@ encoding_converter = NULL; multibyte_oddlen = php_mbstring_oddlen; -#if defined(MBSTR_ENC_TRANS) - /* notify internal encoding to Zend Engine */ - name = (char*)mbfl_no_encoding2name(MBSTRG(current_internal_encoding)); - zend_multibyte_set_internal_encoding(name, strlen(name) TSRMLS_CC); + if(MBSTRG(encoding_translation)) { + /* notify internal encoding to Zend Engine */ + name = (char*)mbfl_no_encoding2name(MBSTRG(current_internal_encoding)); + zend_multibyte_set_internal_encoding(name, strlen(name) TSRMLS_CC); - encoding_converter = php_mbstring_encoding_converter; -#endif /* defined(MBSTR_ENC_TRANS) */ + encoding_converter = php_mbstring_encoding_converter; + } zend_multibyte_set_functions(encoding_detector, encoding_converter, multibyte_oddlen TSRMLS_CC); Index: php4/ext/mbstring/mbstring.h diff -u php4/ext/mbstring/mbstring.h:1.24 php4/ext/mbstring/mbstring.h:1.25 --- php4/ext/mbstring/mbstring.h:1.24 Fri Jul 5 11:06:39 2002 +++ php4/ext/mbstring/mbstring.h Fri Aug 2 02:53:47 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.h,v 1.24 2002/07/05 15:06:39 hirokawa Exp $ */ +/* $Id: mbstring.h,v 1.25 2002/08/02 06:53:47 hirokawa Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -56,6 +56,7 @@ #if HAVE_MBSTRING #include "mbfilter.h" +#include "SAPI.h" #define PHP_MBSTRING_API 20020405 @@ -126,6 +127,7 @@ char *mbstr_strrchr(const char *s, char c TSRMLS_DC); int mbstr_is_mb_leadbyte(const char *s TSRMLS_DC); +int mbstr_encoding_translation(TSRMLS_DC) ; ZEND_BEGIN_MODULE_GLOBALS(mbstring) int language; @@ -154,6 +156,7 @@ int current_filter_illegal_mode; int current_filter_illegal_substchar; long func_overload; + int encoding_translation; mbfl_buffer_converter *outconv; #if HAVE_MBREGEX int default_mbctype; @@ -193,6 +196,9 @@ TSRMLS_DC); int php_mbstring_oddlen(char *string, int length, const char *encoding TSRMLS_DC); #endif /* ZEND_MULTIBYTE */ + +SAPI_POST_HANDLER_FUNC(php_mbstr_post_handler); +SAPI_API SAPI_TREAT_DATA_FUNC(mbstr_treat_data); #else /* HAVE_MBSTRING */ Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.278 php4/ext/standard/string.c:1.279 --- php4/ext/standard/string.c:1.278 Tue Jul 30 06:51:33 2002 +++ php4/ext/standard/string.c Fri Aug 2 02:53:48 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.278 2002/07/30 10:51:33 rasmus Exp $ */ +/* $Id: string.c,v 1.279 2002/08/02 06:53:48 hirokawa Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -3223,14 +3223,14 @@ old_rg = PG(register_globals); if(argCount == 1) { PG(register_globals) = 1; - php_treat_data(PARSE_STRING, res, NULL TSRMLS_CC); + sapi_module.treat_data(PARSE_STRING, res, NULL TSRMLS_CC); } else { PG(register_globals) = 0; /* Clear out the array that was passed in. */ zval_dtor(*arrayArg); array_init(*arrayArg); - php_treat_data(PARSE_STRING, res, *arrayArg TSRMLS_CC); + sapi_module.treat_data(PARSE_STRING, res, *arrayArg TSRMLS_CC); } PG(register_globals) = old_rg; } Index: php4/main/SAPI.c diff -u php4/main/SAPI.c:1.142 php4/main/SAPI.c:1.143 --- php4/main/SAPI.c:1.142 Thu Aug 1 17:12:09 2002 +++ php4/main/SAPI.c Fri Aug 2 02:53:48 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: SAPI.c,v 1.142 2002/08/01 21:12:09 sr Exp $ */ +/* $Id: SAPI.c,v 1.143 2002/08/02 06:53:48 hirokawa Exp $ */ #include <ctype.h> #include <sys/stat.h> @@ -759,6 +759,13 @@ SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D)) { sapi_module.default_post_reader = default_post_reader; + return SUCCESS; +} + + +SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC)) +{ + sapi_module.treat_data = treat_data; return SUCCESS; } Index: php4/main/SAPI.h diff -u php4/main/SAPI.h:1.84 php4/main/SAPI.h:1.85 --- php4/main/SAPI.h:1.84 Sat Jul 27 09:58:16 2002 +++ php4/main/SAPI.h Fri Aug 2 02:53:48 2002 @@ -173,6 +173,7 @@ SAPI_API int sapi_register_post_entry(sapi_post_entry *post_entry); SAPI_API void sapi_unregister_post_entry(sapi_post_entry *post_entry); SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(TSRMLS_D)); +SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC)); SAPI_API int sapi_flush(TSRMLS_D); SAPI_API struct stat *sapi_get_stat(TSRMLS_D); @@ -215,6 +216,7 @@ void (*unblock_interruptions)(void); void (*default_post_reader)(TSRMLS_D); + void (*treat_data)(int arg, char *str, zval *destArray TSRMLS_DC); char *executable_location; }; @@ -243,8 +245,11 @@ #define SAPI_POST_READER_FUNC(post_reader) void post_reader(TSRMLS_D) #define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg TSRMLS_DC) +#define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray TSRMLS_DC) + SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data); SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader); +SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data); #define STANDARD_SAPI_MODULE_PROPERTIES NULL, NULL Index: php4/main/main.c diff -u php4/main/main.c:1.469 php4/main/main.c:1.470 --- php4/main/main.c:1.469 Thu Jul 25 13:31:34 2002 +++ php4/main/main.c Fri Aug 2 02:53:48 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.469 2002/07/25 17:31:34 sniper Exp $ */ +/* $Id: main.c,v 1.470 2002/08/02 06:53:48 hirokawa Exp $ */ /* {{{ includes */ @@ -1152,21 +1152,21 @@ case 'p': case 'P': if (!_gpc_flags[0] && !SG(headers_sent) && SG(request_info).request_method && !strcasecmp(SG(request_info).request_method, "POST")) { - php_treat_data(PARSE_POST, NULL, NULL TSRMLS_CC); /* POST Data */ + sapi_module.treat_data(PARSE_POST, NULL, NULL TSRMLS_CC); /* POST Data */ _gpc_flags[0]=1; } break; case 'c': case 'C': if (!_gpc_flags[1]) { - php_treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC); /* Cookie Data */ + sapi_module.treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC); /* Cookie Data */ _gpc_flags[1]=1; } break; case 'g': case 'G': if (!_gpc_flags[2]) { - php_treat_data(PARSE_GET, NULL, NULL TSRMLS_CC); /* GET Data */ + sapi_module.treat_data(PARSE_GET, NULL, NULL TSRMLS_CC); /* GET Data */ _gpc_flags[2]=1; } break; Index: php4/main/php_content_types.c diff -u php4/main/php_content_types.c:1.20 php4/main/php_content_types.c:1.21 --- php4/main/php_content_types.c:1.20 Thu Feb 28 03:27:03 2002 +++ php4/main/php_content_types.c Fri Aug 2 02:53:48 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_content_types.c,v 1.20 2002/02/28 08:27:03 sebastian Exp $ */ +/* $Id: php_content_types.c,v 1.21 2002/08/02 06:53:48 hirokawa Exp $ */ #include "php.h" #include "SAPI.h" @@ -51,6 +51,7 @@ { sapi_register_post_entries(php_post_entries); sapi_register_default_post_reader(php_default_post_reader); + sapi_register_treat_data(php_default_treat_data); return SUCCESS; } /* }}} */ Index: php4/main/php_main.h diff -u php4/main/php_main.h:1.21 php4/main/php_main.h:1.22 --- php4/main/php_main.h:1.21 Sun May 12 10:48:20 2002 +++ php4/main/php_main.h Fri Aug 2 02:53:48 2002 @@ -18,7 +18,7 @@ */ -/* $Id: php_main.h,v 1.21 2002/05/12 14:48:20 sas Exp $ */ +/* $Id: php_main.h,v 1.22 2002/08/02 06:53:48 hirokawa Exp $ */ #ifndef PHP_MAIN_H @@ -52,9 +52,5 @@ /* environment module */ extern int php_init_environ(void); extern int php_shutdown_environ(void); - -#if defined(MBSTR_ENC_TRANS) -#define php_treat_data mbstr_treat_data -#endif #endif Index: php4/main/php_variables.c diff -u php4/main/php_variables.c:1.39 php4/main/php_variables.c:1.40 --- php4/main/php_variables.c:1.39 Wed Jul 31 12:25:12 2002 +++ php4/main/php_variables.c Fri Aug 2 02:53:48 2002 @@ -16,7 +16,7 @@ | Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: php_variables.c,v 1.39 2002/07/31 16:25:12 zeev Exp $ */ +/* $Id: php_variables.c,v 1.40 2002/08/02 06:53:48 hirokawa Exp $ */ #include <stdio.h> #include "php.h" @@ -216,8 +216,7 @@ } } - -void php_treat_data(int arg, char *str, zval* destArray TSRMLS_DC) +SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data) { char *res = NULL, *var, *val, *separator=NULL; const char *c_var; Index: php4/main/rfc1867.c diff -u php4/main/rfc1867.c:1.110 php4/main/rfc1867.c:1.111 --- php4/main/rfc1867.c:1.110 Mon Jul 15 12:37:15 2002 +++ php4/main/rfc1867.c Fri Aug 2 02:53:48 2002 @@ -16,7 +16,7 @@ | Jani Taskinen <sniper@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: rfc1867.c,v 1.110 2002/07/15 16:37:15 sesser Exp $ */ +/* $Id: rfc1867.c,v 1.111 2002/08/02 06:53:48 hirokawa Exp $ */ /* * This product includes software developed by the Apache Group @@ -32,7 +32,7 @@ #include "php_variables.h" #include "rfc1867.h" -#if HAVE_MBSTRING && MBSTR_ENC_TRANS && !defined(COMPILE_DL_MBSTRING) +#if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING) #include "ext/mbstring/mbstring.h" #endif @@ -459,8 +459,9 @@ *resp++ = start[++i]; } else { *resp++ = start[i]; -#if HAVE_MBSTRING && MBSTR_ENC_TRANS && !defined(COMPILE_DL_MBSTRING) - if (mbstr_is_mb_leadbyte(start+i TSRMLS_CC)) { +#if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING) + if (mbstr_encoding_translation(TSRMLS_CC) && + mbstr_is_mb_leadbyte(start+i TSRMLS_CC)) { *resp++ = start[++i]; } #endif @@ -840,8 +841,12 @@ sprintf(lbuf, "%s_name", param); } -#if HAVE_MBSTRING && MBSTR_ENC_TRANS && !defined(COMPILE_DL_MBSTRING) - s = mbstr_strrchr(filename, '\\' TSRMLS_CC); +#if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING) + if (mbstr_encoding_translation(TSRMLS_CC)) { + s = mbstr_strrchr(filename, '\\' TSRMLS_CC); + } else { + s = strrchr(filename, '\\'); + } #else s = strrchr(filename, '\\'); #endif
« previous php.cvs (#13088) next »