diff options
author | michaels <michaels@cvs.openbsd.org> | 1996-08-30 12:54:19 +0000 |
---|---|---|
committer | michaels <michaels@cvs.openbsd.org> | 1996-08-30 12:54:19 +0000 |
commit | 5c42a62ad6320c742d6aca0d1bd548757187c7c5 (patch) | |
tree | 2689686ddbc51447be0d5a5bc1055be4ae10a7f3 /usr.bin/locate | |
parent | e09cd5b5d9f4bae5bb11ad7edc7f95adc050ed36 (diff) |
Bugs in code, NUL != NULL, from bde@zeta.org.au (Bruce Evans)
Diffstat (limited to 'usr.bin/locate')
-rw-r--r-- | usr.bin/locate/bigram/locate.bigram.c | 12 | ||||
-rw-r--r-- | usr.bin/locate/code/locate.code.c | 18 | ||||
-rw-r--r-- | usr.bin/locate/locate/locate.c | 12 | ||||
-rw-r--r-- | usr.bin/locate/locate/locate.h | 5 |
4 files changed, 25 insertions, 22 deletions
diff --git a/usr.bin/locate/bigram/locate.bigram.c b/usr.bin/locate/bigram/locate.bigram.c index d0c13d86e26..1f8e5d604c6 100644 --- a/usr.bin/locate/bigram/locate.bigram.c +++ b/usr.bin/locate/bigram/locate.bigram.c @@ -1,4 +1,4 @@ -/* $OpenBSD: locate.bigram.c,v 1.3 1996/08/16 22:00:10 michaels Exp $ */ +/* $OpenBSD: locate.bigram.c,v 1.4 1996/08/30 12:54:16 michaels Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -45,7 +45,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)locate.bigram.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: locate.bigram.c,v 1.3 1996/08/16 22:00:10 michaels Exp $"; +static char rcsid[] = "$OpenBSD: locate.bigram.c,v 1.4 1996/08/30 12:54:16 michaels Exp $"; #endif #endif /* not lint */ @@ -77,23 +77,23 @@ int main(void) continue; /* Squelch characters that would botch the decoding. */ - for (cp = path; *cp != NULL; cp++) { + for (cp = path; *cp != NUL; cp++) { /* chop newline */ if (*cp == '\n') - *cp = NULL; + *cp = NUL; /* range */ else if (*cp < ASCII_MIN || *cp > ASCII_MAX) *cp = '?'; } /* skip longest common prefix */ - for (cp = path; *cp == *oldpath && *cp != NULL; cp++, oldpath++) + for (cp = path; *cp == *oldpath && *cp != NUL; cp++, oldpath++) ; /* * output post-residue bigrams only */ /* check later for boundary */ - while ( *cp != NULL && *(cp+1) != NULL ) { + while ( *cp != NUL && *(cp+1) != NUL ) { bigram[*cp][*(cp+1)]++; cp += 2; } diff --git a/usr.bin/locate/code/locate.code.c b/usr.bin/locate/code/locate.code.c index af435e68a22..dae4d532ef3 100644 --- a/usr.bin/locate/code/locate.code.c +++ b/usr.bin/locate/code/locate.code.c @@ -1,4 +1,4 @@ -/* $OpenBSD: locate.code.c,v 1.3 1996/08/16 22:00:11 michaels Exp $ */ +/* $OpenBSD: locate.code.c,v 1.4 1996/08/30 12:54:17 michaels Exp $ */ /* * Copyright (c) 1989, 1993 @@ -46,7 +46,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)locate.code.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: locate.code.c,v 1.3 1996/08/16 22:00:11 michaels Exp $"; +static char rcsid[] = "$OpenBSD: locate.code.c,v 1.4 1996/08/30 12:54:17 michaels Exp $"; #endif #endif /* not lint */ @@ -151,7 +151,7 @@ main(argc, argv) for (j = 0; j < UCHAR_MAX; j++) big[i][j] = (bg_t)-1; - for (cp = bigrams, i = 0; *cp != NULL; i += 2, cp += 2) + for (cp = bigrams, i = 0; *cp != NUL; i += 2, cp += 2) big[(int)*cp][(int)*(cp + 1)] = (bg_t)i; #endif @@ -165,10 +165,10 @@ main(argc, argv) continue; /* Squelch characters that would botch the decoding. */ - for (cp = path; *cp != NULL; cp++) { + for (cp = path; *cp != NUL; cp++) { /* chop newline */ if (*cp == '\n') - *cp = NULL; + *cp = NUL; /* range */ else if (*cp < ASCII_MIN || *cp > ASCII_MAX) *cp = '?'; @@ -188,8 +188,8 @@ main(argc, argv) if (putchar(diffcount) == EOF) err(1, "stdout"); - while (*cp != NULL) { - if (*(cp + 1) == NULL) { + while (*cp != NUL) { + if (*(cp + 1) == NUL) { if (putchar(*cp) == EOF) err(1, "stdout"); break; @@ -229,10 +229,10 @@ bgindex(bg) /* Return location of bg in bigrams or -1. */ bg0 = bg[0]; bg1 = bg[1]; - for (p = bigrams; *p != NULL; p++) + for (p = bigrams; *p != NUL; p++) if (*p++ == bg0 && *p == bg1) break; - return (*p == NULL ? -1 : (--p - bigrams)); + return (*p == NUL ? -1 : (--p - bigrams)); } #endif /* !LOOKUP */ diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c index 3dbc520aca4..d4133e45b2f 100644 --- a/usr.bin/locate/locate/locate.c +++ b/usr.bin/locate/locate/locate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: locate.c,v 1.3 1996/08/16 22:00:12 michaels Exp $ */ +/* $OpenBSD: locate.c,v 1.4 1996/08/30 12:54:18 michaels Exp $ */ /* * Copyright (c) 1989, 1993 @@ -46,7 +46,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)locate.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: locate.c,v 1.3 1996/08/16 22:00:12 michaels Exp $"; +static char rcsid[] = "$OpenBSD: locate.c,v 1.4 1996/08/30 12:54:18 michaels Exp $"; #endif #endif /* not lint */ @@ -103,7 +103,7 @@ main(argc, argv) _PATH_FCODES); exit(1); } - while (*(++argv) != NULL) + while (*(++argv) != NUL) fastfind(*argv); return 0; @@ -136,15 +136,15 @@ fastfind(pathpart) c &= PARITY - 1; *p++ = bigram1[c], *p++ = bigram2[c]; } - *p-- = NULL; + *p-- = NUL; cutoff = (found ? path : path + count); for (found = 0, s = p; s >= cutoff; s--) if (*s == *patend) { /* fast first char check */ - for (p = patend - 1, q = s - 1; *p != NULL; + for (p = patend - 1, q = s - 1; *p != NUL; p--, q--) if (*q != *p) break; - if (*p == NULL) { /* fast match success */ + if (*p == NUL) { /* fast match success */ found = 1; if (!globflag || !fnmatch(pathpart, path, 0)) (void)printf("%s\n", path); diff --git a/usr.bin/locate/locate/locate.h b/usr.bin/locate/locate/locate.h index 04437e13a1b..f613855188b 100644 --- a/usr.bin/locate/locate/locate.h +++ b/usr.bin/locate/locate/locate.h @@ -1,4 +1,4 @@ -/* $OpenBSD: locate.h,v 1.3 1996/08/16 22:00:13 michaels Exp $ */ +/* $OpenBSD: locate.h,v 1.4 1996/08/30 12:54:18 michaels Exp $ */ /* * Copyright (c) 1989, 1993 @@ -67,3 +67,6 @@ u_char myctype[UCHAR_MAX + 1]; #endif #define INTSIZE (sizeof(int)) + +#define NUL '\0' + |