C library: Add functions btowc, mbrtowc, mbtowc, wcscmp, wcscoll, wmemmove

This commit is contained in:
Alan Carvalho de Assis 2016-10-18 08:05:28 -06:00 committed by Gregory Nutt
parent 626408bc29
commit f01c5b79fc
13 changed files with 457 additions and 94 deletions

View File

@ -65,6 +65,8 @@
"lio_listio","aio.h","defined(CONFIG_FS_AIO)","int","int","FAR struct aiocb *const []|FAR struct aiocb *const *","int","FAR struct sigevent *"
"llabs","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long int","long long int"
"match","nuttx/lib/regex.h","","int","const char *","const char *"
"mbrtowc","wchar.h",""defined(CONFIG_LIBC_WCHAR)","size_t","wchar_t *","const char *", "size_t", "mbstate_t *"
"mbtowc","wchar.h",""defined(CONFIG_LIBC_WCHAR)","int","wchar_t *","const wchar_t *", "size_t"
"memccpy","string.h","","FAR void","FAR void *","FAR const void *","int c","size_t"
"memchr","string.h","","FAR void","FAR const void *","int c","size_t"
"memcmp","string.h","","int","FAR const void *","FAR const void *","size_t"
@ -174,4 +176,12 @@
"vsprintf","stdio.h","","int","FAR char *","const char *","va_list"
"vsscanf","stdio.h","","int","char *","const char *","va_list"
"vsyslog","syslog.h","","int","int","FAR const char *","va_list"
"wcscmp","wchar.h","defined(CONFIG_LIBC_WCHAR)","int", "const wchar_t *", "const wchar_t *"
"wcscoll","wchar.h","defined(CONFIG_LIBC_WCHAR)","int", "const wchar_t *", "const wchar_t *"
"wcslen","wchar.h","defined(CONFIG_LIBC_WCHAR)","size_t", "const wchar_t *"
"wmemchr","wchar.h","defined(CONFIG_LIBC_WCHAR)","wchar_t *", "wchar_t *", "wchar_t", "size_t"
"wmemcmp","wchar.h","defined(CONFIG_LIBC_WCHAR)","int", "wchar_t *", "wchar_t *", "size_t"
"wmemcpy","wchar.h","defined(CONFIG_LIBC_WCHAR)","wchat_t *", "wchar_t *", "wchar_t *", "size_t"
"wmemmove","wchar.h","defined(CONFIG_LIBC_WCHAR)","wchat_t *", "wchar_t *", "wchar_t *", "size_t"
"wmemset","wchar.h","defined(CONFIG_LIBC_WCHAR)","wchat_t *", "wchar_t *", "wchar_t", "size_t"
"_warn","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG_WARN)","int","const char *","..."

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -35,9 +35,11 @@
# Add the internal C files to the build
CSRCS += lib_wcslen.c lib_wmemchr.c lib_wmemcmp.c lib_wmemcpy.c lib_wmemset.c
CSRCS += lib_wcscmp.c lib_wcslen.c lib_wmemchr.c lib_wmemcmp.c lib_wmemcpy.c
CSRCS += lib_wmemmove.c lib_wmemset.c lib_mbtowc.c lib_btowc.c lib_mbrtowc.c
# Add the wchar directory to the build
DEPPATH += --dep-path wchar
VPATH += :wchar

76
libc/wchar/lib_btowc.c Normal file
View File

