summaryrefslogtreecommitdiff
path: root/lib/libc/string
Commit message (Collapse)AuthorAgeFilesLines
* MFC: 325765 (imp) Add notes about overlapping copies.Rodney W. Grimes2019-01-223-0/+25
| | | | | | | | | | | | | | Add notes to each of these that specifically state that results are undefined if the strings overlap. In the case of memcpy, we document the overlapping behavior on FreeBSD (pre-existing). For str*, it is left unspecified, however, since the default (and x86) implementations do not handle overlapping strings properly. PR: 223653 Approved by: phk (mentor) Notes: svn path=/stable/10/; revision=343326
* MFC r283584:Enji Cooper2017-02-092-11/+17
| | | | | | | | | | | | | | | | | Relnotes: yes r283584 (by emaste): memmem(3): empty little string matches the beginning of the big string This function originated in glibc, and this matches their behaviour (and NetBSD, OpenBSD, and musl). An empty big string (arg "l") is handled by the existing l_len < s_len test. Notes: svn path=/stable/10/; revision=313480
* MFC r294597:Warren Block2016-02-061-1/+6
| | | | | | | | | Add a standards compliance note for strtok_r Approved by: re (marius@) Notes: svn path=/stable/10/; revision=295350
* MFC r293856:Brooks Davis2016-01-201-1/+1
| | | | | | | | | | | | | | Avoid reading pass the end of the source buffer when it is not NUL terminated. If this buffer is adjacent to an unmapped page or a version of C with bounds checked is used this may result in a crash. PR: 206178 Submitted by: Alexander Cherepanov <cherepan@mccme.ru> Notes: svn path=/stable/10/; revision=294455
* MFC r293855:Brooks Davis2016-01-201-1/+1
| | | | | | | | | | | | | | Avoid reading pass the end of the source buffer when it is not NUL terminated. If this buffer is adjacent to an unmapped page or a version of C with bounds checked is used this may result in a crash. PR: 206177 Submitted by: Alexander Cherepanov <cherepan@mccme.ru> Notes: svn path=/stable/10/; revision=294453
* MFC: r266671, r266725:Allan Jude2015-04-163-98/+38
| | | | | | | | | | Merge strcspn.3 into strspn.3 and clarify the explaination Approved by: eadler (mentor, implicit) Sponsored by: ScaleEngine Inc. Notes: svn path=/stable/10/; revision=281570
* MFC r266865;Pedro F. Giffuni2014-06-141-2/+2
| | | | | | | | | | | | | | | | | | | Fix strcasecmp_l() and strncasecmp_l() POSIX 2008 compliance. POSIX.1-2008 specifies that those two functions should be declared by including <strings.h>, not <string.h> (the latter only has strcoll_l() and strxfrm_l()): http://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html Bump __FreeBSD_version for ports that may be using the non-standard reference. Obtained from: DragonFlyBSD Reviewed by: theraven Notes: svn path=/stable/10/; revision=267465
* MFC r262890:Eitan Adler2014-03-102-6/+0
| | | | | | | | libc man pages: Remove reference to non-existent FreeBSD Security Architecture Notes: svn path=/stable/10/; revision=262965
* libc: Always use our own copy of sys_errlist and sys_nerr (.so only).Jilles Tjoelker2013-08-311-3/+5
| | | | | | | | | | | | | | | | | | This ensures strerror() and friends continue to work correctly even if a (non-PIE) executable linked against an older libc imports sys_errlist (which causes sys_errlist to refer to the executable's copy with a size fixed when that executable was linked). The executable's use of sys_errlist remains broken because it uses the current value of sys_nerr and may access past the bounds of the array. Different from the message "Using sys_errlist from executables is not ABI-stable" on freebsd-arch, this change does not affect the static library. There seems no reason to prevent overriding the error messages in the static library. Notes: svn path=/head/; revision=255108
* Renumber clauses to reduce diffs to other versionsEd Maste2013-05-2873-73/+73
| | | | | | | | NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3, so follow suit to make comparison easier. Notes: svn path=/head/; revision=251069
* Create a symlink from strchrnul.3 to strchr.3.Niclas Zeising2013-03-061-1/+2
| | | | | | | | | This was forgotten in the initial commit of strchrnul() Approved by: theraven Notes: svn path=/head/; revision=247899
* Add strchrnul(), a GNU function similar to strchr(), except that it returnsNiclas Zeising2013-02-134-5/+81
| | | | | | | | | | a pointer to the end of the string, rather than NULL, if the character was not found. Approved by: theraven Notes: svn path=/head/; revision=246766
* clarify the wording for 'first' and 'last'Eitan Adler2012-09-301-5/+4
| | | | | | | | Approved by: wblock MFC after: 3 days Notes: svn path=/head/; revision=241062
* strsignal(): Reindent.Jilles Tjoelker2012-09-191-21/+21
| | | | Notes: svn path=/head/; revision=240705
* strsignal(): Do not append signal numbers to messages for known signals.Jilles Tjoelker2012-09-191-1/+1
| | | | | | | | Messages for known signals looked like "Terminated: 15" instead of "Terminated". Notes: svn path=/head/; revision=240704
* Correct BUGS description of static buffer useEd Maste2012-07-271-3/+3
| | | | | | | | | | Since r142667 strerror has unconditionally returned a pointer to a static buffer. MFC after: 1 week Notes: svn path=/head/; revision=238853
* Add the functions documented in the man pages in commit 237393 to theIsabell Long2012-06-211-2/+7
| | | | | | | | | | | relevant Makefile. Reminded by: gavin Approved by: gabor (mentor) MFC after: 5 days Notes: svn path=/head/; revision=237409
* Add more locale-specific functions to the relevant man pages:Isabell Long2012-06-214-7/+54
| | | | | | | | | | | | | | - libc/string/strcoll.3 - libc/string/strstr.3 - libc/string/strxfrm.3 - libc/string/strcasecmp.3 Reviewed by: theraven, gabor Approved by: gabor (mentor) MFC after: 5 days Notes: svn path=/head/; revision=237393
* General mdoc(7) and typo fixes.Glen Barber2012-05-111-1/+1
| | | | | | | | | PR: 167734 Submitted by: Nobuyuki Koganemaru (kogane!jp.freebsd.org) MFC after: 3 days Notes: svn path=/head/; revision=235286
* Remove trailing whitespace per mdoc lint warningEitan Adler2012-03-291-1/+1
| | | | | | | | | | Disussed with: gavin No objection from: doc Approved by: joel MFC after: 3 days Notes: svn path=/head/; revision=233648
* Fix indentation.Konstantin Belousov2012-03-141-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=232973
* POSIX mandates that swab do nothing when len < 0Eitan Adler2012-03-042-1/+6
| | | | | | | | | | PR: kern/140690 Submitted by: Jeremy Huddleston <jeremyhu@apple.com> Approved by: cperciva MFC after: 2 weeks Notes: svn path=/head/; revision=232503
* Add err(3) to strerror(3) SEE ALSO sectionEitan Adler2012-02-161-0/+1
| | | | | | | | | | PR: docs/164940 Submitted by: Niclas Zeising <zeising@daemonic.se> Approved by: cperciva MFC after: 3 days Notes: svn path=/head/; revision=231813
* Change index() and rindex() to a weak alias.Ed Schouten2012-01-052-2/+2
| | | | | | | | | | | This allows people to still write statically linked applications that call strchr() or strrchr() and have a local variable or function called index. Discussed with: bde@ Notes: svn path=/head/; revision=229571
* Merge index() and strchr() together.Ed Schouten2012-01-035-129/+105
| | | | | | | | | | | | | | | | | | | | As I looked through the C library, I noticed the FreeBSD MIPS port has a hand-written version of index(). This is nice, if it weren't for the fact that most applications call strchr() instead. Also, on the other architectures index() and strchr() are identical, meaning we have two identical pieces of code in the C library and statically linked applications. Solve this by naming the actual file strchr.[cS] and let it use __strong_reference()/STRONG_ALIAS() to provide the index() routine. Do the same for rindex()/strrchr(). This seems to make the C libraries and static binaries slightly smaller, but this reduction in size seems negligible. Notes: svn path=/head/; revision=229368
* Revert r227812 and r227808 per discussionEitan Adler2011-12-024-30/+18
| | | | | | | | Reviewed by: many Approved by: des Notes: svn path=/head/; revision=228202
* - fix some style(9) nits with my last commitEitan Adler2011-11-222-3/+5
| | | | | | | | | | - add a comment explaining why I used '|' instead of '||' Submitted by: danfe@ Approved by: emaste@ Notes: svn path=/head/; revision=227812
* - add check for pointer equality prior to performing the O(n) passEitan Adler2011-11-224-18/+28
| | | | | | | | | | | | - while here change 's' to 's1' in strcoll Submitted by: eadler@ Reviewed by: theraven@ Approved by: brooks@ MFC after: 2 weeks Notes: svn path=/head/; revision=227808
* (Hopefully) Fix the build with clang by removing a typedef that's no longer ↵David Chisnall2011-11-211-2/+0
| | | | | | | | | needed. Approved by: brooks (mentor) Notes: svn path=/head/; revision=227807
* Implement xlocale APIs from Darwin, mainly for use by libc++. This adds aDavid Chisnall2011-11-208-29/+140
| | | | | | | | | | | | | | | load of _l suffixed versions of various standard library functions that use the global locale, making them take an explicit locale parameter. Also adds support for per-thread locales. This work was funded by the FreeBSD Foundation. Please test any code you have that uses the C standard locale functions! Reviewed by: das (gdtoa changes) Approved by: dim (mentor) Notes: svn path=/head/; revision=227753
* Fix prototype for ffsll(3) and fls(3).Xin LI2011-05-031-2/+2
| | | | | | | | | PR: docs/156796 Submitted by: Jean-Yves Migeon <jeanyves.migeon free.fr> MFC after: 3 days Notes: svn path=/head/; revision=221401
* Allow strerror(0) and strerror_r(0, ...).Jilles Tjoelker2011-04-052-2/+5
| | | | | | | | | | | | | | | | Of course, strerror_r() may still fail with ERANGE. Although the POSIX specification said this could fail with EINVAL and doing this likely indicates invalid use of errno, most other implementations permitted it, various POSIX testsuites require it to work (matching the older sys_errlist array) and apparently some applications depend on it. PR: standards/151316 MFC after: 1 week Notes: svn path=/head/; revision=220376
* index(3): Mention that index/rindex are deprecated and not specified byJilles Tjoelker2011-03-201-1/+14
| | | | | | | | | POSIX.1-2008. MFC after: 1 week Notes: svn path=/head/; revision=219803
* Powerpc is special here. powerpc and powerpc64 use different ABIs, soWarner Losh2010-08-241-4/+2
| | | | | | | | | their implementations aren't in the same files. Introduce LIBC_ARCH and use that in preference to MACHINE_CPUARCH. Tested by amd64 and powerpc64 builds (thanks nathanw@) Notes: svn path=/head/; revision=211774
* MFtbemd:Warner Losh2010-08-231-3/+3
| | | | | | | | Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want to test of all the CPUs of a given family conform. Notes: svn path=/head/; revision=211725
* mdoc: move CAVEATS, BUGS and SECURITY CONSIDERATIONS sections to theUlrich Spörlein2010-05-132-27/+27
| | | | | | | | | | | | | | bottom of the manpages and order them consistently. GNU groff doesn't care about the ordering, and doesn't even mention CAVEATS and SECURITY CONSIDERATIONS as common sections and where to put them. Found by: mdocml lint run Reviewed by: ru Notes: svn path=/head/; revision=208027
* Correct bugs fixed but not merged from my own tree.Xin LI2010-03-131-2/+3
| | | | | | | | Pointy hat to: delphij MFC after: 1 month Notes: svn path=/head/; revision=205108
* Follow up commit to reindent the code.Xin LI2010-03-121-13/+13
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=205100
* Two optimizations to MI strlen(3) inspired by David S. Miller'sXin LI2010-03-121-12/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | blog posting [1]. - Use word-sized test for unaligned pointer before working the hard way. Memory page boundary is always integral multiple of a word alignment boundary. Therefore, if we can access memory referenced by pointer p, then (p & ~word mask) must be also accessible. - Better utilization of multi-issue processor's ability of concurrency. The previous implementation utilized a formular that must be executed sequentially. However, the ~, & and - operations can actually be caculated at the same time when the operand were different and unrelated. The original Hacker's Delight formular also offered consistent performance regardless whether the input would contain characters with their highest-bit set, as it catches real nul characters only. These two optimizations has shown further improvements over the previous implementation on microbenchmarks on i386 and amd64 CPU including Pentium 4, Core Duo 2 and i7. [1] http://vger.kernel.org/~davem/cgi-bin/blog.cgi/2010/03/08#strlen_1 MFC after: 1 month Notes: svn path=/head/; revision=205099
* Mark up "unsigned char".Ruslan Ermilov2010-02-044-4/+11
| | | | Notes: svn path=/head/; revision=203485
* Implement strndup(3) using strnlen(3).Ed Schouten2010-02-021-3/+1
| | | | | | | | This makes the implementation a bit more consistent with strdup(3), which uses strlen(3). Notes: svn path=/head/; revision=203391
* Make strsignal(3) thread-safe.Hajimu UMEMOTO2010-01-241-4/+48
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=202916
* Add a missing word to a sentence in the return values section.Tom Rhodes2009-12-041-1/+1
| | | | Notes: svn path=/head/; revision=200095
* Add an .Nm for strncat.Christian Brueffer2009-12-011-2/+3
| | | | | | | | | PR: 141037 Submitted by: Jeremy Huddleston <jeremyhu@apple.com> MFC after: 3 days Notes: svn path=/head/; revision=199988
* Correct the information about when the respective functionality firstChristian Brueffer2009-04-231-1/+1
| | | | | | | | | | | appeared in FreeBSD. PR: 133785 Submitted by: Ulrich Spoerlein <uqs@spoerlein.net> MFC after: 3 days Notes: svn path=/head/; revision=191414
* There is no way for strmode(3) to append '+' if the file has ACL,Edward Tomasz Napierala2009-04-142-4/+2
| | | | | | | | because there is no way to figure that out based on the file mode itself. Make the manual page match reality. Notes: svn path=/head/; revision=191055
* Add wide character variants of string manipulations routines to 'SEE ALSO'.Edward Tomasz Napierala2009-04-0716-16/+33
| | | | | | | Approved by: rwatson (mentor) Notes: svn path=/head/; revision=190798
* 7.2 will be the first release where strndup() appears.Konstantin Belousov2009-03-221-1/+1
| | | | | | | | Submitted by: Florian Smeets <flo kasimir com> MFC after: 3 days Notes: svn path=/head/; revision=190266
* Add wcpcpy(3) and wcpncpy(3).David Schultz2009-03-045-3/+108
| | | | Notes: svn path=/head/; revision=189361
* Add restrict qualifiers.David Schultz2009-02-281-1/+1
| | | | | | | I missed this file in my previous commit. Notes: svn path=/head/; revision=189137