summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>2003-12-17 02:46:48 +0000
committerjkh <jkh@FreeBSD.org>2003-12-17 02:46:48 +0000
commit88ce59ac21e63f73ab2a6f560eedfd546bed9106 (patch)
tree65cabad01932f2d9252277f1b846fb0e6baa48e7 /lib/libc
parent11972a8bcbd128631ab0f3a8b10da0ef9399c68d (diff)
downloadFreeBSD-src-88ce59ac21e63f73ab2a6f560eedfd546bed9106.zip
FreeBSD-src-88ce59ac21e63f73ab2a6f560eedfd546bed9106.tar.gz
Do comparison using appropriate casting first, as per SUSv3 (search for first
[last] character, not int).
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/string/index.c3
-rw-r--r--lib/libc/string/rindex.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/string/index.c b/lib/libc/string/index.c
index c81f95b..fe523be 100644
--- a/lib/libc/string/index.c
+++ b/lib/libc/string/index.c
@@ -52,8 +52,9 @@ index
#endif
(const char *p, int ch)
{
+ char c = ch;
for (;; ++p) {
- if (*p == ch)
+ if (*p == c)
return ((char *)p);
if (*p == '\0')
return (NULL);
diff --git a/lib/libc/string/rindex.c b/lib/libc/string/rindex.c
index d0be32e..9deeb1f 100644
--- a/lib/libc/string/rindex.c
+++ b/lib/libc/string/rindex.c
@@ -53,9 +53,10 @@ rindex
(const char *p, int ch)
{
char *save;
+ char c = ch;
for (save = NULL;; ++p) {
- if (*p == ch)
+ if (*p == c)
save = (char *)p;
if (*p == '\0')
return (save);
OpenPOWER on IntegriCloud