Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/mdocml/dist Merge mdocml-1.10.1



details:   https://anonhg.NetBSD.org/src/rev/247f97bc61f3
branches:  trunk
changeset: 755842:247f97bc61f3
user:      joerg <joerg%NetBSD.org@localhost>
date:      Thu Jun 24 17:19:58 2010 +0000

description:
Merge mdocml-1.10.1

diffstat:

 external/bsd/mdocml/dist/man_term.c    |    9 +-
 external/bsd/mdocml/dist/mdoc_action.c |  181 +++++++++++++-------------------
 external/bsd/mdocml/dist/mdoc_term.c   |  171 +++++++++---------------------
 3 files changed, 130 insertions(+), 231 deletions(-)

diffs (truncated from 729 to 300 lines):

diff -r 68666c52f381 -r 247f97bc61f3 external/bsd/mdocml/dist/man_term.c
--- a/external/bsd/mdocml/dist/man_term.c       Thu Jun 24 17:16:37 2010 +0000
+++ b/external/bsd/mdocml/dist/man_term.c       Thu Jun 24 17:19:58 2010 +0000
@@ -1,6 +1,6 @@
-/*     $Vendor-Id: man_term.c,v 1.73 2010/06/07 20:57:09 kristaps Exp $ */
+/*     $Vendor-Id: man_term.c,v 1.76 2010/06/19 20:46:28 kristaps Exp $ */
 /*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
+ * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps%bsd.lv@localhost>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -73,9 +73,9 @@
 static int               a2width(const struct man_node *);
 static int               a2height(const struct man_node *);
 
-static void              print_man_head(struct termp *, const void *);
 static void              print_man_nodelist(DECL_ARGS);
 static void              print_man_node(DECL_ARGS);
+static void              print_man_head(struct termp *, const void *);
 static void              print_man_foot(struct termp *, const void *);
 static void              print_bvspace(struct termp *, 
                                const struct man_node *);
@@ -158,6 +158,7 @@
 
        p->overstep = 0;
        p->maxrmargin = p->defrmargin;
+       p->tabwidth = 5;
 
        if (NULL == p->symtab)
                switch (p->enc) {
@@ -172,7 +173,7 @@
        n = man_node(man);
        m = man_meta(man);
 
-       term_begin(p, print_man_head, print_man_foot, man_meta(man));
+       term_begin(p, print_man_head, print_man_foot, m);
        p->flags |= TERMP_NOSPACE;
 
        mt.fl = 0;
diff -r 68666c52f381 -r 247f97bc61f3 external/bsd/mdocml/dist/mdoc_action.c
--- a/external/bsd/mdocml/dist/mdoc_action.c    Thu Jun 24 17:16:37 2010 +0000
+++ b/external/bsd/mdocml/dist/mdoc_action.c    Thu Jun 24 17:19:58 2010 +0000
@@ -1,6 +1,6 @@
-/*     $Vendor-Id: mdoc_action.c,v 1.65 2010/06/03 13:44:36 kristaps Exp $ */
+/*     $Vendor-Id: mdoc_action.c,v 1.71 2010/06/19 20:46:28 kristaps Exp $ */
 /*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps%kth.se@localhost>
+ * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps%bsd.lv@localhost>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -68,9 +68,7 @@
 static int       post_std(POST_ARGS);
 
 static int       pre_bd(PRE_ARGS);
-static int       pre_bl(PRE_ARGS);
 static int       pre_dl(PRE_ARGS);
-static int       pre_offset(PRE_ARGS);
 
 static const struct actions mdoc_actions[MDOC_MAX] = {
        { NULL, NULL }, /* Ap */
@@ -84,7 +82,7 @@
        { pre_dl, post_display }, /* Dl */
        { pre_bd, post_display }, /* Bd */ 
        { NULL, NULL }, /* Ed */
