]> granicus.if.org Git - php/commitdiff
reverted patch to support iso2022kr.
authorRui Hirokawa <hirokawa@php.net>
Fri, 24 May 2002 22:28:42 +0000 (22:28 +0000)
committerRui Hirokawa <hirokawa@php.net>
Fri, 24 May 2002 22:28:42 +0000 (22:28 +0000)
ext/mbstring/config.m4
ext/mbstring/mbfilter.c
ext/mbstring/mbfilter_ru.c
ext/mbstring/mbfilter_ru.h
ext/mbstring/mbstring.c

index 4ffc3c6505d721578e8d95c6c95408ec6e30da09..d1db98678c77989c094e390734d6920d2a4e1411 100644 (file)
@@ -8,7 +8,7 @@ PHP_ARG_ENABLE(mbstr_enc_trans, whether to enable encoding translation,
 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 9204f1e838b19d17f7f96b19056e6254654d658d..f179531c81cacad21b7a0455b28fcf5c0ffe488a 100644 (file)
@@ -802,6 +802,15 @@ static mbfl_encoding mbfl_encoding_uhc = {
        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 @@ static mbfl_encoding *mbfl_encoding_ptr_list[] = {
 #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 @@ static int mbfl_filt_ident_big5(int c, mbfl_identify_filter *filter TSRMLS_DC);
 #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 @@ static struct mbfl_convert_vtbl vtbl_wchar_uhc = {
        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 @@ static struct mbfl_convert_vtbl *mbfl_convert_filter_list[] = {
        &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 @@ static struct mbfl_identify_vtbl vtbl_identify_uhc = {
        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 @@ static struct mbfl_identify_vtbl *mbfl_identify_filter_list[] = {
 #if defined(HAVE_MBSTR_KR)
        &vtbl_identify_euckr,
        &vtbl_identify_uhc,
+       &vtbl_identify_2022kr,
 #endif
 #if defined(HAVE_MBSTR_RU)
        &vtbl_identify_cp1251,
@@ -6155,6 +6193,77 @@ mbfl_filt_ident_uhc(int c, mbfl_identify_filter *filter TSRMLS_DC)
        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:
+               filter->status = 0;
+               break;
+       }
+
+       return c;
+}
+
 #endif /* HAVE_MBSTR_KR */
 
 
index 254f9fdc6b1955a09107f1d213c85f9481b6589a..82937da8c4ffdd7e73f06d982808422ec4947170 100644 (file)
@@ -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$ */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -211,3 +232,9 @@ mbfl_filt_conv_wchar_koi8r(int c, mbfl_convert_filter *filter TSRMLS_DC)
 
 #endif /* HAVE_MBSTR_TW */
 
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
index 9bbe31aab1af6c44a818e194a94933408273ef8a..fda4d076b97ad4ceefe052e9f5541bf46b2c6860 100644 (file)
@@ -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$ */
+
 #ifndef MBFL_MBFILTER_RU_H
 #define MBFL_MBFILTER_RU_H
 
@@ -9,3 +29,10 @@ int mbfl_filt_conv_koi8r_wchar(int c, mbfl_convert_filter *filter TSRMLS_DC);
 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 5d8941dca138cbafad9cdab5087894076e58f823..96ae308b6a90bb5e2bac63fc29ddb84ff4a5c577 100644 (file)
@@ -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 @@ PHP_FUNCTION(mb_parse_str)
        } 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 @@ PHPAPI char * php_mb_convert_encoding(char *input, size_t length, char *_to_enco
                        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 @@ PHP_FUNCTION(mb_detect_encoding)
        }
 
        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 @@ PHP_FUNCTION(mb_convert_variables)
                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 @@ PHP_FUNCTION(mb_send_mail)
                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 @@ PHP_FUNCTION(mb_send_mail)
                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);
                }