soundex-patch

text/plain

Filename: soundex-patch
Type: text/plain
Part: 0
Message: Re: /contrib/soundex doesn't work. Version 7.0.2
*** soundex.c.orig	Fri Sep 29 16:25:59 2000
--- soundex.c	Fri Sep 29 16:29:48 2000
***************
*** 21,27 ****
  	int			count = 0;
  	text	   *new_t;
  
! 	char		outstr[6 + 1];	/* max length of soundex is 6 */
  	char	   *instr;
  
  	/* make a null-terminated string */
--- 21,27 ----
  	int			count = 0;
  	text	   *new_t;
  
! 	char		outstr[4 + 1];	/* max length of soundex is 4 */
  	char	   *instr;
  
  	/* make a null-terminated string */
***************
*** 70,76 ****
  
  	*outstr++ = (char) toupper(*instr++);
  
! 	while (*instr && count < 5)
  	{
  		if (isalpha(*instr) && *instr != *(instr - 1))
  		{
--- 70,76 ----
  
  	*outstr++ = (char) toupper(*instr++);
  
! 	while (*instr && count < 3)
  	{
  		if (isalpha(*instr) && *instr != *(instr - 1))
  		{
***************
*** 82,87 ****
--- 82,94 ----
  			}
  		}
  		++instr;
+ 	}
+ 
+ 	while (count < 3)
+ 	{
+ 		*outstr = '0';
+ 		++outstr;
+ 		++count;
  	}
  
  	*outstr = '\0';