Xinqi Bao's Git
projects
/
dmenu.git
/ commitdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (parent:
1c488e6
)
implemented strcasestr for dmenu (I call it cistrstr) for portability issues (cygwin...
author
Anselm R. Garbe <
[email protected]
>
Mon, 1 Oct 2007 13:28:42 +0000
(15:28 +0200)
committer
Anselm R. Garbe <
[email protected]
>
Mon, 1 Oct 2007 13:28:42 +0000
(15:28 +0200)
dmenu.c
patch
|
blob
|
history
diff --git
a/dmenu.c
b/dmenu.c
index
b28a548
..
3256f9c
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-58,6
+58,7
@@
void readstdin(void);
void run(void);
void setup(Bool bottom);
int strcaseido(const char *text, const char *pattern);
void run(void);
void setup(Bool bottom);
int strcaseido(const char *text, const char *pattern);
+char *cistrstr(const char *s, const char *sub);
unsigned int textnw(const char *text, unsigned int len);
unsigned int textw(const char *text);
unsigned int textnw(const char *text, unsigned int len);
unsigned int textw(const char *text);
@@
-511,7
+512,7
@@
match(char *pattern) {
if(!i->matched && !strncasecmp(pattern, i->text, plen))
j = appenditem(i, j);
for(i = allitems; i; i = i->next)
if(!i->matched && !strncasecmp(pattern, i->text, plen))
j = appenditem(i, j);
for(i = allitems; i; i = i->next)
- if(!i->matched &&
strcase
str(i->text, pattern))
+ if(!i->matched &&
cistr
str(i->text, pattern))
j = appenditem(i, j);
if(idomatch)
for(i = allitems; i; i = i->next)
j = appenditem(i, j);
if(idomatch)
for(i = allitems; i; i = i->next)
@@
-629,6
+630,29
@@
strcaseido(const char *text, const char *pattern) {
return !*pattern;
}
return !*pattern;
}
+char *
+cistrstr(const char *s, const char *sub) {
+ int c, csub;
+ unsigned int len;
+
+ if(!sub)
+ return (char *)s;
+ if((c = *sub++) != 0) {
+ c = tolower(c);
+ len = strlen(sub);
+ do {
+ do {
+ if((csub = *s++) == 0)
+ return (NULL);
+ }
+ while(tolower(csub) != c);
+ }
+ while(strncasecmp(s, sub, len) != 0);
+ s--;
+ }
+ return (char *)s;
+}
+
unsigned int
textnw(const char *text, unsigned int len) {
XRectangle r;
unsigned int
textnw(const char *text, unsigned int len) {
XRectangle r;