dwm-meillo
diff tag.c @ 178:e848966a1ac6
removed TLast tag enum, now tags is simple defined as char *[] array, the rest is calculated correctly, rules take an int array for the tags
author | arg@10ksloc.org |
---|---|
date | Thu, 03 Aug 2006 12:12:26 +0200 |
parents | e890cee887d1 |
children | 56fee1dc9d53 |
line diff
1.1 --- a/tag.c Thu Aug 03 11:38:26 2006 +0200 1.2 +++ b/tag.c Thu Aug 03 12:12:26 2006 +0200 1.3 @@ -13,7 +13,7 @@ 1.4 1.5 typedef struct { 1.6 const char *pattern; 1.7 - Bool tags[TLast]; 1.8 + const unsigned int *tags; 1.9 Bool isfloat; 1.10 } Rule; 1.11 1.12 @@ -145,7 +145,7 @@ 1.13 if(!sel) 1.14 return; 1.15 1.16 - for(i = 0; i < TLast; i++) 1.17 + for(i = 0; i < ntags; i++) 1.18 sel->tags[i] = False; 1.19 appendtag(arg); 1.20 } 1.21 @@ -155,7 +155,7 @@ 1.22 { 1.23 char classinst[256]; 1.24 static unsigned int len = sizeof(rule) / sizeof(rule[0]); 1.25 - unsigned int i, j; 1.26 + unsigned int i, j, n; 1.27 regex_t regex; 1.28 regmatch_t tmp; 1.29 Bool matched = False; 1.30 @@ -168,10 +168,11 @@ 1.31 for(i = 0; !matched && i < len; i++) { 1.32 if(!regcomp(®ex, rule[i].pattern, 0)) { 1.33 if(!regexec(®ex, classinst, 1, &tmp, 0)) { 1.34 - for(j = 0; j < TLast; j++) { 1.35 - if((c->tags[j] = rule[i].tags[j])) 1.36 - matched = True; 1.37 - } 1.38 + n = rule[i].tags ? 1.39 + sizeof(rule[i].tags) / sizeof(rule[i].tags[0]) : 0; 1.40 + matched = n != 0; 1.41 + for(j = 0; j < n; j++) 1.42 + c->tags[rule[i].tags[j]] = True; 1.43 c->isfloat = rule[i].isfloat; 1.44 } 1.45 regfree(®ex); 1.46 @@ -204,13 +205,13 @@ 1.47 void 1.48 viewnext(Arg *arg) 1.49 { 1.50 - arg->i = (tsel < TLast-1) ? tsel+1 : 0; 1.51 + arg->i = (tsel < ntags-1) ? tsel+1 : 0; 1.52 view(arg); 1.53 } 1.54 1.55 void 1.56 viewprev(Arg *arg) 1.57 { 1.58 - arg->i = (tsel > 0) ? tsel-1 : TLast-1; 1.59 + arg->i = (tsel > 0) ? tsel-1 : ntags-1; 1.60 view(arg); 1.61 }