summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libman.h1
-rw-r--r--libmdoc.h2
-rw-r--r--main.c4
-rw-r--r--man.c9
-rw-r--r--man_hash.c2
-rw-r--r--man_macro.c14
-rw-r--r--mandoc.149
-rw-r--r--mdoc.c15
-rw-r--r--mdoc_macro.c5
9 files changed, 73 insertions, 28 deletions
diff --git a/libman.h b/libman.h
index e2a5261a..101ea093 100644
--- a/libman.h
+++ b/libman.h
@@ -47,6 +47,7 @@ int man_macro(struct man *, int,
int, int, int *, char *);
int man_hash_find(const void *, const char *);
void man_hash_free(void *);
+int man_macroend(struct man *);
__END_DECLS
diff --git a/libmdoc.h b/libmdoc.h
index 45ddf010..2b8f355d 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -153,7 +153,7 @@ int xstrlcpy(char *, const char *, size_t);
int xstrcmp(const char *, const char *);
void *xrealloc(void *, size_t);
char *xstrdup(const char *);
-int macro_end(struct mdoc *);
+int mdoc_macroend(struct mdoc *);
__END_DECLS
diff --git a/main.c b/main.c
index 1016e31d..f6ed5af6 100644
--- a/main.c
+++ b/main.c
@@ -271,7 +271,9 @@ __dead static void
usage(void)
{
- (void)fprintf(stderr, "usage: %s\n", __progname);
+ (void)fprintf(stderr, "usage: %s [-V] [-foption...] "
+ "[-mformat] [-Toutput] [-Werr...]\n",
+ __progname);
exit(1);
/* NOTREACHED */
}
diff --git a/man.c b/man.c
index 48e26619..e66315c6 100644
--- a/man.c
+++ b/man.c
@@ -102,8 +102,12 @@ int
man_endparse(struct man *m)
{
- /* FIXME. */
- return(1);
+ if (MAN_HALT & m->flags)
+ return(0);
+ else if (man_macroend(m))
+ return(1);
+ m->flags |= MAN_HALT;
+ return(0);
}
@@ -334,3 +338,4 @@ err: /* Error out. */
m->flags |= MAN_HALT;
return(0);
}
+
diff --git a/man_hash.c b/man_hash.c
index 418c0b83..bffb5bac 100644
--- a/man_hash.c
+++ b/man_hash.c
@@ -49,6 +49,8 @@ man_hash_find(const void *arg, const char *tmp)
{
int i;
+ /* TODO */
+
for (i = 0; i < MAN_MAX; i++)
if (0 == strcasecmp(tmp, man_macronames[i]))
return(i);
diff --git a/man_macro.c b/man_macro.c
index 2bea77a8..05a95d22 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -56,8 +56,7 @@ man_macro(struct man *man, int tok, int line,
man->next = MAN_NEXT_SIBLING;
}
- /* TODO: validate. */
- /* TODO: validate. */
+ /* TODO: validate & actions. */
man->last = n;
man->next = MAN_NEXT_SIBLING;
@@ -66,8 +65,17 @@ man_macro(struct man *man, int tok, int line,
}
-/* ARGSUSED */
int
+man_macroend(struct man *m)
+{
+
+ /* TODO: validate & actions. */
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
man_args(struct man *man, int line,
int *pos, char *buf, char **v)
{
diff --git a/mandoc.1 b/mandoc.1
index 528d2445..726b529b 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -22,12 +22,13 @@
.\" SECTION
.Sh NAME
.Nm mandoc
-.Nd format and display BSD manuals
+.Nd format and display UNIX manuals
.\" SECTION
.Sh SYNOPSIS
.Nm mandoc
.Op Fl V
.Op Fl f Ns Ar option...
+.Op Fl m Ns Ar format
.Op Fl W Ns Ar err...
.Op Fl T Ns Ar output
.Op Ar infile...
@@ -35,9 +36,9 @@
.Sh DESCRIPTION
The
.Nm
-utility formats a BSD
-.Dq mdoc
-manual page for display. The arguments are as follows:
+utility formats
+.Ux
+manual pages for display. The arguments are as follows:
.Bl -tag -width XXXXXXXXXXXX
.\" ITEM
.It Fl f Ns Ar option...
@@ -45,6 +46,12 @@ Override default compiler behaviour. See
.Sx Compiler Options
for details.
.\" ITEM
+.It Fl m
+Input format. See
+.Sx Input Formats
+for available formats. Defaults to
+.Fl m Ns Ar mdoc .
+.\" ITEM
.It Fl T
Output format. See
.Sx Output Formats
@@ -80,15 +87,18 @@ will halt with the first failed parse.
.Pp
By default,
.Nm
-reads from stdin and prints 78-column backspace-encoded output to stdout
-as if
+reads
+.Xr mdoc 7
+text from stdin, implying
+.Fl m Ns Ar mdoc ,
+and prints 78-column backspace-encoded output to stdout as if
.Fl T Ns Ar ascii
were provided.
.\" PARAGRAPH
.Pp
.Ex -std mandoc
.\" SUB-SECTION
-.Ss Reserved Words
+.Ss Reserved Words (mdoc only)
The reserved words described in
.Xr mdoc 7
are handled according to the following rules:
@@ -132,6 +142,30 @@ However, if the comma were part of
.Dq ,empirically ,
it would not.
.\" SUB-SECTION
+.Ss Input Formats
+The
+.Nm
+utility accepts
+.Xr mdoc 7
+and
+.Xr man 7
+input with
+.Fl m Ns Ar mdoc
+and
+.Fl m Ns Ar man ,
+respectively. The
+.Xr mdoc 7
+format is
+.Em strongly
+recommended;
+.Xr man 7
+should only be used for legacy manuals.
+.Pp
+Note that the
+.Fl m Ns Ar man
+option is experimental and only works with
+.Fl T Ns Ar tree .
+.\" SUB-SECTION
.Ss Output Formats
The
.Nm
@@ -156,6 +190,7 @@ flag.
.It Fl f Ns Ar ign-scope
When rewinding the scope of a block macro, forces the compiler to ignore
scope violations. This can seriously mangle the resulting tree.
+.Pq mdoc only
.It Fl f Ns Ar ign-escape
Ignore invalid escape sequences.
.It Fl f Ns Ar ign-macro
diff --git a/mdoc.c b/mdoc.c
index 3c6735a6..97d490ca 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -204,20 +204,15 @@ mdoc_alloc(void *data, int pflags, const struct mdoc_cb *cb)
* through to macro_end in macro.c.
*/
int
-mdoc_endparse(struct mdoc *mdoc)
+mdoc_endparse(struct mdoc *m)
{
- if (MDOC_HALT & mdoc->flags)
+ if (MDOC_HALT & m->flags)
return(0);
- if (NULL == mdoc->first)
+ else if (mdoc_macroend(m))
return(1);
-
- assert(mdoc->last);
- if ( ! macro_end(mdoc)) {
- mdoc->flags |= MDOC_HALT;
- return(0);
- }
- return(1);
+ m->flags |= MDOC_HALT;
+ return(0);
}
diff --git a/mdoc_macro.c b/mdoc_macro.c
index bcc6132e..6693b132 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -305,13 +305,10 @@ swarn(struct mdoc *mdoc, enum mdoc_type type,
* are errors.
*/
int
-macro_end(struct mdoc *mdoc)
+mdoc_macroend(struct mdoc *mdoc)
{
struct mdoc_node *n;
- assert(mdoc->first);
- assert(mdoc->last);
-
/* Scan for open explicit scopes. */
n = MDOC_VALID & mdoc->last->flags ?