summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/strlen.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/string/strlen.3')
-rw-r--r--src/lib/libc/string/strlen.375
1 files changed, 54 insertions, 21 deletions
diff --git a/src/lib/libc/string/strlen.3 b/src/lib/libc/string/strlen.3
index f4aff363ee..9187496a00 100644
--- a/src/lib/libc/string/strlen.3
+++ b/src/lib/libc/string/strlen.3
@@ -1,3 +1,5 @@
1.\" $OpenBSD: strlen.3,v 1.10 2011/07/25 00:38:53 schwarze Exp $
2.\"
1.\" Copyright (c) 1990, 1991 The Regents of the University of California. 3.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved. 4.\" All rights reserved.
3.\" 5.\"
@@ -13,11 +15,7 @@
13.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the 16.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution. 17.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software 18.\" 3. Neither the name of the University nor the names of its contributors
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software 19.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission. 20.\" without specific prior written permission.
23.\" 21.\"
@@ -33,39 +31,74 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 32.\" SUCH DAMAGE.
35.\" 33.\"
36.\" from: @(#)strlen.3 5.4 (Berkeley) 6/29/91 34.Dd $Mdocdate: July 25 2011 $
37.\" $Id: strlen.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $
38.\"
39.Dd June 29, 1991
40.Dt STRLEN 3 35.Dt STRLEN 3
41.Os 36.Os
42.Sh NAME 37.Sh NAME
43.Nm strlen 38.Nm strlen ,
44.Nd find length of string 39.Nm strnlen
40.Nd find length of a string
45.Sh SYNOPSIS 41.Sh SYNOPSIS
46.Fd #include <string.h> 42.Fd #include <string.h>
47.Ft size_t 43.Ft size_t
48.Fn strlen "const char *s" 44.Fn strlen "const char *s"
45.Ft size_t
46.Fn strnlen "const char *s" "size_t maxlen"
49.Sh DESCRIPTION 47.Sh DESCRIPTION
50The 48The
51.Fn strlen 49.Fn strlen
52function 50function computes the length of the string
53computes the length of the string
54.Fa s . 51.Fa s .
52.Pp
53The
54.Fn strnlen
55function computes the length of the string
56.Fa s ,
57up to
58.Fa maxlen
59characters.
60The
61.Fn strnlen
62function will never attempt to address more than
63.Fa maxlen
64characters, making it suitable for use with character arrays that are
65not guaranteed to be NUL-terminated.
55.Sh RETURN VALUES 66.Sh RETURN VALUES
56The 67The
57.Fn strlen 68.Fn strlen
58function 69function returns the number of characters that precede the terminating
59returns 70.Tn NUL
60the number of characters that precede the
61terminating
62.Dv NUL
63character. 71character.
72.Pp
73The
74.Fn strnlen
75function returns the number of characters that precede the terminating
76.Tn NUL
77or
78.Fa maxlen ,
79whichever is smaller.
64.Sh SEE ALSO 80.Sh SEE ALSO
65.Xr string 3 81.Xr string 3 ,
82.Xr wcslen 3
66.Sh STANDARDS 83.Sh STANDARDS
67The 84The
68.Fn strlen 85.Fn strlen
69function 86function conforms to
70conforms to
71.St -ansiC . 87.St -ansiC .
88.Pp
89The
90.Fn strlen
91and
92.Fn strnlen
93functions conform to
94.St -p1003.1-2008 .
95.Sh HISTORY
96The
97.Fn strlen
98function first appeared in
99.At v7 .
100The
101.Fn strnlen
102function appeared in glibc 2.0
103and was reimplemented for
104.Ox 4.8 .