Skip to content

Commit 245daed

Browse files
committed
Move kana translation tables to mbfilter_cjk.c
These (static) tables were defined in a header file, which was included in two different .c files. That will result in two copies of the tables being included in the PHP binary. But the tables were only used in one of the two .c files. Move it where it is used to avoid needlessly bloating the binary. (I checked in a hex editor and confirmed that while the previous binary contained two copies of these tables, it now only contains one.)
1 parent 175154d commit 245daed

File tree

2 files changed

+40
-39
lines changed

2 files changed

+40
-39
lines changed

ext/mbstring/libmbfl/filters/mbfilter_cjk.c

+40
Original file line numberDiff line numberDiff line change
@@ -2533,6 +2533,46 @@ static int mbfl_filt_conv_cp5022x_wchar_flush(mbfl_convert_filter *filter)
25332533
return 0;
25342534
}
25352535

2536+
static const unsigned char hankana2zenkana_table[64] = {
2537+
0x00,0x02,0x0C,0x0D,0x01,0xFB,0xF2,0xA1,0xA3,0xA5,
2538+
0xA7,0xA9,0xE3,0xE5,0xE7,0xC3,0xFC,0xA2,0xA4,0xA6,
2539+
0xA8,0xAA,0xAB,0xAD,0xAF,0xB1,0xB3,0xB5,0xB7,0xB9,
2540+
0xBB,0xBD,0xBF,0xC1,0xC4,0xC6,0xC8,0xCA,0xCB,0xCC,
2541+
0xCD,0xCE,0xCF,0xD2,0xD5,0xD8,0xDB,0xDE,0xDF,0xE0,
2542+
0xE1,0xE2,0xE4,0xE6,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,
2543+
0xEF,0xF3,0x9B,0x9C
2544+
};
2545+
2546+
static const unsigned char hankana2zenhira_table[64] = {
2547+
0x00,0x02,0x0C,0x0D,0x01,0xFB,0x92,0x41,0x43,0x45,
2548+
0x47,0x49,0x83,0x85,0x87,0x63,0xFC,0x42,0x44,0x46,
2549+
0x48,0x4A,0x4B,0x4D,0x4F,0x51,0x53,0x55,0x57,0x59,
2550+
0x5B,0x5D,0x5F,0x61,0x64,0x66,0x68,0x6A,0x6B,0x6C,
2551+
0x6D,0x6E,0x6F,0x72,0x75,0x78,0x7B,0x7E,0x7F,0x80,
2552+
0x81,0x82,0x84,0x86,0x88,0x89,0x8A,0x8B,0x8C,0x8D,
2553+
0x8F,0x93,0x9B,0x9C
2554+
};
2555+
2556+
static const unsigned char zenkana2hankana_table[84][2] = {
2557+
{0x67,0x00},{0x71,0x00},{0x68,0x00},{0x72,0x00},{0x69,0x00},
2558+
{0x73,0x00},{0x6A,0x00},{0x74,0x00},{0x6B,0x00},{0x75,0x00},
2559+
{0x76,0x00},{0x76,0x9E},{0x77,0x00},{0x77,0x9E},{0x78,0x00},
2560+
{0x78,0x9E},{0x79,0x00},{0x79,0x9E},{0x7A,0x00},{0x7A,0x9E},
2561+
{0x7B,0x00},{0x7B,0x9E},{0x7C,0x00},{0x7C,0x9E},{0x7D,0x00},
2562+
{0x7D,0x9E},{0x7E,0x00},{0x7E,0x9E},{0x7F,0x00},{0x7F,0x9E},
2563+
{0x80,0x00},{0x80,0x9E},{0x81,0x00},{0x81,0x9E},{0x6F,0x00},
2564+
{0x82,0x00},{0x82,0x9E},{0x83,0x00},{0x83,0x9E},{0x84,0x00},
2565+
{0x84,0x9E},{0x85,0x00},{0x86,0x00},{0x87,0x00},{0x88,0x00},
2566+
{0x89,0x00},{0x8A,0x00},{0x8A,0x9E},{0x8A,0x9F},{0x8B,0x00},
2567+
{0x8B,0x9E},{0x8B,0x9F},{0x8C,0x00},{0x8C,0x9E},{0x8C,0x9F},
2568+
{0x8D,0x00},{0x8D,0x9E},{0x8D,0x9F},{0x8E,0x00},{0x8E,0x9E},
2569+
{0x8E,0x9F},{0x8F,0x00},{0x90,0x00},{0x91,0x00},{0x92,0x00},
2570+
{0x93,0x00},{0x6C,0x00},{0x94,0x00},{0x6D,0x00},{0x95,0x00},
2571+
{0x6E,0x00},{0x96,0x00},{0x97,0x00},{0x98,0x00},{0x99,0x00},
2572+
{0x9A,0x00},{0x9B,0x00},{0x9C,0x00},{0x9C,0x00},{0x72,0x00},
2573+
{0x74,0x00},{0x66,0x00},{0x9D,0x00},{0x73,0x9E}
2574+
};
2575+
25362576
/* Apply various transforms to input codepoint, such as converting halfwidth katakana
25372577
* to fullwidth katakana. `mode` is a bitfield which controls which transforms are
25382578
* actually performed. The bit values are defined in translit_kana_jisx0201_jisx0208.h.

ext/mbstring/libmbfl/filters/translit_kana_jisx0201_jisx0208.h

-39
Original file line numberDiff line numberDiff line change
@@ -47,43 +47,4 @@
4747

4848
#define MBFL_HAN2ZEN_GLUE 0x10000
4949

50-
static const unsigned char hankana2zenkana_table[64] = {
51-
0x00,0x02,0x0C,0x0D,0x01,0xFB,0xF2,0xA1,0xA3,0xA5,
52-
0xA7,0xA9,0xE3,0xE5,0xE7,0xC3,0xFC,0xA2,0xA4,0xA6,
53-
0xA8,0xAA,0xAB,0xAD,0xAF,0xB1,0xB3,0xB5,0xB7,0xB9,
54-
0xBB,0xBD,0xBF,0xC1,0xC4,0xC6,0xC8,0xCA,0xCB,0xCC,
55-
0xCD,0xCE,0xCF,0xD2,0xD5,0xD8,0xDB,0xDE,0xDF,0xE0,
56-
0xE1,0xE2,0xE4,0xE6,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,
57-
0xEF,0xF3,0x9B,0x9C
58-
};
59-
60-
static const unsigned char hankana2zenhira_table[64] = {
61-
0x00,0x02,0x0C,0x0D,0x01,0xFB,0x92,0x41,0x43,0x45,
62-
0x47,0x49,0x83,0x85,0x87,0x63,0xFC,0x42,0x44,0x46,
63-
0x48,0x4A,0x4B,0x4D,0x4F,0x51,0x53,0x55,0x57,0x59,
64-
0x5B,0x5D,0x5F,0x61,0x64,0x66,0x68,0x6A,0x6B,0x6C,
65-
0x6D,0x6E,0x6F,0x72,0x75,0x78,0x7B,0x7E,0x7F,0x80,
66-
0x81,0x82,0x84,0x86,0x88,0x89,0x8A,0x8B,0x8C,0x8D,
67-
0x8F,0x93,0x9B,0x9C
68-
};
69-
static const unsigned char zenkana2hankana_table[84][2] = {
70-
{0x67,0x00},{0x71,0x00},{0x68,0x00},{0x72,0x00},{0x69,0x00},
71-
{0x73,0x00},{0x6A,0x00},{0x74,0x00},{0x6B,0x00},{0x75,0x00},
72-
{0x76,0x00},{0x76,0x9E},{0x77,0x00},{0x77,0x9E},{0x78,0x00},
73-
{0x78,0x9E},{0x79,0x00},{0x79,0x9E},{0x7A,0x00},{0x7A,0x9E},
74-
{0x7B,0x00},{0x7B,0x9E},{0x7C,0x00},{0x7C,0x9E},{0x7D,0x00},
75-
{0x7D,0x9E},{0x7E,0x00},{0x7E,0x9E},{0x7F,0x00},{0x7F,0x9E},
76-
{0x80,0x00},{0x80,0x9E},{0x81,0x00},{0x81,0x9E},{0x6F,0x00},
77-
{0x82,0x00},{0x82,0x9E},{0x83,0x00},{0x83,0x9E},{0x84,0x00},
78-
{0x84,0x9E},{0x85,0x00},{0x86,0x00},{0x87,0x00},{0x88,0x00},
79-
{0x89,0x00},{0x8A,0x00},{0x8A,0x9E},{0x8A,0x9F},{0x8B,0x00},
80-
{0x8B,0x9E},{0x8B,0x9F},{0x8C,0x00},{0x8C,0x9E},{0x8C,0x9F},
81-
{0x8D,0x00},{0x8D,0x9E},{0x8D,0x9F},{0x8E,0x00},{0x8E,0x9E},
82-
{0x8E,0x9F},{0x8F,0x00},{0x90,0x00},{0x91,0x00},{0x92,0x00},
83-
{0x93,0x00},{0x6C,0x00},{0x94,0x00},{0x6D,0x00},{0x95,0x00},
84-
{0x6E,0x00},{0x96,0x00},{0x97,0x00},{0x98,0x00},{0x99,0x00},
85-
{0x9A,0x00},{0x9B,0x00},{0x9C,0x00},{0x9C,0x00},{0x72,0x00},
86-
{0x74,0x00},{0x66,0x00},{0x9D,0x00},{0x73,0x9E}
87-
};
88-
8950
#endif /* TRANSLIT_KANA_JISX0201_JISX0208_H */

0 commit comments

Comments
 (0)