@@ -929,7 +929,7 @@ static void mb_wchar_to_sjis_docomo(uint32_t *in, size_t len, mb_convert_buf *bu
929
929
{
930
930
unsigned char * out , * limit ;
931
931
MB_CONVERT_BUF_LOAD (buf , out , limit );
932
- MB_CONVERT_BUF_ENSURE (buf , out , limit , len );
932
+ MB_CONVERT_BUF_ENSURE (buf , out , limit , len + ( buf -> state ? 1 : 0 ) );
933
933
934
934
uint32_t w ;
935
935
unsigned int s = 0 ;
@@ -939,14 +939,15 @@ static void mb_wchar_to_sjis_docomo(uint32_t *in, size_t len, mb_convert_buf *bu
939
939
w = buf -> state ;
940
940
buf -> state = 0 ;
941
941
if (len ) {
942
- goto process_possible_keypad ;
942
+ goto reprocess_wchar ;
943
943
} else {
944
944
goto emit_output ;
945
945
}
946
946
}
947
947
948
948
while (len -- ) {
949
949
w = * in ++ ;
950
+ reprocess_wchar :
950
951
s = 0 ;
951
952
952
953
if (w >= ucs_a1_jis_table_min && w < ucs_a1_jis_table_max ) {
@@ -1018,7 +1019,6 @@ static void mb_wchar_to_sjis_docomo(uint32_t *in, size_t len, mb_convert_buf *bu
1018
1019
break ;
1019
1020
}
1020
1021
}
1021
- process_possible_keypad : ;
1022
1022
uint32_t w2 = * in ++ ; len -- ;
1023
1023
if (w2 == 0x20E3 ) {
1024
1024
if (w == '#' ) {
@@ -1160,7 +1160,7 @@ static void mb_wchar_to_sjis_kddi(uint32_t *in, size_t len, mb_convert_buf *buf,
1160
1160
{
1161
1161
unsigned char * out , * limit ;
1162
1162
MB_CONVERT_BUF_LOAD (buf , out , limit );
1163
- MB_CONVERT_BUF_ENSURE (buf , out , limit , len );
1163
+ MB_CONVERT_BUF_ENSURE (buf , out , limit , len + ( buf -> state ? 1 : 0 ) );
1164
1164
1165
1165
uint32_t w ;
1166
1166
unsigned int s = 0 ;
@@ -1169,18 +1169,15 @@ static void mb_wchar_to_sjis_kddi(uint32_t *in, size_t len, mb_convert_buf *buf,
1169
1169
w = buf -> state ;
1170
1170
buf -> state = 0 ;
1171
1171
if (len ) {
1172
- if (w >= NFLAGS ('A' )) {
1173
- goto process_possible_flag ;
1174
- } else {
1175
- goto process_possible_keypad ;
1176
- }
1172
+ goto reprocess_wchar ;
1177
1173
} else {
1178
1174
goto emit_output ;
1179
1175
}
1180
1176
}
1181
1177
1182
1178
while (len -- ) {
1183
1179
w = * in ++ ;
1180
+ reprocess_wchar :
1184
1181
s = 0 ;
1185
1182
1186
1183
if (w >= ucs_a1_jis_table_min && w < ucs_a1_jis_table_max ) {
@@ -1246,7 +1243,6 @@ static void mb_wchar_to_sjis_kddi(uint32_t *in, size_t len, mb_convert_buf *buf,
1246
1243
break ;
1247
1244
}
1248
1245
}
1249
- process_possible_keypad : ;
1250
1246
uint32_t w2 = * in ++ ; len -- ;
1251
1247
if (w2 == 0x20E3 ) {
1252
1248
if (w == '#' ) {
@@ -1271,7 +1267,6 @@ process_possible_keypad: ;
1271
1267
}
1272
1268
break ;
1273
1269
}
1274
- process_possible_flag : ;
1275
1270
uint32_t w2 = * in ++ ; len -- ;
1276
1271
if (w2 >= NFLAGS ('B' ) && w2 <= NFLAGS ('U' )) { /* B for GB, U for RU */
1277
1272
for (int i = 0 ; i < 10 ; i ++ ) {
@@ -1472,7 +1467,7 @@ static void mb_wchar_to_sjis_sb(uint32_t *in, size_t len, mb_convert_buf *buf, b
1472
1467
{
1473
1468
unsigned char * out , * limit ;
1474
1469
MB_CONVERT_BUF_LOAD (buf , out , limit );
1475
- MB_CONVERT_BUF_ENSURE (buf , out , limit , len );
1470
+ MB_CONVERT_BUF_ENSURE (buf , out , limit , len + ( buf -> state ? 1 : 0 ) );
1476
1471
1477
1472
uint32_t w ;
1478
1473
unsigned int s = 0 ;
@@ -1481,18 +1476,15 @@ static void mb_wchar_to_sjis_sb(uint32_t *in, size_t len, mb_convert_buf *buf, b
1481
1476
w = buf -> state ;
1482
1477
buf -> state = 0 ;
1483
1478
if (len ) {
1484
- if (w >= NFLAGS ('A' )) {
1485
- goto process_possible_flag ;
1486
- } else {
1487
- goto process_possible_keypad ;
1488
- }
1479
+ goto reprocess_wchar ;
1489
1480
} else {
1490
1481
goto emit_output ;
1491
1482
}
1492
1483
}
1493
1484
1494
1485
while (len -- ) {
1495
1486
w = * in ++ ;
1487
+ reprocess_wchar :
1496
1488
s = 0 ;
1497
1489
1498
1490
if (w >= ucs_a1_jis_table_min && w < ucs_a1_jis_table_max ) {
@@ -1558,7 +1550,6 @@ static void mb_wchar_to_sjis_sb(uint32_t *in, size_t len, mb_convert_buf *buf, b
1558
1550
break ;
1559
1551
}
1560
1552
}
1561
- process_possible_keypad : ;
1562
1553
uint32_t w2 = * in ++ ; len -- ;
1563
1554
if (w2 == 0x20E3 ) {
1564
1555
if (w == '#' ) {
@@ -1577,13 +1568,12 @@ process_possible_keypad: ;
1577
1568
if (end ) {
1578
1569
MB_CONVERT_ERROR (buf , out , limit , w , mb_wchar_to_sjis_sb );
1579
1570
} else {
1580
- /* Reprocess `w` when this function is called again with another buffer
1581
- * of wchars */
1571
+ /* Reprocess `w` when this function is called again with
1572
+ * another buffer of wchars */
1582
1573
buf -> state = w ;
1583
1574
}
1584
1575
break ;
1585
1576
}
1586
- process_possible_flag : ;
1587
1577
uint32_t w2 = * in ++ ; len -- ;
1588
1578
if (w2 >= NFLAGS ('B' ) && w2 <= NFLAGS ('U' )) { /* B for GB, U for RU */
1589
1579
for (int i = 0 ; i < 10 ; i ++ ) {
0 commit comments