summaryrefslogtreecommitdiff
path: root/openbsd-compat/openbsd-compat.h
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2016-07-14 10:59:09 +1000
committerDarren Tucker <dtucker@zip.com.au>2016-07-14 10:59:09 +1000
commita2333584170a565adf4f209586772ef8053b10b8 (patch)
tree37e1f144bdabc09b1ce89c2e6fe603bc8845e7c2 /openbsd-compat/openbsd-compat.h
parent8aaec7050614494014c47510b7e94daf6e644c62 (diff)
Add compat code for missing wcwidth.
If we don't have wcwidth force fallback implementations of nl_langinfo and mbtowc. Based on advice from Ingo Schwarze.
Diffstat (limited to 'openbsd-compat/openbsd-compat.h')
-rw-r--r--openbsd-compat/openbsd-compat.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
index 8cc8a11b7..997541e43 100644
--- a/openbsd-compat/openbsd-compat.h
+++ b/openbsd-compat/openbsd-compat.h
@@ -36,6 +36,8 @@
36 36
37#include <sys/socket.h> 37#include <sys/socket.h>
38 38
39#include <stddef.h> /* for wchar_t */
40
39/* OpenBSD function replacements */ 41/* OpenBSD function replacements */
40#include "base64.h" 42#include "base64.h"
41#include "sigact.h" 43#include "sigact.h"
@@ -231,6 +233,22 @@ long long strtonum(const char *, long long, long long, const char **);
231# define mblen(x, y) (1) 233# define mblen(x, y) (1)
232#endif 234#endif
233 235
236#ifndef HAVE_WCWIDTH
237# define wcwidth(x) (((x) >= 0x20 && (x) <= 0x7e) ? 1 : -1)
238/* force our no-op nl_langinfo and mbtowc */
239# undef HAVE_NL_LANGINFO
240# undef HAVE_MBTOWC
241# undef HAVE_LANGINFO_H
242#endif
243
244#ifndef HAVE_NL_LANGINFO
245# define nl_langinfo(x) ""
246#endif
247
248#ifndef HAVE_MBTOWC
249int mbtowc(wchar_t *, const char*, size_t);
250#endif
251
234#if !defined(HAVE_VASPRINTF) || !defined(HAVE_VSNPRINTF) 252#if !defined(HAVE_VASPRINTF) || !defined(HAVE_VSNPRINTF)
235# include <stdarg.h> 253# include <stdarg.h>
236#endif 254#endif