]> git.cameronkatri.com Git - mandoc.git/commitdiff
Slowly decoupling mdoc(3) from being OpenBSD-only. VERSION_1_3_6
authorKristaps Dzonsons <kristaps@bsd.lv>
Fri, 27 Feb 2009 10:55:16 +0000 (10:55 +0000)
committerKristaps Dzonsons <kristaps@bsd.lv>
Fri, 27 Feb 2009 10:55:16 +0000 (10:55 +0000)
action.c
index.sgml
mdocterm.1
mdocterm.c
strings.c

index 2934750bf934461ae748e4cfd383ef33e26abd70..df5b67695237f5a30f8b2b5076c2d5c04fd5a807 100644 (file)
--- 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 <kristaps@kth.se>
  *
 /*
  * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -271,7 +271,7 @@ post_os(struct mdoc *mdoc)
        if ( ! xstrlcats(buf, mdoc->last->child, 64))
                return(mdoc_err(mdoc, "macro parameters too long")); 
 
        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));
        mdoc->lastnamed = SEC_BODY;
 
        return(post_prologue(mdoc));
index 943253935406da7c7343a7fd93a068df7d4f8e2e..1d576e14a61801b8b681555032e32a37dcd470c6 100644 (file)
                                        </h1>
 
                                        <p>
                                        </h1>
 
                                        <p>
-                                       <span class="nm">mdocml</span> is a suite of tools that compile &#8220;mdoc&#8221;, the roff macro
-                                       package of the BSD manual pages.  The mission of <span class="nm">mdocml</span> is to deprecate <a
+                                       <span class="nm">mdocml</span> is a suite of tools compiling &#8220;mdoc&#8221;, the roff macro
+                                       package for BSD manual pages.  The mission of <span class="nm">mdocml</span> is to deprecate <a
                                        href="http://www.gnu.org/software/groff/" class="external">groff</a>, the GNU roff implementation, for
                                        href="http://www.gnu.org/software/groff/" class="external">groff</a>, 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.
+                                       </p>
+
+                                       <p>
+                                       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).
                                        </p>
 
                                        <p>
                                        </p>
 
                                        <p>
@@ -44,7 +49,7 @@
 
                                        <ul>
                                        <li><span class="man">mdocterm(1)</span> &#8211; formats mdoc input for display on the terminal
 
                                        <ul>
                                        <li><span class="man">mdocterm(1)</span> &#8211; formats mdoc input for display on the terminal
-                                       <li><span class="man">mdochtml(1)</span> &#8211; formats mdoc input as strict HTML (nascent)
+                                       <li><span class="man">mdochtml(1)</span> &#8211; formats mdoc input as HTML/CSS (nascent)
                                        <li><span class="man">mdoclint(1)</span> &#8211; validates mdoc input
                                        <li><span class="man">mdoctree(1)</span> &#8211; prints input abstract syntax tree
                                        </ul>
                                        <li><span class="man">mdoclint(1)</span> &#8211; validates mdoc input
                                        <li><span class="man">mdoctree(1)</span> &#8211; prints input abstract syntax tree
                                        </ul>
                                        </p>
 
                                        <h2>
                                        </p>
 
                                        <h2>
-                                       snapshotted source
+                                       Snapshot source
                                        </h2>
 
                                        <p>
                                        </h2>
 
                                        <p>
-                                       CVS sources are checkedout and snapshotted with big updates.  These may be found in the <a
+                                       CVS sources are checkedout and snapshotted with version updates.  These may be found in the <a
                                        href="/snapshots/">/snapshots/</a> directory.
                                        </p>
 
                                        href="/snapshots/">/snapshots/</a> directory.
                                        </p>
 
                                        </p>
 
                                        <h2>
                                        </p>
 
                                        <h2>
-                                       nightly port
+                                       Snapshot port
                                        </h2>
 
                                        <p>
                                        </h2>
 
                                        <p>
                        <tr>
                                <td>
                                        <div class="foot">
                        <tr>
                                <td>
                                        <div class="foot">
-                                               Copyright &#169; 2009 Kristaps D&#382;onsons, $Date: 2009/02/25 12:46:27 $
+                                               Copyright &#169; 2009 Kristaps D&#382;onsons, $Date: 2009/02/27 10:55:16 $
                                        </div>
                                </td>
                        </tr>
                                        </div>
                                </td>
                        </tr>
index 0782dd42c5869d2710ae23ff2d092113b488d0f5..f350c33670f35d07553f5f1e36ae961347014a0b 100644 (file)
@@ -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 <kristaps@kth.se>
 .\"
 .\"
 .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
 .\"
@@ -111,8 +111,6 @@ Enclosures:
 .Bl -tag -width "OutputXXXX" -offset "XXXX" -compact
 .It Em Output
 .Em Input (Name)
 .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
 .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)
 .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 \(->
 .It \(<-
 \\(<- (left arrow)
 .It \(->
@@ -151,8 +147,6 @@ Mathematical:
 .Bl -tag -width "OutputXXXX" -offset "XXXX" -compact
 .It Em Output
 .Em Input (Name)
 .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 \(>=
 .It \(<=
 \\(<= (less-than-equal)
 .It \(>=
@@ -179,8 +173,6 @@ Diacritics:
 .Bl -tag -width "OutputXXXX" -offset "XXXX" -compact
 .It Em Output
 .Em Input (Name)
 .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
 .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)
 .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
 .It \(bu
 \\(bu (bullet)
 .It \(ba
index d7fbc69ad2694664838c19d0d50f847e2b2dc368..3e2f70f05dbc74549f01920e6606adb86a7161f9 100644 (file)
@@ -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 <kristaps@kth.se>
  *
 /*
  * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -16,6 +16,8 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
+#include <sys/utsname.h>
+
 #include <assert.h>
 #include <ctype.h>
 #include <err.h>
 #include <assert.h>
 #include <ctype.h>
 #include <err.h>
@@ -674,15 +676,21 @@ footer(struct termp *p, const struct mdoc_meta *meta)
 static void
 header(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;
        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 == (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 */
                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:
                        pp = mdoc_vol2a(VOL_KM);
                        break;
                default:
