* docbook2mdoc: skip XML comments even if they contain greater-than
@ 2019-04-02 13:11 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-04-02 13:11 UTC (permalink / raw)
To: source
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-04-02 13:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02 13:11 docbook2mdoc: skip XML comments even if they contain greater-than 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).