Commit Graph

291 Commits

Author SHA1 Message Date
Niclas Zeising
0e7919f704 Create a symlink from strchrnul.3 to strchr.3.
This was forgotten in the initial commit of strchrnul()

Approved by:	theraven
2013-03-06 19:59:42 +00:00
Niclas Zeising
d902844bbd Add strchrnul(), a GNU function similar to strchr(), except that it returns
a pointer to the end of the string, rather than NULL, if the character was
not found.

Approved by:	theraven
2013-02-13 15:46:33 +00:00
Eitan Adler
a181e90d14 clarify the wording for 'first' and 'last'
Approved by:	wblock
MFC after:	3 days
2012-09-30 03:25:04 +00:00
Jilles Tjoelker
1ceeb358f2 strsignal(): Reindent. 2012-09-19 19:22:24 +00:00
Jilles Tjoelker
b8d472d710 strsignal(): Do not append signal numbers to messages for known signals.
Messages for known signals looked like "Terminated: 15" instead of
"Terminated".
2012-09-19 19:21:22 +00:00
Ed Maste
cb75848307 Correct BUGS description of static buffer use
Since r142667 strerror has unconditionally returned a pointer to a
static buffer.

MFC after:	1 week
2012-07-27 21:38:14 +00:00
Isabell Long
93af1bc413 Add the functions documented in the man pages in commit 237393 to the
relevant Makefile.

Reminded by:	gavin
Approved by:	gabor (mentor)
MFC after:	5 days
2012-06-21 18:28:48 +00:00
Isabell Long
db356f0370 Add more locale-specific functions to the relevant man pages:
- 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
2012-06-21 12:52:15 +00:00
Glen Barber
a3fb6da9ba General mdoc(7) and typo fixes.
PR:		167734
Submitted by:	Nobuyuki Koganemaru (kogane!jp.freebsd.org)
MFC after:	3 days
2012-05-11 20:06:46 +00:00
Eitan Adler
50d675f7a9 Remove trailing whitespace per mdoc lint warning
Disussed with:	gavin
No objection from:	doc
Approved by:	joel
MFC after:	3 days
2012-03-29 05:02:12 +00:00
Konstantin Belousov
a9e7383c18 Fix indentation.
MFC after:	3 days
2012-03-14 15:30:59 +00:00
Eitan Adler
0a0c8e010d POSIX mandates that swab do nothing when len < 0
PR:		kern/140690
Submitted by:	Jeremy Huddleston <jeremyhu@apple.com>
Approved by:	cperciva
MFC after:	2 weeks
2012-03-04 16:39:08 +00:00
Eitan Adler
9d4261b795 Add err(3) to strerror(3) SEE ALSO section
PR:		docs/164940
Submitted by:	Niclas Zeising <zeising@daemonic.se>
Approved by:	cperciva
MFC after:	3 days
2012-02-16 05:06:07 +00:00
Ed Schouten
19c262fe87 Change index() and rindex() to a weak alias.
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@
2012-01-05 10:32:53 +00:00
Ed Schouten
46632c18bd Merge index() and strchr() together.
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.
2012-01-03 07:14:01 +00:00
Eitan Adler
0f701093d2 Revert r227812 and r227808 per discussion
Reviewed by:	many
Approved by:	des
2011-12-02 15:41:09 +00:00
Eitan Adler
623b87d8f4 - fix some style(9) nits with my last commit
- add a comment explaining why I used '|' instead of '||'

Submitted by:	danfe@
Approved by:	emaste@
2011-11-22 02:50:24 +00:00
Eitan Adler
55e84fcee1 - add check for pointer equality prior to performing the O(n) pass
- while here change 's' to 's1' in strcoll

Submitted by:	eadler@
Reviewed by:	theraven@
Approved by:	brooks@
MFC after:	2 weeks
2011-11-22 00:07:53 +00:00
David Chisnall
a54626e0cd (Hopefully) Fix the build with clang by removing a typedef that's no longer needed.
Approved by:	brooks (mentor)
2011-11-21 23:32:14 +00:00
David Chisnall
3c87aa1d3d Implement xlocale APIs from Darwin, mainly for use by libc++. This adds a
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)
2011-11-20 14:45:42 +00:00
Xin LI
5b5140322d Fix prototype for ffsll(3) and fls(3).
PR:		docs/156796
Submitted by:	Jean-Yves Migeon <jeanyves.migeon free.fr>
MFC after:	3 days
2011-05-03 19:33:06 +00:00
Jilles Tjoelker
2973057493 Allow strerror(0) and strerror_r(0, ...).
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
2011-04-05 21:56:05 +00:00
Jilles Tjoelker
2908f971d7 index(3): Mention that index/rindex are deprecated and not specified by
POSIX.1-2008.

