]> git.cameronkatri.com Git - mandoc.git/blobdiff - mdoc_term.c
Make sure manuals in architecture-independent directories are treated
[mandoc.git] / mdoc_term.c
index a5254a90ba98aca71b9c0f56cedf5fd00c40b115..e846436273da6d8117c6a89d432c2b295e3beec0 100644 (file)
@@ -1,7 +1,7 @@
-/*     $Id: mdoc_term.c,v 1.328 2015/10/06 18:32:19 schwarze Exp $ */
+/*     $Id: mdoc_term.c,v 1.331 2016/01/08 17:48:09 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012-2016 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -357,7 +357,7 @@ print_mdoc_node(DECL_ARGS)
                break;
        default:
                if (termacts[n->tok].pre &&
-                   (n->end == ENDBODY_NOT || n->nchild))
+                   (n->end == ENDBODY_NOT || n->child != NULL))
                        chld = (*termacts[n->tok].pre)
                                (p, &npair, meta, n);
                break;
@@ -598,7 +598,7 @@ static int
 termp_ll_pre(DECL_ARGS)
 {
 
-       term_setwidth(p, n->nchild ? n->child->string : NULL);
+       term_setwidth(p, n->child != NULL ? n->child->string : NULL);
        return 0;
 }
 
@@ -625,11 +625,8 @@ termp_it_pre(DECL_ARGS)
 
        switch (type) {
        case LIST_bullet:
-               /* FALLTHROUGH */
        case LIST_dash:
-               /* FALLTHROUGH */
        case LIST_hyphen:
-               /* FALLTHROUGH */
        case LIST_enum:
                width = term_len(p, 2);
                break;
@@ -637,7 +634,6 @@ termp_it_pre(DECL_ARGS)
                width = term_len(p, 8);
                break;
        case LIST_column:
-               /* FALLTHROUGH */
        case LIST_tag:
                width = term_len(p, 10);
                break;
@@ -735,7 +731,7 @@ termp_it_pre(DECL_ARGS)
                        term_word(p, "\\ \\ ");
                break;
        case LIST_inset:
-               if (n->type == ROFFT_BODY && n->parent->head->nchild)
+               if (n->type == ROFFT_BODY && n->parent->head->child != NULL)
                        term_word(p, "\\ ");
                break;
        default:
