=================================================================== RCS file: /cvs/mandoc/Attic/apropos_db.c,v retrieving revision 1.13 retrieving revision 1.16 diff -u -p -r1.13 -r1.16 --- mandoc/Attic/apropos_db.c 2011/11/27 18:54:01 1.13 +++ mandoc/Attic/apropos_db.c 2011/11/29 10:53:42 1.16 @@ -1,4 +1,4 @@ -/* $Id: apropos_db.c,v 1.13 2011/11/27 18:54:01 kristaps Exp $ */ +/* $Id: apropos_db.c,v 1.16 2011/11/29 10:53:42 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * Copyright (c) 2011 Ingo Schwarze @@ -52,7 +52,6 @@ struct expr { int regex; /* is regex? */ int index; /* index in match array */ uint64_t mask; /* type-mask */ - int cs; /* is case-sensitive? */ int and; /* is rhs of logical AND? */ char *v; /* search value */ regex_t re; /* compiled re, if regex */ @@ -366,6 +365,7 @@ index_read(const DBT *key, const DBT *val, int index, rec->res.rec = *(recno_t *)key->data; rec->res.volume = index; + INDEX_BREAD(rec->res.type); INDEX_BREAD(rec->res.file); INDEX_BREAD(rec->res.cat); INDEX_BREAD(rec->res.title); @@ -598,10 +598,10 @@ termcomp(int argc, char *argv[], size_t *tt) e = NULL; *tt = 0; - for (pos = 0; pos < argc; pos++) { - sz = strlen(argv[pos]) + 16; + for (pos = argc - 1; pos >= 0; pos--) { + sz = strlen(argv[pos]) + 18; buf = mandoc_realloc(buf, sz); - strlcpy(buf, "~[[:<:]]", sz); + strlcpy(buf, "Nm~[[:<:]]", sz); strlcat(buf, argv[pos], sz); strlcat(buf, "[[:>:]]", sz); if (NULL == (next = exprterm(buf, 0))) { @@ -609,8 +609,7 @@ termcomp(int argc, char *argv[], size_t *tt) exprfree(e); return(NULL); } - if (NULL != e) - e->next = next; + next->next = e; e = next; (*tt)++; } @@ -694,7 +693,6 @@ exprexpr(int argc, char *argv[], int *pos, int *lvl, s ++(*pos); ++(*lvl); next = mandoc_calloc(1, sizeof(struct expr)); - next->cs = 1; next->subexpr = exprexpr(argc, argv, pos, lvl, tt); if (NULL == next->subexpr) { free(next); @@ -745,8 +743,6 @@ exprterm(char *buf, int cs) memset(&e, 0, sizeof(struct expr)); - e.cs = cs; - /* Choose regex or substring match. */ if (NULL == (e.v = strpbrk(buf, "=~"))) { @@ -818,13 +814,8 @@ exprmark(const struct expr *p, const char *cp, if (p->regex) { if (regexec(&p->re, cp, 0, NULL, 0)) continue; - } else if (p->cs) { - if (NULL == strstr(cp, p->v)) - continue; - } else { - if (NULL == strcasestr(cp, p->v)) - continue; - } + } else if (NULL == strcasestr(cp, p->v)) + continue; if (NULL == ms) return(1);