source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Add support for `ft' macro found in groff(7).
@ 2010-12-06 15:31 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-12-06 15:31 UTC (permalink / raw)
  To: source

Log Message:
-----------
Add support for `ft' macro found in groff(7).  Based on a patch by
schwarze@, but without the -T[x]html handling, which structurally does
not work.  Also add man.7 documentation (not in original patch).

Modified Files:
--------------
    mdocml:
        main.c
        man.7
        man.c
        man.h
        man_html.c
        man_macro.c
        man_term.c
        man_validate.c
        mandoc.h

Revision Data
-------------
Index: man.7
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.7,v
retrieving revision 1.90
retrieving revision 1.91
diff -Lman.7 -Lman.7 -u -p -r1.90 -r1.91
--- man.7
+++ man.7
@@ -414,7 +414,6 @@ The syntax is as follows:
 .It Sx \&I   Ta    n         Ta    next-line Ta    \&
 .It Sx \&IB  Ta    n         Ta    current   Ta    \&
 .It Sx \&IR  Ta    n         Ta    current   Ta    \&
-.\" .It Sx \&PD  Ta    n         Ta    current   Ta    compat
 .It Sx \&R   Ta    n         Ta    next-line Ta    \&
 .It Sx \&RB  Ta    n         Ta    current   Ta    \&
 .It Sx \&RI  Ta    n         Ta    current   Ta    \&
@@ -424,6 +423,7 @@ The syntax is as follows:
 .It Sx \&UC  Ta    <=1       Ta    current   Ta    \&
 .It Sx \&br  Ta    0         Ta    current   Ta    compat
 .It Sx \&fi  Ta    0         Ta    current   Ta    compat
+.It Sx \&ft  Ta    1         Ta    current   Ta    compat
 .It Sx \&i   Ta    n         Ta    current   Ta    compat
 .It Sx \&in  Ta    1         Ta    current   Ta    compat
 .It Sx \&na  Ta    0         Ta    current   Ta    compat
@@ -831,6 +831,11 @@ See also
 .Ss \&fi
 End literal mode begun by
 .Sx \&nf .
+.Ss \&ft
+Change the current font mode.
+See
+.Sx Text Decoration
+for a listing of available font modes.
 .Ss \&i
 Italicise arguments.
 Synonym for
Index: man_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_html.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -Lman_html.c -Lman_html.c -u -p -r1.49 -r1.50
--- man_html.c
+++ man_html.c
@@ -114,6 +114,7 @@ static	const struct htmlman mans[MAN_MAX
 	{ man_ign_pre, NULL }, /* PD */
 	{ man_ign_pre, NULL }, /* AT */
 	{ man_in_pre, NULL }, /* in */
+	{ man_in_pre, NULL }, /* ft */
 };
 
 
