Commit d8f118f9 by Nils Goroll

fix and streamline test token generation for keys with negative matches

parent f0b62e19
......@@ -206,16 +206,8 @@ test (const char *fixup_remove_name, const char *fixup_reorder_name) {
char n1[KEYLIM], n2[KEYLIM];
char *save;
if (poskey[0] == '!') {
poskey = strchr(poskey + 1, '*');
assert(poskey);
poskey++;
assert(*poskey);
negkey++;
}
if (strstr(poskey, "*!")) {
if (poskey[0] == '!' ||
strstr(poskey, "*!")) {
const char *pp, *np;
assert(strlen(poskey) < KEYLIM);
......@@ -224,26 +216,46 @@ test (const char *fixup_remove_name, const char *fixup_reorder_name) {
strcpy(p1, poskey);
strcpy(n1, negkey);
pp = strtok_r(p1, "*", &save);
/* extract only positive tokens */
*p2 = '\0';
poskey = p2;
while (pp) {
if (*pp != '!') {
if ((pp = strtok_r(p1, "*", &save))) {
while (pp && *pp == '!')
pp = strtok_r(NULL, "*", &save);
if (pp)
strcat(p2, pp);
while ((pp =
strtok_r(NULL, "*", &save))) {
if (*pp == '!')
continue;
strcat(p2, "*");
strcat(p2, pp);
}
pp = strtok_r(NULL, "*", &save);
}
np = strtok_r(n1, "*", &save);
/* extract negative tokens also */
*n2 = '\0';
negkey = n2;
while (np) {
if ((np = strtok_r(n1, "*", &save))) {
if (*np == '!')
np++;
strcat(n2, np);
np = strtok_r(NULL, "*", &save);
while ((np =
strtok_r(NULL, "*", &save))) {
if (*np == '!')
np++;
strcat(n2, "*");
strcat(n2, np);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment