source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: If we have to reparse the text line because we spring an input
Date: Sat, 29 Aug 2015 18:56:31 -0500 (EST)	[thread overview]
Message-ID: <14341228515569865885.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
If we have to reparse the text line because we spring an input line trap,
we must not escape breakable hyphens yet, or mparse_buf_r() in read.c
will complain and replace the escaped hyphens with question marks.
Bug found in ocserv(8) following a report from Kurt Jaeger <pi at FreeBSD>.

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

Revision Data
-------------
Index: roff.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff.c,v
retrieving revision 1.274
retrieving revision 1.275
diff -Lroff.c -Lroff.c -u -p -r1.274 -r1.275
--- roff.c
+++ roff.c
@@ -1484,9 +1484,7 @@ roff_res(struct roff *r, struct buf *buf
 }
 
 /*
- * Process text streams:
- * Convert all breakable hyphens into ASCII_HYPH.
- * Decrement and spring input line trap.
+ * Process text streams.
  */
 static enum rofferr
 roff_parsetext(struct buf *buf, int pos, int *offs)
@@ -1497,6 +1495,22 @@ roff_parsetext(struct buf *buf, int pos,
 	int		 isz;
 	enum mandoc_esc	 esc;
 
+	/* Spring the input line trap. */
+
+	if (roffit_lines == 1) {
+		isz = mandoc_asprintf(&p, "%s\n.%s", buf->buf, roffit_macro);
+		free(buf->buf);
+		buf->buf = p;
+		buf->sz = isz + 1;
+		*offs = 0;
+		free(roffit_macro);
+		roffit_lines = 0;
+		return(ROFF_REPARSE);
+	} else if (roffit_lines > 1)
+		--roffit_lines;
+
+	/* Convert all breakable hyphens into ASCII_HYPH. */
+
 	start = p = buf->buf + pos;
 
 	while (*p != '\0') {
@@ -1525,19 +1539,6 @@ roff_parsetext(struct buf *buf, int pos,
 			*p = ASCII_HYPH;
 		p++;
 	}
-
-	/* Spring the input line trap. */
-	if (roffit_lines == 1) {
-		isz = mandoc_asprintf(&p, "%s\n.%s", buf->buf, roffit_macro);
-		free(buf->buf);
-		buf->buf = p;
-		buf->sz = isz + 1;
-		*offs = 0;
-		free(roffit_macro);
-		roffit_lines = 0;
-		return(ROFF_REPARSE);
-	} else if (roffit_lines > 1)
-		--roffit_lines;
 	return(ROFF_CONT);
 }
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2015-08-29 23:56 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=14341228515569865885.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).