* Re: override operating system version
2014-12-17 13:35 override operating system version Thomas Klausner
@ 2014-12-17 17:27 ` Ingo Schwarze
2014-12-25 23:15 ` Thomas Klausner
0 siblings, 1 reply; 3+ messages in thread
From: Ingo Schwarze @ 2014-12-17 17:27 UTC (permalink / raw)
To: Thomas Klausner; +Cc: discuss
Hi Thomas,
Thomas Klausner wrote on Wed, Dec 17, 2014 at 02:35:20PM +0100:
> For displaying man pages from older releases on man.netbsd.org,
> we'd like to override the default operating system version put
> into the man page footer. mandoc currently uses the one from
> the operating system on which mandoc is running.
That only applies to mdoc(7) pages, and only if -Ios is not given
on the command line and -DOSNAME is not given at compile time.
For man(7) pages, it is left blank by default, and right now,
that default cannot be overridden, neither at compile time nor
from the command line.
> Using groff, the workaround is to set GROFF_TMAC_PATH to a copy
> of the tmac files from that release.
That sounds like it involves NetBSD-specific customizations.
Stock upstream groff defaults to "BSD" for mdoc(7) and a blank
field for man(7), iirc.
> What's the best way to do that with mandoc?
The easiest way seems to let man(7) use the existing -Ios command
line option just like mdoc(7). I mean, the user will hardly care
what the language of the manual page's source code is, so it's
hard to see why the two should be different.
Obviously, man.cgi(8) has no command line options, but it uses
the manpath of the page being shown - for example "NetBSD-6.1.5" in
http://mdocml.bsd.lv/cgi-bin/man.cgi?query=man&manpath=NetBSD-6.1.5 -
for the purpose man(1) and mandoc(1) use -Ios.
If you like that approach, i'll probably commit it.
Yours,
Ingo
Index: libman.h
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/libman.h,v
retrieving revision 1.41
diff -u -p -r1.41 libman.h
--- libman.h 28 Nov 2014 05:51:29 -0000 1.41
+++ libman.h 17 Dec 2014 17:11:17 -0000
@@ -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. */
Index: libmandoc.h
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/libmandoc.h,v
retrieving revision 1.37
diff -u -p -r1.37 libmandoc.h
--- libmandoc.h 1 Dec 2014 08:05:02 -0000 1.37
+++ libmandoc.h 17 Dec 2014 17:11:17 -0000
@@ -64,7 +64,8 @@ void mdoc_addspan(struct mdoc *, const
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 *);
Index: man.1
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/man.1,v
retrieving revision 1.6
diff -u -p -r1.6 man.1
--- man.1 14 Dec 2014 17:48:48 -0000 1.6
+++ man.1 17 Dec 2014 17:11:17 -0000
@@ -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.
Index: man.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/man.c,v
retrieving revision 1.93
diff -u -p -r1.93 man.c
--- man.c 28 Nov 2014 06:26:46 -0000 1.93
+++ man.c 17 Dec 2014 17:11:17 -0000
@@ -90,7 +90,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;
@@ -98,6 +99,7 @@ man_alloc(struct roff *roff, struct mpar
man_hash_init();
p->parse = parse;
+ p->defos = defos;
p->quick = quick;
p->roff = roff;
Index: man_validate.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/man_validate.c,v
retrieving revision 1.78
diff -u -p -r1.78 man_validate.c
--- man_validate.c 28 Nov 2014 05:51:29 -0000 1.78
+++ man_validate.c 17 Dec 2014 17:11:17 -0000
@@ -377,6 +377,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. */
Index: mandoc.1
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/mandoc.1,v
retrieving revision 1.69
diff -u -p -r1.69 mandoc.1
--- mandoc.1 15 Dec 2014 17:36:47 -0000 1.69
+++ mandoc.1 17 Dec 2014 17:11:17 -0000
@@ -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.
Index: read.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/read.c,v
retrieving revision 1.80
diff -u -p -r1.80 read.c
--- read.c 16 Dec 2014 23:44:16 -0000 1.80
+++ read.c 17 Dec 2014 17:11:17 -0000
@@ -293,7 +293,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;
@@ -689,7 +690,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;
}
@@ -918,7 +920,8 @@ mparse_alloc(int options, enum mandoclev
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);
--
To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 3+ messages in thread