Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdlib/wcrtomb.c')
-rw-r--r--newlib/libc/stdlib/wcrtomb.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/newlib/libc/stdlib/wcrtomb.c b/newlib/libc/stdlib/wcrtomb.c
new file mode 100644
index 000000000..f68533cbd
--- /dev/null
+++ b/newlib/libc/stdlib/wcrtomb.c
@@ -0,0 +1,25 @@
+#include <wchar.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <reent.h>
+#include <errno.h>
+
+size_t
+wcrtomb(char *s, wchar_t wc, mbstate_t *ps)
+{
+ int retval = 0;
+ _REENT_CHECK_MISC(_REENT);
+
+ if (s == NULL)
+ retval = _wctomb_r (_REENT, "", wc, ps);
+ else
+ retval = _wctomb_r (_REENT, s, wc, ps);
+
+ if (retval == -1)
+ {
+ _REENT->_errno = EILSEQ;
+ return (size_t)(-1);
+ }
+ else
+ return (size_t)retval;
+}