tags and view names '.', '..' and '/' are now caught in wmiiwm

This commit is contained in:
Denis Grelich 2007-01-04 02:22:07 +01:00
parent 3e60262324
commit 3346948826
3 changed files with 10 additions and 6 deletions

View File

@ -699,6 +699,7 @@ apply_tags(Client *c, const char *tags) {
char *toks[32];
strncpy(buf, tags, sizeof(buf));
trim(buf, " \t/");
if(!(n = ixp_tokenize(toks, 31, buf, '+')))
return;
for(i=0, j=0; i < n; i++) {
@ -706,13 +707,15 @@ apply_tags(Client *c, const char *tags) {
c->floating = True;
else if(!strncmp(toks[i], "!", 2))
toks[j++] = view ? screen->sel->name : "NULL";
else if(strncmp(toks[i], "sel", 4))
else if(strncmp(toks[i], "sel", 4)
&& strncmp(toks[i], ".", 2)
&& strncmp(toks[i], "..", 3))
toks[j++] = toks[i];
}
c->tags[0] = '\0';
qsort(toks, j, sizeof(char *), compare_tags);
len = sizeof(c->tags);
if(!j) toks[j++] = "NULL";
if(!j) return;
for(i=0, n=0; i < j && len > 1; i++)
if(!n || strcmp(toks[i], toks[n-1])) {
if(i)

View File

@ -20,8 +20,7 @@ conf_which () {
tagsmenu() {
tag=`wmiir read /tag/sel/ctl`
tags=`wmiir ls /tag | sed 's|/||; /^sel$/d' | awk "BEGIN{print \"$tag\"} !/^$tag\$/" | $DMENU \
| sed 's/^\.\.\?$//; s/^\.\.\?+//g; s/+\.\.\?$//g; s/+\.\.\?+/+/g; s/\W//'`
tags=`wmiir ls /tag | sed 's|/||; /^sel$/d' | awk "BEGIN{print \"$tag\"} !/^$tag\$/" | $DMENU`
test -n "$tags" && xwrite $@ "$tags"
}

6
view.c
View File

@ -135,10 +135,12 @@ select_view(const char *arg) {
char buf[256];
strncpy(buf, arg, sizeof(buf));
trim(buf, " \t+");
trim(buf, " \t+/");
if(!strlen(buf))
return;
assign_sel_view(get_view(arg));
if(!strncmp(buf, ".", 2) || !strncmp(buf, "..", 3))
return;
assign_sel_view(get_view(buf));
update_views(); /* performs focus_view */
}