@ -0,0 +1,76 @@
/****************************************************************************
* libc/wchar/lib_btowc.c
*
* Copyright (c)1999 Citrus Project,
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: btowc
*
* Description:
* Minimal byte to wide char converter
*
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
wint_t btowc(int c)
{
int retval = 0;
wchar_t pwc;
unsigned char b;
if (c == EOF)
{
return WEOF;
}
b = (unsigned char)c;
retval = mbtowc(&pwc, &b, 1);
if (retval != 0 && retval != 1)
{
return WEOF;
}
return (wint_t)pwc;
}
#endif

77
libc/wchar/lib_mbrtowc.c Normal file
View File

@ -0,0 +1,77 @@
/****************************************************************************
* libc/wchar/lib_mbrtowc.c
*
* Copyright (c)1999 Citrus Project,
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: mbrtowc
*
* Description:
* Convert a multibyte sequence to a wide character
*
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
size_t mbrtowc(FAR wchar_t *pwc, FAR const char *s, size_t n, mbstate_t *ps)
{
int retval = 0;
if (s == NULL)
{
retval = mbtowc(NULL, "", 1);
}
else
{
retval = mbtowc(pwc, s, n);
}
if (retval == -1)
{
return (size_t) (-1);
}
else
{
return (size_t) retval;
}
}
#endif

71
libc/wchar/lib_mbtowc.c Normal file
View File

@ -0,0 +1,71 @@
/****************************************************************************
* libc/wchar/lib_mbtowc.c
*
* Copyright (c)1999 Citrus Project,
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdlib.h>
#include <wchar.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: mbtowc.c
*
* Description:
* Minimal multibyte to wide char converter
*
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
int mbtowc(FAR wchar_t * pwc, FAR const char *s, size_t n)
{
if (s == NULL)
{
return 0;
}
if (n == 0)
{
return -1;
}
if (pwc)
{
*pwc = (wchar_t) * s;
}
return (*s != '\0');
}
#endif

70
libc/wchar/lib_wcscmp.c Normal file
View File

@ -0,0 +1,70 @@
/****************************************************************************
* libc/wchar/lib_wcscmp.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <string.h>
#include <wchar.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: wcscmp
*
* Description:
* The wcscmp() function returns zero if the wide-character strings at s1
* and s2 are equal. It returns an integer greater than zero if at the first
* differing position i, the corresponding wide-character s1[i] is greater
* than s2[i]. It returns an integer less than zero if at the first differ-
* ing position i, the corresponding wide-character s1[i] is less than s2[i]
*
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
int wcscmp(FAR const wchar_t *s1, FAR const wchar_t *s2)
{
while (*s1 == *s2++)
{
if (*s1++ == 0)
{
return (0);
}
}
return (*s1 - *--s2);
}
#endif

63
libc/wchar/lib_wcscoll.c Normal file
View File

@ -0,0 +1,63 @@
/****************************************************************************
* libc/wchar/lib_wcscoll.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <string.h>
#include <wchar.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: wcscoll
*
* Description:
* The wcscoll() compares the wide-character string pointed to by a to the
* wide-character string pointed to by b using an interpretation appropriate
* to the current LC_COLLATE state.
*
* The current implementation of wcscoll() simply uses wcscmp() and does
* not support any language-specific sorting.
*
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
int wcscoll(FAR const wchar_t *a, FAR const wchar_t *b)
{
return wcscmp(a, b);
}
#endif

View File

@ -1,13 +1,13 @@
/****************************************************************************
* libc/wchar/lib_wcslen.c
*
* Copyright (c)1999 Citrus Project,
* All rights reserved.
* Copyright (c)1999 Citrus Project,
* 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
@ -38,18 +38,6 @@
#include <string.h>
#include <wchar.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -65,9 +53,9 @@
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
size_t wcslen(FAR const wchar_t * s)
size_t wcslen(FAR const wchar_t *s)
{
const wchar_t *p;
FAR const wchar_t *p;
p = s;
while (*p)

View File

@ -1,13 +1,13 @@
/****************************************************************************
* libc/wchar/lib_wmemchr.c
*
* Copyright (c)1999 Citrus Project,
* All rights reserved.
* Copyright (c)1999 Citrus Project,
* 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
@ -26,8 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* citrus Id: wmemchr.c,v 1.2 2000/12/20 14:08:31 itojun Exp
*
****************************************************************************/
/****************************************************************************
@ -38,18 +36,6 @@
#include <string.h>
#include <wchar.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -65,7 +51,7 @@
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
FAR wchar_t *wmemchr(FAR wchar_t * s, wchar_t c, size_t n)
FAR wchar_t *wmemchr(FAR wchar_t *s, wchar_t c, size_t n)
{
size_t i;
@ -74,7 +60,8 @@ FAR wchar_t *wmemchr(FAR wchar_t * s, wchar_t c, size_t n)
if (*s == c)
{
/* LINTED const castaway */
return (wchar_t *) s;
return (FAR wchar_t *) s;
}
s++;
}

