@@ -1923,9 +1923,9 @@ static int mbfl_filt_conv_wchar_jis2004(int c, mbfl_convert_filter *filter)
19231923
19241924 /* check for major japanese chars: U+4E00 - U+9FFF */
19251925 if (s1 <= 0 ) {
1926- for (k = 0 ; k < uni2jis_tbl_len ; k ++ ) {
1927- if (c >= uni2jis_tbl_range [k ][0 ] && c <= uni2jis_tbl_range [k ][1 ]) {
1928- s1 = uni2jis_tbl [k ][c - uni2jis_tbl_range [k ][0 ]];
1926+ for (size_t offset = 0 ; offset < uni2jis_tbl_len ; offset ++ ) {
1927+ if (c >= uni2jis_tbl_range [offset ][0 ] && c <= uni2jis_tbl_range [offset ][1 ]) {
1928+ s1 = uni2jis_tbl [offset ][c - uni2jis_tbl_range [offset ][0 ]];
19291929 break ;
19301930 }
19311931 }
@@ -10687,7 +10687,6 @@ const mbfl_encoding mbfl_encoding_uhc = {
1068710687
1068810688static int mbfl_filt_conv_gb18030_wchar (int c , mbfl_convert_filter * filter )
1068910689{
10690- int k ;
1069110690 int c1 , c2 , c3 , w = -1 ;
1069210691
1069310692 switch (filter -> status ) {
@@ -10728,13 +10727,14 @@ static int mbfl_filt_conv_gb18030_wchar(int c, mbfl_convert_filter *filter)
1072810727
1072910728 c2 = (c1 << 8 ) | c ;
1073010729
10731- if (w <= 0 &&
10732- ((c2 >= 0xa2ab && c2 <= 0xa9f0 + (0xe80f - 0xe801 )) ||
10733- (c2 >= 0xd7fa && c2 <= 0xd7fa + (0xe814 - 0xe810 )) ||
10734- (c2 >= 0xfe50 && c2 <= 0xfe80 + (0xe864 - 0xe844 )))) {
10735- for (k = 0 ; k < mbfl_gb18030_pua_tbl_max ; k ++ ) {
10736- if (c2 >= mbfl_gb18030_pua_tbl [k ][2 ] && c2 <= mbfl_gb18030_pua_tbl [k ][2 ] + mbfl_gb18030_pua_tbl [k ][1 ] - mbfl_gb18030_pua_tbl [k ][0 ]) {
10737- w = c2 - mbfl_gb18030_pua_tbl [k ][2 ] + mbfl_gb18030_pua_tbl [k ][0 ];
10730+ if (w <= 0 && (
10731+ (c2 >= 0xa2ab && c2 <= 0xa9f0 + (0xe80f - 0xe801 )) ||
10732+ (c2 >= 0xd7fa && c2 <= 0xd7fa + (0xe814 - 0xe810 )) ||
10733+ (c2 >= 0xfe50 && c2 <= 0xfe80 + (0xe864 - 0xe844 ))
10734+ )) {
10735+ for (size_t offset = 0 ; offset < mbfl_gb18030_pua_tbl_max ; offset ++ ) {
10736+ if (c2 >= mbfl_gb18030_pua_tbl [offset ][2 ] && c2 <= mbfl_gb18030_pua_tbl [offset ][2 ] + mbfl_gb18030_pua_tbl [offset ][1 ] - mbfl_gb18030_pua_tbl [offset ][0 ]) {
10737+ w = c2 - mbfl_gb18030_pua_tbl [offset ][2 ] + mbfl_gb18030_pua_tbl [offset ][0 ];
1073810738 CK ((* filter -> output_function )(w , filter -> data ));
1073910739 break ;
1074010740 }
@@ -10783,7 +10783,7 @@ static int mbfl_filt_conv_gb18030_wchar(int c, mbfl_convert_filter *filter)
1078310783 } else { /* Unicode BMP */
1078410784 w = (((c1 - 0x81 )* 10 + (c2 - 0x30 ))* 126 + (c3 - 0x81 ))* 10 + (c - 0x30 );
1078510785 if (w >= 0 && w <= 39419 ) {
10786- k = mbfl_bisec_srch (w , mbfl_gb2uni_tbl , mbfl_gb_uni_max );
10786+ int k = mbfl_bisec_srch (w , mbfl_gb2uni_tbl , mbfl_gb_uni_max );
1078710787 w += mbfl_gb_uni_ofst [k ];
1078810788 } else {
1078910789 CK ((* filter -> output_function )(MBFL_BAD_INPUT , filter -> data ));
@@ -11219,7 +11219,6 @@ static void mb_wchar_to_gb18030(uint32_t *in, size_t len, mb_convert_buf *buf, b
1121911219
1122011220static int mbfl_filt_conv_cp936_wchar (int c , mbfl_convert_filter * filter )
1122111221{
11222- int k ;
1122311222 int c1 , c2 , w = -1 ;
1122411223
1122511224 switch (filter -> status ) {
@@ -11253,10 +11252,12 @@ static int mbfl_filt_conv_cp936_wchar(int c, mbfl_convert_filter *filter)
1125311252
1125411253 c2 = (c1 << 8 ) | c ;
1125511254
11256- if (w <= 0 &&
11257- ((c2 >= 0xa2ab && c2 <= 0xa9f0 + (0xe80f - 0xe801 )) ||
11258- (c2 >= 0xd7fa && c2 <= 0xd7fa + (0xe814 - 0xe810 )) ||
11259- (c2 >= 0xfe50 && c2 <= 0xfe80 + (0xe864 - 0xe844 )))) {
11255+ if (w <= 0 && (
11256+ (c2 >= 0xa2ab && c2 <= 0xa9f0 + (0xe80f - 0xe801 )) ||
11257+ (c2 >= 0xd7fa && c2 <= 0xd7fa + (0xe814 - 0xe810 )) ||
11258+ (c2 >= 0xfe50 && c2 <= 0xfe80 + (0xe864 - 0xe844 ))
11259+ )) {
11260+ size_t k ;
1126011261 for (k = 0 ; k < mbfl_cp936_pua_tbl_max ; k ++ ) {
1126111262 if (c2 >= mbfl_cp936_pua_tbl [k ][2 ] &&
1126211263 c2 <= mbfl_cp936_pua_tbl [k ][2 ] +
@@ -12026,7 +12027,7 @@ static inline int is_in_cp950_pua(int c1, int c)
1202612027
1202712028static int mbfl_filt_conv_big5_wchar (int c , mbfl_convert_filter * filter )
1202812029{
12029- int k , c1 , w ;
12030+ int c1 , w ;
1203012031
1203112032 switch (filter -> status ) {
1203212033 case 0 :
@@ -12063,6 +12064,7 @@ static int mbfl_filt_conv_big5_wchar(int c, mbfl_convert_filter *filter)
1206312064 if (is_in_cp950_pua (c1 , c )) {
1206412065 int c2 = (c1 << 8 ) | c ;
1206512066
12067+ size_t k ;
1206612068 for (k = 0 ; k < sizeof (cp950_pua_tbl ) / (sizeof (unsigned short )* 4 ); k ++ ) {
1206712069 if (c2 >= cp950_pua_tbl [k ][2 ] && c2 <= cp950_pua_tbl [k ][3 ]) {
1206812070 break ;
@@ -12147,7 +12149,7 @@ static int mbfl_filt_conv_big5_wchar_flush(mbfl_convert_filter *filter)
1214712149
1214812150static int mbfl_filt_conv_wchar_big5 (int c , mbfl_convert_filter * filter )
1214912151{
12150- int k , s = 0 ;
12152+ int s = 0 ;
1215112153
1215212154 if (c >= ucs_a1_big5_table_min && c < ucs_a1_big5_table_max ) {
1215312155 s = ucs_a1_big5_table [c - ucs_a1_big5_table_min ];
@@ -12165,6 +12167,7 @@ static int mbfl_filt_conv_wchar_big5(int c, mbfl_convert_filter *filter)
1216512167
1216612168 if (filter -> to -> no_encoding == mbfl_no_encoding_cp950 ) {
1216712169 if (c >= 0xe000 && c <= 0xf848 ) { /* PUA for CP950 */
12170+ size_t k ;
1216812171 for (k = 0 ; k < sizeof (cp950_pua_tbl ) / (sizeof (unsigned short )* 4 ); k ++ ) {
1216912172 if (c <= cp950_pua_tbl [k ][1 ]) {
1217012173 break ;
@@ -12373,7 +12376,7 @@ static size_t mb_cp950_to_wchar(unsigned char **in, size_t *in_len, uint32_t *bu
1237312376 if (is_in_cp950_pua (c , c2 )) {
1237412377 unsigned int s = (c << 8 ) | c2 ;
1237512378
12376- int k ;
12379+ size_t k ;
1237712380 for (k = 0 ; k < sizeof (cp950_pua_tbl ) / (sizeof (unsigned short )* 4 ); k ++ ) {
1237812381 if (s >= cp950_pua_tbl [k ][2 ] && s <= cp950_pua_tbl [k ][3 ]) {
1237912382 break ;
@@ -12466,7 +12469,7 @@ static void mb_wchar_to_cp950(uint32_t *in, size_t len, mb_convert_buf *buf, boo
1246612469 }
1246712470
1246812471 if (w >= 0xE000 && w <= 0xF848 ) {
12469- int k ;
12472+ size_t k ;
1247012473 for (k = 0 ; k < sizeof (cp950_pua_tbl ) / (sizeof (unsigned short )* 4 ); k ++ ) {
1247112474 if (w <= cp950_pua_tbl [k ][1 ]) {
1247212475 break ;
0 commit comments