]> git.cameronkatri.com Git - mandoc.git/commitdiff
*** empty log message ***
authorKristaps Dzonsons <kristaps@bsd.lv>
Tue, 9 Dec 2008 19:57:26 +0000 (19:57 +0000)
committerKristaps Dzonsons <kristaps@bsd.lv>
Tue, 9 Dec 2008 19:57:26 +0000 (19:57 +0000)
Makefile
html.c
literals.c
roff.c

index 42b194ba9351666c3304bd65e01e9148b17ba53c..6e85967042d048b46e45ffaa721c57fcf466e1b2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -57,11 +57,11 @@ www: $(HTML) $(XML)
 regress: mdocml
        @for f in $(FAIL); do \
                echo "./mdocml $$f" ; \
-               ./mdocml $$f 1>/dev/null 2>/dev/null || continue ; \
+               ./mdocml -v $$f 1>/dev/null 2>/dev/null || continue ; \
        done
        @for f in $(SUCCEED); do \
                echo "./mdocml $$f" ; \
-               ./mdocml $$f 1>/dev/null || exit 1 ; \
+               ./mdocml -v $$f 1>/dev/null || exit 1 ; \
        done
 
 mdocml: mdocml.o libmdocml.a
diff --git a/html.c b/html.c
index c969b8f0ec4d51cfd5cd21cc19b022db256d85d6..c96770b1a0f84bb50f4f888d17ad8f14dc661bcc 100644 (file)
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.17 2008/12/09 17:09:12 kristaps Exp $ */
+/* $Id: html.c,v 1.18 2008/12/09 19:57:26 kristaps Exp $ */
 /*
  * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
  *
 #include "ml.h"
 
 #define        TAG_HTML        "<html>"
+#define        TAG_HTML_END    "</html>"
 #define        TAG_BODY        "<body>"
+#define        TAG_BODY_END    "</body>"
 #define        TAG_DIV_MDOC    "<div class=\"mdoc\">"
+#define        TAG_DIV_END     "</div>"
 #define        TAG_STYLE_CSS   "<style type=\"text/css\"><!--"
 #define        TAG_STYLE_END   "--></style>"
 #define        TAG_HEAD        "<head>"
@@ -367,6 +370,31 @@ out:
 }
 
 
+static int
+html_putline(struct md_mbuf *mbuf, size_t indent, 
+               const char *p, size_t *res)
+{
+
+       /* FIXME: use INDENT macro for this. */
+       if ( ! ml_putchars(mbuf, ' ', indent * 4, res))
+               return(0);
+       if ( ! ml_puts(mbuf, p, res))
+               return(0);
+       return(ml_nputs(mbuf, "\n", 1, res));
+}
+
+
+static int
+html_putlinestart(struct md_mbuf *mbuf, size_t indent,
+               const char *p, size_t *res)
+{
+
+       if ( ! ml_putchars(mbuf, ' ', indent * 4, res))
+               return(0);
+       return(ml_puts(mbuf, p, res));
+}
+
+
 /* ARGSUSED */
 static int 
 html_begin(struct md_mbuf *mbuf, const struct md_args *args,
@@ -375,7 +403,7 @@ html_begin(struct md_mbuf *mbuf, const struct md_args *args,
                const char *vol)
 {
        char             mtitle[128], css[128];
-       size_t           res;
+       size_t           i;
 
        (void)snprintf(mtitle, sizeof(mtitle), 
                        "Manual Page for %s(%s)",
@@ -383,63 +411,68 @@ html_begin(struct md_mbuf *mbuf, const struct md_args *args,
        (void)snprintf(css, sizeof(css), 
                        TAG_LINK_CSS, args->params.html.css);
 
-       res = 0;
+       i = 0;
 
-       if ( ! ml_puts(mbuf, TAG_DOCTYPE, &res))
-               return(0);
-       if ( ! ml_nputs(mbuf, "\n", 1, &res))
-               return(0);
-       if ( ! ml_puts(mbuf, TAG_HTML, &res))
+       if ( ! html_putline(mbuf, i, TAG_DOCTYPE, NULL))
                return(0);
-       if ( ! ml_nputs(mbuf, "\n", 1, &res))
+       if ( ! html_putline(mbuf, i, TAG_HTML, NULL))
                return(0);
-       if ( ! ml_puts(mbuf, TAG_BODY, &res))
+       if ( ! html_putline(mbuf, i++, TAG_HEAD, NULL))
                return(0);
-       if ( ! ml_nputs(mbuf, "\n", 1, &res))
+       if ( ! html_putline(mbuf, i, TAG_CONTTYPE, NULL))
                return(0);
-       if ( ! ml_puts(mbuf, TAG_CONTTYPE, &res))
+       if ( ! html_putline(mbuf, i, TAG_RESTYPE, NULL))
                return(0);
-       if ( ! ml_nputs(mbuf, "\n", 1, &res))
+       if ( ! html_putlinestart(mbuf, i, TAG_TITLE, NULL))
                return(0);
-       if ( ! ml_puts(mbuf, TAG_RESTYPE, &res))
+       if ( ! ml_putstring(mbuf, mtitle, NULL))
                return(0);
-       if ( ! ml_nputs(mbuf, "\n", 1, &res))
-               return(0);
-       if ( ! ml_puts(mbuf, TAG_TITLE, &res))
-               return(0);
-       if ( ! ml_putstring(mbuf, mtitle, &res))
-               return(0);
-       if ( ! ml_puts(mbuf, TAG_TITLE_END, &res))
-               return(0);
-       if ( ! ml_nputs(mbuf, "\n", 1, &res))
+       if ( ! html_putline(mbuf, i, TAG_TITLE_END, NULL))
                return(0);
 
        if (HTML_CSS_EMBED & args->params.html.flags) {
-               if ( ! ml_puts(mbuf, TAG_STYLE_CSS, &res))
-                       return(0);
-               if ( ! ml_puts(mbuf, "\n", &res))
+               if ( ! html_putline(mbuf, i, TAG_STYLE_CSS, NULL))
                        return(0);
                if ( ! html_loadcss(mbuf, args->params.html.css))
                        return(0);
-               if ( ! ml_puts(mbuf, TAG_STYLE_END, &res))
+               if ( ! html_putline(mbuf, i, TAG_STYLE_END, NULL))
                        return(0);
-       } else if ( ! ml_puts(mbuf, css, &res))
+       } else if ( ! html_putline(mbuf, i, css, NULL))
                return(0);
 
-       if ( ! ml_puts(mbuf, "\n", &res))
+       if ( ! html_putline(mbuf, --i, TAG_HEAD_END, NULL))
                return(0);
-
-       if ( ! ml_puts(mbuf, TAG_HEAD_END, &res))
+       if ( ! html_putline(mbuf, i, TAG_BODY, NULL))
+               return(0);
+       if ( ! html_putline(mbuf, i, TAG_DIV_MDOC, NULL))
+               return(0);
+       if ( ! html_putline(mbuf, i++, "<table width=\"100%\">", NULL))
+               return(0);
+       if ( ! html_putline(mbuf, i++, "<tr>", NULL))
+               return(0);
+       if ( ! html_putline(mbuf, i++, "<td align=\"left\">", NULL))
                return(0);
-       if ( ! ml_nputs(mbuf, "\n", 1, &res))
+       if ( ! ml_putstring(mbuf, title, NULL))
                return(0);
-       if ( ! ml_puts(mbuf, TAG_BODY, &res))
+       if ( ! html_putline(mbuf, --i, "</td>", NULL))
                return(0);
-       if ( ! ml_nputs(mbuf, "\n", 1, &res))
+       if ( ! html_putline(mbuf, i++, "<td align=\"center\">", NULL))
                return(0);
-       if ( ! ml_puts(mbuf, TAG_DIV_MDOC, &res))
+       if ( ! ml_putstring(mbuf, "Hello, world.", NULL))
                return(0);
-       return(ml_nputs(mbuf, "\n", 1, &res));
+       if ( ! html_putline(mbuf, --i, "</td>", NULL))
+               return(0);
+       if ( ! html_putline(mbuf, i++, "<td align=\"right\">", NULL))
+               return(0);
+       if ( ! ml_putstring(mbuf, title, NULL))
+               return(0);
+       if ( ! html_putline(mbuf, --i, "</td>", NULL))
+               return(0);
+       if ( ! html_putline(mbuf, --i, "</tr>", NULL))
+               return(0);
+       if ( ! html_putline(mbuf, --i, "</table>", NULL))
+               return(0);
+       return(1);
 }
 
 
@@ -448,7 +481,11 @@ static int
 html_end(struct md_mbuf *mbuf, const struct md_args *args)
 {
 
-       return(ml_puts(mbuf, "</div></body>\n</html>", NULL));
+       if ( ! html_putline(mbuf, 0, TAG_DIV_END, NULL))
+               return(0);
+       if ( ! html_putline(mbuf, 0, TAG_BODY_END, NULL))
+               return(0);
+       return(html_putline(mbuf, 0, TAG_HTML_END, NULL));
 }
 
 
index f4252e94bcd53462a57a850ba80aa064c436f6ed..364726765bc65092bab1b87947da02b1a997e209 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: literals.c,v 1.5 2008/12/09 17:09:12 kristaps Exp $ */
+/* $Id: literals.c,v 1.6 2008/12/09 19:57:26 kristaps Exp $ */
 /*
  * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -23,7 +23,7 @@
 #include "private.h"
 
 #define        ROFF_ATTname_V1         "v1"
-#define        ROFF_ATTname_V2         "v1"
+#define        ROFF_ATTname_V2         "v2"
 #define        ROFF_ATTname_V3         "v3"
 #define        ROFF_ATTname_V6         "v6"
 #define        ROFF_ATTname_V7         "v7"
diff --git a/roff.c b/roff.c
index cd6bca3a9ab5adec868a808bba2f17ab9edf7289..e4c973ba4eef0d85affac9c095be67aee386256d 100644 (file)
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.55 2008/12/09 17:09:12 kristaps Exp $ */
+/* $Id: roff.c,v 1.56 2008/12/09 19:57:26 kristaps Exp $ */
 /*
  * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -704,7 +704,7 @@ roffspecial(struct rofftree *tree, int tok, const char *start,
        case (ROFF_At):
                if (0 == sz)
                        break;
-               if (ROFF_ATT_MAX == roff_att(*ordp))
+               if (ROFF_ATT_MAX != roff_att(*ordp))
                        break;
                return(roff_errp(tree, *ordp, tok, ERR_BADARG));