From b7aba06f1bb95a981f391df57fdac69592186554 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sat, 27 Jul 2013 07:59:30 +0000 Subject: [PATCH] fixed bug in searcher: fucked up 'o'-tags FossilOrigin-Name: e97440fb82afb4cb42fa572b680380acfbc9681699d1baf86a3b5c205048d8ca --- src/search.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/search.c b/src/search.c index 1f42130..910dbbc 100644 --- a/src/search.c +++ b/src/search.c @@ -80,7 +80,7 @@ static dirinfo_t *list_dir (const char *path) { return di; } // - //dlogf("path: [%s]\n", path); + dlogf("path: [%s]\n", path); // select and then refine while (*path) { tagvalue_t *tv; @@ -97,21 +97,23 @@ static dirinfo_t *list_dir (const char *path) { path = e+1; } } - //dlogf("(%d) condstr: [%s]\n", fcount, condstr); + dlogf("(fcount=%d) condstr: [%s]; inorig: %d\n", fcount, condstr, inorig); if (condstr[0] == ':') { // specific tag - if (tagh != NULL) { fcount = 0; break; } // error + if (tagh != NULL) { dlogf("error: 2 specials\n"); fcount = 0; break; } // error for (size_t f = 0; f < ARRAYLEN(specdirs); ++f) { if (strcmp(specdirs[f], condstr) == 0) { - if (wasspec[f]) { fcount = 0; break; } // error + if (wasspec[f]) { dlogf(" error: dupspecial '%s'\n", condstr+1); fcount = 0; break; } // error wasspec[f] = 1; } + /* if (condstr[1] == 'o' && strcmp(specdirs[f]+2, condstr+2) == 0) { - if (wasspec[f]) { fcount = 0; break; } // error + if (wasspec[f]) { dlogf(" error: dupspecial '%s'\n", condstr+2); fcount = 0; break; } // error wasspec[f] = 1; } + */ } - //dlogf("special: [%s]\n", condstr); + dlogf("special: [%s] (fc=%d)\n", condstr, fcount); if (strcmp(condstr, ":files") == 0) { // we want only files onlyfiles = 1; @@ -124,24 +126,29 @@ static dirinfo_t *list_dir (const char *path) { } // if (strcmp(condstr, ":otags") == 0) { - if (inorig >= 0) { fcount = 0; break; } // error + if (inorig >= 0) { dlogf(" error: 'otags' in tmode\n"); fcount = 0; break; } // error inorig = 1; - //dlogf("otags; path=[%s]\n", path); + dlogf("otags; path=[%s]\n", path); continue; } // if (condstr[1] == 'o') { - if (inorig == 0) { fcount = 0; break; } // no ':o' in normal dirs + if (inorig == 0) { dlogf(" 'o' tag disabled, inorig=%d\n", inorig); fcount = 0; break; } // no ':o' in normal dirs + // disable 'non-o' tags + if (inorig < 0) for (size_t f = 0; f < ARRAYLEN(specdirs); ++f) if (specdirs[f][1] != 'o') wasspec[f] = 1;; inorig = 1; } else { - if (inorig == 1) { fcount = 0; break; } // no normal in orig dirs + if (inorig == 1) { dlogf(" 't' tag disabled, inorig=%d\n", inorig); fcount = 0; break; } // no normal in orig dirs + // disable 'o' tags + if (inorig < 0) for (size_t f = 0; f < ARRAYLEN(specdirs); ++f) if (specdirs[f][1] == 'o') wasspec[f] = 1;; inorig = 0; } // tagh = special_hash(condstr+1); if (tagh == NULL) { fcount = 0; break; } // unknown tag name, nothing can be found fieldofs = special_ofs(condstr+1); - //dlogf(" tag '%s' (%d)\n", condstr+1, fieldofs); + dlogf(" tag '%s' (fofs=%d; fc=%d)\n", condstr+1, fieldofs, fcount); + //dlogf(" tag '%s' (fofs: %d), hcnt=%d\n", condstr+1, fieldofs, HASH_COUNT(*tagh)); continue; } // @@ -153,7 +160,7 @@ static dirinfo_t *list_dir (const char *path) { if (tv != NULL) { wasit = 1; inorig = 0; - //dlogf(" for tag '%s': %d items\n", condstr, tv->idcount); + dlogf(" for tag '%s': %d items\n", condstr, tv->idcount); if (files == NULL) { // first time: add all files with this tag add_from_tv(tv); @@ -168,7 +175,7 @@ static dirinfo_t *list_dir (const char *path) { if (tv != NULL) { wasit = 1; inorig = 1; - //dlogf(" for tag '%s': %d items\n", condstr, tv->idcount); + dlogf(" for tag '%s': %d items\n", condstr, tv->idcount); if (files == NULL) { // first time: add all files with this tag add_from_tv(tv); @@ -183,8 +190,8 @@ static dirinfo_t *list_dir (const char *path) { } else { // special tag HASH_FIND_STR(*tagh, condstr, tv); - if (tv == NULL) { fcount = 0; break; } // no such tag, nothing can be found - //dlogf(" for tag '%s': %d items\n", condstr, tv->idcount); + if (tv == NULL) { dlogf(" for tag '%s': no items\n", condstr); fcount = 0; break; } // no such tag, nothing can be found + dlogf(" for tag '%s': %d items\n", condstr, tv->idcount); if (files == NULL) { // first time: add all files with this tag add_from_tv(tv); @@ -213,7 +220,7 @@ static dirinfo_t *list_dir (const char *path) { if (tagh == NULL) { // path ends with tag value // build tag list - //dlogf("inorig=%d\n", inorig); + dlogf("inorig=%d\n", inorig); for (int f = 0; f < fcount; ++f) { for (size_t sn = 0; sn < ARRAYLEN(specdirs); ++sn) { if ((inorig == 0 && specdirs[sn][1] == 'o') || (inorig == 1 && specdirs[sn][1] != 'o')) continue; @@ -247,7 +254,7 @@ static dirinfo_t *list_dir (const char *path) { } } else { // build tag list - //dlogf("inorig=%d\n", inorig); + dlogf("inorig=%d; tag '%s'; fcount=%d\n", inorig, condstr, fcount); for (int f = 0; f < fcount; ++f) { ftlist = (tagvalue_t **)((uint8_t *)(files[f])+fieldofs); if (ftlist[0] != NULL) { @@ -271,7 +278,7 @@ static dirinfo_t *list_dir (const char *path) { } // di->names = calloc(di->fcount+1, sizeof(di->names[0])); - //dlogf("allocated %d names (%p); pos=%d\n", di->fcount+1, di->names, pos); + dlogf("allocated %d names (%p); pos=%d\n", di->fcount+1, di->names, pos); if (!onlyfiles) { // specials di->names[pos++] = ":files"; -- 2.11.4.GIT