From 1b1e02d4acd11f96e061ac04ae243ab0589d2f8a Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Fri, 27 Feb 2009 10:55:16 +0000 Subject: Slowly decoupling mdoc(3) from being OpenBSD-only. --- action.c | 4 ++-- index.sgml | 23 ++++++++++++++--------- mdocterm.1 | 12 +----------- mdocterm.c | 34 ++++++++++++++++++++++++++-------- strings.c | 20 ++++++++++---------- 5 files changed, 53 insertions(+), 40 deletions(-) diff --git a/action.c b/action.c index 2934750b..df5b6769 100644 --- a/action.c +++ b/action.c @@ -1,4 +1,4 @@ -/* $Id: action.c,v 1.21 2009/02/27 09:39:40 kristaps Exp $ */ +/* $Id: action.c,v 1.22 2009/02/27 10:55:16 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -271,7 +271,7 @@ post_os(struct mdoc *mdoc) if ( ! xstrlcats(buf, mdoc->last->child, 64)) return(mdoc_err(mdoc, "macro parameters too long")); - mdoc->meta.os = xstrdup(buf[0] ? buf : "local"); + mdoc->meta.os = xstrdup(buf[0] ? buf : "LOCAL"); mdoc->lastnamed = SEC_BODY; return(post_prologue(mdoc)); diff --git a/index.sgml b/index.sgml index 94325393..1d576e14 100644 --- a/index.sgml +++ b/index.sgml @@ -24,11 +24,16 @@

- mdocml is a suite of tools that compile “mdoc”, the roff macro - package of the BSD manual pages. The mission of mdocml is to deprecate mdocml is a suite of tools compiling “mdoc”, the roff macro + package for BSD manual pages. The mission of mdocml is to deprecate groff, the GNU roff implementation, for - displaying BSD mdoc pages. groff amounts to over 60 000 lines of GPL C++ source, which is a - considerable encumbrance to BSD operating systems. + displaying BSD mdoc pages. +

+ +

+ Why? groff amounts to roughly 5,2 MB of source code (OpenBSD 4.2), some of which is C++ and all of + which is GPL. It runs slowly, produces uncertain output, and varies in operation from system + to system. mdocml strives to fix this (respectively small, C, ISC-licensed, fast and regular).

@@ -44,7 +49,7 @@

@@ -79,11 +84,11 @@

- snapshotted source + Snapshot source

- CVS sources are checkedout and snapshotted with big updates. These may be found in the /snapshots/ directory.

@@ -97,7 +102,7 @@

- nightly port + Snapshot port

@@ -141,7 +146,7 @@

- Copyright © 2009 Kristaps Džonsons, $Date: 2009/02/25 12:46:27 $ + Copyright © 2009 Kristaps Džonsons, $Date: 2009/02/27 10:55:16 $
diff --git a/mdocterm.1 b/mdocterm.1 index 0782dd42..f350c336 100644 --- a/mdocterm.1 +++ b/mdocterm.1 @@ -1,4 +1,4 @@ -.\" $Id: mdocterm.1,v 1.7 2009/02/27 09:14:02 kristaps Exp $ +.\" $Id: mdocterm.1,v 1.8 2009/02/27 10:55:16 kristaps Exp $ .\" .\" Copyright (c) 2009 Kristaps Dzonsons .\" @@ -111,8 +111,6 @@ Enclosures: .Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It Em Output .Em Input (Name) -.El -.Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It \(rB \\(rB (right bracket) .It \(lB @@ -133,8 +131,6 @@ Indicatives: .Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It Em Output .Em Input (Name) -.El -.Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It \(<- \\(<- (left arrow) .It \(-> @@ -151,8 +147,6 @@ Mathematical: .Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It Em Output .Em Input (Name) -.El -.Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It \(<= \\(<= (less-than-equal) .It \(>= @@ -179,8 +173,6 @@ Diacritics: .Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It Em Output .Em Input (Name) -.El -.Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It \(ga \\(ga (accent grave) .It \(aa @@ -193,8 +185,6 @@ Special symbols: .Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It Em Output .Em Input (Name) -.El -.Bl -tag -width "OutputXXXX" -offset "XXXX" -compact .It \(bu \\(bu (bullet) .It \(ba diff --git a/mdocterm.c b/mdocterm.c index d7fbc69a..3e2f70f0 100644 --- a/mdocterm.c +++ b/mdocterm.c @@ -1,4 +1,4 @@ -/* $Id: mdocterm.c,v 1.17 2009/02/27 09:14:02 kristaps Exp $ */ +/* $Id: mdocterm.c,v 1.18 2009/02/27 10:55:16 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -16,6 +16,8 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ +#include + #include #include #include @@ -674,15 +676,21 @@ footer(struct termp *p, const struct mdoc_meta *meta) static void header(struct termp *p, const struct mdoc_meta *meta) { - char *buf, *title, *bufp; + char *buf, *title, *bufp, *vbuf; const char *pp; + struct utsname uts; + + p->rmargin = p->maxrmargin; + p->offset = 0; if (NULL == (buf = malloc(p->rmargin))) err(1, "malloc"); if (NULL == (title = malloc(p->rmargin))) err(1, "malloc"); + if (NULL == (vbuf = malloc(p->rmargin))) + err(1, "malloc"); - if (NULL == (pp = mdoc_vol2a(meta->vol))) + if (NULL == (pp = mdoc_vol2a(meta->vol))) { switch (meta->msec) { case (MSEC_1): /* FALLTHROUGH */ @@ -707,11 +715,20 @@ header(struct termp *p, const struct mdoc_meta *meta) pp = mdoc_vol2a(VOL_KM); break; default: - /* FIXME: capitalise. */ - if (NULL == (pp = mdoc_msec2a(meta->msec))) - pp = mdoc_msec2a(MSEC_local); break; } + } + vbuf[0] = 0; + + if (pp) { + if (-1 == uname(&uts)) + err(1, "uname"); + (void)strlcat(vbuf, uts.sysname, p->rmargin); + (void)strlcat(vbuf, " ", p->rmargin); + } else if (NULL == (pp = mdoc_msec2a(meta->msec))) + pp = mdoc_msec2a(MSEC_local); + + (void)strlcat(vbuf, pp, p->rmargin); /* * The header is strange. It has three components, which are @@ -728,9 +745,9 @@ header(struct termp *p, const struct mdoc_meta *meta) if (mdoc_arch2a(meta->arch)) (void)snprintf(buf, p->rmargin, "%s (%s)", - pp, mdoc_arch2a(meta->arch)); + vbuf, mdoc_arch2a(meta->arch)); else - (void)strlcpy(buf, pp, p->rmargin); + (void)strlcpy(buf, vbuf, p->rmargin); pp = mdoc_msec2a(meta->msec); @@ -767,5 +784,6 @@ header(struct termp *p, const struct mdoc_meta *meta) p->flags &= ~TERMP_NOSPACE; free(title); + free(vbuf); free(buf); } diff --git a/strings.c b/strings.c index 87a9b35e..896971a9 100644 --- a/strings.c +++ b/strings.c @@ -1,4 +1,4 @@ -/* $Id: strings.c,v 1.21 2009/02/27 08:20:15 kristaps Exp $ */ +/* $Id: strings.c,v 1.22 2009/02/27 10:55:16 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -472,23 +472,23 @@ mdoc_vol2a(enum mdoc_vol vol) switch (vol) { case (VOL_AMD): - return("OpenBSD Ancestral Manual Documents"); + return("Ancestral Manual Documents"); case (VOL_IND): - return("OpenBSD Manual Master Index"); + return("Manual Master Index"); case (VOL_KM): - return("OpenBSD Kernel Manual"); + return("Kernel Manual"); case (VOL_LOCAL): - return("OpenBSD Local Manual"); + return("Local Manual"); case (VOL_PRM): - return("OpenBSD Programmer's Manual"); + return("Programmer's Manual"); case (VOL_PS1): - return("OpenBSD Programmer's Supplementary Documents"); + return("Programmer's Supplementary Documents"); case (VOL_SMM): - return("OpenBSD System Manager's Manual"); + return("System Manager's Manual"); case (VOL_URM): - return("OpenBSD Reference Manual"); + return("Reference Manual"); case (VOL_USD): - return("OpenBSD User's Supplementary Documents"); + return("User's Supplementary Documents"); case (VOL_DEFAULT): return(NULL); default: -- cgit v1.2.3