=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/apropos/Attic/apropos.c,v retrieving revision 1.1.1.1 retrieving revision 1.11 diff -u -r1.1.1.1 -r1.11 --- src/usr.bin/apropos/Attic/apropos.c 1995/10/18 08:44:52 1.1.1.1 +++ src/usr.bin/apropos/Attic/apropos.c 2005/10/17 19:04:19 1.11 @@ -1,3 +1,4 @@ +/* $OpenBSD: apropos.c,v 1.11 2005/10/17 19:04:19 otto Exp $ */ /* $NetBSD: apropos.c,v 1.5 1995/09/04 20:46:20 tls Exp $ */ /* @@ -12,11 +13,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -43,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)apropos.c 8.8 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$NetBSD: apropos.c,v 1.5 1995/09/04 20:46:20 tls Exp $"; +static char rcsid[] = "$OpenBSD: apropos.c,v 1.11 2005/10/17 19:04:19 otto Exp $"; #endif #endif /* not lint */ @@ -63,15 +60,15 @@ static int *found, foundman; -void apropos __P((char **, char *, int)); -void lowstr __P((char *, char *)); -int match __P((char *, char *)); -void usage __P((void)); +#define MAXLINELEN 8192 /* max line handled */ +void apropos(char **, char *, int); +void lowstr(char *, char *); +int match(char *, char *); +void usage(void); + int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { ENTRY *ep; TAG *tp; @@ -80,7 +77,7 @@ conffile = NULL; p_augment = p_path = NULL; - while ((ch = getopt(argc, argv, "C:M:m:P:")) != EOF) + while ((ch = getopt(argc, argv, "C:M:m:P:")) != -1) switch (ch) { case 'C': conffile = optarg; @@ -116,8 +113,8 @@ else { config(conffile); ep = (tp = getlist("_whatdb")) == NULL ? - NULL : tp->list.tqh_first; - for (; ep != NULL; ep = ep->q.tqe_next) + NULL : TAILQ_FIRST(&tp->list); + for (; ep != NULL; ep = TAILQ_NEXT(ep, q)) apropos(argv, ep->s, 0); } @@ -134,21 +131,19 @@ } void -apropos(argv, path, buildpath) - char **argv, *path; - int buildpath; +apropos(char **argv, char *path, int buildpath) { char *end, *name, **p; - char buf[LINE_MAX + 1], wbuf[LINE_MAX + 1]; + char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1]; + char hold[MAXPATHLEN]; for (name = path; name; name = end) { /* through name list */ - if (end = strchr(name, ':')) + if ((end = strchr(name, ':'))) *end++ = '\0'; if (buildpath) { - char hold[MAXPATHLEN + 1]; - - (void)sprintf(hold, "%s/%s", name, _PATH_WHATIS); + (void)snprintf(hold, sizeof(hold), "%s/%s", name, + _PATH_WHATIS); name = hold; } @@ -184,8 +179,7 @@ * match anywhere the string appears */ int -match(bp, str) - char *bp, *str; +match(char *bp, char *str) { int len; char test; @@ -206,8 +200,7 @@ * convert a string to lower case */ void -lowstr(from, to) - char *from, *to; +lowstr(char *from, char *to) { char ch; @@ -221,10 +214,10 @@ * print usage message and die */ void -usage() +usage(void) { (void)fprintf(stderr, - "usage: apropos [-C file] [-M path] [-m path] keyword ...\n"); + "usage: apropos [-C file] [-M path] [-m path] keyword [...]\n"); exit(1); }