Commit Graph

302 Commits

Author SHA1 Message Date
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
Ruslan Ermilov
efad698c19 Sort MLINKS. 2009-01-09 16:24:10 +00:00
Maxim Konovalov
9435575dbe o Use full month name in .Dd macro. 2008-12-09 09:24:25 +00:00
Konstantin Belousov
f0eca40a14 Import the strndup(3) function.
Copyright attribution is kept the same as in original NetBSD source.

Submitted by:	Florian Smeets <flo kasimir com>
Obtained from:	NetBSD
MFC after:	2 weeks
2008-12-06 09:37:54 +00:00
Konstantin Belousov
6197062881 Order the str*.c files mostly alphabetical.
Submitted by:	Florian Smeets <flo kasimir com>
MFC after:	2 weeks
2008-12-06 09:28:46 +00:00
Pawel Jakub Dawidek
3027fbe00b Add an easier example.
Reviewed by:	trasz
2008-12-05 15:50:59 +00:00
Konstantin Belousov
4a723bd20c Add the ffsll and flsll functions. These are ffs and fls operating
on long long arguments.

Reviewed by:	bde (previous version, that included asm implementation
	for all ffs and fls functions on i386 and amd64)
MFC after:	2 weeks
2008-11-03 10:22:19 +00:00
Konstantin Belousov
6f41f432e1 Fix style. 2008-11-03 10:14:47 +00:00
Xin LI
59f0ec8329 - License change to a less restrictive one;
- ANSIfy;
 - Convert do {} while loop -> while {} for clarity;
 - Sync RCS ID with OpenBSD;

Obtained from:	OpenBSD
2008-10-19 10:11:35 +00:00
Xin LI
ecc61e2fb1 Further simplify the code.
Submitted by:	Christoph Mallon <christoph.mallon gmx.de>
2008-10-19 09:10:44 +00:00
Xin LI
f53577c0d4 Use strlcpy() in !localized case to avoid the -1's. 2008-10-17 21:29:05 +00:00
Xin LI
82e45205c8 Add memrchr(3).
Obtained from:	OpenBSD
2008-04-10 00:12:44 +00:00
Wes Peters
05db21b17b Remove license clause 3 to agree with the now-standard BSD license.
Prompted by:	Glenn Halperin, Symbian Software
2007-12-12 18:33:06 +00:00
Daniel Eischen
5f864214bb Use C comments since we now preprocess these files with CPP. 2007-04-29 14:05:22 +00:00
Warner Losh
c879ae3536 Per Regents of the University of Calfornia letter, remove advertising
clause.

# If I've done so improperly on a file, please let me know.
2007-01-09 00:28:16 +00:00
Ruslan Ermilov
948ec60d36 Don't say "rightmost" when referring to the least significant bit.
PR:		docs/94803
MFC after:	3 days
2006-10-12 15:08:41 +00:00
Dima Dorfman
01510e402d Improve the wording. Remove the appositive about strcmp, putting the
first sentence back to the way it was. Add a second sentence that
explains the case when strcmp is called.
2006-08-14 08:21:27 +00:00
Maxim Konovalov
f0a3522b5d o Make grep ^strlcpy work: put a return value type on separate line. 2006-06-15 15:56:55 +00:00
Daniel Eischen
6fad3aaf15 Add each directory's symbol map file to SYM_MAPS. 2006-03-13 01:15:01 +00:00
Daniel Eischen
cce72e8860 Add symbol maps and initial symbol version definitions to libc.
Reviewed by:	davidxu
2006-03-13 00:53:21 +00:00
Ruslan Ermilov
36c71f6ac1 Fix prototype. 2005-11-24 06:56:21 +00:00
Ruslan Ermilov
ca5137742a Fix up markup. 2005-11-18 11:54:14 +00:00
Tim J. Robbins
6595b51a7f Remove references to nonexistent "FreeBSD Security Architecture" document. 2005-09-05 09:49:33 +00:00
Gary W. Swearingen
669fe42db9 Added a sentence to explain what "span" means.
PR:             docs/84850
Submitted by:   garys
MFC after:      3 days
Approved by:    keramida
2005-08-29 20:41:58 +00:00
Andre Oppermann
6050c8fe05 Add the function memmem(3) as found in glibc and others.
It is the binary equivalent to strstr(3).

 void *memmem(const void *big, size_t big_len,
	const void *little, size_t little_len);

