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/compress/compress.c | |
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/compress/compress.c')
-rw-r--r-- | usr.bin/compress/compress.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/compress/compress.c b/usr.bin/compress/compress.c index f73419d..1f458e5 100644 --- a/usr.bin/compress/compress.c +++ b/usr.bin/compress/compress.c @@ -75,7 +75,7 @@ main(int argc, char *argv[]) char *p, newname[MAXPATHLEN]; cat = 0; - if ((p = rindex(argv[0], '/')) == NULL) + if ((p = strrchr(argv[0], '/')) == NULL) p = argv[0]; else ++p; @@ -141,7 +141,7 @@ main(int argc, char *argv[]) compress(*argv, "/dev/stdout", bits); break; } - if ((p = rindex(*argv, '.')) != NULL && + if ((p = strrchr(*argv, '.')) != NULL && !strcmp(p, ".Z")) { cwarnx("%s: name already has trailing .Z", *argv); @@ -164,7 +164,7 @@ main(int argc, char *argv[]) break; } len = strlen(*argv); - if ((p = rindex(*argv, '.')) == NULL || + if ((p = strrchr(*argv, '.')) == NULL || strcmp(p, ".Z")) { if (len > sizeof(newname) - 3) { cwarnx("%s: name too long", *argv); |