From b3608ae18f1e5598bed81d0a10dd585a5080c40d Mon Sep 17 00:00:00 2001 From: Ed Schouten 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/tset/map.c | 2 +- usr.bin/tset/term.c | 4 ++-- usr.bin/tset/wrterm.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'usr.bin/tset') diff --git a/usr.bin/tset/map.c b/usr.bin/tset/map.c index 18ee135b785c..8de594fecdd6 100644 --- a/usr.bin/tset/map.c +++ b/usr.bin/tset/map.c @@ -132,7 +132,7 @@ next: if (*arg == ':') { goto badmopt; ++arg; } else { /* Optional baudrate. */ - arg = index(p = arg, ':'); + arg = strchr(p = arg, ':'); if (arg == NULL) goto badmopt; *arg++ = '\0'; diff --git a/usr.bin/tset/term.c b/usr.bin/tset/term.c index 7082e5f2dea0..544e9288bb28 100644 --- a/usr.bin/tset/term.c +++ b/usr.bin/tset/term.c @@ -74,7 +74,7 @@ get_termcap_entry(char *userarg, char **tcapbufp) /* Try ttyname(3); check for dialup or other mapping. */ if ((ttypath = ttyname(STDERR_FILENO))) { - if ((p = rindex(ttypath, '/'))) + if ((p = strrchr(ttypath, '/'))) ++p; else p = ttypath; @@ -146,7 +146,7 @@ askuser(const char *dflt) return (dflt); } - if ((p = index(answer, '\n'))) + if ((p = strchr(answer, '\n'))) *p = '\0'; if (answer[0]) return (answer); diff --git a/usr.bin/tset/wrterm.c b/usr.bin/tset/wrterm.c index e258e16b656c..77751fa30a21 100644 --- a/usr.bin/tset/wrterm.c +++ b/usr.bin/tset/wrterm.c @@ -56,7 +56,7 @@ wrtermcap(char *bp) char *t, *sep; /* Find the end of the terminal names. */ - if ((t = index(bp, ':')) == NULL) + if ((t = strchr(bp, ':')) == NULL) errx(1, "termcap names not colon terminated"); *t++ = '\0'; -- cgit v1.2.3