Index: man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -Lman.c -Lman.c -u -p -r1.90 -r1.91
--- man.c
+++ man.c
@@ -39,7 +39,7 @@ const	char *const __man_macronames[MAN_M
 	"RI",		"na",		"i",		"sp",
 	"nf",		"fi",		"r",		"RE",
 	"RS",		"DT",		"UC",		"PD",
-	"AT",		"in"
+	"AT",		"in",		"ft"
 	};
 
 const	char * const *man_macronames = __man_macronames;
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -Lmandoc.h -Lmandoc.h -u -p -r1.30 -r1.31
--- mandoc.h
+++ mandoc.h
@@ -66,6 +66,7 @@ enum	mandocerr {
 	MANDOCERR_ERROR, /* ===== start of errors ===== */
 	MANDOCERR_NAMESECFIRST, /* NAME section must come first */
 	MANDOCERR_BADBOOL, /* bad Boolean value */
+	MANDOCERR_BADFONT, /* unknown font */
 	MANDOCERR_CHILD, /* child violates parent syntax */
 	MANDOCERR_NESTEDDISP, /* displays may not be nested */
 	MANDOCERR_BADATT, /* bad AT&T symbol */
Index: main.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -Lmain.c -Lmain.c -u -p -r1.119 -r1.120
--- main.c
+++ main.c
@@ -144,6 +144,7 @@ static	const char * const	mandocerrs[MAN
 
 	"NAME section must come first",
 	"bad Boolean value",
+	"unknown font",
 	"child violates parent syntax",
 	"displays may not be nested",
 	"bad AT&T symbol",
Index: man_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_term.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -Lman_term.c -Lman_term.c -u -p -r1.88 -r1.89
--- man_term.c
+++ man_term.c
@@ -94,6 +94,7 @@ static	int		  pre_ign(DECL_ARGS);
 static	int		  pre_in(DECL_ARGS);
 static	int		  pre_literal(DECL_ARGS);
 static	int		  pre_sp(DECL_ARGS);
+static	int		  pre_ft(DECL_ARGS);
 
 static	void		  post_IP(DECL_ARGS);
 static	void		  post_HP(DECL_ARGS);
@@ -137,6 +138,7 @@ static	const struct termact termacts[MAN
 	{ pre_ign, NULL, 0 }, /* PD */
 	{ pre_ign, NULL, 0 }, /* AT */
 	{ pre_in, NULL, MAN_NOTEXT }, /* in */
+	{ pre_ft, NULL, MAN_NOTEXT }, /* ft */
 };
 
 
@@ -316,6 +318,47 @@ pre_B(DECL_ARGS)
 
 	term_fontrepl(p, TERMFONT_BOLD);
 	return(1);
+}
+
+/* ARGSUSED */
+static int
+pre_ft(DECL_ARGS)
+{
+	const char	*cp;
+
+	if (NULL == n->child) {
+		term_fontlast(p);
+		return(0);
+	}
+
+	cp = n->child->string;
+	switch (*cp) {
+	case ('4'):
+		/* FALLTHROUGH */
+	case ('3'):
+		/* FALLTHROUGH */
+	case ('B'):
+		term_fontrepl(p, TERMFONT_BOLD);
+		break;
+	case ('2'):
+		/* FALLTHROUGH */
+	case ('I'):
+		term_fontrepl(p, TERMFONT_UNDER);
+		break;
+	case ('P'):
+		term_fontlast(p);
+		break;
+	case ('1'):
+		/* FALLTHROUGH */
+	case ('C'):
+		/* FALLTHROUGH */
+	case ('R'):
+		term_fontrepl(p, TERMFONT_NONE);
+		break;
+	default:
+		break;
+	}
+	return(0);
 }
 
 /* ARGSUSED */
Index: man.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -Lman.h -Lman.h -u -p -r1.46 -r1.47
--- man.h
+++ man.h
@@ -55,6 +55,7 @@ enum	mant {
 	MAN_PD,
 	MAN_AT,
 	MAN_in,
+	MAN_ft,
 	MAN_MAX
 };
 
Index: man_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_macro.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -Lman_macro.c -Lman_macro.c -u -p -r1.52 -r1.53
--- man_macro.c
+++ man_macro.c
@@ -81,6 +81,7 @@ const	struct man_macro __man_macros[MAN_
 	{ in_line_eoln, 0 }, /* PD */
 	{ in_line_eoln, 0 }, /* AT */
 	{ in_line_eoln, 0 }, /* in */
+	{ in_line_eoln, 0 }, /* ft */
 };
 
 const	struct man_macro * const man_macros = __man_macros;
Index: man_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_validate.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -Lman_validate.c -Lman_validate.c -u -p -r1.54 -r1.55
--- man_validate.c
+++ man_validate.c
@@ -44,6 +44,7 @@ struct	man_valid {
 
 static	int	  check_bline(CHKARGS);
 static	int	  check_eq0(CHKARGS);
+static	int	  check_ft(CHKARGS);
 static	int	  check_le1(CHKARGS);
 static	int	  check_ge2(CHKARGS);
 static	int	  check_le5(CHKARGS);
@@ -64,6 +65,7 @@ static	v_check	  posts_at[] = { post_AT,
 static	v_check	  posts_eq0[] = { check_eq0, NULL };
 static	v_check	  posts_fi[] = { check_eq0, post_fi, NULL };
 static	v_check	  posts_le1[] = { check_le1, NULL };
+static	v_check	  posts_ft[] = { check_ft, NULL };
 static	v_check	  posts_nf[] = { check_eq0, post_nf, NULL };
 static	v_check	  posts_par[] = { check_par, NULL };
 static	v_check	  posts_part[] = { check_part, NULL };
@@ -108,6 +110,7 @@ static	const struct man_valid man_valids
 	{ NULL, NULL }, /* PD */
 	{ NULL, posts_at }, /* AT */
 	{ NULL, NULL }, /* in */
+	{ NULL, posts_ft }, /* ft */
 };
 
 
@@ -268,6 +271,58 @@ INEQ_DEFINE(1, <=, le1)
 INEQ_DEFINE(2, >=, ge2)
 INEQ_DEFINE(5, <=, le5)
 
+static int
+check_ft(CHKARGS)
+{
+	char	*cp;
+	int	 ok;
+
+	if (0 == n->nchild)
+		return(1);
+
+	ok = 0;
+	cp = n->child->string;
+	switch (*cp) {
+	case ('1'):
+		/* FALLTHROUGH */
+	case ('2'):
+		/* FALLTHROUGH */
+	case ('3'):
+		/* FALLTHROUGH */
+	case ('4'):
+		/* FALLTHROUGH */
+	case ('I'):
+		/* FALLTHROUGH */
+	case ('P'):
+		/* FALLTHROUGH */
+	case ('R'):
+		if ('\0' == cp[1])
+			ok = 1;
+		break;
+	case ('B'):
+		if ('\0' == cp[1] || ('I' == cp[1] && '\0' == cp[2]))
+			ok = 1;
+		break;
+	case ('C'):
+		if ('W' == cp[1] && '\0' == cp[2])
+			ok = 1;
+		break;
+	default:
+		break;
+	}
+
+	if (0 == ok) {
+		man_vmsg(m, MANDOCERR_BADFONT, 
+				n->line, n->pos, "%s", cp);
+		*cp = '\0';
+	}
+
+	if (1 < n->nchild)
+		man_vmsg(m, MANDOCERR_ARGCOUNT, n->line, n->pos,
+				"want one child (have %d)", n->nchild);
+
+	return(1);
+}
 
 static int
 check_sec(CHKARGS)
--
 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:[~2010-12-06 15:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-06 15:31 mdocml: Add support for `ft' macro found in groff(7) 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).