diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-10-04 07:30:05 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-10-04 07:30:05 +0000 |
commit | fbda91b119b7673a4d448f0dce31766eaa65112e (patch) | |
tree | 432f48a3043ee1216216e6b93547017b954cde9c /sysdeps/generic/memrchr.c | |
parent | ba60c6d921580bd4b1adf24506bcebfd8efdea34 (diff) | |
download | glibc-fbda91b119b7673a4d448f0dce31766eaa65112e.tar glibc-fbda91b119b7673a4d448f0dce31766eaa65112e.tar.gz glibc-fbda91b119b7673a4d448f0dce31766eaa65112e.tar.bz2 glibc-fbda91b119b7673a4d448f0dce31766eaa65112e.zip |
Update.
1999-10-04 Ulrich Drepper <drepper@cygnus.com>
* include/string.h: Add __memrchr declaration.
* string/string.h: Moce __memrchr declaration to include/string.h.
1999-10-03 Ulrich Drepper <drepper@cygnus.com>
* string/Makefile (routines): Add memrchr.
* sysdeps/generic/memrchr.c: Don't undef memchr, undef memrchr.
Correct order of tests for matching bytes.
* string/tester.c: Add tests for memrchr.
* sysdeps/i386/i486/bits/string.h (__memrchr): Correct implementation.
Start from the last character and take decrement not increment
into account for correction in return line. Add memrchr alias.
* sysdeps/i386/bits/string.h: Likewise.
Diffstat (limited to 'sysdeps/generic/memrchr.c')
-rw-r--r-- | sysdeps/generic/memrchr.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/sysdeps/generic/memrchr.c b/sysdeps/generic/memrchr.c index c86625755b..874caf1072 100644 --- a/sysdeps/generic/memrchr.c +++ b/sysdeps/generic/memrchr.c @@ -51,6 +51,8 @@ #include <sys/types.h> +#undef memrchr + /* Search no more than N bytes of S for C. */ __ptr_t @@ -163,24 +165,24 @@ __memrchr (s, c_in, n) const unsigned char *cp = (const unsigned char *) longword_ptr; - if (cp[0] == c) - return (__ptr_t) cp; - if (cp[1] == c) - return (__ptr_t) &cp[1]; - if (cp[2] == c) - return (__ptr_t) &cp[2]; - if (cp[3] == c) - return (__ptr_t) &cp[3]; #if LONG_MAX > 2147483647 - if (cp[4] == c) - return (__ptr_t) &cp[4]; - if (cp[5] == c) - return (__ptr_t) &cp[5]; - if (cp[6] == c) - return (__ptr_t) &cp[6]; if (cp[7] == c) return (__ptr_t) &cp[7]; + if (cp[6] == c) + return (__ptr_t) &cp[6]; + if (cp[5] == c) + return (__ptr_t) &cp[5]; + if (cp[4] == c) + return (__ptr_t) &cp[4]; #endif + if (cp[3] == c) + return (__ptr_t) &cp[3]; + if (cp[2] == c) + return (__ptr_t) &cp[2]; + if (cp[1] == c) + return (__ptr_t) &cp[1]; + if (cp[0] == c) + return (__ptr_t) cp; } n -= sizeof (longword); |