aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-12-06 15:31:19 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-12-06 15:31:19 +0000
commit8824599579c15c29a52a6ec127ec1b2a35719e2c (patch)
treef539cfc87104909847b10dcdfe2a9610a7a177c1
parent6da78159c4f30e5cbfe60fe6a244c73321edcb1c (diff)
downloadmandoc-8824599579c15c29a52a6ec127ec1b2a35719e2c.tar.gz
mandoc-8824599579c15c29a52a6ec127ec1b2a35719e2c.tar.zst
mandoc-8824599579c15c29a52a6ec127ec1b2a35719e2c.zip
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).
-rw-r--r--main.c3
-rw-r--r--man.711
-rw-r--r--man.c4
-rw-r--r--man.h3
-rw-r--r--man_html.c3
-rw-r--r--man_macro.c3
-rw-r--r--man_term.c45
-rw-r--r--man_validate.c57
-rw-r--r--mandoc.h3
9 files changed, 120 insertions, 12 deletions
diff --git a/main.c b/main.c
index 92056e45..1a9a2554 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.119 2010/12/06 11:01:19 kristaps Exp $ */
+/* $Id: main.c,v 1.120 2010/12/06 15:31:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -144,6 +144,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"NAME section must come first",
"bad Boolean value",
+ "unknown font",
"child violates parent syntax",
"displays may not be nested",
"bad AT&T symbol",
diff --git a/man.7 b/man.7
index bc49b0cb..2bfbd7da 100644
--- a/man.7
+++ b/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.90 2010/12/05 16:14:16 kristaps Exp $
+.\" $Id: man.7,v 1.91 2010/12/06 15:31:19 kristaps Exp $
.\"
.\" Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: December 5 2010 $
+.Dd $Mdocdate: December 6 2010 $
.Dt MAN 7
.Os
.Sh NAME
@@ -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
diff --git a/man.c b/man.c
index 293ab6fe..dd0a5335 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.90 2010/12/06 13:49:02 kristaps Exp $ */
+/* $Id: man.c,v 1.91 2010/12/06 15:31:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -39,7 +39,7 @@ const char *const __man_macronames[MAN_MAX] = {
"RI", "na", "i", "sp",
"nf", "fi", "r", "RE",
"RS", "DT", "UC", "PD",
- "AT", "in"
+ "AT", "in", "ft"
};
const char * const *man_macronames = __man_macronames;
diff --git a/man.h b/man.h
index 43a71bfb..1e7a3a2d 100644
--- a/man.h
+++ b/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.46 2010/12/05 16:14:16 kristaps Exp $ */
+/* $Id: man.h,v 1.47 2010/12/06 15:31:19 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -55,6 +55,7 @@ enum mant {
MAN_PD,
MAN_AT,
MAN_in,
+ MAN_ft,
MAN_MAX
};
diff --git a/man_html.c b/man_html.c
index 69c0cbfa..ed498463 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.49 2010/12/06 14:12:48 kristaps Exp $ */
+/* $Id: man_html.c,v 1.50 2010/12/06 15:31:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 */
};
diff --git a/man_macro.c b/man_macro.c
index 32179c67..4f15a3d1 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.52 2010/12/05 16:14:16 kristaps Exp $ */
+/* $Id: man_macro.c,v 1.53 2010/12/06 15:31:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -81,6 +81,7 @@ const struct man_macro __man_macros[MAN_MAX] = {
{ 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;
diff --git a/man_term.c b/man_term.c
index 6cd40e39..d07028a2 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.88 2010/12/06 14:04:11 kristaps Exp $ */
+/* $Id: man_term.c,v 1.89 2010/12/06 15:31:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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_MAX] = {
{ pre_ign, NULL, 0 }, /* PD */
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
+ { pre_ft, NULL, MAN_NOTEXT }, /* ft */
};
@@ -320,6 +322,47 @@ pre_B(DECL_ARGS)
/* 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 */
+static int
pre_in(DECL_ARGS)
{
int len, less;
diff --git a/man_validate.c b/man_validate.c
index 11f3de78..94bfdf29 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.54 2010/12/06 13:56:56 kristaps Exp $ */
+/* $Id: man_validate.c,v 1.55 2010/12/06 15:31:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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, NULL };
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[MAN_MAX] = {
{ 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)
diff --git a/mandoc.h b/mandoc.h
index 99f56b27..7f7e0a92 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.30 2010/12/06 11:01:19 kristaps Exp $ */
+/* $Id: mandoc.h,v 1.31 2010/12/06 15:31:19 kristaps Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 */