aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-07-02 21:18:29 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-07-02 21:18:29 +0000
commitec4aa33aa49344c12ff324f27bb68a147a21623e (patch)
tree03ab3cef63acc0d53aadd0edbdb78d211819addd
parente5501471e172d4f6de0c3e4afca1fffb5cc93ea7 (diff)
downloadmandoc-ec4aa33aa49344c12ff324f27bb68a147a21623e.tar.gz
mandoc-ec4aa33aa49344c12ff324f27bb68a147a21623e.tar.zst
mandoc-ec4aa33aa49344c12ff324f27bb68a147a21623e.zip
If a single page references the same non-existent manual more than
once, print "(N times)" after the message "referenced manual not found", to lessen the risk that people fix the first instance and miss the others; jmc@ confirmed that this is useful.
-rw-r--r--main.c8
-rw-r--r--mandoc_xr.c4
-rw-r--r--mandoc_xr.h3
3 files changed, 11 insertions, 4 deletions
diff --git a/main.c b/main.c
index 2c289e4a..cac2fe49 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.297 2017/07/02 15:31:59 schwarze Exp $ */
+/* $Id: main.c,v 1.298 2017/07/02 21:18:29 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -844,7 +844,11 @@ check_xr(const char *file)
continue;
if (fs_search(&search, &paths, 1, &xr->name, NULL, &sz))
continue;
- mandoc_asprintf(&cp, "Xr %s %s", xr->name, xr->sec);
+ if (xr->count == 1)
+ mandoc_asprintf(&cp, "Xr %s %s", xr->name, xr->sec);
+ else
+ mandoc_asprintf(&cp, "Xr %s %s (%d times)",
+ xr->name, xr->sec, xr->count);
mmsg(MANDOCERR_XR_BAD, MANDOCLEVEL_STYLE,
file, xr->line, xr->pos + 1, cp);
free(cp);
diff --git a/mandoc_xr.c b/mandoc_xr.c
index f6cb46d4..da0a7f0c 100644
--- a/mandoc_xr.c
+++ b/mandoc_xr.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc_xr.c,v 1.2 2017/07/02 15:31:59 schwarze Exp $ */
+/* $Id: mandoc_xr.c,v 1.3 2017/07/02 21:18:29 schwarze Exp $ */
/*
* Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -81,6 +81,7 @@ mandoc_xr_add(const char *sec, const char *name, int line, int pos)
xr->name = xr->hashkey + ssz;
xr->line = line;
xr->pos = pos;
+ xr->count = 1;
memcpy(xr->sec, sec, ssz);
memcpy(xr->name, name, nsz);
@@ -97,6 +98,7 @@ mandoc_xr_add(const char *sec, const char *name, int line, int pos)
return 0;
}
+ oxr->count++;
ret = (oxr->line == -1) ^ (xr->line == -1);
if (xr->line == -1)
oxr->line = -1;
diff --git a/mandoc_xr.h b/mandoc_xr.h
index bf82598d..e0c6af0e 100644
--- a/mandoc_xr.h
+++ b/mandoc_xr.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc_xr.h,v 1.2 2017/07/02 15:31:59 schwarze Exp $ */
+/* $Id: mandoc_xr.h,v 1.3 2017/07/02 21:18:29 schwarze Exp $ */
/*
* Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -21,6 +21,7 @@ struct mandoc_xr {
char *name;
int line; /* Or -1 for this page's own names. */
int pos;
+ int count;
char hashkey[];
};