Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/mdocml Update to 1.9.13 and merge.



details:   https://anonhg.NetBSD.org/src/rev/6bb25f6ed1bb
branches:  trunk
changeset: 748806:6bb25f6ed1bb
user:      joerg <joerg%NetBSD.org@localhost>
date:      Thu Nov 05 18:28:10 2009 +0000

description:
Update to 1.9.13 and merge.

diffstat:

 external/bsd/mdocml/Makefile.inc       |    4 +-
 external/bsd/mdocml/dist/mdoc_action.c |  378 +++++++++++++++++---------------
 2 files changed, 202 insertions(+), 180 deletions(-)

diffs (truncated from 758 to 300 lines):

diff -r 1f891f6640a7 -r 6bb25f6ed1bb external/bsd/mdocml/Makefile.inc
--- a/external/bsd/mdocml/Makefile.inc  Thu Nov 05 18:24:50 2009 +0000
+++ b/external/bsd/mdocml/Makefile.inc  Thu Nov 05 18:28:10 2009 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile.inc,v 1.2 2009/10/26 14:55:12 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.3 2009/11/05 18:28:10 joerg Exp $
 
 .include <bsd.own.mk>
 
-VERSION=       1.9.10
+VERSION=       1.9.13
 
 CPPFLAGS+=     -DVERSION=\"${VERSION}\"
 
diff -r 1f891f6640a7 -r 6bb25f6ed1bb external/bsd/mdocml/dist/mdoc_action.c
--- a/external/bsd/mdocml/dist/mdoc_action.c    Thu Nov 05 18:24:50 2009 +0000
+++ b/external/bsd/mdocml/dist/mdoc_action.c    Thu Nov 05 18:28:10 2009 +0000
@@ -1,4 +1,4 @@
-/*     $Vendor-Id: mdoc_action.c,v 1.44 2009/10/26 04:09:45 kristaps Exp $ */
+/*     $Vendor-Id: mdoc_action.c,v 1.49 2009/11/02 06:22:45 kristaps Exp $ */
 /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
  *
@@ -19,25 +19,27 @@
 #endif
 
 #include <assert.h>
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 
 #include "libmdoc.h"
+#include "libmandoc.h"
 
 #define        POST_ARGS struct mdoc *m, struct mdoc_node *n
 #define        PRE_ARGS  struct mdoc *m, const struct mdoc_node *n
 
+#define        NUMSIZ    32
+#define        DATESIZ   32
+
 struct actions {
        int     (*pre)(PRE_ARGS);
        int     (*post)(POST_ARGS);
 };
 
-static int       concat(struct mdoc *, 
-                       const struct mdoc_node *, 
-                       char *, size_t);
+static int       concat(struct mdoc *, char *,
+                       const struct mdoc_node *, size_t);
 static inline int order_rs(int);
 
 #ifdef __linux__
@@ -56,12 +58,12 @@
 static int       post_lb(POST_ARGS);
 static int       post_nm(POST_ARGS);
 static int       post_os(POST_ARGS);
+static int       post_pa(POST_ARGS);
 static int       post_prol(POST_ARGS);
 static int       post_rs(POST_ARGS);
 static int       post_sh(POST_ARGS);
 static int       post_st(POST_ARGS);
 static int       post_std(POST_ARGS);
-static int       post_tilde(POST_ARGS);
 
 static int       pre_bd(PRE_ARGS);
 static int       pre_bl(PRE_ARGS);
@@ -104,7 +106,7 @@
        { NULL, post_nm }, /* Nm */ 
        { NULL, NULL }, /* Op */
        { NULL, NULL }, /* Ot */
-       { NULL, post_tilde }, /* Pa */
+       { NULL, post_pa }, /* Pa */
        { NULL, post_std }, /* Rv */
        { NULL, post_st }, /* St */
        { NULL, NULL }, /* Va */
@@ -208,7 +210,8 @@
        MDOC__Q,
        MDOC__D,
        MDOC__O,
-       MDOC__C
+       MDOC__C,
+       MDOC__U
 };
 
 
@@ -254,18 +257,24 @@
 }
 
 
+/*
+ * Concatenate sibling nodes together.  All siblings must be of type
+ * MDOC_TEXT or an assertion is raised.  Concatenation is separated by a
+ * single whitespace.
+ */
 static int
-concat(struct mdoc *m, const struct mdoc_node *n, 
-               char *buf, size_t sz)
+concat(struct mdoc *m, char *p, const struct mdoc_node *n, size_t sz)
 {
 
+       assert(sz);
+       p[0] = '\0';
        for ( ; n; n = n->next) {
                assert(MDOC_TEXT == n->type);
-               if (strlcat(buf, n->string, sz) >= sz)
+               if (strlcat(p, n->string, sz) >= sz)
                        return(mdoc_nerr(m, n, ETOOLONG));
                if (NULL == n->next)
                        continue;
-               if (strlcat(buf, " ", sz) >= sz)
+               if (strlcat(p, " ", sz) >= sz)
                        return(mdoc_nerr(m, n, ETOOLONG));
        }
 
@@ -273,6 +282,10 @@
 }
 
 
