source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Use correct column of warning messages and make sure this
Date: Tue, 26 Jul 2011 10:24:06 -0400 (EDT)	[thread overview]
Message-ID: <201107261424.p6QEO610026800@krisdoz.my.domain> (raw)

Log Message:
-----------
Use correct column of warning messages and make sure this function is
run even when `first_string' isn't defined.

Modified Files:
--------------
    mdocml:
        roff.c

Revision Data
-------------
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.152
retrieving revision 1.153
diff -Lroff.c -Lroff.c -u -p -r1.152 -r1.153
--- roff.c
+++ roff.c
@@ -395,12 +395,12 @@ roff_alloc(struct mparse *parse)
 	return(r);
 }
 
-
 /*
  * Pre-filter each and every line for reserved words (one beginning with
  * `\*', e.g., `\*(ab').  These must be handled before the actual line
  * is processed. 
- */
+ * This also checks the syntax of regular escapes.
+*/
 static int
 roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)
 {
@@ -433,9 +433,10 @@ roff_res(struct roff *r, char **bufp, si
 			esc = mandoc_escape(&cp, NULL, NULL);
 			if (ESCAPE_ERROR != esc)
 				continue;
-			mandoc_msg(MANDOCERR_BADESCAPE, 
-					r->parse, ln, pos, NULL);
 			cp = res;
+			mandoc_msg
+				(MANDOCERR_BADESCAPE, r->parse, 
+				 ln, (int)(stesc - *bufp), NULL);
 			continue;
 		}
 
@@ -467,8 +468,13 @@ roff_res(struct roff *r, char **bufp, si
 		/* Advance to the end of the name. */
 
 		for (i = 0; 0 == maxl || i < maxl; i++, cp++) {
-			if ('\0' == *cp)
-				return(1); /* Error. */
+			if ('\0' == *cp) {
+				mandoc_msg
+					(MANDOCERR_BADESCAPE, 
+					 r->parse, ln, 
+					 (int)(stesc - *bufp), NULL);
+				return(1); 
+			}
 			if (0 == maxl && ']' == *cp)
 				break;
 		}
@@ -481,8 +487,9 @@ roff_res(struct roff *r, char **bufp, si
 		res = roff_getstrn(r, stnam, (size_t)i);
 
 		if (NULL == res) {
-			/* TODO: keep track of the correct position. */
-			mandoc_msg(MANDOCERR_BADESCAPE, r->parse, ln, pos, NULL);
+			mandoc_msg
+				(MANDOCERR_BADESCAPE, r->parse, 
+				 ln, (int)(stesc - *bufp), NULL);
 			res = "";
 		}
 
@@ -505,7 +512,6 @@ roff_res(struct roff *r, char **bufp, si
 	return(1);
 }
 
-
 enum rofferr
 roff_parseln(struct roff *r, int ln, char **bufp, 
 		size_t *szp, int pos, int *offs)
@@ -519,7 +525,7 @@ roff_parseln(struct roff *r, int ln, cha
 	 * words to fill in.
 	 */
 
-	if (r->first_string && ! roff_res(r, bufp, szp, ln, pos))
+	if ( ! roff_res(r, bufp, szp, ln, pos))
 		return(ROFF_REPARSE);
 
 	ppos = pos;
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2011-07-26 14:24 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=201107261424.p6QEO610026800@krisdoz.my.domain \
    --to=kristaps@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).