Remove dead code from mbfilter_cp866.c (and do general code cleanup)

Since there are no invalid bytes in CP866, these `if` conditions will never
be true.
This commit is contained in:
Alex Dowad 2020-10-18 16:26:59 +02:00
parent bc04e0cc6d
commit 20a404f765
2 changed files with 8 additions and 40 deletions

View file

@ -72,62 +72,31 @@ const struct mbfl_convert_vtbl vtbl_cp866_wchar = {
#define CK(statement) do { if ((statement) < 0) return (-1); } while (0)
/*
* cp866 => wchar
*/
int
mbfl_filt_conv_cp866_wchar(int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_cp866_wchar(int c, mbfl_convert_filter *filter)
{
int s;
if (c >= 0 && c < cp866_ucs_table_min) {
if (c < cp866_ucs_table_min) {
s = c;
} else if (c >= cp866_ucs_table_min && c < 0x100) {
s = cp866_ucs_table[c - cp866_ucs_table_min];
if (s <= 0) {
s = c;
s &= MBFL_WCSPLANE_MASK;
s |= MBFL_WCSPLANE_CP866;
}
} else {
s = c;
s &= MBFL_WCSGROUP_MASK;
s |= MBFL_WCSGROUP_THROUGH;
s = cp866_ucs_table[c - cp866_ucs_table_min];
}
CK((*filter->output_function)(s, filter->data));
return c;
}
/*
* wchar => cp866
*/
int
mbfl_filt_conv_wchar_cp866(int c, mbfl_convert_filter *filter)
int mbfl_filt_conv_wchar_cp866(int c, mbfl_convert_filter *filter)
{
int s, n;
if (c < 0x80) {
s = c;
CK((*filter->output_function)(c, filter->data));
} else {
s = -1;
n = cp866_ucs_table_len-1;
while (n >= 0) {
for (int n = 0; n < cp866_ucs_table_len; n++) {
if (c == cp866_ucs_table[n]) {
s = cp866_ucs_table_min + n;
break;
}
n--;
}
if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_CP866) {
s = c & MBFL_WCSPLANE_MASK;
CK((*filter->output_function)(cp866_ucs_table_min + n, filter->data));
return c;
}
}
if (s >= 0) {
CK((*filter->output_function)(s, filter->data));
} else {
CK(mbfl_filt_conv_illegal_output(c, filter));
}

View file

@ -70,7 +70,6 @@
#define MBFL_WCSPLANE_BIG5 0x70f40000 /* 2121h - 9898h */
#define MBFL_WCSPLANE_CNS11643 0x70f50000 /* 2121h - 9898h */
#define MBFL_WCSPLANE_UHC 0x70f60000 /* 8141h - fefeh */
#define MBFL_WCSPLANE_CP866 0x70f80000
#define MBFL_WCSPLANE_KOI8R 0x70f90000
#define MBFL_WCSPLANE_8859_16 0x70fa0000 /* 00h - FFh */
#define MBFL_WCSPLANE_ARMSCII8 0x70fb0000