Commit Graph

364 Commits

Author SHA1 Message Date
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
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
Robert Drehmel
2f4772b37f Add the 'restrict' type qualifier to the function prototype
of the swab(3) function in its manual page to match the
standardization by POSIX.1-2001.
2002-08-30 21:18:39 +00:00
Robert Drehmel
9abf5797a0 - Update the manual page of bcmp(3) by replacing
.In string.h
   with
     .In strings.h
   and adding a sentence to the HISTORY section.
 - Use an ANSI-C function definition.
 - Include <strings.h> instead of <string.h>.
 - Apply style(9): Put a space after return keywords.
2002-08-30 21:07:40 +00:00
Robert Drehmel
c9ab23eea5 - Convert the function definition to declare its arguments
in the ANSI-C format.
 - Change the code a bit to hopefully save some cycles.
   I.e. (simplified) change

     a = b + 1;
     while (--b & 0x7)
	/* ... */
   to
     a = b;
     for (; b & 0x7; b--)
	/* ... */
   and
     while (--a >= 0)
	/* ... */
   to
     for (; a > 0; a--)
	/* ... */
 - Equip two function arguments of swab() with the 'restrict'
   type qualifier in form of the '__restrict' macro.  This is
   specified by POSIX.1-2001.
2002-08-30 20:33:05 +00:00
Robert Drehmel
425289a9db - Update the manual pages of index() and rindex() to show
<strings.h> as the associated header file.
   The prototypes have been moved there from <string.h> because
   POSIX.1-2001 said so.
 - Conditionally include either <strings.h> or <string.h> based
   on whether the [r]index() or str[r]chr() functions are
   compiled, respectively.
 - Style(9) tells us to
    - put a space after the return keyword
    - to check for a NUL character without using the ! operator.
    - use NULL instead of (type *)NULL where the compiler knows
      the type.
   Apply these rules.
 - Rather use ANSI-C function definitions than K&R ones.
 - For index(3), correct second function argument's type; it was
   declared to be a `const char' before and is now an `int'.
2002-08-30 19:42:07 +00:00
Robert Drehmel
554331bbb9 - Update the manual page to show that the associated header file
is <strings.h> and not <string.h> anymore.
 - Tell the reader about this change in the HISTORY section.
 - Switch to use an ANSI-C function definition.
 - Include <strings.h> instead of <string.h> in the source file.
2002-08-30 19:08:53 +00:00
Robert Drehmel
c271a3613c - Update strcasecmp(3)/strncasecmp(3) to reflect the fact that
the prototypes for both functions are now in the <strings.h>
   header, as required by IEEE Std 1003.1-2001.
 - Add one sentence about that in the HISTORY section.
 - Include <strings.h> in the source file to have the prototypes
   in scope when the _ANSI_SOURCE macro is defined.
2002-08-30 15:40:01 +00:00
Tim J. Robbins
c8e804757d Add a manual page for wcswidth(). 2002-08-20 03:40:45 +00:00
Andrey A. Chernov
353450fbbe Move just committed version of wcswidth.c here (from "locale"),
a bit optimized now.
2002-08-20 02:06:28 +00:00
Robert Drehmel
ad90696815 - Add the 'restrict' qualifier to the definitions of the string
concatenation and copy functions using the '__restrict' macro.
   This is to satisfy IEEE Std 1003-1.2001.
 - Use ANSI-C function definitions.
 - Add the 'restrict' keyword to the manual pages, too.
2002-08-14 22:59:22 +00:00
Robert Drehmel
33f9b60eee - Add the 'restrict' qualifier required by IEEE Std 1003.1-2001
to the function definition of strxfrm(3) in form of our
   '__restrict' macro.
 - Use an ANSI-C function definition for strxfrm(3).
 - Change the manual page accordingly.
2002-08-14 21:01:04 +00:00
Archie Cobbs
a8ee7a0256 Correct an inaccuracy in this man page regarding detecting empty fields.
MFC after:	2 days
2002-08-07 20:08:50 +00:00
Jonathan Mini
16f33a4885 Fix off-by-one error.
PR:		misc/40104
Submitted by:	Neal Fachan <neal@isilon.com>
MFC after:	3 days
2002-07-03 06:28:04 +00:00
David E. O'Brien
333fc21e3c Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.
2002-03-22 21:53:29 +00:00
David E. O'Brien
8fb3f3f682 Remove 'register' keyword. 2002-03-21 18:49:23 +00:00
Chris D. Faulhaber
ea018aa260 Revert last commit. stdio.h include is for perror(), not strerror() 2002-01-31 13:32:14 +00:00
Chris D. Faulhaber
066f7169c1 strerror(3) is in string.h, not stdio.h
MFC after:	1 week
2002-01-31 13:20:48 +00:00
Mike Barcroft
4681597d9a Add a few cleanups from rev 1.1:
o Restore vendor ID.
o Order variable types by size.
o Remove a gratuitous temporary variable.

