xref: /OK3568_Linux_fs/buildroot/package/popt/0004-fix-build-without-wchar.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 41911aac46d69df6a205af59d60f23a418b0e875 Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Wed, 2 Sep 2020 11:55:17 +0200
4Subject: [PATCH] fix build without wchar
5
6Check for wchar.h and use HAVE_WCHAR_H instead of hardcoding
7POPT_WCHAR_HACK to fix the build with (embedded) toolchains that don't
8support wchar
9
10Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
11[Retrieved from:
12https://github.com/rpm-software-management/popt/commit/41911aac46d69df6a205af59d60f23a418b0e875]
13---
14 configure.ac   | 2 +-
15 src/popthelp.c | 5 ++---
16 2 files changed, 3 insertions(+), 4 deletions(-)
17
18diff --git a/configure.ac b/configure.ac
19index 009ae7b..1fce6df 100644
20--- a/configure.ac
21+++ b/configure.ac
22@@ -18,7 +18,7 @@ LT_INIT
23
24 AC_SYS_LARGEFILE
25
26-AC_CHECK_HEADERS([fnmatch.h glob.h langinfo.h libintl.h mcheck.h stdalign.h])
27+AC_CHECK_HEADERS([fnmatch.h glob.h langinfo.h libintl.h mcheck.h stdalign.h wchar.h])
28
29 # For some systems we know that we have ld_version scripts.
30 # Use it then as default.
31diff --git a/src/popthelp.c b/src/popthelp.c
32index 9a3f489..5cbc1f4 100644
33--- a/src/popthelp.c
34+++ b/src/popthelp.c
35@@ -15,8 +15,7 @@
36 #include <sys/ioctl.h>
37 #endif
38
39-#define	POPT_WCHAR_HACK
40-#ifdef 	POPT_WCHAR_HACK
41+#ifdef HAVE_WCHAR_H
42 #include <wchar.h>			/* for mbsrtowcs */
43 #endif
44 #include "poptint.h"
45@@ -118,7 +117,7 @@ static size_t maxColumnWidth(FILE *fp)
46 static inline size_t stringDisplayWidth(const char *s)
47 {
48     size_t n = strlen(s);
49-#ifdef	POPT_WCHAR_HACK
50+#ifdef HAVE_WCHAR_H
51     mbstate_t t;
52
53     memset ((void *)&t, 0, sizeof (t));	/* In initial state.  */
54