]> git.cameronkatri.com Git - mandoc.git/blobdiff - mdoc_html.c
Do not report a page as arch=any merely because .Dt lacks the third argument.
[mandoc.git] / mdoc_html.c
index 07a2e3ec5ffbb223fad3d2f894a3e0c6ac3c4bcc..5b0497a8b3db6dda79afc80dab132a5e5aa3ad23 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mdoc_html.c,v 1.191 2014/07/02 03:48:07 schwarze Exp $ */
+/*     $Id: mdoc_html.c,v 1.199 2014/08/21 12:57:17 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,9 +15,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include <sys/types.h>
 
@@ -380,8 +378,9 @@ print_mdoc_head(MDOC_ARGS)
 
        print_gen_head(h);
        bufinit(h);
-       bufcat_fmt(h, "%s(%s)", meta->title, meta->msec);
-
+       bufcat(h, meta->title);
+       if (meta->msec)
+               bufcat_fmt(h, "(%s)", meta->msec);
        if (meta->arch)
                bufcat_fmt(h, " (%s)", meta->arch);
 
@@ -525,7 +524,11 @@ mdoc_root_pre(MDOC_ARGS)
                mandoc_asprintf(&volume, "%s (%s)",
                    meta->vol, meta->arch);
 
-       mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec);
+       if (NULL == meta->msec)
+               title = mandoc_strdup(meta->title);
+       else
+               mandoc_asprintf(&title, "%s(%s)",
+                   meta->title, meta->msec);
 
        PAIR_SUMMARY_INIT(&tag[0], "Document Header");
        PAIR_CLASS_INIT(&tag[1], "head");
@@ -637,9 +640,10 @@ mdoc_fl_pre(MDOC_ARGS)
 
        print_text(h, "\\-");
 
-       if (n->child)
-               h->flags |= HTML_NOSPACE;
-       else if (n->next && n->next->line == n->line)
+       if ( ! (n->nchild == 0 &&
+           (n->next == NULL ||
+            n->next->type == MDOC_TEXT ||
+            n->next->flags & MDOC_LINE)))
                h->flags |= HTML_NOSPACE;
 
        return(1);
@@ -699,7 +703,7 @@ mdoc_nm_pre(MDOC_ARGS)
        if (0 == len && meta->name)
                len = html_strlen(meta->name);
 
-       SCALE_HS_INIT(&su, (double)len);
+       SCALE_HS_INIT(&su, len);
        bufinit(h);
        bufcat_su(h, "width", &su);
        PAIR_STYLE_INIT(&tag, h);
@@ -1069,11 +1073,11 @@ mdoc_ex_pre(MDOC_ARGS)
        }
 
        if (nchild > 1)
-               print_text(h, "utilities exit");
+               print_text(h, "utilities exit\\~0");
        else
-               print_text(h, "utility exits");
+               print_text(h, "utility exits\\~0");
 
-       print_text(h, "0 on success, and >0 if an error occurs.");
+       print_text(h, "on success, and\\~>0 if an error occurs.");
        return(0);
 }
 
@@ -1524,23 +1528,16 @@ static int
 mdoc_sm_pre(MDOC_ARGS)
 {
 
-       assert(n->child && MDOC_TEXT == n->child->type);
-       if (0 == strcmp("on", n->child->string)) {
-               /*
-                * FIXME: no p->col to check.  Thus, if we have
-                *  .Bd -literal
-                *  .Sm off
-                *  1 2
-                *  .Sm on
-                *  3
-                *  .Ed
-                * the "3" is preceded by a space.
-                */
-               h->flags &= ~HTML_NOSPACE;
+       if (NULL == n->child)
+               h->flags ^= HTML_NONOSPACE;
+       else if (0 == strcmp("on", n->child->string))
                h->flags &= ~HTML_NONOSPACE;
-       else
+       else
                h->flags |= HTML_NONOSPACE;
 
+       if ( ! (HTML_NONOSPACE & h->flags))
+               h->flags &= ~HTML_NOSPACE;
+
        return(0);
 }
 
@@ -1572,7 +1569,7 @@ mdoc_sp_pre(MDOC_ARGS)
                        if ( ! a2roffsu(n->string, &su, SCALE_VS))
                                SCALE_VS_INIT(&su, atoi(n->string));
        } else
-               su.scale = 0;
+               su.scale = 0.0;
 
        bufinit(h);
        bufcat_su(h, "height", &su);
@@ -1751,35 +1748,41 @@ mdoc_rv_pre(MDOC_ARGS)
 
        PAIR_CLASS_INIT(&tag, "fname");
 
-       print_text(h, "The");
-
        nchild = n->nchild;
-       for (n = n->child; n; n = n->next) {
-               assert(MDOC_TEXT == n->type);
-
-               t = print_otag(h, TAG_B, 1, &tag);
-               print_text(h, n->string);
-               print_tagq(h, t);
+       if (nchild > 0) {
+               print_text(h, "The");
 
-               h->flags |= HTML_NOSPACE;
-               print_text(h, "()");
+               for (n = n->child; n; n = n->next) {
+                       t = print_otag(h, TAG_B, 1, &tag);
+                       print_text(h, n->string);
+                       print_tagq(h, t);
 
-               if (nchild > 2 && n->next) {
                        h->flags |= HTML_NOSPACE;
-                       print_text(h, ",");
+                       print_text(h, "()");
+
+                       if (n->next == NULL)
+                               continue;
+
+                       if (nchild > 2) {
+                               h->flags |= HTML_NOSPACE;
+                               print_text(h, ",");
+                       }
+                       if (n->next->next == NULL)
+                               print_text(h, "and");
                }
 
-               if (n->next && NULL == n->next->next)
-                       print_text(h, "and");
-       }
+               if (nchild > 1)
+                       print_text(h, "functions return");
+               else
+                       print_text(h, "function returns");
 
-       if (nchild > 1)
-               print_text(h, "functions return");
-       else
-               print_text(h, "function returns");
+               print_text(h, "the value\\~0 if successful;");
+       } else
+               print_text(h, "Upon successful completion,"
+                    " the value\\~0 is returned;");
 
-       print_text(h, "the value 0 if successful; otherwise the "
-           "value -1 is returned and the global variable");
+       print_text(h, "otherwise the value\\~\\-1 is returned"
+          " and the global variable");
 
        PAIR_CLASS_INIT(&tag, "var");
        t = print_otag(h, TAG_B, 1, &tag);