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.bin/hexdump | |
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.bin/hexdump')
-rw-r--r-- | usr.bin/hexdump/display.c | 2 | ||||
-rw-r--r-- | usr.bin/hexdump/hexdump.c | 2 | ||||
-rw-r--r-- | usr.bin/hexdump/hexsyntax.c | 2 | ||||
-rw-r--r-- | usr.bin/hexdump/parse.c | 8 |
4 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c index 991509d..a5f2a47 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -220,7 +220,7 @@ bpad(PR *pr) pr->cchar[0] = 's'; pr->cchar[1] = '\0'; for (p1 = pr->fmt; *p1 != '%'; ++p1); - for (p2 = ++p1; *p1 && index(spec, *p1); ++p1); + for (p2 = ++p1; *p1 && strchr(spec, *p1); ++p1); while ((*p2++ = *p1++)); } diff --git a/usr.bin/hexdump/hexdump.c b/usr.bin/hexdump/hexdump.c index c3aaab5..d3c4bb5 100644 --- a/usr.bin/hexdump/hexdump.c +++ b/usr.bin/hexdump/hexdump.c @@ -61,7 +61,7 @@ main(int argc, char *argv[]) (void)setlocale(LC_ALL, ""); - if (!(p = rindex(argv[0], 'o')) || strcmp(p, "od")) + if (!(p = strrchr(argv[0], 'o')) || strcmp(p, "od")) newsyntax(argc, &argv); else oldsyntax(argc, &argv); diff --git a/usr.bin/hexdump/hexsyntax.c b/usr.bin/hexdump/hexsyntax.c index a1b2099..ac1971a 100644 --- a/usr.bin/hexdump/hexsyntax.c +++ b/usr.bin/hexdump/hexsyntax.c @@ -54,7 +54,7 @@ newsyntax(int argc, char ***argvp) char *p, **argv; argv = *argvp; - if ((p = rindex(argv[0], 'h')) != NULL && + if ((p = strrchr(argv[0], 'h')) != NULL && strcmp(p, "hd") == 0) { /* "Canonical" format, implies -C. */ add("\"%08.8_Ax\n\""); diff --git a/usr.bin/hexdump/parse.c b/usr.bin/hexdump/parse.c index b550bd6..0fa24f5 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); |