diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-12-28 14:42:27 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-12-28 14:42:27 +0000 |
commit | e0c8ee70b0d6b84f57714a5446e2ecfeca8826b4 (patch) | |
tree | a958c1c720cac88b7740009ea1436b5c356e1eb7 | |
parent | 6c9bf65b847eba6ae5bf1d6bf9d72a29550bf824 (diff) | |
download | mandoc-e0c8ee70b0d6b84f57714a5446e2ecfeca8826b4.tar.gz |
mdoc(7) already uses the mandoc(1) -Ios argument in the footer line
when .Os has no argument, so do the same for man(7) when .TH has less
than four arguments; there is no reason to treat both differently.
Issue found following a question from Thomas Klausner <wiz at NetBSD>.
-rw-r--r-- | libman.h | 1 | ||||
-rw-r--r-- | libmandoc.h | 3 | ||||
-rw-r--r-- | man.1 | 3 | ||||
-rw-r--r-- | man.c | 4 | ||||
-rw-r--r-- | man_validate.c | 2 | ||||
-rw-r--r-- | mandoc.1 | 3 | ||||
-rw-r--r-- | read.c | 9 |
7 files changed, 20 insertions, 5 deletions
@@ -23,6 +23,7 @@ enum man_next { struct man { struct mparse *parse; /* parse pointer */ + const char *defos; /* default OS argument for .TH */ int quick; /* abort parse early */ int flags; /* parse flags */ #define MAN_ELINE (1 << 1) /* Next-line element scope. */ diff --git a/libmandoc.h b/libmandoc.h index e5b52efd..71b9bb3f 100644 --- a/libmandoc.h +++ b/libmandoc.h @@ -66,7 +66,8 @@ void mdoc_addspan(struct mdoc *, const struct tbl_span *); void mdoc_addeqn(struct mdoc *, const struct eqn *); void man_free(struct man *); -struct man *man_alloc(struct roff *, struct mparse *, int); +struct man *man_alloc(struct roff *, struct mparse *, + const char *, int); void man_reset(struct man *); int man_parseln(struct man *, int, char *, int); int man_endparse(struct man *); @@ -106,6 +106,9 @@ Override the default operating system for the .Xr mdoc 7 .Ic \&Os +and for the +.Xr man 7 +.Ic \&TH macro. .It Fl h Display only the SYNOPSIS lines of the requested manual pages. @@ -92,7 +92,8 @@ man_free(struct man *man) } struct man * -man_alloc(struct roff *roff, struct mparse *parse, int quick) +man_alloc(struct roff *roff, struct mparse *parse, + const char *defos, int quick) { struct man *p; @@ -100,6 +101,7 @@ man_alloc(struct roff *roff, struct mparse *parse, int quick) man_hash_init(); p->parse = parse; + p->defos = defos; p->quick = quick; p->roff = roff; diff --git a/man_validate.c b/man_validate.c index 5688bb54..48f2ed5b 100644 --- a/man_validate.c +++ b/man_validate.c @@ -379,6 +379,8 @@ post_TH(CHKARGS) if (n && (n = n->next)) man->meta.source = mandoc_strdup(n->string); + else if (man->defos != NULL) + man->meta.source = mandoc_strdup(man->defos); /* TITLE MSEC DATE SOURCE ->VOL<- */ /* If missing, use the default VOL name for MSEC. */ @@ -85,6 +85,9 @@ Override the default operating system for the .Xr mdoc 7 .Sq \&Os +and for the +.Xr man 7 +.Sq \&TH macro. .It Fl h Display only the SYNOPSIS lines. @@ -298,7 +298,8 @@ choose_parser(struct mparse *curp) /* Fall back to man(7) as a last resort. */ if (NULL == curp->pman) - curp->pman = man_alloc(curp->roff, curp, + curp->pman = man_alloc( + curp->roff, curp, curp->defos, MPARSE_QUICK & curp->options ? 1 : 0); assert(curp->pman); curp->man = curp->pman; @@ -696,7 +697,8 @@ mparse_end(struct mparse *curp) curp->mdoc = curp->pmdoc; else { if (curp->pman == NULL) - curp->pman = man_alloc(curp->roff, curp, + curp->pman = man_alloc( + curp->roff, curp, curp->defos, curp->options & MPARSE_QUICK ? 1 : 0); curp->man = curp->pman; } @@ -940,7 +942,8 @@ mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg, curp->roff, curp, curp->defos, curp->options & MPARSE_QUICK ? 1 : 0); if (curp->options & MPARSE_MAN) - curp->pman = man_alloc(curp->roff, curp, + curp->pman = man_alloc( + curp->roff, curp, curp->defos, curp->options & MPARSE_QUICK ? 1 : 0); return(curp); |