Ingo Schwarze wrote:
> So, here is some cleanup:
>  * garbage collect useless hand-rolled lookup tables
>  * merge one-line helper functions into callers
>  * garbage collect obfuscating macros
>  * fix one format string error (%d used for u_int)
>  * garbage collect setlocale(3) and <locale.h>
>  * garbage collect several unused constants
>  * minus 45 LOC, no functional change
> 
> OK?
>   Ingo

I think you may be fixing a bug here...

> Index: locate/fastfind.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/locate/locate/fastfind.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 fastfind.c
> --- locate/fastfind.c 8 Dec 2017 17:26:42 -0000       1.14
> +++ locate/fastfind.c 13 Jan 2019 02:07:47 -0000
> @@ -126,10 +126,8 @@ fastfind_mmap
>       u_char bigram1[NBG], bigram2[NBG], path[PATH_MAX];
>  
>  #ifdef FF_ICASE
> -     /* use a lookup table for case insensitive search */
> -     u_char table[UCHAR_MAX + 1];
> -
> -     tolower_word(pathpart);
> +     for (p = pathpart; *p != '\0'; p++)
> +             *p = tolower(*p);
>  #endif /* FF_ICASE*/
>  
>       /* init bigram table */
> @@ -156,11 +154,8 @@ fastfind_mmap
>       p = pathpart;
>       patend = patprep(p);
>       cc = *patend;
> -
>  #ifdef FF_ICASE
> -     /* set patend char to true */
> -     table[TOLOWER(*patend)] = 1;
> -     table[toupper(*patend)] = 1;
> +     cc = tolower(cc);
>  #endif /* FF_ICASE */

I cannot see where that table is zeroed. It lives on the stack, it could
contain anything.

Reply via email to