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 /usr.sbin/config | |
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 'usr.sbin/config')
-rw-r--r-- | usr.sbin/config/main.c | 2 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index ceee035..28d4f8a 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -626,7 +626,7 @@ remember(const char *file) else s = ns(file); - if (index(s, '_') && strncmp(s, "opt_", 4) != 0) { + if (strchr(s, '_') && strncmp(s, "opt_", 4) != 0) { free(s); return; } diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 9ae52af..4cbc135 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -206,12 +206,12 @@ makehints(void) err(1, "%s", hint->hint_name); while (fgets(line, BUFSIZ, ifp) != 0) { /* zap trailing CR and/or LF */ - while ((s = rindex(line, '\n')) != NULL) + while ((s = strrchr(line, '\n')) != NULL) *s = '\0'; - while ((s = rindex(line, '\r')) != NULL) + while ((s = strrchr(line, '\r')) != NULL) *s = '\0'; /* remove # comments */ - s = index(line, '#'); + s = strchr(line, '#'); if (s) *s = '\0'; /* remove any whitespace and " characters */ @@ -268,12 +268,12 @@ makeenv(void) if (ifp) { while (fgets(line, BUFSIZ, ifp) != 0) { /* zap trailing CR and/or LF */ - while ((s = rindex(line, '\n')) != NULL) + while ((s = strrchr(line, '\n')) != NULL) *s = '\0'; - while ((s = rindex(line, '\r')) != NULL) + while ((s = strrchr(line, '\r')) != NULL) *s = '\0'; /* remove # comments */ - s = index(line, '#'); + s = strchr(line, '#'); if (s) *s = '\0'; /* remove any whitespace and " characters */ @@ -689,7 +689,7 @@ tail(char *fn) { char *cp; - cp = rindex(fn, '/'); + cp = strrchr(fn, '/'); if (cp == 0) return (fn); return (cp+1); |