From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Start fixing issues that beck@ helped find: Distinguish between
Date: Sat, 12 Jul 2014 12:14:35 -0400 (EDT) [thread overview]
Message-ID: <201407121614.s6CGEZTq016293@krisdoz.my.domain> (raw)
Log Message:
-----------
Start fixing issues that beck@ helped find:
Distinguish between man(1) and apropos(1) mode by adding back the classical
QUERY_STRING variable "apropos=". Change the default back to "apropos=0".
Control it by adding a HTML <SELECT> element for it.
Rename the "expr=" QUERY_STRING variable back to its classical name "query=",
i don't see how the new name is better than the classical one.
While here, drop the concept of a "legacy mode". Simply continue to
support the features, and use what we consider best.
Modified Files:
--------------
mdocml:
cgi.c
Revision Data
-------------
Index: cgi.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/cgi.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -Lcgi.c -Lcgi.c -u -p -r1.64 -r1.65
--- cgi.c
+++ cgi.c
@@ -49,7 +49,7 @@ struct query {
const char *arch; /* architecture */
const char *sec; /* manual section */
const char *expr; /* unparsed expression string */
- int legacy; /* whether legacy mode */
+ int equal; /* match whole names, not substrings */
};
struct req {
@@ -142,9 +142,11 @@ http_printquery(const struct req *req)
http_print(req->q.arch);
}
if (NULL != req->q.expr) {
- printf("&expr=");
- http_print(req->q.expr ? req->q.expr : "");
+ printf("&query=");
+ http_print(req->q.expr);
}
+ if (0 == req->q.equal)
+ printf("&apropos=1");
}
static void
@@ -164,9 +166,11 @@ html_printquery(const struct req *req)
html_print(req->q.arch);
}
if (NULL != req->q.expr) {
- printf("&expr=");
+ printf("&query=");
html_print(req->q.expr);
}
+ if (0 == req->q.equal)
+ printf("&apropos=1");
}
static void
@@ -202,12 +206,11 @@ static void
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];
+ req->q.equal = 1;
- legacy = -1;
while ('\0' != *p) {
key = p;
val = NULL;
@@ -228,37 +231,21 @@ http_parse(struct req *req, char *p)
if (NULL != val && ! http_decode(val))
break;
- if (0 == strcmp(key, "expr"))
+ if (0 == strcmp(key, "query"))
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");
+ 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;
+ }
}
-
- /* 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
@@ -368,10 +355,20 @@ resp_searchform(const struct req *req)
"<FORM ACTION=\"%s/search\" METHOD=\"get\">\n"
"<FIELDSET>\n"
"<LEGEND>Search Parameters</LEGEND>\n"
- "<INPUT TYPE=\"submit\" "
- " VALUE=\"Search\"> for manuals matching \n"
- "<INPUT TYPE=\"text\" NAME=\"expr\" VALUE=\"",
+ "<INPUT TYPE=\"submit\" VALUE=\"Search\"> "
+ "for manuals \n",
scriptname);
+ printf("<SELECT NAME=\"apropos\">\n"
+ "<OPTION VALUE=\"0\"");
+ if (req->q.equal)
+ printf(" SELECTED=\"selected\"");
+ printf(">named</OPTION>\n"
+ "<OPTION VALUE=\"1\"");
+ if (0 == req->q.equal)
+ printf(" SELECTED=\"selected\"");
+ printf(">matching</OPTION>\n"
+ "</SELECT>\n"
+ "<INPUT TYPE=\"text\" NAME=\"query\" VALUE=\"");
html_print(req->q.expr ? req->q.expr : "");
printf("\">, section "
"<INPUT TYPE=\"text\""
@@ -784,8 +781,8 @@ pg_search(const struct req *req, char *p
search.arch = req->q.arch;
search.sec = req->q.sec;
- search.deftype = TYPE_Nm | TYPE_Nd;
- search.flags = 0;
+ 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 *));
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2014-07-12 16:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201407121614.s6CGEZTq016293@krisdoz.my.domain \
--to=schwarze@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).