tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: Stephen Gregoratto <dev@sgregoratto.me>
Cc: tech@mandoc.bsd.lv
Subject: Re: Parsing errors, output regressions with new XML parser
Date: Tue, 2 Apr 2019 15:16:42 +0200	[thread overview]
Message-ID: <20190402131642.GC6369@athene.usta.de> (raw)
In-Reply-To: <20190330001919.rrbc2xxrx47upalg@BlackBox>

Hi Stephen,

Stephen Gregoratto wrote on Sat, Mar 30, 2019 at 11:19:19AM +1100:

> -  XML comments aren't ignored.

Most comments were already ignored.
However...

>    This leads to documents like these[1] 
>    being formatted as one loooong section under NAME.
> [1] https://gitlab.gnome.org/GNOME/gtk/blob/master/docs/reference/gtk/css-overview.xml#L20

... you have a point here.  If a comment contains a greater-than sign,
than was mistaken as the end of the comment.

Fixed with the commit below.

Thanks for the report,
  Ingo


Log Message:
-----------
skip XML comments even if they contain greater-than characters;
issue reported by Stephen Gregoratto <dev at sgregoratto dot me>

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

Revision Data
-------------
Index: parse.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/parse.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -Lparse.c -Lparse.c -u -p -r1.7 -r1.8
--- parse.c
+++ parse.c
@@ -522,6 +522,7 @@ struct ptree *
 parse_file(struct parse *p, int fd, const char *fname)
 {
 	char		 b[4096];
+	char		*cp;
 	ssize_t		 rsz;	/* Return value from read(2). */
 	size_t		 rlen;  /* Number of bytes in b[]. */
 	size_t		 poff;  /* Parse offset in b[]. */
@@ -647,6 +648,29 @@ parse_file(struct parse *p, int fd, cons
 				if (advance(p, b, rlen, &pend, " >") &&
 				    rsz > 0)
 					break;
+				if (pend > poff + 3 &&
+				    strncmp(b + poff, "<!--", 4) == 0) {
+
+					/* Skip a comment. */
+
+					cp = strstr(b + pend - 2, "-->");
+					if (cp == NULL) {
+						if (rsz > 0) {
+							pend = rlen;
+							break;
+						}
+						cp = b + rlen;
+					} else
+						cp += 3;
+					while (b + pend < cp) {
+						if (b[++pend] == '\n') {
+							p->nline++;
+							p->ncol = 1;
+						} else
+							p->ncol++;
+					}
+					continue;
+				}
 				elem_end = 0;
 				if (b[pend] != '>')
 					in_tag = 1;
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

--
 To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv

  reply	other threads:[~2019-04-02 13:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-30  0:19 Stephen Gregoratto
2019-04-02 13:16 ` Ingo Schwarze [this message]
2019-04-02 16:02 ` Ingo Schwarze
2019-04-02 16:50 ` Ingo Schwarze
2019-04-02 17:20 ` Ingo Schwarze
2019-04-02 17:48 ` Ingo Schwarze

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=20190402131642.GC6369@athene.usta.de \
    --to=schwarze@usta.de \
    --cc=dev@sgregoratto.me \
    --cc=tech@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).