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 c458192e for ; Wed, 1 May 2019 10:06:10 -0500 (EST) Date: Wed, 1 May 2019 10:06:10 -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: In no-fill context, do not break the output line when a X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- In no-fill context, do not break the output line when a text node on a text line is followed by a macro node. Modified Files: -------------- docbook2mdoc: docbook2mdoc.c macro.c macro.h Revision Data ------------- Index: macro.h =================================================================== RCS file: /home/cvs/mdocml/docbook2mdoc/macro.h,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacro.h -Lmacro.h -u -p -r1.5 -r1.6 --- macro.h +++ macro.h @@ -34,6 +34,7 @@ enum parastate { struct format { int level; /* Header level, starting at 1. */ + int nofill; /* Level of no-fill block nesting. */ int flags; #define FMT_NOSPC (1 << 0) /* Suppress space before next node. */ #define FMT_ARG (1 << 1) /* May add argument to current macro. */ Index: docbook2mdoc.c =================================================================== RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v retrieving revision 1.145 retrieving revision 1.146 diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.145 -r1.146 --- docbook2mdoc.c +++ docbook2mdoc.c @@ -930,6 +930,9 @@ pnode_print(struct format *f, struct pno if (n == NULL) return; + if (f->nofill && n->flags & NFLAG_LINE) + macro_close(f); + was_impl = f->flags & FMT_IMPL; if (n->flags & NFLAG_SPC) f->flags &= ~FMT_NOSPC; @@ -1193,6 +1196,9 @@ pnode_print(struct format *f, struct pno break; } + if (pnode_class(n->node) == CLASS_NOFILL) + f->nofill++; + TAILQ_FOREACH(nc, &n->childq, child) pnode_print(f, nc); @@ -1306,6 +1312,8 @@ pnode_print(struct format *f, struct pno break; } f->flags &= ~FMT_ARG; + if (pnode_class(n->node) == CLASS_NOFILL) + f->nofill--; } void @@ -1313,7 +1321,7 @@ ptree_print_mdoc(struct ptree *tree) { struct format formatter; - formatter.level = 0; + formatter.level = formatter.nofill = 0; formatter.linestate = LINE_NEW; formatter.parastate = PARA_HAVE; pnode_printprologue(&formatter, tree->root); Index: macro.c =================================================================== RCS file: /home/cvs/mdocml/docbook2mdoc/macro.c,v retrieving revision 1.16 retrieving revision 1.17 diff -Lmacro.c -Lmacro.c -u -p -r1.16 -r1.17 --- macro.c +++ macro.c @@ -49,6 +49,8 @@ macro_open(struct format *f, const char } /* FALLTHROUGH */ case LINE_TEXT: + if (f->nofill) + fputs(" \\c", stdout); putchar('\n'); /* FALLTHROUGH */ case LINE_NEW: -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv