aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--libmdoc.h4
-rw-r--r--man.724
-rw-r--r--mdoc.730
-rw-r--r--mdoc.h7
-rw-r--r--mdoc.template4
-rw-r--r--mdoc_action.c4
-rw-r--r--mdoc_strings.c64
-rw-r--r--mdoc_validate.c13
8 files changed, 73 insertions, 77 deletions
diff --git a/libmdoc.h b/libmdoc.h
index 395d7794..8b76c95f 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.40 2010/05/09 10:17:02 kristaps Exp $ */
+/* $Id: libmdoc.h,v 1.41 2010/05/12 08:41:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -162,7 +162,7 @@ enum mdoct mdoc_hash_find(const char *);
int mdoc_iscdelim(char);
int mdoc_isdelim(const char *);
size_t mdoc_isescape(const char *);
-enum mdoc_sec mdoc_atosec(const char *);
+enum mdoc_sec mdoc_str2sec(const char *);
time_t mdoc_atotime(const char *);
size_t mdoc_macro2len(enum mdoct);
const char *mdoc_a2att(const char *);
diff --git a/man.7 b/man.7
index f410ced3..42a4044d 100644
--- a/man.7
+++ b/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.66 2010/05/08 22:26:39 kristaps Exp $
+.\" $Id: man.7,v 1.67 2010/05/12 08:41:17 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 8 2010 $
+.Dd $Mdocdate: May 12 2010 $
.Dt MAN 7
.Os
.Sh NAME
@@ -232,13 +232,13 @@ are generally structured as follows:
The \efBfoo\efR utility processes files...
\&.
\&.\e\*q .SH IMPLEMENTATION NOTES
-\&.\e\*q The next is for sections 1 & 8 only.
-\&.\e\*q .SH EXIT STATUS
\&.\e\*q The next is for sections 2, 3, & 9 only.
\&.\e\*q .SH RETURN VALUES
\&.\e\*q The next is for sections 1, 6, 7, & 8 only.
\&.\e\*q .SH ENVIRONMENT
\&.\e\*q .SH FILES
+\&.\e\*q The next is for sections 1 & 8 only.
+\&.\e\*q .SH EXIT STATUS
\&.\e\*q .SH EXAMPLES
\&.\e\*q The next is for sections 1, 4, 6, 7, & 8 only.
\&.\e\*q .SH DIAGNOSTICS
@@ -298,14 +298,6 @@ command).
Implementation-specific notes should be kept here. This is useful when
implementing standard functions that may have side effects or notable
algorithmic implications.
-.It Em EXIT STATUS
-Command exit status for section 1, 6, and 8 manuals. This section is
-the dual of
-.Em RETURN VALUES ,
-which is used for functions. Historically, this information was
-described in
-.Em DIAGNOSTICS ,
-a practise that is now discouraged.
.It Em RETURN VALUES
This section is the dual of
.Em EXIT STATUS ,
@@ -317,6 +309,14 @@ Documents any usages of environment variables, e.g.,
.It Em FILES
Documents files used. It's helpful to document both the file and a
short description of how the file is used (created, modified, etc.).
+.It Em EXIT STATUS
+Command exit status for section 1, 6, and 8 manuals. This section is
+the dual of
+.Em RETURN VALUES ,
+which is used for functions. Historically, this information was
+described in
+.Em DIAGNOSTICS ,
+a practise that is now discouraged.
.It Em EXAMPLES
Example usages. This often contains snippets of well-formed,
well-tested invocations. Make doubly sure that your examples work
diff --git a/mdoc.7 b/mdoc.7
index 2d62a604..d58b5d60 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.98 2010/05/08 22:26:39 kristaps Exp $
+.\" $Id: mdoc.7,v 1.99 2010/05/12 08:41:17 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 8 2010 $
+.Dd $Mdocdate: May 12 2010 $
.Dt MDOC 7
.Os
.Sh NAME
@@ -334,13 +334,13 @@ The
\&.Nm
utility processes files ...
\&.\e\*q .Sh IMPLEMENTATION NOTES
-\&.\e\*q The next is for sections 1 & 8 only.
-\&.\e\*q .Sh EXIT STATUS
\&.\e\*q The next is for sections 2, 3, & 9 only.
\&.\e\*q .Sh RETURN VALUES
\&.\e\*q The next is for sections 1, 6, 7, & 8 only.
\&.\e\*q .Sh ENVIRONMENT
\&.\e\*q .Sh FILES
+\&.\e\*q The next is for sections 1 & 8 only.
+\&.\e\*q .Sh EXIT STATUS
\&.\e\*q .Sh EXAMPLES
\&.\e\*q The next is for sections 1, 4, 6, 7, & 8 only.
\&.\e\*q .Sh DIAGNOSTICS
@@ -452,17 +452,6 @@ Manuals not documenting a command won't include the above fragment.
Implementation-specific notes should be kept here. This is useful when
implementing standard functions that may have side effects or notable
algorithmic implications.
-.It Em EXIT STATUS
-Command exit status for section 1, 6, and 8 manuals. This section is
-the dual of
-.Em RETURN VALUES ,
-which is used for functions. Historically, this information was
-described in
-.Em DIAGNOSTICS ,
-a practise that is now discouraged.
-.Pp
-See
-.Sx \&Ex .
.It Em RETURN VALUES
This section is the dual of
.Em EXIT STATUS ,
@@ -483,6 +472,17 @@ short description of how the file is used (created, modified, etc.).
.Pp
See
.Sx \&Pa .
+.It Em EXIT STATUS
+Command exit status for section 1, 6, and 8 manuals. This section is
+the dual of
+.Em RETURN VALUES ,
+which is used for functions. Historically, this information was
+described in
+.Em DIAGNOSTICS ,
+a practise that is now discouraged.
+.Pp
+See
+.Sx \&Ex .
.It Em EXAMPLES
Example usages. This often contains snippets of well-formed,
well-tested invocations. Make doubly sure that your examples work
diff --git a/mdoc.h b/mdoc.h
index 2abb1d40..44641612 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.75 2010/05/09 21:19:42 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.76 2010/05/12 08:41:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -202,10 +202,10 @@ enum mdoc_sec {
SEC_SYNOPSIS,
SEC_DESCRIPTION,
SEC_IMPLEMENTATION,
- SEC_EXIT_STATUS,
SEC_RETURN_VALUES,
SEC_ENVIRONMENT,
SEC_FILES,
+ SEC_EXIT_STATUS,
SEC_EXAMPLES,
SEC_DIAGNOSTICS,
SEC_COMPATIBILITY,
@@ -217,7 +217,8 @@ enum mdoc_sec {
SEC_CAVEATS,
SEC_BUGS,
SEC_SECURITY,
- SEC_CUSTOM /* User-defined. */
+ SEC_CUSTOM, /* User-defined. */
+ SEC__MAX
};
/* Information from prologue. */
diff --git a/mdoc.template b/mdoc.template
index 5122f882..f26a83e6 100644
--- a/mdoc.template
+++ b/mdoc.template
@@ -19,13 +19,13 @@
.Sh SYNOPSIS
.Sh DESCRIPTION
.\" .Sh IMPLEMENTATION NOTES
-.\" The next is for sections 1 & 8 only.
-.\" .Sh EXIT STATUS
.\" The next is for sections 2, 3, & 9 only.
.\" .Sh RETURN VALUES
.\" The next is for sections 1, 6, 7 & 8 only.
.\" .Sh ENVIRONMENT
.\" .Sh FILES
+.\" The next is for sections 1 & 8 only.
+.\" .Sh EXIT STATUS
.\" .Sh EXAMPLES
.\" The next is for sections 1, 4, 6, 7, & 8 only
.\" .Sh DIAGNOSTICS
diff --git a/mdoc_action.c b/mdoc_action.c
index b9b95f99..f84542d4 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.54 2010/05/08 07:30:19 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.55 2010/05/12 08:41:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -419,7 +419,7 @@ post_sh(POST_ARGS)
if ( ! concat(m, buf, n->child, BUFSIZ))
return(0);
- sec = mdoc_atosec(buf);
+ sec = mdoc_str2sec(buf);
/*
* The first section should always make us move into a non-new
* state.
diff --git a/mdoc_strings.c b/mdoc_strings.c
index 33f5da15..ff8eba1f 100644
--- a/mdoc_strings.c
+++ b/mdoc_strings.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_strings.c,v 1.18 2010/05/09 21:06:50 kristaps Exp $ */
+/* $Id: mdoc_strings.c,v 1.19 2010/05/12 08:41:17 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -28,39 +28,31 @@
#include "libmdoc.h"
-/* FIXME: this file is poorly named. */
-
-struct mdoc_secname {
- const char *name; /* Name of section. */
- enum mdoc_sec sec; /* Corresponding section. */
-};
-
-#define SECNAME_MAX (20)
-
-static const struct mdoc_secname secnames[SECNAME_MAX] = {
- { "NAME", SEC_NAME },
- { "LIBRARY", SEC_LIBRARY },
- { "SYNOPSIS", SEC_SYNOPSIS },
- { "DESCRIPTION", SEC_DESCRIPTION },
- { "IMPLEMENTATION NOTES", SEC_IMPLEMENTATION },
- { "EXIT STATUS", SEC_EXIT_STATUS },
- { "RETURN VALUES", SEC_RETURN_VALUES },
- { "ENVIRONMENT", SEC_ENVIRONMENT },
- { "FILES", SEC_FILES },
- { "EXAMPLES", SEC_EXAMPLES },
- { "DIAGNOSTICS", SEC_DIAGNOSTICS },
- { "COMPATIBILITY", SEC_COMPATIBILITY },
- { "ERRORS", SEC_ERRORS },
- { "SEE ALSO", SEC_SEE_ALSO },
- { "STANDARDS", SEC_STANDARDS },
- { "HISTORY", SEC_HISTORY },
- { "AUTHORS", SEC_AUTHORS },
- { "CAVEATS", SEC_CAVEATS },
- { "BUGS", SEC_BUGS },
- { "SECURITY CONSIDERATIONS", SEC_SECURITY }
+static const char * const secnames[SEC__MAX] = {
+ NULL,
+ "NAME",
+ "LIBRARY",
+ "SYNOPSIS",
+ "DESCRIPTION",
+ "IMPLEMENTATION NOTES",
+ "RETURN VALUES",
+ "ENVIRONMENT",
+ "FILES",
+ "EXIT STATUS",
+ "EXAMPLES",
+ "DIAGNOSTICS",
+ "COMPATIBILITY",
+ "ERRORS",
+ "SEE ALSO",
+ "STANDARDS",
+ "HISTORY",
+ "AUTHORS",
+ "CAVEATS",
+ "BUGS",
+ "SECURITY CONSIDERATIONS",
+ NULL
};
-
/*
* FIXME: this is repeated in print_text() (html.c) and term_word()
* (term.c).
@@ -119,13 +111,13 @@ mdoc_isdelim(const char *p)
enum mdoc_sec
-mdoc_atosec(const char *p)
+mdoc_str2sec(const char *p)
{
int i;
- for (i = 0; i < SECNAME_MAX; i++)
- if (0 == strcmp(p, secnames[i].name))
- return(secnames[i].sec);
+ for (i = 0; i < (int)SEC__MAX; i++)
+ if (secnames[i] && 0 == strcmp(p, secnames[i]))
+ return((enum mdoc_sec)i);
return(SEC_CUSTOM);
}
diff --git a/mdoc_validate.c b/mdoc_validate.c
index a25ae856..85d78e1e 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.71 2010/05/09 21:19:42 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.72 2010/05/12 08:41:17 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -1286,21 +1286,24 @@ post_sh_head(POST_ARGS)
return(mdoc_nerr(mdoc, n, ETOOLONG));
}
- sec = mdoc_atosec(buf);
+ sec = mdoc_str2sec(buf);
/*
* Check: NAME should always be first, CUSTOM has no roles,
* non-CUSTOM has a conventional order to be followed.
*/
- if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed &&
- ! mdoc_nwarn(mdoc, mdoc->last, ESECNAME))
- return(0);
+ if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed)
+ if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECNAME))
+ return(0);
+
if (SEC_CUSTOM == sec)
return(1);
+
if (sec == mdoc->lastnamed)
if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECREP))
return(0);
+
if (sec < mdoc->lastnamed)
if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECOOO))
return(0);