source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Ignore mdoc(7) and man(7) macros inside tbl(7) code because they
Date: Tue, 16 Dec 2014 18:44:42 -0500 (EST)	[thread overview]
Message-ID: <3668301787584140963.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Ignore mdoc(7) and man(7) macros inside tbl(7) code because they 
would abort the table in an unclean way, causing assertion failures
found by jsg@.

Modified Files:
--------------
    mdocml:
        mandoc.1
        mandoc.h
        read.c
        roff.c

Revision Data
-------------
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v
retrieving revision 1.176
retrieving revision 1.177
diff -Lmandoc.h -Lmandoc.h -u -p -r1.176 -r1.177
--- mandoc.h
+++ mandoc.h
@@ -144,6 +144,7 @@ enum	mandocerr {
 	MANDOCERR_TBLIGNDATA, /* ignore data in cell */
 	MANDOCERR_TBLBLOCK, /* data block still open */
 	MANDOCERR_TBLEXTRADAT, /* ignoring extra data cells */
+	MANDOCERR_TBLMACRO, /* ignoring macro in table: macro */
 
 	/* related to document structure and macros */
 	MANDOCERR_ROFFLOOP, /* input stack limit exceeded, infinite loop? */
Index: roff.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff.c,v
retrieving revision 1.242
retrieving revision 1.243
diff -Lroff.c -Lroff.c -u -p -r1.242 -r1.243
--- roff.c
+++ roff.c
@@ -730,6 +730,7 @@ roff_parseln(struct roff *r, int ln, str
 	enum rofft	 t;
 	enum rofferr	 e;
 	int		 pos;	/* parse point */
+	int		 spos;	/* saved parse point for messages */
 	int		 ppos;	/* original offset in buf->buf */
 	int		 ctl;	/* macro line (boolean) */
 
@@ -800,14 +801,28 @@ roff_parseln(struct roff *r, int ln, str
 		return((*roffs[t].sub)(r, t, buf, ln, ppos, pos, offs));
 	}
 
+	/* No scope is open.  This is a new request or macro. */
+
+	spos = pos;
+	t = roff_parse(r, buf->buf, &pos, ln, ppos);
+
+	/* Tables ignore most macros. */
+
+	if (r->tbl != NULL && (t == ROFF_MAX || t == ROFF_TS)) {
+		mandoc_msg(MANDOCERR_TBLMACRO, r->parse,
+		    ln, pos, buf->buf + spos);
+		return(ROFF_IGN);
+	}
+
 	/*
-	 * Lastly, as we've no scope open, try to look up and execute
-	 * the new macro.  If no macro is found, simply return and let
-	 * the compilers handle it.
+	 * This is neither a roff request nor a user-defined macro.
+	 * Let the standard macro set parsers handle it.
 	 */
 
-	if ((t = roff_parse(r, buf->buf, &pos, ln, ppos)) == ROFF_MAX)
+	if (t == ROFF_MAX)
 		return(ROFF_CONT);
+
+	/* Execute a roff request or a user defined macro. */
 
 	assert(roffs[t].proc);
 	return((*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs));
Index: read.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/read.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -Lread.c -Lread.c -u -p -r1.104 -r1.105
--- read.c
+++ read.c
@@ -188,6 +188,7 @@ static	const char * const	mandocerrs[MAN
 	"ignore data in cell",
 	"data block still open",
 	"ignoring extra data cells",
+	"ignoring macro in table",
 
 	/* related to document structure and macros */
 	"input stack limit exceeded, infinite loop?",
Index: mandoc.1
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.1,v
retrieving revision 1.128
retrieving revision 1.129
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.128 -r1.129
--- mandoc.1
+++ mandoc.1
@@ -1266,6 +1266,7 @@ keeps the code more readable.
 .It "ignore data in cell"
 .It "data block still open"
 .It "ignoring extra data cells"
+.It "ignoring macro in table"
 .El
 .Ss "Errors related to roff, mdoc, and man code"
 .Bl -ohang
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-12-16 23:44 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=3668301787584140963.enqueue@fantadrom.bsd.lv \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.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).