* commit 'cb835cd77c8e60b4a9fb8a54a06d4fd4039ae1b0': string: Fix wrong comparison semantics
This commit is contained in:
commit
6d77a81456
4 changed files with 7 additions and 7 deletions
|
@ -34,7 +34,7 @@ char *
|
|||
index(const char *p, int ch)
|
||||
{
|
||||
for (;; ++p) {
|
||||
if (*p == ch)
|
||||
if (*p == (char) ch)
|
||||
return((char *)p);
|
||||
if (!*p)
|
||||
return((char *)NULL);
|
||||
|
|
|
@ -35,10 +35,10 @@ void *memrchr(const void *s, int c, size_t n)
|
|||
const char* q = p + n;
|
||||
|
||||
while (1) {
|
||||
q--; if (q < p || q[0] == c) break;
|
||||
q--; if (q < p || q[0] == c) break;
|
||||
q--; if (q < p || q[0] == c) break;
|
||||
q--; if (q < p || q[0] == c) break;
|
||||
q--; if (q < p || q[0] == (char) c) break;
|
||||
q--; if (q < p || q[0] == (char) c) break;
|
||||
q--; if (q < p || q[0] == (char) c) break;
|
||||
q--; if (q < p || q[0] == (char) c) break;
|
||||
}
|
||||
if (q >= p)
|
||||
return (void*)q;
|
||||
|
|
|
@ -34,7 +34,7 @@ char *
|
|||
strchr(const char *p, int ch)
|
||||
{
|
||||
for (;; ++p) {
|
||||
if (*p == ch)
|
||||
if (*p == (char) ch)
|
||||
return((char *)p);
|
||||
if (!*p)
|
||||
return((char *)NULL);
|
||||
|
|
|
@ -36,7 +36,7 @@ strrchr(const char *p, int ch)
|
|||
char *save;
|
||||
|
||||
for (save = NULL;; ++p) {
|
||||
if (*p == ch)
|
||||
if (*p == (char) ch)
|
||||
save = (char *)p;
|
||||
if (!*p)
|
||||
return(save);
|
||||
|
|
Loading…
Reference in a new issue