]> granicus.if.org Git - php/commitdiff
- Fixed bug #48709 (metaphone and 'wh')
authorFelipe Pena <felipe@php.net>
Sun, 28 Jun 2009 18:41:20 +0000 (18:41 +0000)
committerFelipe Pena <felipe@php.net>
Sun, 28 Jun 2009 18:41:20 +0000 (18:41 +0000)
ext/standard/metaphone.c
ext/standard/tests/strings/bug48709.phpt [new file with mode: 0644]

index 2d1c7bf083ce68c3b8978d925ca9e8882aca9abc..675879de0872c4d02ee788bd1632bf3f1efc4e1f 100644 (file)
@@ -224,15 +224,14 @@ static int metaphone(unsigned char *word, int word_len, long max_phonemes, char
                        w_idx += 2;
                }
                break;
-               /* WH becomes H
+               /* WH becomes W
                   WR becomes R 
                   W if followed by a vowel */
        case 'W':
-               if (Next_Letter == 'H' ||
-                       Next_Letter == 'R') {
+               if (Next_Letter == 'R') {
                        Phonize(Next_Letter);
                        w_idx += 2;
-               } else if (isvowel(Next_Letter)) {
+               } else if (Next_Letter == 'H' || isvowel(Next_Letter)) {
                        Phonize('W');
                        w_idx += 2;
                }
diff --git a/ext/standard/tests/strings/bug48709.phpt b/ext/standard/tests/strings/bug48709.phpt
new file mode 100644 (file)
index 0000000..999a2c6
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+Bug #48709 (metaphone and 'wh')
+--FILE--
+<?php
+
+/* Initial letter exceptions */
+$exceptions = array(
+       'kn', // Drop first letter
+       'gn', // ditto
+       'pn', // ditto
+       'ae', // ditto
+       'wr', // ditto
+       'x',  // s
+       'wh', // w
+       'wa'  // w
+);     
+       
+foreach ($exceptions as $letter) {
+       printf("%s => %s\n", $letter, metaphone($letter));
+}
+
+?>
+--EXPECT--
+kn => N
+gn => N
+pn => N
+ae => E
+wr => R
+x => S
+wh => W
+wa => W