Skip to content

Commit e814588

Browse files
committed
Remove dead code from mbfilter_koi8u.c (and do general code cleanup)
1 parent f9826fb commit e814588

File tree

2 files changed

+8
-40
lines changed

2 files changed

+8
-40
lines changed

ext/mbstring/libmbfl/filters/mbfilter_koi8u.c

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -69,62 +69,31 @@ const struct mbfl_convert_vtbl vtbl_koi8u_wchar = {
6969

7070
#define CK(statement) do { if ((statement) < 0) return (-1); } while (0)
7171

72-
/*
73-
* koi8u => wchar
74-
*/
75-
int
76-
mbfl_filt_conv_koi8u_wchar(int c, mbfl_convert_filter *filter)
72+
int mbfl_filt_conv_koi8u_wchar(int c, mbfl_convert_filter *filter)
7773
{
7874
int s;
7975

80-
if (c >= 0 && c < koi8u_ucs_table_min) {
76+
if (c < koi8u_ucs_table_min) {
8177
s = c;
82-
} else if (c >= koi8u_ucs_table_min && c < 0x100) {
83-
s = koi8u_ucs_table[c - koi8u_ucs_table_min];
84-
if (s <= 0) {
85-
s = c;
86-
s &= MBFL_WCSPLANE_MASK;
87-
s |= MBFL_WCSPLANE_KOI8U;
88-
}
8978
} else {
90-
s = c;
91-
s &= MBFL_WCSGROUP_MASK;
92-
s |= MBFL_WCSGROUP_THROUGH;
79+
s = koi8u_ucs_table[c - koi8u_ucs_table_min];
9380
}
9481

9582
CK((*filter->output_function)(s, filter->data));
96-
9783
return c;
9884
}
9985

100-
/*
101-
* wchar => koi8u
102-
*/
103-
int
104-
mbfl_filt_conv_wchar_koi8u(int c, mbfl_convert_filter *filter)
86+
int mbfl_filt_conv_wchar_koi8u(int c, mbfl_convert_filter *filter)
10587
{
106-
int s, n;
107-
10888
if (c < 0x80) {
109-
s = c;
89+
CK((*filter->output_function)(c, filter->data));
11090
} else {
111-
s = -1;
112-
n = koi8u_ucs_table_len-1;
113-
while (n >= 0) {
91+
for (int n = 0; n < koi8u_ucs_table_len; n++) {
11492
if (c == koi8u_ucs_table[n]) {
115-
s = koi8u_ucs_table_min + n;
116-
break;
93+
CK((*filter->output_function)(koi8u_ucs_table_min + n, filter->data));
94+
return c;
11795
}
118-
n--;
119-
}
120-
if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_KOI8U) {
121-
s = c & MBFL_WCSPLANE_MASK;
12296
}
123-
}
124-
125-
if (s >= 0) {
126-
CK((*filter->output_function)(s, filter->data));
127-
} else {
12897
CK(mbfl_filt_conv_illegal_output(c, filter));
12998
}
13099

ext/mbstring/libmbfl/mbfl/mbfl_consts.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
#define MBFL_WCSPLANE_CNS11643 0x70f50000 /* 2121h - 9898h */
6363
#define MBFL_WCSPLANE_UHC 0x70f60000 /* 8141h - fefeh */
6464
#define MBFL_WCSPLANE_ARMSCII8 0x70fb0000
65-
#define MBFL_WCSPLANE_KOI8U 0x70fc0000
6665
#define MBFL_WCSPLANE_GB18030 0x70ff0000 /* a1a1h-e3329a35h */
6766
#define MBFL_WCSGROUP_MASK 0xffffff
6867
#define MBFL_WCSGROUP_UCS4MAX 0x70000000

0 commit comments

Comments
 (0)