diff --git a/libc/libc.csv b/libc/libc.csv index 3cdfa73c9e..327b796d32 100644 --- a/libc/libc.csv +++ b/libc/libc.csv @@ -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 *","..." diff --git a/libc/wchar/Make.defs b/libc/wchar/Make.defs index 5cf6997007..45936e895b 100644 --- a/libc/wchar/Make.defs +++ b/libc/wchar/Make.defs @@ -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 + diff --git a/libc/wchar/lib_btowc.c b/libc/wchar/lib_btowc.c new file mode 100644 index 0000000000..7314294699 --- /dev/null +++ b/libc/wchar/lib_btowc.c @@ -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 +#include +#include +#include +#include + +/**************************************************************************** + * 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 diff --git a/libc/wchar/lib_mbrtowc.c b/libc/wchar/lib_mbrtowc.c new file mode 100644 index 0000000000..09887b77e0 --- /dev/null +++ b/libc/wchar/lib_mbrtowc.c @@ -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 +#include +#include +#include +#include +#include + +/**************************************************************************** + * 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 diff --git a/libc/wchar/lib_mbtowc.c b/libc/wchar/lib_mbtowc.c new file mode 100644 index 0000000000..5e50d86b28 --- /dev/null +++ b/libc/wchar/lib_mbtowc.c @@ -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 +#include +#include + +/**************************************************************************** + * 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 diff --git a/libc/wchar/lib_wcscmp.c b/libc/wchar/lib_wcscmp.c new file mode 100644 index 0000000000..72e6bb3565 --- /dev/null +++ b/libc/wchar/lib_wcscmp.c @@ -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 +#include +#include + +/**************************************************************************** + * 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 diff --git a/libc/wchar/lib_wcscoll.c b/libc/wchar/lib_wcscoll.c new file mode 100644 index 0000000000..9bdc727d21 --- /dev/null +++ b/libc/wchar/lib_wcscoll.c @@ -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 +#include +#include + +/**************************************************************************** + * 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 diff --git a/libc/wchar/lib_wcslen.c b/libc/wchar/lib_wcslen.c index be99ccded6..f5a4d18afc 100644 --- a/libc/wchar/lib_wcslen.c +++ b/libc/wchar/lib_wcslen.c @@ -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 #include -/**************************************************************************** - * 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) diff --git a/libc/wchar/lib_wmemchr.c b/libc/wchar/lib_wmemchr.c index 696de1abf9..732c4ca019 100644 --- a/libc/wchar/lib_wmemchr.c +++ b/libc/wchar/lib_wmemchr.c @@ -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 #include -/**************************************************************************** - * 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++; } diff --git a/libc/wchar/lib_wmemcmp.c b/libc/wchar/lib_wmemcmp.c index 223c3eefc8..134f69e0d1 100644 --- a/libc/wchar/lib_wmemcmp.c +++ b/libc/wchar/lib_wmemcmp.c @@ -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 #include -/**************************************************************************** - * 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++; } diff --git a/libc/wchar/lib_wmemcpy.c b/libc/wchar/lib_wmemcpy.c index e5e6b926e7..8a28173c7f 100644 --- a/libc/wchar/lib_wmemcpy.c +++ b/libc/wchar/lib_wmemcpy.c @@ -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 #include -/**************************************************************************** - * 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 diff --git a/libc/wchar/lib_wmemmove.c b/libc/wchar/lib_wmemmove.c new file mode 100644 index 0000000000..3ce34272f3 --- /dev/null +++ b/libc/wchar/lib_wmemmove.c @@ -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 +#include +#include + +/**************************************************************************** + * 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 diff --git a/libc/wchar/lib_wmemset.c b/libc/wchar/lib_wmemset.c index 0deba00f4c..8eea8a23ed 100644 --- a/libc/wchar/lib_wmemset.c +++ b/libc/wchar/lib_wmemset.c @@ -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 #include -/**************************************************************************** - * 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;