Submitted by:	Pascal Gloor <pascal.gloor at spale.com>
MFC after:	3 days
2005-08-25 18:26:58 +00:00
Tim J. Robbins
d62e8d4c7c Add an implementation of the semi-standard wcsdup() function, as found
on Microsoft and GNU systems.
2005-08-13 05:54:33 +00:00
David Schultz
f0ceb98f93 Replace the current strspn() and strcspn() with significantly faster
implementations inspired by the ones in DragonFly.  Unlike the
DragonFly versions, these have a small data cache footprint, and my
tests show that they're never slower than the old code except when the
charset or the span is 0 or 1 characters.  This implementation is
generally faster than DragonFly until either the charset or the span
gets in the ballpark of 32 to 64 characters.
2005-04-02 18:52:44 +00:00
Maxime Henrion
cea5da0456 Unbreak strsignal(). This is an MFC candidate.
Reported by:	Sean McNeil <sean@mcneil.com>
2005-03-06 03:19:19 +00:00
Alexey Zelkin
fc7c352831 Unbreak !NLS case 2005-02-27 21:17:22 +00:00
Alexey Zelkin
fba5c5fa09 Add NLS catalogs support to strerror(), strerror_r() and strsignal().
Controlled by NLS define, currently disabled by default.

Idea obtained from:	NetBSD
2005-02-27 16:58:28 +00:00
Pawel Jakub Dawidek
029f08c23c Don't read more than the given 'len' bytes from the 'big' string.
PR:		misc/77369
Submitted by:	Ed Maste <emaste@phaedrus.sandvine.ca>
MFC after:	1 week
2005-02-11 21:07:51 +00:00
Ruslan Ermilov
24a0682c64 Sort sections. 2005-01-20 09:17:07 +00:00
Tom Rhodes
cf8f149faf Date business, update. 2004-12-10 15:27:06 +00:00
Tom Rhodes
2f5cde3c64 According to the information on:
http://www.opengroup.org/onlinepubs/009695399/functions/swab.html
the prototype for swab() should be in <unistd.h> and not in <string.h>.
Move it, and update to match SUS.  Leave the prototype in string.h for
now, for backwards compat.

PR:		74751
Submitted by:	Craig Rodrigues <rodrigc@crodrigues.org>
Discussed with:	das
2004-12-10 15:24:40 +00:00
David E. O'Brien
a9bdcd3711 Enable building with LIBC_SCCS defined.
Bug submitted by:	Andrea Campi <andrea+freebsd_current@webcom.it>
2004-10-16 06:32:43 +00:00
Stefan Farfeleder
d749cd6f7c Remove extra closing parenthesis added in revision 1.4.
Noticed by:	Andrea Campi
2004-10-14 21:31:42 +00:00
Giorgos Keramidas
4bf94cc1f7 Correctly document the return value of strerror() and strerror_r() and
the contents of the returned buffer for unknown error codes.

PR:		docs/72578
Submitted by:	Jilles Tjoelker <jilles@stack.nl>
MFC after:	3 days
2004-10-12 14:52:52 +00:00
Ruslan Ermilov
1a0a934547 Mechanically kill hard sentence breaks. 2004-07-02 23:52:20 +00:00
Ruslan Ermilov
33992dc0ed Markup, grammar, and spelling fixes. 2004-06-30 20:09:10 +00:00
Tim J. Robbins
dc763237da Prepare to handle state-dependent encodings. This mainly involves not
taking shortcuts when it comes to storing and passing around conversion
states.
2004-04-07 09:47:56 +00:00
Dag-Erling Smørgrav
29554ea51a Translate from GNU C to ISO C. 2004-01-14 07:47:10 +00:00
Dag-Erling Smørgrav
f434fe1237 Add and document ffsl(), fls() and flsl(). 2004-01-13 16:05:47 +00:00
Jordan K. Hubbard
fee66713ad Brucification: Don't initialize in declaration, make sure extra lines
follow declaration section.
2003-12-18 07:44:53 +00:00
Jordan K. Hubbard
dee551158f Do comparison using appropriate casting first, as per SUSv3 (search for first
[last] character, not int).
2003-12-17 02:46:48 +00:00
Tim J. Robbins
22749a6e2a Pass NULL instead of a pointer to a zeroed mbstate_t object. 2003-11-05 08:07:00 +00:00
Peter Wemm
a352421215 Pacify gcc about casting pointers to integers (for the lowest few bits). 2003-10-26 03:55:58 +00:00
Ruslan Ermilov
fe08efe680 mdoc(7): Use the new feature of the .In macro. 2003-09-08 19:57:22 +00:00
Simon L. B. Nielsen
4bbf46d65c Move a sentence about the terminating \0 from the RETURN VALUES section
(where it didn't really belong), to the DESCRIPTION section.

English advice:	ceri
Requested by:	das
MFC after:	4 weeks
2003-09-04 20:36:54 +00:00
Simon L. B. Nielsen
c9ae54eebb * Merge index(3) and rindex(3) to index(3) since the two functions are
almost identical.
* Merge strchr(3) and strrchr(3) to strchr(3) since the two functions
  are almost identical.
* Make the wording of index(3) and strchr(3) more similar.
* mdoc(7) cleanup.

Submitted by:	SUZUKI Koichi <metal@gc5.so-net.ne.jp>, keramida, myself
PR:		docs/32054
Reviewed by:	ru
Approved by:	ceri (mentor)
2003-07-28 22:50:42 +00:00
Maxim Konovalov
8473e4cfc2 o strmode(3) returns void not 0.
PR:		docs/53488
Submitted by:	Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
MFC after:	1 week
2003-07-01 15:28:05 +00:00
Jacques Vidrine
d05090827f Back out the `hiding' of strlcpy and strlcat. Several people
vocally objected to this safety belt.
2003-05-01 19:03:14 +00:00
Jacques Vidrine
5723e501ab `Hide' strlcpy and strlcat (using the namespace.h / __weak_reference
technique) so that we don't wind up calling into an application's
version if the application defines them.

