diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-04-05 16:34:22 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-04-05 16:34:22 +0000 |
commit | 075a3ee5ea7b8a761f32c3afd8b483dad8b67049 (patch) | |
tree | 47185381dcb0068f3a7b1e6f24cea9d7c445e13e | |
parent | 8542238145aa7d3a422b4a3975a7e994638f29e5 (diff) | |
download | mandoc-075a3ee5ea7b8a761f32c3afd8b483dad8b67049.tar.gz |
man(3) doesn't use err.h anymore.
Added .i to man(3).
Fixed up manuals.
Fixed up webpage.
Assertion fixes in man(3) (hashtable).
Fixed assertion for .IP in mandoc -man.
-rw-r--r-- | Makefile | 26 | ||||
-rw-r--r-- | ascii.c | 6 | ||||
-rw-r--r-- | index.sgml | 40 | ||||
-rw-r--r-- | man.7 | 15 | ||||
-rw-r--r-- | man.c | 59 | ||||
-rw-r--r-- | man.h | 3 | ||||
-rw-r--r-- | man_action.c | 1 | ||||
-rw-r--r-- | man_hash.c | 12 | ||||
-rw-r--r-- | man_macro.c | 1 | ||||
-rw-r--r-- | man_term.c | 13 | ||||
-rw-r--r-- | man_validate.c | 1 | ||||
-rw-r--r-- | mandoc.1 | 98 | ||||
-rw-r--r-- | style.css | 3 |
13 files changed, 157 insertions, 121 deletions
@@ -1,4 +1,4 @@ -.SUFFIXES: .html .sgml +.SUFFIXES: .html .sgml .1.txt .3.txt .7.txt .1 .3 .7 BINDIR = $(PREFIX)/bin INCLUDEDIR = $(PREFIX)/include @@ -9,8 +9,8 @@ INSTALL_DATA = install -m 0444 INSTALL_LIB = install -m 0644 INSTALL_MAN = $(INSTALL_DATA) -VERSION = 1.7.9 -VDATE = 03 April 2009 +VERSION = 1.7.10 +VDATE = 05 April 2009 VFLAGS = -DVERSION=\"$(VERSION)\" CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -g @@ -55,10 +55,13 @@ TARGZS = mdocml-$(VERSION).tar.gz \ mdocml-oport-$(VERSION).tar.gz \ mdocml-fport-$(VERSION).tar.gz \ mdocml-nport-$(VERSION).tar.gz -MANS = mandoc.1 mdoc.3 mdoc.7 manuals.7 +MANS = mandoc.1 mdoc.3 mdoc.7 manuals.7 mandoc_char.7 \ + man.7 man.3 +TEXTS = mandoc.1.txt mdoc.3.txt mdoc.7.txt manuals.7.txt \ + mandoc_char.7.txt man.7.txt man.3.txt BINS = mandoc -CLEAN = $(BINS) $(LNS) $(LLNS) $(LIBS) $(OBJS) $(HTMLS) $(TARGZS) \ - tags +CLEAN = $(BINS) $(LNS) $(LLNS) $(LIBS) $(OBJS) $(HTMLS) \ + $(TARGZS) tags $(TEXTS) MAKEFILES = Makefile.netbsd Makefile.openbsd Makefile.freebsd \ Makefile INSTALL = $(SRCS) $(HEADS) $(MAKEFILES) DESCR $(MANS) $(SGMLS) \ @@ -80,7 +83,7 @@ port: mdocml-oport-$(VERSION).tar.gz \ mdocml-fport-$(VERSION).tar.gz \ mdocml-nport-$(VERSION).tar.gz -www: $(HTMLS) $(TARGZS) +www: all $(HTMLS) $(TARGZS) $(TEXTS) installwww: www install -m 0444 $(HTMLS) $(STATICS) $(PREFIX)/ @@ -242,3 +245,12 @@ mandoc: $(MAINOBJS) libmdoc.a libman.a .sgml.html: validate $< sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< > $@ + +.1.1.txt: + ./mandoc -Wall,error $< | col -b > $@ + +.3.3.txt: + ./mandoc -Wall,error $< | col -b > $@ + +.7.7.txt: + ./mandoc -Wall,error $< | col -b > $@ @@ -26,12 +26,6 @@ #define ASCII_PRINT_HI 126 #define ASCII_PRINT_LO 32 -/* - * Lookup and hashing routines for constructing the ASCII symbol table, - * which should contain a significant portion of mdoc(7)'s special - * symbols. - */ - struct line { const char *code; const char *out; @@ -24,10 +24,16 @@ </h1> <p> - <span class="nm">mdocml</span> is a suite of tools compiling “-mdoc”, the roff macro - package of choice for BSD manual pages. The mission of <span class="nm">mdocml</span> is to deprecate - <a href="http://www.gnu.org/software/groff/" class="external">groff</a>, the GNU roff implementation, - for displaying -mdoc pages. + <span class="nm">mdocml</span> is a suite of tools compiling “-mdoc”, the roff macro package + of choice for BSD manual pages, and “-man”, the predominant historical package for UNIX + manuals. The mission of <span class="nm">mdocml</span> is to deprecate <a + href="http://www.gnu.org/software/groff/" class="external">groff</a>, the GNU roff implementation, for + displaying <a href="mdoc.7.txt" class="man">mdoc(7)</a> pages whilst providing token support for <a + href="man.7.txt" class="man">man(7)</a>. + </p> + + <p> + What are UNIX manuals? Read <a href="manuals.7.txt" class="man">manuals(7)</a> for an introduction. </p> <p> @@ -37,16 +43,16 @@ </p> <p> - The core of <span class="nm">mdocml</span> is the libmdoc library, a validating scanner-parser producing - intermediate-form output from -mdoc input. libmdoc is a simple, fast library operating on memory - buffers, so it can be used for a variety of front-ends (terminal-based, CGI and so on). + The core of <span class="nm">mdocml</span> are the <a href="man.3.txt" class="man">man(3)</a> and <a + href="mdoc.3.txt" class="man">mdoc(3)</a> libraries, validating compilers producing intermediate-form + output from -man or -mdoc input. Both are simple, fast libraries operating on memory buffers, so they + may be used for a variety of front-ends (terminal-based, CGI and so on). </p> <p> - The primary front-end is <span class="man">mandoc(1)</span>, which formats -mdoc manuals for display on - the terminal. The <span class="man">mandoc(1)</span> utility is intended to deprecate usage of <a - href="http://www.gnu.org/software/groff/" class="external">groff</a> for displaying mdoc manuals on the - terminal. + The primary front-end is <a href="mandoc.1.txt" class="man">mandoc(1)</a>, which formats manuals for + display on the terminal. Its purpose is to deprecate usage of groff for displaying -mdoc and, to a + limited extent, -man manuals on the terminal. </p> <p> @@ -83,7 +89,8 @@ <p class="boxed"> % cd /tmp<br> - % ftp -V -o- http://mdocml.bsd.lv/snapshots/mdocml.tar.gz | tar -zvxf -<br> + % ftp -V -o- <a href="http://mdocml.bsd.lv/snapshots/mdocml.tar.gz"> + http://mdocml.bsd.lv/snapshots/mdocml.tar.gz</a> | tar -zvxf -<br> % cd mdocml<br> % make all<br> % make regress<br> @@ -113,7 +120,8 @@ # pkg_delete mdocml<br> # cd /usr/ports/textproc/<br> # rm -rf mdocml<br> - # ftp -V -o- http://mdocml.bsd.lv/ports-openbsd/mdocml.tar.gz | tar -zvxf -<br> + # ftp -V -o- <a href="http://mdocml.bsd.lv/ports-openbsd/mdocml.tar.gz"> + http://mdocml.bsd.lv/ports-openbsd/mdocml.tar.gz</a> | tar -zvxf -<br> # cd mdocml<br> # make build<br> # make install @@ -127,7 +135,8 @@ # pkg_delete mdocml<br> # cd /usr/pkgsrc/textproc/<br> # rm -rf mdocml<br> - # ftp -V -o- http://mdocml.bsd.lv/ports-netbsd/mdocml.tar.gz | tar -zvxf -<br> + # ftp -V -o- <a href="http://mdocml.bsd.lv/ports-netbsd/mdocml.tar.gz"> + http://mdocml.bsd.lv/ports-netbsd/mdocml.tar.gz</a> | tar -zvxf -<br> # cd mdocml<br> # make build<br> # make install @@ -140,7 +149,8 @@ <p class="boxed"> # pkg_delete -x mdocml<br> # cd /tmp<br> - # ftp -V -o- http://mdocml.bsd.lv/ports-freebsd/mdocml.tar.gz | tar -zvxf -<br> + # ftp -V -o- <a href="http://mdocml.bsd.lv/ports-freebsd/mdocml.tar.gz"> + http://mdocml.bsd.lv/ports-freebsd/mdocml.tar.gz</a> | tar -zvxf -<br> # cd mdocml<br> # make<br> # make install @@ -29,12 +29,10 @@ The .Nm man language was historically used to format .Ux -manuals. In this reference document, we describe the syntax and -structure of the -.Nm -language. +manuals. This reference document describes the syntax and structure of +this language. .Pp -.Em \&Do not ever +.Em \&Do not use .Nm to write your manuals. Use the @@ -134,7 +132,7 @@ foo .Ed .Pp is equivalent to -.Sq \&.RI foo . +.Sq \&.RI foo . If two consecutive lines exhibit the latter behaviour, an error is raised. Thus, the following is not acceptable: .Bd -literal -offset indent @@ -184,7 +182,12 @@ system, the following macros are also supported: .Bl -column "MacroX" "Arguments" -compact -offset indent .It Em Macro Ta Em Arguments .It \&.br Ta 0 +.It \&.i Ta n .El +.Pp +These follow the same calling conventions as the above +.Nm +macros. .\" SECTION .Sh SEE ALSO .Xr mandoc 1 , @@ -18,7 +18,6 @@ */ #include <assert.h> #include <ctype.h> -#include <err.h> #include <stdarg.h> #include <stdlib.h> #include <stdio.h> @@ -32,18 +31,19 @@ const char *const __man_macronames[MAN_MAX] = { "IP", "HP", "SM", "SB", "BI", "IB", "BR", "RB", "R", "B", "I", "IR", - "RI", "br", "na" + "RI", "br", "na", "i" }; const char * const *man_macronames = __man_macronames; -static struct man_node *man_node_alloc(int, int, enum man_type); +static struct man_node *man_node_alloc(int, int, + enum man_type, int); static int man_node_append(struct man *, struct man_node *); static int man_ptext(struct man *, int, char *); static int man_pmacro(struct man *, int, char *); static void man_free1(struct man *); -static void man_alloc1(struct man *); +static int man_alloc1(struct man *); const struct man_node * @@ -67,9 +67,7 @@ man_reset(struct man *man) { man_free1(man); - man_alloc1(man); - /* TODO */ - return(1); + return(man_alloc1(man)); } @@ -90,19 +88,22 @@ man_alloc(void *data, int pflags, const struct man_cb *cb) { struct man *p; - p = calloc(1, sizeof(struct man)); - if (NULL == p) - err(1, "calloc"); - - man_alloc1(p); + if (NULL == (p = calloc(1, sizeof(struct man)))) + return(NULL); - if (cb) - (void)memcpy(&p->cb, cb, sizeof(struct man_cb)); + if ( ! man_alloc1(p)) { + free(p); + return(NULL); + } - p->htab = man_hash_alloc(); p->data = data; p->pflags = pflags; + (void)memcpy(&p->cb, cb, sizeof(struct man_cb)); + if (NULL == (p->htab = man_hash_alloc())) { + free(p); + return(NULL); + } return(p); } @@ -145,7 +146,7 @@ man_free1(struct man *man) } -static void +static int man_alloc1(struct man *m) { @@ -153,10 +154,11 @@ man_alloc1(struct man *m) m->flags = 0; m->last = calloc(1, sizeof(struct man_node)); if (NULL == m->last) - err(1, "calloc"); + return(0); m->first = m->last; m->last->type = MAN_ROOT; m->next = MAN_NEXT_CHILD; + return(1); } @@ -201,16 +203,18 @@ man_node_append(struct man *man, struct man_node *p) static struct man_node * -man_node_alloc(int line, int pos, enum man_type type) +man_node_alloc(int line, int pos, enum man_type type, int tok) { struct man_node *p; - if (NULL == (p = calloc(1, sizeof(struct man_node)))) - err(1, "malloc"); + p = calloc(1, sizeof(struct man_node)); + if (NULL == p) + return(NULL); + p->line = line; p->pos = pos; p->type = type; - + p->tok = tok; return(p); } @@ -220,9 +224,9 @@ man_elem_alloc(struct man *man, int line, int pos, int tok) { struct man_node *p; - p = man_node_alloc(line, pos, MAN_ELEM); - p->tok = tok; - + p = man_node_alloc(line, pos, MAN_ELEM, tok); + if (NULL == p) + return(0); return(man_node_append(man, p)); } @@ -233,10 +237,11 @@ man_word_alloc(struct man *man, { struct man_node *p; - p = man_node_alloc(line, pos, MAN_TEXT); + p = man_node_alloc(line, pos, MAN_TEXT, -1); + if (NULL == p) + return(0); if (NULL == (p->string = strdup(word))) - err(1, "strdup"); - + return(0); return(man_node_append(man, p)); } @@ -44,7 +44,8 @@ #define MAN_RI 20 #define MAN_br 21 #define MAN_na 22 -#define MAN_MAX 23 +#define MAN_i 23 +#define MAN_MAX 24 enum man_type { MAN_TEXT, diff --git a/man_action.c b/man_action.c index c6eef21a..8f0a9e31 100644 --- a/man_action.c +++ b/man_action.c @@ -61,6 +61,7 @@ const struct actions man_actions[MAN_MAX] = { { NULL }, /* RI */ { NULL }, /* br */ { NULL }, /* na */ + { NULL }, /* i */ }; @@ -39,7 +39,7 @@ man_hash_alloc(void) int *htab; int i, j, x; - htab = calloc(26 * 4, sizeof(int)); + htab = calloc(26 * 5, sizeof(int)); if (NULL == htab) return(NULL); @@ -50,15 +50,15 @@ man_hash_alloc(void) (x >= 97 && x <= 122)); x -= (x <= 90) ? 65 : 97; - x *= 4; + x *= 5; - for (j = 0; j < 4; j++) + for (j = 0; j < 5; j++) if (0 == htab[x + j]) { htab[x + j] = i; break; } - assert(j < 4); + assert(j < 5); } return((void *)htab); @@ -79,9 +79,9 @@ man_hash_find(const void *arg, const char *tmp) return(MAN_MAX); x -= (x <= 90) ? 65 : 97; - x *= 4; + x *= 5; - for (i = 0; i < 4; i++) { + for (i = 0; i < 5; i++) { if (0 == (tok = htab[x + i])) return(MAN_MAX); if (0 == strcmp(tmp, man_macronames[tok])) diff --git a/man_macro.c b/man_macro.c index 8c49983f..047a21f3 100644 --- a/man_macro.c +++ b/man_macro.c @@ -53,6 +53,7 @@ static int man_flags[MAN_MAX] = { FL_NLINE, /* RI */ 0, /* br */ 0, /* na */ + FL_NLINE, /* i */ }; int @@ -82,6 +82,7 @@ static const struct termact termacts[MAN_MAX] = { { pre_RI, NULL }, /* RI */ { pre_PP, NULL }, /* br */ { NULL, NULL }, /* na */ + { pre_I, post_I }, /* i */ }; static void print_head(struct termp *, @@ -282,15 +283,15 @@ pre_IP(DECL_ARGS) if (NULL == (nn = n->child)) return(1); - - /* FIXME - ignore the designator. */ - nn = nn->next; - if (MAN_TEXT != nn->type) errx(1, "expected text line argument"); - offs = (size_t)atoi(nn->string); - nn = nn->next; + if (nn->next) { + if (MAN_TEXT != nn->next->type) + errx(1, "expected text line argument"); + offs = (size_t)atoi(nn->next->string); + } else + offs = strlen(nn->string); p->flags |= TERMP_NOSPACE; p->offset += offs; diff --git a/man_validate.c b/man_validate.c index ceded34e..37cbff68 100644 --- a/man_validate.c +++ b/man_validate.c @@ -73,6 +73,7 @@ static const struct man_valid man_valids[MAN_MAX] = { { NULL }, /* RI */ { posts_eq0 }, /* br */ { posts_eq0 }, /* na */ + { NULL }, /* i */ }; @@ -100,21 +100,19 @@ were provided. .Pp .Ex -std mandoc .\" SUB-SECTION -.Ss Reserved Words (mdoc only) -The reserved words described in -.Xr mdoc 7 -are handled according to the following rules: -.Bl -enum -offset XXX -.It -Opening delimiters +.Ss Punctuation +If punctuation is set apart from words, such as in the phrase +.Dq to be \&, or not to be , +it's processed by +.Nm +according to the following rules. Opening punctuation .Po .Sq \&( , .Sq \&[ , and .Sq \&{ -.Pc are not followed by whitespace. -.It -Closing delimiters +.Pc +is not followed by a space. Closing punctuation .Po .Sq \&. , .Sq \&, , @@ -126,23 +124,12 @@ Closing delimiters .Sq \&] and .Sq \&} -.Pc are not preceeded by whitespace. -.El -.\" PARAGRAPH -.Pp -Note that reserved words only register as such as if they appear as -standalone tokens, either in parsed lines or streams of text. Thus, the -following fragment: -.Bd -literal -offset XXXX -this self is not that of the waking , empirically real man -.Ed -.\" PARAGRAPH +.Pc +is not preceeded by whitespace. .Pp -\&...correctly adjusts the comma spacing to -.Dq this self is not that of the waking , empirically real man . -However, if the comma were part of -.Dq ,empirically , -it would not. +If the input is +.Xr mdoc 7 , +these rules are also applied to macro arguments when appropriate. .\" SUB-SECTION .Ss Input Formats The @@ -165,24 +152,37 @@ should only be used for legacy manuals. .Pp A third option, .Fl m Ns Ar andoc , -which is also the default, determines encoding on-the-fly. If multiple -files are passed in, each has its file-type determined this way. If -multiple files are passed and +which is also the default, determines encoding on-the-fly: if the first +non-comment macro is +.Sq \&.Dd +or +.Sq \&.Dt , +the +.Xr mdoc 7 +parser is used; otherwise, the +.Xr man 7 +parser is used. +.Pp +If multiple +files are specified with +.Fl m Ns Ar andoc , +each has its file-type determined this way. If multiple files are +specified and .Fl m Ns Ar doc or .Fl m Ns Ar an is specified, then this format is used exclusively. -.Pp -The following escape sequences are recognised, although the per-format -compiler may not allow certain sequences. -.Bl -tag -width Ds -offset XXXX -.It \efX -sets the font mode to X (B, I, R or P, where P resets the font) -.It \eX, \e(XX, \e[XN] -queries the special-character table for a corresponding symbol -.It \e*X, \e*(XX, \e*[XN] -deprecated special-character format -.El +.\" .Pp +.\" The following escape sequences are recognised, although the per-format +.\" compiler may not allow certain sequences. +.\" .Bl -tag -width Ds -offset XXXX +.\" .It \efX +.\" sets the font mode to X (B, I, R or P, where P resets the font) +.\" .It \eX, \e(XX, \e[XN] +.\" queries the special-character table for a corresponding symbol +.\" .It \e*X, \e*(XX, \e*[XN] +.\" deprecated special-character format +.\" .El .\" SUB-SECTION .Ss Output Formats The @@ -190,21 +190,24 @@ The utility accepts the following .Fl T arguments: -.Bl -tag -width XXXXXXXXXXXX -offset XXXX -.It Ar ascii +.Bl -tag -width XXXXXXXXXXXX +.It Fl T Ns Ar ascii Produce 7-bit ASCII output, backspace-encoded for bold and underline styles. This is the default. -.It Ar tree +.It Fl T Ns Ar tree Produce an indented parse tree. -.It Ar lint +.It Fl T Ns Ar lint Parse only: produce no output. .El +.Pp +If multiple input files are specified, these will be processed by the +corresponding filter in-order. .\" SUB-SECTION .Ss Compiler Options Default compiler behaviour may be overriden with the .Fl f flag. -.Bl -tag -width XXXXXXXXXXXXXX -offset XXXX +.Bl -tag -width XXXXXXXXXXXXXX .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. @@ -231,12 +234,15 @@ options may be grouped and delimited with a comma. Using for example, will try to ignore scope and character-escape errors. .\" SECTION .Sh EXAMPLES -To page this manual page on the terminal: +To page manuals to the terminal: .\" PARAGRAPH .Pp .D1 % mandoc \-Wall,error mandoc.1 2>&1 | less +.Pp +.D1 % mandoc mandoc.1 mdoc.3 mdoc.7 | less .\" SECTION .Sh SEE ALSO +.Xr mandoc_char 7 , .Xr mdoc 7 , .Xr man 7 .\" @@ -31,7 +31,8 @@ h3 { font-size: small; margin-bottom: 0px; font-family: Verdana, Tahoma, Arial, sans-serif; } -span.man { color: #000000; border-bottom: 1px dotted #999999; } +a.man { text-decoration: none; + border-bottom: 1px dotted #999999; } span.path { color: #000000; } |