Skip to content

Commit 9e1447d

Browse files
committed
Rename KANA2HIRA and HIRA2KANA constants (for mb_convert_kana)
mb_convert_kana is able to convert fullwidth katakana to fullwidth hiragana (and vice versa). The constants referring to these modes had names like MBFL_FILT_TL_ZEN2HAN_KANA2HIRA. The "ZEN2HAN" part of the name is misleading, since these modes do not convert fullwidth (zenkaku) kana to halfwidth (hankaku). The converted characters are fullwidth both before and after the conversion. So... let's name the constants accordingly.
1 parent c8e65c9 commit 9e1447d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

ext/mbstring/libmbfl/filters/mbfilter_tl_jisx0201_jisx0208.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ int mbfl_convert_kana(int c, int next, bool *consumed, int *second, int mode)
165165
} else if (c == 0x30fb) {
166166
return 0xff65; /* HALFWIDTH KATAKANA MIDDLE DOT */
167167
}
168-
} else if (mode & (MBFL_FILT_TL_ZEN2HAN_HIRA2KANA | MBFL_FILT_TL_ZEN2HAN_KANA2HIRA)) {
169-
if ((mode & MBFL_FILT_TL_ZEN2HAN_HIRA2KANA) && ((c >= 0x3041 && c <= 0x3093) || c == 0x309d || c == 0x309e)) {
168+
} else if (mode & (MBFL_FILT_TL_ZENKAKU_HIRA2KANA | MBFL_FILT_TL_ZENKAKU_KANA2HIRA)) {
169+
if ((mode & MBFL_FILT_TL_ZENKAKU_HIRA2KANA) && ((c >= 0x3041 && c <= 0x3093) || c == 0x309d || c == 0x309e)) {
170170
/* Zenkaku hiragana to Zenkaku katakana */
171171
return c + 0x60;
172-
} else if ((mode & MBFL_FILT_TL_ZEN2HAN_KANA2HIRA) && ((c >= 0x30a1 && c <= 0x30f3) || c == 0x30fd || c == 0x30fe)) {
172+
} else if ((mode & MBFL_FILT_TL_ZENKAKU_KANA2HIRA) && ((c >= 0x30a1 && c <= 0x30f3) || c == 0x30fd || c == 0x30fe)) {
173173
/* Zenkaku katakana to Zenkaku hiragana */
174174
return c - 0x60;
175175
}

ext/mbstring/libmbfl/filters/mbfilter_tl_jisx0201_jisx0208.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
#define MBFL_FILT_TL_HAN2ZEN_GLUE 0x00000800
4343
#define MBFL_FILT_TL_ZEN2HAN_KATAKANA 0x00001000
4444
#define MBFL_FILT_TL_ZEN2HAN_HIRAGANA 0x00002000
45-
#define MBFL_FILT_TL_ZEN2HAN_HIRA2KANA 0x00010000
46-
#define MBFL_FILT_TL_ZEN2HAN_KANA2HIRA 0x00020000
45+
#define MBFL_FILT_TL_ZENKAKU_HIRA2KANA 0x00010000
46+
#define MBFL_FILT_TL_ZENKAKU_KANA2HIRA 0x00020000
4747
#define MBFL_FILT_TL_HAN2ZEN_COMPAT1 0x00100000
4848
#define MBFL_FILT_TL_ZEN2HAN_COMPAT1 0x00200000
4949
#define MBFL_FILT_TL_HAN2ZEN_MASK ( \
@@ -62,8 +62,8 @@
6262
MBFL_FILT_TL_ZEN2HAN_SPACE | \
6363
MBFL_FILT_TL_ZEN2HAN_KATAKANA | \
6464
MBFL_FILT_TL_ZEN2HAN_HIRAGANA | \
65-
MBFL_FILT_TL_ZEN2HAN_HIRA2KANA | \
66-
MBFL_FILT_TL_ZEN2HAN_KANA2HIRA | \
65+
MBFL_FILT_TL_ZENKAKU_HIRA2KANA | \
66+
MBFL_FILT_TL_ZENKAKU_KANA2HIRA | \
6767
MBFL_FILT_TL_ZEN2HAN_COMPAT1)
6868

6969
extern const struct mbfl_convert_vtbl vtbl_tl_jisx0201_jisx0208;

ext/mbstring/mbstring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,10 +2910,10 @@ PHP_FUNCTION(mb_convert_kana)
29102910
opt |= MBFL_FILT_TL_HAN2ZEN_GLUE;
29112911
break;
29122912
case 'C':
2913-
opt |= MBFL_FILT_TL_ZEN2HAN_HIRA2KANA;
2913+
opt |= MBFL_FILT_TL_ZENKAKU_HIRA2KANA;
29142914
break;
29152915
case 'c':
2916-
opt |= MBFL_FILT_TL_ZEN2HAN_KANA2HIRA;
2916+
opt |= MBFL_FILT_TL_ZENKAKU_KANA2HIRA;
29172917
break;
29182918
case 'M':
29192919
/* TODO: figure out what 'M' and 'm' are for, and rename the constant

0 commit comments

Comments
 (0)