|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 2380 (0x94c) Types: TextFile Names: »soundex.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« └─⟦de7628f85⟧ └─⟦this⟧ »isode-6.0/dsap/common/soundex.c«
/* soundex.c - compare a filter and attribute value */ #ifndef lint static char *rcsid = "$Header: /f/osi/dsap/common/RCS/soundex.c,v 7.0 89/11/23 21:47:46 mrose Rel $"; #endif /* * $Header: /f/osi/dsap/common/RCS/soundex.c,v 7.0 89/11/23 21:47:46 mrose Rel $ * * * $Log: soundex.c,v $ * Revision 7.0 89/11/23 21:47:46 mrose * Release 6.0 * */ /* * NOTICE * * Acquisition, use, and distribution of this module and related * materials are subject to the restrictions of a license agreement. * Consult the Preface in the User's Manual for the full terms of * this agreement. * */ #include <ctype.h> #include "quipu/util.h" #include "quipu/attrvalue.h" #include "quipu/ds_search.h" static char * next_word (ptr) register char *ptr; { while ( (*ptr != '.') && (*ptr != ' ') && (*ptr != '-') && (*ptr != 0) ) ptr++; if (*ptr) return (++ptr); return (NULLCP); } static char next_char (a,last) register char ** a; char last; { extern char chrcnv[]; register char lc, c; if (**a == 0) return (0); for (;*++*a;) { if ( (**a == '.') || (**a ==' ') || (**a == '-') ) return (0); lc = chrcnv[**a]; if (isupper (lc)) { /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */ c = "abcdabcaacclmmabcrcdabacac" [lc-'A']; if ((c != 'a') && (c != last)) return (c); } else if (isdigit (lc)) return (lc); } return (0); } static match_word (a,b) char *a; char *b; { register char lasta, lastb; if ( (lasta = chrcnv[*a]) != (lastb = chrcnv[*b]) ) return FALSE; for (;;) { lasta = next_char (&a,lasta); lastb = next_char (&b,lastb); if (lastb == 0) return TRUE; if (lasta != lastb) return FALSE; } /* NOTREACHED */ } soundex_cmp (a,b) register char *a; register char *b; { char result = FALSE; register char * ptr; for( ; a && b ; b = next_word (b) ) { for (ptr=a; ptr; ptr=next_word(ptr) ) { if (match_word (ptr,b)) { a = next_word (ptr); result = TRUE; break; } } if (ptr == NULLCP) return FALSE; } if ((a == NULL) && (b != NULL)) return FALSE; return (result); } soundex_match (fitem,avs) register struct filter_item *fitem; register AV_Sequence avs; { for (; avs != NULLAV; avs=avs->avseq_next) if (soundex_cmp ((char *)avs->avseq_av.av_struct, (char *)fitem->UNAVA.ava_value->av_struct)) return (OK); return (NOTOK); }