about summary refs log tree commit diff
path: root/src/multibyte/btowc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/multibyte/btowc.c')
-rw-r--r--src/multibyte/btowc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/multibyte/btowc.c b/src/multibyte/btowc.c
index 29cb798d..8acd0a2c 100644
--- a/src/multibyte/btowc.c
+++ b/src/multibyte/btowc.c
@@ -1,8 +1,10 @@
 #include <stdio.h>
 #include <wchar.h>
+#include <stdlib.h>
+#include "internal.h"
 
 wint_t btowc(int c)
 {
-	c = (unsigned char)c;
-	return c<128U ? c : EOF;
+	int b = (unsigned char)c;
+	return b<128U ? b : (MB_CUR_MAX==1 && c!=EOF) ? CODEUNIT(c) : WEOF;
 }