Skip to content

Commit 0e294f2

Browse files
committed
- MFH: Fixed bug #48709 (metaphone and 'wh')
1 parent 51f8b64 commit 0e294f2

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

ext/standard/metaphone.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,14 @@ static int metaphone(unsigned char *word, int word_len, long max_phonemes, char
225225
w_idx += 2;
226226
}
227227
break;
228-
/* WH becomes H,
228+
/* WH becomes W,
229229
WR becomes R
230230
W if followed by a vowel */
231231
case 'W':
232-
if (Next_Letter == 'H' ||
233-
Next_Letter == 'R') {
232+
if (Next_Letter == 'R') {
234233
Phonize(Next_Letter);
235234
w_idx += 2;
236-
} else if (isvowel(Next_Letter)) {
235+
} else if (Next_Letter == 'H' || isvowel(Next_Letter)) {
237236
Phonize('W');
238237
w_idx += 2;
239238
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Bug #48709 (metaphone and 'wh')
3+
--FILE--
4+
<?php
5+
6+
/* Initial letter exceptions */
7+
$exceptions = array(
8+
'kn', // Drop first letter
9+
'gn', // ditto
10+
'pn', // ditto
11+
'ae', // ditto
12+
'wr', // ditto
13+
'x', // s
14+
'wh', // w
15+
'wa' // w
16+
);
17+
18+
foreach ($exceptions as $letter) {
19+
printf("%s => %s\n", $letter, metaphone($letter));
20+
}
21+
22+
?>
23+
--EXPECT--
24+
kn => N
25+
gn => N
26+
pn => N
27+
ae => E
28+
wr => R
29+
x => S
30+
wh => W
31+
wa => W

0 commit comments

Comments
 (0)