mirror of
https://git.musl-libc.org/git/musl
synced 2025-02-23 13:44:11 +03:00

commit 37bb3cce4598c19288628e675eaf1cda6e96958f suppressed the declaration for C++, where it is wrongly interpreted as declaring the function as taking no arguments. with C23 removing non-prototype declarations, that problem is now also relevant to C. the non-prototype declaration for basename originates with commit 06aec8d7152dfb8360cb7ed9b3d7215ca0b0b500, where it was designed to avoid conflicts with programs which declare basename with the GNU signature taking const char *. that change was probably misguided, as it represents not only misaligned expectations with the caller, but also undefined behavior (calling a function that's been declared with the wrong type). we could opt to fix the declaration, but since glibc, with the gratuitously incompatible GNU-basename function, seems to be the only implementation that declares it in string.h, it seems better to just remove the declaration. this provides some warning if applications are being built expecting the GNU behavior but not getting it. if we declared it here, it would only produce a warning if the caller also declares it themselves (rare) or if the caller attempts to pass a const-qualified pointer.
105 lines
2.9 KiB
C++
105 lines
2.9 KiB
C++
#ifndef _STRING_H
|
|
#define _STRING_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <features.h>
|
|
|
|
#if __cplusplus >= 201103L
|
|
#define NULL nullptr
|
|
#elif defined(__cplusplus)
|
|
#define NULL 0L
|
|
#else
|
|
#define NULL ((void*)0)
|
|
#endif
|
|
|
|
#define __NEED_size_t
|
|
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|
|
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
|
|
|| defined(_BSD_SOURCE)
|
|
#define __NEED_locale_t
|
|
#endif
|
|
|
|
#include <bits/alltypes.h>
|
|
|
|
void *memcpy (void *__restrict, const void *__restrict, size_t);
|
|
void *memmove (void *, const void *, size_t);
|
|
void *memset (void *, int, size_t);
|
|
int memcmp (const void *, const void *, size_t);
|
|
void *memchr (const void *, int, size_t);
|
|
|
|
char *strcpy (char *__restrict, const char *__restrict);
|
|
char *strncpy (char *__restrict, const char *__restrict, size_t);
|
|
|
|
char *strcat (char *__restrict, const char *__restrict);
|
|
char *strncat (char *__restrict, const char *__restrict, size_t);
|
|
|
|
int strcmp (const char *, const char *);
|
|
int strncmp (const char *, const char *, size_t);
|
|
|
|
int strcoll (const char *, const char *);
|
|
size_t strxfrm (char *__restrict, const char *__restrict, size_t);
|
|
|
|
char *strchr (const char *, int);
|
|
char *strrchr (const char *, int);
|
|
|
|
size_t strcspn (const char *, const char *);
|
|
size_t strspn (const char *, const char *);
|
|
char *strpbrk (const char *, const char *);
|
|
char *strstr (const char *, const char *);
|
|
char *strtok (char *__restrict, const char *__restrict);
|
|
|
|
size_t strlen (const char *);
|
|
|
|
char *strerror (int);
|
|
|
|
#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
|
|
#include <strings.h>
|
|
#endif
|
|
|
|
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|
|
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
|
|
|| defined(_BSD_SOURCE)
|
|
char *strtok_r (char *__restrict, const char *__restrict, char **__restrict);
|
|
int strerror_r (int, char *, size_t);
|
|
char *stpcpy(char *__restrict, const char *__restrict);
|
|
char *stpncpy(char *__restrict, const char *__restrict, size_t);
|
|
size_t strnlen (const char *, size_t);
|
|
char *strdup (const char *);
|
|
char *strndup (const char *, size_t);
|
|
char *strsignal(int);
|
|
char *strerror_l (int, locale_t);
|
|
int strcoll_l (const char *, const char *, locale_t);
|
|
size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
|
|
void *memmem(const void *, size_t, const void *, size_t);
|
|
#endif
|
|
|
|
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
|
|
|| defined(_BSD_SOURCE)
|
|
void *memccpy (void *__restrict, const void *__restrict, int, size_t);
|
|
#endif
|
|
|
|
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
|
char *strsep(char **, const char *);
|
|
size_t strlcat (char *, const char *, size_t);
|
|
size_t strlcpy (char *, const char *, size_t);
|
|
void explicit_bzero (void *, size_t);
|
|
#endif
|
|
|
|
#ifdef _GNU_SOURCE
|
|
#define strdupa(x) strcpy(alloca(strlen(x)+1),x)
|
|
int strverscmp (const char *, const char *);
|
|
char *strchrnul(const char *, int);
|
|
char *strcasestr(const char *, const char *);
|
|
void *memrchr(const void *, int, size_t);
|
|
void *mempcpy(void *, const void *, size_t);
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|