Re: [hackers] [dmenu] improve performance of case-insensitive matching || Hiltjo Posthuma

From: NRK <nrk_AT_disroot.org>
Date: Mon, 7 Feb 2022 13:59:39 +0600

On Mon, Feb 07, 2022 at 12:22:44AM +0100, git_AT_suckless.org wrote:
> commit eb96af27f4059c93d7e000e910b71d74829a239b
> Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
> AuthorDate: Mon Feb 7 00:21:12 2022 +0100
> Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
> CommitDate: Mon Feb 7 00:21:12 2022 +0100
>
> improve performance of case-insensitive matching
>
> diff --git a/dmenu.c b/dmenu.c
> index 98507d9..d06bea1 100644
> --- a/dmenu.c
> +++ b/dmenu.c
> _AT_@ -102,17 +102,6 @@ cleanup(void)
> XCloseDisplay(dpy);
> }
>
> -static char *
> -cistrstr(const char *s, const char *sub)
> -{
> - size_t len;
> -
> - for (len = strlen(sub); *s; s++)
> - if (!strncasecmp(s, sub, len))
> - return (char *)s;
> - return NULL;
> -}
> -
> static int
> drawitem(struct item *item, int x, int y, int w)
> {
> _AT_@ -722,7 +711,7 @@ main(int argc, char *argv[])
> fast = 1;
> else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
> fstrncmp = strncasecmp;
> - fstrstr = cistrstr;
> + fstrstr = strcasestr;
> } else if (i + 1 == argc)
> usage();
> /* these options take one argument */
>

Hi,

This fails to compile on my machine with the following error:

        dmenu.c:714:35: error: 'strcasestr' undeclared (first use in this function); did you mean 'strcasecmp'?
          714 | fstrstr = strcasestr;

`_GNU_SOURCE` needs to be defined for this to work, since strcasestr() is
non-standard extension.

- NRK
Received on Mon Feb 07 2022 - 08:59:39 CET

This archive was generated by hypermail 2.3.0 : Mon Feb 07 2022 - 09:00:37 CET