From 84e56ad2cf3f4b33089396bba6483888d54d99a3 Mon Sep 17 00:00:00 2001 From: tedu <> Date: Tue, 18 May 2010 22:24:55 +0000 Subject: add posix_madvise, posix_memalign, strndup, and strnlen. mostly from brad and millert, with hints from guenther, jmc, and otto I think. ok previous. --- src/lib/libc/string/strlen.3 | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'src/lib/libc/string/strlen.3') 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 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: strlen.3,v 1.6 2007/05/31 19:19:32 jmc Exp $ +.\" $OpenBSD: strlen.3,v 1.7 2010/05/18 22:24:55 tedu Exp $ .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: May 18 2010 $ .Dt STRLEN 3 .Os .Sh NAME -.Nm strlen +.Nm strlen , +.Nm strnlen .Nd find length of a string .Sh SYNOPSIS .Fd #include .Ft size_t .Fn strlen "const char *s" +.Ft size_t +.Fn strnlen "const char *s" "size_t maxlen" .Sh DESCRIPTION The .Fn strlen function computes the length of the string .Fa s . +.Pp +The +.Fn strnlen +function computes the length of the string +.Fa s , +up to +.Fa maxlen +characters. +The +.Fn strnlen +function will never attempt to address more than +.Fa maxlen +characters, making it suitable for use with character arrays that are +not guaranteed to be NUL-terminated. +.Pp .Sh RETURN VALUES The .Fn strlen function returns the number of characters that precede the terminating .Tn NUL character. +.Pp +The +.Fn strnlen +function returns the number of characters that precede the terminating +.Tn NUL +or +.Fa maxlen , +whichever is smaller. .Sh SEE ALSO .Xr string 3 .Sh STANDARDS @@ -59,3 +85,10 @@ The .Fn strlen function conforms to .St -ansiC . +.Pp +The +.Fn strlen +and +.Fn strnlen +functions conform to +.St -p1003.1-2008 . -- cgit v1.2.3-55-g6feb