Since GLOB_NOCHECK is not set, explicitly check for a return value of

GLOB_NOMATCH from glob().  Noticed by Juergen Hannken-Illjes.
This commit is contained in:
kleink 1998-07-06 14:23:31 +00:00
parent 14119e2944
commit d39ba37ccb
3 changed files with 30 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: apropos.c,v 1.12 1998/06/19 23:00:25 kleink Exp $ */
/* $NetBSD: apropos.c,v 1.13 1998/07/06 14:23:31 kleink Exp $ */
/*
* Copyright (c) 1987, 1993, 1994
@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)apropos.c 8.8 (Berkeley) 5/4/95";
#else
__RCSID("$NetBSD: apropos.c,v 1.12 1998/06/19 23:00:25 kleink Exp $");
__RCSID("$NetBSD: apropos.c,v 1.13 1998/07/06 14:23:31 kleink Exp $");
#endif
#endif /* not lint */
@ -124,9 +124,13 @@ main(argc, argv)
ep = (tp = getlist("_whatdb")) == NULL ?
NULL : tp->list.tqh_first;
for (; ep != NULL; ep = ep->q.tqe_next) {
if (glob(ep->s, GLOB_BRACE | GLOB_NOSORT, NULL,
&pg) != 0)
err(1, "glob");
if ((rv = glob(ep->s, GLOB_BRACE | GLOB_NOSORT, NULL,
&pg)) != 0) {
if (rv == GLOB_NOMATCH)
continue;
else
err(1, "glob");
}
if (pg.gl_pathc)
for (p = pg.gl_pathv; *p; p++)
apropos(argv, *p, 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: man.c,v 1.11 1998/06/19 23:02:44 kleink Exp $ */
/* $NetBSD: man.c,v 1.12 1998/07/06 14:23:32 kleink Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994, 1995\n\
#if 0
static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
#else
__RCSID("$NetBSD: man.c,v 1.11 1998/06/19 23:02:44 kleink Exp $");
__RCSID("$NetBSD: man.c,v 1.12 1998/07/06 14:23:32 kleink Exp $");
#endif
#endif /* not lint */
@ -374,7 +374,7 @@ manual(page, tag, pg)
{
ENTRY *ep, *e_sufp, *e_tag;
TAG *missp, *sufp;
int anyfound, cnt, found;
int anyfound, cnt, error, found;
char *p, buf[MAXPATHLEN];
anyfound = 0;
@ -384,11 +384,15 @@ manual(page, tag, pg)
e_tag = tag == NULL ? NULL : tag->list.tqh_first;
for (; e_tag != NULL; e_tag = e_tag->q.tqe_next) {
(void)snprintf(buf, sizeof(buf), "%s/%s.*", e_tag->s, page);
if (glob(buf,
GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT, NULL, pg)) {
warn("globbing");
(void)cleanup();
exit(1);
if ((error = glob(buf,
GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT, NULL, pg)) != 0) {
if (error == GLOB_NOMATCH)
continue;
else {
warn("globbing");
(void)cleanup();
exit(1);
}
}
if (pg->gl_matchc == 0)
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: whatis.c,v 1.11 1998/06/19 23:03:39 kleink Exp $ */
/* $NetBSD: whatis.c,v 1.12 1998/07/06 14:23:32 kleink Exp $ */
/*
* Copyright (c) 1987, 1993
@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
#if 0
static char sccsid[] = "@(#)whatis.c 8.5 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: whatis.c,v 1.11 1998/06/19 23:03:39 kleink Exp $");
__RCSID("$NetBSD: whatis.c,v 1.12 1998/07/06 14:23:32 kleink Exp $");
#endif
#endif /* not lint */
@ -124,9 +124,13 @@ main(argc, argv)
ep = (tp = getlist("_whatdb")) == NULL ?
NULL : tp->list.tqh_first;
for (; ep != NULL; ep = ep->q.tqe_next) {
if (glob(ep->s, GLOB_BRACE | GLOB_NOSORT, NULL,
&pg) != 0)
err(1, "glob");
if ((rv = glob(ep->s, GLOB_BRACE | GLOB_NOSORT, NULL,
&pg)) != 0) {
if (rv == GLOB_NOMATCH)
continue;
else
err(1, "glob");
}
if (pg.gl_pathc)
for (p = pg.gl_pathv; *p; p++)
whatis(argv, *p, 0);