From b44b43f687b8f98c50f0f22a5feae1bc72693b07 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 2 Dec 2011 01:37:14 +0000 Subject: 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 --- Makefile | 4 ++-- libmandoc.h | 1 + libmdoc.h | 1 - man.7 | 13 +++++++++++++ man_validate.c | 4 ++++ mdoc_validate.c | 2 +- msec.c | 5 ++--- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index aa93b3b8..e6f8f2a3 100644 --- a/Makefile +++ b/Makefile @@ -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 7a123f0e..2a0c28df 100644 --- a/libmandoc.h +++ b/libmandoc.h @@ -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 *); diff --git a/libmdoc.h b/libmdoc.h index b7223c16..a23b2366 100644 --- a/libmdoc.h +++ b/libmdoc.h @@ -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, diff --git a/man.7 b/man.7 index fa7dbb0a..ff88058e 100644 --- a/man.7 +++ b/man.7 @@ -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 27ecd087..c63dcdfc 100644 --- a/man_validate.c +++ b/man_validate.c @@ -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 f5158b01..7dc24961 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -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); diff --git a/msec.c b/msec.c index 906534be..14b52c00 100644 --- a/msec.c +++ b/msec.c @@ -21,15 +21,14 @@ #include #include -#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" -- cgit