source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Allow RS/RE blocks to nest.
@ 2011-06-18 17:36 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-06-18 17:36 UTC (permalink / raw)
  To: source

Log Message:
-----------
Allow RS/RE blocks to nest.  This requires first the syntax tree to
accomodate for the fix, then for the front-ends.  -T[x]html accepted the
syntax tree natively, but -Tascii had to use relative offsets.  It's
quite a simple fix.

From a TODO by {dcoppa,dsoares}@openbsd.

Modified Files:
--------------
    mdocml:
        TODO
        man_macro.c
        man_term.c

Revision Data
-------------
Index: man_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_term.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -Lman_term.c -Lman_term.c -u -p -r1.109 -r1.110
--- man_term.c
+++ man_term.c
@@ -791,13 +791,12 @@ post_SH(DECL_ARGS)
 	}
 }
 
-
 /* ARGSUSED */
 static int
 pre_RS(DECL_ARGS)
 {
-	const struct man_node	*nn;
-	int			 ival;
+	int		 ival;
+	size_t		 sz;
 
 	switch (n->type) {
 	case (MAN_BLOCK):
@@ -809,40 +808,44 @@ pre_RS(DECL_ARGS)
 		break;
 	}
 
-	if (NULL == (nn = n->parent->head->child)) {
-		mt->offset = mt->lmargin + term_len(p, INDENT);
-		p->offset = mt->offset;
-		return(1);
-	}
+	sz = term_len(p, INDENT);
 
-	if ((ival = a2width(p, nn->string)) < 0)
-		return(1);
+	if (NULL != (n = n->parent->head->child))
+		if ((ival = a2width(p, n->string)) >= 0) 
+			sz = (size_t)ival;
 
-	mt->offset = term_len(p, INDENT) + (size_t)ival;
+	mt->offset += sz;
 	p->offset = mt->offset;
 
 	return(1);
 }
 
-
 /* ARGSUSED */
 static void
 post_RS(DECL_ARGS)
 {
+	int		 ival;
+	size_t		 sz;
 
 	switch (n->type) {
 	case (MAN_BLOCK):
-		mt->offset = mt->lmargin = term_len(p, INDENT);
-		break;
+		return;
 	case (MAN_HEAD):
-		break;
+		return;
 	default:
 		term_newln(p);
-		p->offset = term_len(p, INDENT);
 		break;
 	}
-}
 
+	sz = term_len(p, INDENT);
+
+	if (NULL != (n = n->parent->head->child)) 
+		if ((ival = a2width(p, n->string)) >= 0) 
+			sz = (size_t)ival;
+
+	mt->offset = mt->offset < sz ?  0 : mt->offset - sz;
+	p->offset = mt->offset;
+}
 
 static void
 print_man_node(DECL_ARGS)
Index: TODO
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/TODO,v
retrieving revision 1.111
retrieving revision 1.112
diff -LTODO -LTODO -u -p -r1.111 -r1.112
--- TODO
+++ TODO
@@ -120,11 +120,6 @@
 
 --- missing man features -----------------------------------------------
 
-- .RS/.RE can be nested, see e.g. the x11/fluxbox manuals
-  noticed by dcoppa@  Wed, Apr 13, 2011 at 04:58:14PM +0200:
-  also affects p5-Net-SFTP-Foreign-1.65
-  as reported by gsoares@  Wed, 18 May 2011 09:59:06 -0300
-
 - groff an-ext.tmac macros (.UR, .UE) occur in xine(5)
   reported by brad@  Sat, 15 Jan 2011 15:45:23 -0500
 
Index: man_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_macro.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -Lman_macro.c -Lman_macro.c -u -p -r1.62 -r1.63
--- man_macro.c
+++ man_macro.c
@@ -307,11 +307,6 @@ blk_exp(MACRO_PROT_ARGS)
 	 * anywhere.
 	 */
 
-	if ( ! rew_scope(MAN_BODY, m, tok))
-		return(0);
-	if ( ! rew_scope(MAN_BLOCK, m, tok))
-		return(0);
-
 	if ( ! man_block_alloc(m, line, ppos, tok))
 		return(0);
 	if ( ! man_head_alloc(m, line, ppos, tok))
--
 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:[~2011-06-18 17:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-18 17:36 mdocml: Allow RS/RE blocks to nest kristaps

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