diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2011-12-02 01:37:14 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2011-12-02 01:37:14 +0000 |
commit | 92b82a1384a9e9840e25d2364a36c9fa50384e34 (patch) | |
tree | 827d1f0788bc8e1d2f9fb69aa580c83339372c74 | |
parent | b505ecce3956d6be1ab0554257d7ce9ead09ff89 (diff) | |
download | mandoc-92b82a1384a9e9840e25d2364a36c9fa50384e34.tar.gz mandoc-92b82a1384a9e9840e25d2364a36c9fa50384e34.tar.zst mandoc-92b82a1384a9e9840e25d2364a36c9fa50384e34.zip |
In man(7), when no explicit volume name is given, use the default
volume name for the respective manual section, just like in mdoc(7).
This gives us nicer page headers for cvs(1), lynx(1), tic(1),
mkhybrid(8), and many curses(3) manuals.
ok kristaps@
To not break compatibility, i wrote a corresponding patch for GNU troff
which Werner Lemberg accepted upstream at rev. 1.65 of:
http://cvs.savannah.gnu.org/viewvc/groff/tmac/an-old.tmac?root=groff
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | libmandoc.h | 3 | ||||
-rw-r--r-- | libmdoc.h | 3 | ||||
-rw-r--r-- | man.7 | 17 | ||||
-rw-r--r-- | man_validate.c | 6 | ||||
-rw-r--r-- | mdoc_validate.c | 4 | ||||
-rw-r--r-- | msec.c | 7 |
7 files changed, 30 insertions, 14 deletions
@@ -173,7 +173,6 @@ LIBMDOC_OBJS = arch.o \ mdoc_hash.o \ mdoc_macro.o \ mdoc_validate.o \ - msec.o \ st.o \ vol.o LIBMDOC_LNS = arch.ln \ @@ -184,7 +183,6 @@ LIBMDOC_LNS = arch.ln \ mdoc_hash.ln \ mdoc_macro.ln \ mdoc_validate.ln \ - msec.ln \ st.ln \ vol.ln @@ -206,12 +204,14 @@ LIBMANDOC_OBJS = $(LIBMAN_OBJS) \ $(LIBROFF_OBJS) \ chars.o \ mandoc.o \ + msec.o \ read.o LIBMANDOC_LNS = $(LIBMAN_LNS) \ $(LIBMDOC_LNS) \ $(LIBROFF_LNS) \ chars.ln \ mandoc.ln \ + msec.ln \ read.ln COMPAT_OBJS = compat_getsubopt.o \ diff --git a/libmandoc.h b/libmandoc.h index bedf0497..de422884 100644 --- a/libmandoc.h +++ b/libmandoc.h @@ -1,4 +1,4 @@ -/* $Id: libmandoc.h,v 1.28 2011/07/28 14:17:11 kristaps Exp $ */ +/* $Id: libmandoc.h,v 1.29 2011/12/02 01:37:14 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -49,6 +49,7 @@ char *mandoc_normdate(struct mparse *, char *, int, int); int mandoc_eos(const char *, size_t, int); int mandoc_getcontrol(const char *, int *); int mandoc_strntoi(const char *, size_t, int); +const char *mandoc_a2msec(const char*); void mdoc_free(struct mdoc *); struct mdoc *mdoc_alloc(struct roff *, struct mparse *); @@ -1,4 +1,4 @@ -/* $Id: libmdoc.h,v 1.77 2011/09/18 14:14:15 schwarze Exp $ */ +/* $Id: libmdoc.h,v 1.78 2011/12/02 01:37:14 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -124,7 +124,6 @@ const char *mdoc_a2lib(const char *); const char *mdoc_a2st(const char *); const char *mdoc_a2arch(const char *); const char *mdoc_a2vol(const char *); -const char *mdoc_a2msec(const char *); int mdoc_valid_pre(struct mdoc *, struct mdoc_node *); int mdoc_valid_post(struct mdoc *); enum margverr mdoc_argv(struct mdoc *, int, enum mdoct, @@ -1,4 +1,4 @@ -.\" $Id: man.7,v 1.111 2011/09/26 23:07:31 schwarze Exp $ +.\" $Id: man.7,v 1.112 2011/12/02 01:37:14 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> .\" Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -15,7 +15,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: September 26 2011 $ +.Dd $Mdocdate: December 2 2011 $ .Dt MAN 7 .Os .Sh NAME @@ -840,6 +840,19 @@ The .Sx \&sp macro does not accept negative values in mandoc. In GNU troff, this would result in strange behaviour. +.It +In page header lines, GNU troff versions up to and including 1.21 +only print +.Ar volume +names explicitly specified in the +.Sx \&TH +macro; mandoc and newer groff print the default volume name +corresponding to the +.Ar section +number when no +.Ar volume +is given, like in +.Xr mdoc 7 . .El .Sh SEE ALSO .Xr man 1 , diff --git a/man_validate.c b/man_validate.c index d39618ff..bf266ca6 100644 --- a/man_validate.c +++ b/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.78 2011/11/07 01:24:40 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.79 2011/12/02 01:37:14 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -413,9 +413,13 @@ post_TH(CHKARGS) m->meta.source = mandoc_strdup(n->string); /* TITLE MSEC DATE SOURCE ->VOL<- */ + /* If missing, use the default VOL name for MSEC. */ if (n && (n = n->next)) m->meta.vol = mandoc_strdup(n->string); + else if ('\0' != m->meta.msec[0] && + (NULL != (p = mandoc_a2msec(m->meta.msec)))) + m->meta.vol = mandoc_strdup(p); /* * Remove the `TH' node after we've processed it for our diff --git a/mdoc_validate.c b/mdoc_validate.c index dd38477c..9bb378ef 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.179 2011/11/19 13:29:47 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.180 2011/12/02 01:37:14 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -2084,7 +2084,7 @@ post_dt(POST_ARGS) * arch = NULL */ - cp = mdoc_a2msec(nn->string); + cp = mandoc_a2msec(nn->string); if (cp) { mdoc->meta.vol = mandoc_strdup(cp); mdoc->meta.msec = mandoc_strdup(nn->string); @@ -1,4 +1,4 @@ -/* $Id: msec.c,v 1.9 2011/03/22 14:33:05 kristaps Exp $ */ +/* $Id: msec.c,v 1.10 2011/12/02 01:37:14 schwarze Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -21,15 +21,14 @@ #include <stdlib.h> #include <string.h> -#include "mdoc.h" #include "mandoc.h" -#include "libmdoc.h" +#include "libmandoc.h" #define LINE(x, y) \ if (0 == strcmp(p, x)) return(y); const char * -mdoc_a2msec(const char *p) +mandoc_a2msec(const char *p) { #include "msec.in" |