diff options
author | Ed Schouten <ed@FreeBSD.org> | 2012-01-03 18:51:58 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2012-01-03 18:51:58 +0000 |
commit | b3608ae18f1e5598bed81d0a10dd585a5080c40d (patch) | |
tree | b751618c7a82d9c00cab91ea9f611585dbf14d84 /usr.bin/hexdump/parse.c | |
parent | 69ee3e2f52eb8cba6e103cd1de3f91a7ffe1ddc7 (diff) | |
download | src-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 'usr.bin/hexdump/parse.c')
-rw-r--r-- | usr.bin/hexdump/parse.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/hexdump/parse.c b/usr.bin/hexdump/parse.c index b550bd657f3a..0fa24f514084 100644 --- a/usr.bin/hexdump/parse.c +++ b/usr.bin/hexdump/parse.c @@ -58,7 +58,7 @@ addfile(char *name) if ((fp = fopen(name, "r")) == NULL) err(1, "%s", name); while (fgets(buf, sizeof(buf), fp)) { - if (!(p = index(buf, '\n'))) { + if (!(p = strchr(buf, '\n'))) { warnx("line too long"); while ((ch = getchar()) != '\n' && ch != EOF); continue; @@ -167,7 +167,7 @@ size(FS *fs) * skip any special chars -- save precision in * case it's a %s format. */ - while (index(spec + 1, *++fmt)); + while (strchr(spec + 1, *++fmt)); if (*fmt == '.' && isdigit(*++fmt)) { prec = atoi(fmt); while (isdigit(*++fmt)); @@ -243,10 +243,10 @@ rewrite(FS *fs) if (fu->bcnt) { sokay = USEBCNT; /* Skip to conversion character. */ - for (++p1; index(spec, *p1); ++p1); + for (++p1; strchr(spec, *p1); ++p1); } else { /* Skip any special chars, field width. */ - while (index(spec + 1, *++p1)); + while (strchr(spec + 1, *++p1)); if (*p1 == '.' && isdigit(*++p1)) { sokay = USEPREC; prec = atoi(p1); |