summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2008-12-09 19:57:26 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2008-12-09 19:57:26 +0000
commit5181e986114c18c409bb0b17c01aa4306c15c24e (patch)
tree2ded27b85f10b0f771f6fc5a128313d0f837b2a3
parente7ff9604055db4b313427625036e15953beaaebc (diff)
downloadmandoc-5181e986114c18c409bb0b17c01aa4306c15c24e.tar.gz
*** empty log message ***
-rw-r--r--Makefile4
-rw-r--r--html.c109
-rw-r--r--literals.c2
-rw-r--r--roff.c2
4 files changed, 77 insertions, 40 deletions
diff --git a/Makefile b/Makefile
index 42b194ba..6e859670 100644
--- 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 ab5fb2cc..fd6a07ee 100644
--- a/html.c
+++ b/html.c
@@ -31,8 +31,11 @@
#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));
}
diff --git a/literals.c b/literals.c
index dfb45360..25c671e4 100644
--- a/literals.c
+++ b/literals.c
@@ -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 4e31ce0c..8ed064c6 100644
--- a/roff.c
+++ b/roff.c
@@ -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));