]> git.cameronkatri.com Git - mandoc.git/blobdiff - term.c
Added new old escape sequence \*[nn].
[mandoc.git] / term.c
diff --git a/term.c b/term.c
index f9d60a8d74ddf1bccf7aa3b1e74133f1d93908ea..8096238733bd82b7f638e9fa777f52cfb56ca76f 100644 (file)
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.31 2009/03/01 13:06:49 kristaps Exp $ */
+/* $Id: term.c,v 1.35 2009/03/02 17:14:46 kristaps Exp $ */
 /*
  * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
  *
 /*
  * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -25,8 +25,6 @@
 
 #include "term.h"
 
 
 #include "term.h"
 
-#define        INDENT            6
-
 /*
  * Performs actions on nodes of the abstract syntax tree.  Both pre- and
  * post-fix operations are defined here.
 /*
  * Performs actions on nodes of the abstract syntax tree.  Both pre- and
  * post-fix operations are defined here.
@@ -934,6 +932,9 @@ static int
 termp_ft_pre(DECL_ARGS)
 {
 
 termp_ft_pre(DECL_ARGS)
 {
 
+       if (SEC_SYNOPSIS == node->sec)
+               if (node->prev && MDOC_Fo == node->prev->tok)
+                       vspace(p);
        TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_FUNC_TYPE]);
        return(1);
 }
        TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_FUNC_TYPE]);
        return(1);
 }
@@ -944,7 +945,7 @@ static void
 termp_ft_post(DECL_ARGS)
 {
 
 termp_ft_post(DECL_ARGS)
 {
 
-       if (node->sec == SEC_SYNOPSIS)
+       if (SEC_SYNOPSIS == node->sec)
                newln(p);
 }
 
                newln(p);
 }
 
@@ -1050,8 +1051,8 @@ static int
 termp_bd_pre(DECL_ARGS)
 {
        const struct mdoc_block *bl;
 termp_bd_pre(DECL_ARGS)
 {
        const struct mdoc_block *bl;
-       const struct mdoc_node *n;
-       int              i;
+       const struct mdoc_node  *n;
+       int              i, type;
 
        if (MDOC_BLOCK == node->type) {
                if (node->prev)
 
        if (MDOC_BLOCK == node->type) {
                if (node->prev)
@@ -1060,11 +1061,27 @@ termp_bd_pre(DECL_ARGS)
        } else if (MDOC_BODY != node->type)
                return(1);
 
        } else if (MDOC_BODY != node->type)
                return(1);
 
-       assert(MDOC_BLOCK == node->parent->type);
        pair->offset = p->offset;
        pair->offset = p->offset;
-
        bl = &node->parent->data.block;
 
        bl = &node->parent->data.block;
 
+       for (type = -1, i = 0; i < (int)bl->argc; i++) {
+               switch (bl->argv[i].arg) {
+               case (MDOC_Ragged):
+                       /* FALLTHROUGH */
+               case (MDOC_Filled):
+                       /* FALLTHROUGH */
+               case (MDOC_Unfilled):
+                       /* FALLTHROUGH */
+               case (MDOC_Literal):
+                       type = bl->argv[i].arg;
+                       i = (int)bl->argc;
+                       break;
+               default:
+                       errx(1, "display type not supported");
+               }
+       }
+
+       assert(-1 != type);
 
        i = arg_getattr(MDOC_Offset, bl->argc, bl->argv);
        if (-1 != i) {
 
        i = arg_getattr(MDOC_Offset, bl->argc, bl->argv);
        if (-1 != i) {
@@ -1072,22 +1089,27 @@ termp_bd_pre(DECL_ARGS)
                p->offset += arg_offset(&bl->argv[i]);
        }
 
                p->offset += arg_offset(&bl->argv[i]);
        }
 
-       if ( ! arg_hasattr(MDOC_Literal, bl->argc, bl->argv))
+
+       switch (type) {
+       case (MDOC_Literal):
+               /* FALLTHROUGH */
+       case (MDOC_Unfilled):
+               break;
+       default:
                return(1);
                return(1);
+       }
 
        p->flags |= TERMP_LITERAL;
 
        for (n = node->child; n; n = n->next) {
 
        p->flags |= TERMP_LITERAL;
 
        for (n = node->child; n; n = n->next) {
-               assert(MDOC_TEXT == n->type); /* FIXME */
-               if ((*n->data.text.string)) {
-                       word(p, n->data.text.string);
-                       flushln(p);
-               } else
-                       vspace(p);
-
+               if (MDOC_TEXT != n->type) {
+                       warnx("non-text children not yet allowed");
+                       continue;
+               }
+               word(p, n->data.text.string);
+               flushln(p);
        }
 
        }
 
-       p->flags &= ~TERMP_LITERAL;
        return(0);
 }
 
        return(0);
 }
 
@@ -1099,7 +1121,11 @@ termp_bd_post(DECL_ARGS)
 
        if (MDOC_BODY != node->type) 
                return;
 
        if (MDOC_BODY != node->type) 
                return;
-       newln(p);
+
+       if ( ! (p->flags & TERMP_LITERAL))
+               flushln(p);
+
+       p->flags &= ~TERMP_LITERAL;
        p->offset = pair->offset;
 }
 
        p->offset = pair->offset;
 }
 
@@ -1144,7 +1170,8 @@ static void
 termp_bx_post(DECL_ARGS)
 {
 
 termp_bx_post(DECL_ARGS)
 {
 
-       p->flags |= TERMP_NOSPACE;
+       if (node->child)
+               p->flags |= TERMP_NOSPACE;
        word(p, "BSD");
 }
 
        word(p, "BSD");
 }
 
@@ -1295,6 +1322,7 @@ termp_cd_pre(DECL_ARGS)
 {
 
        TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CONFIG]);
 {
 
        TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_CONFIG]);
+       newln(p);
        return(1);
 }
 
        return(1);
 }