source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* docbook2mdoc: handle file inclusion via "<!ENTITY %"
@ 2019-04-23 15:47 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-23 15:47 UTC (permalink / raw)
  To: source

Log Message:
-----------
handle file inclusion via "<!ENTITY %"

Modified Files:
--------------
    docbook2mdoc:
        docbook2mdoc.1
        parse.c

Revision Data
-------------
Index: docbook2mdoc.1
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/docbook2mdoc.1,v
retrieving revision 1.12
retrieving revision 1.13
diff -Ldocbook2mdoc.1 -Ldocbook2mdoc.1 -u -p -r1.12 -r1.13
--- docbook2mdoc.1
+++ docbook2mdoc.1
@@ -101,6 +101,16 @@ Internal subset declaration to define an
 .Ec >
 Internal subset declaration to define an XML entity using an external
 .Ar file .
+.It Eo <!
+.Ic DOCTYPE No ...
+.Bo
+.Eo " <!" Ic ENTITY No % Ar name Cm SYSTEM Qo Ar file Qc Ec >
+.Pf % Ar name No \&
+.Bc
+.Ec >
+Internal subset declaration to include an external
+.Ar file
+that is supposed to contain entity declarations.
 .It Eo < Ic mml : Ns ... Ec >
 Elements from the MathML namespace.
 These are translated to
Index: parse.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/parse.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -Lparse.c -Lparse.c -u -p -r1.49 -r1.50
--- parse.c
+++ parse.c
@@ -638,6 +638,7 @@ xml_elem_end(struct parse *p, const char
 	if (p->del == 0)
 		pnode_closetext(p, 0);
 
+	n = p->cur;
 	node = name == NULL ? p->ncur : xml_name2node(p, name);
 
 	switch (node) {
@@ -650,8 +651,7 @@ xml_elem_end(struct parse *p, const char
 	case NODE_UNKNOWN:
 		break;
 	case NODE_INCLUDE:
-		n = p->cur;
-		p->cur = p->cur->parent;
+		p->cur = n->parent;
 		cp = pnode_getattr_raw(n, ATTRKEY_HREF, NULL);
 		if (cp == NULL)
 			error_msg(p, "<xi:include> element "
@@ -667,7 +667,7 @@ xml_elem_end(struct parse *p, const char
 		p->flags &= ~PFLAG_EEND;
 		/* FALLTHROUGH */
 	default:
-		if (p->cur == NULL || node != p->cur->node) {
+		if (n == NULL || node != n->node) {
 			warn_msg(p, "element not open: </%s>", name);
 			break;
 		}
@@ -681,13 +681,21 @@ xml_elem_end(struct parse *p, const char
 		 * obviously better than discarding it or crashing.
 		 */
 
-		if (p->cur->parent != NULL || node == NODE_DOCTYPE) {
-			p->cur = p->cur->parent;
+		if (n->parent != NULL || node == NODE_DOCTYPE) {
+			p->cur = n->parent;
 			if (p->cur != NULL)
 				p->ncur = p->cur->node;
 		} else
 			p->tree->flags |= TREE_CLOSED;
 		p->flags &= ~PFLAG_SPC;
+
+		/* Include a file containing entity declarations. */
+
+		if (node == NODE_ENTITY && strcmp("%",
+		    pnode_getattr_raw(n, ATTRKEY_NAME, "")) == 0 &&
+		    (cp = pnode_getattr_raw(n, ATTRKEY_SYSTEM, NULL)) != NULL)
+			parse_file(p, -1, cp);
+
 		break;
 	}
 	assert(p->del == 0);
--
 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-23 15:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23 15:47 docbook2mdoc: handle file inclusion via "<!ENTITY %" 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).