From: Adam Dickmeiss Date: Thu, 8 Oct 2009 10:47:48 +0000 (+0200) Subject: Substring for all setting types. X-Git-Tag: v1.2.2~19 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=0d30555c2b982e4e7cb9c4a6741bae7d32e3e801;p=pazpar2-moved-to-github.git Substring for all setting types. Change match_criterion so that substring (~) match uses strstr always. The equal/string (=) uses match_zurl magic and strcmp as before. This also ensure that v ptr is always set at end of routine to prevent undefined behavior. --- diff --git a/src/database.c b/src/database.c index d51cd4f..0a87d0c 100644 --- a/src/database.c +++ b/src/database.c @@ -239,8 +239,9 @@ static int match_criterion(struct setting **settings, } if (!settings[offset]) return 0; - if (c->type == PAZPAR2_STRING_MATCH) - for (v = c->values; v; v = v->next) + for (v = c->values; v; v = v->next) + { + if (c->type == PAZPAR2_STRING_MATCH) { if (offset == PZ_ID) { @@ -252,21 +253,13 @@ static int match_criterion(struct setting **settings, if (!strcmp(settings[offset]->value, v->value)) break; } - } - else if (c->type == PAZPAR2_SUBSTRING_MATCH) - for (v = c->values; v; v = v->next) + } + else if (c->type == PAZPAR2_SUBSTRING_MATCH) { - if (offset == PZ_ID) - { - if (match_zurl(settings[offset]->value, v->value)) - break; - } - else - { - if (strstr(settings[offset]->value, v->value)) - break; - } + if (strstr(settings[offset]->value, v->value)) + break; } + } if (v) return 1; else