From 1254d31d7c5a8dfeacbc26ea5957b16eb3c1c51f Mon Sep 17 00:00:00 2001 From: ketmar Date: Mon, 29 Jul 2013 00:05:03 +0000 Subject: [PATCH] searcher: NO_SEARCH_DBGLOG define to turn off logging FossilOrigin-Name: d1d7a8765e139e4956a366c079ae83c007742b008787a3d398252797d48c42b7 --- src/search.c | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/search.c b/src/search.c index 639c639..d1d2a78 100644 --- a/src/search.c +++ b/src/search.c @@ -1,6 +1,13 @@ #include "common.h" +#ifdef NO_SEARCH_DBGLOG +# define sxdlogf(...) ((void)0) +#else +# define sxdlogf dlogf +#endif + + //////////////////////////////////////////////////////////////////////////////// typedef struct { const char *name; @@ -236,7 +243,7 @@ static dirinfo_t *list_dir_simple (const char *path) { for (int tn = 0; tn < TFL_MAX; ++tn) { if (sp != NULL && tn != sp->tflidx) continue; if (sp == NULL && tp != SPT_ANY && tagtype[tn] != SPT_ANY && tp != tagtype[tn]) continue; - //dlogf("checking (%d)[%s]: %u : %u\n", tn, get_str(fi->shortname), fi->tags[tn], tv2idx(tv)); + //sxdlogf("checking (%d)[%s]: %u : %u\n", tn, get_str(fi->shortname), fi->tags[tn], tv2idx(tv)); if (fi->tags[tn] == tv2idx(tv)) { dodrop = 0; break; } } if (dodrop) HASH_DEL(fhash, cf); @@ -289,7 +296,7 @@ doroot: goto ret_sort_di; } // - dlogf("path: [%s]\n", path); + sxdlogf("path: [%s]\n", path); // select and then refine while (*path) { fl_tagvalue_t *tv; @@ -306,7 +313,7 @@ doroot: path = e+1; } } - dlogf("(fcount=%d) condstr: [%s]; sptype: %d\n", HASH_COUNT(fhash), condstr, sptype); + sxdlogf("(fcount=%d) condstr: [%s]; sptype: %d\n", HASH_COUNT(fhash), condstr, sptype); if (condstr[0] == ':') { // specific tag if (strcmp(condstr, ":and") == 0 || strcmp(condstr, ":or") == 0) { @@ -315,7 +322,7 @@ doroot: } firsttime = 0; // - if (sdi != NULL) { dlogf("error: 2 specials\n"); HASH_CLEAR(hh, fhash); break; } // error + if (sdi != NULL) { sxdlogf("error: 2 specials\n"); HASH_CLEAR(hh, fhash); break; } // error // if (strcmp(condstr, ":files") == 0) { // we want only files @@ -333,34 +340,34 @@ doroot: } // if (strcmp(condstr, ":otags") == 0) { - if (sptype == SPT_ORIG) { dlogf(" error: 'otags' in tmode\n"); HASH_CLEAR(hh, fhash); break; } // error + if (sptype == SPT_ORIG) { sxdlogf(" error: 'otags' in tmode\n"); HASH_CLEAR(hh, fhash); break; } // error sptype = SPT_ORIG; - dlogf("otags; path=[%s]\n", path); + sxdlogf("otags; path=[%s]\n", path); continue; } // if (strcmp(condstr, ":ttags") == 0) { - if (sptype == SPT_TRANS) { dlogf(" error: 'ttags' in tmode\n"); HASH_CLEAR(hh, fhash); break; } // error + if (sptype == SPT_TRANS) { sxdlogf(" error: 'ttags' in tmode\n"); HASH_CLEAR(hh, fhash); break; } // error sptype = SPT_TRANS; - dlogf("ttags; path=[%s]\n", path); + sxdlogf("ttags; path=[%s]\n", path); continue; } // if ((sdi = get_special_by_name(condstr)) == NULL) { - dlogf("unknown special: [%s]\n", condstr); + sxdlogf("unknown special: [%s]\n", condstr); HASH_CLEAR(hh, fhash); break; } // if (sdi->type != SPT_ANY && sptype != SPT_ANY) { if (sdi->type != sptype) { - dlogf("bad special in mode %d: [%s]\n", sptype, condstr); + sxdlogf("bad special in mode %d: [%s]\n", sptype, condstr); HASH_CLEAR(hh, fhash); break; } } // - dlogf("special: [%s] (fc=%d)\n", condstr, HASH_COUNT(fhash)); + sxdlogf("special: [%s] (fc=%d)\n", condstr, HASH_COUNT(fhash)); if (sdi->type != SPT_ANY) sptype = sdi->type; // continue; @@ -368,14 +375,14 @@ doroot: firsttime = 0; // got tag value tv = get_tag_with_special(condstr, sdi); - if (tv == NULL) { dlogf(" for tag '%s': wtf?!\n", condstr); HASH_CLEAR(hh, fhash); break; } // no items, nothing can be found + if (tv == NULL) { sxdlogf(" for tag '%s': wtf?!\n", condstr); HASH_CLEAR(hh, fhash); break; } // no items, nothing can be found if (files == NULL) { // first time: add all files with this tag - dlogf("first time: sdi=%p; sptype=%d", sdi, sptype); + sxdlogf("first time: sdi=%p; sptype=%d", sdi, sptype); add_from_tv(tv, sdi, sptype); } else { // remove all files that have no such tag in given field - dlogf("filtering out: sdi=%p; sptype=%d", sdi, sptype); + sxdlogf("filtering out: sdi=%p; sptype=%d", sdi, sptype); remove_not_have_tv(tv, sdi, sptype); } sdi = NULL; // processed @@ -389,7 +396,7 @@ doroot: if (sdi == NULL) { // path ends with tag value // build tag list - dlogf("sptype=%d\n", sptype); + sxdlogf("sptype=%d\n", sptype); for (u32value_t *cf = fhash; cf != NULL; cf = cf->hh.next) { for (size_t sn = 0; sn < ARRAYLEN(spec_dirs); ++sn) { uint32_t idx; @@ -420,7 +427,7 @@ doroot: } } else { // collect from files - //dlogf("sptype=%d; tag '%s'; fcount=%d\n", sptype, condstr, fcount); + //sxdlogf("sptype=%d; tag '%s'; fcount=%d\n", sptype, condstr, fcount); for (u32value_t *cf = fhash; cf != NULL; cf = cf->hh.next) { uint32_t idx = get_fi(cf->idx)->tags[sdi->tflidx]; HASH_FIND_UINT32(tl_hash, &idx, hx); @@ -440,7 +447,7 @@ doroot: } // di->names = calloc(di->fcount+1, sizeof(di->names[0])); - dlogf("allocated %d names (%p); pos=%d\n", di->fcount+1, di->names, pos); + sxdlogf("allocated %d names (%p); pos=%d\n", di->fcount+1, di->names, pos); if (!onlyfiles) { // specials di->names[pos++] = ":files"; @@ -466,7 +473,7 @@ ret_sort_di: qsort(di->names, di->fcount, sizeof(di->names[0]), lambda(int, (const void *p0, const void *p1) { const char *s0 = *((const char **)p0); const char *s1 = *((const char **)p1); - //dlogf("[%s] [%s]\n", s0, s1); + //sxdlogf("[%s] [%s]\n", s0, s1); if (s0[0] == ':' && s1[0] != ':') return -1; if (s0[0] != ':' && s1[0] == ':') return 1; return strcmp(s0, s1); @@ -482,7 +489,7 @@ static dirinfo_t *list_dir_or (char *pt) { char *ta = strstr(pt, "/:or/"); if (ta == NULL) return list_dir_simple(pt); *ta = 0; - dlogf("OR: [%s]\n", pt); + sxdlogf("OR: [%s]\n", pt); di = list_dir_simple(pt); *ta = '/'; pt = strchr(ta+1, '/'); @@ -528,18 +535,18 @@ static dirinfo_t *list_dir (const char *path) { strcpy(pt, path); for (;;) { char *tn; - dlogf("***a: [%s]\n", pt); + sxdlogf("***a: [%s]\n", pt); tn = strstr(pt, "/:and/"); if (tn == NULL) { - dlogf("ALAST: [%s]\n", pt); + sxdlogf("ALAST: [%s]\n", pt); fill_nhash(list_dir_or(pt)); break; } *tn = 0; - dlogf("AND: pt=[%s]; tn=[/%s]\n", pt, tn+1); + sxdlogf("AND: pt=[%s]; tn=[/%s]\n", pt, tn+1); fill_nhash(list_dir_or(pt)); pt = strchr(tn+1, '/'); - dlogf("xxx: [%s]\n", pt); + sxdlogf("xxx: [%s]\n", pt); } // now build result from nhash HASH_SORT(nhash, lambda(int, (const nlist_t *i0, const nlist_t *i1) { -- 2.11.4.GIT