summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorwosch <wosch@FreeBSD.org>2002-01-01 21:16:10 +0000
committerwosch <wosch@FreeBSD.org>2002-01-01 21:16:10 +0000
commit5b2b74c0d4d8555db5b36000c07ebbd7d38bacb9 (patch)
tree56e35c4915ad0360aff5e81d70dd1d0c67b1e6ad /usr.bin
parent2a960306a9a69c8ba0f2664e77542a08c7994306 (diff)
downloadFreeBSD-src-5b2b74c0d4d8555db5b36000c07ebbd7d38bacb9.zip
FreeBSD-src-5b2b74c0d4d8555db5b36000c07ebbd7d38bacb9.tar.gz
A global is used even though the value is
passed through the function call. Submitted by: "Crist J . Clark" <cjc@freebsd.org>
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/locate/locate/locate.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
index 0ee14f3..e4d0179 100644
--- a/usr.bin/locate/locate/locate.c
+++ b/usr.bin/locate/locate/locate.c
@@ -112,7 +112,6 @@ static const char rcsid[] =
# include <sys/resource.h>
#endif
-char *path_fcodes; /* locate database */
int f_mmap; /* use mmap */
int f_icase; /* ignore case */
int f_stdin; /* read database from stdin */
@@ -147,6 +146,7 @@ main(argc, argv)
{
register int ch;
char **dbv = NULL;
+ char *path_fcodes; /* locate database */
#ifdef MMAP
f_mmap = 1; /* mmap is default */
#endif
@@ -246,12 +246,12 @@ search_fopen(db, s)
*(s+1) = NULL;
}
}
- else if ((fp = fopen(path_fcodes, "r")) == NULL)
- err(1, "`%s'", path_fcodes);
+ else if ((fp = fopen(db, "r")) == NULL)
+ err(1, "`%s'", db);
/* count only chars or lines */
if (f_statistic) {
- statistic(fp, path_fcodes);
+ statistic(fp, db);
(void)fclose(fp);
return;
}
@@ -263,12 +263,12 @@ search_fopen(db, s)
#endif
if (!f_stdin &&
fseek(fp, (long)0, SEEK_SET) == -1)
- err(1, "fseek to begin of ``%s''\n", path_fcodes);
+ err(1, "fseek to begin of ``%s''\n", db);
if (f_icase)
- fastfind_icase(fp, *s, path_fcodes);
+ fastfind_icase(fp, *s, db);
else
- fastfind(fp, *s, path_fcodes);
+ fastfind(fp, *s, db);
#ifdef DEBUG
warnx("fastfind %ld ms", cputime () - t0);
#endif
@@ -290,15 +290,15 @@ search_mmap(db, s)
#ifdef DEBUG
long t0;
#endif
- if ((fd = open(path_fcodes, O_RDONLY)) == -1 ||
+ if ((fd = open(db, O_RDONLY)) == -1 ||
fstat(fd, &sb) == -1)
- err(1, "`%s'", path_fcodes);
+ err(1, "`%s'", db);
len = sb.st_size;
if ((p = mmap((caddr_t)0, (size_t)len,
PROT_READ, MAP_SHARED,
fd, (off_t)0)) == MAP_FAILED)
- err(1, "mmap ``%s''", path_fcodes);
+ err(1, "mmap ``%s''", db);
/* foreach search string ... */
while (*s != NULL) {
@@ -306,9 +306,9 @@ search_mmap(db, s)
t0 = cputime();
#endif
if (f_icase)
- fastfind_mmap_icase(*s, p, (int)len, path_fcodes);
+ fastfind_mmap_icase(*s, p, (int)len, db);
else
- fastfind_mmap(*s, p, (int)len, path_fcodes);
+ fastfind_mmap(*s, p, (int)len, db);
#ifdef DEBUG
warnx("fastfind %ld ms", cputime () - t0);
#endif
@@ -316,7 +316,7 @@ search_mmap(db, s)
}
if (munmap(p, (size_t)len) == -1)
- warn("munmap %s\n", path_fcodes);
+ warn("munmap %s\n", db);
(void)close(fd);
}
OpenPOWER on IntegriCloud