source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Polish -Tman .Rs support.
@ 2012-07-11 23:46 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2012-07-11 23:46 UTC (permalink / raw)
  To: source

Log Message:
-----------
Polish -Tman .Rs support.
All mdoc(7) macros are now supported by -Tman.
OpenBSD rev. 1.32

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.33
retrieving revision 1.34
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.33 -r1.34
--- mdoc_man.c
+++ mdoc_man.c
@@ -43,6 +43,7 @@ static	int	  cond_body(DECL_ARGS);
 static	int	  cond_head(DECL_ARGS);
 static  void	  font_push(char);
 static	void	  font_pop(void);
+static	void	  post__t(DECL_ARGS);
 static	void	  post_bd(DECL_ARGS);
 static	void	  post_bf(DECL_ARGS);
 static	void	  post_bk(DECL_ARGS);
@@ -65,6 +66,7 @@ static	void	  post_pf(DECL_ARGS);
 static	void	  post_sect(DECL_ARGS);
 static	void	  post_sp(DECL_ARGS);
 static	void	  post_vt(DECL_ARGS);
+static	int	  pre__t(DECL_ARGS);
 static	int	  pre_an(DECL_ARGS);
 static	int	  pre_ap(DECL_ARGS);
 static	int	  pre_bd(DECL_ARGS);
@@ -90,6 +92,7 @@ static	int	  pre_nm(DECL_ARGS);
 static	int	  pre_no(DECL_ARGS);
 static	int	  pre_ns(DECL_ARGS);
 static	int	  pre_pp(DECL_ARGS);
+static	int	  pre_rs(DECL_ARGS);
 static	int	  pre_sm(DECL_ARGS);
 static	int	  pre_sp(DECL_ARGS);
 static	int	  pre_sect(DECL_ARGS);