-                       /* FIXME: capitalise. */
-                       if (NULL == (pp = mdoc_msec2a(meta->msec)))
-                               pp = mdoc_msec2a(MSEC_local);
                        break;
                }
                        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
 
        /*
         * 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)",
 
        if (mdoc_arch2a(meta->arch))
                (void)snprintf(buf, p->rmargin, "%s (%s)",
-                               pp, mdoc_arch2a(meta->arch));
+                               vbuf, mdoc_arch2a(meta->arch));
        else
        else
-               (void)strlcpy(buf, pp, p->rmargin);
+               (void)strlcpy(buf, vbuf, p->rmargin);
 
        pp = mdoc_msec2a(meta->msec);
 
 
        pp = mdoc_msec2a(meta->msec);
 
@@ -767,5 +784,6 @@ header(struct termp *p, const struct mdoc_meta *meta)
        p->flags &= ~TERMP_NOSPACE;
 
        free(title);
        p->flags &= ~TERMP_NOSPACE;
 
        free(title);
+       free(vbuf);
        free(buf);
 }
        free(buf);
 }
index 87a9b35e8da9b27d1df47da87f41550f9f8066f3..896971a9e56eeea28b3394d1a22646bd33e8a10e 100644 (file)
--- 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 <kristaps@kth.se>
  *
 /*
  * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -472,23 +472,23 @@ mdoc_vol2a(enum mdoc_vol vol)
 
        switch (vol) {
        case (VOL_AMD):
 
        switch (vol) {
        case (VOL_AMD):
-               return("OpenBSD Ancestral Manual Documents");
+               return("Ancestral Manual Documents");
        case (VOL_IND):
        case (VOL_IND):
-               return("OpenBSD Manual Master Index");
+               return("Manual Master Index");
        case (VOL_KM):
        case (VOL_KM):
-               return("OpenBSD Kernel Manual");
+               return("Kernel Manual");
        case (VOL_LOCAL):
        case (VOL_LOCAL):
-               return("OpenBSD Local Manual");
+               return("Local Manual");
        case (VOL_PRM):
        case (VOL_PRM):
-               return("OpenBSD Programmer's Manual");
+               return("Programmer's Manual");
        case (VOL_PS1):
        case (VOL_PS1):
-               return("OpenBSD Programmer's Supplementary Documents");
+               return("Programmer's Supplementary Documents");
        case (VOL_SMM):
        case (VOL_SMM):
-               return("OpenBSD System Manager's Manual");
+               return("System Manager's Manual");
        case (VOL_URM):
        case (VOL_URM):
-               return("OpenBSD Reference Manual");
+               return("Reference Manual");
        case (VOL_USD):
        case (VOL_USD):
-               return("OpenBSD User's Supplementary Documents");
+               return("User's Supplementary Documents");
        case (VOL_DEFAULT):
                return(NULL);
        default:
        case (VOL_DEFAULT):
                return(NULL);
        default: