source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Fix handling of paragraph macros inside lists: * When they are
@ 2012-07-18 11:11 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2012-07-18 11:11 UTC (permalink / raw)
  To: source

Log Message:
-----------
Fix handling of paragraph macros inside lists:
* When they are trailing the last item, move them outside the list.
* When they are trailing any other none-compact item, drop them.

OpenBSD rev. mdoc_validate.c 1.107, mdoc.c 1.91

Modified Files:
--------------
    mdocml:
        TODO
        libmdoc.h
        mandoc.h
        mdoc.c
        mdoc_validate.c
        read.c

Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.188
retrieving revision 1.189
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.188 -r1.189
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -1353,7 +1353,7 @@ post_it(POST_ARGS)
 static int
 post_bl_block(POST_ARGS) 
 {
-	struct mdoc_node *n;
+	struct mdoc_node *n, *ni, *nc;
 
 	/*
 	 * These are fairly complicated, so we've broken them into two
@@ -1369,13 +1369,42 @@ post_bl_block(POST_ARGS) 
 			NULL == n->norm->Bl.width) {
 		if ( ! post_bl_block_tag(mdoc))
 			return(0);
+		assert(n->norm->Bl.width);
 	} else if (NULL != n->norm->Bl.width) {
 		if ( ! post_bl_block_width(mdoc))
 			return(0);
-	} else 
-		return(1);
+		assert(n->norm->Bl.width);
+	}
 
-	assert(n->norm->Bl.width);
+	for (ni = n->body->child; ni; ni = ni->next) {
+		if (NULL == ni->body)
+			continue;
+		nc = ni->body->last;
+		while (NULL != nc) {
+			switch (nc->tok) {
+			case (MDOC_Pp):
+				/* FALLTHROUGH */
+			case (MDOC_Lp):
+				/* FALLTHROUGH */
+			case (MDOC_br):
+				break;
+			default:
+				nc = NULL;
+				continue;
+			}
+			if (NULL == ni->next) {
+				mdoc_nmsg(mdoc, nc, MANDOCERR_MOVEPAR);
+				if ( ! mdoc_node_relink(mdoc, nc))
+					return(0);
+			} else if (0 == n->norm->Bl.comp &&
+			    LIST_column != n->norm->Bl.type) {
+				mdoc_nmsg(mdoc, nc, MANDOCERR_IGNPAR);
+				mdoc_node_delete(mdoc, nc);
+			} else
+				break;
+			nc = ni->body->last;
+		}
+	}
 	return(1);
 }
 
Index: TODO
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/TODO,v
retrieving revision 1.138
retrieving revision 1.139
diff -LTODO -LTODO -u -p -r1.138 -r1.139
--- TODO
+++ TODO
@@ -203,13 +203,6 @@
   is just "o\bo".
   see for example OpenBSD ksh(1)
 
-- A bogus .Pp between two .It must not produce a double blank line,
-  see between -R and -r in OpenBSD rm(1), before "update" in mount(8),
-  or in DIAGNOSTICS in init(8), or before "is always true" in ksh(1).
-  The same happens with .Pp just before .El, see bgpd.conf(5).
-  Also have `It' complain if `Pp' is invoked at certain times (not
-  -compact?).
-
 - .Pp between two .It in .Bl -column should produce one,
   not two blank lines, see e.g. login.conf(5).
   reported by jmc@  Sun, 17 Apr 2011 14:04:58 +0059
Index: libmdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmdoc.h,v
retrieving revision 1.79
retrieving revision 1.80
diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.79 -r1.80
--- libmdoc.h
+++ libmdoc.h
@@ -118,6 +118,7 @@ int		  mdoc_endbody_alloc(struct mdoc *m
 			enum mdoct tok, struct mdoc_node *body,
 			enum mdoc_endbody end);
 void		  mdoc_node_delete(struct mdoc *, struct mdoc_node *);
+int		  mdoc_node_relink(struct mdoc *, struct mdoc_node *);
 void		  mdoc_hash_init(void);
 enum mdoct	  mdoc_hash_find(const char *);
 const char	 *mdoc_a2att(const char *);
Index: mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v
retrieving revision 1.200
retrieving revision 1.201
diff -Lmdoc.c -Lmdoc.c -u -p -r1.200 -r1.201
--- mdoc.c
+++ mdoc.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012 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
@@ -646,6 +646,14 @@ mdoc_node_delete(struct mdoc *m, struct 
 
 	mdoc_node_unlink(m, p);
 	mdoc_node_free(p);
+}
+
+int
+mdoc_node_relink(struct mdoc *m, struct mdoc_node *p)
+{
+
+	mdoc_node_unlink(m, p);
+	return(node_append(m, p));
 }
 
 #if 0
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.103
retrieving revision 1.104
diff -Lmandoc.h -Lmandoc.h -u -p -r1.103 -r1.104
--- mandoc.h
+++ mandoc.h
@@ -68,6 +68,7 @@ enum	mandocerr {
 	/* related to macros and nesting */
 	MANDOCERR_MACROOBS, /* skipping obsolete macro */
 	MANDOCERR_IGNPAR, /* skipping paragraph macro */
+	MANDOCERR_MOVEPAR, /* moving paragraph macro out of list */
 	MANDOCERR_IGNNS, /* skipping no-space macro */
 	MANDOCERR_SCOPENEST, /* blocks badly nested */
 	MANDOCERR_CHILD, /* child violates parent syntax */
Index: read.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -Lread.c -Lread.c -u -p -r1.30 -r1.31
--- read.c
+++ read.c
@@ -113,6 +113,7 @@ static	const char * const	mandocerrs[MAN
 	/* related to macros and nesting */
 	"skipping obsolete macro",
 	"skipping paragraph macro",
+	"moving paragraph macro out of list",
 	"skipping no-space macro",
 	"blocks badly nested",
 	"child violates parent syntax",
--
 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-18 11:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-18 11:11 mdocml: Fix handling of paragraph macros inside lists: * When they are 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).