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. --- sbin/ipfw/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sbin/ipfw/main.c') diff --git a/sbin/ipfw/main.c b/sbin/ipfw/main.c index 337d545..debed4e 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); -- cgit v1.1