cvs: php4 /ext/mbstring config.m4 mbfilter.c mbfilter_ru.c mbfilter_ru.h mbstring.c

From: Date: Fri, 24 May 2002 22:28:43 +0000
Subject: cvs: php4 /ext/mbstring config.m4 mbfilter.c mbfilter_ru.c mbfilter_ru.h mbstring.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12094@lists.php.net to get a copy of this message
hirokawa Fri May 24 18:28:43 2002 EDT Modified files: /php4/ext/mbstring config.m4 mbfilter.c mbfilter_ru.c mbfilter_ru.h mbstring.c Log: reverted patch to support iso2022kr.

Index: php4/ext/mbstring/config.m4 diff -u php4/ext/mbstring/config.m4:1.13 php4/ext/mbstring/config.m4:1.14 --- php4/ext/mbstring/config.m4:1.13 Tue May 21 03:00:30 2002 +++ php4/ext/mbstring/config.m4 Fri May 24 18:28:42 2002 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4,v 1.13 2002/05/21 07:00:30 dets Exp $ +dnl $Id: config.m4,v 1.14 2002/05/24 22:28:42 hirokawa Exp $ dnl PHP_ARG_ENABLE(mbstr_enc_trans, whether to enable encoding translation, @@ -8,7 +8,7 @@ PHP_ARG_ENABLE(mbregex, whether to enable multibyte regex support, [ --enable-mbregex Enable multibyte regex support], yes) -PHP_ARG_ENABLE(mbstring, whether to enable multibyte string support, +PHP_ARG_WITH(mbstring, whether to enable multibyte string support, [ --disable-mbstring Disable multibyte string support], yes) if test "$PHP_MBSTRING" != "no"; then Index: php4/ext/mbstring/mbfilter.c diff -u php4/ext/mbstring/mbfilter.c:1.30 php4/ext/mbstring/mbfilter.c:1.31 --- php4/ext/mbstring/mbfilter.c:1.30 Tue May 21 03:00:31 2002 +++ php4/ext/mbstring/mbfilter.c Fri May 24 18:28:42 2002 @@ -79,7 +79,7 @@ * */ -/* $Id: mbfilter.c,v 1.30 2002/05/21 07:00:31 dets Exp $ */ +/* $Id: mbfilter.c,v 1.31 2002/05/24 22:28:42 hirokawa Exp $ */ #ifdef HAVE_CONFIG_H @@ -802,6 +802,15 @@ MBFL_ENCTYPE_MBCS }; +static mbfl_encoding mbfl_encoding_2022kr = { + mbfl_no_encoding_2022kr, + "ISO-2022-KR", + "ISO-2022-KR", + NULL, + NULL, + MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE +}; + #endif /* HAVE_MBSTR_KR */ static const char *mbfl_encoding_cp1252_aliases[] = {"cp1252", NULL}; @@ -1056,6 +1065,7 @@ #if defined(HAVE_MBSTR_KR) &mbfl_encoding_euc_kr, &mbfl_encoding_uhc, + &mbfl_encoding_2022kr, #endif #if defined(HAVE_MBSTR_RU) &mbfl_encoding_cp1251, @@ -1169,6 +1179,7 @@ #if defined(HAVE_MBSTR_KR) static int mbfl_filt_ident_euckr(int c, mbfl_identify_filter *filter TSRMLS_DC); static int mbfl_filt_ident_uhc(int c, mbfl_identify_filter *filter TSRMLS_DC); +static int mbfl_filt_ident_2022kr(int c, mbfl_identify_filter *filter TSRMLS_DC); #endif /* HAVE_MBSTR_KR */ #if defined(HAVE_MBSTR_RU) @@ -1783,6 +1794,23 @@ mbfl_filt_conv_common_dtor, mbfl_filt_conv_wchar_uhc, mbfl_filt_conv_common_flush }; + +static struct mbfl_convert_vtbl vtbl_wchar_2022kr = { + mbfl_no_encoding_wchar, + mbfl_no_encoding_2022kr, + mbfl_filt_conv_common_ctor, + mbfl_filt_conv_common_dtor, + mbfl_filt_conv_wchar_2022kr, + mbfl_filt_conv_any_2022kr_flush }; + +static struct mbfl_convert_vtbl vtbl_2022kr_wchar = { + mbfl_no_encoding_2022kr, + mbfl_no_encoding_wchar, + mbfl_filt_conv_common_ctor, + mbfl_filt_conv_common_dtor, + mbfl_filt_conv_2022kr_wchar, + mbfl_filt_conv_common_flush }; + #endif /* HAVE_MBSTR_KR */ #if defined(HAVE_MBSTR_RU) @@ -2098,6 +2126,8 @@ &vtbl_wchar_euckr, &vtbl_uhc_wchar, &vtbl_wchar_uhc, + &vtbl_2022kr_wchar, + &vtbl_wchar_2022kr, #endif #if defined(HAVE_MBSTR_RU) &vtbl_cp1251_wchar, @@ -2289,6 +2319,13 @@ mbfl_filt_ident_common_ctor, mbfl_filt_ident_common_dtor, mbfl_filt_ident_uhc }; + +static struct mbfl_identify_vtbl vtbl_identify_2022kr = { + mbfl_no_encoding_2022kr, + mbfl_filt_ident_common_ctor, + mbfl_filt_ident_common_dtor, + mbfl_filt_ident_2022kr }; + #endif /* HAVE_MBSTR_KR */ #if defined(HAVE_MBSTR_RU) @@ -2425,6 +2462,7 @@ #if defined(HAVE_MBSTR_KR) &vtbl_identify_euckr, &vtbl_identify_uhc, + &vtbl_identify_2022kr, #endif #if defined(HAVE_MBSTR_RU) &vtbl_identify_cp1251, @@ -6145,6 +6183,77 @@ filter->flag = 1; } filter->status = 0; + break; + + default: + filter->status = 0; + break; + } + + return c; +} + +static int +mbfl_filt_ident_2022kr(int c, mbfl_identify_filter *filter TSRMLS_DC) +{ +retry: + switch (filter->status & 0xf) { +/* case 0x00: ASCII */ +/* case 0x10: KSC5601 mode */ +/* case 0x20: KSC5601 DBCS */ +/* case 0x40: KSC5601 SBCS */ + case 0: + if (!(filter->status & 0x10)) { + if (c == 0x1b) + filter->status += 2; + } else if (filter->status == 0x20 && c > 0x20 && c < 0x7f) { /* kanji first char */ + filter->status += 1; + } else if (c >= 0 && c < 0x80) { /* latin, CTLs */ + ; + } else { + filter->flag = 1; /* bad */ + } + break; + +/* case 0x21: KSC5601 second char */ + case 1: + filter->status &= ~0xf; + if (c < 0x21 || c > 0x7e) { /* bad */ + filter->flag = 1; + } + break; + + /* ESC */ + case 2: + if (c == 0x24) { /* '$' */ + filter->status++; + } else { + filter->flag = 1; /* bad */ + filter->status &= ~0xf; + goto retry; + } + break; + + /* ESC $ */ + case 3: + if (c == 0x29) { /* ')' */ + filter->status++; + } else { + filter->flag = 1; /* bad */ + filter->status &= ~0xf; + goto retry; + } + break; + + /* ESC $) */ + case 5: + if (c == 0x43) { /* 'C' */ + filter->status = 0x10; + } else { + filter->flag = 1; /* bad */ + filter->status &= ~0xf; + goto retry; + } break; default: Index: php4/ext/mbstring/mbfilter_ru.c diff -u php4/ext/mbstring/mbfilter_ru.c:1.2 php4/ext/mbstring/mbfilter_ru.c:1.3 --- php4/ext/mbstring/mbfilter_ru.c:1.2 Tue May 21 03:10:26 2002 +++ php4/ext/mbstring/mbfilter_ru.c Fri May 24 18:28:42 2002 @@ -1,6 +1,27 @@ /* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | Copyright (c) 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Den V. Tsopa <tdv@edisoft.ru> | + +----------------------------------------------------------------------+ + */ + +/* * "russian code filter and converter" */ + +/* $Id: mbfilter_ru.c,v 1.3 2002/05/24 22:28:42 hirokawa Exp $ */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -211,3 +232,9 @@ #endif /* HAVE_MBSTR_TW */ +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ Index: php4/ext/mbstring/mbfilter_ru.h diff -u php4/ext/mbstring/mbfilter_ru.h:1.1 php4/ext/mbstring/mbfilter_ru.h:1.2 --- php4/ext/mbstring/mbfilter_ru.h:1.1 Tue May 21 03:00:34 2002 +++ php4/ext/mbstring/mbfilter_ru.h Fri May 24 18:28:42 2002 @@ -1,3 +1,23 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | Copyright (c) 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Den V. Tsopa <tdv@edisoft.ru> | + +----------------------------------------------------------------------+ + */ + +/* $Id: mbfilter_ru.h,v 1.2 2002/05/24 22:28:42 hirokawa Exp $ */ + #ifndef MBFL_MBFILTER_RU_H #define MBFL_MBFILTER_RU_H @@ -9,3 +29,10 @@ int mbfl_filt_conv_wchar_koi8r(int c, mbfl_convert_filter *filter TSRMLS_DC); #endif /* MBFL_MBFILTER_RU_H */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ Index: php4/ext/mbstring/mbstring.c diff -u php4/ext/mbstring/mbstring.c:1.70 php4/ext/mbstring/mbstring.c:1.71 --- php4/ext/mbstring/mbstring.c:1.70 Tue May 21 03:00:34 2002 +++ php4/ext/mbstring/mbstring.c Fri May 24 18:28:42 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.70 2002/05/21 07:00:34 dets Exp $ */ +/* $Id: mbstring.c,v 1.71 2002/05/24 22:28:42 hirokawa Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -75,6 +75,8 @@ #include "mbregex.h" #endif +#include "mbfilter.h" + #if defined(HAVE_MBSTR_JA) static const enum mbfl_no_encoding php_mbstr_default_identify_list[] = { mbfl_no_encoding_ascii, @@ -1538,7 +1540,7 @@ } else { /* auto detect */ from_encoding = mbfl_no_encoding_invalid; - identd = mbfl_encoding_detector_new(elist, elistsz TSRMLS_CC); + identd = mbfl_encoding_detector_new((mbfl_no_encoding *)elist, elistsz TSRMLS_CC); if (identd != NULL) { n = 0; while (n < num) { @@ -2260,7 +2262,7 @@ string.no_encoding = from_encoding; } else if (size > 1) { /* auto detect */ - from_encoding = mbfl_identify_encoding_no(&string, list, size TSRMLS_CC); + from_encoding = mbfl_identify_encoding_no(&string, (mbfl_no_encoding *)list, size TSRMLS_CC); if (from_encoding != mbfl_no_encoding_invalid) { string.no_encoding = from_encoding; } else { @@ -2433,9 +2435,9 @@ } if (size > 0 && list != NULL) { - elist = list; + elist = (mbfl_no_encoding *)list; } else { - elist = MBSTRG(current_detect_order_list); + elist = (mbfl_no_encoding *)MBSTRG(current_detect_order_list); size = MBSTRG(current_detect_order_list_size); } @@ -2742,7 +2744,7 @@ stack = (pval ***)emalloc(stack_max*sizeof(pval **)); if (stack != NULL) { stack_level = 0; - identd = mbfl_encoding_detector_new(elist, elistsz TSRMLS_CC); + identd = mbfl_encoding_detector_new((mbfl_no_encoding *)elist, elistsz TSRMLS_CC); if (identd != NULL) { n = 2; while (n < argc || stack_level > 0) { @@ -3065,7 +3067,7 @@ orig_str.no_language = MBSTRG(current_language); orig_str.val = Z_STRVAL_PP(argv[1]); orig_str.len = Z_STRLEN_PP(argv[1]); - orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size) TSRMLS_CC); + orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, (mbfl_no_encoding *)MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size) TSRMLS_CC); if(orig_str.no_encoding == mbfl_no_encoding_invalid) { orig_str.no_encoding = MBSTRG(current_internal_encoding); } @@ -3087,7 +3089,7 @@ orig_str.no_language = MBSTRG(current_language); orig_str.val = Z_STRVAL_PP(argv[2]); orig_str.len = Z_STRLEN_PP(argv[2]); - orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size) TSRMLS_CC); + orig_str.no_encoding = mbfl_identify_encoding_no(&orig_str, (mbfl_no_encoding *)MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size) TSRMLS_CC); if(orig_str.no_encoding == mbfl_no_encoding_invalid) { orig_str.no_encoding = MBSTRG(current_internal_encoding); }
« previous php.cvs (#12094) next »