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

diff --git a/NEWS b/NEWS
index a9782685f9cd623eb176d5b3d577f4fe9fa8a0a2..3601d51a07fef89a5c10ea45b1d91c50a0d7168a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ PHP                                                                        NEWS
 - Fixed regression in cURL extension that prevented flush of data to output
   defined as a file handle. (Ilia)
 
+- Fixed bug #48709 (metaphone and 'wh'). (brettz9 at yahoo dot com, Felipe)
 - Fixed bug #48693 (Double declaration of __lambda_func when lambda wrongly
   formatted). (peter at lvp-media dot com, Felipe)
 - Fixed bug #48661 (phpize is broken with non-bash shells). (Jani)
index d3b1960b55484eb2d109b1c43e39f54bf500a979..235b4a996dff39a4b61404e9581f01447ae2b895 100644 (file)
@@ -225,15 +225,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