View File

@ -1,13 +1,13 @@
/****************************************************************************
* libc/wchar/lib_wmemcmp.c
*
* Copyright (c)1999 Citrus Project,
* All rights reserved.
* Copyright (c)1999 Citrus Project,
* 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
@ -26,8 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* citrus Id: wmemcmp.c,v 1.2 2000/12/20 14:08:31 itojun Exp
*
****************************************************************************/
/****************************************************************************
@ -38,18 +36,6 @@
#include <string.h>
#include <wchar.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -65,7 +51,7 @@
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
int wmemcmp(FAR const wchar_t * s1, FAR const wchar_t * s2, size_t n)
int wmemcmp(FAR const wchar_t *s1, FAR const wchar_t *s2, size_t n)
{
size_t i;
@ -74,8 +60,10 @@ int wmemcmp(FAR const wchar_t * s1, FAR const wchar_t * s2, size_t n)
if (*s1 != *s2)
{
/* wchar might be unsigned */
return *s1 > *s2 ? 1 : -1;
}
s1++;
s2++;
}

View File

@ -1,13 +1,13 @@
/****************************************************************************
* libc/wchar/lib_wmemcpy.c
*
* Copyright (c)1999 Citrus Project,
* All rights reserved.
* Copyright (c)1999 Citrus Project,
* 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
@ -26,8 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* citrus Id: wmemcpy.c,v 1.2 2000/12/20 14:08:31 itojun Exp
*
****************************************************************************/
/****************************************************************************
@ -38,18 +36,6 @@
#include <string.h>
#include <wchar.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -65,8 +51,8 @@
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
wchar_t *wmemcpy(FAR wchar_t * d, FAR wchar_t * s, size_t n)
FAR wchar_t *wmemcpy(FAR wchar_t *d, FAR wchar_t *s, size_t n)
{
return (wchar_t *) memcpy(d, s, n * sizeof(wchar_t));
return (FAR wchar_t *) memcpy(d, s, n * sizeof(wchar_t));
}
#endif

58
libc/wchar/lib_wmemmove.c Normal file
View File

@ -0,0 +1,58 @@
/****************************************************************************
* libc/wchar/lib_wmemmove.c
*
* Copyright (c)1999 Citrus Project,
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <string.h>
#include <wchar.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: wmemmove
*
* Description:
* The wmemmove() function is the wide-character equivalent of the memmove()
* function. It copies n wide characters from the array starting at src to
* the array starting at dest. The arrays may overlap.
*
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
FAR wchar_t *wmemmove(FAR wchar_t *d, FAR const wchar_t *s, size_t n)
{
return (FAR wchar_t *) memmove(d, s, n * sizeof(wchar_t));
}
#endif

View File

@ -1,13 +1,13 @@
/****************************************************************************
* libc/wchar/lib_wmemset.c
*
* Copyright (c)1999 Citrus Project,
* All rights reserved.
* Copyright (c)1999 Citrus Project,
* 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
@ -26,8 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* citrus Id: wmemset.c,v 1.2 2000/12/20 14:08:31 itojun Exp
*/
****************************************************************************/
/****************************************************************************
* Included Files
@ -37,18 +36,6 @@
#include <string.h>
#include <wchar.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -64,12 +51,12 @@
****************************************************************************/
#ifdef CONFIG_LIBC_WCHAR
FAR wchar_t *wmemset(FAR wchar_t * s, wchar_t c, size_t n)
FAR wchar_t *wmemset(FAR wchar_t *s, wchar_t c, size_t n)
{
FAR wchar_t *p;
size_t i;
wchar_t *p;
p = (wchar_t *) s;
p = (FAR wchar_t *) s;
for (i = 0; i < n; i++)
{
*p = c;