source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* docbook2mdoc: Make <funcdef> more robust: If the first child is text,
@ 2019-04-03 15:05 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-03 15:05 UTC (permalink / raw)
  To: source

Log Message:
-----------
Make <funcdef> more robust:
If the first child is text, use it for .Ft,
then use all remaining children for .Fo.

Make <funcprototype> more robust:
Use all children but the first <funcdef> for .Fa.

Modified Files:
--------------
    docbook2mdoc:
        docbook2mdoc.c
        statistics.c

Revision Data
-------------
Index: statistics.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/statistics.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lstatistics.c -Lstatistics.c -u -p -r1.7 -r1.8
--- statistics.c
+++ statistics.c
@@ -349,7 +349,13 @@ main(int argc, char *argv[])
 	/* Exclude relations that are already fully implemented. */
 	if (show_all == 0) {
 		table_add("chapter", "title");
+		table_add("emphasis", "TEXT");
 		table_add("entry", NULL);
+		table_add("funcdef", "function");
+		table_add("funcdef", "TEXT");
+		table_add("funcprototype", "funcdef");
+		table_add("funcprototype", "paramdef");
+		table_add("function", "TEXT");
 		table_add("informaltable", "tgroup");
 		table_add("itemizedlist", "listitem");
 		table_add("listitem", NULL);
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.85 -r1.86
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -201,25 +201,17 @@ pnode_printrefmeta(struct format *p, str
 }
 
 static void
-pnode_printfuncdef(struct format *p, struct pnode *pn)
+pnode_printfuncdef(struct format *f, struct pnode *n)
 {
-	struct pnode	*pp, *ftype, *func;
+	struct pnode	*nc;
 
-	ftype = func = NULL;
-	TAILQ_FOREACH(pp, &pn->childq, child) {
-		if (pp->node == NODE_TEXT)
-			ftype = pp;
-		else if (pp->node == NODE_FUNCTION)
-			func = pp;
+	nc = TAILQ_FIRST(&n->childq);
+	if (nc != NULL && nc->node == NODE_TEXT) {
+		macro_argline(f, "Ft", nc->b);
+		pnode_unlink(nc);
 	}
-	if (ftype != NULL)
-		macro_argline(p, "Ft", ftype->b);
-	macro_open(p, "Fo");
-	if (func == NULL)
-		macro_addarg(p, "UNKNOWN", ARG_SPACE);
-	else
-		macro_addnode(p, func, ARG_SPACE | ARG_SINGLE);
-	macro_close(p);
+	macro_nodeline(f, "Fo", n, ARG_SINGLE);
+	pnode_unlinksub(n);
 }
 
 /*
@@ -288,14 +280,14 @@ pnode_printfuncprototype(struct format *
 		if (fdef->node == NODE_FUNCDEF)
 			break;
 
-	if (fdef != NULL)
+	if (fdef != NULL) {
 		pnode_printfuncdef(p, fdef);
-	else
+		pnode_unlink(fdef);
+	} else
 		macro_line(p, "Fo UNKNOWN");
 
 	TAILQ_FOREACH(pp, &pn->childq, child)
-		if (pp->node == NODE_PARAMDEF)
-			macro_nodeline(p, "Fa", pp, ARG_SINGLE);
+		macro_nodeline(p, "Fa", pp, ARG_SINGLE);
 
 	macro_line(p, "Fc");
 	pnode_unlinksub(pn);
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

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

only message in thread, other threads:[~2019-04-03 15:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03 15:05 docbook2mdoc: Make <funcdef> more robust: If the first child is text, 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).