diff options
author | Yuri Pankov <yuri.pankov@nexenta.com> | 2017-01-09 20:07:52 +0300 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2017-01-10 15:06:10 -0800 |
commit | a593473611dc9e109c40317ce52161b8cfe015ff (patch) | |
tree | 59594c4c235692e031bf0313bd4529432a58f80b | |
parent | 28b83f21b6f708fcc61937fcc89194e3e5e2b295 (diff) | |
download | illumos-joyent-a593473611dc9e109c40317ce52161b8cfe015ff.tar.gz |
7712 mandoc -Tlint does always exit with error code 0
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r-- | usr/src/cmd/mandoc/main.c | 101 | ||||
-rw-r--r-- | usr/src/cmd/mandoc/mandoc.h | 11 | ||||
-rw-r--r-- | usr/src/cmd/mandoc/read.c | 61 | ||||
-rw-r--r-- | usr/src/man/man1m/dns-sd.1m | 10 | ||||
-rw-r--r-- | usr/src/man/man1m/mdnsd.1m | 10 | ||||
-rw-r--r-- | usr/src/man/man3c/pthread_mutex_consistent.3c | 2 | ||||
-rw-r--r-- | usr/src/man/man3c/pthread_mutexattr_getrobust.3c | 2 | ||||
-rw-r--r-- | usr/src/man/man3c/signalfd.3c | 2 | ||||
-rw-r--r-- | usr/src/man/man3c/smt_pause.3c | 2 |
9 files changed, 107 insertions, 94 deletions
diff --git a/usr/src/cmd/mandoc/main.c b/usr/src/cmd/mandoc/main.c index 0dd6bb5dcc..20562c7118 100644 --- a/usr/src/cmd/mandoc/main.c +++ b/usr/src/cmd/mandoc/main.c @@ -1,7 +1,8 @@ -/* $Id: main.c,v 1.269 2016/07/12 05:18:38 kristaps Exp $ */ + +/* $Id: main.c,v 1.273.2.3 2017/01/09 02:27:58 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2010-2012, 2014-2016 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org> * * Permission to use, copy, modify, and distribute this software for any @@ -51,12 +52,6 @@ #include "manconf.h" #include "mansearch.h" -#if !defined(__GNUC__) || (__GNUC__ < 2) -# if !defined(lint) -# define __attribute__(x) -# endif -#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */ - enum outmode { OUTMODE_DEF = 0, OUTMODE_FLN, @@ -87,6 +82,11 @@ struct curparse { struct manoutput *outopts; /* output options */ }; + +#if HAVE_SQLITE3 +int mandocdb(int, char *[]); +#endif + static int fs_lookup(const struct manpaths *, size_t ipath, const char *, const char *, const char *, @@ -95,12 +95,10 @@ static void fs_search(const struct mansearch *, const struct manpaths *, int, char**, struct manpage **, size_t *); static int koptions(int *, char *); -#if HAVE_SQLITE3 -int mandocdb(int, char**); -#endif static int moptions(int *, char *); static void mmsg(enum mandocerr, enum mandoclevel, const char *, int, int, const char *); +static void outdata_alloc(struct curparse *); static void parse(struct curparse *, int, const char *); static void passthrough(const char *, int, int); static pid_t spawn_pager(struct tag_files *); @@ -486,8 +484,11 @@ main(int argc, char *argv[]) passthrough(resp->file, fd, conf.output.synopsisonly); - if (argc > 1 && curp.outtype <= OUTT_UTF8) + if (argc > 1 && curp.outtype <= OUTT_UTF8) { + if (curp.outdata == NULL) + outdata_alloc(&curp); terminal_sepline(curp.outdata); + } } else if (rc < MANDOCLEVEL_ERROR) rc = MANDOCLEVEL_ERROR; @@ -747,32 +748,8 @@ parse(struct curparse *curp, int fd, const char *file) if (rctmp != MANDOCLEVEL_OK && curp->wstop) return; - /* If unset, allocate output dev now (if applicable). */ - - if (curp->outdata == NULL) { - switch (curp->outtype) { - case OUTT_HTML: - curp->outdata = html_alloc(curp->outopts); - break; - case OUTT_UTF8: - curp->outdata = utf8_alloc(curp->outopts); - break; - case OUTT_LOCALE: - curp->outdata = locale_alloc(curp->outopts); - break; - case OUTT_ASCII: - curp->outdata = ascii_alloc(curp->outopts); - break; - case OUTT_PDF: - curp->outdata = pdf_alloc(curp->outopts); - break; - case OUTT_PS: - curp->outdata = ps_alloc(curp->outopts); - break; - default: - break; - } - } + if (curp->outdata == NULL) + outdata_alloc(curp); mparse_result(curp->mp, &man, NULL); @@ -826,6 +803,34 @@ parse(struct curparse *curp, int fd, const char *file) break; } } + mparse_updaterc(curp->mp, &rc); +} + +static void +outdata_alloc(struct curparse *curp) +{ + switch (curp->outtype) { + case OUTT_HTML: + curp->outdata = html_alloc(curp->outopts); + break; + case OUTT_UTF8: + curp->outdata = utf8_alloc(curp->outopts); + break; + case OUTT_LOCALE: + curp->outdata = locale_alloc(curp->outopts); + break; + case OUTT_ASCII: + curp->outdata = ascii_alloc(curp->outopts); + break; + case OUTT_PDF: + curp->outdata = pdf_alloc(curp->outopts); + break; + case OUTT_PS: + curp->outdata = ps_alloc(curp->outopts); + break; + default: + break; + } } static void @@ -838,11 +843,17 @@ passthrough(const char *file, int fd, int synopsis_only) const char *syscall; char *line, *cp; size_t linesz; + ssize_t len, written; int print; line = NULL; linesz = 0; + if (fflush(stdout) == EOF) { + syscall = "fflush"; + goto fail; + } + if ((stream = fdopen(fd, "r")) == NULL) { close(fd); syscall = "fdopen"; @@ -850,14 +861,16 @@ passthrough(const char *file, int fd, int synopsis_only) } print = 0; - while (getline(&line, &linesz, stream) != -1) { + while ((len = getline(&line, &linesz, stream)) != -1) { cp = line; if (synopsis_only) { if (print) { if ( ! isspace((unsigned char)*cp)) goto done; - while (isspace((unsigned char)*cp)) + while (isspace((unsigned char)*cp)) { cp++; + len--; + } } else { if (strcmp(cp, synb) == 0 || strcmp(cp, synr) == 0) @@ -865,9 +878,11 @@ passthrough(const char *file, int fd, int synopsis_only) continue; } } - if (fputs(cp, stdout)) { + for (; len > 0; len -= written) { + if ((written = write(STDOUT_FILENO, cp, len)) != -1) + continue; fclose(stream); - syscall = "fputs"; + syscall = "write"; goto fail; } } @@ -978,7 +993,7 @@ woptions(struct curparse *curp, char *arg) while (*arg) { o = arg; - switch (getsubopt(&arg, UNCONST(toks), &v)) { + switch (getsubopt(&arg, (char * const *)toks, &v)) { case 0: curp->wstop = 1; break; diff --git a/usr/src/cmd/mandoc/mandoc.h b/usr/src/cmd/mandoc/mandoc.h index d63814c6de..2ea64ea0ae 100644 --- a/usr/src/cmd/mandoc/mandoc.h +++ b/usr/src/cmd/mandoc/mandoc.h @@ -1,7 +1,7 @@ -/* $Id: mandoc.h,v 1.209 2016/01/08 02:53:13 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.213 2017/01/09 01:37:03 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -65,10 +65,11 @@ enum mandocerr { MANDOCERR_DOC_EMPTY, /* no document body */ MANDOCERR_SEC_BEFORE, /* content before first section header: macro */ MANDOCERR_NAMESEC_FIRST, /* first section is not NAME: Sh title */ - MANDOCERR_NAMESEC_NONM, /* NAME section without name */ + MANDOCERR_NAMESEC_NONM, /* NAME section without Nm before Nd */ MANDOCERR_NAMESEC_NOND, /* NAME section without description */ MANDOCERR_NAMESEC_ND, /* description not at the end of NAME */ MANDOCERR_NAMESEC_BAD, /* bad NAME section content: macro */ + MANDOCERR_NAMESEC_PUNCT, /* missing comma before name: Nm name */ MANDOCERR_ND_EMPTY, /* missing description line, using "" */ MANDOCERR_SEC_ORDER, /* sections out of conventional order: Sh title */ MANDOCERR_SEC_REP, /* duplicate section title: Sh title */ @@ -98,7 +99,7 @@ enum mandocerr { MANDOCERR_ARG_EMPTY, /* empty argument, using 0n: macro arg */ MANDOCERR_BD_NOTYPE, /* missing display type, using -ragged: Bd */ MANDOCERR_BL_LATETYPE, /* list type is not the first argument: Bl arg */ - MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 8n */ + MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 6n */ MANDOCERR_EX_NONAME, /* missing utility name, using "": Ex */ MANDOCERR_FO_NOHEAD, /* missing function name, using "": Fo */ MANDOCERR_IT_NOHEAD, /* empty head in list item: Bl -type It */ @@ -107,6 +108,7 @@ enum mandocerr { MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: Bf font */ MANDOCERR_PF_SKIP, /* nothing follows prefix: Pf arg */ MANDOCERR_RS_EMPTY, /* empty reference block: Rs */ + MANDOCERR_XR_NOSEC, /* missing section argument: Xr arg */ MANDOCERR_ARG_STD, /* missing -std argument, adding it: macro */ MANDOCERR_OP_EMPTY, /* missing option string, using "": OP */ MANDOCERR_UR_NOHEAD, /* missing resource identifier, using "": UR */ @@ -433,3 +435,4 @@ void mparse_result(struct mparse *, const char *mparse_getkeep(const struct mparse *); const char *mparse_strerror(enum mandocerr); const char *mparse_strlevel(enum mandoclevel); +void mparse_updaterc(struct mparse *, enum mandoclevel *); diff --git a/usr/src/cmd/mandoc/read.c b/usr/src/cmd/mandoc/read.c index 6cbcd2df00..0c5188b757 100644 --- a/usr/src/cmd/mandoc/read.c +++ b/usr/src/cmd/mandoc/read.c @@ -1,7 +1,7 @@ -/* $Id: read.c,v 1.149 2016/07/10 13:34:30 schwarze Exp $ */ +/* $Id: read.c,v 1.150.2.5 2017/01/09 02:25:53 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2010, 2012 Joerg Sonnenberger <joerg@netbsd.org> * * Permission to use, copy, modify, and distribute this software for any @@ -110,10 +110,11 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "no document body", "content before first section header", "first section is not \"NAME\"", - "NAME section without name", + "NAME section without Nm before Nd", "NAME section without description", "description not at the end of NAME", "bad NAME section content", + "missing comma before name", "missing description line, using \"\"", "sections out of conventional order", "duplicate section title", @@ -143,7 +144,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "empty argument, using 0n", "missing display type, using -ragged", "list type is not the first argument", - "missing -width in -tag list, using 8n", + "missing -width in -tag list, using 6n", "missing utility name, using \"\"", "missing function name, using \"\"", "empty head in list item", @@ -152,6 +153,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "unknown font type, using \\fR", "nothing follows prefix", "empty reference block", + "missing section argument", "missing -std argument, adding it", "missing option string, using \"\"", "missing resource identifier, using \"\"", @@ -291,13 +293,6 @@ choose_parser(struct mparse *curp) } } - if (curp->man == NULL) { - curp->man = roff_man_alloc(curp->roff, curp, curp->defos, - curp->options & MPARSE_QUICK ? 1 : 0); - curp->man->macroset = MACROSET_MAN; - curp->man->first->tok = TOKEN_NONE; - } - if (format == MPARSE_MDOC) { mdoc_hash_init(); curp->man->macroset = MACROSET_MDOC; @@ -324,6 +319,7 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start) const char *save_file; char *cp; size_t pos; /* byte number in the ln buffer */ + size_t j; /* auxiliary byte number in the blk buffer */ enum rofferr rr; int of; int lnn; /* line number in the real file */ @@ -429,14 +425,21 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start) } if ('"' == blk.buf[i + 1] || '#' == blk.buf[i + 1]) { + j = i; i += 2; /* Comment, skip to end of line */ for (; i < blk.sz; ++i) { - if ('\n' == blk.buf[i]) { - ++i; - ++lnn; - break; - } + if (blk.buf[i] != '\n') + continue; + if (blk.buf[i - 1] == ' ' || + blk.buf[i - 1] == '\t') + mandoc_msg( + MANDOCERR_SPACE_EOL, + curp, curp->line, + pos + i-1 - j, NULL); + ++i; + ++lnn; + break; } /* Backout trailing whitespaces */ @@ -562,15 +565,7 @@ rerun: break; } - /* - * If input parsers have not been allocated, do so now. - * We keep these instanced between parsers, but set them - * locally per parse routine since we can use different - * parsers with each one. - */ - - if (curp->man == NULL || - curp->man->macroset == MACROSET_NONE) + if (curp->man->macroset == MACROSET_NONE) choose_parser(curp); /* @@ -683,10 +678,6 @@ read_whole_file(struct mparse *curp, const char *file, int fd, static void mparse_end(struct mparse *curp) { - - if (curp->man == NULL && curp->sodest == NULL) - curp->man = roff_man_alloc(curp->roff, curp, curp->defos, - curp->options & MPARSE_QUICK ? 1 : 0); if (curp->man->macroset == MACROSET_NONE) curp->man->macroset = MACROSET_MAN; if (curp->man->macroset == MACROSET_MDOC) @@ -842,11 +833,8 @@ mparse_alloc(int options, enum mandoclevel wlevel, mandocmsg mmsg, void mparse_reset(struct mparse *curp) { - roff_reset(curp->roff); - - if (curp->man != NULL) - roff_man_reset(curp->man); + roff_man_reset(curp->man); if (curp->secondary) curp->secondary->sz = 0; @@ -885,6 +873,13 @@ mparse_result(struct mparse *curp, struct roff_man **man, } void +mparse_updaterc(struct mparse *curp, enum mandoclevel *rc) +{ + if (curp->file_status > *rc) + *rc = curp->file_status; +} + +void mandoc_vmsg(enum mandocerr t, struct mparse *m, int ln, int pos, const char *fmt, ...) { diff --git a/usr/src/man/man1m/dns-sd.1m b/usr/src/man/man1m/dns-sd.1m index 1b1e8082eb..5fa529bfcc 100644 --- a/usr/src/man/man1m/dns-sd.1m +++ b/usr/src/man/man1m/dns-sd.1m @@ -1,13 +1,13 @@ .\" -*- tab-width: 4 -*- -.\" +.\" .\" Copyright (c) 2004 Apple Computer, Inc. All Rights Reserved. -.\" +.\" .\" Licensed under the Apache License, Version 2.0 (the "License"); .\" you may not use this file except in compliance with the License. .\" You may obtain a copy of the License at -.\" +.\" .\" http://www.apache.org/licenses/LICENSE-2.0 -.\" +.\" .\" Unless required by applicable law or agreed to in writing, software .\" distributed under the License is distributed on an "AS IS" BASIS, .\" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,7 @@ .Sh NAME .Nm dns-sd .Nd Multicast DNS (mDNS) & DNS Service Discovery (DNS-SD) Test Tool \" For whatis -.\" +.\" .Sh SYNOPSIS .Nm .Op Fl E diff --git a/usr/src/man/man1m/mdnsd.1m b/usr/src/man/man1m/mdnsd.1m index 73d51e523c..b2dcedd695 100644 --- a/usr/src/man/man1m/mdnsd.1m +++ b/usr/src/man/man1m/mdnsd.1m @@ -1,13 +1,13 @@ .\" -*- tab-width: 4 -*- -.\" +.\" .\" Copyright (c) 2003-2004 Apple Computer, Inc. All Rights Reserved. -.\" +.\" .\" Licensed under the Apache License, Version 2.0 (the "License"); .\" you may not use this file except in compliance with the License. .\" You may obtain a copy of the License at -.\" +.\" .\" http://www.apache.org/licenses/LICENSE-2.0 -.\" +.\" .\" Unless required by applicable law or agreed to in writing, software .\" distributed under the License is distributed on an "AS IS" BASIS, .\" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,7 @@ .Sh NAME .Nm mdnsd .Nd Multicast and Unicast DNS daemon \" Name Description for whatis database -.\" +.\" .Sh SYNOPSIS .Nm .\" diff --git a/usr/src/man/man3c/pthread_mutex_consistent.3c b/usr/src/man/man3c/pthread_mutex_consistent.3c index 7adfec6527..cb45730cc4 100644 --- a/usr/src/man/man3c/pthread_mutex_consistent.3c +++ b/usr/src/man/man3c/pthread_mutex_consistent.3c @@ -9,7 +9,7 @@ .\" http://www.illumos.org/license/CDDL. .\" .\" -.\" Copyright (c) 2014, Joyent, Inc. +.\" Copyright (c) 2014, Joyent, Inc. .\" .Dd "Dec 22, 2014" .Dt PTHREAD_MUTEX_CONSISTENT 3C diff --git a/usr/src/man/man3c/pthread_mutexattr_getrobust.3c b/usr/src/man/man3c/pthread_mutexattr_getrobust.3c index 3f7abffff5..cefcc73042 100644 --- a/usr/src/man/man3c/pthread_mutexattr_getrobust.3c +++ b/usr/src/man/man3c/pthread_mutexattr_getrobust.3c @@ -9,7 +9,7 @@ .\" http://www.illumos.org/license/CDDL. .\" .\" -.\" Copyright (c) 2014, Joyent, Inc. +.\" Copyright (c) 2014, Joyent, Inc. .\" .Dd "Dec 22, 2014" .Dt PTHREAD_MUTEXATTR_GETROBUST 3C diff --git a/usr/src/man/man3c/signalfd.3c b/usr/src/man/man3c/signalfd.3c index f08e85b273..fecd46e124 100644 --- a/usr/src/man/man3c/signalfd.3c +++ b/usr/src/man/man3c/signalfd.3c @@ -3,7 +3,7 @@ .\" Common Development and Distribution License ("CDDL"), version 1.0. .\" You may only use this file in accordance with the terms of version .\" 1.0 of the CDDL. -.\" +.\" .\" A full copy of the text of the CDDL should have accompanied this .\" source. A copy of the CDDL is also available via the Internet at .\" http://www.illumos.org/license/CDDL. diff --git a/usr/src/man/man3c/smt_pause.3c b/usr/src/man/man3c/smt_pause.3c index 2a890c4977..495d3b78d1 100644 --- a/usr/src/man/man3c/smt_pause.3c +++ b/usr/src/man/man3c/smt_pause.3c @@ -9,7 +9,7 @@ .\" http://www.illumos.org/license/CDDL. .\" .\" -.\" Copyright (c) 2014, Joyent, Inc. +.\" Copyright (c) 2014, Joyent, Inc. .\" .Dd "Dec 22, 2014" .Dt SMT_PAUSE 3C |