]> granicus.if.org Git - php/commitdiff
Remove dead code from mbfilter_koi8u.c (and do general code cleanup)
authorAlex Dowad <alexinbeijing@gmail.com>
Sun, 18 Oct 2020 15:11:17 +0000 (17:11 +0200)
committerAlex Dowad <alexinbeijing@gmail.com>
Mon, 2 Nov 2020 19:31:06 +0000 (21:31 +0200)
ext/mbstring/libmbfl/filters/mbfilter_koi8u.c
ext/mbstring/libmbfl/mbfl/mbfl_consts.h

index 0362c42dab3fc21e73286834b88d6e068077b4d0..c94f59aa5a22ae5c16f5ddbfabf48bb104b12677 100644 (file)
@@ -69,62 +69,31 @@ const struct mbfl_convert_vtbl vtbl_koi8u_wchar = {
 
 #define CK(statement)  do { if ((statement) < 0) return (-1); } while (0)
 
-/*
- * koi8u => wchar
- */
-int
-mbfl_filt_conv_koi8u_wchar(int c, mbfl_convert_filter *filter)
+int mbfl_filt_conv_koi8u_wchar(int c, mbfl_convert_filter *filter)
 {
        int s;
 
-       if (c >= 0 && c < koi8u_ucs_table_min) {
+       if (c < koi8u_ucs_table_min) {
                s = c;
-       } else if (c >= koi8u_ucs_table_min && c < 0x100) {
-               s = koi8u_ucs_table[c - koi8u_ucs_table_min];
-               if (s <= 0) {
-                       s = c;
-                       s &= MBFL_WCSPLANE_MASK;
-                       s |= MBFL_WCSPLANE_KOI8U;
-               }
        } else {
-               s = c;
-               s &= MBFL_WCSGROUP_MASK;
-               s |= MBFL_WCSGROUP_THROUGH;
+               s = koi8u_ucs_table[c - koi8u_ucs_table_min];
        }
 
        CK((*filter->output_function)(s, filter->data));
-
        return c;
 }
 
-/*
- * wchar => koi8u
- */
-int
-mbfl_filt_conv_wchar_koi8u(int c, mbfl_convert_filter *filter)
+int mbfl_filt_conv_wchar_koi8u(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 = koi8u_ucs_table_len-1;
-               while (n >= 0) {
+               for (int n = 0; n < koi8u_ucs_table_len; n++) {
                        if (c == koi8u_ucs_table[n]) {
-                               s = koi8u_ucs_table_min + n;
-                               break;
+                               CK((*filter->output_function)(koi8u_ucs_table_min + n, filter->data));
+                               return c;
                        }
-                       n--;
-               }
-               if (s <= 0 && (c & ~MBFL_WCSPLANE_MASK) == MBFL_WCSPLANE_KOI8U) {
-                       s = c & MBFL_WCSPLANE_MASK;
                }
-       }
-
-       if (s >= 0) {
-               CK((*filter->output_function)(s, filter->data));
-       } else {
                CK(mbfl_filt_conv_illegal_output(c, filter));
        }
 
index 1ddaa381a5ab97e16f3fc07582cfb8ffe14e72a6..a5a8765072f38950fa24dd9a2e4b8d7a933680dd 100644 (file)
@@ -62,7 +62,6 @@
 #define MBFL_WCSPLANE_CNS11643         0x70f50000              /*  2121h - 9898h */
 #define MBFL_WCSPLANE_UHC              0x70f60000              /*  8141h - fefeh */
 #define MBFL_WCSPLANE_ARMSCII8                 0x70fb0000
-#define MBFL_WCSPLANE_KOI8U            0x70fc0000
 #define MBFL_WCSPLANE_GB18030          0x70ff0000              /* a1a1h-e3329a35h  */
 #define MBFL_WCSGROUP_MASK                0xffffff
 #define MBFL_WCSGROUP_UCS4MAX          0x70000000