From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id fc0ee710 for ; Fri, 12 Apr 2019 06:20:01 -0500 (EST) Date: Fri, 12 Apr 2019 06:20:01 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: docbook2mdoc: Clean up the mess to get rid of the worst X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- Clean up the mess to get rid of the worst "sv" user: Explicit loop over elements in . Treat stray elements just like . Modified Files: -------------- docbook2mdoc: docbook2mdoc.c Revision Data ------------- Index: docbook2mdoc.c =================================================================== RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v retrieving revision 1.109 retrieving revision 1.110 diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.109 -r1.110 --- docbook2mdoc.c +++ docbook2mdoc.c @@ -150,6 +150,27 @@ pnode_printpara(struct format *f, struct macro_line(f, "Pp"); } +static void +pnode_printrefnamediv(struct format *f, struct pnode *n) +{ + struct pnode *nc, *nn; + int comma; + + macro_line(f, "Sh NAME"); + comma = 0; + TAILQ_FOREACH_SAFE(nc, &n->childq, child, nn) { + if (nc->node != NODE_REFNAME) + continue; + if (comma) + macro_addarg(f, ",", ARG_SPACE); + macro_open(f, "Nm"); + macro_addnode(f, nc, ARG_SPACE); + pnode_unlink(nc); + comma = 1; + } + macro_close(f); +} + /* * If the SYNOPSIS macro has a superfluous title, kill it. */ @@ -964,13 +985,11 @@ pnode_print(struct format *f, struct pno pnode_unlinksub(n); break; case NODE_REFNAME: - /* Suppress non-text children... */ + /* More often, these appear inside NODE_REFNAMEDIV. */ macro_open(f, "Nm"); - macro_addnode(f, n, ARG_SPACE | ARG_SINGLE); - pnode_unlinksub(n); break; case NODE_REFNAMEDIV: - macro_line(f, "Sh NAME"); + pnode_printrefnamediv(f, n); break; case NODE_REFPURPOSE: macro_open(f, "Nd"); @@ -1071,20 +1090,6 @@ pnode_print(struct format *f, struct pno macro_close(f); sv = f->linestate; macro_open(f, "Qc"); - if (sv == LINE_NEW) - macro_close(f); - break; - case NODE_REFNAME: - /* - * If we're in the NAME macro and we have multiple - * macros in sequence, then print out a - * trailing comma before the newline. - */ - if (n->parent != NULL && - n->parent->node == NODE_REFNAMEDIV && - TAILQ_NEXT(n, child) != NULL && - TAILQ_NEXT(n, child)->node == NODE_REFNAME) - macro_addarg(f, ",", ARG_SPACE); if (sv == LINE_NEW) macro_close(f); break; -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv