diff options
author | ed <ed@FreeBSD.org> | 2012-01-03 18:51:58 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-01-03 18:51:58 +0000 |
commit | e7e5b53bf16ab3b35646f0580b36fa7d7afa9678 (patch) | |
tree | b751618c7a82d9c00cab91ea9f611585dbf14d84 /lib/libc | |
parent | d106f2fd7cf6be7617b1756d893b5b6fba5310f4 (diff) | |
download | FreeBSD-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 'lib/libc')
-rw-r--r-- | lib/libc/gen/exec.c | 2 | ||||
-rw-r--r-- | lib/libc/gen/getttyent.c | 6 | ||||
-rw-r--r-- | lib/libc/gen/timezone.c | 2 | ||||
-rw-r--r-- | lib/libc/net/gethostbynis.c | 2 | ||||
-rw-r--r-- | lib/libc/net/getnetbynis.c | 2 |
5 files changed, 7 insertions, 7 deletions
diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c index b83136e..4998ee8 100644 --- a/lib/libc/gen/exec.c +++ b/lib/libc/gen/exec.c @@ -159,7 +159,7 @@ execvPe(const char *name, const char *path, char * const *argv, eacces = 0; /* If it's an absolute or relative path name, it's easy. */ - if (index(name, '/')) { + if (strchr(name, '/')) { bp = name; cur = NULL; goto retry; diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c index 9b9e3ea..f2fc298 100644 --- a/lib/libc/gen/getttyent.c +++ b/lib/libc/gen/getttyent.c @@ -78,7 +78,7 @@ getttyent(void) if (!fgets(p = line, lbsize, tf)) return (NULL); /* extend buffer if line was too big, and retry */ - while (!index(p, '\n') && !feof(tf)) { + while (!strchr(p, '\n') && !feof(tf)) { i = strlen(p); lbsize += MALLOCCHUNK; if ((p = realloc(line, lbsize)) == NULL) { @@ -148,7 +148,7 @@ getttyent(void) tty.ty_comment = p; if (*p == 0) tty.ty_comment = 0; - if ( (p = index(p, '\n')) ) + if ((p = strchr(p, '\n'))) *p = '\0'; return (&tty); } @@ -196,7 +196,7 @@ static char * value(char *p) { - return ((p = index(p, '=')) ? ++p : NULL); + return ((p = strchr(p, '=')) ? ++p : NULL); } int diff --git a/lib/libc/gen/timezone.c b/lib/libc/gen/timezone.c index 5f0fa66..9b50e79 100644 --- a/lib/libc/gen/timezone.c +++ b/lib/libc/gen/timezone.c @@ -59,7 +59,7 @@ timezone(int zone, int dst) *end; if ( (beg = getenv("TZNAME")) ) { /* set in environment */ - if ( (end = index(beg, ',')) ) {/* "PST,PDT" */ + if ((end = strchr(beg, ','))) { /* "PST,PDT" */ if (dst) return(++end); *end = '\0'; diff --git a/lib/libc/net/gethostbynis.c b/lib/libc/net/gethostbynis.c index 11de8ae..c0d5177 100644 --- a/lib/libc/net/gethostbynis.c +++ b/lib/libc/net/gethostbynis.c @@ -91,7 +91,7 @@ _gethostbynis(const char *name, char *map, int af, struct hostent *he, free(result); result = (char *)&ypbuf; - if ((cp = index(result, '\n'))) + if ((cp = strchr(result, '\n'))) *cp = '\0'; cp = strpbrk(result, " \t"); diff --git a/lib/libc/net/getnetbynis.c b/lib/libc/net/getnetbynis.c index 811e431..1dbed83 100644 --- a/lib/libc/net/getnetbynis.c +++ b/lib/libc/net/getnetbynis.c @@ -80,7 +80,7 @@ _getnetbynis(const char *name, char *map, int af, struct netent *ne, free(result); result = (char *)&ypbuf; - if ((cp = index(result, '\n'))) + if ((cp = strchr(result, '\n'))) *cp = '\0'; cp = strpbrk(result, " \t"); |