From 56c2713e35a776515ec4c20fd46eb6e1b80f2e41 Mon Sep 17 00:00:00 2001 From: schwarze Date: Sat, 17 Jun 2017 23:06:43 +0000 Subject: [PATCH] style message about duplicate RCS ids; inspired by mdoclint --- usr.bin/mandoc/mandoc.1 | 7 ++++++- usr.bin/mandoc/mandoc.h | 3 ++- usr.bin/mandoc/read.c | 3 ++- usr.bin/mandoc/roff.c | 8 ++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1 index 0e6d6b322cc..6210f1c91a5 100644 --- a/usr.bin/mandoc/mandoc.1 +++ b/usr.bin/mandoc/mandoc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mandoc.1,v 1.124 2017/06/17 22:40:27 schwarze Exp $ +.\" $OpenBSD: mandoc.1,v 1.125 2017/06/17 23:06:43 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons .\" Copyright (c) 2012, 2014-2017 Ingo Schwarze @@ -799,6 +799,11 @@ generated by CVS or .Ic NetBSD keyword substitution as conventionally used in these operating systems. +.It Sy "duplicate RCS id" +A single manual page contains two copies of the RCS identifier for +the same operating system. +Consider deleting the later instance and moving the first one up +to the top of the page. .It Sy "useless macro" .Pq mdoc A diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index bb7b9c32ebd..55e1643dec4 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.173 2017/06/17 22:40:27 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.174 2017/06/17 23:06:43 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -50,6 +50,7 @@ enum mandocerr { MANDOCERR_MDOCDATE_MISSING, /* Mdocdate missing: Dd ... */ MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */ MANDOCERR_RCS_MISSING, /* RCS id missing */ + MANDOCERR_RCS_REP, /* duplicate RCS id: ... */ MANDOCERR_MACRO_USELESS, /* useless macro: macro */ MANDOCERR_BX, /* consider using OS macro: macro */ MANDOCERR_ER_ORDER, /* errnos out of order: Er ... */ diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 83422873abc..3994caca0d3 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.149 2017/06/17 22:40:27 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.150 2017/06/17 23:06:43 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -88,6 +88,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "Mdocdate missing", "legacy man(7) date format", "RCS id missing", + "duplicate RCS id", "useless macro", "consider using OS macro", "errnos out of order", diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 516c13217d1..c108ae89d02 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.185 2017/06/17 22:40:27 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.186 2017/06/17 23:06:43 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017 Ingo Schwarze @@ -1194,8 +1194,12 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos) } if (cp != NULL && isalnum((unsigned char)*cp) == 0 && - strchr(cp, '$') != NULL) + strchr(cp, '$') != NULL) { + if (r->man->meta.rcsids & (1 << os_e)) + mandoc_msg(MANDOCERR_RCS_REP, r->parse, + ln, stesc + 1 - buf->buf, stesc + 1); r->man->meta.rcsids |= 1 << os_e; + } /* Handle trailing whitespace. */ -- 2.20.1