diff options
author | Guido van Rossum <guido@python.org> | 1996-05-23 22:54:17 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-05-23 22:54:17 (GMT) |
commit | 5038412d0fb65376ea759bb3b1276f8d439e996f (patch) | |
tree | 93b9ea4ed4606a4816e8ef2041f9ec5d9c65f5b1 /Modules/soundex.c | |
parent | bceeac8dc1627c307e64c2ace9dcd1e486636ad8 (diff) | |
download | cpython-5038412d0fb65376ea759bb3b1276f8d439e996f.zip cpython-5038412d0fb65376ea759bb3b1276f8d439e996f.tar.gz cpython-5038412d0fb65376ea759bb3b1276f8d439e996f.tar.bz2 |
Added __doc__ strings. Added get_soundex().
Diffstat (limited to 'Modules/soundex.c')
-rw-r--r-- | Modules/soundex.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/Modules/soundex.c b/Modules/soundex.c index adbf176..cfa9339 100644 --- a/Modules/soundex.c +++ b/Modules/soundex.c @@ -8,12 +8,19 @@ for non-literal string matching. From: David Wayne Williams <dwwillia@iucf.indiana.edu> + + Apr 29 1996 - added get_soundex method that returns the soundex of a + string (chrish@qnx.com) + May 2 1996 - added doc strings (chrish@qnx.com) */ #include <string.h> #include <ctype.h> #include "Python.h" +static char soundex_module__doc__[] = +"Perform Soundex comparisons on strings, allowing non-literal matching."; + void soundex_hash(char *str, char *result) { char *sptr = str; /* pointer into str */ @@ -104,6 +111,27 @@ void soundex_hash(char *str, char *result) } +/* Return the actual soundex value. */ +/* Added by Chris Herborth (chrish@qnx.com) */ +static char soundex_get_soundex__doc__[] = + "Return the (English) Soundex hash value for a string."; +static PyObject * +get_soundex(PyObject *self, PyObject *args) +{ + char *str; + int retval; + char sdx[7]; + + if(!PyArg_ParseTuple( args, "s", &str)) + return NULL; + + soundex_hash(str, sdx); + + return PyString_FromString(sdx); +} + +static char soundex_sound_similar__doc__[] = + "Compare two strings to see if they sound similar (English)."; static PyObject * sound_similar(PyObject *self, PyObject *args) { @@ -127,7 +155,9 @@ sound_similar(PyObject *self, PyObject *args) */ static PyMethodDef SoundexMethods[] = { - {"sound_similar", sound_similar, 1}, + {"sound_similar", sound_similar, 1, soundex_sound_similar__doc__}, + {"get_soundex", get_soundex, 1, soundex_get_soundex__doc__}, + {NULL, NULL } /* sentinel */ }; @@ -137,5 +167,9 @@ static PyMethodDef SoundexMethods[] = void initsoundex() { - (void) Py_InitModule("soundex",SoundexMethods); + (void) Py_InitModule4("soundex", + SoundexMethods, + soundex_module__doc__, + (PyObject *)NULL, + PYTHON_API_VERSION); } |