revert using strcasestr and use a more optimized portable version 3e39c526
... compared to the old cistrstr().

Thanks for the feedback!
Hiltjo Posthuma · 2022-02-08 19:32 2 file(s) · +21 −2
config.mk +1 −1
23 23
LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS)
24 24
25 25
# flags
26 -
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
26 +
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
27 27
CFLAGS   = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS)
28 28
LDFLAGS  = $(LIBS)
29 29
dmenu.c +20 −1
102 102
	XCloseDisplay(dpy);
103 103
}
104 104
105 +
static char *
106 +
cistrstr(const char *h, const char *n)
107 +
108 +
{
109 +
	size_t i;
110 +
111 +
	if (!n[0])
112 +
		return (char *)h;
113 +
114 +
	for (; *h; ++h) {
115 +
		for (i = 0; n[i] && tolower((unsigned char)n[i]) ==
116 +
		            tolower((unsigned char)h[i]); ++i)
117 +
			;
118 +
		if (n[i] == '\0')
119 +
			return (char *)h;
120 +
	}
121 +
	return NULL;
122 +
}
123 +
105 124
static int
106 125
drawitem(struct item *item, int x, int y, int w)
107 126
{
711 730
			fast = 1;
712 731
		else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
713 732
			fstrncmp = strncasecmp;
714 -
			fstrstr = strcasestr;
733 +
			fstrstr = cistrstr;
715 734
		} else if (i + 1 == argc)
716 735
			usage();
717 736
		/* these options take one argument */