source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Without the MPARSE_SO option, if the file contains nothing but a
@ 2014-03-19 22:20 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-03-19 22:20 UTC (permalink / raw)
  To: source

Log Message:
-----------
Without the MPARSE_SO option, if the file contains nothing but a
single .so request, do not read the file pointed to, but instead
let mparse_result() provide the file name pointed to as a return
value.  To be used by makewhatis(8) in the future.

Modified Files:
--------------
    mdocml:
        cgi.c
        demandoc.c
        main.c
        mandoc.h
        mandocdb.c
        read.c

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.116 -r1.117
--- mandocdb.c
+++ mandocdb.c
@@ -999,7 +999,7 @@ mpages_merge(struct mchars *mc, struct m
 		    FORM_CAT != mpage->mlinks->fform) {
 			lvl = mparse_readfd(mp, -1, mpage->mlinks->file);
 			if (lvl < MANDOCLEVEL_FATAL)
-				mparse_result(mp, &mdoc, &man);
+				mparse_result(mp, &mdoc, &man, NULL);
 		}
 
 		if (NULL != mdoc) {
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.116
retrieving revision 1.117
diff -Lmandoc.h -Lmandoc.h -u -p -r1.116 -r1.117
--- mandoc.h
+++ mandoc.h
@@ -427,7 +427,7 @@ enum mandoclevel  mparse_readmem(struct 
 			const char *);
 void		  mparse_reset(struct mparse *);
 void		  mparse_result(struct mparse *, 
-			struct mdoc **, struct man **);
+			struct mdoc **, struct man **, char **);
 const char	 *mparse_getkeep(const struct mparse *);
 const char	 *mparse_strerror(enum mandocerr);
 const char	 *mparse_strlevel(enum mandoclevel);
Index: demandoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/demandoc.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -Ldemandoc.c -Ldemandoc.c -u -p -r1.9 -r1.10
--- demandoc.c
+++ demandoc.c
@@ -110,7 +110,7 @@ pmandoc(struct mparse *mp, int fd, const
 		return;
 	}
 
-	mparse_result(mp, &mdoc, &man);
+	mparse_result(mp, &mdoc, &man, NULL);
 	line = 1;
 	col = 0;
 
Index: cgi.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/cgi.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -Lcgi.c -Lcgi.c -u -p -r1.48 -r1.49
--- cgi.c
+++ cgi.c
@@ -753,7 +753,7 @@ format(const struct req *req, const char
 			/*"includes=/cgi-bin/man.cgi/usr/include/%%I"*/,
 			progname);
 
-	mparse_result(mp, &mdoc, &man);
+	mparse_result(mp, &mdoc, &man, NULL);
 	if (NULL == man && NULL == mdoc) {
 		resp_baddb();
 		mparse_free(mp);
Index: read.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -Lread.c -Lread.c -u -p -r1.44 -r1.45
--- read.c
+++ read.c
@@ -59,6 +59,7 @@ struct	mparse {
 	struct man	 *man; /* man parser */
 	struct mdoc	 *mdoc; /* mdoc parser */
 	struct roff	 *roff; /* roff parser (!NULL) */
+	char		 *sodest; /* filename pointed to by .so */
 	int		  reparse_count; /* finite interp. stack */
 	mandocmsg	  mmsg; /* warning/error message handler */
 	const char	 *file; 
@@ -490,6 +491,12 @@ rerun:
 			assert(MANDOCLEVEL_FATAL <= curp->file_status);
 			break;
 		case (ROFF_SO):
+			if (0 == (MPARSE_SO & curp->options) &&
+			    (i >= (int)blk.sz || '\0' == blk.buf[i])) {
+				curp->sodest = mandoc_strdup(ln.buf + of);
+				free(ln.buf);
+				return;
+			}
 			/*
 			 * We remove `so' clauses from our lookaside
 			 * buffer because we're going to descend into
@@ -676,7 +683,7 @@ mparse_end(struct mparse *curp)
 		return;
 	}
 
-	if ( ! (curp->man || curp->mdoc)) {
+	if ( ! (curp->mdoc || curp->man || curp->sodest)) {
 		mandoc_msg(MANDOCERR_NOTMANUAL, curp, 1, 0, NULL);
 		curp->file_status = MANDOCLEVEL_FATAL;
 		return;
@@ -798,6 +805,9 @@ mparse_reset(struct mparse *curp)
 	curp->file_status = MANDOCLEVEL_OK;
 	curp->mdoc = NULL;
 	curp->man = NULL;
+
+	free(curp->sodest);
+	curp->sodest = NULL;
 }
 
 void
@@ -814,13 +824,20 @@ mparse_free(struct mparse *curp)
 		free(curp->secondary->buf);
 
 	free(curp->secondary);
+	free(curp->sodest);
 	free(curp);
 }
 
 void
-mparse_result(struct mparse *curp, struct mdoc **mdoc, struct man **man)
+mparse_result(struct mparse *curp,
+	struct mdoc **mdoc, struct man **man, char **sodest)
 {
 
+	if (sodest && NULL != (*sodest = curp->sodest)) {
+		*mdoc = NULL;
+		*man = NULL;
+		return;
+	}
 	if (mdoc)
 		*mdoc = curp->mdoc;
 	if (man)
Index: main.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
retrieving revision 1.170
retrieving revision 1.171
diff -Lmain.c -Lmain.c -u -p -r1.170 -r1.171
--- main.c
+++ main.c
@@ -294,7 +294,7 @@ parse(struct curparse *curp, int fd, 
 		}
 	}
 
-	mparse_result(curp->mp, &mdoc, &man);
+	mparse_result(curp->mp, &mdoc, &man, NULL);
 
 	/* Execute the out device, if it exists. */
 
--
 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-03-19 22:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19 22:20 mdocml: Without the MPARSE_SO option, if the file contains nothing but a 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).