=================================================================== RCS file: /cvs/mandoc/cgi.c,v retrieving revision 1.37 retrieving revision 1.40 diff -u -p -r1.37 -r1.40 --- mandoc/cgi.c 2011/12/16 20:05:31 1.37 +++ mandoc/cgi.c 2012/03/23 09:03:07 1.40 @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.37 2011/12/16 20:05:31 kristaps Exp $ */ +/* $Id: cgi.c,v 1.40 2012/03/23 09:03:07 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -41,6 +41,7 @@ #include "man.h" #include "main.h" #include "manpath.h" +#include "mandocdb.h" #ifdef __linux__ # include @@ -68,7 +69,6 @@ struct query { const char *sec; /* manual section */ const char *expr; /* unparsed expression string */ int manroot; /* manroot index (or -1)*/ - int whatis; /* whether whatis mode */ int legacy; /* whether legacy mode */ }; @@ -134,7 +134,7 @@ atou(const char *buf, unsigned *v) return(0); if ((errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) || - (lval > UINT_MAX || lval < 0)) + (lval > INT_MAX || lval < 0)) return(0); *v = (unsigned int)lval; @@ -229,7 +229,6 @@ http_parse(struct req *req, char *p) memset(&req->q, 0, sizeof(struct query)); - req->q.whatis = 1; legacy = -1; manroot = NULL; @@ -267,19 +266,11 @@ http_parse(struct req *req, char *p) manroot = val; else if (0 == strcmp(key, "apropos")) legacy = 0 == strcmp(val, "0"); - else if (0 == strcmp(key, "op")) - req->q.whatis = 0 == strcasecmp(val, "whatis"); } /* Test for old man.cgi compatibility mode. */ - if (legacy == 0) { - req->q.whatis = 0; - req->q.legacy = 1; - } else if (legacy > 0) { - req->q.legacy = 1; - req->q.whatis = 1; - } + req->q.legacy = legacy > 0; /* * Section "0" means no section when in legacy mode. @@ -407,10 +398,8 @@ resp_searchform(const struct req *req) "
\n" "
\n" "Search Parameters\n" - " or \n" - " for manuals satisfying \n" + " for manuals satisfying \n" "q.expr ? req->q.expr : ""); @@ -537,18 +526,10 @@ resp_search(struct res *r, size_t sz, void *arg) puts("
"); if (0 == sz) { - printf("

\n" - "No %s results found.\n", - req->q.whatis ? "whatis" : "apropos"); - if (req->q.whatis) { - printf("(Try " - "apropos?)"); - } - puts("

"); - puts("
"); + puts("

\n" + "No results found.\n" + "

\n" + ""); resp_end_html(); return; } @@ -843,7 +824,8 @@ pg_show(const struct req *req, char *path) sz = strlcpy(file, ps.paths[vol], MAXPATHLEN); assert(sz < MAXPATHLEN); - strlcat(file, "/mandoc.index", MAXPATHLEN); + strlcat(file, "/", MAXPATHLEN); + strlcat(file, MANDOC_IDX, MAXPATHLEN); /* Open the index recno(3) database. */ @@ -951,7 +933,7 @@ pg_search(const struct req *req, char *path) * The resp_search() function is called with the results. */ - expr = req->q.whatis ? + expr = req->q.legacy ? termcomp(sz, cp, &tt) : exprcomp(sz, cp, &tt); if (NULL != expr)