diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-03-23 15:41:09 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-03-23 15:41:09 +0000 |
commit | b657e31a9ec6631499c82ab01201bfb7db357ba3 (patch) | |
tree | b4d902aaa9d17e0684c61f1912c194589fb05bc1 | |
parent | 858ffa5feefe929dcf0dabf5d771106577f1d9e7 (diff) | |
download | mandoc-b657e31a9ec6631499c82ab01201bfb7db357ba3.tar.gz |
-man linked to mandoc in documentation.
-rw-r--r-- | libman.h | 1 | ||||
-rw-r--r-- | libmdoc.h | 2 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | man.c | 9 | ||||
-rw-r--r-- | man_hash.c | 2 | ||||
-rw-r--r-- | man_macro.c | 14 | ||||
-rw-r--r-- | mandoc.1 | 49 | ||||
-rw-r--r-- | mdoc.c | 15 | ||||
-rw-r--r-- | mdoc_macro.c | 5 |
9 files changed, 73 insertions, 28 deletions
@@ -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 @@ -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 @@ -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 */ } @@ -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); } + @@ -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) { @@ -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 @@ -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 ? |