mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Fix locale memmem namespace (bug 17585).
Locale code, brought in by ISO C functions, calls memmem, which is not an ISO C function. This isn't an ISO C conformance bug, because all mem* names are reserved, but glibc practice is not to rely on that reservation (thus, memmem is only declared in string.h if __USE_GNU even though ISO C would allow it to be declared unconditionally, for example). This patch changes that code to use __memmem. Note: there are uses of memmem elsewhere in glibc that I didn't change, although it may turn out some of those also need to use __memmem. Tested for x86_64 (testsuite, and that disassembly of installed shared libraries is unchanged by this patch). [BZ #17585] * string/memmem.c [!_LIBC] (__memmem): Define to memmem. (memmem): Rename to __memmem and define as weak alias of __memmem. Use libc_hidden_weak. (__memmem): Use libc_hidden_def. * include/string.h (__memmem): Declare. Use libc_hidden_proto. * locale/findlocale.c (valid_locale_name): Use __memmem instead of memmem.
This commit is contained in:
@ -26,6 +26,7 @@
|
||||
|
||||
#ifndef _LIBC
|
||||
# define __builtin_expect(expr, val) (expr)
|
||||
# define __memmem memmem
|
||||
#endif
|
||||
|
||||
#define RETURN_TYPE void *
|
||||
@ -38,8 +39,8 @@
|
||||
if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in
|
||||
HAYSTACK. */
|
||||
void *
|
||||
memmem (const void *haystack_start, size_t haystack_len,
|
||||
const void *needle_start, size_t needle_len)
|
||||
__memmem (const void *haystack_start, size_t haystack_len,
|
||||
const void *needle_start, size_t needle_len)
|
||||
{
|
||||
/* Abstract memory is considered to be an array of 'unsigned char' values,
|
||||
not an array of 'char' values. See ISO C 99 section 6.2.6.1. */
|
||||
@ -73,6 +74,8 @@ memmem (const void *haystack_start, size_t haystack_len,
|
||||
else
|
||||
return two_way_long_needle (haystack, haystack_len, needle, needle_len);
|
||||
}
|
||||
libc_hidden_def (memmem)
|
||||
libc_hidden_def (__memmem)
|
||||
weak_alias (__memmem, memmem)
|
||||
libc_hidden_weak (memmem)
|
||||
|
||||
#undef LONG_NEEDLE_THRESHOLD
|
||||
|
Reference in New Issue
Block a user