From 3eea13a29bbb5c7f2ee6da6453320666cf97fe69 Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Mon, 13 Mar 2006 19:49:06 +0100 Subject: [PATCH] I recently worked on allowing 'select tag(s)', but not finished yet --- cmd/wm/tag.c | 22 +++++++++++++++------- libcext/tokenize.c | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c index 16798982..954d1acf 100644 --- a/cmd/wm/tag.c +++ b/cmd/wm/tag.c @@ -148,27 +148,35 @@ istag(char **tags, char *tag, unsigned int ntags) Tag * get_tag(char *name) { - unsigned int i, n = 0; + unsigned int i, n = 0, j, nt; Tag *t; + char buf[256]; + char *tags[128]; - if(!istag(ctag, name, nctag)) - return nil; for(i = 0; i < ntag; i++) { t = tag[i]; if(!strncmp(t->name, name, strlen(t->name))) return t; } + cext_strlcpy(buf, name, sizeof(buf)); + nt = cext_tokenize(tags, 128, buf, ' '); + for(i = 0; i < nclient; i++) - if(strstr(client[i]->tags, name)) - n++; + for(j = 0; j < nt; j++) + if(strstr(client[i]->tags, tags[j])) + n++; + + fprintf(stderr, "get_tag %d\n", n); if(!n) return nil; t = alloc_tag(name); for(i = 0; i < nclient; i++) - if(strstr(client[i]->tags, name)) - attach_totag(t, client[i]); + for(j = 0; j < nt; j++) + if(strstr(client[i]->tags, tags[j])) + if(!clientoftag(t, client[i])) + attach_totag(t, client[i]); return t; } diff --git a/libcext/tokenize.c b/libcext/tokenize.c index 412e0aaf..d4c35fa7 100644 --- a/libcext/tokenize.c +++ b/libcext/tokenize.c @@ -28,7 +28,7 @@ cext_tokenize(char **result, unsigned int reslen, char *str, char delim) } else n++; } - if(strlen(p)) + if((i < reslen) && (p < n) && strlen(p)) result[i++] = p; return i; /* number of tokens */ }