summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-23 15:41:09 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-23 15:41:09 +0000
commit364660607f78ece4469bf93ed5a754c04ec61847 (patch)
tree98a745094e489116617f1e7baa6ab167c9c4ed3e
parent1b03ebdce412e8ef752ed49e9aba8d666cdc9bf2 (diff)
downloadmandoc-364660607f78ece4469bf93ed5a754c04ec61847.tar.gz
mandoc-364660607f78ece4469bf93ed5a754c04ec61847.tar.zst
mandoc-364660607f78ece4469bf93ed5a754c04ec61847.zip
-man linked to mandoc in documentation.
-rw-r--r--libman.h3
-rw-r--r--libmdoc.h4
-rw-r--r--main.c6
-rw-r--r--man.c11
-rw-r--r--man_hash.c4
-rw-r--r--man_macro.c16
-rw-r--r--mandoc.151
-rw-r--r--mdoc.c17
-rw-r--r--mdoc_macro.c7
9 files changed, 82 insertions, 37 deletions
diff --git a/libman.h b/libman.h
index 7359799b..4054b22f 100644
--- a/libman.h
+++ b/libman.h
@@ -1,4 +1,4 @@
-/* $Id: libman.h,v 1.2 2009/03/23 15:20:51 kristaps Exp $ */
+/* $Id: libman.h,v 1.3 2009/03/23 15:41:09 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 722fde26..5819fe9d 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.1 2009/03/23 14:22:11 kristaps Exp $ */
+/* $Id: libmdoc.h,v 1.2 2009/03/23 15:41:09 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 6e0ed5c8..3601b7af 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.11 2009/03/23 15:20:51 kristaps Exp $ */
+/* $Id: main.c,v 1.12 2009/03/23 15:41:09 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 484d125e..86dc3e4f 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.2 2009/03/23 15:20:51 kristaps Exp $ */
+/* $Id: man.c,v 1.3 2009/03/23 15:41:09 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 918258e1..de4546f5 100644
--- a/man_hash.c
+++ b/man_hash.c
@@ -1,4 +1,4 @@
-/* $Id: man_hash.c,v 1.1 2009/03/23 14:22:11 kristaps Exp $ */
+/* $Id: man_hash.c,v 1.2 2009/03/23 15:41:09 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 942f3a69..baeea39f 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.3 2009/03/23 15:20:51 kristaps Exp $ */
+/* $Id: man_macro.c,v 1.4 2009/03/23 15:41:09 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 8cc56b2b..9a66e74b 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.7 2009/03/23 09:42:43 kristaps Exp $
+.\" $Id: mandoc.1,v 1.8 2009/03/23 15:41:09 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
.\"
@@ -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 d508e8ef..47eb517f 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.71 2009/03/23 15:20:51 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.72 2009/03/23 15:41:09 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 15fe4609..c73d4312 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.1 2009/03/23 14:22:11 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.2 2009/03/23 15:41:09 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
@@ -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 ?