diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-12-07 00:08:53 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-12-07 00:08:53 +0000 |
commit | 7dd7e9890d9671522a535999d40e0970f883cbbf (patch) | |
tree | cbc0ef5c09bbb3e71747e477fc98260daa5e41f3 | |
parent | 67de4b6243d14565beae59c8d441b6da38f7a4bd (diff) |
Complete the merge of bsd.lv version 1.10.7:
No more functional changes, just sync ordering, comments and white space.
-rw-r--r-- | usr.bin/mandoc/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/man.3 | 7 | ||||
-rw-r--r-- | usr.bin/mandoc/man.c | 7 | ||||
-rw-r--r-- | usr.bin/mandoc/man_term.c | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/man_validate.c | 114 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/roff.c | 36 |
8 files changed, 98 insertions, 86 deletions
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile index b658d892f17..d94e5bbf594 100644 --- a/usr.bin/mandoc/Makefile +++ b/usr.bin/mandoc/Makefile @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile,v 1.48 2010/12/01 23:02:57 schwarze Exp $ +# $OpenBSD: Makefile,v 1.49 2010/12/07 00:08:52 schwarze Exp $ .include <bsd.own.mk> -VERSION=1.10.6 +VERSION=1.10.7 CFLAGS+=-DVERSION=\"${VERSION}\" CFLAGS+=-W -Wall -Wstrict-prototypes diff --git a/usr.bin/mandoc/man.3 b/usr.bin/mandoc/man.3 index 39732684dd7..39435c2a8c3 100644 --- a/usr.bin/mandoc/man.3 +++ b/usr.bin/mandoc/man.3 @@ -1,4 +1,4 @@ -.\" $Id: man.3,v 1.17 2010/11/29 02:26:45 schwarze Exp $ +.\" $Id: man.3,v 1.18 2010/12/07 00:08:52 schwarze Exp $ .\" .\" Copyright (c) 2009-2010 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: November 29 2010 $ +.Dd $Mdocdate: December 7 2010 $ .Dt MAN 3 .Os .Sh NAME @@ -85,7 +85,8 @@ library also accepts the following macro: .Pp .Bl -tag -width Ds -compact .It PD -Has no effect. Handled as a current-scope line macro. +Has no effect. +Handled as a current-scope line macro. .El .Ss Types .Bl -ohang diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index 8778aea1408..8b2621facd8 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.48 2010/12/01 23:02:59 schwarze Exp $ */ +/* $Id: man.c,v 1.49 2010/12/07 00:08:52 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -517,12 +517,13 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) n = m->last; assert(MAN_TEXT != n->type); - /* .B .br .br .B: remove prior including children */ + /* Remove repeated NSCOPED macros causing ELINE. */ + if (MAN_NSCOPED & man_macros[n->tok].flags) n = n->parent; man_vmsg(m, MANDOCERR_LINESCOPE, n->line, n->pos, - "%s", man_macronames[n->tok]); + "%s", man_macronames[n->tok]); man_node_delete(m, n); m->flags &= ~MAN_ELINE; diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index 1a4280fc81b..ddd9bfbb147 100644 --- a/usr.bin/mandoc/man_term.c +++ b/usr.bin/mandoc/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.54 2010/12/06 22:43:54 schwarze Exp $ */ +/* $Id: man_term.c,v 1.55 2010/12/07 00:08:52 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -260,7 +260,6 @@ pre_literal(DECL_ARGS) return(1); } - /* ARGSUSED */ static int pre_alternate(DECL_ARGS) @@ -313,7 +312,6 @@ pre_alternate(DECL_ARGS) return(0); } - /* ARGSUSED */ static int pre_B(DECL_ARGS) @@ -323,7 +321,6 @@ pre_B(DECL_ARGS) return(1); } - /* ARGSUSED */ static int pre_ft(DECL_ARGS) @@ -365,7 +362,6 @@ pre_ft(DECL_ARGS) return(0); } - /* ARGSUSED */ static int pre_in(DECL_ARGS) diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index 179d7ede5d6..43820d75b19 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.35 2010/12/06 23:03:56 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.36 2010/12/07 00:08:52 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -24,6 +24,7 @@ #include <stdarg.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include "mandoc.h" #include "libman.h" @@ -44,10 +45,10 @@ struct man_valid { static int check_bline(CHKARGS); static int check_eq0(CHKARGS); +static int check_ft(CHKARGS); static int check_le1(CHKARGS); static int check_ge2(CHKARGS); static int check_le5(CHKARGS); -static int check_ft(CHKARGS); static int check_par(CHKARGS); static int check_part(CHKARGS); static int check_root(CHKARGS); @@ -66,8 +67,8 @@ static v_check posts_at[] = { post_AT, NULL }; static v_check posts_eq0[] = { check_eq0, NULL }; static v_check posts_fi[] = { check_eq0, post_fi, NULL }; static v_check posts_le1[] = { check_le1, NULL }; -static v_check posts_nf[] = { check_eq0, post_nf, NULL }; static v_check posts_ft[] = { check_ft, NULL }; +static v_check posts_nf[] = { check_eq0, post_nf, NULL }; static v_check posts_par[] = { check_par, NULL }; static v_check posts_part[] = { check_part, NULL }; static v_check posts_sec[] = { check_sec, NULL }; @@ -275,7 +276,6 @@ INEQ_DEFINE(1, <=, le1) INEQ_DEFINE(2, >=, ge2) INEQ_DEFINE(5, <=, le5) - static int check_ft(CHKARGS) { @@ -317,18 +317,18 @@ check_ft(CHKARGS) } if (0 == ok) { - man_vmsg(m, MANDOCERR_BADFONT, n->line, n->pos, "%s", cp); + man_vmsg(m, MANDOCERR_BADFONT, + n->line, n->pos, "%s", cp); *cp = '\0'; } if (1 < n->nchild) man_vmsg(m, MANDOCERR_ARGCOUNT, n->line, n->pos, - "want one child (have %d)", n->nchild); + "want one child (have %d)", n->nchild); return(1); } - static int check_sec(CHKARGS) { @@ -353,6 +353,56 @@ check_part(CHKARGS) return(1); } + +static int +check_par(CHKARGS) +{ + + if (MAN_BODY == n->type) + switch (n->tok) { + case (MAN_IP): + /* FALLTHROUGH */ + case (MAN_HP): + /* FALLTHROUGH */ + case (MAN_TP): + /* Body-less lists are ok. */ + break; + default: + if (0 == n->nchild) + man_nmsg(m, n, MANDOCERR_NOBODY); + break; + } + if (MAN_HEAD == n->type) + switch (n->tok) { + case (MAN_PP): + /* FALLTHROUGH */ + case (MAN_P): + /* FALLTHROUGH */ + case (MAN_LP): + if (n->nchild) + man_nmsg(m, n, MANDOCERR_ARGSLOST); + break; + default: + break; + } + + return(1); +} + + +static int +check_bline(CHKARGS) +{ + + assert( ! (MAN_ELINE & m->flags)); + if (MAN_BLINE & m->flags) { + man_nmsg(m, n, MANDOCERR_SYNTLINESCOPE); + return(0); + } + + return(1); +} + static int post_TH(CHKARGS) { @@ -534,53 +584,3 @@ post_TS(CHKARGS) return(1); } - -static int -check_par(CHKARGS) -{ - - if (MAN_BODY == n->type) - switch (n->tok) { - case (MAN_IP): - /* FALLTHROUGH */ - case (MAN_HP): - /* FALLTHROUGH */ - case (MAN_TP): - /* Body-less lists are ok. */ - break; - default: - if (0 == n->nchild) - man_nmsg(m, n, MANDOCERR_NOBODY); - break; - } - if (MAN_HEAD == n->type) - switch (n->tok) { - case (MAN_PP): - /* FALLTHROUGH */ - case (MAN_P): - /* FALLTHROUGH */ - case (MAN_LP): - if (n->nchild) - man_nmsg(m, n, MANDOCERR_ARGSLOST); - break; - default: - break; - } - - return(1); -} - - -static int -check_bline(CHKARGS) -{ - - assert( ! (MAN_ELINE & m->flags)); - if (MAN_BLINE & m->flags) { - man_nmsg(m, n, MANDOCERR_SYNTLINESCOPE); - return(0); - } - - return(1); -} - diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index aa7a04de05e..b6ce8685677 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.23 2010/12/01 22:02:29 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.24 2010/12/07 00:08:52 schwarze Exp $ */ /* * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -100,6 +100,7 @@ enum mandocerr { MANDOCERR_BADQUOTE, /* unterminated quoted string */ MANDOCERR_ERROR, /* ===== start of errors ===== */ + MANDOCERR_BADCHAR, /* skipping bad character */ MANDOCERR_NOTEXT, /* skipping text before the first section header */ MANDOCERR_MACRO, /* skipping unknown macro */ @@ -120,6 +121,7 @@ enum mandocerr { MANDOCERR_TBL, /* tbl(1) error */ MANDOCERR_FATAL, /* ===== start of fatal errors ===== */ + MANDOCERR_COLUMNS, /* column syntax is inconsistent */ MANDOCERR_BADDISP, /* NOT IMPLEMENTED: .Bd -file */ MANDOCERR_SYNTLINESCOPE, /* line scope broken, syntax violated */ diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 6c412b47793..3a5f22e5754 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.76 2010/12/01 22:02:29 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.77 2010/12/07 00:08:52 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -2121,7 +2121,8 @@ post_os(POST_ARGS) * of filling in "sysname release" from uname(). */ - free(mdoc->meta.os); + if (mdoc->meta.os) + free(mdoc->meta.os); if ( ! concat(mdoc, buf, n->child, BUFSIZ)) return(0); @@ -2191,7 +2192,6 @@ post_std(POST_ARGS) return(1); } - static int concat(struct mdoc *m, char *p, const struct mdoc_node *n, size_t sz) { diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index de161836d77..87c1ce1ae79 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.21 2010/11/28 19:35:33 schwarze Exp $ */ +/* $Id: roff.c,v 1.22 2010/12/07 00:08:52 schwarze Exp $ */ /* * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -633,6 +633,12 @@ roff_block(ROFF_ARGS) (*r->msg)(MANDOCERR_NOARGS, r->data, ln, ppos, NULL); return(ROFF_IGN); } + + /* + * Re-write `de1', since we don't really care about + * groff's strange compatibility mode, into `de'. + */ + if (ROFF_de1 == tok) tok = ROFF_de; if (ROFF_de == tok) @@ -640,8 +646,10 @@ roff_block(ROFF_ARGS) else (*r->msg)(MANDOCERR_REQUEST, r->data, ln, ppos, roffs[tok].name); + while ((*bufp)[pos] && ' ' != (*bufp)[pos]) pos++; + while (' ' == (*bufp)[pos]) (*bufp)[pos++] = '\0'; } @@ -653,14 +661,18 @@ roff_block(ROFF_ARGS) * with the same name, if there is one. New content will be * added from roff_block_text() in multiline mode. */ + if (ROFF_de == tok) roff_setstr(r, name, "", 0); if ('\0' == (*bufp)[pos]) return(ROFF_IGN); + /* If present, process the custom end-of-line marker. */ + sv = pos; - while ((*bufp)[pos] && ' ' != (*bufp)[pos] && + while ((*bufp)[pos] && + ' ' != (*bufp)[pos] && '\t' != (*bufp)[pos]) pos++; @@ -682,8 +694,7 @@ roff_block(ROFF_ARGS) r->last->end[(int)sz] = '\0'; if ((*bufp)[pos]) - if ( ! (*r->msg)(MANDOCERR_ARGSLOST, r->data, ln, pos, NULL)) - return(ROFF_ERR); + (*r->msg)(MANDOCERR_ARGSLOST, r->data, ln, pos, NULL); return(ROFF_IGN); } @@ -858,7 +869,6 @@ roff_evalcond(const char *v, int *pos) return(ROFFRULE_DENY); } - /* ARGSUSED */ static enum rofferr roff_line_ignore(ROFF_ARGS) @@ -867,7 +877,6 @@ roff_line_ignore(ROFF_ARGS) return(ROFF_IGN); } - /* ARGSUSED */ static enum rofferr roff_line_error(ROFF_ARGS) @@ -877,7 +886,6 @@ roff_line_error(ROFF_ARGS) return(ROFF_IGN); } - /* ARGSUSED */ static enum rofferr roff_cond(ROFF_ARGS) @@ -919,9 +927,8 @@ roff_cond(ROFF_ARGS) */ if ('\0' == (*bufp)[pos] && sv != pos) { - if ((*r->msg)(MANDOCERR_NOARGS, r->data, ln, ppos, NULL)) - return(ROFF_IGN); - return(ROFF_ERR); + (*r->msg)(MANDOCERR_NOARGS, r->data, ln, ppos, NULL); + return(ROFF_IGN); } roffnode_push(r, tok, NULL, ln, ppos); @@ -1054,7 +1061,6 @@ roff_nr(ROFF_ARGS) return(ROFF_IGN); } - /* ARGSUSED */ static enum rofferr roff_so(ROFF_ARGS) @@ -1063,6 +1069,13 @@ roff_so(ROFF_ARGS) (*r->msg)(MANDOCERR_SO, r->data, ln, ppos, NULL); + /* + * Handle `so'. Be EXTREMELY careful, as we shouldn't be + * opening anything that's not in our cwd or anything beneath + * it. Thus, explicitly disallow traversing up the file-system + * or using absolute paths. + */ + name = *bufp + pos; if ('/' == *name || strstr(name, "../") || strstr(name, "/..")) { (*r->msg)(MANDOCERR_SOPATH, r->data, ln, pos, NULL); @@ -1073,7 +1086,6 @@ roff_so(ROFF_ARGS) return(ROFF_SO); } - /* ARGSUSED */ static enum rofferr roff_userdef(ROFF_ARGS) |