aboutsummaryrefslogtreecommitdiffstats
path: root/mansearch.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2017-10-06 11:45:56 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2017-10-06 11:45:56 +0000
commitabba600e6fdb031951c32298f8be9e45fb339099 (patch)
treeac8e6e8ae5bd8922ffff03805923fe6f0557e8f1 /mansearch.c
parent75b6c55cb02aaa5d40a725b90ffb672a4c25e2ee (diff)
downloadsrc-abba600e6fdb031951c32298f8be9e45fb339099.tar.gz
src-abba600e6fdb031951c32298f8be9e45fb339099.zip
Import mandoc 1.14.3vendor/mandoc/1.14.3
Notes
Notes: svn path=/vendor/mdocml/dist/; revision=324356 svn path=/vendor/mdocml/1.14.3/; revision=324357; tag=vendor/mandoc/1.14.3
Diffstat (limited to 'mansearch.c')
-rw-r--r--mansearch.c67
1 files changed, 49 insertions, 18 deletions
diff --git a/mansearch.c b/mansearch.c
index c889aecf52f2..0d60c3bed731 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mansearch.c,v 1.50 2016/07/09 15:23:36 schwarze Exp $ */
+/* $Id: mansearch.c,v 1.76 2017/08/02 13:29:04 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -171,7 +171,9 @@ mansearch(const struct mansearch *search,
page = dbm_page_get(rp->page);
if (lstmatch(search->sec, page->sect) == 0 ||
- lstmatch(search->arch, page->arch) == 0)
+ lstmatch(search->arch, page->arch) == 0 ||
+ (search->argmode == ARG_NAME &&
+ rp->bits <= (int32_t)(NAME_SYN & NAME_MASK)))
continue;
if (res == NULL) {
@@ -452,14 +454,28 @@ lstlen(const char *cp, size_t sep)
{
size_t sz;
- for (sz = 0;; sz++) {
- if (cp[0] == '\0') {
- if (cp[1] == '\0')
- break;
- sz += sep - 1;
- } else if (cp[0] < ' ')
- sz--;
- cp++;
+ for (sz = 0; *cp != '\0'; cp++) {
+
+ /* Skip names appearing only in the SYNOPSIS. */
+ if (*cp <= (char)(NAME_SYN & NAME_MASK)) {
+ while (*cp != '\0')
+ cp++;
+ continue;
+ }
+
+ /* Skip name class markers. */
+ if (*cp < ' ')
+ cp++;
+
+ /* Print a separator before each but the first string. */
+ if (sz)
+ sz += sep;
+
+ /* Copy one string. */
+ while (*cp != '\0') {
+ sz++;
+ cp++;
+ }
}
return sz;
}
@@ -471,19 +487,34 @@ lstlen(const char *cp, size_t sep)
static void
lstcat(char *buf, size_t *i, const char *cp, const char *sep)
{
- const char *s;
+ const char *s;
+ size_t i_start;
- for (;;) {
- if (cp[0] == '\0') {
- if (cp[1] == '\0')
- break;
+ for (i_start = *i; *cp != '\0'; cp++) {
+
+ /* Skip names appearing only in the SYNOPSIS. */
+ if (*cp <= (char)(NAME_SYN & NAME_MASK)) {
+ while (*cp != '\0')
+ cp++;
+ continue;
+ }
+
+ /* Skip name class markers. */
+ if (*cp < ' ')
+ cp++;
+
+ /* Print a separator before each but the first string. */
+ if (*i > i_start) {
s = sep;
while (*s != '\0')
buf[(*i)++] = *s++;
- } else if (cp[0] >= ' ')
- buf[(*i)++] = cp[0];
- cp++;
+ }
+
+ /* Copy one string. */
+ while (*cp != '\0')
+ buf[(*i)++] = *cp++;
}
+
}
/*