aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test-wchar.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-08-28 10:38:06 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-08-28 10:38:06 +0000
commit13a468c1e025f5fbb958d0b9bb9e8f3ae1e680ed (patch)
tree64aef4c60c045420c45cbefbff97b03f711d8ecc /test-wchar.c
parent9f8ebb91e4cd327288ff8f4a514b8eb1fdd2b6cf (diff)
downloadmandoc-13a468c1e025f5fbb958d0b9bb9e8f3ae1e680ed.tar.gz
mandoc-13a468c1e025f5fbb958d0b9bb9e8f3ae1e680ed.tar.zst
mandoc-13a468c1e025f5fbb958d0b9bb9e8f3ae1e680ed.zip
On Linux, wcwidth() needs _XOPEN_SOURCE, or just _GNU_SOURCE for simplicity.
Besides, signedness of wchar_t and wint_t may differ, it i only guaranteed that each wchar_t can be represented as a wint_t. A problem report by Daniel Levai reminded me to fix this.
Diffstat (limited to 'test-wchar.c')
-rw-r--r--test-wchar.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/test-wchar.c b/test-wchar.c
index ad37c5fc..2cbb49dd 100644
--- a/test-wchar.c
+++ b/test-wchar.c
@@ -1,4 +1,4 @@
-/* $Id: test-wchar.c,v 1.1 2014/08/16 19:00:01 schwarze Exp $ */
+/* $Id: test-wchar.c,v 1.2 2014/08/28 10:38:06 schwarze Exp $ */
/*
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -15,6 +15,10 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#if defined(__linux__) || defined(__MINT__)
+#define _GNU_SOURCE /* wcwidth() */
+#endif
+
#include <locale.h>
#include <stdio.h>
#include <wchar.h>
@@ -50,7 +54,7 @@ main(void)
dup2(STDERR_FILENO, STDOUT_FILENO);
wc = L'*';
- if (putwchar(wc) != wc) {
+ if (putwchar(wc) != (wint_t)wc) {
fputs("bad putwchar return value\n", stderr);
return(1);
}