+/*
+ * Macros accepting `-std' as an argument have the name of the current
+ * document (`Nm') filled in as the argument if it's not provided.
+ */
 static int
 post_std(POST_ARGS)
 {
@@ -287,29 +300,34 @@
        if ( ! mdoc_word_alloc(m, n->line, n->pos, m->meta.name))
                return(0);
        m->last = nn;
-
        return(1);
 }
 
 
+/*
+ * The `Nm' macro's first use sets the name of the document.  See also
+ * post_std(), etc.
+ */
 static int
 post_nm(POST_ARGS)
 {
-       char             buf[64];
+       char             buf[BUFSIZ];
 
        if (m->meta.name)
                return(1);
-
-       buf[0] = 0;
-       if ( ! concat(m, n->child, buf, sizeof(buf)))
+       if ( ! concat(m, buf, n->child, BUFSIZ))
                return(0);
-       if (NULL == (m->meta.name = strdup(buf)))
-               return(mdoc_nerr(m, n, EMALLOC));
-
+       m->meta.name = mandoc_strdup(buf);
        return(1);
 }
 
 
+/*
+ * Look up the value of `Lb' for matching predefined strings.  If it has
+ * one, then substitute the current value for the formatted value.  Note
+ * that the lookup may fail (we can provide arbitrary strings).
+ */
+/* ARGSUSED */
 static int
 post_lb(POST_ARGS)
 {
@@ -319,28 +337,29 @@
 
        assert(MDOC_TEXT == n->child->type);
        p = mdoc_a2lib(n->child->string);
-       if (NULL == p) {
-               sz = strlen(n->child->string) +
-                       2 + strlen("\\(lqlibrary\\(rq");
-               buf = malloc(sz);
-               if (NULL == buf)
-                       return(mdoc_nerr(m, n, EMALLOC));
-               (void)snprintf(buf, sz, "library \\(lq%s\\(rq", 
-                               n->child->string);
+
+       if (p) {
                free(n->child->string);
-               n->child->string = buf;
+               n->child->string = mandoc_strdup(p);
                return(1);
        }
 
+       sz = strlen(n->child->string) +
+               2 + strlen("\\(lqlibrary\\(rq");
+       buf = mandoc_malloc(sz);
+       snprintf(buf, sz, "library \\(lq%s\\(rq", n->child->string);
        free(n->child->string);
-       n->child->string = strdup(p);
-       if (NULL == n->child->string)
-               return(mdoc_nerr(m, n, EMALLOC));
-
+       n->child->string = buf;
        return(1);
 }
 
 
+/*
+ * Substitute the value of `St' for the corresponding formatted string.
+ * We're guaranteed that this exists (it's been verified during the
+ * validation phase).
+ */
+/* ARGSUSED */
 static int
 post_st(POST_ARGS)
 {
@@ -350,14 +369,16 @@
        p = mdoc_a2st(n->child->string);
        assert(p);
        free(n->child->string);
-       n->child->string = strdup(p);
-       if (NULL == n->child->string)
-               return(mdoc_nerr(m, n, EMALLOC));
-
+       n->child->string = mandoc_strdup(p);
        return(1);
 }
 
 
+/*
+ * Look up the standard string in a table.  We know that it exists from
+ * the validation phase, so assert on failure.  If a standard key wasn't
+ * supplied, supply the default ``AT&T UNIX''.
+ */
 static int
 post_at(POST_ARGS)
 {
@@ -369,44 +390,42 @@
                p = mdoc_a2att(n->child->string);
                assert(p);
                free(n->child->string);
-               n->child->string = strdup(p);
-               if (NULL == n->child->string)
-                       return(mdoc_nerr(m, n, EMALLOC));
+               n->child->string = mandoc_strdup(p);
                return(1);
        }
 
        nn = n;
        m->next = MDOC_NEXT_CHILD;
-
        if ( ! mdoc_word_alloc(m, nn->line, nn->pos, "AT&T UNIX"))
                return(0);
        m->last = nn;
-
        return(1);
 }
 
 
+/*
+ * Mark the current section.  The ``named'' section (lastnamed) is set
+ * whenever the current section isn't a custom section--we use this to
+ * keep track of section ordering.  Also check that the section is
+ * allowed within the document's manual section.
+ */
 static int
 post_sh(POST_ARGS)
 {
        enum mdoc_sec    sec;
-       char             buf[64];
-
-       /*
-        * We keep track of the current section /and/ the "named"
-        * section, which is one of the conventional ones, in order to
-        * check ordering.
-        */
+       char             buf[BUFSIZ];
 
        if (MDOC_HEAD != n->type)
                return(1);
 
-       buf[0] = 0;
-       if ( ! concat(m, n->child, buf, sizeof(buf)))
+       if ( ! concat(m, buf, n->child, BUFSIZ))
                return(0);
-       if (SEC_CUSTOM != (sec = mdoc_atosec(buf)))
+       sec = mdoc_atosec(buf);
+       if (SEC_CUSTOM != sec)
                m->lastnamed = sec;
 
+       /* Some sections only live in certain manual sections. */
+
        switch ((m->lastsec = sec)) {
        case (SEC_RETURN_VALUES):
                /* FALLTHROUGH */
@@ -429,6 +448,10 @@
 }
 
 
+/*
+ * Parse out the contents of `Dt'.  See in-line documentation for how we
+ * handle the various fields of this macro.



Home | Main Index | Thread Index | Old Index