From e7e5b53bf16ab3b35646f0580b36fa7d7afa9678 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 3 Jan 2012 18:51:58 +0000 Subject: 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. --- usr.bin/locate/locate/fastfind.c | 2 +- usr.bin/locate/locate/util.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'usr.bin/locate') 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));) -- cgit v1.1