From a4bf3b21427f15756c56a5ef84c90a9e79ac7cf4 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sun, 13 Jul 2003 05:20:10 +0000 Subject: [PATCH] add a special case: a termless, match-any query git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8866 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/qofquery.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/engine/qofquery.c b/src/engine/qofquery.c index 268f53e855..7a19c36779 100644 --- a/src/engine/qofquery.c +++ b/src/engine/qofquery.c @@ -360,11 +360,14 @@ check_object (QofQuery *q, gpointer object) QofQueryTerm * qt; int and_terms_ok=1; - for(or_ptr = q->terms; or_ptr; or_ptr = or_ptr->next) { + for(or_ptr = q->terms; or_ptr; or_ptr = or_ptr->next) + { and_terms_ok = 1; - for(and_ptr = or_ptr->data; and_ptr; and_ptr = and_ptr->next) { + for(and_ptr = or_ptr->data; and_ptr; and_ptr = and_ptr->next) + { qt = (QofQueryTerm *)(and_ptr->data); - if (qt->param_fcns && qt->pred_fcn) { + if (qt->param_fcns && qt->pred_fcn) + { GSList *node; QofAccessFunc get_fcn; gpointer conv_obj = object; @@ -380,19 +383,30 @@ check_object (QofQuery *q, gpointer object) conv_obj = get_fcn (conv_obj); } - if (((qt->pred_fcn)(conv_obj, get_fcn, qt->pdata)) - == qt->invert) { + if (((qt->pred_fcn)(conv_obj, get_fcn, qt->pdata)) == qt->invert) + { and_terms_ok = 0; break; } - } else { + } + else + { /* XXX: Don't know how to do this conversion -- do we care? */ } } - if(and_terms_ok) { + if (and_terms_ok) + { return 1; } } + + /* If there are no terms, assume a "match any" applies. + * A query with no terms is still meaningful, since the user + * may want to get all objects, but in a particular sorted + * order. + */ + if (NULL == q->terms) return 1; + return 0; }