From 0d30555c2b982e4e7cb9c4a6741bae7d32e3e801 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 8 Oct 2009 12:47:48 +0200 Subject: [PATCH] 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. --- src/database.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) 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 -- 1.7.10.4