-.\" $OpenBSD: mandoc.1,v 1.114 2017/05/30 20:20:45 jmc Exp $
+.\" $OpenBSD: mandoc.1,v 1.115 2017/05/31 15:30:12 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 30 2017 $
+.Dd $Mdocdate: May 31 2017 $
.Dt MANDOC 1
.Os
.Sh NAME
.Ic \&Ud
macro was found.
Simply delete it: it serves no useful purpose.
+.It Sy "consider using OS macro"
+.Pq mdoc
+A string was found in plain text or in a
+.Ic \&Bx
+macro that could be represented using
+.Ic \&Ox ,
+.Ic \&Nx ,
+.Ic \&Fx ,
+or
+.Ic \&Dx .
.El
.Ss Warnings related to the document prologue
.Bl -ohang
-/* $OpenBSD: mandoc.h,v 1.159 2017/05/30 19:29:31 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.160 2017/05/31 15:30:12 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
MANDOCERR_STYLE, /* ===== start of style suggestions ===== */
MANDOCERR_MACRO_USELESS, /* useless macro: macro */
+ MANDOCERR_BX, /* consider using OS macro: macro */
MANDOCERR_WARNING, /* ===== start of warnings ===== */
-/* $OpenBSD: mdoc_validate.c,v 1.244 2017/05/30 19:29:31 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.245 2017/05/31 15:30:12 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
static int build_list(struct roff_man *, int);
static void check_text(struct roff_man *, int, int, char *);
+static void check_bsd(struct roff_man *, int, int, char *);
static void check_argv(struct roff_man *,
struct roff_node *, struct mdoc_argv *);
static void check_args(struct roff_man *, struct roff_node *);
if (n->sec != SEC_SYNOPSIS ||
(n->parent->tok != MDOC_Cd && n->parent->tok != MDOC_Fd))
check_text(mdoc, n->line, n->pos, n->string);
+ if (n->parent->tok == MDOC_Sh ||
+ n->parent->tok == MDOC_Ss ||
+ n->parent->tok == MDOC_It)
+ check_bsd(mdoc, n->line, n->pos, n->string);
break;
case ROFFT_EQN:
case ROFFT_TBL:
ln, pos + (int)(p - cp), NULL);
}
+static void
+check_bsd(struct roff_man *mdoc, int ln, int pos, char *p)
+{
+ const char *cp;
+
+ if ((cp = strstr(p, "OpenBSD")) != NULL)
+ mandoc_msg(MANDOCERR_BX, mdoc->parse,
+ ln, pos + (cp - p), "Ox");
+ if ((cp = strstr(p, "NetBSD")) != NULL)
+ mandoc_msg(MANDOCERR_BX, mdoc->parse,
+ ln, pos + (cp - p), "Nx");
+ if ((cp = strstr(p, "FreeBSD")) != NULL)
+ mandoc_msg(MANDOCERR_BX, mdoc->parse,
+ ln, pos + (cp - p), "Fx");
+ if ((cp = strstr(p, "DragonFly")) != NULL)
+ mandoc_msg(MANDOCERR_BX, mdoc->parse,
+ ln, pos + (cp - p), "Dx");
+}
+
static void
post_bl_norm(POST_ARGS)
{
post_bx(POST_ARGS)
{
struct roff_node *n, *nch;
+ const char *macro;
n = mdoc->last;
nch = n->child;
if (nch != NULL) {
+ macro = !strcmp(nch->string, "Open") ? "Ox" :
+ !strcmp(nch->string, "Net") ? "Nx" :
+ !strcmp(nch->string, "Free") ? "Fx" :
+ !strcmp(nch->string, "DragonFly") ? "Dx" : NULL;
+ if (macro != NULL)
+ mandoc_msg(MANDOCERR_BX, mdoc->parse,
+ n->line, n->pos, macro);
mdoc->last = nch;
nch = nch->next;
mdoc->next = ROFF_NEXT_SIBLING;