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