From: Kristaps Dzonsons <kristaps@bsd.lv>
Date: Tue, 14 Jul 2009 15:17:25 +0000 (+0000)
Subject: Removed unnecessary save/restore of style around list prefix.
X-Git-Tag: VERSION_1_8_0~6
X-Git-Url: https://git.cameronkatri.com/mandoc.git/commitdiff_plain/36612897332d39fea86a5e0ec1013a54aed57a32?ds=sidebyside

Removed unnecessary save/restore of style around list prefix.
Added -hang list support.
---

diff --git a/mdoc_term.c b/mdoc_term.c
index 08ae01d4..13aad112 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/*	$Id: mdoc_term.c,v 1.38 2009/07/13 07:23:07 kristaps Exp $ */
+/*	$Id: mdoc_term.c,v 1.39 2009/07/14 15:17:25 kristaps Exp $ */
 /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -700,7 +700,7 @@ termp_it_pre(DECL_ARGS)
 {
 	const struct mdoc_node *bl, *n;
 	char		        buf[7];
-	int		        i, type, keys[3], vals[3], sv;
+	int		        i, type, keys[3], vals[3];
 	size_t		        width, offset;
 
 	if (MDOC_BLOCK == node->type)
@@ -769,7 +769,9 @@ termp_it_pre(DECL_ARGS)
 			width = 5;
 		break;
 	case (MDOC_Hang):
-		/* FALLTHROUGH */
+		if (0 == width)
+			width = 8;
+		break;
 	case (MDOC_Tag):
 		if (0 == width)
 			width = 10;
@@ -787,8 +789,6 @@ termp_it_pre(DECL_ARGS)
 	case (MDOC_Diag):
 		term_word(p, "\\ ");
 		/* FALLTHROUGH */
-	case (MDOC_Hang):
-		/* FALLTHROUGH */
 	case (MDOC_Inset):
 		if (MDOC_BODY == node->type) 
 			p->flags &= ~TERMP_NOSPACE;
@@ -829,22 +829,30 @@ termp_it_pre(DECL_ARGS)
 	case (MDOC_Enum):
 		/* FALLTHROUGH */
 	case (MDOC_Hyphen):
-		/* FALLTHROUGH */
+		if (MDOC_HEAD == node->type)
+			p->flags |= TERMP_NOBREAK;
+		else
+			p->flags |= TERMP_NOLPAD;
+		break;
 	case (MDOC_Hang):
-		/* FALLTHROUGH */
-	case (MDOC_Tag):
 		if (MDOC_HEAD == node->type)
 			p->flags |= TERMP_NOBREAK;
 		else
 			p->flags |= TERMP_NOLPAD;
 
-		if (MDOC_HEAD == node->type && MDOC_Hang == type)
-			p->flags |= TERMP_NONOBREAK;
+		if (MDOC_HEAD == node->type)
+			p->flags |= TERMP_HANG;
+		break;
+	case (MDOC_Tag):
+		if (MDOC_HEAD == node->type)
+			p->flags |= TERMP_NOBREAK;
+		else
+			p->flags |= TERMP_NOLPAD;
 
-		if (MDOC_HEAD == node->type && MDOC_Tag == type)
-			if (NULL == node->next ||
-					NULL == node->next->child)
-				p->flags |= TERMP_NONOBREAK;
+		if (MDOC_HEAD != node->type)
+			break;
+		if (NULL == node->next || NULL == node->next->child)
+			p->flags |= TERMP_DANGLE;
 		break;
 	case (MDOC_Column):
 		if (MDOC_HEAD == node->type) {
@@ -902,18 +910,19 @@ termp_it_pre(DECL_ARGS)
 	 * HEAD character (temporarily bold, in some cases).  
 	 */
 
-	sv = p->flags;
 	if (MDOC_HEAD == node->type)
 		switch (type) {
 		case (MDOC_Bullet):
 			p->flags |= TERMP_BOLD;
 			term_word(p, "\\[bu]");
+			p->flags &= ~TERMP_BOLD;
 			break;
 		case (MDOC_Dash):
 			/* FALLTHROUGH */
 		case (MDOC_Hyphen):
 			p->flags |= TERMP_BOLD;
 			term_word(p, "\\(hy");
+			p->flags &= ~TERMP_BOLD;
 			break;
 		case (MDOC_Enum):
 			(pair->ppair->ppair->count)++;
@@ -925,8 +934,6 @@ termp_it_pre(DECL_ARGS)
 			break;
 		}
 
-	p->flags = sv; /* Restore saved flags. */
-
 	/* 
 	 * If we're not going to process our children, indicate so here.
 	 */