Tsukada
ttsuk****@users*****
2002年 8月 10日 (土) 12:36:47 JST
ttsukada 02/08/10 12:36:47 Modified: ext/mbstring mbstring.c mbstring.h php_mb.h Log: improved convert table structure Revision Changes Path 1.16 +73 -184 php4/ext/mbstring/mbstring.c Index: mbstring.c =================================================================== RCS file: /cvsroot/php-i18n/php4/ext/mbstring/mbstring.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- mbstring.c 10 Jun 2002 11:39:38 -0000 1.15 +++ mbstring.c 10 Aug 2002 03:36:47 -0000 1.16 @@ -119,8 +119,7 @@ PHP_FE(mb_get_language, NULL) PHP_FE(mb_get_encoding, NULL) PHP_FE(mb_get_codeset, NULL) - PHP_FE(mb_get_pair_table, NULL) - PHP_FE(mb_get_lookup_table, NULL) + PHP_FE(mb_get_convert_table, NULL) PHP_FE(mb_get_convert_cllection, NULL) PHP_FE(mb_parse_str, second_args_force_ref) PHP_FE(mb_output_handler, NULL) @@ -470,45 +469,37 @@ /* php.ini directive registration */ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("mbstring.detect_order", NULL, PHP_INI_ALL, OnUpdateString, detect_order, zend_mbstring_globals, mbstring_globals) + STD_PHP_INI_ENTRY("mbstring.func_overload", "0", PHP_INI_SYSTEM, OnUpdateInt, func_overload, zend_mbstring_globals, mbstring_globals) STD_PHP_INI_ENTRY("mbstring.http_input", NULL, PHP_INI_ALL, OnUpdateString, http_input, zend_mbstring_globals, mbstring_globals) STD_PHP_INI_ENTRY("mbstring.http_output", NULL, PHP_INI_ALL, OnUpdateString, http_output, zend_mbstring_globals, mbstring_globals) PHP_INI_ENTRY("mbstring.internal_encoding", NULL, PHP_INI_ALL, OnUpdate_mbstring_internal_encoding) PHP_INI_ENTRY("mbstring.language", NULL, PHP_INI_ALL, OnUpdate_mbstring_language) -#ifdef ZEND_MULTIBYTE STD_PHP_INI_ENTRY("mbstring.script_encoding", NULL, PHP_INI_ALL, OnUpdateString, script_encoding, zend_mbstring_globals, mbstring_globals) -#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) PHP_INI_END() -/* pair table list */ -extern const mbfl_pair_table *mbfl_pair_table_list_8859[]; - -static const mbfl_pair_table **pair_table_builtin[] ={ - mbfl_pair_table_list_8859, - NULL -}; - -/* lookup table list */ -extern const mbfl_lookup_table * mbfl_lookup_table_list_ja[]; - -static const mbfl_lookup_table **lookup_table_builtin[] ={ - mbfl_lookup_table_list_ja, +/* convert table list */ +extern mbfl_convert_table *mbfl_convert_table_list_8859[]; +extern mbfl_convert_table * mbfl_convert_table_list_ja[]; + +static mbfl_convert_table **convert_table_builtin[] ={ + mbfl_convert_table_list_8859, + mbfl_convert_table_list_ja, NULL }; /* convert collection list */ -extern const mbfl_convert_collection * mbfl_convert_collection_list_standard[]; -extern const mbfl_convert_collection * mbfl_convert_collection_list_mime[]; -extern const mbfl_convert_collection * mbfl_convert_collection_list_ucs[]; -extern const mbfl_convert_collection * mbfl_convert_collection_list_ja[]; -extern const mbfl_convert_collection * mbfl_convert_collection_list_8859[]; -extern const mbfl_convert_collection * mbfl_convert_collection_list_cn[]; -extern const mbfl_convert_collection * mbfl_convert_collection_list_kr[]; -extern const mbfl_convert_collection * mbfl_convert_collection_list_tw[]; +extern mbfl_convert_collection * mbfl_convert_collection_list_standard[]; +extern mbfl_convert_collection * mbfl_convert_collection_list_mime[]; +extern mbfl_convert_collection * mbfl_convert_collection_list_ucs[]; +extern mbfl_convert_collection * mbfl_convert_collection_list_ja[]; +extern mbfl_convert_collection * mbfl_convert_collection_list_8859[]; +extern mbfl_convert_collection * mbfl_convert_collection_list_cn[]; +extern mbfl_convert_collection * mbfl_convert_collection_list_kr[]; +extern mbfl_convert_collection * mbfl_convert_collection_list_tw[]; -static const mbfl_convert_collection **convert_collection_builtin[] ={ +static mbfl_convert_collection **convert_collection_builtin[] ={ mbfl_convert_collection_list_standard, mbfl_convert_collection_list_mime, mbfl_convert_collection_list_ucs, @@ -521,16 +512,16 @@ }; /* identify function list */ -extern const mbfl_identify_function *mbfl_identify_function_list_standard[]; -extern const mbfl_identify_function *mbfl_identify_function_list_mime[]; -extern const mbfl_identify_function *mbfl_identify_function_list_ucs[]; -extern const mbfl_identify_function *mbfl_identify_function_list_ja[]; -extern const mbfl_identify_function *mbfl_identify_function_list_8859[]; -extern const mbfl_identify_function *mbfl_identify_function_list_cn[]; -extern const mbfl_identify_function *mbfl_identify_function_list_kr[]; -extern const mbfl_identify_function *mbfl_identify_function_list_tw[]; +extern mbfl_identify_function *mbfl_identify_function_list_standard[]; +extern mbfl_identify_function *mbfl_identify_function_list_mime[]; +extern mbfl_identify_function *mbfl_identify_function_list_ucs[]; +extern mbfl_identify_function *mbfl_identify_function_list_ja[]; +extern mbfl_identify_function *mbfl_identify_function_list_8859[]; +extern mbfl_identify_function *mbfl_identify_function_list_cn[]; +extern mbfl_identify_function *mbfl_identify_function_list_kr[]; +extern mbfl_identify_function *mbfl_identify_function_list_tw[]; -static const mbfl_identify_function **identify_function_builtin[] ={ +static mbfl_identify_function **identify_function_builtin[] ={ mbfl_identify_function_list_standard, mbfl_identify_function_list_mime, mbfl_identify_function_list_ucs, @@ -547,57 +538,33 @@ php_mbstring_globals_ctor(zend_mbstring_globals *pglobals TSRMLS_DC) { int i, j, n; - const mbfl_pair_table **pair_list; - const mbfl_pair_table *pair; - const mbfl_lookup_table **lookup_list; - const mbfl_lookup_table *lookup; - const mbfl_convert_collection **convert_list; - const mbfl_convert_collection *convert_collection; - const mbfl_identify_function **identify_list; - const mbfl_identify_function *identify_function; - - /* pair table list */ - n = 1; - i = 0; - while ((pair_list = pair_table_builtin[i++]) != NULL) { - j = 0; - while (pair_list[j++] != NULL) { - n++; - } - } - MBSTRG(pair_table_list_m) = malloc(n*sizeof(mbfl_pair_table *)); - if (MBSTRG(pair_table_list_m) != NULL) { - n = 0; - i = 0; - while ((pair_list = pair_table_builtin[i++]) != NULL) { - j = 0; - while ((pair = pair_list[j++]) != NULL) { - MBSTRG(pair_table_list_m)[n++] = (mbfl_pair_table *)pair; - } - } - MBSTRG(pair_table_list_m)[n] = NULL; - } + mbfl_convert_table **table_list; + mbfl_convert_table *table; + mbfl_convert_collection **convert_list; + mbfl_convert_collection *convert_collection; + mbfl_identify_function **identify_list; + mbfl_identify_function *identify_function; - /* lookup table list */ + /* convert table list */ n = 1; i = 0; - while ((lookup_list = lookup_table_builtin[i++]) != NULL) { + while ((table_list = convert_table_builtin[i++]) != NULL) { j = 0; - while (lookup_list[j++] != NULL) { + while (table_list[j++] != NULL) { n++; } } - MBSTRG(lookup_table_list_m) = malloc(n*sizeof(mbfl_lookup_table *)); - if (MBSTRG(lookup_table_list_m) != NULL) { + MBSTRG(convert_table_list_m) = malloc(n*sizeof(mbfl_convert_table *)); + if (MBSTRG(convert_table_list_m) != NULL) { n = 0; i = 0; - while ((lookup_list = lookup_table_builtin[i++]) != NULL) { + while ((table_list = convert_table_builtin[i++]) != NULL) { j = 0; - while ((lookup = lookup_list[j++]) != NULL) { - MBSTRG(lookup_table_list_m)[n++] = (mbfl_lookup_table *)lookup; + while ((table = table_list[j++]) != NULL) { + MBSTRG(convert_table_list_m)[n++] = (mbfl_convert_table *)table; } } - MBSTRG(lookup_table_list_m)[n] = NULL; + MBSTRG(convert_table_list_m)[n] = NULL; } /* convert collection list */ @@ -678,8 +645,7 @@ MBSTRG(filter_substchar_r) = MBSTRG(filter_substchar_m); MBSTRG(func_overload) = 0; MBSTRG(outconv) = NULL; - MBSTRG(pair_table_list_r) = NULL; - MBSTRG(lookup_table_list_r) = NULL; + MBSTRG(convert_table_list_r) = NULL; MBSTRG(convert_collection_list_r) = NULL; MBSTRG(encoding_cache_pos) = 0; MBSTRG(convert_cache_pos) = 0; @@ -700,17 +666,11 @@ static void php_mbstring_globals_dtor(zend_mbstring_globals *pglobals TSRMLS_DC) { - if (pglobals->pair_table_list_m != NULL) { - free(pglobals->pair_table_list_m); - } - if (pglobals->pair_table_list_r != NULL) { - efree(pglobals->pair_table_list_r); + if (pglobals->convert_table_list_m != NULL) { + free(pglobals->convert_table_list_m); } - if (pglobals->lookup_table_list_m != NULL) { - free(pglobals->lookup_table_list_m); - } - if (pglobals->lookup_table_list_r != NULL) { - efree(pglobals->lookup_table_list_r); + if (pglobals->convert_table_list_r != NULL) { + efree(pglobals->convert_table_list_r); } if (pglobals->convert_collection_list_m != NULL) { free(pglobals->convert_collection_list_m); @@ -846,11 +806,8 @@ } /* free temporary objects. */ - if (MBSTRG(pair_table_list_r) != NULL) { - efree(MBSTRG(pair_table_list_r)); - } - if (MBSTRG(lookup_table_list_r) != NULL) { - efree(MBSTRG(lookup_table_list_r)); + if (MBSTRG(convert_table_list_r) != NULL) { + efree(MBSTRG(convert_table_list_r)); } if (MBSTRG(convert_collection_list_r) != NULL) { efree(MBSTRG(convert_collection_list_r)); @@ -1408,14 +1365,14 @@ /* }}} */ -/* {{{ proto object mb_get_lookup_table([string name]) - Retrieves the LookupTable object */ -PHP_FUNCTION(mb_get_lookup_table) +/* {{{ proto object mb_get_convert_table([string name]) + Retrieves the ConvertTable object */ +PHP_FUNCTION(mb_get_convert_table) { zval **arg1, *element; int i; const char *name; - mbfl_lookup_table *lookup_table; + mbfl_convert_table *convert_table; PHP_MB_ERRRST(); if ( ZEND_NUM_ARGS() != 0 && @@ -1426,36 +1383,37 @@ if (ZEND_NUM_ARGS() == 0) { array_init(return_value); i = 0; - while ((lookup_table = MBSTRG(lookup_table_list_m)[i]) != NULL) { - add_index_string(return_value, i, (char *)lookup_table->name, 1); + while ((convert_table = MBSTRG(convert_table_list_m)[i]) != NULL) { + add_index_string(return_value, i, (char *)convert_table->name, 1); i++; } } else { convert_to_string_ex(arg1); name = Z_STRVAL_PP(arg1); - lookup_table = NULL; + convert_table = NULL; i = 0; - while ((lookup_table = MBSTRG(lookup_table_list_m)[i++]) != NULL) { - if (strcasecmp(name, lookup_table->name) == 0) { + while ((convert_table = MBSTRG(convert_table_list_m)[i++]) != NULL) { + if (strcasecmp(name, convert_table->name) == 0) { break; } } - if (lookup_table == NULL) { + if (convert_table == NULL) { php_error(E_WARNING, "unable to find LookupTable"); RETURN_FALSE; } object_init_ex(return_value, mbstdresource_class_entry); - add_property_string(return_value, "name", (char *)lookup_table->name, 1); - add_property_long(return_value, "size", lookup_table->size); - add_property_long(return_value, "min", lookup_table->min); - add_property_long(return_value, "max", lookup_table->max); - if (lookup_table->table != NULL) { + add_property_long(return_value, "type", convert_table->type); + add_property_string(return_value, "name", (char *)convert_table->name, 1); + add_property_long(return_value, "size", convert_table->size); + add_property_long(return_value, "min", convert_table->min); + add_property_long(return_value, "max", convert_table->max); + if (convert_table->table != NULL) { MAKE_STD_ZVAL(element); array_init(element); i = 0; - while (i < lookup_table->size) { - add_index_long(element, i, lookup_table->table[i]); + while (i < convert_table->size) { + add_index_long(element, i, convert_table->table[i]); i++; } add_property_zval(return_value, "table", element); @@ -1475,8 +1433,7 @@ int i; const char *name; mbfl_convert_collection *convert_collection; - const mbfl_pair_table *pair_table; - const mbfl_lookup_table *lookup_table; + const mbfl_convert_table *convert_table; php_mb_enc *encoding; PHP_MB_ERRRST(); @@ -1514,84 +1471,16 @@ encoding = php_mb_enc_get(convert_collection->to); add_property_string(return_value, "to", (char *)encoding->name, 1); add_property_string(return_value, "function", (char *)convert_collection->function->name, 1); - if (convert_collection->pair_table_list != NULL) { - MAKE_STD_ZVAL(element); - array_init(element); - i = 0; - while ((pair_table = convert_collection->pair_table_list[i++]) != NULL) { - add_next_index_string(element, (char *)pair_table->name, 1); - } - add_property_zval(return_value, "pair_table_list", element); - } else { - add_property_null(return_value, "pair_table_list"); - } - if (convert_collection->lookup_table_list != NULL) { + if (convert_collection->table_list != NULL) { MAKE_STD_ZVAL(element); array_init(element); i = 0; - while ((lookup_table = convert_collection->lookup_table_list[i++]) != NULL) { - add_next_index_string(element, (char *)lookup_table->name, 1); + while ((convert_table = convert_collection->table_list[i++]) != NULL) { + add_next_index_string(element, (char *)convert_table->name, 1); } - add_property_zval(return_value, "lookup_table_list", element); + add_property_zval(return_value, "table_list", element); } else { - add_property_null(return_value, "lookup_table_list"); - } - } -} -/* }}} */ - - -/* {{{ proto object mb_get_pair_table([string name]) - Retrieves the PairTable object */ -PHP_FUNCTION(mb_get_pair_table) -{ - zval **arg1, *element; - int i; - const char *name; - mbfl_pair_table *pair_table; - - PHP_MB_ERRRST(); - if ( ZEND_NUM_ARGS() != 0 && - (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) ) { - WRONG_PARAM_COUNT; - } - - if (ZEND_NUM_ARGS() == 0) { - array_init(return_value); - i = 0; - while ((pair_table = MBSTRG(pair_table_list_m)[i]) != NULL) { - add_index_string(return_value, i, (char *)pair_table->name, 1); - i++; - } - } else { - convert_to_string_ex(arg1); - name = Z_STRVAL_PP(arg1); - pair_table = NULL; - i = 0; - while ((pair_table = MBSTRG(pair_table_list_m)[i++]) != NULL) { - if (strcasecmp(name, pair_table->name) == 0) { - break; - } - } - if (pair_table == NULL) { - php_error(E_WARNING, "unable to find PairTable"); - RETURN_FALSE; - } - - object_init_ex(return_value, mbstdresource_class_entry); - add_property_string(return_value, "name", (char *)pair_table->name, 1); - add_property_long(return_value, "size", pair_table->size); - if (pair_table->table != NULL) { - MAKE_STD_ZVAL(element); - array_init(element); - i = 0; - while (i < pair_table->size) { - add_index_long(element, pair_table->table[i].mb, pair_table->table[i].uc); - i++; - } - add_property_zval(return_value, "table", element); - } else { - add_property_null(return_value, "table"); + add_property_null(return_value, "table_list"); } } } 1.11 +4 -4 php4/ext/mbstring/mbstring.h Index: mbstring.h =================================================================== RCS file: /cvsroot/php-i18n/php4/ext/mbstring/mbstring.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- mbstring.h 10 Jun 2002 11:32:40 -0000 1.10 +++ mbstring.h 10 Aug 2002 03:36:47 -0000 1.11 @@ -74,10 +74,8 @@ PHP_FUNCTION(mb_get_language); PHP_FUNCTION(mb_get_encoding); PHP_FUNCTION(mb_get_codeset); -PHP_FUNCTION(mb_get_pair_table); -PHP_FUNCTION(mb_register_pair_table); -PHP_FUNCTION(mb_get_lookup_table); -PHP_FUNCTION(mb_register_lookup_table); +PHP_FUNCTION(mb_get_convert_table); +PHP_FUNCTION(mb_register_convert_table); PHP_FUNCTION(mb_get_convert_cllection); PHP_FUNCTION(mb_is_supported_convert); PHP_FUNCTION(mb_preferred_mime_name); @@ -136,6 +134,8 @@ PHP_FUNCTION(mb_buf_iterate); PHP_FUNCTION(mb_buf_check_include); PHP_FUNCTION(mb_buf_check_exclude); +PHP_FUNCTION(mb_buf_search_include); +PHP_FUNCTION(mb_buf_search_exclude); PHP_FUNCTION(mb_buf_length); PHP_FUNCTION(mb_buf_index_of); PHP_FUNCTION(mb_buf_last_index_of); 1.6 +2 -4 php4/ext/mbstring/php_mb.h Index: php_mb.h =================================================================== RCS file: /cvsroot/php-i18n/php4/ext/mbstring/php_mb.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- php_mb.h 9 Jun 2002 04:41:23 -0000 1.5 +++ php_mb.h 10 Aug 2002 03:36:47 -0000 1.6 @@ -99,10 +99,8 @@ long func_overload; php_mb_bufconv *outconv; - mbfl_pair_table **pair_table_list_m; - mbfl_pair_table **pair_table_list_r; - mbfl_lookup_table **lookup_table_list_m; - mbfl_lookup_table **lookup_table_list_r; + mbfl_convert_table **convert_table_list_m; + mbfl_convert_table **convert_table_list_r; mbfl_convert_collection **convert_collection_list_m; mbfl_convert_collection **convert_collection_list_r; mbfl_identify_function **identify_function_list;