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.339
1 files changed, 36 insertions, 3 deletions
diff --git a/src/lib/libc/string/strlen.3 b/src/lib/libc/string/strlen.3
index f8a4efe9d2..3b5f9a10c1 100644
--- a/src/lib/libc/string/strlen.3
+++ b/src/lib/libc/string/strlen.3
@@ -29,29 +29,55 @@
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE. 30.\" SUCH DAMAGE.
31.\" 31.\"
32.\" $OpenBSD: strlen.3,v 1.6 2007/05/31 19:19:32 jmc Exp $ 32.\" $OpenBSD: strlen.3,v 1.7 2010/05/18 22:24:55 tedu Exp $
33.\" 33.\"
34.Dd $Mdocdate: May 31 2007 $ 34.Dd $Mdocdate: May 18 2010 $
35.Dt STRLEN 3 35.Dt STRLEN 3
36.Os 36.Os
37.Sh NAME 37.Sh NAME
38.Nm strlen 38.Nm strlen ,
39.Nm strnlen
39.Nd find length of a string 40.Nd find length of a string
40.Sh SYNOPSIS 41.Sh SYNOPSIS
41.Fd #include <string.h> 42.Fd #include <string.h>
42.Ft size_t 43.Ft size_t
43.Fn strlen "const char *s" 44.Fn strlen "const char *s"
45.Ft size_t
46.Fn strnlen "const char *s" "size_t maxlen"
44.Sh DESCRIPTION 47.Sh DESCRIPTION
45The 48The
46.Fn strlen 49.Fn strlen
47function computes the length of the string 50function computes the length of the string
48.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.
66.Pp
49.Sh RETURN VALUES 67.Sh RETURN VALUES
50The 68The
51.Fn strlen 69.Fn strlen
52function returns the number of characters that precede the terminating 70function returns the number of characters that precede the terminating
53.Tn NUL 71.Tn NUL
54character. 72character.
73.Pp
74The
75.Fn strnlen
76function returns the number of characters that precede the terminating
77.Tn NUL
78or
79.Fa maxlen ,
80whichever is smaller.
55.Sh SEE ALSO 81.Sh SEE ALSO
56.Xr string 3 82.Xr string 3
57.Sh STANDARDS 83.Sh STANDARDS
@@ -59,3 +85,10 @@ The
59.Fn strlen 85.Fn strlen
60function conforms to 86function conforms to
61.St -ansiC . 87.St -ansiC .
88.Pp
89The
90.Fn strlen
91and
92.Fn strnlen
93functions conform to
94.St -p1003.1-2008 .