-       { pre_bl, post_bl }, /* Bl */ 
+       { NULL, post_bl }, /* Bl */ 
        { NULL, NULL }, /* El */
        { NULL, NULL }, /* It */
        { NULL, NULL }, /* Ad */ 
@@ -633,33 +631,34 @@
 post_bl_tagwidth(POST_ARGS)
 {
        struct mdoc_node *nn;
-       size_t            sz;
+       size_t            sz, ssz;
        int               i;
        char              buf[NUMSIZ];
 
-       /* Defaults to ten ens. */
-
-       sz = 10; /* XXX: make this a macro value. */
+       sz = 10;
 
        for (nn = n->body->child; nn; nn = nn->next) {
-               if (MDOC_It == nn->tok)
-                       break;
-       }
+               if (MDOC_It != nn->tok)
+                       continue;
 
-       if (nn) {
                assert(MDOC_BLOCK == nn->type);
                nn = nn->head->child;
-               if (MDOC_TEXT != nn->type) {
-                       sz = mdoc_macro2len(nn->tok);
-                       if (sz == 0) {
-                               if ( ! mdoc_nmsg(m, n, MANDOCERR_NOWIDTHARG))
-                                       return(0);
-                               sz = 10;
-                       }
-               } else
+
+               if (MDOC_TEXT == nn->type) {
                        sz = strlen(nn->string) + 1;
+                       break;
+               }
+
+               if (0 != (ssz = mdoc_macro2len(nn->tok)))
+                       sz = ssz;
+               else if ( ! mdoc_nmsg(m, n, MANDOCERR_NOWIDTHARG))
+                       return(0);
+
+               break;
        } 
 
+       /* Defaults to ten ens. */
+
        snprintf(buf, NUMSIZ, "%zun", sz);
 
        /*
@@ -667,19 +666,21 @@
         * We're guaranteed that a MDOC_Width doesn't already exist.
         */
 
-       nn = n;
-       assert(nn->args);
-       i = (int)(nn->args->argc)++;
+       assert(n->args);
+       i = (int)(n->args->argc)++;
 
-       nn->args->argv = mandoc_realloc(nn->args->argv, 
-                       nn->args->argc * sizeof(struct mdoc_argv));
+       n->args->argv = mandoc_realloc(n->args->argv, 
+                       n->args->argc * sizeof(struct mdoc_argv));
 
-       nn->args->argv[i].arg = MDOC_Width;
-       nn->args->argv[i].line = n->line;
-       nn->args->argv[i].pos = n->pos;
-       nn->args->argv[i].sz = 1;
-       nn->args->argv[i].value = mandoc_malloc(sizeof(char *));
-       nn->args->argv[i].value[0] = mandoc_strdup(buf);
+       n->args->argv[i].arg = MDOC_Width;
+       n->args->argv[i].line = n->line;
+       n->args->argv[i].pos = n->pos;
+       n->args->argv[i].sz = 1;
+       n->args->argv[i].value = mandoc_malloc(sizeof(char *));
+       n->args->argv[i].value[0] = mandoc_strdup(buf);
+
+       /* Set our width! */
+       n->data.Bl.width = n->args->argv[i].value[0];
        return(1);
 }
 
@@ -696,36 +697,35 @@
        int               i;
        enum mdoct        tok;
        char              buf[NUMSIZ];
-       char             *p;
-
-       if (NULL == n->args)
-               return(1);
-
-       for (i = 0; i < (int)n->args->argc; i++)
-               if (MDOC_Width == n->args->argv[i].arg)
-                       break;
-
-       if (i == (int)n->args->argc)
-               return(1);
-       p = n->args->argv[i].value[0];
 
        /*
         * If the value to -width is a macro, then we re-write it to be
         * the macro's width as set in share/tmac/mdoc/doc-common.
         */
 
-       if (0 == strcmp(p, "Ds"))
+       if (0 == strcmp(n->data.Bl.width, "Ds"))
                width = 6;
