source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Improve handling of .Va and .Vt macros.
@ 2016-01-04 14:45 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2016-01-04 14:45 UTC (permalink / raw)
  To: source

Log Message:
-----------
Improve handling of .Va and .Vt macros.
tedu@ noticed that no Vt= database entries were generated.
Serguey Parkhomovsky suggested the deletion of parse_mdoc_body().
tb@ noticed that the fix requires more than just adding TYPE_Vt
to the MDOC_Vt mask in the mdoc_handler array.

Modified Files:
--------------
    mdocml:
        mandocdb.c

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.210
retrieving revision 1.211
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.210 -r1.211
--- mandocdb.c
+++ mandocdb.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011-2016 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -156,8 +156,6 @@ static	void	 parse_man(struct mpage *, c
 			const struct roff_node *);
 static	void	 parse_mdoc(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
-static	int	 parse_mdoc_body(struct mpage *, const struct roff_meta *,
-			const struct roff_node *);
 static	int	 parse_mdoc_head(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
 static	int	 parse_mdoc_Fd(struct mpage *, const struct roff_meta *,
@@ -173,6 +171,8 @@ static	int	 parse_mdoc_Nm(struct mpage *
 			const struct roff_node *);
 static	int	 parse_mdoc_Sh(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
+static	int	 parse_mdoc_Va(struct mpage *, const struct roff_meta *,
+			const struct roff_node *);
 static	int	 parse_mdoc_Xr(struct mpage *, const struct roff_meta *,
 			const struct roff_node *);
 static	void	 putkey(const struct mpage *, char *, uint64_t);
@@ -242,8 +242,8 @@ static	const struct mdoc_handler mdocs[M
 	{ NULL, TYPE_Pa },  /* Pa */
 	{ NULL, 0 },  /* Rv */
 	{ NULL, TYPE_St },  /* St */
-	{ NULL, TYPE_Va },  /* Va */
-	{ parse_mdoc_body, TYPE_Va },  /* Vt */
+	{ parse_mdoc_Va, TYPE_Va },  /* Va */
+	{ parse_mdoc_Va, TYPE_Vt },  /* Vt */
 	{ parse_mdoc_Xr, 0 },  /* Xr */
 	{ NULL, 0 },  /* %A */
 	{ NULL, 0 },  /* %B */
@@ -1689,6 +1689,29 @@ parse_mdoc_Fo(struct mpage *mpage, const
 }
 
 static int
+parse_mdoc_Va(struct mpage *mpage, const struct roff_meta *meta,
+	const struct roff_node *n)
+{
+	char *cp;
+
+	if (n->type != ROFFT_ELEM && n->type != ROFFT_BODY)
+		return 0;
+
+	if (n->nchild == 1 && n->child->type == ROFFT_TEXT)
+		return 1;
+
+	cp = NULL;
+	deroff(&cp, n);
+	if (cp != NULL) {
+		putkey(mpage, cp, TYPE_Vt | (n->tok == MDOC_Va ||
+		    n->type == ROFFT_BODY ? TYPE_Va : 0));
+		free(cp);
+	}
+
+	return 0;
+}
+
+static int
 parse_mdoc_Xr(struct mpage *mpage, const struct roff_meta *meta,
 	const struct roff_node *n)
 {
@@ -1754,14 +1777,6 @@ parse_mdoc_head(struct mpage *mpage, con
 {
 
 	return n->type == ROFFT_HEAD;
-}
-
-static int
-parse_mdoc_body(struct mpage *mpage, const struct roff_meta *meta,
-	const struct roff_node *n)
-{
-
-	return n->type == ROFFT_BODY;
 }
 
 /*
--
 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:[~2016-01-04 14:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-04 14:45 mdocml: Improve handling of .Va and .Vt macros 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).