Inspired by:	qpopper's interfering and buggy version of strlcpy
2003-04-29 21:13:50 +00:00
Tim J. Robbins
07648c8bb8 MFp4: Make `spanp' const. 2003-03-12 06:41:49 +00:00
Mike Barcroft
e37f8b5313 Optimize errstr() by reducing the number of times it walks a string.
As a side effect, it makes the code easier to read and requires less
pointer arithmetic.

Test by:	strerror regression test
Submitted by:	Tim Kientzle <kientzle@acm.org>
2003-01-03 16:44:42 +00:00
Mike Barcroft
68cd9bedfb Stylistic changes:
o Fix an English error (comma splice) and poorly worded sentence.
o Fix KNF ordering of variables (pointers come before arithmetic types).
o Restore hand-optimization of sizeof()-1, instead of strlen().
o Remove unneeded local variables in strerror_r().

Test by:	strerror regression test
Requested by:	bde
Reviewed by:	bde
2002-12-20 05:26:10 +00:00
Tim J. Robbins
c0dd63a8a8 Add back the Standards section claiming conformance to 1003.1-2001 and
C99 now that all known standards-related bugs have been fixed.
2002-12-19 10:24:52 +00:00
Ruslan Ermilov
2efeeba554 mdoc(7) police: "The .Fa argument.". 2002-12-19 09:40:28 +00:00
Mike Barcroft
5a98f074e6 Rearrange strerror() so that its itoa procedure can be used with
strerror_r().  Doing this allows us to ensure that strerror_r() always
fills the supplied buffer regardless of EINVAL or ERANGE errors.

strerror()'s semantics have changed slightly such that an argument of
0 is now considered invalid and errno is set to EINVAL.

Remove internal regression test for strerror() and strerror_r().  This
will be reincarnated in src/tools/regression/lib/libc/string.

In strerror(3), add a comment about strerror()'s bogus return type.

PR:	44356
2002-12-18 16:53:31 +00:00
Ruslan Ermilov
5c564bae0a mdoc(7) police: Fixed abuses of the .Ar and .Em macros. 2002-12-18 13:33:04 +00:00
Ruslan Ermilov
1fae73b137 mdoc(7) police: "The .Fn function". 2002-12-18 12:45:11 +00:00
Ruslan Ermilov
fd779e0181 mdoc(7) police: tiny nits.
Approved by:	re
2002-12-09 14:04:05 +00:00
Ruslan Ermilov
1798791d24 mdoc(7) police: formatting nits.
Approved by:	re
2002-11-29 15:57:50 +00:00
Ruslan Ermilov
c51d717f0c libc_r wasn't so tied to libc for 22 months. 2002-11-18 09:50:57 +00:00
Tim J. Robbins
fcd7f38f46 Replace wcsstr() with an implementation based on strstr(), which is far
more efficient. The problem with the previous implementation was that it
calculated the length of the first argument ("big") with wcslen() when
it was not necessary.
2002-10-24 02:53:45 +00:00
Tim J. Robbins
1707c9c3f5 Restore Berkeley SCCS id. 2002-10-24 02:48:45 +00:00
Tim J. Robbins
6f9ed74abc Remove the Standards section again until we get these functions sorted
out. This will probably have to wait until after 5.0-R.
2002-10-24 01:24:26 +00:00
Tim J. Robbins
fb22884400 Fix the NetBSD RCS id's on these files; somehow they were initially
committed with the tags unexpanded.
2002-10-23 11:08:40 +00:00
Tim J. Robbins
1eb0f442c7 Reimplement more efficiently, using a single forward scan (like strrchr(3))
instead of scanning forwards to find the end of the string then scanning
backwards to find the character.
2002-10-23 10:52:04 +00:00
Tim J. Robbins
ec23fdffc7 Reimplement, handling the case where c == L'\0' correctly and fixing
some style(9) bugs.
2002-10-23 10:47:47 +00:00
Tim J. Robbins
edafcb6d73 Add a Standards section, claiming conformance to IEEE Std. 1003.1-2001.
Also add a note to the Bugs section pointing out that strerror() and
perror() share the same static buffer.
2002-10-23 10:16:21 +00:00
Dag-Erling Smørgrav
02edf2208d Translate to English. 2002-10-23 08:55:14 +00:00
Tim J. Robbins
4bf546e192 Replace this wcsncpy() implementation with one based on strncpy.c to fix
two major bugs:
- off-by-one overflow when the length of the source string exceeds or
  equals the destination buffer size.
- old version was not padding the destination buffer with null wide chars
2002-10-23 04:35:25 +00:00
Tim J. Robbins
f7383f14ae C89 does not specifiy strsep(), so our strsep() implementation cannot
conform to it.

Obtained from:	OpenBSD
2002-10-19 13:41:22 +00:00
Tim J. Robbins
2fe3e5cda7 Add cross-references to the wide character counterparts of these functions. 2002-10-15 10:11:53 +00:00
Tim J. Robbins
616e099e5c Remove stray comma at the end of the See Also list. 2002-10-15 09:49:54 +00:00
Robert Drehmel
5d38e85ded Fix another spelling mistake. 2002-10-10 14:16:08 +00:00
Robert Drehmel
73fbee5795 Correct a spelling mistake. 2002-10-10 14:14:44 +00:00
Tim J. Robbins
fd4f1dd9fa Add a placeholder implementation of wcscoll() and wcsxfrm() which gives
locale-sensitive collation only in single-byte locales, and just does
binary comparison for the others with extended character sets.
2002-10-04 03:18:26 +00:00
David E. O'Brien
8269e8c887 Add stpcpy(3). 2002-10-03 19:39:20 +00:00
Tim J. Robbins
61d7477610 Add an example showing how to use wcstok(). Fix ordering of See Also section. 2002-10-02 14:28:26 +00:00
Tim J. Robbins
ce2a18008c Simplify by removing unneeded local variables and explicit null termination. 2002-09-26 09:28:55 +00:00
Tim J. Robbins
e2361b6f16 Simplify by removing useless local variables and explicit null termination. 2002-09-26 09:23:07 +00:00
Tim J. Robbins
99330f8368 Remove unnecessary #include <assert.h>; it was used to bring in the
_DIAGASSERT macro on NetBSD, but we don't need it.
2002-09-21 00:29:23 +00:00
Tim J. Robbins
8e4365cf75 Replace a stray reference to strtok() with one to wcstok(). 2002-09-08 11:09:24 +00:00
Tim J. Robbins
9ad391340e Add an implementation of wcstok(), based on strtok_r(). 2002-09-07 08:16:57 +00:00
Tim J. Robbins
85adcfc150 Sync prototypes with <wchar.h> with respect to the restrict qualifier. 2002-09-07 04:07:00 +00:00
Tim J. Robbins
9c261371ec Add restrict qualifiers where C99 permits them. All of these already had
restrict qualifiers on their prototypes in <wchar.h>.
2002-09-07 04:03:28 +00:00
Tim J. Robbins
91bd11ad84 Call strtok_r() via a libc private name from within strtok(). 2002-09-07 02:53:19 +00:00
Tim J. Robbins
58d38e2520 Style: One space between "restrict" qualifier and "*". 2002-09-06 11:24:06 +00:00
Robert Drehmel
bc0ad8e7a1 - Let their manual pages show the reader that the bzero(3) and
bcopy(3) functions are prototyped in <strings.h> and not in
   <string.h> anymore.
 - Add a sentence about that to the respective HISTORY sections.
In the C source files:
 - Include <string.h> or <strings.h> depending on what function
   is to be compiled.
 - Use ANSI-C function definitions.
2002-09-01 21:53:46 +00:00