summaryrefslogtreecommitdiff
path: root/usr.bin/locate
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-03-18 20:13:50 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-03-18 20:13:50 +0000
commitac1137b6a847c7588490a81e52944d5a73b778ac (patch)
tree2f5f0621fb41393935b8c4d628598c9c259dc6c9 /usr.bin/locate
parenta3396f1e62f80fcd096c538c5a3ce406d196b6c0 (diff)
It's not smart to use a space as a field separator when a space can
be part of a bigram. So switch to tab and as a bonus detect in locate.code if the bigram array is too short. Problem seen by Han Boetes and other people with too big mps3 collections; these typically contain lots of file names with spaces in them. ok jasper@
Diffstat (limited to 'usr.bin/locate')
-rw-r--r--usr.bin/locate/bigram/locate.bigram.c8
-rw-r--r--usr.bin/locate/code/locate.code.c9
-rw-r--r--usr.bin/locate/locate/mklocatedb.sh6
3 files changed, 13 insertions, 10 deletions
diff --git a/usr.bin/locate/bigram/locate.bigram.c b/usr.bin/locate/bigram/locate.bigram.c
index b741b29ccb3..8d5a62696fc 100644
--- a/usr.bin/locate/bigram/locate.bigram.c
+++ b/usr.bin/locate/bigram/locate.bigram.c
@@ -1,5 +1,5 @@
/*
- * $OpenBSD: locate.bigram.c,v 1.10 2003/09/29 16:03:16 deraadt Exp $
+ * $OpenBSD: locate.bigram.c,v 1.11 2007/03/18 20:13:49 otto Exp $
*
* Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
* Copyright (c) 1989, 1993
@@ -32,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: locate.bigram.c,v 1.10 2003/09/29 16:03:16 deraadt Exp $
+ * $Id: locate.bigram.c,v 1.11 2007/03/18 20:13:49 otto Exp $
*/
#ifndef lint
@@ -41,7 +41,7 @@ static char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#else
-static char rcsid[] = "$OpenBSD: locate.bigram.c,v 1.10 2003/09/29 16:03:16 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: locate.bigram.c,v 1.11 2007/03/18 20:13:49 otto Exp $";
#endif
#endif /* not lint */
@@ -106,7 +106,7 @@ main(void)
for (i = ASCII_MIN; i <= ASCII_MAX; i++)
for (j = ASCII_MIN; j <= ASCII_MAX; j++)
if (bigram[i][j] != 0)
- (void)printf("%4u %c%c\n", bigram[i][j], i, j);
+ (void)printf("%4u\t%c%c\n", bigram[i][j], i, j);
exit(0);
}
diff --git a/usr.bin/locate/code/locate.code.c b/usr.bin/locate/code/locate.code.c
index a6ea2bdacee..fe6d980d0d8 100644
--- a/usr.bin/locate/code/locate.code.c
+++ b/usr.bin/locate/code/locate.code.c
@@ -1,5 +1,5 @@
/*
- * $OpenBSD: locate.code.c,v 1.14 2007/02/19 20:01:12 ray Exp $
+ * $OpenBSD: locate.code.c,v 1.15 2007/03/18 20:13:49 otto Exp $
*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: locate.code.c,v 1.14 2007/02/19 20:01:12 ray Exp $
+ * $Id: locate.code.c,v 1.15 2007/03/18 20:13:49 otto Exp $
*/
#ifndef lint
@@ -44,7 +44,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.14 2007/02/19 20:01:12 ray Exp $";
+static char rcsid[] = "$OpenBSD: locate.code.c,v 1.15 2007/03/18 20:13:49 otto Exp $";
#endif
#endif /* not lint */
@@ -149,6 +149,9 @@ main(int argc, char *argv[])
if (fgets(bigrams, sizeof(bigrams), fp) == NULL)
err(1, "fgets");
+ if (strlen(bigrams) != BGBUFSIZE)
+ errx(1, "bigram array too small to build db, index more files");
+
if (fputs(bigrams, stdout) == EOF)
err(1, "stdout");
(void)fclose(fp);
diff --git a/usr.bin/locate/locate/mklocatedb.sh b/usr.bin/locate/locate/mklocatedb.sh
index b032ad19580..ba14a8e02a8 100644
--- a/usr.bin/locate/locate/mklocatedb.sh
+++ b/usr.bin/locate/locate/mklocatedb.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $OpenBSD: mklocatedb.sh,v 1.12 2003/06/29 21:59:28 millert Exp $
+# $OpenBSD: mklocatedb.sh,v 1.13 2007/03/18 20:13:49 otto Exp $
#
# Copyright (c) September 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
# All rights reserved.
@@ -30,7 +30,7 @@
#
# usage: mklocatedb [-presort] < filelist > database
#
-# $Id: mklocatedb.sh,v 1.12 2003/06/29 21:59:28 millert Exp $
+# $Id: mklocatedb.sh,v 1.13 2007/03/18 20:13:49 otto Exp $
# The directory containing locate subprograms
@@ -68,7 +68,7 @@ trap 'rm -f $bigrams $filelist' 0 1 2 3 5 10 15
if $sortcmd $sortopt > $filelist; then
$bigram < $filelist | $sort -nr |
- awk 'BEGIN { ORS = "" } NR <= 128 { print $2 }' > $bigrams &&
+ awk -Ft 'BEGIN { ORS = "" } NR <= 128 { print $2 }' > $bigrams &&
$code $bigrams < $filelist
else
echo "`basename $0`: cannot build locate database" >&2