add wcsl{cat,cpy} - outside of ISO/IEC 9899:1999,
but i believe it should be there.
This commit is contained in:
parent
f4f13f67be
commit
2c828fd4c7
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.290 2000/12/22 04:59:41 itojun Exp $
|
||||
# $NetBSD: mi,v 1.291 2000/12/22 05:21:40 itojun Exp $
|
||||
./sys comp-sysutil-root
|
||||
./usr/bin/addr2line comp-miscutil-bin
|
||||
./usr/bin/ar comp-util-bin
|
||||
|
@ -2809,6 +2809,8 @@
|
|||
./usr/share/man/cat3/wcscmp.0 comp-c-catman
|
||||
./usr/share/man/cat3/wcscpy.0 comp-c-catman
|
||||
./usr/share/man/cat3/wcscspn.0 comp-c-catman
|
||||
./usr/share/man/cat3/wcslcat.0 comp-c-catman
|
||||
./usr/share/man/cat3/wcslcpy.0 comp-c-catman
|
||||
./usr/share/man/cat3/wcslen.0 comp-c-catman
|
||||
./usr/share/man/cat3/wcsncat.0 comp-c-catman
|
||||
./usr/share/man/cat3/wcsncmp.0 comp-c-catman
|
||||
|
@ -4610,6 +4612,8 @@
|
|||
./usr/share/man/man3/wcscmp.3 comp-c-man
|
||||
./usr/share/man/man3/wcscpy.3 comp-c-man
|
||||
./usr/share/man/man3/wcscspn.3 comp-c-man
|
||||
./usr/share/man/man3/wcslcat.3 comp-c-man
|
||||
./usr/share/man/man3/wcslcpy.3 comp-c-man
|
||||
./usr/share/man/man3/wcslen.3 comp-c-man
|
||||
./usr/share/man/man3/wcsncat.3 comp-c-man
|
||||
./usr/share/man/man3/wcsncmp.3 comp-c-man
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# from: @(#)Makefile.inc 5.1 (Berkeley) 2/18/91
|
||||
# $NetBSD: Makefile.inc,v 1.27 2000/12/22 04:59:41 itojun Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.28 2000/12/22 05:21:41 itojun Exp $
|
||||
|
||||
# locale sources
|
||||
.PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
|
||||
|
@ -7,7 +7,8 @@
|
|||
SRCS+= _def_messages.c _def_monetary.c _def_numeric.c _def_time.c \
|
||||
ctypeio.c iswctype.c localeconv.c nl_langinfo.c \
|
||||
setlocale.c setlocale_sb.c \
|
||||
wcscat.c wcschr.c wcscmp.c wcscpy.c wcscspn.c wcslen.c wcsncat.c \
|
||||
wcscat.c wcschr.c wcscmp.c wcscpy.c wcscspn.c wcslcat.c wcslcpy.c \
|
||||
wcslen.c wcsncat.c \
|
||||
wcsncmp.c wcsncpy.c wcspbrk.c wcsrchr.c wcsspn.c wcsstr.c wcswidth.c \
|
||||
wmemchr.c wmemcmp.c wmemcpy.c wmemmove.c wmemset.c
|
||||
MAN+= nl_langinfo.3 setlocale.3
|
||||
|
@ -35,7 +36,8 @@ MLINKS+=wmemchr.3 wmemcmp.3 wmemchr.3 wmemcpy.3 \
|
|||
wmemchr.3 wmemmove.3 wmemchr.3 wmemset.3 \
|
||||
wmemchr.3 wcscat.3 wmemchr.3 wcschr.3 \
|
||||
wmemchr.3 wcscmp.3 wmemchr.3 wcscpy.3 \
|
||||
wmemchr.3 wcscspn.3 wmemchr.3 wcslen.3 \
|
||||
wmemchr.3 wcscspn.3 wmemchr.3 wcslcat.3 \
|
||||
wmemchr.3 wcslcpy.3 wmemchr.3 wcslen.3 \
|
||||
wmemchr.3 wcsncat.3 wmemchr.3 wcsncmp.3 \
|
||||
wmemchr.3 wcsncpy.3 wmemchr.3 wcspbrk.3 \
|
||||
wmemchr.3 wcsrchr.3 wmemchr.3 wcsspn.3 \
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/* $NetBSD: wcslcat.c,v 1.1 2000/12/22 05:21:41 itojun Exp $ */
|
||||
/* from OpenBSD: strlcat.c,v 1.3 2000/11/24 11:10:02 itojun Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``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 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: wcslcat.c,v 1.1 2000/12/22 05:21:41 itojun Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <wchar.h>
|
||||
|
||||
/*
|
||||
* Appends src to string dst of size siz (unlike wcsncat, siz is the
|
||||
* full size of dst, not space left). At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz == 0).
|
||||
* Returns wcslen(initial dst) + wcslen(src); if retval >= siz,
|
||||
* truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
wcslcat(dst, src, siz)
|
||||
wchar_t *dst;
|
||||
const wchar_t *src;
|
||||
size_t siz;
|
||||
{
|
||||
register wchar_t *d = dst;
|
||||
register const wchar_t *s = src;
|
||||
register size_t n = siz;
|
||||
size_t dlen;
|
||||
|
||||
_DIAGASSERT(dst != NULL);
|
||||
_DIAGASSERT(src != NULL);
|
||||
|
||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
||||
while (*d != '\0' && n-- != 0)
|
||||
d++;
|
||||
dlen = d - dst;
|
||||
n = siz - dlen;
|
||||
|
||||
if (n == 0)
|
||||
return(dlen + wcslen(s));
|
||||
while (*s != '\0') {
|
||||
if (n != 1) {
|
||||
*d++ = *s;
|
||||
n--;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
*d = '\0';
|
||||
|
||||
return(dlen + (s - src)); /* count does not include NUL */
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/* $NetBSD: wcslcpy.c,v 1.1 2000/12/22 05:21:41 itojun Exp $ */
|
||||
/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
* 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``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 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: wcslcpy.c,v 1.1 2000/12/22 05:21:41 itojun Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <wchar.h>
|
||||
|
||||
/*
|
||||
* Copy src to string dst of size siz. At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz == 0).
|
||||
* Returns wcslen(src); if retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
wcslcpy(dst, src, siz)
|
||||
wchar_t *dst;
|
||||
const wchar_t *src;
|
||||
size_t siz;
|
||||
{
|
||||
register wchar_t *d = dst;
|
||||
register const wchar_t *s = src;
|
||||
register size_t n = siz;
|
||||
|
||||
_DIAGASSERT(dst != NULL);
|
||||
_DIAGASSERT(src != NULL);
|
||||
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0 && --n != 0) {
|
||||
do {
|
||||
if ((*d++ = *s++) == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
}
|
||||
|
||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||
if (n == 0) {
|
||||
if (siz != 0)
|
||||
*d = '\0'; /* NUL-terminate dst */
|
||||
while (*s++)
|
||||
;
|
||||
}
|
||||
|
||||
return(s - src - 1); /* count does not include NUL */
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: wmemchr.3,v 1.1 2000/12/22 04:59:41 itojun Exp $
|
||||
.\" $NetBSD: wmemchr.3,v 1.2 2000/12/22 05:21:41 itojun Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -51,6 +51,8 @@
|
|||
.Nm wcscmp ,
|
||||
.Nm wcscpy ,
|
||||
.Nm wcscspn ,
|
||||
.Nm wcslcat ,
|
||||
.Nm wcslcpy ,
|
||||
.Nm wcslen ,
|
||||
.Nm wcsncat ,
|
||||
.Nm wcsncmp ,
|
||||
|
@ -85,6 +87,10 @@
|
|||
.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 *s1" "const wchar_t *s2" "size_t n"
|
||||
|
@ -125,4 +131,9 @@ For detailed description, refer to documents for singlebyte counterpart, like
|
|||
.Xr strspn 3 ,
|
||||
.Xr strstr 3
|
||||
.Sh STANDARDS
|
||||
The functions conform to ISO/IEC 9899:1999(E).
|
||||
The functions,
|
||||
except
|
||||
.Nm wcslcat
|
||||
and
|
||||
.Nm wcslcpy ,
|
||||
conform to ISO/IEC 9899:1999(E).
|
||||
|
|
Loading…
Reference in New Issue