summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.c6
-rw-r--r--mandoc_xr.c2
-rw-r--r--mandoc_xr.h1
3 files changed, 8 insertions, 1 deletions
diff --git a/main.c b/main.c
index 03825c4f..9d6db883 100644
--- a/main.c
+++ b/main.c
@@ -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 4d6b7825..6146741c 100644
--- a/mandoc_xr.c
+++ b/mandoc_xr.c
@@ -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 182dc1ad..1e19199a 100644
--- a/mandoc_xr.h
+++ b/mandoc_xr.h
@@ -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[];
};