MFC after:	1 week
2011-03-20 20:53:55 +00:00
Warner Losh
2c0959ae6b Powerpc is special here. powerpc and powerpc64 use different ABIs, so
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@)
2010-08-24 20:54:43 +00:00
Warner Losh
25faff346c MFtbemd:
Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want
to test of all the CPUs of a given family conform.
2010-08-23 22:24:11 +00:00
Ulrich Spörlein
0afc94c17a mdoc: move CAVEATS, BUGS and SECURITY CONSIDERATIONS sections to the
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
2010-05-13 12:07:55 +00:00
Xin LI
87c88b2632 Correct bugs fixed but not merged from my own tree.
Pointy hat to:	delphij
MFC after:	1 month
2010-03-13 00:15:06 +00:00
Xin LI
51e48ff21b Follow up commit to reindent the code.
MFC after:	1 month
2010-03-12 21:15:35 +00:00
Xin LI
dabae22639 Two optimizations to MI strlen(3) inspired by David S. Miller's
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
2010-03-12 21:14:56 +00:00
Ruslan Ermilov
2eeaf93408 Mark up "unsigned char". 2010-02-04 11:23:28 +00:00
Ed Schouten
61d38d61e2 Implement strndup(3) using strnlen(3).
This makes the implementation a bit more consistent with strdup(3),
which uses strlen(3).
2010-02-02 19:02:08 +00:00
Hajimu UMEMOTO
4f86602c03 Make strsignal(3) thread-safe.
MFC after:	2 weeks
2010-01-24 10:35:26 +00:00
Tom Rhodes
2ce5c85ed0 Add a missing word to a sentence in the return values section. 2009-12-04 09:20:20 +00:00
Christian Brueffer
ef33e7368a Add an .Nm for strncat.
PR:		141037
Submitted by:	Jeremy Huddleston <jeremyhu@apple.com>
MFC after:	3 days
2009-12-01 07:28:56 +00:00
Christian Brueffer
2a72feb42b Correct the information about when the respective functionality first
appeared in FreeBSD.

PR:		133785
Submitted by:	Ulrich Spoerlein <uqs@spoerlein.net>
MFC after:	3 days
2009-04-23 08:37:56 +00:00
Edward Tomasz Napierala
bab43bab0c There is no way for strmode(3) to append '+' if the file has ACL,
because there is no way to figure that out based on the file mode
itself.  Make the manual page match reality.
2009-04-14 11:39:56 +00:00
Edward Tomasz Napierala
5174a6a262 Add wide character variants of string manipulations routines to 'SEE ALSO'.
Approved by:	rwatson (mentor)
2009-04-07 13:42:53 +00:00
Konstantin Belousov
2e92f03abd 7.2 will be the first release where strndup() appears.
Submitted by:	Florian Smeets <flo kasimir com>
MFC after:	3 days
2009-03-22 15:29:12 +00:00
David Schultz
09efd0ec6a Add wcpcpy(3) and wcpncpy(3). 2009-03-04 06:01:27 +00:00
David Schultz
9c5cb6d8ae Add restrict qualifiers.
I missed this file in my previous commit.
2009-02-28 06:05:37 +00:00
David Schultz
69099ba2ec - Add getdelim(), getline(), stpncpy(), strnlen(), wcsnlen(),
wcscasecmp(), and wcsncasecmp().
- Make some previously non-standard extensions visible
  if POSIX_VISIBLE >= 200809.
- Use restrict qualifiers in stpcpy().
- Declare off_t and size_t in stdio.h.
- Bump __FreeBSD_version in case the new symbols (particularly
  getline()) cause issues with ports.

Reviewed by:	standards@
2009-02-28 06:00:58 +00:00
David Schultz
e00a6d21eb Add restrict qualifiers to the parameters to strlcpy() and strlcat().
The annotation mainly just serves as a hint that they're not intended
for use with overlapping strings.
2009-02-28 05:15:02 +00:00
Warner Losh
0ff7d9b4e9 Make sure the comparison is done with an unsigned char. 2009-02-07 19:34:44 +00:00
Warner Losh
ea58272861 Fix the functions to match prototypes. The K&R definitions differ
from the ANSI-C prototype due to the 'int promotion' rule.
2009-02-03 20:25:36 +00:00
Daniel Gerzo
bd604b4b06 - ANSIfy function definitions
- use nul when we are looking for a terminating character where appropriate

Approved by:	imp
2009-02-03 17:58:20 +00:00
Xin LI
481101b823 - Fix grammar. [1]
- Use the correct term 'long mode'. [2]
 - style(9) for return value. [3]

Submitted by:	Ben Kaduk <minimarmot gmail com> [1],
		obrien [2], scf [3]
2009-01-26 07:31:28 +00:00
Xin LI
4c6a60218c Rewrite of MI strlen(3) in a way that can better utilize modern hardware by
reducing branches and doing word-sized operation.

The idea is taken from J.T. Conklin's x86_64 optimized version of strlen(3)
for NetBSD, and reimplemented in C by me.

Discussed on:	-arch@
2009-01-25 23:08:47 +00:00
Konstantin Belousov
64d83d29b9 Document that ffsll(3) and flsll(3) functions first appeared in
FreeBSD 7.1

Submitted by:	Jan Henrik Sylvester <me janh de>
MFC after:	3 days
2009-01-13 13:19:42 +00:00
Xin LI
46714885b3 o Language improvements from OpenBSD;
o Use an ISC-style license as did by the author.

Obtained from:	OpenBSD
2009-01-12 06:10:48 +00:00
Xin LI
ba840c782f o ANSIfy.
o Use ISC style copyright as did by the author.

Obtained from:	OpenBSD
2009-01-12 06:09:34 +00:00