diff --git a/include/wchar.h b/include/wchar.h index 7d954287e7e78..ffe0a30239329 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -150,7 +150,7 @@ wint_t fputwc_unlocked(wchar_t, FAR FILE *); int fputws(FAR const wchar_t *, FILE *); int fputws_unlocked(FAR const wchar_t *, FAR FILE *); int fwide(FILE *, int); -wint_t getwc(FILE *); +wint_t getwc(FAR FILE *); wint_t getwchar(void); int mbsinit(FAR const mbstate_t *); size_t mbrlen(FAR const char *, size_t, FAR mbstate_t *); diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv index f05cc9f0c8ab3..1a8fedcc61bf9 100644 --- a/libs/libc/libc.csv +++ b/libs/libc/libc.csv @@ -109,6 +109,7 @@ "gets","stdio.h","defined(CONFIG_FILE_STREAM)","FAR char *","FAR char *" "gettext","libintl.h","defined(CONFIG_LIBC_LOCALE_GETTEXT)","FAR char *","FAR const char *" "gettimeofday","sys/time.h","","int","FAR struct timeval *","FAR struct timezone *" +"getwc","wchar.h","defined(CONFIG_FILE_STREAM)","wint_t","FAR FILE *" "gmtime","time.h","","FAR struct tm *","FAR const time_t *" "gmtime_r","time.h","","FAR struct tm *","FAR const time_t *","FAR struct tm *" "htonl","arpa/inet.h","","uint32_t","uint32_t" diff --git a/libs/libc/stdio/CMakeLists.txt b/libs/libc/stdio/CMakeLists.txt index 6bb5234c7dadd..1e85b03d41e87 100644 --- a/libs/libc/stdio/CMakeLists.txt +++ b/libs/libc/stdio/CMakeLists.txt @@ -106,7 +106,8 @@ if(CONFIG_FILE_STREAM) lib_fputws.c lib_fopencookie.c lib_fmemopen.c - lib_fgetwc.c) + lib_fgetwc.c + lib_getwc.c) endif() target_sources(c PRIVATE ${SRCS}) diff --git a/libs/libc/stdio/Make.defs b/libs/libc/stdio/Make.defs index e182ce17c20a0..0acddb12a9c5c 100644 --- a/libs/libc/stdio/Make.defs +++ b/libs/libc/stdio/Make.defs @@ -49,6 +49,7 @@ CSRCS += lib_scanf.c lib_vscanf.c lib_fscanf.c lib_vfscanf.c lib_tmpfile.c CSRCS += lib_setbuf.c lib_setvbuf.c lib_libfilelock.c lib_libgetstreams.c CSRCS += lib_setbuffer.c lib_fputwc.c lib_putwc.c lib_fputws.c CSRCS += lib_fopencookie.c lib_fmemopen.c lib_open_memstream.c lib_fgetwc.c +CSRCS += lib_getwc.c endif # Add the stdio directory to the build diff --git a/libs/libc/stdio/lib_getwc.c b/libs/libc/stdio/lib_getwc.c new file mode 100644 index 0000000000000..df8870f706b37 --- /dev/null +++ b/libs/libc/stdio/lib_getwc.c @@ -0,0 +1,60 @@ +/**************************************************************************** + * libs/libc/stdio/lib_getwc.c + * + * Copyright © 2005-2014 Rich Felker, et al. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#ifdef CONFIG_FILE_STREAM + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: getwc + * + * Description: + * Get wide character from stream + * + * Input Parameters: + * f - Pointer to a FILE object that identifies an input stream + * + * Returned Value: + * Return the character read is returned, + * Return WEOF is the sequence of bytes that read cannot be interpreted as + * a valid wide characted, and sets the errno to EILSEQ + * + ****************************************************************************/ + +wint_t getwc(FAR FILE *f) +{ + return fgetwc(f); +} + +#endif /* CONFIG_FILE_STREAM */