source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Do not crash in -Tman on: * .Fn with exactly one argument * .Bl
@ 2012-07-12  8:55 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2012-07-12  8:55 UTC (permalink / raw)
  To: source

Log Message:
-----------
Do not crash in -Tman on:
* .Fn with exactly one argument
* .Bl -hang without a -width 
Now all 3776 OpenBSD base manuals build without crashing.
OpenBSD rev. 1.33

Modified Files:
--------------
    mdocml:
        mdoc_man.c

Revision Data
-------------
Index: mdoc_man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_man.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.34 -r1.35
--- mdoc_man.c
+++ mdoc_man.c
@@ -103,7 +103,8 @@ static	int	  pre_ux(DECL_ARGS);
 static	int	  pre_xr(DECL_ARGS);
 static	void	  print_word(const char *);
 static	void	  print_offs(const char *);
-static	void	  print_width(const char *, const struct mdoc_node *);
+static	void	  print_width(const char *,
+				const struct mdoc_node *, size_t);
 static	void	  print_count(int *);
 static	void	  print_node(DECL_ARGS);
 
@@ -363,7 +364,7 @@ print_offs(const char *v)
 }
 
 void
-print_width(const char *v, const struct mdoc_node *child)
+print_width(const char *v, const struct mdoc_node *child, size_t defsz)
 {
 	char		  buf[24];
 	struct roffsu	  su;
@@ -373,7 +374,9 @@ print_width(const char *v, const struct 
 	chsz = (NULL != child && MDOC_TEXT == child->type) ?
 			strlen(child->string) : 0;
 
-	if (a2roffsu(v, &su, SCALE_MAX)) {
+	if (NULL == v)
+		sz = defsz;
+	else if (a2roffsu(v, &su, SCALE_MAX)) {
 		if (SCALE_EN == su.unit)
 			sz = su.scale;
 		else {
@@ -962,7 +965,11 @@ pre_fn(DECL_ARGS)
 	outflags &= ~MMAN_spc;
 	print_word("(");
 	outflags &= ~MMAN_spc;
-	return(pre_fa(m, n->next));
+
+	n = n->next;
+	if (NULL != n)
+		pre_fa(m, n);
+	return(0);
 }
 
 static void
@@ -1092,7 +1099,7 @@ pre_it(DECL_ARGS)
 		case (LIST_dash):
 			/* FALLTHROUGH */
 		case (LIST_hyphen):
-			print_width(bln->norm->Bl.width, NULL);
+			print_width(bln->norm->Bl.width, NULL, 0);
 			outflags |= MMAN_nl;
 			font_push('B');
 			if (LIST_bullet == bln->norm->Bl.type)
@@ -1102,15 +1109,15 @@ pre_it(DECL_ARGS)
 			font_pop();
 			break;
 		case (LIST_enum):
-			print_width(bln->norm->Bl.width, NULL);
+			print_width(bln->norm->Bl.width, NULL, 0);
 			outflags |= MMAN_nl;
 			print_count(&bln->norm->Bl.count);
 			break;
 		case (LIST_hang):
-			print_width(bln->norm->Bl.width, n->child);
+			print_width(bln->norm->Bl.width, n->child, 6);
 			break;
 		case (LIST_tag):
-			print_width(bln->norm->Bl.width, NULL);
+			print_width(bln->norm->Bl.width, NULL, 8);
 			break;
 		default:
 			return(1);
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-07-12  8:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-12  8:55 mdocml: Do not crash in -Tman on: * .Fn with exactly one argument * .Bl schwarze

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).