/* module to generate soundex encoding; used by build and qi_query */
/* Bruce Tanner - Cerritos College */
/* return a <size> character encoding in <dest> */
/* <dest> must be <size> + 1 characters long */
/* the old version had problems with names starting with "ph" and "pf"
since p and f have the same numeric value, a numeric-only output
seems to take care of this.
*/
#define alnum 0 /* 0 = hash to number only */
/* 1 = keep the first alpha character of name */
dp = dest; /* point to dest */
#if alnum
*dp++ = *src++; /* retain the first letter */
size--; /* count characters moved */
#endif
while (*src && size) {
if (strchr(vowels, *src) == (char *) 0) { /* don't do vowels */
cp = strchr(values, *src); /* find letter */
if (cp && /* if there was a character found */
size && /* and we haven't found <size> chars */
((dp == dest) || /* first character or */
((dp > dest) && (*(dp - 1) != *(cp + 1))) /* not dup value */
)) {
*dp++ = *(cp + 1); /* get value */
size--;
}
}
src++;
}
while (size--)
*dp++ = '0'; /* pad dest with 0 */
*dp = '\0';