summaryrefslogtreecommitdiffstats
path: root/usr.bin/locate
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2012-01-03 18:51:58 +0000
committered <ed@FreeBSD.org>2012-01-03 18:51:58 +0000
commite7e5b53bf16ab3b35646f0580b36fa7d7afa9678 (patch)
treeb751618c7a82d9c00cab91ea9f611585dbf14d84 /usr.bin/locate
parentd106f2fd7cf6be7617b1756d893b5b6fba5310f4 (diff)
downloadFreeBSD-src-e7e5b53bf16ab3b35646f0580b36fa7d7afa9678.zip
FreeBSD-src-e7e5b53bf16ab3b35646f0580b36fa7d7afa9678.tar.gz
Replace index() and rindex() calls with strchr() and strrchr().
The index() and rindex() functions were marked LEGACY in the 2001 revision of POSIX and were subsequently removed from the 2008 revision. The strchr() and strrchr() functions are part of the C standard. This makes the source code a lot more consistent, as most of these C files also call into other str*() routines. In fact, about a dozen already perform strchr() calls.
Diffstat (limited to 'usr.bin/locate')
-rw-r--r--usr.bin/locate/locate/fastfind.c2
-rw-r--r--usr.bin/locate/locate/util.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/locate/locate/fastfind.c b/usr.bin/locate/locate/fastfind.c
index 21148bc..c15730b 100644
--- a/usr.bin/locate/locate/fastfind.c
+++ b/usr.bin/locate/locate/fastfind.c
@@ -167,7 +167,7 @@ fastfind
/* find optimal (last) char for searching */
for (p = pathpart; *p != '\0'; p++)
- if (index(LOCATE_REG, *p) != NULL)
+ if (strchr(LOCATE_REG, *p) != NULL)
break;
if (*p == '\0')
diff --git a/usr.bin/locate/locate/util.c b/usr.bin/locate/locate/util.c
index 7b9fe49..d00a9a3 100644
--- a/usr.bin/locate/locate/util.c
+++ b/usr.bin/locate/locate/util.c
@@ -162,7 +162,7 @@ patprep(name)
/* skip trailing metacharacters */
for (; p >= name; p--)
- if (index(LOCATE_REG, *p) == NULL)
+ if (strchr(LOCATE_REG, *p) == NULL)
break;
/*
@@ -172,7 +172,7 @@ patprep(name)
* |----< p
*/
if (p >= name &&
- (index(p, '[') != NULL || index(p, ']') != NULL)) {
+ (strchr(p, '[') != NULL || strchr(p, ']') != NULL)) {
for (p = name; *p != '\0'; p++)
if (*p == ']' || *p == '[')
break;
@@ -183,7 +183,7 @@ patprep(name)
* '*\*[a-z]'
* |-------< p
*/
- if (p >= name && index(LOCATE_REG, *p) != NULL)
+ if (p >= name && strchr(LOCATE_REG, *p) != NULL)
p = name - 1;
}
@@ -193,7 +193,7 @@ patprep(name)
else {
for (endmark = p; p >= name; p--)
- if (index(LOCATE_REG, *p) != NULL)
+ if (strchr(LOCATE_REG, *p) != NULL)
break;
for (++p;
(p <= endmark) && subp < (globfree + sizeof(globfree));)
OpenPOWER on IntegriCloud