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 | b44b43f687b8f98c50f0f22a5feae1bc72693b07 (patch) | |
tree | 6e63dbeffceec35e93a32a4cf8def8c59ed331d4 | |
parent | d1b540afdd77328cb66da01be9399236630bf4f6 (diff) | |
download | mandoc-b44b43f687b8f98c50f0f22a5feae1bc72693b07.tar.gz |
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 | 1 | ||||
-rw-r--r-- | libmdoc.h | 1 | ||||
-rw-r--r-- | man.7 | 13 | ||||
-rw-r--r-- | man_validate.c | 4 | ||||
-rw-r--r-- | mdoc_validate.c | 2 | ||||
-rw-r--r-- | msec.c | 5 |
7 files changed, 23 insertions, 7 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 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 *); @@ -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, @@ -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); @@ -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" |