]> git.cameronkatri.com Git - mandoc.git/blobdiff - mansearch.c
If a manual page is installed gzip(1)ed, let makewhatis(8) take
[mandoc.git] / mansearch.c
index 8a38c6572d8ea37fffe5a756dfb59977634e589d..9c88fac8047c40a90fc876b393eeb46c75c7ddae 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mansearch.c,v 1.45 2014/08/17 03:24:47 schwarze Exp $ */
+/*     $Id: mansearch.c,v 1.48 2014/09/03 18:09:14 schwarze Exp $ */
 /*
  * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -80,7 +80,7 @@ struct        expr {
 struct match {
        uint64_t         pageid; /* identifier in database */
        char            *desc; /* manual page description */
-       int              form; /* 0 == catpage */
+       int              form; /* bit field: formatted, zipped? */
 };
 
 static void             buildnames(struct manpage *, sqlite3 *,
@@ -335,6 +335,7 @@ mansearch(const struct mansearch *search,
                                    maxres, sizeof(struct manpage));
                        }
                        mpage = *res + cur;
+                       mpage->ipath = i;
                        mpage->sec = 10;
                        mpage->form = mp->form;
                        buildnames(mpage, db, s, mp->pageid,
@@ -397,6 +398,7 @@ buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
 {
        char            *newnames, *prevsec, *prevarch;
        const char      *oldnames, *sep1, *name, *sec, *sep2, *arch, *fsec;
+       const char      *gzip;
        size_t           i;
        int              c;
 
@@ -462,16 +464,20 @@ buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
                if (NULL != mpage->file)
                        continue;
 
-               if (form) {
+               if (form & FORM_SRC) {
                        sep1 = "man";
                        fsec = sec;
                } else {
                        sep1 = "cat";
                        fsec = "0";
                }
+               if (form & FORM_GZ)
+                       gzip = ".gz";
+               else
+                       gzip = "";
                sep2 = '\0' == *arch ? "" : "/";
-               mandoc_asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s",
-                   path, sep1, sec, sep2, arch, name, fsec);
+               mandoc_asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s%s",
+                   path, sep1, sec, sep2, arch, name, fsec, gzip);
        }
        if (SQLITE_DONE != c)
                fprintf(stderr, "%s\n", sqlite3_errmsg(db));
@@ -768,6 +774,7 @@ exprterm(const struct mansearch *search, char *buf, int cs)
                e->bits = TYPE_Nm;
                e->substr = NULL;
                mandoc_asprintf(&val, "[[:<:]]%s[[:>:]]", buf);
+               cs = 0;
        } else if ((val = strpbrk(buf, "=~")) == NULL) {
                e->bits = TYPE_Nm | TYPE_Nd;
                e->substr = buf;