aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2012-01-03 18:51:58 +0000
committerEd Schouten <ed@FreeBSD.org>2012-01-03 18:51:58 +0000
commitb3608ae18f1e5598bed81d0a10dd585a5080c40d (patch)
treeb751618c7a82d9c00cab91ea9f611585dbf14d84 /sbin
parent69ee3e2f52eb8cba6e103cd1de3f91a7ffe1ddc7 (diff)
downloadsrc-b3608ae18f1e5598bed81d0a10dd585a5080c40d.tar.gz
src-b3608ae18f1e5598bed81d0a10dd585a5080c40d.zip
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.
Notes
Notes: svn path=/head/; revision=229403
Diffstat (limited to 'sbin')
-rw-r--r--sbin/bsdlabel/bsdlabel.c4
-rw-r--r--sbin/dump/main.c2
-rw-r--r--sbin/fsck_ffs/pass2.c2
-rw-r--r--sbin/ipfw/main.c10
-rw-r--r--sbin/shutdown/shutdown.c2
5 files changed, 10 insertions, 10 deletions
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index 2dcffd0a752b..a7cc2a2d4bd6 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -782,12 +782,12 @@ getasciilabel(FILE *f, struct disklabel *lp)
lp->d_sbsize = 0; /* XXX */
while (fgets(line, sizeof(line) - 1, f)) {
lineno++;
- if ((cp = index(line,'\n')) != 0)
+ if ((cp = strchr(line,'\n')) != 0)
*cp = '\0';
cp = skip(line);
if (cp == NULL)
continue;
- tp = index(cp, ':');
+ tp = strchr(cp, ':');
if (tp == NULL) {
fprintf(stderr, "line %d: syntax error\n", lineno);
errors++;
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index 3e6ed1f1ac52..3ec78fd1de53 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -290,7 +290,7 @@ main(int argc, char *argv[])
tape = strchr(host, ':');
*tape++ = '\0';
#ifdef RDUMP
- if (index(tape, '\n')) {
+ if (strchr(tape, '\n')) {
(void)fprintf(stderr, "invalid characters in tape\n");
exit(X_STARTUP);
}
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
index 5959778e0546..bd9bf97e92c8 100644
--- a/sbin/fsck_ffs/pass2.c
+++ b/sbin/fsck_ffs/pass2.c
@@ -613,7 +613,7 @@ fix_extraneous(struct inoinfo *inp, struct inodesc *idesc)
printf(" (IGNORED)\n");
return (0);
}
- if ((cp = rindex(oldname, '/')) == NULL) {
+ if ((cp = strchr(oldname, '/')) == NULL) {
printf(" (IGNORED)\n");
return (0);
}
diff --git a/sbin/ipfw/main.c b/sbin/ipfw/main.c
index 337d5455f53f..debed4e82116 100644
--- a/sbin/ipfw/main.c
+++ b/sbin/ipfw/main.c
@@ -122,9 +122,9 @@ ipfw_main(int oldac, char **oldav)
break;
if (copy) {
arg[j++] = arg[i];
- copy = !index("," WHITESP, arg[i]);
+ copy = !strchr("," WHITESP, arg[i]);
} else {
- copy = !index(WHITESP, arg[i]);
+ copy = !strchr(WHITESP, arg[i]);
if (copy)
arg[j++] = arg[i];
}
@@ -141,7 +141,7 @@ ipfw_main(int oldac, char **oldav)
* processing, this is just the number of blanks plus 1.
*/
for (i = 0, ac = 1; i < l; i++)
- if (index(WHITESP, arg[i]) != NULL)
+ if (strchr(WHITESP, arg[i]) != NULL)
ac++;
/*
@@ -162,7 +162,7 @@ ipfw_main(int oldac, char **oldav)
*/
av_p = (char *)&av[ac+1];
for (ac = 1, i = j = 0; i < l; i++) {
- if (index(WHITESP, arg[i]) != NULL || i == l-1) {
+ if (strchr(WHITESP, arg[i]) != NULL || i == l-1) {
if (i == l-1)
i++;
bcopy(arg+j, av_p, i-j);
@@ -240,7 +240,7 @@ ipfw_main(int oldac, char **oldav)
" ipfw sysctl -a\n");
return 0;
}
- s = index(av[2], '=');
+ s = strchr(av[2], '=');
if (s == NULL) {
s = !strcmp(av[2], "-a") ? NULL : av[2];
sysctlbyname(s, NULL, NULL, NULL, 0);
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c
index 7bd93a0c0881..6e662a8b6f44 100644
--- a/sbin/shutdown/shutdown.c
+++ b/sbin/shutdown/shutdown.c
@@ -123,7 +123,7 @@ main(int argc, char **argv)
* Test for the special case where the utility is called as
* "poweroff", for which it runs 'shutdown -p now'.
*/
- if ((p = rindex(argv[0], '/')) == NULL)
+ if ((p = strrchr(argv[0], '/')) == NULL)
p = argv[0];
else
++p;