I recently worked on allowing 'select tag(s)', but not finished yet

This commit is contained in:
Anselm R. Garbe 2006-03-13 19:49:06 +01:00
parent ae9064ab09
commit 3eea13a29b
2 changed files with 16 additions and 8 deletions

View File

@ -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;
}

View File

@ -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 */
}