* libc/include/wchar.h (wcsdup, _wcsdup_r): Declare.
* libc/string/Makefile.am: Add wcsdup.c. * libc/string/Makefile.in: Regenerate. * libc/string/strings.tex: Add wcsdup documentation reference. * libc/string/wcsdup.c: New file.
This commit is contained in:
parent
7b011fb192
commit
159a17c8c8
|
@ -1,3 +1,11 @@
|
|||
2009-03-15 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* libc/include/wchar.h (wcsdup, _wcsdup_r): Declare.
|
||||
* libc/string/Makefile.am: Add wcsdup.c.
|
||||
* libc/string/Makefile.in: Regenerate.
|
||||
* libc/string/strings.tex: Add wcsdup documentation reference.
|
||||
* libc/string/wcsdup.c: New file.
|
||||
|
||||
2009-03-14 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* libc/include/stdlib.h (_mkstemp_r, _mktemp_r): Move out of
|
||||
|
|
|
@ -72,6 +72,8 @@ int _EXFUN(wcscmp, (const wchar_t *, const wchar_t *));
|
|||
int _EXFUN(wcscoll, (const wchar_t *, const wchar_t *));
|
||||
wchar_t *_EXFUN(wcscpy, (wchar_t * , const wchar_t *));
|
||||
wchar_t *_EXFUN(wcpcpy, (wchar_t * , const wchar_t *));
|
||||
wchar_t *_EXFUN(wcsdup, (const wchar_t *));
|
||||
wchar_t *_EXFUN(_wcsdup_r, (struct _reent *, const wchar_t * ));
|
||||
size_t _EXFUN(wcscspn, (const wchar_t *, const wchar_t *));
|
||||
size_t _EXFUN(wcsftime, (wchar_t *, size_t, const wchar_t *, const struct tm *));
|
||||
size_t _EXFUN(wcslcat, (wchar_t *, const wchar_t *, size_t));
|
||||
|
|
|
@ -85,7 +85,8 @@ ELIX_2_SOURCES = \
|
|||
strcasestr.c \
|
||||
strndup_r.c \
|
||||
wcpcpy.c \
|
||||
wcpncpy.c
|
||||
wcpncpy.c \
|
||||
wcsdup.c
|
||||
endif !ELIX_LEVEL_1
|
||||
|
||||
if ELIX_LEVEL_1
|
||||
|
@ -130,7 +131,7 @@ memcmp.def strchr.def strlen.def strnlen.def strspn.def \
|
|||
strcasecmp.def strncasecmp.def strcasestr.def strlwr.def strupr.def \
|
||||
memccpy.def mempcpy.def stpcpy.def stpncpy.def \
|
||||
wcscasecmp.def wcscat.def wcschr.def wcscmp.def wcscoll.def \
|
||||
wcscpy.def wcscspn.def wcpcpy.def wcpncpy.def \
|
||||
wcscpy.def wcscspn.def wcpcpy.def wcpncpy.def wcsdup \
|
||||
wcslcat.def wcslcpy.def wcslen.def wcsncasecmp.def wcsncat.def \
|
||||
wcsncmp.def wcsncpy.def wcsnlen.def wcspbrk.def \
|
||||
wcsrchr.def wcsspn.def wcsstr.def wcstok.def \
|
||||
|
|
|
@ -100,7 +100,8 @@ am__objects_1 = lib_a-bcopy.$(OBJEXT) lib_a-bzero.$(OBJEXT) \
|
|||
@ELIX_LEVEL_1_FALSE@ lib_a-strcasestr.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@ lib_a-strndup_r.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@ lib_a-wcpcpy.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@ lib_a-wcpncpy.$(OBJEXT)
|
||||
@ELIX_LEVEL_1_FALSE@ lib_a-wcpncpy.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@ lib_a-wcsdup.$(OBJEXT)
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_3 = lib_a-memmem.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-wcscasecmp.$(OBJEXT) \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-wcsncasecmp.$(OBJEXT)
|
||||
|
@ -125,7 +126,7 @@ am__objects_4 = bcopy.lo bzero.lo index.lo memchr.lo memcmp.lo \
|
|||
@ELIX_LEVEL_1_FALSE@am__objects_5 = bcmp.lo memccpy.lo mempcpy.lo \
|
||||
@ELIX_LEVEL_1_FALSE@ stpcpy.lo stpncpy.lo strndup.lo \
|
||||
@ELIX_LEVEL_1_FALSE@ strcasestr.lo strndup_r.lo wcpcpy.lo \
|
||||
@ELIX_LEVEL_1_FALSE@ wcpncpy.lo
|
||||
@ELIX_LEVEL_1_FALSE@ wcpncpy.lo wcsdup.lo
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_6 = memmem.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ wcscasecmp.lo \
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ wcsncasecmp.lo
|
||||
|
@ -391,7 +392,8 @@ GENERAL_SOURCES = \
|
|||
@ELIX_LEVEL_1_FALSE@ strcasestr.c \
|
||||
@ELIX_LEVEL_1_FALSE@ strndup_r.c \
|
||||
@ELIX_LEVEL_1_FALSE@ wcpcpy.c \
|
||||
@ELIX_LEVEL_1_FALSE@ wcpncpy.c
|
||||
@ELIX_LEVEL_1_FALSE@ wcpncpy.c \
|
||||
@ELIX_LEVEL_1_FALSE@ wcsdup.c
|
||||
|
||||
@ELIX_LEVEL_1_TRUE@ELIX_2_SOURCES =
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ELIX_4_SOURCES = \
|
||||
|
@ -420,7 +422,7 @@ memcmp.def strchr.def strlen.def strnlen.def strspn.def \
|
|||
strcasecmp.def strncasecmp.def strcasestr.def strlwr.def strupr.def \
|
||||
memccpy.def mempcpy.def stpcpy.def stpncpy.def \
|
||||
wcscasecmp.def wcscat.def wcschr.def wcscmp.def wcscoll.def \
|
||||
wcscpy.def wcscspn.def wcpcpy.def wcpncpy.def \
|
||||
wcscpy.def wcscspn.def wcpcpy.def wcpncpy.def wcsdup \
|
||||
wcslcat.def wcslcpy.def wcslen.def wcsncasecmp.def wcsncat.def \
|
||||
wcsncmp.def wcsncpy.def wcsnlen.def wcspbrk.def \
|
||||
wcsrchr.def wcsspn.def wcsstr.def wcstok.def \
|
||||
|
@ -955,6 +957,12 @@ lib_a-wcpncpy.o: wcpncpy.c
|
|||
lib_a-wcpncpy.obj: wcpncpy.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcpncpy.obj `if test -f 'wcpncpy.c'; then $(CYGPATH_W) 'wcpncpy.c'; else $(CYGPATH_W) '$(srcdir)/wcpncpy.c'; fi`
|
||||
|
||||
lib_a-wcsdup.o: wcsdup.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcsdup.o `test -f 'wcsdup.c' || echo '$(srcdir)/'`wcsdup.c
|
||||
|
||||
lib_a-wcsdup.obj: wcsdup.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcsdup.obj `if test -f 'wcsdup.c'; then $(CYGPATH_W) 'wcsdup.c'; else $(CYGPATH_W) '$(srcdir)/wcsdup.c'; fi`
|
||||
|
||||
lib_a-memmem.o: memmem.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memmem.o `test -f 'memmem.c' || echo '$(srcdir)/'`memmem.c
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ managing areas of memory. The corresponding declarations are in
|
|||
* strxfrm:: Transform string
|
||||
* swab:: Swap adjacent bytes
|
||||
* wcscasecmp:: Compare wide character strings ignoring case
|
||||
* wcsdup:: Wide character string duplicate
|
||||
* wcsncasecmp:: Compare wide character strings ignoring case
|
||||
@end menu
|
||||
|
||||
|
@ -173,5 +174,8 @@ managing areas of memory. The corresponding declarations are in
|
|||
@page
|
||||
@include string/wcscasecmp.def
|
||||
|
||||
@page
|
||||
@include string/wcsdup.def
|
||||
|
||||
@page
|
||||
@include string/wcsncasecmp.def
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
FUNCTION
|
||||
<<wcsdup>>---wide character string duplicate
|
||||
|
||||
INDEX
|
||||
wcsdup
|
||||
INDEX
|
||||
_wcsdup_r
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <wchar.h>
|
||||
wchar_t *wcsdup(const wchar_t *<[str]>);
|
||||
|
||||
#include <wchar.h>
|
||||
wchar_t *_wcsdup_r(struct _reent *<ptr>, const wchar_t *<[str]>);
|
||||
|
||||
TRAD_SYNOPSIS
|
||||
#include <wchar.h>
|
||||
wchar_t *wcsdup(<ptr>, <[str]>)
|
||||
struct _reent *<ptr>;
|
||||
wchar_t *<[str]>;
|
||||
|
||||
DESCRIPTION
|
||||
<<wcsdup>> allocates a new wide character string using <<malloc>,
|
||||
and copies the content of the argument <[str]> into the newly
|
||||
allocated string, thus making a copy of <[str]>.
|
||||
|
||||
RETURNS
|
||||
<<wcsdup>> returns a pointer to the copy of <[str]> if enough
|
||||
memory for the copy was available. Otherwise it returns NULL
|
||||
and errno is set to ENOMEM.
|
||||
|
||||
PORTABILITY
|
||||
POSIX-1.2008
|
||||
|
||||
QUICKREF
|
||||
wcsdup
|
||||
*/
|
||||
|
||||
#include <reent.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
|
||||
wchar_t *
|
||||
_wcsdup_r (struct _reent *p, const wchar_t *str)
|
||||
{
|
||||
size_t len = wcslen (str) + 1;
|
||||
wchar_t *copy = _malloc_r (p, len * sizeof (wchar_t));
|
||||
if (copy)
|
||||
wmemcpy (copy, str, len);
|
||||
return copy;
|
||||
}
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
|
||||
wchar_t *
|
||||
wcsdup (const wchar_t *str)
|
||||
{
|
||||
return _wcsdup_r (_REENT, str);
|
||||
}
|
||||
|
||||
#endif /* !_REENT_ONLY */
|
Loading…
Reference in New Issue