source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* docbook2mdoc: merge parse.c rev.
@ 2019-04-03  8:40 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-03  8:40 UTC (permalink / raw)
  To: source

Log Message:
-----------
merge parse.c rev. 1.8: skip XML comments containing greater-than characters

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

Revision Data
-------------
Index: statistics.c
===================================================================
RCS file: /home/cvs/mdocml/docbook2mdoc/statistics.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lstatistics.c -Lstatistics.c -u -p -r1.2 -r1.3
--- statistics.c
+++ statistics.c
@@ -165,6 +165,7 @@ static void
 parse_file(int fd, 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[]. */
@@ -232,6 +233,18 @@ parse_file(int fd, char *fname)
 			} else if (b[poff] == '<') {
 				if (advance(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) {
+						pend = rlen;
+						if (rsz > 0)
+							break;
+					} else
+						pend = cp + 3 - b;
+					continue;
+				}
 				elem_end = 0;
 				if (b[pend] != '>')
 					in_tag = 1;
--
 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-03  8:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03  8:40 docbook2mdoc: merge parse.c rev 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).