source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* docbook2mdoc: Finally get rid of the "sv" variable in pnode_print().
@ 2019-04-12 12:07 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-12 12:07 UTC (permalink / raw)
  To: source

Log Message:
-----------
Finally get rid of the "sv" variable in pnode_print().
Switch <literal> and <quote> between explicit and implicit enclosures
depending on whether we are already inside an implicit context.

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

Revision Data
-------------
Index: docbook2mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -Ldocbook2mdoc.c -Ldocbook2mdoc.c -u -p -r1.111 -r1.112
--- docbook2mdoc.c
+++ docbook2mdoc.c
@@ -830,12 +830,12 @@ static void
 pnode_print(struct format *f, struct pnode *n)
 {
 	struct pnode	*nc, *nn;
-	enum linestate	 sv;
+	int		 was_impl;
 
 	if (n == NULL)
 		return;
 
-	sv = f->linestate;
+	was_impl = f->flags & FMT_IMPL;
 	if (n->spc)
 		f->flags &= ~FMT_NOSPC;
 	else
@@ -874,7 +874,6 @@ pnode_print(struct format *f, struct pno
 		break;
 	case NODE_EDITOR:
 		print_text(f, "editor:", ARG_SPACE);
-		sv = LINE_TEXT;
 		macro_open(f, "An");
 		break;
 	case NODE_EMAIL:
@@ -922,7 +921,12 @@ pnode_print(struct format *f, struct pno
 		pnode_printlink(f, n);
 		break;
 	case NODE_LITERAL:
-		macro_open(f, "Ql");
+		if (was_impl)
+			macro_open(f, "So");
+		else {
+			macro_open(f, "Ql");
+			f->flags |= FMT_IMPL;
+		}
 		break;
 	case NODE_LITERALLAYOUT:
 		macro_close(f);
@@ -965,7 +969,12 @@ pnode_print(struct format *f, struct pno
 		pnode_unlinksub(n);
 		break;
 	case NODE_QUOTE:
-		macro_open(f, "Qo");
+		if (was_impl)
+			macro_open(f, "Do");
+		else {
+			macro_open(f, "Dq");
+			f->flags |= FMT_IMPL;
+		}
 		break;
 	case NODE_PROGRAMLISTING:
 	case NODE_SCREEN:
@@ -1051,6 +1060,12 @@ pnode_print(struct format *f, struct pno
 	case NODE_INLINEEQUATION:
 		macro_line(f, "EN");
 		break;
+	case NODE_LITERAL:
+		if (was_impl)
+			macro_open(f, "Sc");
+		else
+			f->flags &= ~FMT_IMPL;
+		break;
 	case NODE_MEMBER:
 		if ((nn = TAILQ_NEXT(n, child)) != NULL &&
 		    nn->node != NODE_MEMBER)
@@ -1078,12 +1093,10 @@ pnode_print(struct format *f, struct pno
 		fputs(" } ", stdout);
 		break;
 	case NODE_QUOTE:
-		if (sv == LINE_NEW)
-			macro_close(f);
-		sv = f->linestate;
-		macro_open(f, "Qc");
-		if (sv == LINE_NEW)
-			macro_close(f);
+		if (was_impl)
+			macro_open(f, "Dc");
+		else
+			f->flags &= ~FMT_IMPL;
 		break;
 	case NODE_PREFACE:
 	case NODE_SECTION:
--
 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-12 12:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 12:07 docbook2mdoc: Finally get rid of the "sv" variable in pnode_print() 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).