コード例 #1
0
ファイル: mf_soundex.c プロジェクト: 16898500/SkyFireEMU
void soundex(CHARSET_INFO * cs,register char * out_pntr, char * in_pntr,
         pbool remove_garbage)
{
  char ch,last_ch;
  reg3 char * end;
  register uchar *map=cs->to_upper;

  if (remove_garbage)
  {
    while (*in_pntr && !my_isalpha(cs,*in_pntr)) /* Skip pre-space */
      in_pntr++;
  }
  *out_pntr++ = map[(uchar)*in_pntr];	/* Copy first letter		 */
  last_ch = get_scode(cs,&in_pntr,0);	/* code of the first letter	 */
                    /* for the first 'double-letter  */
                    /* check.			 */
  end=out_pntr+3;			/* Loop on input letters until	 */
                    /* end of input (null) or output */
                    /* letter code count = 3	 */

  in_pntr++;
  while (out_pntr < end && (ch = get_scode(cs,&in_pntr,remove_garbage)) != 0)
  {
    in_pntr++;
    if ((ch != '0') && (ch != last_ch)) /* if not skipped or double */
    {
      *out_pntr++ = ch;			/* letter, copy to output */
    }					/* for next double-letter check */
    last_ch = ch;			/* save code of last input letter */
  }
  while (out_pntr < end)
    *out_pntr++ = '0';
  *out_pntr=0;				/* end string */
  return;
} /* soundex */
コード例 #2
0
ファイル: mf_soundex.c プロジェクト: NickeyWoo/mysql-3.23.49
void soundex(register my_string out_pntr, my_string in_pntr,
	     pbool remove_garbage)
{
  char ch,last_ch;
  reg3 my_string end;

  if (remove_garbage)
  {
    while (*in_pntr && isspace(*in_pntr))	/* Skipp pre-space */
      in_pntr++;
  }
  *out_pntr++ = toupper(*in_pntr);	/* Copy first letter		 */
  last_ch = get_scode(&in_pntr,0);	/* code of the first letter	 */
					/* for the first 'double-letter  */
					/* check.			 */
  end=out_pntr+3;			/* Loop on input letters until	 */
					/* end of input (null) or output */
					/* letter code count = 3	 */

  in_pntr++;
  while (out_pntr < end && (ch = get_scode(&in_pntr,remove_garbage)) != 0)
  {
    in_pntr++;
    if ((ch != '0') && (ch != last_ch)) /* if not skipped or double */
    {
      *out_pntr++ = ch;			/* letter, copy to output */
    }					/* for next double-letter check */
    last_ch = ch;			/* save code of last input letter */
  }
  while (out_pntr < end)
    *out_pntr++ = '0';
  *out_pntr=0;				/* end string */
  return;
} /* soundex */
コード例 #3
0
ファイル: SOUNDLL.C プロジェクト: hervethouzard/divers_c
int FAR PASCAL Soundex(char *in_pntr,LPSTR out_pntr)
{
 char ch,last_ch;
 int count = 0;
 AnsiUpper(in_pntr);
 lstrcpy(out_pntr,"0000");    
 out_pntr[0]=toupper(*in_pntr);
 last_ch = get_scode(*in_pntr);
 while((ch = get_scode(*(++in_pntr)) ) && (count < 3) )
 {
  if( (ch != '0') && (ch != last_ch) ) 
  *(out_pntr+(++count)) = ch;     
  last_ch = ch;                  
 }
 return(0);
}