-       else if (MDOC_MAX == (tok = mdoc_hash_find(p)))
+       else if (MDOC_MAX == (tok = mdoc_hash_find(n->data.Bl.width)))
                return(1);
        else if (0 == (width = mdoc_macro2len(tok))) 
                return(mdoc_nmsg(m, n, MANDOCERR_BADWIDTH));
 
        /* The value already exists: free and reallocate it. */
 
+       assert(n->args);
+
+       for (i = 0; i < (int)n->args->argc; i++) 
+               if (MDOC_Width == n->args->argv[i].arg)
+                       break;
+
+       assert(i < (int)n->args->argc);
+
        snprintf(buf, NUMSIZ, "%zun", width);
        free(n->args->argv[i].value[0]);
        n->args->argv[i].value[0] = mandoc_strdup(buf);
+
+       /* Set our width! */
+       n->data.Bl.width = n->args->argv[i].value[0];
        return(1);
 }
 
@@ -741,7 +741,9 @@
        int                      i, c;
        struct mdoc_node        *np, *nn, *nnp;
 
-       if (NULL == n->child)
+       if (LIST_column != n->data.Bl.type)
+               return(1);
+       else if (NULL == n->child)
                return(1);
 
        np = n->parent;
@@ -751,8 +753,7 @@
                if (MDOC_Column == np->args->argv[c].arg)
                        break;
 
-       if (c == (int)np->args->argc)
-               return(1);
+       assert(c < (int)np->args->argc);
        assert(0 == np->args->argv[c].sz);
 
        /*
@@ -782,7 +783,8 @@
 static int
 post_bl(POST_ARGS)
 {
-       int               i, r, len;
+       struct mdoc_node *nn;
+       const char       *ww;
 
        if (MDOC_HEAD == n->type)
                return(post_bl_head(m, n));
@@ -797,21 +799,27 @@
         * rewritten into real lengths).
         */
 
-       len = (int)(n->args ? n->args->argc : 0);
+       ww = n->data.Bl.width;
 
-       for (r = i = 0; i < len; i++) {
-               if (MDOC_Tag == n->args->argv[i].arg)
-                       r |= 1 << 0;
-               if (MDOC_Width == n->args->argv[i].arg)
-                       r |= 1 << 1;
-       }
-
-       if (r & (1 << 0) && ! (r & (1 << 1))) {
+       if (LIST_tag == n->data.Bl.type && NULL == n->data.Bl.width) {
                if ( ! post_bl_tagwidth(m, n))
                        return(0);
-       } else if (r & (1 << 1))
+       } else if (NULL != n->data.Bl.width) {
                if ( ! post_bl_width(m, n))
                        return(0);
+       } else 
+               return(1);
+
+       assert(n->data.Bl.width);
+
+       /* If it has changed, propogate new width to children. */
+
+       if (ww == n->data.Bl.width)
+               return(1);
+
+       for (nn = n->child; nn; nn = nn->next)
+               if (MDOC_Bl == nn->tok)
+                       nn->data.Bl.width = n->data.Bl.width;
 
        return(1);
 }
@@ -831,7 +839,6 @@
        
        np = n;
        m->next = MDOC_NEXT_CHILD;
-       /* XXX: make into macro value. */
        if ( ! mdoc_word_alloc(m, n->line, n->pos, "~"))
                return(0);
        m->last = np;
@@ -937,61 +944,17 @@
 }
 
 
-/* ARGSUSED */
-static int
-pre_offset(PRE_ARGS)
-{
-       int              i;
-
-       /* 
-        * Make sure that an empty offset produces an 8n length space as
-        * stipulated by mdoc.samples. 
-        */
-
-       for (i = 0; n->args && i < (int)n->args->argc; i++) {
-               if (MDOC_Offset != n->args->argv[i].arg) 
-                       continue;



Home | Main Index | Thread Index | Old Index