source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Sort the URI keys for .Xr links in the same order used by the
@ 2014-07-25 20:09 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-07-25 20:09 UTC (permalink / raw)
  To: source

Log Message:
-----------
Sort the URI keys for .Xr links in the same order used by the search form,
and leave out the manpath when it is the default.
For building the HTML formatter options, do not use a static buffer.

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.89
retrieving revision 1.90
diff -Lcgi.c -Lcgi.c -u -p -r1.89 -r1.90
--- cgi.c
+++ cgi.c
@@ -851,12 +851,13 @@ static void
 format(const struct req *req, const char *file)
 {
 	struct mparse	*mp;
-	int		 fd;
 	struct mdoc	*mdoc;
 	struct man	*man;
 	void		*vp;
+	char		*opts;
 	enum mandoclevel rc;
-	char		 opts[PATH_MAX + 128];
+	int		 fd;
+	int		 usepath;
 
 	if (-1 == (fd = open(file, O_RDONLY, 0))) {
 		puts("<P>You specified an invalid manual file.</P>");
@@ -875,11 +876,14 @@ format(const struct req *req, const char
 		return;
 	}
 
-	snprintf(opts, sizeof(opts), "fragment,man=%s?"
-	    "manpath=%s&query=%%N&sec=%%S%s%s",
-	    scriptname, req->q.manpath,
-	    req->q.arch ? "&arch=" : "",
-	    req->q.arch ? req->q.arch : "");
+	usepath = strcmp(req->q.manpath, req->p[0]);
+	mandoc_asprintf(&opts,
+	    "fragment,man=%s?query=%%N&sec=%%S%s%s%s%s",
+	    scriptname,
+	    req->q.arch	? "&arch="       : "",
+	    req->q.arch	? req->q.arch    : "",
+	    usepath	? "&manpath="    : "",
+	    usepath	? req->q.manpath : "");
 
 	mparse_result(mp, &mdoc, &man, NULL);
 	if (NULL == man && NULL == mdoc) {
@@ -899,6 +903,7 @@ format(const struct req *req, const char
 
 	html_free(vp);
 	mparse_free(mp);
+	free(opts);
 }
 
 static void
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-25 20:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-25 20:09 mdocml: Sort the URI keys for .Xr links in the same order used by the schwarze

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).