source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Oops, i forgot to adjust this file to the changes in roff.h rev.
Date: Thu, 3 Jan 2019 22:18:06 -0500 (EST)	[thread overview]
Message-ID: <05f951a9f009d68a@fantadrom.bsd.lv> (raw)

Log Message:
-----------
Oops, i forgot to adjust this file to the changes in roff.h rev. 1.67.
Provide a handler for the new .nf and .fi roff(7) request nodes,
avoiding a potential crash, and correctly restore the former fill
more at .Ed even when there was .nf or .fi inside the block.

Modified Files:
--------------
    mandoc:
        mdoc_man.c

Revision Data
-------------
Index: mdoc_man.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_man.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.131 -r1.132
--- mdoc_man.c
+++ mdoc_man.c
@@ -1,6 +1,6 @@
 /*	$Id$ */
 /*
- * Copyright (c) 2011-2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011-2019 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -104,6 +104,7 @@ static	int	  pre_lk(DECL_ARGS);
 static	int	  pre_li(DECL_ARGS);
 static	int	  pre_nm(DECL_ARGS);
 static	int	  pre_no(DECL_ARGS);
+static	void	  pre_noarg(DECL_ARGS);
 static	int	  pre_ns(DECL_ARGS);
 static	void	  pre_onearg(DECL_ARGS);
 static	int	  pre_pp(DECL_ARGS);
@@ -128,9 +129,11 @@ static	void	  print_node(DECL_ARGS);
 static const void_fp roff_man_acts[ROFF_MAX] = {
 	pre_br,		/* br */
 	pre_onearg,	/* ce */
+	pre_noarg,	/* fi */
 	pre_ft,		/* ft */
 	pre_onearg,	/* ll */
 	pre_onearg,	/* mc */
+	pre_noarg,	/* nf */
 	pre_onearg,	/* po */
 	pre_onearg,	/* rj */
 	pre_sp,		/* sp */
@@ -936,7 +939,6 @@ post_aq(DECL_ARGS)
 static int
 pre_bd(DECL_ARGS)
 {
-
 	outflags &= ~(MMAN_PP | MMAN_sp | MMAN_br);
 
 	if (DISP_unfilled == n->norm->Bd.type ||
@@ -951,12 +953,27 @@ pre_bd(DECL_ARGS)
 static void
 post_bd(DECL_ARGS)
 {
+	enum roff_tok	 bef, now;
 
 	/* Close out this display. */
 	print_line(".RE", MMAN_nl);
-	if (DISP_unfilled == n->norm->Bd.type ||
-	    DISP_literal  == n->norm->Bd.type)
-		print_line(".fi", MMAN_nl);
+	bef = n->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi;
+	if (n->last == NULL)
+		now = n->norm->Bd.type == DISP_unfilled ||
+		    n->norm->Bd.type == DISP_literal ? ROFF_nf : ROFF_fi;
+	else if (n->last->tok == ROFF_nf)
+		now = ROFF_nf;
+	else if (n->last->tok == ROFF_fi)
+		now = ROFF_fi;
+	else
+		now = n->last->flags & NODE_NOFILL ? ROFF_nf : ROFF_fi;
+	if (bef != now) {
+		outflags |= MMAN_nl;
+		print_word(".");
+		outflags &= ~MMAN_spc;
+		print_word(roff_name[bef]);
+		outflags |= MMAN_nl;
+	}
 
 	/* Maybe we are inside an enclosing list? */
 	if (NULL != n->parent->next)
@@ -1607,7 +1624,6 @@ pre_onearg(DECL_ARGS)
 static int
 pre_li(DECL_ARGS)
 {
-
 	font_push('R');
 	return 1;
 }
@@ -1640,7 +1656,6 @@ pre_nm(DECL_ARGS)
 static void
 post_nm(DECL_ARGS)
 {
-
 	switch (n->type) {
 	case ROFFT_BLOCK:
 		outflags &= ~MMAN_Bk;
@@ -1658,15 +1673,23 @@ post_nm(DECL_ARGS)
 static int
 pre_no(DECL_ARGS)
 {
-
 	outflags |= MMAN_spc_force;
 	return 1;
 }
 
+static void
+pre_noarg(DECL_ARGS)
+{
+	outflags |= MMAN_nl;
+	print_word(".");
+	outflags &= ~MMAN_spc;
+	print_word(roff_name[n->tok]);
+	outflags |= MMAN_nl;
+}
+
 static int
 pre_ns(DECL_ARGS)
 {
-
 	outflags &= ~MMAN_spc;
 	return 0;
 }
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

                 reply	other threads:[~2019-01-04  3:18 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=05f951a9f009d68a@fantadrom.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.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).