From: Sascha Wildner Date: Sat, 31 May 2008 04:51:55 +0000 (+0000) Subject: Add some missing manual pages: wcscoll(3), wcswidth(3), wcsxfrm(3), and X-Git-Tag: v2.0.1~515 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/6d588d9f4d7a751401c4fa0952f7cdd72190f3f3 Add some missing manual pages: wcscoll(3), wcswidth(3), wcsxfrm(3), and wcwidth(3) Taken-from: NetBSD --- diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc index 39d77b9e73..8855f79668 100644 --- a/lib/libc/locale/Makefile.inc +++ b/lib/libc/locale/Makefile.inc @@ -1,4 +1,4 @@ -# $DragonFly: src/lib/libc/locale/Makefile.inc,v 1.12 2006/11/02 19:53:56 swildner Exp $ +# $DragonFly: src/lib/libc/locale/Makefile.inc,v 1.13 2008/05/31 04:51:55 swildner Exp $ .PATH: ${.CURDIR}/../libc/locale @@ -16,8 +16,8 @@ CFLAGS+= -I${.CURDIR}/../libc/locale MAN+= nl_langinfo.3 setlocale.3 MAN+= btowc.3 iswalnum.3 iswctype.3 towlower.3 towctrans.3 mblen.3 mbrlen.3 MAN+= mbrtowc.3 mbsinit.3 mbsrtowcs.3 mbstowcs.3 mbtowc.3 wcrtomb.3 -MAN+= wcsftime.3 wcsrtombs.3 wcstombs.3 wctob.3 wctomb.3 wctrans.3 wctype.3 -MAN+= wcstod.3 wcstol.3 +MAN+= wcscoll.3 wcsftime.3 wcstod.3 wcstol.3 wcsrtombs.3 wcstombs.3 wcsxfrm.3 +MAN+= wctob.3 wctomb.3 wctrans.3 wctype.3 wcwidth.3 MLINKS+=iswalnum.3 iswalpha.3 iswalnum.3 iswblank.3 MLINKS+=iswalnum.3 iswcntrl.3 iswalnum.3 iswdigit.3 diff --git a/lib/libc/locale/wcscoll.3 b/lib/libc/locale/wcscoll.3 new file mode 100644 index 0000000000..b8fdc91377 --- /dev/null +++ b/lib/libc/locale/wcscoll.3 @@ -0,0 +1,113 @@ +.\" $NetBSD: wcscoll.3,v 1.2 2006/10/14 07:44:58 wiz 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 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strcoll.3 8.1 (Berkeley) 6/4/93 +.\" FreeBSD: src/lib/libc/string/strcoll.3,v 1.11 2001/10/01 16:09:00 ru Exp +.\" FreeBSD: /repoman/r/ncvs/src/lib/libc/string/wcscoll.3,v 1.2 2002/12/09 14:04:05 ru Exp +.\" $DragonFly: src/lib/libc/locale/wcscoll.3,v 1.1 2008/05/31 04:51:55 swildner Exp $ +.\" +.Dd May 30, 2008 +.Dt WCSCOLL 3 +.Os +.Sh NAME +.Nm wcscoll +.Nd compare wide strings according to current collation +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In wchar.h +.Ft int +.Fn wcscoll "const wchar_t *s1" "const wchar_t *s2" +.Sh DESCRIPTION +The +.Fn wcscoll +function compares the nul-terminated strings +.Fa s1 +and +.Fa s2 +according to the current locale collation order. +In the +.Dq Li C +locale, +.Fn wcscoll +is equivalent to +.Fn wcscmp . +.Sh RETURN VALUES +The +.Fn wcscoll +function returns an integer greater than, equal to, or less than +0, if +.Fa s1 +is greater than, equal to, or less than +.Fa s2 . +.Pp +No return value is reserved to indicate errors; +callers should set +.Va errno +to 0 before calling +.Fn wcscoll . +If it is non-zero upon return from +.Fn wcscoll , +an error has occurred. +.Sh ERRORS +The +.Fn wcscoll +function will fail if: +.Bl -tag -width Er +.It Bq Er EILSEQ +An invalid wide character code was specified. +.It Bq Er ENOMEM +Cannot allocate enough memory for temporary buffers. +.El +.Sh SEE ALSO +.Xr setlocale 3 , +.Xr strcoll 3 , +.Xr wcscmp 3 , +.Xr wcsxfrm 3 +.Sh STANDARDS +The +.Fn wcscoll +function conforms to +.St -isoC-99 . +.Sh BUGS +The current implementation of +.Fn wcscoll +function disregards +.Dv LC_COLLATE +locales, and falls back to using the +.Fn wcscmp +function. diff --git a/lib/libc/locale/wcsxfrm.3 b/lib/libc/locale/wcsxfrm.3 new file mode 100644 index 0000000000..47edda63a1 --- /dev/null +++ b/lib/libc/locale/wcsxfrm.3 @@ -0,0 +1,108 @@ +.\" $NetBSD: wcsxfrm.3,v 1.3 2006/10/16 08:42:16 wiz 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 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. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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. +.\" +.\" @(#)strxfrm.3 8.1 (Berkeley) 6/4/93 +.\" FreeBSD: src/lib/libc/string/strxfrm.3,v 1.16 2002/09/06 11:24:06 tjr Exp +.\" FreeBSD: /repoman/r/ncvs/src/lib/libc/string/wcsxfrm.3,v 1.2 2002/12/09 14:04:05 ru Exp +.\" $DragonFly: src/lib/libc/locale/wcsxfrm.3,v 1.1 2008/05/31 04:51:55 swildner Exp $ +.\" +.Dd May 30, 2008 +.Dt WCSXFRM 3 +.Os +.Sh NAME +.Nm wcsxfrm +.Nd transform a wide string under locale +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In wchar.h +.Ft size_t +.Fn wcsxfrm "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t n" +.Sh DESCRIPTION +The +.Fn wcsxfrm +function transforms a nul-terminated wide character string pointed to by +.Fa src +according to the current locale collation order then copies the +transformed string into +.Fa dst . +No more than +.Fa n +wide characters are copied into +.Fa dst , +including the terminating nul character added. +If +.Fa n +is set to 0 +(it helps to determine an actual size needed for transformation), +.Fa dst +is permitted to be a null pointer. +.Pp +Comparing two strings using +.Fn wcscmp +after +.Fn wcsxfrm +is equivalent to comparing two original strings with +.Fn wcscoll . +.Sh RETURN VALUES +Upon successful completion, +.Fn wcsxfrm +returns the length of the transformed string not including +the terminating nul character. +If this value is +.Fa n +or more, the contents of +.Fa dst +are indeterminate. +.Sh SEE ALSO +.Xr setlocale 3 , +.Xr strxfrm 3 , +.Xr wcscmp 3 , +.Xr wcscoll 3 +.Sh STANDARDS +The +.Fn wcsxfrm +function conforms to +.St -isoC-99 . +.Sh BUGS +The current implementation of +.Fn wcsxfrm +function disregards +.Dv LC_COLLATE +locales, and falls back to using the +.Fn wcsncpy +function. diff --git a/lib/libc/locale/wcwidth.3 b/lib/libc/locale/wcwidth.3 new file mode 100644 index 0000000000..615cbeb59d --- /dev/null +++ b/lib/libc/locale/wcwidth.3 @@ -0,0 +1,90 @@ +.\" $NetBSD: wcwidth.3,v 1.3 2006/10/14 07:51:01 wiz Exp $ +.\" FreeBSD: src/lib/libc/locale/wcwidth.3,v 1.6 2004/08/17 04:56:03 trhodes Exp +.\" +.\" Copyright (c) 2002 Tim J. Robbins +.\" All rights reserved. +.\" +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $DragonFly: src/lib/libc/locale/wcwidth.3,v 1.1 2008/05/31 04:51:55 swildner Exp $ +.\" +.Dd May 30, 2008 +.Dt WCWIDTH 3 +.Os +.Sh NAME +.Nm wcwidth +.Nd "number of column positions of a wide-character code" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In wchar.h +.Ft int +.Fn wcwidth "wchar_t wc" +.Sh DESCRIPTION +The +.Fn wcwidth +function determines the number of column positions required to +display the wide character +.Fa wc . +.Sh RETURN VALUES +The +.Fn wcwidth +function returns 0 if the +.Fa wc +argument is a nul wide character (L'\e0'), +\-1 if +.Fa wc +is not printable, +otherwise it returns the number of column positions the +character occupies. +.Sh EXAMPLES +This code fragment reads text from standard input and +breaks lines that are more than 20 column positions wide, +similar to the +.Xr fold 1 +utility: +.Bd -literal -offset indent +wint_t ch; +int column, w; + +column = 0; +while ((ch = getwchar()) != WEOF) { + w = wcwidth(ch); + if (w \*[Gt] 0 \*[Am]\*[Am] column + w \*[Gt]= 20) { + putwchar(L'\en'); + column = 0; + } + putwchar(ch); + if (ch == L'\en') + column = 0; + else if (w \*[Gt] 0) + column += w; +} +.Ed +.Sh SEE ALSO +.Xr iswprint 3 , +.Xr wcswidth 3 +.Sh STANDARDS +The +.Fn wcwidth +function conforms to +.St -p1003.1-2001 . diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc index ddfee0b0bd..e82a77c7af 100644 --- a/lib/libc/string/Makefile.inc +++ b/lib/libc/string/Makefile.inc @@ -1,6 +1,6 @@ # @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 # $FreeBSD: src/lib/libc/string/Makefile.inc,v 1.19.2.5 2001/12/25 00:36:53 ache Exp $ -# $DragonFly: src/lib/libc/string/Makefile.inc,v 1.4 2005/08/26 22:03:26 joerg Exp $ +# $DragonFly: src/lib/libc/string/Makefile.inc,v 1.5 2008/05/31 04:51:55 swildner Exp $ .PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/string ${.CURDIR}/../libc/string @@ -28,7 +28,7 @@ MAN+= bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \ memcmp.3 memcpy.3 memmove.3 memset.3 rindex.3 strcasecmp.3 strcat.3 \ strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strdup.3 strerror.3 \ string.3 strlcpy.3 strlen.3 strmode.3 strpbrk.3 strrchr.3 strsep.3 \ - strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 wmemchr.3 + strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 wcswidth.3 wmemchr.3 MLINKS+=strcasecmp.3 strncasecmp.3 MLINKS+=strcat.3 strncat.3 diff --git a/lib/libc/string/wcswidth.3 b/lib/libc/string/wcswidth.3 new file mode 100644 index 0000000000..d75042657e --- /dev/null +++ b/lib/libc/string/wcswidth.3 @@ -0,0 +1,65 @@ +.\" $NetBSD: wcswidth.3,v 1.2 2006/10/16 08:48:45 wiz Exp $ +.\" FreeBSD: src/lib/libc/string/wcswidth.3,v 1.2 2002/12/09 14:04:05 ru Exp +.\" +.\" Copyright (c) 2002 Tim J. Robbins +.\" All rights reserved. +.\" +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +.\" +.\" $DragonFly: src/lib/libc/string/wcswidth.3,v 1.1 2008/05/31 04:51:55 swildner Exp $ +.\" +.Dd May 30, 2008 +.Dt WCSWIDTH 3 +.Os +.Sh NAME +.Nm wcswidth +.Nd "number of column positions in wide-character string" +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In wchar.h +.Ft int +.Fn wcswidth "const wchar_t *pwcs" "size_t n" +.Sh DESCRIPTION +The +.Fn wcswidth +function determines the number of column positions required for the first +.Fa n +characters of +.Fa pwcs , +or until a nul wide character (L'\e0') is encountered. +.Sh RETURN VALUES +The +.Fn wcswidth +function returns 0 if +.Fa pwcs +is an empty string (L""), +\-1 if a non-printing wide character is encountered, +otherwise it returns the number of column positions occupied. +.Sh SEE ALSO +.Xr iswprint 3 , +.Xr wcwidth 3 +.Sh STANDARDS +The +.Fn wcswidth +function conforms to +.St -p1003.1-2001 .