source@mandoc.bsd.lv
 help / color / Atom feed
* docbook2mdoc: When rendering XML entities, skip escaping in 
@ 2019-05-20 20:08 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-05-20 20:08 UTC (permalink / raw)
  To: source

Log Message:
-----------
When rendering XML entities, skip escaping in macro_addarg().
Fixing a bug which bentley@ found in fonts(7).

Modified Files:
--------------
    docbook2mdoc:
        macro.c
        macro.h

Revision Data
-------------
Index: macro.h
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/macro.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lmacro.h -Lmacro.h -u -p -r1.7 -r1.8
--- macro.h
+++ macro.h
@@ -44,10 +44,11 @@ struct	format {
 	enum parastate	 parastate;
 };
 
-#define	ARG_SPACE	1  /* Insert whitespace before this argument. */
-#define	ARG_SINGLE	2  /* Quote argument if it contains whitespace. */
-#define	ARG_QUOTED	4  /* We are already in a quoted argument. */
-#define	ARG_UPPER	8  /* Covert argument to upper case. */
+#define	ARG_SPACE	(1 << 0)  /* Insert whitespace before this argument. */
+#define	ARG_SINGLE	(1 << 1)  /* Quote arg if it contains whitespace. */
+#define	ARG_QUOTED	(1 << 2)  /* We are already in a quoted argument. */
+#define	ARG_RAW		(1 << 3)  /* Skip macro and backslash escaping. */
+#define	ARG_UPPER	(1 << 4)  /* Convert argument to upper case. */
 
 
 void	 macro_open(struct format *, const char *);
Index: macro.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/macro.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lmacro.c -Lmacro.c -u -p -r1.20 -r1.21
--- macro.c
+++ macro.c
@@ -130,6 +130,13 @@ macro_addarg(struct format *f, const cha
 			flags &= ~ ARG_SPACE;
 		}
 
+		/* For XML entities, skip escaping. */
+
+		if (flags & ARG_RAW) {
+			fputs(arg, stdout);
+			break;
+		}
+
 		/* Escape us if we look like a macro. */
 
 		if ((flags & (ARG_QUOTED | ARG_UPPER)) == 0 &&
@@ -186,10 +193,16 @@ macro_addnode(struct format *f, struct p
 	    TAILQ_NEXT(nc, child) == NULL)
 		n = nc;
 
-	if (n->node == NODE_TEXT || n->node == NODE_ESCAPE) {
+	switch (n->node) {
+	case NODE_ESCAPE:
+		flags |= ARG_RAW;
+		/* FALLTHROUGH */
+	case NODE_TEXT:
 		macro_addarg(f, n->b, flags);
 		f->parastate = PARA_MID;
 		return;
+	default:
+		break;
 	}
 
 	/*
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

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

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-20 20:08 docbook2mdoc: When rendering XML entities, skip escaping in schwarze

source@mandoc.bsd.lv

Archives are clonable: git clone --mirror http://inbox.vuxu.org/mandoc-source

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git