aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/include/string.h
AgeCommit message (Collapse)AuthorFilesLines
2018-01-17ansification: remove _EXFUN, _EXFUN_NOTHROWYaakov Selkowitz1-52/+52
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _PTRYaakov Selkowitz1-10/+10
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-29ssp: add Object Size Checking for string.hYaakov Selkowitz1-0/+4
The implementation is from NetBSD, with the addition of mempcpy (a GNU extension) for parity with glibc and libssp. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-28Make __nonnull macro compatible with glibcYaakov Selkowitz1-1/+1
This form allows for multiple arguments, e.g. __nonnull((1,2)). Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-08-25Port strnstr.c to newlib.Sichen Zhao1-0/+3
2017-07-07Rename __in and __out in headers to avoid collision with Windows APIsDavid Macek1-9/+9
* string.h: Local variables in expansion of strdupa and strndupa * sys/wait.h: Fields in anonymous union in expansion of __wait_status_to_int
2017-07-05Synchronize <strings.h> with latest FreeBSDSebastian Huber1-28/+4
Include <strings.h> in <string.h> if __BSD_VISIBLE like on FreeBSD. Remove redundant declarations from <string.h>. Make ffsl(), ffsll(), strncasecmp(), strcasecmp_l(), and strncasecmp_l() visible via __BSD_VISIBLE instead of __GNU_VISIBLE. Add fls(), flsl(), and flsll() to <strings.h> if __BSD_VISIBLE. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-06-19string: add strverscmpYaakov Selkowitz1-0/+4
The actual implementation is from musl (MIT license). Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-03-22Rename <sys/_locale.h> to <xlocale.h>Yaakov Selkowitz1-1/+1
The locale_t type is provided by <xlocale.h> on Linux, FreeBSD, and Darwin. While, like on some of those systems, it is automatically included by <locale.h> with the proper feature test macros, its presence under this particular name is still presumed in real-world software. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-08-25Add strerror_l prototype, change str[n]casecmp_l feature testsBrian Inglis1-6/+7
strerror_l prototype was missing. str[n]casecmp_l feature tests in string.h vs. strings.h were transposed.
2016-08-15Add sys/_locale.h header and fix up headersCorinna Vinschen1-3/+2
Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15Implement per-locale string functionsCorinna Vinschen1-0/+13
strcasecmp_l, strcoll_l, strncasecmp_l, strxfrm_l, wcscasecmp_l, wcscoll_l, wcstrncasecmp_l, wcstrxfrm_l, strftime_l. Add missing CHEWOUT_FILES from previous patch. TODO: strfmon_l. Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-04-13Feature test macros overhaul: string.h and strings.h overlapsYaakov Selkowitz1-7/+7
strings.h is the header mandated for these functions in POSIX.1 prior to 2008 (when most of these were removed). The declarations in string.h are only for BSD compatibility. But when both headers are included, avoid duplicate declarations. Also, mark stpcpy and stpncpy as POSIX.1-2008. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-18Add timingsafe_memcmp()Sebastian Huber1-0/+1
This function is used by LibreSSL and OpenSSH and is provided by the OpenBSD libc. * libc/include/string.h (timingsafe_memcmp): Declare. * libc/string/timingsafe_memcmp.c: New file. * libc/string/Makefile.am: Add new file. * libc/string/Makefile.in: Regenerate.
2016-03-18Add timingsafe_bcmp()Sebastian Huber1-0/+1
This function is used by LibreSSL and OpenSSH and is provided by the OpenBSD libc. * libc/include/string.h (timingsafe_bcmp): Declare. * libc/string/timingsafe_bcmp.c: New file. * libc/string/Makefile.am: Add new file. * libc/string/Makefile.in: Regenerate.
2016-03-18Add explicit_bzero()Sebastian Huber1-0/+3
This function is used by LibreSSL and OpenSSH and is provided by the OpenBSD libc. * libc/include/string.h (explicit_bzero): Declare. * libc/string/explicit_bzero.c: New file. * libc/string/Makefile.am: Add new file. * libc/string/Makefile.in: Regenerate.
2016-03-17Feature test macros overhaul: string.hYaakov Selkowitz1-23/+15
Throughout, remove __STRICT_ANSI__ and use the proper internal macros. bcmp, bcopy, bzero, index, and rindex were in POSIX prior to 2008. memrchr is GNU. strdup and strndup are POSIX.1-2008. The int-returning form of strerror_r is POSIX.1-2001. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2015-07-06Rework handling of basename variantsYaakov Selkowitz1-2/+2
As a commonly-included header, the #define basename in <string.h> can affect code which uses "basename" for its own purposes (e.g. struct members or C++ namespaced functions). When such cases occur and some code includes <string.h> and some not, then errors result. OTOH, <libgen.h> is rarely used, and that's where the renaming occurs in glibc, so code using <libgen.h> should already be safe. * libc/include/libgen.h (basename): Define as __xpg_basename for source compatibility with glibc. Declare with __ASMNAME("basename") for ABI compatibility. * libc/include/string.h (basename): Define as basename for source compatibility with glibc. Declare with __ASMNAME("__gnu_basename") for ABI compatibility.
2015-04-23Fix basename prototype collision string.h vs libgen.hCorinna Vinschen1-11/+13
* libc/include/libgen.h (basename): Drop defining _BASENAME_DEFINED. Always define macro basename. Add comment to explain why. * libc/include/string.h (basename): Check for basename instead of _BASENAME_DEFINED. Drop __GNUC__ branch, always use basename macro. Change comment to explain why. Add nonnull function attribute. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23string: add GNU basename(3)Yaakov Selkowitz1-0/+14
* libc/include/libgen.h (_BASENAME_DEFINED): Define. * libc/include/string.h (basename): Declare. * libc/string/Makefile.am (ELIX_4_SOURCES): Add gnu_basename.c. * libc/string/Makefile.in: Regenerate. * libc/string/gnu_basename.c: New file.
2015-02-06 * libc/include/complex.h (cabsl): Add prototype.Nick Clifton1-1/+4
(cimagl): Add prototype. (creall): Add prototype. * libc/include/ieeefp.h: Include float.h. (EXT_EXPBITS, EXT_FRACHBITS, EXT_FRACLBITS) (EXT_EXP_INFNAN. EXT_EXP_BIAS, EXT_FRACBITS): Define. (struct ieee_ext, union ieee_ext_u): New types for long double support. * libc/include/math.h (finitel): Add prototype. (hypotl): Add prototype. (sqrtl): Add prototype. * libm/common/Makefile.am (lsrc): Add sl_finite.c. * libm/common/Makefile.in: Regenerate. * libm/common/fdlibm.h (__ieee754_hypotl): Add prototype. * libm/common/hypotl.c (hypotl): Add implementation for when long double is larger than double. * libm/common/sqrtl.c (sqrtl): Likewise. * libm/common/sl_finite.c: New file. Adds implementation of the finitel function. * libm/complex/Makefile.am (lsrc): Define. (libcomplex_la_SOURCES): Add lsrc. (lib_a_SOURCES): Add lsrc. * libm/complex/Makefile.in: Regenerate. * libm/complex/cabs.c: Add documentation of cabsl function. * libm/complex/cimag.c: Add documentation of cimagl function. * libm/complex/creall.c: Add documentation of creall function. * libm/complex/cabsl.c: New file. Adds implementation of the cabsl function. * libm/complex/cimagl.c: New file. Adds implementation of the cimagl function. * libm/complex/creall.c: New file. Adds implementation of the creall function. * libm/math/Makefile.am (lsrc): Define. (libmath_la_SOURCES): Add lsrc. (lib_a_SOURCES): Add lsrc. * libm/math/Makefile.in: Regenerate. * libm/math/el_hypot.c: New file. Adds implementation of the __ieee754_hypotl function.
2014-10-302014-10-29 Jon Turney <jon.turney@dronecode.org.uk>Jon TURNEY1-1/+1
* libc/include/string.h: Correct guard for strcasecmp().
2014-10-08 * libc/include/string.h (ffsl): Declare as GNU function.Corinna Vinschen1-0/+5
(ffsll): Ditto.
2014-09-162014-09-17 Joel Sherrill <joel.sherrill@oarcorp.com>Jeff Johnston1-1/+2
Thomas Uhle <thomas.uhle@eas.iis.fraunhofer.de> * libc/include/string.h: Correct guard for strnlen().
2014-08-182014-08-18 Joel Sherrill <joel.sherrill@oarcorp.com>Joel Sherrill1-34/+51
* libc/include/string.h: Improve language and OS standard guards.
2013-07-23 * libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c,Corinna Vinschen1-11/+11
libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo() and getaddrinfo() to increase standards compliance and match glibc. * libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c, libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c, libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c, libc/string/strtok_r.c, libc/string/strxfrm.c libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c, libc/machine/cris/memcpy.c: Add __restrict to prototype to increase standards compliance.
2013-06-24* libc/include/string.h (rawmemchr): Declare.Yaakov Selkowitz1-0/+1
* libc/string/Makefile.am (ELIX_4_SOURCES): Add rawmemchr.c. (CHEWOUT_FILES): Add rawmemchr.def. * libc/string/Makefile.in: Regenerate. * libc/string/rawmemchr.c: New file.
2013-01-12 * libc/include/string.h: Fix preprocessor expressions usingCorinna Vinschen1-2/+2
_XOPEN_SOURCE.
2012-11-01 * libc/include/locale.h (NULL): Fetch definition via stddef.h.Corinna Vinschen1-4/+1
* libc/include/stdio.h (NULL): Ditto. * libc/include/stdlib.h (NULL): Ditto. * libc/include/string.h (NULL): Ditto. * libc/include/wchar.h (NULL): Ditto. * libc/include/rpc/types.h (NULL): Ditto. * libc/include/time.h (NULL): Ditto. Include stddef.h earlier.
2012-10-22 * libc/include/string.h (strdup, strndup): Declare if notCorinna Vinschen1-0/+9
__STRICT_ANSI__ or _XOPEN_SOURCE is defined appropriately.
2012-05-10 * libc/include/string.h (memrchr): Declare.Corinna Vinschen1-0/+1
* libc/string/Makefile.am (ELIX_4_SOURCES): Add memrchr.c. (CHEWOUT_FILES): Add memrchr.def. * libc/string/Makefile.in: Regenerate. * libc/string/memrchr.c: New file.
2011-06-102011-06-09 Yaakov Selkowitz <yselkowitz@...>Jeff Johnston1-0/+14
* libc/include/string.h (strdupa): New macro function. (strndupa): New macro function.
2011-05-25strerror: allow user hook to comply with POSIX rulesEric Blake1-0/+3
* libc/string/strerror.c (strerror): Split body into... (_strerror_r): ...new reentrant function. * libc/string/u_strerr.c (_user_strerror): Update signature. * libc/include/stdio.h (_strerror_r): New prototype. * libc/posix/collate.c (__collate_err): Adjust callers. * libc/stdio/perror.c (_perror_r): Likewise. * libc/string/strerror_r.c (strerror_r): Likewise. * libc/string/xpg_strerror_r.c (__xpg_strerror_r): Likewise.
2011-03-28 * libc/include/string.h (strchrnul): Declare.Corinna Vinschen1-0/+1
* libc/string/strchrnul.c: New file. * libc/string/Makefile.am (ELIX_2_SOURCES): Add strchrnul.c. * libc/string/Makefile.in: Regenerate.
2011-03-03 * libc/include/string.h: Include sys/cdefs.h.Corinna Vinschen1-0/+1
2011-03-03 * libc/include/sys/cdefs.h (__CONCAT1): Define.Corinna Vinschen1-1/+1
(__CONCAT): Define. (__STRING): Define. (__XSTRING): Define. (__ASMNAME): Define. * libc/include/string.h (strerror_r): Use __ASMNAME to take target specific label prefixes into account.
2011-02-10strerror_r: provide POSIX implementationEric Blake1-1/+14
* libc/include/string.h (strerror_r): Update declaration. * libc/string/strerror.c (strerror): Update documentation. * libc/string/strerror_r.c (strerror_r): Always return NUL-terminated string; don't overwrite too-short buf. * libc/string/xpg_strerror_r.c (__xpg_strerror_r): Implement POSIX variant. * libc/string/Makefile.am (GENERAL_SOURCES): Build new file. * libc/string/Makefile.in: Regenerate.
2011-01-10 * libc/include/string.h: Make strsignal() available unconditionally.Corinna Vinschen1-1/+1
2008-06-18Per Posix, strsignal returns non-const char*.Eric Blake1-1/+1
* libc/include/string.h (strsignal): Fix return type.
2008-01-12Make strstr and strcasestr O(n), not O(n^2); add memmem.Eric Blake1-3/+1
* libc/string/str-two-way.h: New file. * libc/string/memmem.c (memmem): New file. * libc/include/string.h (memmem): Declare for all platforms. * libc/string/strstr.c (strstr): Provide O(n) implementation when not optimizing for space. * libc/string/strcasestr.c (strcasestr): Likewise. * libc/string/Makefile.am (ELIX_SOURCES): Rename to... (ELIX_2_SOURCES): ...this. (ELIX_4_SOURCES): New category, for memmem. (lib_a_SOURCES, libstring_la_SOURCES): Build new file. (CHEWOUT_FILES): Build documentation for memmem. * libc/string/strings.tex: Include new docs.
2007-06-28 * libc/include/string.h: Add prototypes for stpcpy and stpncpy.Corinna Vinschen1-0/+2
* libc/string/Makefile.am (ELIX_SOURCES): Add stpcpy.c and stpncpy.c. (CHEWOUT_FILES): Add stpcpy.def and stpncpy.def. * libc/string/Makefile.in: Regenerate. * libc/string/stpcpy.c: New file. * libc/string/stpncpy.c: New file. * libc/string/strings.tex: Add stpcpy and stpncpy.
2007-06-082007-06-08 Jeff Johnston <jjohnstn@redhat.com>Jeff Johnston1-0/+1
* libc/string/strcasestr.c: New file. * libc/include/string.h: Add strcasestr. * libc/string/strings.tex: Add strcasestr. * libc/string/Makefile.am: Ditto. * libc/string/Makefile.in: Regenerated.
2005-11-08* libc/include/string.h: Add cygwin-specific function declaration.Christopher Faylor1-0/+3
2005-08-26* libc/include/string.h: Revert previous change.Christopher Faylor1-4/+0
2005-08-25* libc/include/string.h: For Cygwin, Define strerror_r as per ISO C.Christopher Faylor1-0/+4
2005-01-242005-01-24 Jeff Johnston <jjohnstn@redhat.com>Jeff Johnston1-2/+2
* libc/include/string.h: Remove Linux-specific declaration of strsignal and add #include <sys/string.h>. * libc/include/sys/string.h: New file. * libc/include/sys/linux/sys/string.h: New file with strsignal declaration deleted above.
2002-07-232002-07-23 Jeff Johnston <jjohnstn@redhat.com>Jeff Johnston1-0/+3
* libc/include/string.h: Add mempcpy, strndup, and _strndup_r prototypes. * libc/stdlib/Makefile.am: Remove strdup.c and strdup_r.c. * libc/stdlib/Makefile.in: Regenerated. * libc/stdlib/strdup.c: Removed. * libc/stdlib/strdup_r.c: Removed. * libc/string/Makefile.am: Add strdup.c, strdup_r.c, memccpy.c, mempcpy.c, strndup.c, and strndup_r.c. * libc/string/Makefile.in: Regenerated. * libc/string/memccpy.c: New file. * libc/string/mempcpy.c: Ditto. * libc/string/strndup.c: Ditto. * libc/string/strndup_r.c: Ditto. * libc/string/strdup.c: New file moved from stdlib. * libc/string/strdup_r.c: Ditto. * libc/string/strings.tex: Add memccpy and mempcpy documentation.
2002-06-272002-06-27 Benjamin Kosnik <bkoz@redhat.com>Jeff Johnston1-7/+4
* libc/include/stdio.h: Untangle, add _BEGIN_STD_C and _END_STD_C. * libc/include/time.h: Same. * libc/include/string.h: Same. * libc/include/stdlib.h: Same. * libc/include/signal.h: Same. * libc/include/setjmp.h: Same. * libc/include/math.h: Same. * libc/include/locale.h: Same. * libc/include/ctype.h: Same. * libc/include/machine/setjmp.h: Same. * libc/include/_ansi.h (_BEGIN_STD_C): Add. (_END_STD_C): Add.
2002-06-052002-06-05 Jeff Johnston <jjohnstn@redhat.com>Jeff Johnston1-0/+2
* libc/include/string.h[__linux__]: Add strsignal prototype. * libc/include/sys/lock.h: New file with default locking support. * libc/include/sys/reent.h: Add signal buffer support for strsignal and psignal. * libc/posix/Makefile.am: Add support for readdir_r.c. * libc/posix/Makefile.in: Regenerated. * libc/posix/closedir.c: Add locking support and hash table cleanup. * libc/posix/opendir.c: Add lock support. * libc/posix/readdir.c: Ditto. * libc/posix/rewinddir.c: Ditto. * libc/posix/scandir.c: Ditto. * libc/posix/seekdir.c: Ditto. * libc/posix/telldir.c: Ditto plus add _cleanupdir routine to clean up leftover hash table entries. * libc/posix/readdir_r.c: New file. * libc/sys/linux/Makefile.am: Add psignal.c and strsignal.c support. * libc/sys/linux/Makefile.in: Regenerated. * libc/sys/linux/sys/dirent.h: Add dd_lock to DIR structure. * libc/sys/linux/sys/signal.h: Add psignal prototype. * libc/sys/linux/psignal.c: New file. * libc/sys/linux/strsignal.c: Ditto.
2002-05-242002-05-24 Jeff Johnston <jjohnstn@redhat.com>Jeff Johnston1-0/+2
* libc/include/string.h: Add strnlen and strerror_r prototypes. * libc/string/Makefile.am: Add strnlen.c and strerror_r.c support. * libc/string/Makefile.in: Regenerated. * libc/string/strerror_r.c: New file. * libc/string/strnlen.c: New file. * libc/sys/linux/Makefile.am: Add rename.c. * libc/sys/linux/Makefile.in: Regenerated. * libc/sys/linux/rename.c: New file to override default rename.