version 1.74, 2017/07/01 09:47:30 |
version 1.78, 2018/11/19 19:27:37 |
|
|
/* $OpenBSD$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2013-2017 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2013-2018 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 171 mansearch(const struct mansearch *search, |
|
Line 171 mansearch(const struct mansearch *search, |
|
page = dbm_page_get(rp->page); |
page = dbm_page_get(rp->page); |
|
|
if (lstmatch(search->sec, page->sect) == 0 || |
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; |
continue; |
|
|
if (res == NULL) { |
if (res == NULL) { |
Line 186 mansearch(const struct mansearch *search, |
|
Line 188 mansearch(const struct mansearch *search, |
|
mpage = *res + cur; |
mpage = *res + cur; |
mandoc_asprintf(&mpage->file, "%s/%s", |
mandoc_asprintf(&mpage->file, "%s/%s", |
paths->paths[i], page->file + 1); |
paths->paths[i], page->file + 1); |
|
if (access(chdir_status ? page->file + 1 : |
|
mpage->file, R_OK) == -1) { |
|
warn("%s", mpage->file); |
|
warnx("outdated mandoc.db contains " |
|
"bogus %s entry, run makewhatis %s", |
|
page->file + 1, paths->paths[i]); |
|
free(mpage->file); |
|
free(rp); |
|
continue; |
|
} |
mpage->names = buildnames(page); |
mpage->names = buildnames(page); |
mpage->output = buildoutput(outkey, page); |
mpage->output = buildoutput(outkey, page); |
mpage->ipath = i; |
mpage->ipath = i; |
|
|
manpage_compare(const void *vp1, const void *vp2) |
manpage_compare(const void *vp1, const void *vp2) |
{ |
{ |
const struct manpage *mp1, *mp2; |
const struct manpage *mp1, *mp2; |
|
const char *cp1, *cp2; |
|
size_t sz1, sz2; |
int diff; |
int diff; |
|
|
mp1 = vp1; |
mp1 = vp1; |
mp2 = vp2; |
mp2 = vp2; |
return (diff = mp2->bits - mp1->bits) ? diff : |
if ((diff = mp2->bits - mp1->bits) || |
(diff = mp1->sec - mp2->sec) ? diff : |
(diff = mp1->sec - mp2->sec)) |
strcasecmp(mp1->names, mp2->names); |
return diff; |
|
|
|
/* Fall back to alphabetic ordering of names. */ |
|
sz1 = strcspn(mp1->names, "("); |
|
sz2 = strcspn(mp2->names, "("); |
|
if (sz1 < sz2) |
|
sz1 = sz2; |
|
if ((diff = strncasecmp(mp1->names, mp2->names, sz1))) |
|
return diff; |
|
|
|
/* For identical names and sections, prefer arch-dependent. */ |
|
cp1 = strchr(mp1->names + sz1, '/'); |
|
cp2 = strchr(mp2->names + sz2, '/'); |
|
return cp1 != NULL && cp2 != NULL ? strcasecmp(cp1, cp2) : |
|
cp1 != NULL ? -1 : cp2 != NULL ? 1 : 0; |
} |
} |
|
|
static char * |
static char * |
Line 436 lstlen(const char *cp, size_t sep) |
|
Line 464 lstlen(const char *cp, size_t sep) |
|
{ |
{ |
size_t sz; |
size_t sz; |
|
|
for (sz = 0;; sz++) { |
for (sz = 0; *cp != '\0'; cp++) { |
if (cp[0] == '\0') { |
|
if (cp[1] == '\0') |
/* Skip names appearing only in the SYNOPSIS. */ |
break; |
if (*cp <= (char)(NAME_SYN & NAME_MASK)) { |
sz += sep - 1; |
while (*cp != '\0') |
} else if (cp[0] < ' ') |
cp++; |
sz--; |
continue; |
cp++; |
} |
|
|
|
/* 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; |
return sz; |
} |
} |
Line 455 lstlen(const char *cp, size_t sep) |
|
Line 497 lstlen(const char *cp, size_t sep) |
|
static void |
static void |
lstcat(char *buf, size_t *i, const char *cp, const char *sep) |
lstcat(char *buf, size_t *i, const char *cp, const char *sep) |
{ |
{ |
const char *s; |
const char *s; |
|
size_t i_start; |
|
|
for (;;) { |
for (i_start = *i; *cp != '\0'; cp++) { |
if (cp[0] == '\0') { |
|
if (cp[1] == '\0') |
/* Skip names appearing only in the SYNOPSIS. */ |
break; |
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; |
s = sep; |
while (*s != '\0') |
while (*s != '\0') |
buf[(*i)++] = *s++; |
buf[(*i)++] = *s++; |
} else if (cp[0] >= ' ') |
} |
buf[(*i)++] = cp[0]; |
|
cp++; |
/* Copy one string. */ |
|
while (*cp != '\0') |
|
buf[(*i)++] = *cp++; |
} |
} |
|
|
} |
} |
|
|
/* |
/* |
Line 717 exprterm(const struct mansearch *search, int argc, cha |
|
Line 774 exprterm(const struct mansearch *search, int argc, cha |
|
cs = 0; |
cs = 0; |
} else if ((val = strpbrk(argv[*argi], "=~")) == NULL) { |
} else if ((val = strpbrk(argv[*argi], "=~")) == NULL) { |
e->bits = TYPE_Nm | TYPE_Nd; |
e->bits = TYPE_Nm | TYPE_Nd; |
e->match.type = DBM_SUB; |
e->match.type = DBM_REGEX; |
e->match.str = argv[*argi]; |
val = argv[*argi]; |
|
cs = 0; |
} else { |
} else { |
if (val == argv[*argi]) |
if (val == argv[*argi]) |
e->bits = TYPE_Nm | TYPE_Nd; |
e->bits = TYPE_Nm | TYPE_Nd; |