@@ -762,16 +758,13 @@ termp_it_pre(DECL_ARGS)
 
        switch (type) {
        case LIST_enum:
+       case LIST_bullet:
+       case LIST_dash:
+       case LIST_hyphen:
                /*
                 * Weird special case.
                 * Some very narrow lists actually hang.
                 */
-               /* FALLTHROUGH */
-       case LIST_bullet:
-               /* FALLTHROUGH */
-       case LIST_dash:
-               /* FALLTHROUGH */
-       case LIST_hyphen:
                if (width <= (int)term_len(p, 2))
                        p->flags |= TERMP_HANG;
                if (n->type != ROFFT_HEAD)
@@ -854,13 +847,9 @@ termp_it_pre(DECL_ARGS)
                        break;
                /* FALLTHROUGH */
        case LIST_bullet:
-               /* FALLTHROUGH */
        case LIST_dash:
-               /* FALLTHROUGH */
        case LIST_enum:
-               /* FALLTHROUGH */
        case LIST_hyphen:
-               /* FALLTHROUGH */
        case LIST_tag:
                if (n->type == ROFFT_HEAD)
                        p->rmargin = p->offset + width;
@@ -896,10 +885,9 @@ termp_it_pre(DECL_ARGS)
                        term_fontpop(p);
                        break;
                case LIST_dash:
-                       /* FALLTHROUGH */
                case LIST_hyphen:
                        term_fontpush(p, TERMFONT_BOLD);
-                       term_word(p, "\\(hy");
+                       term_word(p, "-");
                        term_fontpop(p);
                        break;
                case LIST_enum:
@@ -918,13 +906,9 @@ termp_it_pre(DECL_ARGS)
 
        switch (type) {
        case LIST_bullet:
-               /* FALLTHROUGH */
        case LIST_item:
-               /* FALLTHROUGH */
        case LIST_dash:
-               /* FALLTHROUGH */
        case LIST_hyphen:
-               /* FALLTHROUGH */
        case LIST_enum:
                if (n->type == ROFFT_HEAD)
                        return 0;
@@ -952,9 +936,7 @@ termp_it_post(DECL_ARGS)
 
        switch (type) {
        case LIST_item:
-               /* FALLTHROUGH */
        case LIST_diag:
-               /* FALLTHROUGH */
        case LIST_inset:
                if (n->type == ROFFT_BODY)
                        term_newln(p);
@@ -1057,7 +1039,7 @@ termp_fl_pre(DECL_ARGS)
        term_fontpush(p, TERMFONT_BOLD);
        term_word(p, "\\-");
 
-       if ( ! (n->nchild == 0 &&
+       if (!(n->child == NULL &&
            (n->next == NULL ||
             n->next->type == ROFFT_TEXT ||
             n->next->flags & MDOC_LINE)))
@@ -1124,34 +1106,33 @@ termp_rs_pre(DECL_ARGS)
 static int
 termp_rv_pre(DECL_ARGS)
 {
-       int              nchild;
+       struct roff_node *nch;
 
        term_newln(p);
 
-       nchild = n->nchild;
-       if (nchild > 0) {
+       if (n->child != NULL) {
                term_word(p, "The");
 
-               for (n = n->child; n; n = n->next) {
+               for (nch = n->child; nch != NULL; nch = nch->next) {
                        term_fontpush(p, TERMFONT_BOLD);
-                       term_word(p, n->string);
+                       term_word(p, nch->string);
                        term_fontpop(p);
 
                        p->flags |= TERMP_NOSPACE;
                        term_word(p, "()");
 
-                       if (n->next == NULL)
+                       if (nch->next == NULL)
                                continue;
 
-                       if (nchild > 2) {
+                       if (nch->prev != NULL || nch->next->next != NULL) {
                                p->flags |= TERMP_NOSPACE;
                                term_word(p, ",");
                        }
-                       if (n->next->next == NULL)
+                       if (nch->next->next == NULL)
                                term_word(p, "and");
                }
 
-               if (nchild > 1)
+               if (n->child != NULL && n->child->next != NULL)
                        term_word(p, "functions return");
                else
                        term_word(p, "function returns");
@@ -1177,27 +1158,29 @@ termp_rv_pre(DECL_ARGS)
 static int
 termp_ex_pre(DECL_ARGS)
 {
-       int              nchild;
+       struct roff_node *nch;
 
        term_newln(p);
        term_word(p, "The");
 
-       nchild = n->nchild;
-       for (n = n->child; n; n = n->next) {
+       for (nch = n->child; nch != NULL; nch = nch->next) {
                term_fontpush(p, TERMFONT_BOLD);
-               term_word(p, n->string);
+               term_word(p, nch->string);
                term_fontpop(p);
 
-               if (nchild > 2 && n->next) {
+               if (nch->next == NULL)
+                       continue;
+
+               if (nch->prev != NULL || nch->next->next != NULL) {
                        p->flags |= TERMP_NOSPACE;
                        term_word(p, ",");
                }
 
-               if (n->next && NULL == n->next->next)
+               if (nch->next->next == NULL)
                        term_word(p, "and");
        }
 
-       if (nchild > 1)
+       if (n->child != NULL && n->child->next != NULL)
                term_word(p, "utilities exit\\~0");
        else
                term_word(p, "utility exits\\~0");
@@ -1293,13 +1276,9 @@ synopsis_pre(struct termp *p, const struct roff_node *n)
         */
        switch (n->prev->tok) {
        case MDOC_Fd:
-               /* FALLTHROUGH */
        case MDOC_Fn:
-               /* FALLTHROUGH */
        case MDOC_Fo:
-               /* FALLTHROUGH */
        case MDOC_In:
-               /* FALLTHROUGH */
        case MDOC_Vt:
                term_vspace(p);
                break;
@@ -1617,19 +1596,12 @@ termp_bd_pre(DECL_ARGS)
                 */
                switch (nn->tok) {
                case MDOC_Sm:
-                       /* FALLTHROUGH */
                case MDOC_br:
-                       /* FALLTHROUGH */
                case MDOC_sp:
-                       /* FALLTHROUGH */
                case MDOC_Bl:
-                       /* FALLTHROUGH */
                case MDOC_D1:
-                       /* FALLTHROUGH */
                case MDOC_Dl:
-                       /* FALLTHROUGH */
                case MDOC_Lp:
-                       /* FALLTHROUGH */
                case MDOC_Pp:
                        continue;
                default:
@@ -1866,27 +1838,21 @@ termp_quote_pre(DECL_ARGS)
 
        switch (n->tok) {
        case MDOC_Ao:
-               /* FALLTHROUGH */
        case MDOC_Aq:
-               term_word(p, n->nchild == 1 &&
+               term_word(p, n->child != NULL && n->child->next == NULL &&
                    n->child->tok == MDOC_Mt ? "<" : "\\(la");
                break;
        case MDOC_Bro:
-               /* FALLTHROUGH */
        case MDOC_Brq:
                term_word(p, "{");
                break;
        case MDOC_Oo:
-               /* FALLTHROUGH */
        case MDOC_Op:
-               /* FALLTHROUGH */
        case MDOC_Bo:
-               /* FALLTHROUGH */
        case MDOC_Bq:
                term_word(p, "[");
                break;
        case MDOC_Do:
-               /* FALLTHROUGH */
        case MDOC_Dq:
                term_word(p, "\\(Lq");
                break;
@@ -1897,21 +1863,16 @@ termp_quote_pre(DECL_ARGS)
                term_word(p, n->norm->Es->child->string);
                break;
        case MDOC_Po:
-               /* FALLTHROUGH */
        case MDOC_Pq:
                term_word(p, "(");
                break;
        case MDOC__T:
-               /* FALLTHROUGH */
        case MDOC_Qo:
-               /* FALLTHROUGH */
        case MDOC_Qq:
                term_word(p, "\"");
                break;
        case MDOC_Ql:
-               /* FALLTHROUGH */
        case MDOC_So:
-               /* FALLTHROUGH */
        case MDOC_Sq:
                term_word(p, "\\(oq");
                break;
@@ -1934,27 +1895,21 @@ termp_quote_post(DECL_ARGS)
 
        switch (n->tok) {
        case MDOC_Ao:
-               /* FALLTHROUGH */
        case MDOC_Aq:
-               term_word(p, n->nchild == 1 &&
+               term_word(p, n->child != NULL && n->child->next == NULL &&
                    n->child->tok == MDOC_Mt ? ">" : "\\(ra");
                break;
        case MDOC_Bro:
-               /* FALLTHROUGH */
        case MDOC_Brq:
                term_word(p, "}");
                break;
        case MDOC_Oo:
-               /* FALLTHROUGH */
        case MDOC_Op:
-               /* FALLTHROUGH */
        case MDOC_Bo:
-               /* FALLTHROUGH */
        case MDOC_Bq:
                term_word(p, "]");
                break;
        case MDOC_Do:
-               /* FALLTHROUGH */
        case MDOC_Dq:
                term_word(p, "\\(Rq");
                break;
@@ -1967,21 +1922,16 @@ termp_quote_post(DECL_ARGS)
                        term_word(p, n->norm->Es->child->next->string);
                break;
        case MDOC_Po:
-               /* FALLTHROUGH */
        case MDOC_Pq:
                term_word(p, ")");
                break;
        case MDOC__T:
-               /* FALLTHROUGH */
        case MDOC_Qo:
-               /* FALLTHROUGH */
        case MDOC_Qq:
                term_word(p, "\"");
                break;
        case MDOC_Ql:
-               /* FALLTHROUGH */
        case MDOC_So:
-               /* FALLTHROUGH */
        case MDOC_Sq:
                term_word(p, "\\(cq");
                break;
@@ -2210,7 +2160,7 @@ termp_bk_pre(DECL_ARGS)
        case ROFFT_HEAD:
                return 0;
        case ROFFT_BODY:
-               if (n->parent->args || 0 == n->prev->nchild)
+               if (n->parent->args != NULL || n->prev->child == NULL)
                        p->flags |= TERMP_PREKEEP;
                break;
        default: