diff options
author | Guido van Rossum <guido@python.org> | 1996-12-05 23:41:26 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-12-05 23:41:26 (GMT) |
commit | 60fca2c90fe4d00715f4ae28d68560e67955ab9b (patch) | |
tree | 28770b4748ff1c1bb0dbe20532021ec25149c13d /Modules/soundex.c | |
parent | 049cd90b93e4d25e0fac18d4cfbba6cc0b0e19d9 (diff) | |
download | cpython-60fca2c90fe4d00715f4ae28d68560e67955ab9b.zip cpython-60fca2c90fe4d00715f4ae28d68560e67955ab9b.tar.gz cpython-60fca2c90fe4d00715f4ae28d68560e67955ab9b.tar.bz2 |
Add case for 'R' and a little bit of cleanup. Andrew Kuchling.
Diffstat (limited to 'Modules/soundex.c')
-rw-r--r-- | Modules/soundex.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Modules/soundex.c b/Modules/soundex.c index c1cbf70..fe00ac6 100644 --- a/Modules/soundex.c +++ b/Modules/soundex.c @@ -26,7 +26,7 @@ static void soundex_hash(char *str, char *result) char *sptr = str; /* pointer into str */ char *rptr = result; /* pointer into result */ - if(*str == NULL) + if(*str == '\0') { strcpy(result,"000000"); return; @@ -39,19 +39,20 @@ static void soundex_hash(char *str, char *result) /* Translate the rest of the input string into result. The following transformations are used: - 1) All vowles, W, and H, are skipped. + 1) All vowels, W, and H, are skipped. 2) BFPV = 1 CGJKQSXZ = 2 DT = 3 L = 4 MN = 5 + R = 6 3) Only translate the first of adjacent equal translations. I.E. remove duplicate digits. */ - for(;(rptr - result) < 6 && *sptr != NULL;sptr++) + for(;(rptr - result) < 6 && *sptr != '\0';sptr++) { switch (toupper(*sptr)) { @@ -95,6 +96,9 @@ static void soundex_hash(char *str, char *result) if(*(rptr - 1) != '5') *(rptr++) = '5'; break; + case 'R': + if(*(rptr -1) != '6') + *(rptr++) = '6'; default: break; } @@ -107,7 +111,7 @@ static void soundex_hash(char *str, char *result) /* Terminate the result string. */ - *(result + 6) = NULL; + *(result + 6) = '\0'; } @@ -119,7 +123,6 @@ static PyObject * get_soundex(PyObject *self, PyObject *args) { char *str; - int retval; char sdx[7]; if(!PyArg_ParseTuple( args, "s", &str)) @@ -136,7 +139,6 @@ static PyObject * sound_similar(PyObject *self, PyObject *args) { char *str1, *str2; - int return_value; char res1[7], res2[7]; if(!PyArg_ParseTuple(args, "ss", &str1, &str2)) |