Return to repo list

suckless-gf-dmenu

Gentoo-friendly patches for Suckless's dmenu.
Return to HMagellan.com

caseinsensitive.patch (1395B)


      1 From 54acbdf72083a5eae5783eed42e162424ab2cec2 Mon Sep 17 00:00:00 2001
      2 From: Kim Torgersen <kim@torgersen.se>
      3 Date: Sat, 23 May 2020 14:48:28 +0200
      4 Subject: [PATCH] case-insensitive item matching default, case-sensitive option
      5  (-s)
      6 
      7 ---
      8  dmenu.c | 11 ++++++-----
      9  1 file changed, 6 insertions(+), 5 deletions(-)
     10 
     11 diff --git a/dmenu.c b/dmenu.c
     12 index 65f25ce..855df59 100644
     13 --- a/dmenu.c
     14 +++ b/dmenu.c
     15 @@ -55,8 +55,9 @@ static Clr *scheme[SchemeLast];
     16  
     17  #include "config.h"
     18  
     19 -static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
     20 -static char *(*fstrstr)(const char *, const char *) = strstr;
     21 +static char * cistrstr(const char *s, const char *sub);
     22 +static int (*fstrncmp)(const char *, const char *, size_t) = strncasecmp;
     23 +static char *(*fstrstr)(const char *, const char *) = cistrstr;
     24  
     25  static void
     26  appenditem(struct item *item, struct item **list, struct item **last)
     27 @@ -709,9 +710,9 @@ main(int argc, char *argv[])
     28  			topbar = 0;
     29  		else if (!strcmp(argv[i], "-f"))   /* grabs keyboard before reading stdin */
     30  			fast = 1;
     31 -		else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
     32 -			fstrncmp = strncasecmp;
     33 -			fstrstr = cistrstr;
     34 +		else if (!strcmp(argv[i], "-s")) { /* case-sensitive item matching */
     35 +			fstrncmp = strncmp;
     36 +			fstrstr = strstr;
     37  		} else if (i + 1 == argc)
     38  			usage();
     39  		/* these options take one argument */
     40 -- 
     41 2.26.2
     42