summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-06-11 13:13:44 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-06-11 13:13:44 +0000
commit2677411c0d09fa40d38fa39fd550e9c9068f5959 (patch)
tree0ea1d4a2725f7aa1b77bba2f4ca621d3ae0779ff
parent956a32ced8b03e63533433f33625ce01588e46a7 (diff)
downloadmandoc-2677411c0d09fa40d38fa39fd550e9c9068f5959.tar.gz
mandoc-2677411c0d09fa40d38fa39fd550e9c9068f5959.tar.zst
mandoc-2677411c0d09fa40d38fa39fd550e9c9068f5959.zip
Added mdoc.template (from NetBSD -- unlicensed??).
Moved MDOC_TEXT type checks into assertions (should be caught by parser). Added some FIXME notes in mdoc output (largely that things should be asserted, not caught).
-rw-r--r--mdoc.template38
-rw-r--r--mdoc_term.c40
2 files changed, 59 insertions, 19 deletions
diff --git a/mdoc.template b/mdoc.template
new file mode 100644
index 00000000..e9f70665
--- /dev/null
+++ b/mdoc.template
@@ -0,0 +1,38 @@
+.\" $\&Id$
+.\"
+.\" Copyright notice goes here.
+.\"
+.\" The uncommented requests are required for all man pages.
+.\" The commented requests should be uncommented and used where appropriate.
+.\"
+.\" See mdoc(7) for further reference.
+.\"
+.Dd $\&Mdocdate$
+.Dt DOCUMENT_TITLE SECTION
+.Os
+.Sh NAME
+.\" The next request should be used for sections 2 and 3 only.
+.\" .Sh LIBRARY
+.Sh SYNOPSIS
+.Sh DESCRIPTION
+.\" This next request is for sections 1 and 8 exit statuses only.
+.\" .Sh EXIT STATUS
+.\" This next request is for sections 2 and 3 function return values only.
+.\" .Sh RETURN VALUES
+.\" This next request is for sections 1, 6, 7 & 8 only.
+.\" .Sh ENVIRONMENT
+.\" .Sh FILES
+.\" .Sh EXAMPLES
+.\" This next request is for sections 1, 6, 7 & 8 only
+.\" .Sh DIAGNOSTICS
+.\" The next request is for sections 2 and 3 error and signal handling only.
+.\" .Sh ERRORS
+.\" .Sh SEE ALSO
+.\" Cross-references should be ordered by section (low to high), then in
+.\" alphabetical order.
+.\" .Sh STANDARDS
+.\" .Sh HISTORY
+.\" .Sh AUTHORS
+.\" .Sh CAVEATS
+.\" .Sh BUGS
+.\" .Sh SECURITY CONSIDERATIONS
diff --git a/mdoc_term.c b/mdoc_term.c
index 2e071de2..07aef10c 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.10 2009/06/11 12:55:30 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.11 2009/06/11 13:13:44 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -592,6 +592,8 @@ arg_listtype(const struct mdoc_node *n)
break;
}
+ /* FIXME: mandated by parser. */
+
errx(1, "list type not supported");
/* NOTREACHED */
}
@@ -610,6 +612,7 @@ arg_offset(const struct mdoc_argv *arg)
return(INDENT * 2);
/* FIXME: needs to support field-widths (10n, etc.). */
+
return(strlen(*arg->value));
}
@@ -1071,6 +1074,8 @@ termp_rv_pre(DECL_ARGS)
{
int i;
+ /* FIXME: mandated by parser. */
+
if (-1 == (i = arg_getattr(MDOC_Std, node)))
errx(1, "expected -std argument");
if (1 != node->args->argv[i].sz)
@@ -1104,6 +1109,8 @@ termp_ex_pre(DECL_ARGS)
{
int i;
+ /* FIXME: mandated by parser? */
+
if (-1 == (i = arg_getattr(MDOC_Std, node)))
errx(1, "expected -std argument");
if (1 != node->args->argv[i].sz)
@@ -1157,8 +1164,9 @@ termp_xr_pre(DECL_ARGS)
{
const struct mdoc_node *n;
- if (NULL == (n = node->child))
- errx(1, "expected text line argument");
+ assert(node->child && MDOC_TEXT == node->child->type);
+ n = node->child;
+
term_word(p, n->string);
if (NULL == (n = n->next))
return(0);
@@ -1292,8 +1300,7 @@ termp_lb_pre(DECL_ARGS)
{
const char *lb;
- if (NULL == node->child)
- errx(1, "expected text line argument");
+ assert(node->child && MDOC_TEXT == node->child->type);
if ((lb = mdoc_a2lib(node->child->string))) {
term_word(p, lb);
return(0);
@@ -1401,8 +1408,7 @@ termp_fn_pre(DECL_ARGS)
{
const struct mdoc_node *n;
- if (NULL == node->child)
- errx(1, "expected text line arguments");
+ assert(node->child && MDOC_TEXT == node->child->type);
/* FIXME: can be "type funcname" "type varname"... */
@@ -1509,6 +1515,8 @@ termp_bd_pre(DECL_ARGS)
else if (MDOC_BODY != node->type)
return(1);
+ /* FIXME: display type should be mandated by parser. */
+
if (NULL == node->parent->args)
errx(1, "missing display type");
@@ -1957,8 +1965,7 @@ termp_fo_pre(DECL_ARGS)
p->flags |= ttypes[TTYPE_FUNC_NAME];
for (n = node->child; n; n = n->next) {
- if (MDOC_TEXT != n->type)
- errx(1, "expected text line argument");
+ assert(MDOC_TEXT == n->type);
term_word(p, n->string);
}
p->flags &= ~ttypes[TTYPE_FUNC_NAME];
@@ -2002,9 +2009,7 @@ termp_bf_pre(DECL_ARGS)
return(1);
}
- if (MDOC_TEXT != n->type)
- errx(1, "expected text line arguments");
-
+ assert(MDOC_TEXT == n->type);
if (0 == strcmp("Em", n->string))
TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_EMPH]);
else if (0 == strcmp("Sy", n->string))
@@ -2040,9 +2045,7 @@ static int
termp_sm_pre(DECL_ARGS)
{
- if (NULL == node->child || MDOC_TEXT != node->child->type)
- errx(1, "expected boolean line argument");
-
+ assert(node->child && MDOC_TEXT == node->child->type);
if (0 == strcmp("on", node->child->string)) {
p->flags &= ~TERMP_NONOSPACE;
p->flags &= ~TERMP_NOSPACE;
@@ -2113,8 +2116,8 @@ termp_lk_pre(DECL_ARGS)
{
const struct mdoc_node *n;
- if (NULL == (n = node->child))
- errx(1, "expected line argument");
+ assert(node->child);
+ n = node->child;
p->flags |= ttypes[TTYPE_LINK_ANCHOR];
term_word(p, n->string);
@@ -2123,9 +2126,8 @@ termp_lk_pre(DECL_ARGS)
term_word(p, ":");
p->flags |= ttypes[TTYPE_LINK_TEXT];
- for ( ; n; n = n->next) {
+ for ( ; n; n = n->next)
term_word(p, n->string);
- }
p->flags &= ~ttypes[TTYPE_LINK_TEXT];
return(0);