]> git.cameronkatri.com Git - mandoc.git/blobdiff - mdoctree.c
Bumped minor-number.
[mandoc.git] / mdoctree.c
index 444dde48211f4a3ff2efc2eab7d112850acf9c2e..6507034816f3fcd74470d1da79216d97b8b9b33c 100644 (file)
@@ -1,4 +1,4 @@
-       /* $Id: mdoctree.c,v 1.3 2009/02/23 07:09:13 kristaps Exp $ */
+       /* $Id: mdoctree.c,v 1.6 2009/03/08 14:01:46 kristaps Exp $ */
 /*
  * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -31,16 +31,15 @@ static      void    doprint(const struct mdoc_node *, int);
 int
 main(int argc, char *argv[])
 {
-       struct mmain    *p;
+       struct mmain      *p;
+       int                c;
        const struct mdoc *mdoc;
 
-       extern int       optreset;
-       extern int       optind;
-
        p = mmain_alloc();
 
-       if ( ! mmain_getopt(p, argc, argv, NULL, NULL, NULL, NULL))
-               mmain_exit(p, 1);
+       c = mmain_getopt(p, argc, argv, NULL, NULL, NULL, NULL);
+       if (1 != c) 
+               mmain_exit(p, -1 == c ? 1 : 0);
 
        if (NULL == (mdoc = mmain_mdoc(p)))
                mmain_exit(p, 1);
@@ -58,7 +57,7 @@ doprint(const struct mdoc_node *n, int indent)
        int               i, j;
        size_t            argc, sz;
        char            **params;
-       struct mdoc_arg  *argv;
+       struct mdoc_argv *argv;
 
        argv = NULL;
        argc = sz = 0;
@@ -93,7 +92,7 @@ doprint(const struct mdoc_node *n, int indent)
 
        switch (n->type) {
        case (MDOC_TEXT):
-               p = n->data.text.string;
+               p = n->string;
                break;
        case (MDOC_BODY):
                p = mdoc_macronames[n->tok];
@@ -106,13 +105,17 @@ doprint(const struct mdoc_node *n, int indent)
                break;
        case (MDOC_ELEM):
                p = mdoc_macronames[n->tok];
-               argv = n->data.elem.argv;
-               argc = n->data.elem.argc;
+               if (n->args) {
+                       argv = n->args->argv;
+                       argc = n->args->argc;
+               }
                break;
        case (MDOC_BLOCK):
                p = mdoc_macronames[n->tok];
-               argv = n->data.block.argv;
-               argc = n->data.block.argc;
+               if (n->args) {
+                       argv = n->args->argv;
+                       argc = n->args->argc;
+               }
                break;
        case (MDOC_ROOT):
                p = "root";