source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: docbook2mdoc: handle file inclusion via "<!ENTITY %"
Date: Tue, 23 Apr 2019 10:47:53 -0500 (EST)	[thread overview]
Message-ID: <e3fe64b6ad14ffb0@fantadrom.bsd.lv> (raw)

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

                 reply	other threads:[~2019-04-23 15:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e3fe64b6ad14ffb0@fantadrom.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).