=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/cgi.c,v retrieving revision 1.4 retrieving revision 1.5 diff -c -r1.4 -r1.5 *** src/usr.bin/mandoc/cgi.c 2014/07/12 01:52:57 1.4 --- src/usr.bin/mandoc/cgi.c 2014/07/12 16:13:36 1.5 *************** *** 1,4 **** ! /* $Id: cgi.c,v 1.4 2014/07/12 01:52:57 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze --- 1,4 ---- ! /* $Id: cgi.c,v 1.5 2014/07/12 16:13:36 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze *************** *** 45,51 **** const char *arch; /* architecture */ const char *sec; /* manual section */ const char *expr; /* unparsed expression string */ ! int legacy; /* whether legacy mode */ }; struct req { --- 45,51 ---- const char *arch; /* architecture */ const char *sec; /* manual section */ const char *expr; /* unparsed expression string */ ! int equal; /* match whole names, not substrings */ }; struct req { *************** *** 138,146 **** http_print(req->q.arch); } if (NULL != req->q.expr) { ! printf("&expr="); ! http_print(req->q.expr ? req->q.expr : ""); } } static void --- 138,148 ---- http_print(req->q.arch); } if (NULL != req->q.expr) { ! printf("&query="); ! http_print(req->q.expr); } + if (0 == req->q.equal) + printf("&apropos=1"); } static void *************** *** 160,168 **** html_print(req->q.arch); } if (NULL != req->q.expr) { ! printf("&expr="); html_print(req->q.expr); } } static void --- 162,172 ---- html_print(req->q.arch); } if (NULL != req->q.expr) { ! printf("&query="); html_print(req->q.expr); } + if (0 == req->q.equal) + printf("&apropos=1"); } static void *************** *** 198,209 **** http_parse(struct req *req, char *p) { char *key, *val; - int legacy; memset(&req->q, 0, sizeof(struct query)); req->q.manpath = req->p[0]; - legacy = -1; while ('\0' != *p) { key = p; val = NULL; --- 202,212 ---- http_parse(struct req *req, char *p) { char *key, *val; memset(&req->q, 0, sizeof(struct query)); req->q.manpath = req->p[0]; + req->q.equal = 1; while ('\0' != *p) { key = p; val = NULL; *************** *** 224,260 **** if (NULL != val && ! http_decode(val)) break; ! if (0 == strcmp(key, "expr")) req->q.expr = val; - else if (0 == strcmp(key, "query")) - req->q.expr = val; - else if (0 == strcmp(key, "sec")) - req->q.sec = val; - else if (0 == strcmp(key, "sektion")) - req->q.sec = val; - else if (0 == strcmp(key, "arch")) - req->q.arch = val; else if (0 == strcmp(key, "manpath")) req->q.manpath = val; else if (0 == strcmp(key, "apropos")) ! legacy = 0 == strcmp(val, "0"); } - - /* Test for old man.cgi compatibility mode. */ - - req->q.legacy = legacy > 0; - - /* - * Section "0" means no section when in legacy mode. - * For some man.cgi scripts, "default" arch is none. - */ - - if (req->q.legacy && NULL != req->q.sec) - if (0 == strcmp(req->q.sec, "0")) - req->q.sec = NULL; - if (req->q.legacy && NULL != req->q.arch) - if (0 == strcmp(req->q.arch, "default")) - req->q.arch = NULL; } static void --- 227,247 ---- if (NULL != val && ! http_decode(val)) break; ! if (0 == strcmp(key, "query")) req->q.expr = val; else if (0 == strcmp(key, "manpath")) req->q.manpath = val; else if (0 == strcmp(key, "apropos")) ! req->q.equal = !strcmp(val, "0"); ! else if (0 == strcmp(key, "sec") || ! 0 == strcmp(key, "sektion")) { ! if (strcmp(val, "0")) ! req->q.sec = val; ! } else if (0 == strcmp(key, "arch")) { ! if (strcmp(val, "default")) ! req->q.arch = val; ! } } } static void *************** *** 364,373 **** "
\n" "
\n" "Search Parameters\n" ! " for manuals matching \n" ! "q.expr ? req->q.expr : ""); printf("\">, section " "\n" "
\n" "Search Parameters\n" ! " " ! "for manuals \n", scriptname); + printf("\n" + "q.expr ? req->q.expr : ""); printf("\">, section " "q.arch; search.sec = req->q.sec; ! search.deftype = TYPE_Nm | TYPE_Nd; ! search.flags = 0; paths.sz = 1; paths.paths = mandoc_malloc(sizeof(char *)); --- 777,784 ---- search.arch = req->q.arch; search.sec = req->q.sec; ! search.deftype = req->q.equal ? TYPE_Nm : (TYPE_Nm | TYPE_Nd); ! search.flags = req->q.equal ? MANSEARCH_MAN : 0; paths.sz = 1; paths.paths = mandoc_malloc(sizeof(char *));