Skip to content

Commit 4550036

Browse files
committed
Minor formatting tweaks in mbfilter_uhc.c
1 parent 9868c17 commit 4550036

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

ext/mbstring/libmbfl/filters/mbfilter_uhc.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
*
2828
*/
2929

30+
/* UHC was introduced by MicroSoft in Windows 95, and is also known as CP949.
31+
* It is the same as EUC-KR, but with 8,822 additional characters added to
32+
* complete all the characters in the Johab charset. */
33+
3034
#include "mbfilter.h"
3135
#include "mbfilter_uhc.h"
3236
#define UNICODE_TABLE_UHC_DEF
@@ -86,19 +90,16 @@ const struct mbfl_convert_vtbl vtbl_wchar_uhc = {
8690

8791
#define CK(statement) do { if ((statement) < 0) return (-1); } while (0)
8892

89-
/*
90-
* UHC => wchar
91-
*/
9293
int
9394
mbfl_filt_conv_uhc_wchar(int c, mbfl_convert_filter *filter)
9495
{
9596
int c1, w = 0, flag = 0;
9697

9798
switch (filter->status) {
9899
case 0:
99-
if (c >= 0 && c < 0x80) { /* latin */
100+
if (c >= 0 && c < 0x80) { /* latin */
100101
CK((*filter->output_function)(c, filter->data));
101-
} else if (c > 0x80 && c < 0xff && c != 0xc9) { /* dbcs lead byte */
102+
} else if (c > 0x80 && c < 0xff && c != 0xc9) { /* dbcs lead byte */
102103
filter->status = 1;
103104
filter->cache = c;
104105
} else {
@@ -108,27 +109,27 @@ mbfl_filt_conv_uhc_wchar(int c, mbfl_convert_filter *filter)
108109
}
109110
break;
110111

111-
case 1: /* dbcs second byte */
112+
case 1: /* dbcs second byte */
112113
filter->status = 0;
113114
c1 = filter->cache;
114115

115-
if ( c1 >= 0x81 && c1 <= 0xa0){
116+
if (c1 >= 0x81 && c1 <= 0xa0) {
116117
w = (c1 - 0x81)*190 + (c - 0x41);
117118
if (w >= 0 && w < uhc1_ucs_table_size) {
118119
flag = 1;
119120
w = uhc1_ucs_table[w];
120121
} else {
121122
w = 0;
122123
}
123-
} else if ( c1 >= 0xa1 && c1 <= 0xc6){
124+
} else if (c1 >= 0xa1 && c1 <= 0xc6) {
124125
w = (c1 - 0xa1)*190 + (c - 0x41);
125126
if (w >= 0 && w < uhc2_ucs_table_size) {
126127
flag = 2;
127128
w = uhc2_ucs_table[w];
128129
} else {
129130
w = 0;
130131
}
131-
} else if ( c1 >= 0xc7 && c1 <= 0xfe){
132+
} else if (c1 >= 0xc7 && c1 <= 0xfe) {
132133
w = (c1 - 0xc7)*94 + (c - 0xa1);
133134
if (w >= 0 && w < uhc3_ucs_table_size) {
134135
flag = 3;
@@ -137,15 +138,16 @@ mbfl_filt_conv_uhc_wchar(int c, mbfl_convert_filter *filter)
137138
w = 0;
138139
}
139140
}
140-
if (flag > 0){
141+
142+
if (flag > 0) {
141143
if (w <= 0) {
142144
w = (c1 << 8) | c;
143145
w &= MBFL_WCSPLANE_MASK;
144146
w |= MBFL_WCSPLANE_UHC;
145147
}
146148
CK((*filter->output_function)(w, filter->data));
147149
} else {
148-
if ((c >= 0 && c < 0x21) || c == 0x7f) { /* CTLs */
150+
if ((c >= 0 && c < 0x21) || c == 0x7f) { /* CTLs */
149151
CK((*filter->output_function)(c, filter->data));
150152
} else {
151153
w = (c1 << 8) | c;
@@ -164,15 +166,11 @@ mbfl_filt_conv_uhc_wchar(int c, mbfl_convert_filter *filter)
164166
return c;
165167
}
166168

167-
/*
168-
* wchar => UHC
169-
*/
170169
int
171170
mbfl_filt_conv_wchar_uhc(int c, mbfl_convert_filter *filter)
172171
{
173-
int c1, s;
172+
int c1, s = 0;
174173

175-
s = 0;
176174
if (c >= ucs_a1_uhc_table_min && c < ucs_a1_uhc_table_max) {
177175
s = ucs_a1_uhc_table[c - ucs_a1_uhc_table_min];
178176
} else if (c >= ucs_a2_uhc_table_min && c < ucs_a2_uhc_table_max) {
@@ -200,7 +198,7 @@ mbfl_filt_conv_wchar_uhc(int c, mbfl_convert_filter *filter)
200198
}
201199
}
202200
if (s >= 0) {
203-
if (s < 0x80) { /* latin */
201+
if (s < 0x80) { /* latin */
204202
CK((*filter->output_function)(s, filter->data));
205203
} else {
206204
CK((*filter->output_function)((s >> 8) & 0xff, filter->data));

0 commit comments

Comments
 (0)