From fbd15bedaaeb647ec5c9ba015cb5538e1986f584 Mon Sep 17 00:00:00 2001 From: nicm <> Date: Sat, 9 Jul 2011 16:32:11 +0000 Subject: [PATCH] Instead of documenting all the wide string functions in wmemchr(3), add individual pages (based on the existing string man pages). By Tim van der Molen (tbvdm at xs4all dot nl) after a suggestion by millert@. ok deraadt --- src/lib/libc/string/Makefile.inc | 32 ++----- src/lib/libc/string/wcscasecmp.3 | 77 ++++++++++++++++ src/lib/libc/string/wcscat.3 | 93 +++++++++++++++++++ src/lib/libc/string/wcschr.3 | 77 ++++++++++++++++ src/lib/libc/string/wcscmp.3 | 82 +++++++++++++++++ src/lib/libc/string/wcscpy.3 | 97 ++++++++++++++++++++ src/lib/libc/string/wcscspn.3 | 75 ++++++++++++++++ src/lib/libc/string/wcslcpy.3 | 139 ++++++++++++++++++++++++++++ src/lib/libc/string/wcslen.3 | 62 +++++++++++++ src/lib/libc/string/wcspbrk.3 | 73 +++++++++++++++ src/lib/libc/string/wcsrchr.3 | 77 ++++++++++++++++ src/lib/libc/string/wcsspn.3 | 71 +++++++++++++++ src/lib/libc/string/wcsstr.3 | 80 +++++++++++++++++ src/lib/libc/string/wmemchr.3 | 150 +++++++------------------------ src/lib/libc/string/wmemcmp.3 | 70 +++++++++++++++ src/lib/libc/string/wmemcpy.3 | 77 ++++++++++++++++ src/lib/libc/string/wmemmove.3 | 70 +++++++++++++++ src/lib/libc/string/wmemset.3 | 64 +++++++++++++ 18 files changed, 1327 insertions(+), 139 deletions(-) create mode 100644 src/lib/libc/string/wcscasecmp.3 create mode 100644 src/lib/libc/string/wcscat.3 create mode 100644 src/lib/libc/string/wcschr.3 create mode 100644 src/lib/libc/string/wcscmp.3 create mode 100644 src/lib/libc/string/wcscpy.3 create mode 100644 src/lib/libc/string/wcscspn.3 create mode 100644 src/lib/libc/string/wcslcpy.3 create mode 100644 src/lib/libc/string/wcslen.3 create mode 100644 src/lib/libc/string/wcspbrk.3 create mode 100644 src/lib/libc/string/wcsrchr.3 create mode 100644 src/lib/libc/string/wcsspn.3 create mode 100644 src/lib/libc/string/wcsstr.3 create mode 100644 src/lib/libc/string/wmemcmp.3 create mode 100644 src/lib/libc/string/wmemcpy.3 create mode 100644 src/lib/libc/string/wmemmove.3 create mode 100644 src/lib/libc/string/wmemset.3 diff --git a/src/lib/libc/string/Makefile.inc b/src/lib/libc/string/Makefile.inc index bb285e13..40713956 100644 --- a/src/lib/libc/string/Makefile.inc +++ b/src/lib/libc/string/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.26 2011/07/04 04:37:34 nicm Exp $ +# $OpenBSD: Makefile.inc,v 1.27 2011/07/09 16:32:11 nicm Exp $ # string sources .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/string ${LIBCSRCDIR}/string @@ -144,7 +144,9 @@ MAN+= bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 memccpy.3 memchr.3 \ strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strerror.3 \ string.3 strlen.3 strmode.3 strdup.3 strpbrk.3 strrchr.3 strsep.3 \ strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 strlcpy.3 \ - wcstok.3 wmemchr.3 wcswidth.3 wcsdup.3 + wcscasecmp.3 wcscat.3 wcschr.3 wcscmp.3 wcscpy.3 wcscspn.3 wcsdup.3 \ + wcslcpy.3 wcslen.3 wcspbrk.3 wcsrchr.3 wcsspn.3 wcsstr.3 wcstok.3 \ + wcswidth.3 wmemchr.3 wmemcmp.3 wmemcpy.3 wmemmove.3 wmemset.3 MLINKS+=bm.3 bm_comp.3 bm.3 bm_exec.3 bm.3 bm_free.3 MLINKS+=memchr.3 memrchr.3 @@ -160,25 +162,9 @@ MLINKS+=strlen.3 strnlen.3 MLINKS+=strstr.3 strcasestr.3 MLINKS+=strtok.3 strtok_r.3 MLINKS+=strerror.3 strerror_r.3 -MLINKS+=wmemchr.3 wmemcmp.3 -MLINKS+=wmemchr.3 wmemcpy.3 -MLINKS+=wmemchr.3 wmemmove.3 -MLINKS+=wmemchr.3 wmemset.3 -MLINKS+=wmemchr.3 wcscat.3 -MLINKS+=wmemchr.3 wcschr.3 -MLINKS+=wmemchr.3 wcscmp.3 -MLINKS+=wmemchr.3 wcscasecmp.3 -MLINKS+=wmemchr.3 wcscpy.3 -MLINKS+=wmemchr.3 wcscspn.3 -MLINKS+=wmemchr.3 wcslcat.3 -MLINKS+=wmemchr.3 wcslcpy.3 -MLINKS+=wmemchr.3 wcslen.3 -MLINKS+=wmemchr.3 wcsncat.3 -MLINKS+=wmemchr.3 wcsncmp.3 -MLINKS+=wmemchr.3 wcsncasecmp.3 -MLINKS+=wmemchr.3 wcsncpy.3 -MLINKS+=wmemchr.3 wcspbrk.3 -MLINKS+=wmemchr.3 wcsrchr.3 -MLINKS+=wmemchr.3 wcsspn.3 -MLINKS+=wmemchr.3 wcsstr.3 +MLINKS+=wcscasecmp.3 wcsncasecmp.3 +MLINKS+=wcscat.3 wcsncat.3 +MLINKS+=wcscmp.3 wcsncmp.3 +MLINKS+=wcscpy.3 wcsncpy.3 +MLINKS+=wcslcpy.3 wcslcat.3 MLINKS+=bcmp.3 timingsafe_bcmp.3 diff --git a/src/lib/libc/string/wcscasecmp.3 b/src/lib/libc/string/wcscasecmp.3 new file mode 100644 index 00000000..d76d33bd --- /dev/null +++ b/src/lib/libc/string/wcscasecmp.3 @@ -0,0 +1,77 @@ +.\" $OpenBSD: wcscasecmp.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93 +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSCASECMP 3 +.Os +.Sh NAME +.Nm wcscasecmp , +.Nm wcsncasecmp +.Nd compare wide strings, ignoring case +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn wcscasecmp "const wchar_t *s1" "const wchar_t *s2" +.Ft int +.Fn wcsncasecmp "const wchar_t *s1" "const wchar_t *s2" "size_t len" +.Sh DESCRIPTION +The +.Fn wcscasecmp +and +.Fn wcsncasecmp +functions compare the wide strings +.Fa s1 +and +.Fa s2 +and return an integer greater than, equal to, or less than 0, +according to whether +.Fa s1 +is lexicographically greater than, equal to, or less than +.Fa s2 +after translation of each corresponding wide character to lower case. +The wide strings themselves are not modified. +.Pp +.Fn wcsncasecmp +compares at most +.Fa len +wide characters. +.Sh SEE ALSO +.Xr wcscmp 3 , +.Xr wmemcmp 3 +.Sh STANDARDS +The +.Fn wcscasecmp +and +.Fn wcsncasecmp +functions conform to +.St -p1003.1-2008 . diff --git a/src/lib/libc/string/wcscat.3 b/src/lib/libc/string/wcscat.3 new file mode 100644 index 00000000..c5321d5a --- /dev/null +++ b/src/lib/libc/string/wcscat.3 @@ -0,0 +1,93 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wcscat.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSCAT 3 +.Os +.Sh NAME +.Nm wcscat , +.Nm wcsncat +.Nd concatenate wide strings +.Sh SYNOPSIS +.Fd #include +.Ft wchar_t * +.Fn wcscat "wchar_t * restrict s" "const wchar_t * restrict append" +.Ft wchar_t * +.Fo strncat +.Fa "wchar_t * restrict s" +.Fa "const wchar_t * restrict append" +.Fa "size_t count" +.Fc +.Sh DESCRIPTION +The +.Fn wcscat +and +.Fn wcsncat +functions append a copy of the wide string +.Fa append +to the end of the wide string +.Fa s , +then add a terminating null wide character (L'\e0'). +The wide string +.Fa s +must have sufficient space to hold the result. +.Pp +The +.Fn wcsncat +function appends not more than +.Fa count +wide characters where space for the terminating null wide character +should not be included in +.Fa count . +.Sh RETURN VALUES +The +.Fn wcscat +and +.Fn wcsncat +functions return the pointer +.Fa s . +.Sh SEE ALSO +.Xr wcscpy 3 , +.Xr wcslcat 3 , +.Xr wcslcpy 3 , +.Xr wmemcpy 3 , +.Xr wmemmove 3 +.Sh STANDARDS +The +.Fn wcscat +and +.Fn wcsncat +functions conform to +.St -isoC-99 +and were first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wcschr.3 b/src/lib/libc/string/wcschr.3 new file mode 100644 index 00000000..10c78f34 --- /dev/null +++ b/src/lib/libc/string/wcschr.3 @@ -0,0 +1,77 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wcschr.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt STRCHR 3 +.Os +.Sh NAME +.Nm wcschr +.Nd locate first occurrence of a wide character in a wide string +.Sh SYNOPSIS +.Fd #include +.Ft wchar_t * +.Fn wcschr "const wchar_t *s" "wchar_t c" +.Sh DESCRIPTION +The +.Fn wcschr +function locates the first occurrence of the wide character +.Fa c +in the wide string +.Fa s . +The terminating null wide character is considered part of the wide string. +If +.Fa c +is the null wide character (L'\e0'), +.Fn wcschr +locates the terminating null wide character. +.Sh RETURN VALUES +The +.Fn wcschr +function returns a pointer to the located wide character or +.Dv NULL +if the wide character does not appear in the wide string. +.Sh SEE ALSO +.Xr wcscspn 3 , +.Xr wcspbrk 3 , +.Xr wcsrchr 3 , +.Xr wcsspn 3 , +.Xr wcsstr 3 , +.Xr wcstok 3 , +.Xr wmemchr 3 +.Sh STANDARDS +The +.Fn wcschr +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wcscmp.3 b/src/lib/libc/string/wcscmp.3 new file mode 100644 index 00000000..15952b90 --- /dev/null +++ b/src/lib/libc/string/wcscmp.3 @@ -0,0 +1,82 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wcscmp.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSCMP 3 +.Os +.Sh NAME +.Nm wcscmp , +.Nm wcsncmp +.Nd compare wide strings +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn wcscmp "const wchar_t *s1" "const wchar_t *s2" +.Ft int +.Fn wcsncmp "const wchar_t *s1" "const wchar_t *s2" "size_t len" +.Sh DESCRIPTION +The +.Fn wcscmp +and +.Fn wcsncmp +functions lexicographically compare the wide strings +.Fa s1 +and +.Fa s2 . +The +.Fn wcsncmp +compares at most +.Fa len +wide characters. +.Sh RETURN VALUES +The +.Fn wcscmp +and +.Fn wcsncmp +functions return an integer greater than, equal to, or less than 0, according +to whether the wide string +.Fa s1 +is greater than, equal to, or less than the wide string +.Fa s2 . +.Sh SEE ALSO +.Xr wcscasecmp 3 , +.Xr wmemcmp 3 +.Sh STANDARDS +The +.Fn wcscmp +and +.Fn wcsncmp +functions conform to +.St -isoC-99 +and were first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wcscpy.3 b/src/lib/libc/string/wcscpy.3 new file mode 100644 index 00000000..a71d54f8 --- /dev/null +++ b/src/lib/libc/string/wcscpy.3 @@ -0,0 +1,97 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wcscpy.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSCPY 3 +.Os +.Sh NAME +.Nm wcscpy , +.Nm wcsncpy +.Nd copy wide strings +.Sh SYNOPSIS +.Fd #include +.Ft wchar_t * +.Fn wcscpy "wchar_t * restrict dst" "const wchar_t * restrict src" +.Ft wchar_t * +.Fo wcsncpy +.Fa "wchar_t * restrict dst" +.Fa "const wchar_t * restrict src" +.Fa "size_t len" +.Fc +.Sh DESCRIPTION +The +.Fn wcscpy +function copies the wide string +.Fa src +to +.Fa dst +(including the terminating null wide character). +.Pp +The +.Fn wcsncpy +function copies not more than +.Fa len +wide characters to +.Fa dst , +appending null wide characters if the length of +.Fa src +is less than +.Fa len , +and +.Em not +terminating +.Fa dst +if the length of +.Fa src +is greater than or equal to +.Fa len . +.Sh RETURN VALUES +The +.Fn wcscpy +and +.Fn wcsncpy +functions return +.Fa dst . +.Sh SEE ALSO +.Xr wcslcpy 3 , +.Xr wmemcpy 3 , +.Xr wmemmove 3 +.Sh STANDARDS +The +.Fn wcscpy +and +.Fn wcsncpy +functions conform to +.St -isoC-99 +and were first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wcscspn.3 b/src/lib/libc/string/wcscspn.3 new file mode 100644 index 00000000..7623e998 --- /dev/null +++ b/src/lib/libc/string/wcscspn.3 @@ -0,0 +1,75 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wcscspn.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSCSPN 3 +.Os +.Sh NAME +.Nm wcscspn +.Nd span the complement of a wide string +.Sh SYNOPSIS +.Fd #include +.Ft size_t +.Fn wcscspn "const wchar_t *s" "const wchar_t *charset" +.Sh DESCRIPTION +The +.Fn wcscspn +function spans the initial part of the wide string +.Fa s +as long as the wide characters from +.Fa s +do not occur in string +.Fa charset +(it spans the +.Em complement +of +.Fa charset ) . +.Sh RETURN VALUES +The +.Fn wcscspn +function returns the number of wide characters spanned. +.Sh SEE ALSO +.Xr wcschr 3 , +.Xr wcspbrk 3 , +.Xr wcsrchr 3 , +.Xr wcsspn 3 , +.Xr wcsstr 3 , +.Xr wcstok 3 , +.Xr wmemchr 3 +.Sh STANDARDS +The +.Fn wcscspn +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wcslcpy.3 b/src/lib/libc/string/wcslcpy.3 new file mode 100644 index 00000000..6f068dc9 --- /dev/null +++ b/src/lib/libc/string/wcslcpy.3 @@ -0,0 +1,139 @@ +.\" $OpenBSD: wcslcpy.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.\" Copyright (c) 1998, 2000 Todd C. Miller +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSLCPY 3 +.Os +.Sh NAME +.Nm wcslcpy , +.Nm wcslcat +.Nd size-bounded wide string copying and concatenation +.Sh SYNOPSIS +.Fd #include +.Ft size_t +.Fn wcslcpy "wchar_t *dst" "const wchar_t *src" "size_t size" +.Ft size_t +.Fn wcslcat "wchar_t *dst" "const wchar_t *src" "size_t size" +.Sh DESCRIPTION +The +.Fn wcslcpy +and +.Fn wcslcat +functions copy and concatenate wide strings respectively. +They are designed to be safer, more consistent, and less error prone +replacements for +.Xr wcsncpy 3 +and +.Xr wcsncat 3 . +Unlike those functions, +.Fn wcslcpy +and +.Fn wcslcat +take the full size of the buffer (not just the length) and guarantee to +terminate the result with a null wide character (as long as +.Fa size +is larger than 0 or, in the case of +.Fn wcslcat , +as long as there is at least one wide character free in +.Fa dst ) . +Note that a wide character for the null wide character should be included in +.Fa size . +Also note that +.Fn wcslcpy +and +.Fn wcslcat +only operate on wide strings that are terminated with a null wide character +(L'\e0'). +This means that for +.Fn wcslcpy +.Fa src +must be terminated with a null wide character and for +.Fn wcslcat +both +.Fa src +and +.Fa dst +must be terminated with a null wide character. +.Pp +The +.Fn wcslcpy +function copies up to +.Fa size +\(mi 1 wide characters from the wide string +.Fa src +to +.Fa dst , +terminating the result with a null wide character. +.Pp +The +.Fn wcslcat +function appends the wide string +.Fa src +to the end of +.Fa dst . +It will append at most +.Fa size +\(mi wcslen(dst) \(mi 1 wide characters, terminating the result with a null +wide character. +.Sh RETURN VALUES +The +.Fn wcslcpy +and +.Fn wcslcat +functions return the total length of the wide string they tried to create. +For +.Fn wcslcpy +that means the length of +.Fa src . +For +.Fn wcslcat +that means the initial length of +.Fa dst +plus +the length of +.Fa src . +While this may seem somewhat confusing, it was done to make +truncation detection simple. +.Pp +Note, however, that if +.Fn wcslcat +traverses +.Fa size +wide characters without finding a null wide character, the length of the +string is considered to be +.Fa size +and the destination wide string will not be terminated with a null wide +character (since there was no space for it). +This keeps +.Fn wcslcat +from running off the end of a wide string. +In practice this should not happen (as it means that either +.Fa size +is incorrect or that +.Fa dst +is not terminated with a null wide character). +The check exists to prevent potential security problems in incorrect code. +.Sh SEE ALSO +.Xr swprintf 3 , +.Xr wcsncat 3 , +.Xr wcsncpy 3 +.Sh HISTORY +The +.Fn wcslcpy +and +.Fn wcslcat +functions first appeared in +.Ox 3.8 . diff --git a/src/lib/libc/string/wcslen.3 b/src/lib/libc/string/wcslen.3 new file mode 100644 index 00000000..cf4813c4 --- /dev/null +++ b/src/lib/libc/string/wcslen.3 @@ -0,0 +1,62 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wcslen.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSLEN 3 +.Os +.Sh NAME +.Nm wcslen +.Nd find length of a wide string +.Sh SYNOPSIS +.Fd #include +.Ft size_t +.Fn wcslen "const wchar_t *s" +.Sh DESCRIPTION +The +.Fn wcslen +function computes the length of the wide string +.Fa s . +.Sh RETURN VALUES +The +.Fn wcslen +function returns the number of wide characters that precede the terminating +null wide character. +.Sh SEE ALSO +.Xr wcswidth 3 +.Sh STANDARDS +The +.Fn wcslen +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wcspbrk.3 b/src/lib/libc/string/wcspbrk.3 new file mode 100644 index 00000000..81f08a8f --- /dev/null +++ b/src/lib/libc/string/wcspbrk.3 @@ -0,0 +1,73 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wcspbrk.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSPBRK 3 +.Os +.Sh NAME +.Nm wcspbrk +.Nd locate multiple wide characters in a wide string +.Sh SYNOPSIS +.Fd #include +.Ft wchar_t * +.Fn wcspbrk "const wchar_t *s" "const wchar_t *charset" +.Sh DESCRIPTION +The +.Fn wcspbrk +function locates in the wide string +.Fa s +the first occurrence of any wide character in the wide string +.Fa charset +and returns a pointer to this wide character. +If no wide characters from +.Fa charset +occur anywhere in +.Fa s , +.Fn wcspbrk +returns +.Dv NULL . +.Sh SEE ALSO +.Xr wmemchr 3 , +.Xr wcschr 3 , +.Xr wcscspn 3 , +.Xr wcsrchr 3 , +.Xr wcsspn 3 , +.Xr wcsstr 3 , +.Xr wcstok 3 +.Sh STANDARDS +The +.Fn wcspbrk +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wcsrchr.3 b/src/lib/libc/string/wcsrchr.3 new file mode 100644 index 00000000..5e0c1f88 --- /dev/null +++ b/src/lib/libc/string/wcsrchr.3 @@ -0,0 +1,77 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wcsrchr.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSRCHR 3 +.Os +.Sh NAME +.Nm wcsrchr +.Nd locate last occurrence of a wide character in a wide string +.Sh SYNOPSIS +.Fd #include +.Ft wchar_t * +.Fn wcsrchr "const wchar_t *s" "wchar_t c" +.Sh DESCRIPTION +The +.Fn wcsrchr +function locates the last occurrence of the wide character +.Fa c +in the wide string +.Fa s . +The terminating null wide character is considered part of the wide string. +If +.Fa c +is the null wide character (L'\e0'), +.Fn wcsrchr +locates the terminating null wide character. +.Sh RETURN VALUES +The +.Fn wcsrchr +function returns a pointer to the located wide character or +.Dv NULL +if the wide character does not appear in the wide string. +.Sh SEE ALSO +.Xr wcschr 3 , +.Xr wcscspn 3 , +.Xr wcspbrk 3 , +.Xr wcsspn 3 , +.Xr wcsstr 3 , +.Xr wcstok 3 , +.Xr wmemchr 3 +.Sh STANDARDS +The +.Fn wcsrchr +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wcsspn.3 b/src/lib/libc/string/wcsspn.3 new file mode 100644 index 00000000..c73e1307 --- /dev/null +++ b/src/lib/libc/string/wcsspn.3 @@ -0,0 +1,71 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wcsspn.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSSPN 3 +.Os +.Sh NAME +.Nm wcsspn +.Nd span a wide string +.Sh SYNOPSIS +.Fd #include +.Ft size_t +.Fn wcsspn "const wchar_t *s" "const wchar_t *charset" +.Sh DESCRIPTION +The +.Fn wcsspn +function spans the initial part of the wide string +.Fa s +as long as the wide characters from +.Fa s +occur in the wide string +.Fa charset . +.Sh RETURN VALUES +The +.Fn wcsspn +function returns the number of wide characters spanned. +.Sh SEE ALSO +.Xr wcschr 3 , +.Xr wcscspn 3 , +.Xr wcspbrk 3 , +.Xr wcsrchr 3 , +.Xr wcsstr 3 , +.Xr wcstok 3 , +.Xr wmemchr 3 +.Sh STANDARDS +The +.Fn wcsspn +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wcsstr.3 b/src/lib/libc/string/wcsstr.3 new file mode 100644 index 00000000..dc99b706 --- /dev/null +++ b/src/lib/libc/string/wcsstr.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wcsstr.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WCSSTR 3 +.Os +.Sh NAME +.Nm wcsstr +.Nd locate a wide substring in a wide string +.Sh SYNOPSIS +.Fd #include +.Ft wchar_t * +.Fn wcsstr "const wchar_t *big" "const wchar_t *little" +.Sh DESCRIPTION +The +.Fn wcsstr +function locates the first occurrence of the wide string +.Fa little +in the wide string +.Fa big . +.Pp +If +.Fa little +is an empty wide string, +.Fa big +is returned; +if +.Fa little +occurs nowhere in +.Fa big , +.Dv NULL +is returned; +otherwise a pointer to the first wide character of the first occurrence of +.Fa little +is returned. +.Sh SEE ALSO +.Xr wcschr 3 , +.Xr wcscspn 3 , +.Xr wcspbrk 3 , +.Xr wcsrchr 3 , +.Xr wcsspn 3 , +.Xr wcstok 3 , +.Xr wmemchr 3 , +.Sh STANDARDS +The +.Fn wcsstr +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wmemchr.3 b/src/lib/libc/string/wmemchr.3 index 529f27b0..40a68bf2 100644 --- a/src/lib/libc/string/wmemchr.3 +++ b/src/lib/libc/string/wmemchr.3 @@ -1,9 +1,5 @@ -.\" $OpenBSD: wmemchr.3,v 1.6 2011/05/28 17:12:43 jmc Exp $ -.\" -.\" $NetBSD: wmemchr.3,v 1.9 2003/09/08 17:54:33 wiz Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, @@ -33,123 +29,45 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" from: @(#)strcpy.3 8.1 (Berkeley) 6/4/93 +.\" $OpenBSD: wmemchr.3,v 1.7 2011/07/09 16:32:11 nicm Exp $ .\" -.Dd $Mdocdate: May 28 2011 $ +.Dd $Mdocdate: July 9 2011 $ .Dt WMEMCHR 3 .Os .Sh NAME -.Nm wmemchr , -.Nm wmemcmp , -.Nm wmemcpy , -.Nm wmemmove , -.Nm wmemset , -.Nm wcscat , -.Nm wcschr , -.Nm wcscmp , -.Nm wcscasecmp , -.Nm wcscpy , -.Nm wcscspn , -.Nm wcslcat , -.Nm wcslcpy , -.Nm wcslen , -.Nm wcsncat , -.Nm wcsncmp , -.Nm wcsncasecmp , -.Nm wcsncpy , -.Nm wcspbrk , -.Nm wcsrchr , -.Nm wcsspn , -.Nm wcsstr -.Nd wide-character string manipulation operations +.Nm wmemchr +.Nd locate wide character in wide string .Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wmemchr "const wchar_t *s" "wchar_t c" "size_t n" -.Ft int -.Fn wmemcmp "const wchar_t *s1" "const wchar_t *s2" "size_t n" -.Ft wchar_t * -.Fn wmemcpy "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n" -.Ft wchar_t * -.Fn wmemmove "wchar_t *s1" "const wchar_t *s2" "size_t n" -.Ft wchar_t * -.Fn wmemset "wchar_t *s" "wchar_t c" "size_t n" -.Ft wchar_t * -.Fn wcscat "wchar_t * restrict s1" "const wchar_t * restrict s2" -.Ft wchar_t * -.Fn wcschr "const wchar_t *s" "wchar_t c" -.Ft int -.Fn wcscmp "const wchar_t *s1" "const wchar_t *s2" -.Ft int -.Fn wcscasecmp "const wchar_t *s1" "const wchar_t *s2" -.Ft wchar_t * -.Fn wcscpy "wchar_t * restrict s1" "const wchar_t * restrict s2" -.Ft size_t -.Fn wcscspn "const wchar_t *s1" "const wchar_t *s2" -.Ft size_t -.Fn wcslcat "wchar_t *s1" "const wchar_t *s2" "size_t n" -.Ft size_t -.Fn wcslcpy "wchar_t *s1" "const wchar_t *s2" "size_t n" -.Ft size_t -.Fn wcslen "const wchar_t *s" -.Ft wchar_t * -.Fn wcsncat "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n" -.Ft int -.Fn wcsncmp "const wchar_t *s1" "const wchar_t * s2" "size_t n" -.Ft int -.Fn wcsncasecmp "const wchar_t *s1" "const wchar_t * s2" "size_t n" -.Ft wchar_t * -.Fn wcsncpy "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n" -.Ft wchar_t * -.Fn wcspbrk "const wchar_t *s1" "const wchar_t *s2" -.Ft wchar_t * -.Fn wcsrchr "const wchar_t *s" "wchar_t c" -.Ft size_t -.Fn wcsspn "const wchar_t *s1" "const wchar_t *s2" +.Fd #include .Ft wchar_t * -.Fn wcsstr "const wchar_t *s1" "const wchar_t *s2" +.Fn memchr "const wchar_t *b" "wchar_t c" "size_t len" .Sh DESCRIPTION -These functions implement string manipulation operations over wide-character -strings. -For a detailed description, refer to documents for the respective single-byte -counterpart, such as -.Xr memchr 3 . +The +.Fn wmemchr +function locates the first occurrence of +.Fa c +in wide string +.Fa b . +.Sh RETURN VALUES +The +.Fn wmemchr +function returns a pointer to the wide character located, or +.Dv NULL +if no such wide character exists within +.Fa len +wide characters. .Sh SEE ALSO -.Xr memchr 3 , -.Xr memcmp 3 , -.Xr memcpy 3 , -.Xr memmove 3 , -.Xr memset 3 , -.Xr strcasecmp 3 , -.Xr strcat 3 , -.Xr strchr 3 , -.Xr strcmp 3 , -.Xr strcpy 3 , -.Xr strcspn 3 , -.Xr strlcat 3 , -.Xr strlcpy 3 , -.Xr strlen 3 , -.Xr strncasecmp 3 , -.Xr strncat 3 , -.Xr strncmp 3 , -.Xr strncpy 3 , -.Xr strpbrk 3 , -.Xr strrchr 3 , -.Xr strspn 3 , -.Xr strstr 3 +.Xr wcschr 3 , +.Xr wcscspn 3 , +.Xr wcspbrk 3 , +.Xr wcsrchr 3 , +.Xr wcsspn 3 , +.Xr wcsstr 3 , +.Xr wcstok 3 .Sh STANDARDS -These functions conform to +The +.Fn memchr +function conforms to .St -isoC-99 -and were first introduced in -.St -isoC-amd1 , -except for -.Fn wcscasecmp -and -.Fn wcsncasecmp , -which conform to -.St -p1003.1-2008 , -and -.Fn wcslcat -and -.Fn wcslcpy , -which are extensions. +and was first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wmemcmp.3 b/src/lib/libc/string/wmemcmp.3 new file mode 100644 index 00000000..e1d56ec3 --- /dev/null +++ b/src/lib/libc/string/wmemcmp.3 @@ -0,0 +1,70 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wmemcmp.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WMEMCMP 3 +.Os +.Sh NAME +.Nm wmemcmp +.Nd compare wide strings +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn wmemcmp "const wchar_t *s1" "const wchar_t *s2" "size_t len" +.Sh DESCRIPTION +The +.Fn wmemcmp +function compares the wide string +.Fa s1 +against the wide string +.Fa s2 . +Both wide strings are assumed to be +.Fa len +wide characters long. +.Sh RETURN VALUES +The +.Fn wmemcmp +function returns zero if the two wide strings are identical, +otherwise the difference between the first two differing wide characters is +returned. +Zero-length wide strings are always identical. +.Sh SEE ALSO +.Xr wcscasecmp 3 , +.Xr wcscmp 3 , +.Sh STANDARDS +The +.Fn wmemcmp +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wmemcpy.3 b/src/lib/libc/string/wmemcpy.3 new file mode 100644 index 00000000..8f4293c9 --- /dev/null +++ b/src/lib/libc/string/wmemcpy.3 @@ -0,0 +1,77 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wmemcpy.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt MEMCPY 3 +.Os +.Sh NAME +.Nm wmemcpy +.Nd copy wide characters +.Sh SYNOPSIS +.Fd #include +.Ft wchar_t * +.Fn memcpy "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t len" +.Sh DESCRIPTION +The +.Fn wmemcpy +function copies +.Fa len +wide characters from buffer +.Fa src +to buffer +.Fa dst . +.Sh RETURN VALUES +The +.Fn wmemcpy +function returns the original value of +.Fa dst . +.Sh SEE ALSO +.Xr wcscpy 3 , +.Xr wcslcpy 3 , +.Xr wmemmove 3 +.Sh STANDARDS +The +.Fn wmemcpy +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 . +.Sh BUGS +In this implementation +.Fn wmemcpy +is implemented using +.Xr bcopy 3 , +and therefore the buffers may overlap. +On other systems, copying overlapping buffers may produce surprises. +A simpler solution is to not use +.Fn wmemcpy . diff --git a/src/lib/libc/string/wmemmove.3 b/src/lib/libc/string/wmemmove.3 new file mode 100644 index 00000000..b018bd5c --- /dev/null +++ b/src/lib/libc/string/wmemmove.3 @@ -0,0 +1,70 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wmemmove.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WMEMMOVE 3 +.Os +.Sh NAME +.Nm wmemmove +.Nd copy wide characters +.Sh SYNOPSIS +.Fd #include +.Ft wchar_t * +.Fn wmemmove "wchar_t *dst" "const wchar_t *src" "size_t len" +.Sh DESCRIPTION +The +.Fn wmemmove +function copies +.Fa len +wide characters from buffer +.Fa src +to buffer +.Fa dst . +The two buffers may overlap; +the copy is always done in a non-destructive manner. +.Sh RETURN VALUES +The +.Fn wmemmove +function returns the original value of +.Fa dst . +.Sh SEE ALSO +.Xr wcscpy 3 , +.Xr wcslcpy 3 , +.Xr wmemcpy 3 +.Sh STANDARDS +The +.Fn wmemmove +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 . diff --git a/src/lib/libc/string/wmemset.3 b/src/lib/libc/string/wmemset.3 new file mode 100644 index 00000000..c43fc107 --- /dev/null +++ b/src/lib/libc/string/wmemset.3 @@ -0,0 +1,64 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $OpenBSD: wmemset.3,v 1.1 2011/07/09 16:32:11 nicm Exp $ +.\" +.Dd $Mdocdate: July 9 2011 $ +.Dt WMEMSET 3 +.Os +.Sh NAME +.Nm wmemset +.Nd write a wide string +.Sh SYNOPSIS +.Fd #include +.Ft wchar_t * +.Fn wmemset "wchar_t *s" "wchar_t c" "size_t len" +.Sh DESCRIPTION +The +.Fn wmemset +function writes +.Fa len +wide characters of value +.Fa c +to the wide string +.Fa s . +.Sh RETURN VALUES +The +.Fn wmemset +function returns the original value of +.Fa s . +.Sh STANDARDS +The +.Fn memset +function conforms to +.St -isoC-99 +and was first introduced in +.St -isoC-amd1 .