Submitted by:	bde
2002-01-15 17:52:21 +00:00
Mike Barcroft
1936b2c83b o Add prototype for printf(3).
style(9):
o Order variables in declarations.
o Move initialization out of declaration.
o Fix over-indents in previous delta.
2002-01-15 08:50:28 +00:00
Mike Barcroft
f601b5ba4b style(9)
Submitted by:	Joseph Mallett <jmallett@xmach.org>
Reviewed by:	md5(1)
2002-01-15 08:26:58 +00:00
Ruslan Ermilov
ce9df6eefc mdoc(7) police:
Stop abusing the .%J macro for where the .Pa macro should have been used.
2002-01-09 14:01:22 +00:00
Dima Dorfman
b06e8b97a9 Suggest using memmove(3) if src and dst may overlap.
PR:		33298
Submitted by:	Tim J. Robbins <tim@robbins.dropbear.id.au>
2002-01-07 06:03:37 +00:00
Chris Costello
41f91cb492 Add a new `SECURITY CONSIDERATIONS' section. Sample code similar to
the first revision of strcpy(3)'s section is included, but should be
removed as the Security Architecture document is committed and
completed.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2002-01-05 20:44:34 +00:00
Chris Costello
80080d642e Include a section cross-reference to EXAMPLES' in SECURITY
CONSIDERATIONS' as a source for relevant sample code.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2002-01-05 20:36:47 +00:00
Chris Costello
8680aaea87 Remove the example from SECURITY CONSIDERATIONS. This is mostly
duplicated code from EXAMPLES.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2002-01-05 20:24:38 +00:00
Chris Costello
17dc85f4d0 Copy the sample `SECURITY CONSIDERATIONS' section from sec-doc.7.
This will be trimmed as the FreeBSD Security Architecture document
is fleshed out and committed.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
2002-01-02 19:56:57 +00:00
Ruslan Ermilov
6184d98a2a mdoc(7) police: minor markup nits. 2001-12-12 15:02:32 +00:00
Wes Peters
556f162ac0 Make strerror and strerror_r use sys_errlist[0] for errnum = 0. Be
more careful about reporting truncation with ERANGE in strerror_r.
Set errno to EINVAL for "unknown" errnum in strerror as required
by P1003.1-200x Draft June 14, 2001.

More carefully document the handling of strerrbuf when errors
(ERANGE, EINVAL) are encountered in strerror_r.

Reviewed by:	bde (ongoing discussion)
2001-12-07 06:28:58 +00:00
Wes Peters
f61a2ede84 New, improved, more Posix-compliant strerror_r implementation,
complete with documentation.

Reviewed by:	mike@ gad@
MFC after:	1 week
2001-12-06 04:53:31 +00:00
Wes Peters
4f7d6d65dc Must link strerror manpage to strerror_r.
Thanks for the review, Mike.

Submitted by:	Mike Barcroft <mike@FreeBSD.org>
2001-11-27 07:57:31 +00:00
Wes Peters
9c324dc0c0 Add strerror_r function per Posix prototype.
Reviewed by:	Mike Barcroft <mike@FreeBSD.org>
MFC after:	2 weeks
2001-11-27 07:39:46 +00:00
Ruslan Ermilov
1ddfc2e3aa mdoc(7) police: minor markup and spelling fixes. 2001-11-20 14:11:07 +00:00
Dag-Erling Smørgrav
33ad961d11 Increment the loop counter.
PR:		bin/29218
Submitted by:	Goran Lowkrantz <goran.lowkrantz@ismobile.com>
2001-11-10 17:36:58 +00:00
David E. O'Brien
de5fe5d53b rcsid[]->__FBSDID 2001-11-07 19:55:16 +00:00
Mike Barcroft
43e13bf58f Note that strncmp() will not compare characters after a NUL character.
Add a missing word.  Bump document date.

Inspired by:	IEEE Std 1003.1-200x (Draft 7)
MFC after:	3 days
2001-10-11 17:02:44 +00:00
Mike Barcroft
a9227c40eb Clarify that strnstr() will stop searching after in encounters a NUL
character.  Bump document date.  Add a missing comma.
2001-10-11 15:49:06 +00:00
Andrey A. Chernov
89503316a0 Implement strcasestr() which many others (f.e. Linux) already have. 2001-10-10 02:17:35 +00:00
Mike Barcroft
7ec7a350c5 Document the fact that the strnstr(3) function is not portable.
Requested by:	brian, gad
2001-10-09 17:22:02 +00:00
Mike Barcroft
41036d782d Add a new libc function, strnstr(3), which allows one to limit the
number of characters that are searched.  This is especially useful
with file operations and non-NUL terminated strings.

Silence from:	-audit, -hackers
MFC after:	5 days
2001-10-09 01:29:56 +00:00