1
0
mirror of https://github.com/php/php-src.git synced 2026-04-05 07:02:33 +02:00

Remove some dead code from mbstring

mbstring has a great deal of dead code. Some common types are:

- Default switch clauses which will never be taken
- If clauses intended to convert codepoints which were not present in
  a conversion table... but the codepoint in question *is* in the table,
  so the if clause is not needed.
- Bounds checks in places where it is not possible for a value to ever
  be out of bounds.
- Checks to see if an unmatched Unicode codepoint is in CP932 extension
  range 3... but every codepoint in range 3 is also in range 2, so no
  codepoint will ever be matched and converted by that code.
This commit is contained in:
Alex Dowad
2021-07-30 11:44:18 +02:00
parent d824eaee33
commit 626f0fec54
26 changed files with 108 additions and 285 deletions

View File

@@ -239,9 +239,7 @@ int mbfl_filt_conv_big5_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -298,9 +298,7 @@ retry:
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
@@ -322,16 +320,13 @@ static int mbfl_filt_conv_cp5022x_wchar_flush(mbfl_convert_filter *filter)
static int mbfl_filt_conv_wchar_cp50220(int c, mbfl_convert_filter *filter)
{
int mode = MBFL_FILT_TL_HAN2ZEN_KATAKANA | MBFL_FILT_TL_HAN2ZEN_GLUE, second = 0;
int mode = MBFL_FILT_TL_HAN2ZEN_KATAKANA | MBFL_FILT_TL_HAN2ZEN_GLUE;
bool consumed = false;
if (filter->cache) {
int s = mbfl_convert_kana(filter->cache, c, &consumed, &second, mode);
int s = mbfl_convert_kana(filter->cache, c, &consumed, NULL, mode);
filter->cache = consumed ? 0 : c;
mbfl_filt_conv_wchar_cp50221(s, filter);
if (second) {
mbfl_filt_conv_wchar_cp50221(second, filter);
}
} else if (c == 0) {
/* This case has to be handled separately, since `filter->cache == 0` means
* no codepoint is cached */
@@ -345,14 +340,11 @@ static int mbfl_filt_conv_wchar_cp50220(int c, mbfl_convert_filter *filter)
static int mbfl_filt_conv_wchar_cp50220_flush(mbfl_convert_filter *filter)
{
int mode = MBFL_FILT_TL_HAN2ZEN_KATAKANA | MBFL_FILT_TL_HAN2ZEN_GLUE, second = 0;
int mode = MBFL_FILT_TL_HAN2ZEN_KATAKANA | MBFL_FILT_TL_HAN2ZEN_GLUE;
if (filter->cache) {
int s = mbfl_convert_kana(filter->cache, 0, NULL, &second, mode);
int s = mbfl_convert_kana(filter->cache, 0, NULL, NULL, mode);
mbfl_filt_conv_wchar_cp50221(s, filter);
if (second) {
mbfl_filt_conv_wchar_cp50221(s, filter);
}
filter->cache = 0;
}
@@ -432,21 +424,6 @@ int mbfl_filt_conv_wchar_cp50221(int c, mbfl_convert_filter *filter)
}
}
if (s < 0) {
const int cp932ext3_ucs_table_size =
cp932ext3_ucs_table_max - cp932ext3_ucs_table_min;
const int limit = cp932ext3_ucs_table_size >
cp932ext3_eucjp_table_size ?
cp932ext3_eucjp_table_size:
cp932ext3_ucs_table_size;
for (i = 0; i < limit; i++) {
if (c == cp932ext3_ucs_table[i]) {
s = cp932ext3_eucjp_table[i];
break;
}
}
}
if (c == 0) {
s = 0;
} else if (s <= 0) {
@@ -564,21 +541,6 @@ int mbfl_filt_conv_wchar_cp50222(int c, mbfl_convert_filter *filter)
}
}
if (s <= 0) {
const int cp932ext3_ucs_table_size =
cp932ext3_ucs_table_max - cp932ext3_ucs_table_min;
const int limit = cp932ext3_ucs_table_size >
cp932ext3_eucjp_table_size ?
cp932ext3_eucjp_table_size:
cp932ext3_ucs_table_size;
for (i = 0; i < limit; i++) {
if (c == cp932ext3_ucs_table[i]) {
s = cp932ext3_eucjp_table[i];
break;
}
}
}
if (c == 0) {
s = 0;
} else if (s <= 0) {

View File

@@ -163,9 +163,7 @@ mbfl_filt_conv_cp51932_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -203,9 +203,7 @@ mbfl_filt_conv_cp932_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -142,24 +142,16 @@ int mbfl_filt_conv_cp936_wchar(int c, mbfl_convert_filter *filter)
if (w <= 0) {
if (c1 < 0xff && c1 > 0x80 && c >= 0x40 && c < 0xff && c != 0x7f) {
w = (c1 - 0x81)*192 + (c - 0x40);
if (w >= 0 && w < cp936_ucs_table_size) {
w = cp936_ucs_table[w];
if (!w)
w = MBFL_BAD_INPUT;
} else {
w = MBFL_BAD_INPUT;
}
CK((*filter->output_function)(w, filter->data));
w = (c1 - 0x81)*192 + c - 0x40;
ZEND_ASSERT(w < cp936_ucs_table_size);
CK((*filter->output_function)(cp936_ucs_table[w], filter->data));
} else {
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
}
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -108,19 +108,16 @@ int mbfl_filt_conv_euccn_wchar(int c, mbfl_convert_filter *filter)
filter->status = 0;
c1 = filter->cache;
if (c > 0xA0 && c < 0xFF) {
w = (c1 - 0x81)*192 + (c - 0x40);
if (w >= 0 && w < cp936_ucs_table_size) {
if (w == 0x1864) {
w = 0x30FB;
} else if (w == 0x186A) {
w = 0x2015;
} else if ((w >= 0x1921 && w <= 0x192A) || w == 0x1963 || (w >= 0x1C59 && w <= 0x1C7E) || (w >= 0x1DBB && w <= 0x1DC4)) {
w = 0;
} else {
w = cp936_ucs_table[w];
}
} else {
w = (c1 - 0x81)*192 + c - 0x40;
ZEND_ASSERT(w < cp936_ucs_table_size);
if (w == 0x1864) {
w = 0x30FB;
} else if (w == 0x186A) {
w = 0x2015;
} else if ((w >= 0x1921 && w <= 0x192A) || w == 0x1963 || (w >= 0x1C59 && w <= 0x1C7E) || (w >= 0x1DBB && w <= 0x1DC4)) {
w = 0;
} else {
w = cp936_ucs_table[w];
}
if (w <= 0) {
@@ -133,9 +130,7 @@ int mbfl_filt_conv_euccn_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -166,9 +166,7 @@ mbfl_filt_conv_eucjp_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
@@ -209,8 +207,6 @@ mbfl_filt_conv_wchar_eucjp(int c, mbfl_convert_filter *filter)
if (s <= 0) {
if (c == 0xff3c) { /* FULLWIDTH REVERSE SOLIDUS */
s = 0x2140;
} else if (c == 0xff5e) { /* FULLWIDTH TILDE */
s = 0x2141;
} else if (c == 0x2225) { /* PARALLEL TO */
s = 0x2142;
} else if (c == 0xff0d) { /* FULLWIDTH HYPHEN-MINUS */

View File

@@ -167,6 +167,7 @@ int mbfl_filt_conv_eucjpwin_wchar(int c, mbfl_convert_filter *filter)
filter->status++;
filter->cache = c;
break;
case 4: /* got 0x8f, X 0212 second char */
filter->status = 0;
c1 = filter->cache;
@@ -211,9 +212,7 @@ int mbfl_filt_conv_eucjpwin_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
@@ -271,8 +270,6 @@ int mbfl_filt_conv_wchar_eucjpwin(int c, mbfl_convert_filter *filter)
s1 = 0x213D;
} else if (c == 0xff3c) { /* FULLWIDTH REVERSE SOLIDUS */
s1 = 0x2140;
} else if (c == 0xff5e) { /* FULLWIDTH TILDE */
s1 = 0x2141;
} else if (c == 0x2225) { /* PARALLEL TO */
s1 = 0x2142;
} else if (c == 0xff0d) { /* FULLWIDTH HYPHEN-MINUS */

View File

@@ -114,19 +114,13 @@ int mbfl_filt_conv_euckr_wchar(int c, mbfl_convert_filter *filter)
}
if (flag > 0 && c >= 0xa1 && c <= 0xfe) {
if (flag == 1) { /* 1st: 0xa1..0xc6, 2nd: 0x41..0x7a, 0x81..0xfe */
w = (c1 - 0xa1)*190 + (c - 0x41);
if (w >= 0 && w < uhc2_ucs_table_size) {
w = uhc2_ucs_table[w];
} else {
w = 0;
}
w = (c1 - 0xa1)*190 + c - 0x41;
ZEND_ASSERT(w < uhc2_ucs_table_size);
w = uhc2_ucs_table[w];
} else { /* 1st: 0xc7..0xc8,0xca..0xfe, 2nd: 0xa1..0xfe */
w = (c1 - 0xc7)*94 + (c - 0xa1);
if (w >= 0 && w < uhc3_ucs_table_size) {
w = uhc3_ucs_table[w];
} else {
w = 0;
}
w = (c1 - 0xc7)*94 + c - 0xa1;
ZEND_ASSERT(w < uhc3_ucs_table_size);
w = uhc3_ucs_table[w];
}
if (w <= 0) {
@@ -138,9 +132,7 @@ int mbfl_filt_conv_euckr_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -184,9 +184,7 @@ int mbfl_filt_conv_euctw_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -168,15 +168,9 @@ int mbfl_filt_conv_gb18030_wchar(int c, mbfl_convert_filter *filter)
(c1 >= 0x81 && c1 <= 0xa0 && c >= 0x40 && c <= 0xfe && c != 0x7f) ||
(c1 >= 0xaa && c1 <= 0xfe && c >= 0x40 && c <= 0xa0 && c != 0x7f) ||
(c1 >= 0xa8 && c1 <= 0xa9 && c >= 0x40 && c <= 0xa0 && c != 0x7f)) {
w = (c1 - 0x81)*192 + (c - 0x40);
if (w >= 0 && w < cp936_ucs_table_size) {
w = cp936_ucs_table[w];
if (!w)
w = MBFL_BAD_INPUT;
} else {
w = MBFL_BAD_INPUT;
}
CK((*filter->output_function)(w, filter->data));
w = (c1 - 0x81)*192 + c - 0x40;
ZEND_ASSERT(w < cp936_ucs_table_size);
CK((*filter->output_function)(cp936_ucs_table[w], filter->data));
} else {
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
}
@@ -211,10 +205,6 @@ int mbfl_filt_conv_gb18030_wchar(int c, mbfl_convert_filter *filter)
w = (((c1 - 0x81)*10 + (c2 - 0x30))*126 + (c3 - 0x81))*10 + (c - 0x30);
if (w >= 0 && w <= 39419) {
k = mbfl_bisec_srch(w, mbfl_gb2uni_tbl, mbfl_gb_uni_max);
if (k < 0) {
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
return 0;
}
w += mbfl_gb_uni_ofst[k];
} else {
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
@@ -227,9 +217,7 @@ int mbfl_filt_conv_gb18030_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
@@ -370,12 +358,8 @@ int mbfl_filt_conv_wchar_gb18030(int c, mbfl_convert_filter *filter)
s1 = c1 + 0x90;
}
if (s <= 0) {
if (c == 0) {
s = 0;
} else {
s = -1;
}
if (c == 0) {
s = 0;
}
if (s >= 0) {

View File

@@ -95,20 +95,17 @@ int mbfl_filt_conv_hz_wchar(int c, mbfl_convert_filter *filter)
c1 = filter->cache;
if (c1 > 0x20 && c1 < 0x7F && c > 0x20 && c < 0x7F) {
s = (c1 - 1)*192 + c + 0x40; /* GB2312 */
if (s >= 0 && s < cp936_ucs_table_size) {
if (s == 0x1864) {
w = 0x30FB;
} else if (s == 0x186A) {
w = 0x2015;
} else if (s == 0x186C) {
w = 0x2225;
} else if ((s >= 0x1920 && s <= 0x192A) || s == 0x1963 || (s >= 0x1C60 && s <= 0x1C7F) || (s >= 0x1DBB && s <= 0x1DC4)) {
w = 0;
} else {
w = cp936_ucs_table[s];
}
} else {
ZEND_ASSERT(s < cp936_ucs_table_size);
if (s == 0x1864) {
w = 0x30FB;
} else if (s == 0x186A) {
w = 0x2015;
} else if (s == 0x186C) {
w = 0x2225;
} else if ((s >= 0x1920 && s <= 0x192A) || s == 0x1963 || (s >= 0x1C60 && s <= 0x1C7F) || (s >= 0x1DBB && s <= 0x1DC4)) {
w = 0;
} else {
w = cp936_ucs_table[s];
}
if (w <= 0) {
@@ -139,9 +136,7 @@ int mbfl_filt_conv_hz_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -258,12 +258,8 @@ int mbfl_filt_conv_wchar_2022jpms(int c, mbfl_convert_filter *filter)
if (s1 <= 0) {
if (c == 0xA5) { /* YEN SIGN */
s1 = 0x216F; /* FULLWIDTH YEN SIGN */
} else if (c == 0x203E) { /* OVER LINE */
s1 = 0x2131; /* FULLWIDTH MACRON */
} else if (c == 0xFF3C) { /* FULLWIDTH REVERSE SOLIDUS */
s1 = 0x2140;
} else if (c == 0xFF5E) { /* FULLWIDTH TILDE */
s1 = 0x2141;
} else if (c == 0x2225) { /* PARALLEL TO */
s1 = 0x2142;
} else if (c == 0xFF0D) { /* FULLWIDTH HYPHEN-MINUS */

View File

@@ -113,19 +113,13 @@ int mbfl_filt_conv_2022kr_wchar(int c, mbfl_convert_filter *filter)
if (flag == 1) {
if (c1 != 0x22 || c <= 0x65) {
w = (c1 - 0x21)*190 + (c - 0x41) + 0x80;
if (w >= 0 && w < uhc2_ucs_table_size) {
w = uhc2_ucs_table[w];
} else {
w = 0;
}
ZEND_ASSERT(w < uhc2_ucs_table_size);
w = uhc2_ucs_table[w];
}
} else {
w = (c1 - 0x47)*94 + (c - 0x21);
if (w >= 0 && w < uhc3_ucs_table_size) {
w = uhc3_ucs_table[w];
} else {
w = 0;
}
w = (c1 - 0x47)*94 + c - 0x21;
ZEND_ASSERT(w < uhc3_ucs_table_size);
w = uhc3_ucs_table[w];
}
if (w <= 0) {
@@ -162,9 +156,7 @@ int mbfl_filt_conv_2022kr_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -268,12 +268,8 @@ int mbfl_filt_conv_wchar_2022jp_mobile(int c, mbfl_convert_filter *filter)
if (s1 <= 0) {
if (c == 0xA5) { /* YEN SIGN */
s1 = 0x216F; /* FULLWIDTH YEN SIGN */
} else if (c == 0x203E) { /* OVER LINE */
s1 = 0x2131; /* FULLWIDTH MACRON */
} else if (c == 0xFF3C) { /* FULLWIDTH REVERSE SOLIDUS */
s1 = 0x2140;
} else if (c == 0xFF5E) { /* FULLWIDTH TILDE */
s1 = 0x2141;
} else if (c == 0x2225) { /* PARALLEL TO */
s1 = 0x2142;
} else if (c == 0xFF0D) { /* FULLWIDTH HYPHEN-MINUS */

View File

@@ -251,9 +251,7 @@ retry:
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
@@ -318,14 +316,6 @@ mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter)
}
filter->status = 0;
CK((*filter->output_function)(s, filter->data));
} else if (s < 0x100) { /* kana */
if ((filter->status & 0xff00) != 0x100) {
CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
CK((*filter->output_function)(0x28, filter->data)); /* '(' */
CK((*filter->output_function)(0x49, filter->data)); /* 'I' */
}
filter->status = 0x100;
CK((*filter->output_function)(s & 0x7f, filter->data));
} else if (s < 0x8080) { /* X 0208 */
if ((filter->status & 0xff00) != 0x200) {
CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
@@ -380,11 +370,10 @@ mbfl_filt_conv_wchar_2022jp(int c, mbfl_convert_filter *filter)
} else if (c >= ucs_r_jis_table_min && c < ucs_r_jis_table_max) {
s = ucs_r_jis_table[c - ucs_r_jis_table_min];
}
if (s <= 0) {
if (c == 0xa5) { /* YEN SIGN */
s = 0x1005c;
} else if (c == 0x203e) { /* OVER LINE */
s = 0x1007e;
} else if (c == 0xff3c) { /* FULLWIDTH REVERSE SOLIDUS */
s = 0x2140;
} else if (c == 0x2225) { /* PARALLEL TO */

View File

@@ -221,8 +221,6 @@ int mbfl_filt_conv_wchar_sjis(int c, mbfl_convert_filter *filter)
s1 = 0x5C;
} else if (c == 0xFF3C) { /* FULLWIDTH REVERSE SOLIDUS */
s1 = 0x2140;
} else if (c == 0xFF5E) { /* FULLWIDTH TILDE */
s1 = 0x2141;
} else if (c == 0x2225) { /* PARALLEL TO */
s1 = 0x2142;
} else if (c == 0xFF0D) { /* FULLWIDTH HYPHEN-MINUS */

View File

@@ -209,43 +209,39 @@ int mbfl_filt_conv_jis2004_wchar(int c, mbfl_convert_filter *filter)
}
w1 = (s1 << 8) | s2;
if (w1 >= 0x2121) {
/* conversion for combining characters */
if ((w1 >= 0x2477 && w1 <= 0x2479) || (w1 >= 0x2479 && w1 <= 0x247B) ||
(w1 >= 0x2577 && w1 <= 0x257E) || w1 == 0x2678 || w1 == 0x2B44 ||
(w1 >= 0x2B48 && w1 <= 0x2B4F) || (w1 >= 0x2B65 && w1 <= 0x2B66)) {
k = mbfl_bisec_srch2(w1, jisx0213_u2_key, jisx0213_u2_tbl_len);
if (k >= 0) {
w = jisx0213_u2_tbl[2*k];
CK((*filter->output_function)(w, filter->data));
w = jisx0213_u2_tbl[2*k+1];
}
/* conversion for combining characters */
if ((w1 >= 0x2477 && w1 <= 0x2479) || (w1 >= 0x2479 && w1 <= 0x247B) ||
(w1 >= 0x2577 && w1 <= 0x257E) || w1 == 0x2678 || w1 == 0x2B44 ||
(w1 >= 0x2B48 && w1 <= 0x2B4F) || (w1 >= 0x2B65 && w1 <= 0x2B66)) {
k = mbfl_bisec_srch2(w1, jisx0213_u2_key, jisx0213_u2_tbl_len);
if (k >= 0) {
w = jisx0213_u2_tbl[2*k];
CK((*filter->output_function)(w, filter->data));
w = jisx0213_u2_tbl[2*k+1];
}
/* conversion for BMP */
if (w <= 0) {
w1 = (s1 - 0x21)*94 + s2 - 0x21;
if (w1 >= 0 && w1 < jisx0213_ucs_table_size) {
w = jisx0213_ucs_table[w1];
}
}
/* conversion for CJK Unified Ideographs ext.B (U+2XXXX) */
if (w <= 0) {
w1 = (s1 << 8) | s2;
k = mbfl_bisec_srch2(w1, jisx0213_jis_u5_key, jisx0213_u5_tbl_len);
if (k >= 0) {
w = jisx0213_jis_u5_tbl[k] + 0x20000;
}
}
if (w <= 0) {
w = MBFL_BAD_INPUT;
}
CK((*filter->output_function)(w, filter->data));
} else {
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
}
/* conversion for BMP */
if (w <= 0) {
w1 = (s1 - 0x21)*94 + s2 - 0x21;
if (w1 >= 0 && w1 < jisx0213_ucs_table_size) {
w = jisx0213_ucs_table[w1];
}
}
/* conversion for CJK Unified Ideographs ext.B (U+2XXXX) */
if (w <= 0) {
w1 = (s1 << 8) | s2;
k = mbfl_bisec_srch2(w1, jisx0213_jis_u5_key, jisx0213_u5_tbl_len);
if (k >= 0) {
w = jisx0213_jis_u5_tbl[k] + 0x20000;
}
}
if (w <= 0) {
w = MBFL_BAD_INPUT;
}
CK((*filter->output_function)(w, filter->data));
break;
case 2: /* got 0x8e: EUC-JP-2004 kana */
@@ -297,11 +293,8 @@ int mbfl_filt_conv_jis2004_wchar(int c, mbfl_convert_filter *filter)
/* check for japanese chars in BMP */
s = (s1 + 94 + k)*94 + s2;
if (s >= 0 && s < jisx0213_ucs_table_size) {
w = jisx0213_ucs_table[s];
} else {
w = 0;
}
ZEND_ASSERT(s < jisx0213_ucs_table_size);
w = jisx0213_ucs_table[s];
/* check for japanese chars in CJK Unified Ideographs ext.B (U+2XXXX) */
if (w <= 0) {
@@ -408,9 +401,7 @@ int mbfl_filt_conv_jis2004_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
@@ -543,8 +534,6 @@ retry:
} else {
s1 = -1;
}
} else if (s1 >= 0x9980) {
s1 = -1;
}
if (s1 >= 0) {

View File

@@ -253,9 +253,7 @@ mbfl_filt_conv_sjis_mac_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
@@ -287,7 +285,6 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
// r: U+FF00 -> U+FFFF
switch (filter->status) {
case 1:
c1 = filter->cache;
filter->cache = 0;
@@ -368,7 +365,6 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
ZEND_FALLTHROUGH;
case 0:
if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) {
s1 = ucs_a1_jis_table[c - ucs_a1_jis_table_min];
if (c == 0x5c) {
@@ -480,7 +476,6 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
}
break;
case 2:
c1 = filter->cache;
filter->cache = 0;
@@ -516,7 +511,6 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
CK(mbfl_filt_conv_illegal_output(c1, filter));
return mbfl_filt_conv_wchar_sjis_mac(c, filter);
}
break;
case 3:
@@ -653,10 +647,9 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
}

View File

@@ -785,16 +785,6 @@ int mbfl_filt_conv_wchar_sjis_mobile(int c, mbfl_convert_filter *filter)
}
}
if (s1 <= 0) {
/* CP932 vendor ext3 (115ku - 119ku) */
for (c1 = 0; c1 < cp932ext3_ucs_table_max - cp932ext3_ucs_table_min; c1++) {
if (c == cp932ext3_ucs_table[c1]) {
s1 = (((c1 / 94) + 0x93) << 8) + (c1 % 94) + 0x21;
break;
}
}
}
if (c == 0) {
s1 = 0;
}

View File

@@ -133,9 +133,7 @@ int mbfl_filt_conv_uhc_wchar(int c, mbfl_convert_filter *filter)
CK((*filter->output_function)(w, filter->data));
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -163,11 +163,7 @@ int mbfl_filt_conv_utf7_wchar(int c, mbfl_convert_filter *filter)
s &= 0x3ff;
s |= (filter->cache & 0xfff0000) >> 6;
filter->cache = n;
if (s >= MBFL_WCSPLANE_SUPMIN && s < MBFL_WCSPLANE_SUPMAX) {
CK((*filter->output_function)(s, filter->data));
} else { /* illegal character */
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
}
CK((*filter->output_function)(s, filter->data));
} else {
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
filter->cache = n;
@@ -207,11 +203,7 @@ int mbfl_filt_conv_utf7_wchar(int c, mbfl_convert_filter *filter)
s &= 0x3ff;
s |= (filter->cache & 0xfff0000) >> 6;
filter->cache = n;
if (s >= MBFL_WCSPLANE_SUPMIN && s < MBFL_WCSPLANE_SUPMAX) {
CK((*filter->output_function)(s, filter->data));
} else { /* illegal character */
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
}
CK((*filter->output_function)(s, filter->data));
} else {
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
filter->cache = n;
@@ -245,11 +237,7 @@ int mbfl_filt_conv_utf7_wchar(int c, mbfl_convert_filter *filter)
s &= 0x3ff;
s |= (filter->cache & 0xfff0000) >> 6;
filter->cache = 0;
if (s >= MBFL_WCSPLANE_SUPMIN && s < MBFL_WCSPLANE_SUPMAX) {
CK((*filter->output_function)(s, filter->data));
} else { /* illegal character */
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
}
CK((*filter->output_function)(s, filter->data));
} else {
CK((*filter->output_function)(MBFL_BAD_INPUT, filter->data));
filter->cache = 0;
@@ -264,9 +252,7 @@ int mbfl_filt_conv_utf7_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
@@ -373,9 +359,7 @@ int mbfl_filt_conv_wchar_utf7(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -269,9 +269,7 @@ int mbfl_filt_conv_utf7imap_wchar(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
@@ -397,9 +395,7 @@ int mbfl_filt_conv_wchar_utf7imap(int c, mbfl_convert_filter *filter)
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;
@@ -434,5 +430,6 @@ static int mbfl_filt_conv_wchar_utf7imap_flush(mbfl_convert_filter *filter)
CK((*filter->output_function)('-', filter->data));
break;
}
return 0;
}

View File

@@ -172,9 +172,8 @@ retry:
}
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -261,9 +261,8 @@ retry:
goto retry;
}
break;
default:
filter->status = 0;
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 0;

View File

@@ -2480,8 +2480,6 @@ int mbfl_filt_decode_htmlnumericentity_flush(mbfl_convert_filter *filter)
(*pc->decoder->filter_function)(mbfl_hexchar_table[d], pc->decoder);
}
break;
default:
break;
}
}