summaryrefslogtreecommitdiff
path: root/usr.bin/locate
diff options
context:
space:
mode:
authorlukem <lukem@NetBSD.org>2018-05-14 05:17:10 +0000
committerlukem <lukem@NetBSD.org>2018-05-14 05:17:10 +0000
commit5b6604b6a8fc14295fc801fe98b89c1a39f3fa7b (patch)
tree86638b9d229ed1ee3d823618479eb9ae3088f486 /usr.bin/locate
parent72c5074146e4a659029348cf371b853d0ba9c4dd (diff)
locate: fix support for multiple databases
Ensure that the first database is correctly added when more than one database is provided. Fixes problem I introduced in rev 1.17 on 2009-04-12, and noticed recently by Simon.
Diffstat (limited to 'usr.bin/locate')
-rw-r--r--usr.bin/locate/locate/locate.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
index fb86ac6a47c..43ab04d68f2 100644
--- a/usr.bin/locate/locate/locate.c
+++ b/usr.bin/locate/locate/locate.c
@@ -1,4 +1,4 @@
-/* $NetBSD: locate.c,v 1.18 2016/09/05 00:40:29 sevan Exp $ */
+/* $NetBSD: locate.c,v 1.19 2018/05/14 05:17:10 lukem Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\
#if 0
static char sccsid[] = "@(#)locate.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: locate.c,v 1.18 2016/09/05 00:40:29 sevan Exp $");
+__RCSID("$NetBSD: locate.c,v 1.19 2018/05/14 05:17:10 lukem Exp $");
#endif /* not lint */
/*
@@ -153,15 +153,15 @@ main(int argc, char *argv[])
}
if (!locate_path)
locate_path = _PATH_FCODES;
- if ((cp = strrchr(locate_path, ':'))) {
- char *lp = strdup(locate_path);
- while ((cp = strrchr(lp, ':'))) {
- *cp++ = '\0';
- add_db(cp);
- }
- free(lp);
+
+ char *lp = strdup(locate_path);
+ while ((cp = strrchr(lp, ':'))) {
+ *cp++ = '\0';
+ add_db(cp);
}
- add_db(locate_path);
+ add_db(lp);
+ free(lp);
+
if (LIST_EMPTY(&db_list))
exit(1);
for (; optind < argc; ++optind) {