Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/locate/locate locate: fix support for m...



details:   https://anonhg.NetBSD.org/src/rev/81a2cd88eca9
branches:  trunk
changeset: 319029:81a2cd88eca9
user:      lukem <lukem%NetBSD.org@localhost>
date:      Mon May 14 05:17:10 2018 +0000
description:
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:

 usr.bin/locate/locate/locate.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (42 lines):

diff -r 119a37d49e7f -r 81a2cd88eca9 usr.bin/locate/locate/locate.c
--- a/usr.bin/locate/locate/locate.c    Mon May 14 02:55:46 2018 +0000
+++ b/usr.bin/locate/locate/locate.c    Mon May 14 05:17:10 2018 +0000
@@ -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 @@
 #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 @@
        }
        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) {



Home | Main Index | Thread Index | Old Index