source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: In the SYNOPSIS, if .Nm occurs without argument, give the first
Date: Thu, 4 Dec 2014 12:36:01 -0500 (EST)	[thread overview]
Message-ID: <12190042002529289567.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
In the SYNOPSIS, if .Nm occurs without argument, give the first .Nm 
that occurred in the document a NAME_SYN entry in the names table.

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

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.171
retrieving revision 1.172
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.171 -r1.172
--- mandocdb.c
+++ mandocdb.c
@@ -128,7 +128,8 @@ enum	stmt {
 	STMT__MAX
 };
 
-typedef	int (*mdoc_fp)(struct mpage *, const struct mdoc_node *);
+typedef	int (*mdoc_fp)(struct mpage *, const struct mdoc_meta *,
+			const struct mdoc_node *);
 
 struct	mdoc_handler {
 	mdoc_fp		 fp; /* optional handler */
@@ -154,15 +155,24 @@ static	void	 mpages_merge(struct mchars 
 static	void	 names_check(void);
 static	void	 parse_cat(struct mpage *, int);
 static	void	 parse_man(struct mpage *, const struct man_node *);
-static	void	 parse_mdoc(struct mpage *, const struct mdoc_node *);
-static	int	 parse_mdoc_body(struct mpage *, const struct mdoc_node *);
-static	int	 parse_mdoc_head(struct mpage *, const struct mdoc_node *);
-static	int	 parse_mdoc_Fd(struct mpage *, const struct mdoc_node *);
-static	int	 parse_mdoc_Fn(struct mpage *, const struct mdoc_node *);
-static	int	 parse_mdoc_Nd(struct mpage *, const struct mdoc_node *);
-static	int	 parse_mdoc_Nm(struct mpage *, const struct mdoc_node *);
-static	int	 parse_mdoc_Sh(struct mpage *, const struct mdoc_node *);
-static	int	 parse_mdoc_Xr(struct mpage *, const struct mdoc_node *);
+static	void	 parse_mdoc(struct mpage *, const struct mdoc_meta *,
+			const struct mdoc_node *);
+static	int	 parse_mdoc_body(struct mpage *, const struct mdoc_meta *,
+			const struct mdoc_node *);
+static	int	 parse_mdoc_head(struct mpage *, const struct mdoc_meta *,
+			const struct mdoc_node *);
+static	int	 parse_mdoc_Fd(struct mpage *, const struct mdoc_meta *,
+			const struct mdoc_node *);
+static	int	 parse_mdoc_Fn(struct mpage *, const struct mdoc_meta *,
+			const struct mdoc_node *);
+static	int	 parse_mdoc_Nd(struct mpage *, const struct mdoc_meta *,
+			const struct mdoc_node *);
+static	int	 parse_mdoc_Nm(struct mpage *, const struct mdoc_meta *,
+			const struct mdoc_node *);
+static	int	 parse_mdoc_Sh(struct mpage *, const struct mdoc_meta *,
+			const struct mdoc_node *);
+static	int	 parse_mdoc_Xr(struct mpage *, const struct mdoc_meta *,
+			const struct mdoc_node *);
 static	void	 putkey(const struct mpage *, char *, uint64_t);
 static	void	 putkeys(const struct mpage *,
 			const char *, size_t, uint64_t);
@@ -1217,7 +1227,7 @@ mpages_merge(struct mchars *mc, struct m
 		if (NULL != mdoc) {
 			if (NULL != (cp = mdoc_meta(mdoc)->name))
 				putkey(mpage, cp, NAME_HEAD);
-			parse_mdoc(mpage, mdoc_node(mdoc));
+			parse_mdoc(mpage, mdoc_meta(mdoc), mdoc_node(mdoc));
 		} else if (NULL != man)
 			parse_man(mpage, man_node(man));
 		else
@@ -1542,7 +1552,8 @@ parse_man(struct mpage *mpage, const str
 }
 
 static void
-parse_mdoc(struct mpage *mpage, const struct mdoc_node *n)
+parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta,
+	const struct mdoc_node *n)
 {
 
 	assert(NULL != n);
@@ -1558,7 +1569,7 @@ parse_mdoc(struct mpage *mpage, const st
 			/* FALLTHROUGH */
 		case MDOC_TAIL:
 			if (NULL != mdocs[n->tok].fp)
-			       if (0 == (*mdocs[n->tok].fp)(mpage, n))
+			       if (0 == (*mdocs[n->tok].fp)(mpage, meta, n))
 				       break;
 			if (mdocs[n->tok].mask)
 				putmdockey(mpage, n->child,
@@ -1569,12 +1580,13 @@ parse_mdoc(struct mpage *mpage, const st
 			continue;
 		}
 		if (NULL != n->child)
-			parse_mdoc(mpage, n);
+			parse_mdoc(mpage, meta, n);
 	}
 }
 
 static int
-parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_node *n)
+parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_meta *meta,
+	const struct mdoc_node *n)
 {
 	const char	*start, *end;
 	size_t		 sz;
@@ -1617,7 +1629,8 @@ parse_mdoc_Fd(struct mpage *mpage, const
 }
 
 static int
-parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_node *n)
+parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta,
+	const struct mdoc_node *n)
 {
 	char	*cp;
 
@@ -1650,7 +1663,8 @@ parse_mdoc_Fn(struct mpage *mpage, const
 }
 
 static int
-parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_node *n)
+parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_meta *meta,
+	const struct mdoc_node *n)
 {
 	char	*cp;
 
@@ -1669,7 +1683,8 @@ parse_mdoc_Xr(struct mpage *mpage, const
 }
 
 static int
-parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_node *n)
+parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_meta *meta,
+	const struct mdoc_node *n)
 {
 
 	if (MDOC_BODY == n->type)
@@ -1678,32 +1693,40 @@ parse_mdoc_Nd(struct mpage *mpage, const
 }
 
 static int
-parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_node *n)
+parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta,
+	const struct mdoc_node *n)
 {
 
 	if (SEC_NAME == n->sec)
 		putmdockey(mpage, n->child, NAME_TITLE);
-	else if (SEC_SYNOPSIS == n->sec && MDOC_HEAD == n->type)
-		putmdockey(mpage, n->child, NAME_SYN);
+	else if (SEC_SYNOPSIS == n->sec && MDOC_HEAD == n->type) {
+		if (n->child == NULL)
+			putkey(mpage, meta->name, NAME_SYN);
+		else
+			putmdockey(mpage, n->child, NAME_SYN);
+	}
 	return(0);
 }
 
 static int
-parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_node *n)
+parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_meta *meta,
+	const struct mdoc_node *n)
 {
 
 	return(SEC_CUSTOM == n->sec && MDOC_HEAD == n->type);
 }
 
 static int
-parse_mdoc_head(struct mpage *mpage, const struct mdoc_node *n)
+parse_mdoc_head(struct mpage *mpage, const struct mdoc_meta *meta,
+	const struct mdoc_node *n)
 {
 
 	return(MDOC_HEAD == n->type);
 }
 
 static int
-parse_mdoc_body(struct mpage *mpage, const struct mdoc_node *n)
+parse_mdoc_body(struct mpage *mpage, const struct mdoc_meta *meta,
+	const struct mdoc_node *n)
 {
 
 	return(MDOC_BODY == n->type);
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-12-04 17:36 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=12190042002529289567.enqueue@fantadrom.bsd.lv \
    --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).