@@ -152,17 +155,17 @@ static	const struct manact manacts[MDOC_
 	{ NULL, pre_em, post_font, NULL, NULL }, /* Va */
 	{ NULL, pre_vt, post_vt, NULL, NULL }, /* Vt */
 	{ NULL, pre_xr, NULL, NULL, NULL }, /* Xr */
-	{ NULL, NULL, post_percent, NULL, NULL }, /* _%A */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _%B */
-	{ NULL, NULL, post_percent, NULL, NULL }, /* _%D */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _%I */
-	{ NULL, pre_enc, post_percent, "\\fI", "\\fP" }, /* %J */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _%N */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _%O */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _%P */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _%R */
-	{ NULL, pre_enc, post_percent, "\"", "\"" }, /* %T */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _%V */
+	{ NULL, NULL, post_percent, NULL, NULL }, /* %A */
+	{ NULL, pre_em, post_percent, NULL, NULL }, /* %B */
+	{ NULL, NULL, post_percent, NULL, NULL }, /* %D */
+	{ NULL, pre_em, post_percent, NULL, NULL }, /* %I */
+	{ NULL, pre_em, post_percent, NULL, NULL }, /* %J */
+	{ NULL, NULL, post_percent, NULL, NULL }, /* %N */
+	{ NULL, NULL, post_percent, NULL, NULL }, /* %O */
+	{ NULL, NULL, post_percent, NULL, NULL }, /* %P */
+	{ NULL, NULL, post_percent, NULL, NULL }, /* %R */
+	{ NULL, pre__t, post__t, NULL, NULL }, /* %T */
+	{ NULL, NULL, post_percent, NULL, NULL }, /* %V */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Ac */
 	{ cond_body, pre_enc, post_enc, "<", ">" }, /* Ao */
 	{ cond_body, pre_enc, post_enc, "<", ">" }, /* Aq */
@@ -196,7 +199,7 @@ static	const struct manact manacts[MDOC_
 	{ cond_body, pre_enc, post_enc, "\"", "\"" }, /* Qo */
 	{ cond_body, pre_enc, post_enc, "\"", "\"" }, /* Qq */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Re */
-	{ cond_body, pre_pp, NULL, NULL, NULL }, /* Rs */
+	{ cond_body, pre_rs, NULL, NULL, NULL }, /* Rs */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Sc */
 	{ cond_body, pre_enc, post_enc, "`", "'" }, /* So */
 	{ cond_body, pre_enc, post_enc, "`", "'" }, /* Sq */
@@ -205,8 +208,8 @@ static	const struct manact manacts[MDOC_
 	{ NULL, pre_sy, post_font, NULL, NULL }, /* Sy */
 	{ NULL, pre_li, post_font, NULL, NULL }, /* Tn */
 	{ NULL, pre_ux, NULL, "UNIX", NULL }, /* Ux */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _Xc */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _Xo */
+	{ NULL, NULL, NULL, NULL, NULL }, /* Xc */
+	{ NULL, NULL, NULL, NULL, NULL }, /* Xo */
 	{ NULL, pre_fo, post_fo, NULL, NULL }, /* Fo */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Fc */
 	{ cond_body, pre_enc, post_enc, "[", "]" }, /* Oo */
@@ -224,15 +227,15 @@ static	const struct manact manacts[MDOC_
 	{ cond_body, pre_enc, post_enc, "{", "}" }, /* Brq */
 	{ cond_body, pre_enc, post_enc, "{", "}" }, /* Bro */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Brc */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _%C */
+	{ NULL, NULL, post_percent, NULL, NULL }, /* %C */
 	{ NULL, NULL, NULL, NULL, NULL }, /* Es */
 	{ NULL, NULL, NULL, NULL, NULL }, /* En */
 	{ NULL, pre_ux, NULL, "DragonFly", NULL }, /* Dx */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _%Q */
+	{ NULL, NULL, post_percent, NULL, NULL }, /* %Q */
 	{ NULL, pre_br, NULL, NULL, NULL }, /* br */
 	{ NULL, pre_sp, post_sp, NULL, NULL }, /* sp */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _%U */
-	{ NULL, NULL, NULL, NULL, NULL }, /* _Ta */
+	{ NULL, NULL, post_percent, NULL, NULL }, /* %U */
+	{ NULL, NULL, NULL, NULL, NULL }, /* Ta */
 	{ NULL, NULL, NULL, NULL, NULL }, /* ROOT */
 };
 
@@ -539,24 +542,49 @@ post_font(DECL_ARGS)
 	font_pop();
 }
 
-/*
- * Used in listings (percent = %A, e.g.).
- * FIXME: this is incomplete. 
- * It doesn't print a nice ", and" for lists.
- */
 static void
 post_percent(DECL_ARGS)
 {
 
-	post_enc(m, n);
-	if (n->next)
+	if (pre_em == manacts[n->tok].pre)
+		font_pop();
+	if (n->next) {
 		print_word(",");
-	else {
+		if (n->prev &&	n->prev->tok == n->tok &&
+				n->next->tok == n->tok)
+			print_word("and");
+	} else {
 		print_word(".");
 		outflags |= MMAN_nl;
 	}
 }
 
+static int
+pre__t(DECL_ARGS)
+{
+
+        if (n->parent && MDOC_Rs == n->parent->tok &&
+                        n->parent->norm->Rs.quote_T) {
+		print_word("\"");
+		outflags &= ~MMAN_spc;
+	} else
+		font_push('I');
+	return(1);
+}
+
+static void
+post__t(DECL_ARGS)
+{
+
+        if (n->parent && MDOC_Rs == n->parent->tok &&
+                        n->parent->norm->Rs.quote_T) {
+		outflags &= ~MMAN_spc;
+		print_word("\"");
+	} else
+		font_pop();
+	post_percent(m, n);
+}
+
 /*
  * Print before a section header.
  */
@@ -1225,7 +1253,19 @@ pre_pp(DECL_ARGS)
 	else
 		print_word(".PP");
 	outflags |= MMAN_nl;
-	return(MDOC_Rs == n->tok);
+	return(0);
+}
+
+static int
+pre_rs(DECL_ARGS)
+{
+
+	if (SEC_SEE_ALSO == n->sec) {
+		outflags |= MMAN_nl;
+		print_word(".PP");
+		outflags |= MMAN_nl;
+	}
+	return(1);
 }
 
 static int
--
 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-11 23:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-11 23:46 mdocml: Polish -Tman .Rs support 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).