am cb835cd7: am cb1df916: string: Fix wrong comparison semantics

* commit 'cb835cd77c8e60b4a9fb8a54a06d4fd4039ae1b0':
  string: Fix wrong comparison semantics
This commit is contained in:
Bruce Beare 2011-12-05 22:13:21 -08:00 committed by Android Git Automerger
commit 6d77a81456
4 changed files with 7 additions and 7 deletions

View file

@ -34,7 +34,7 @@ char *
index(const char *p, int ch) index(const char *p, int ch)
{ {
for (;; ++p) { for (;; ++p) {
if (*p == ch) if (*p == (char) ch)
return((char *)p); return((char *)p);
if (!*p) if (!*p)
return((char *)NULL); return((char *)NULL);

View file

@ -35,10 +35,10 @@ void *memrchr(const void *s, int c, size_t n)
const char* q = p + n; const char* q = p + n;
while (1) { while (1) {
q--; if (q < p || q[0] == c) break; q--; if (q < p || q[0] == (char) 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] == c) break; q--; if (q < p || q[0] == (char) c) break;
q--; if (q < p || q[0] == c) break; q--; if (q < p || q[0] == (char) c) break;
} }
if (q >= p) if (q >= p)
return (void*)q; return (void*)q;

View file

@ -34,7 +34,7 @@ char *
strchr(const char *p, int ch) strchr(const char *p, int ch)
{ {
for (;; ++p) { for (;; ++p) {
if (*p == ch) if (*p == (char) ch)
return((char *)p); return((char *)p);
if (!*p) if (!*p)
return((char *)NULL); return((char *)NULL);

View file

@ -36,7 +36,7 @@ strrchr(const char *p, int ch)
char *save; char *save;
for (save = NULL;; ++p) { for (save = NULL;; ++p) {
if (*p == ch) if (*p == (char) ch)
save = (char *)p; save = (char *)p;
if (!*p) if (!*p)
return(save); return(save);