aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2012-11-19 17:57:23 +0000
committerIngo Schwarze <schwarze@openbsd.org>2012-11-19 17:57:23 +0000
commitdc409878671ea1571807749a48b645dd88048385 (patch)
tree83834697b270533b1b80f4f6df735a0231d6ae94
parent9ded0b0acccd78c24e423f47db992897a949faef (diff)
downloadmandoc-dc409878671ea1571807749a48b645dd88048385.tar.gz
mandoc-dc409878671ea1571807749a48b645dd88048385.tar.zst
mandoc-dc409878671ea1571807749a48b645dd88048385.zip
In groff, trying to redefine standard man(7) macros before .TH has no effect;
after .TH, it works. Trying to redefine standard mdoc(7) macros before .Dd works when calling groff with the -mdoc command line option, but does not when calling groff with -mandoc; after .Dd, it always works. Arguably, one might call that buggy behaviour in groff, but it is very unlikely that anybody will change groff in this respect (certainly, i'm not volunteering). So let's be bug-compatible. This fixes the vertical spacing in sox(1). Merging from OpenBSD libmandoc.h 1.18, read.c 1.8, roff.c 1.47, June 2, 2012.
-rw-r--r--libmandoc.h6
-rw-r--r--read.c4
-rw-r--r--roff.c71
3 files changed, 73 insertions, 8 deletions
diff --git a/libmandoc.h b/libmandoc.h
index e10a162a..9b3ffee1 100644
--- a/libmandoc.h
+++ b/libmandoc.h
@@ -1,6 +1,6 @@
-/* $Id: libmandoc.h,v 1.31 2012/06/12 20:21:04 kristaps Exp $ */
+/* $Id: libmandoc.h,v 1.32 2012/11/19 17:57:23 schwarze Exp $ */
/*
- * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -67,7 +67,7 @@ int man_addspan(struct man *, const struct tbl_span *);
int man_addeqn(struct man *, const struct eqn *);
void roff_free(struct roff *);
-struct roff *roff_alloc(struct mparse *);
+struct roff *roff_alloc(enum mparset, struct mparse *);
void roff_reset(struct roff *);
enum rofferr roff_parseln(struct roff *, int,
char **, size_t *, int, int *);
diff --git a/read.c b/read.c
index 967d8b80..89b2c28d 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.32 2012/11/16 22:21:05 schwarze Exp $ */
+/* $Id: read.c,v 1.33 2012/11/19 17:57:23 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -740,7 +740,7 @@ mparse_alloc(enum mparset inttype, enum mandoclevel wlevel,
curp->inttype = inttype;
curp->defos = defos;
- curp->roff = roff_alloc(curp);
+ curp->roff = roff_alloc(inttype, curp);
return(curp);
}
diff --git a/roff.c b/roff.c
index ad9645ee..f99ff2dc 100644
--- a/roff.c
+++ b/roff.c
@@ -1,6 +1,6 @@
-/* $Id: roff.c,v 1.174 2012/06/12 20:21:04 kristaps Exp $ */
+/* $Id: roff.c,v 1.175 2012/11/19 17:57:23 schwarze Exp $ */
/*
- * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -59,6 +59,8 @@ enum rofft {
ROFF_so,
ROFF_ta,
ROFF_tr,
+ ROFF_Dd,
+ ROFF_TH,
ROFF_TS,
ROFF_TE,
ROFF_T_,
@@ -103,6 +105,7 @@ struct roffkv {
};
struct roff {
+ enum mparset parsetype; /* requested parse type */
struct mparse *parse; /* parse point */
struct roffnode *last; /* leaf of stack */
enum roffrule rstack[RSTACK_MAX]; /* stack of !`ie' rules */
@@ -198,6 +201,8 @@ static void roff_setstrn(struct roffkv **, const char *,
size_t, const char *, size_t, int);
static enum rofferr roff_so(ROFF_ARGS);
static enum rofferr roff_tr(ROFF_ARGS);
+static enum rofferr roff_Dd(ROFF_ARGS);
+static enum rofferr roff_TH(ROFF_ARGS);
static enum rofferr roff_TE(ROFF_ARGS);
static enum rofferr roff_TS(ROFF_ARGS);
static enum rofferr roff_EQ(ROFF_ARGS);
@@ -238,6 +243,8 @@ static struct roffmac roffs[ROFF_MAX] = {
{ "so", roff_so, NULL, NULL, 0, NULL },
{ "ta", roff_line_ignore, NULL, NULL, 0, NULL },
{ "tr", roff_tr, NULL, NULL, 0, NULL },
+ { "Dd", roff_Dd, NULL, NULL, 0, NULL },
+ { "TH", roff_TH, NULL, NULL, 0, NULL },
{ "TS", roff_TS, NULL, NULL, 0, NULL },
{ "TE", roff_TE, NULL, NULL, 0, NULL },
{ "T&", roff_T_, NULL, NULL, 0, NULL },
@@ -248,6 +255,37 @@ static struct roffmac roffs[ROFF_MAX] = {
{ NULL, roff_userdef, NULL, NULL, 0, NULL },
};
+const char *const __mdoc_reserved[] = {
+ "Ac", "Ad", "An", "Ao", "Ap", "Aq", "Ar", "At",
+ "Bc", "Bd", "Bf", "Bk", "Bl", "Bo", "Bq",
+ "Brc", "Bro", "Brq", "Bsx", "Bt", "Bx",
+ "Cd", "Cm", "Db", "Dc", "Dd", "Dl", "Do", "Dq",
+ "Ds", "Dt", "Dv", "Dx", "D1",
+ "Ec", "Ed", "Ef", "Ek", "El", "Em", "em",
+ "En", "Eo", "Eq", "Er", "Es", "Ev", "Ex",
+ "Fa", "Fc", "Fd", "Fl", "Fn", "Fo", "Fr", "Ft", "Fx",
+ "Hf", "Ic", "In", "It", "Lb", "Li", "Lk", "Lp", "LP",
+ "Me", "Ms", "Mt", "Nd", "Nm", "No", "Ns", "Nx",
+ "Oc", "Oo", "Op", "Os", "Ot", "Ox",
+ "Pa", "Pc", "Pf", "Po", "Pp", "PP", "pp", "Pq",
+ "Qc", "Ql", "Qo", "Qq", "Or", "Rd", "Re", "Rs", "Rv",
+ "Sc", "Sf", "Sh", "SH", "Sm", "So", "Sq",
+ "Ss", "St", "Sx", "Sy",
+ "Ta", "Tn", "Ud", "Ux", "Va", "Vt", "Xc", "Xo", "Xr",
+ "%A", "%B", "%D", "%I", "%J", "%N", "%O",
+ "%P", "%Q", "%R", "%T", "%U", "%V",
+ NULL
+};
+
+const char *const __man_reserved[] = {
+ "AT", "B", "BI", "BR", "BT", "DE", "DS", "DT",
+ "EE", "EN", "EQ", "EX", "HF", "HP", "I", "IB", "IP", "IR",
+ "LP", "ME", "MT", "OP", "P", "PD", "PP", "PT",
+ "R", "RB", "RE", "RI", "RS", "SB", "SH", "SM", "SS", "SY",
+ "TE", "TH", "TP", "TQ", "TS", "T&", "UC", "UE", "UR", "YS",
+ NULL
+};
+
/* Array of injected predefined strings. */
#define PREDEFS_MAX 38
static const struct predef predefs[PREDEFS_MAX] = {
@@ -414,12 +452,13 @@ roff_free(struct roff *r)
struct roff *
-roff_alloc(struct mparse *parse)
+roff_alloc(enum mparset type, struct mparse *parse)
{
struct roff *r;
int i;
r = mandoc_calloc(1, sizeof(struct roff));
+ r->parsetype = type;
r->parse = parse;
r->rstackpos = -1;
@@ -1270,6 +1309,32 @@ roff_rm(ROFF_ARGS)
/* ARGSUSED */
static enum rofferr
+roff_Dd(ROFF_ARGS)
+{
+ const char *const *cp;
+
+ if (MPARSE_MDOC != r->parsetype)
+ for (cp = __mdoc_reserved; *cp; cp++)
+ roff_setstr(r, *cp, NULL, 0);
+
+ return(ROFF_CONT);
+}
+
+/* ARGSUSED */
+static enum rofferr
+roff_TH(ROFF_ARGS)
+{
+ const char *const *cp;
+
+ if (MPARSE_MDOC != r->parsetype)
+ for (cp = __man_reserved; *cp; cp++)
+ roff_setstr(r, *cp, NULL, 0);
+
+ return(ROFF_CONT);
+}
+
+/* ARGSUSED */
+static enum rofferr
roff_TE(ROFF_ARGS)
{