From 0a79d97a250d24bd88a53f8c68b0185f42a1be6a Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 24 Feb 2015 17:01:23 +0000 Subject: Fix Mac OS X build failures (wcsncasecmp unsat) Cherry-pick of upstream commit 31593e1b96c792abba3c5268d6423975aefa56b2 2015-02-24 Nick Clifton * configure.ac (AC_CHECK_HEADERS): Add wctype.h. * configure: Regenerate. * config.in: Regenerate. * peXXigen.c: Include wctype.h if HAVE_WCTYPE_H is defined. (u16_mbtowc): Use wint_t types if HAVE_WCTYPE_H is defined. (rsrc_cmp): Use towlower instead of wcsncasecmp if HAVE_WCTYPE_H is defined. Bug: 25427405 Change-Id: I06e99d906226ce9c88ff1c568ae7a4d84df7f332 --- binutils-2.25/bfd/ChangeLog | 10 ++++++++++ binutils-2.25/bfd/config.in | 3 +++ binutils-2.25/bfd/configure | 2 +- binutils-2.25/bfd/configure.ac | 2 +- binutils-2.25/bfd/peXXigen.c | 29 +++++++++++++++++++++++++---- 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/binutils-2.25/bfd/ChangeLog b/binutils-2.25/bfd/ChangeLog index 458b0b14..c66bb1ac 100644 --- a/binutils-2.25/bfd/ChangeLog +++ b/binutils-2.25/bfd/ChangeLog @@ -4,6 +4,16 @@ : Add target address to host address difference, not to host pointer. + 2015-02-24 Nick Clifton + + * configure.ac (AC_CHECK_HEADERS): Add wctype.h. + * configure: Regenerate. + * config.in: Regenerate. + * peXXigen.c: Include wctype.h if HAVE_WCTYPE_H is defined. + (u16_mbtowc): Use wint_t types if HAVE_WCTYPE_H is defined. + (rsrc_cmp): Use towlower instead of wcsncasecmp if HAVE_WCTYPE_H + is defined. + 2014-11-18 Igor Zamyatin * elf64-x86-64.c (elf_x86_64_check_relocs): Enable MPX PLT only diff --git a/binutils-2.25/bfd/config.in b/binutils-2.25/bfd/config.in index b911bf6e..96a3e740 100644 --- a/binutils-2.25/bfd/config.in +++ b/binutils-2.25/bfd/config.in @@ -262,6 +262,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_WCTYPE_H + /* Define if has win32_pstatus_t. */ #undef HAVE_WIN32_PSTATUS_T diff --git a/binutils-2.25/bfd/configure b/binutils-2.25/bfd/configure index 482efe33..ea5d50d5 100755 --- a/binutils-2.25/bfd/configure +++ b/binutils-2.25/bfd/configure @@ -12988,7 +12988,7 @@ $as_echo "$bfd_cv_build_exeext" >&6; } fi -for ac_header in alloca.h stddef.h string.h strings.h stdlib.h time.h unistd.h wchar.h +for ac_header in alloca.h stddef.h string.h strings.h stdlib.h time.h unistd.h wchar.h wctype.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" diff --git a/binutils-2.25/bfd/configure.ac b/binutils-2.25/bfd/configure.ac index ba98e393..4eda4320 100644 --- a/binutils-2.25/bfd/configure.ac +++ b/binutils-2.25/bfd/configure.ac @@ -207,7 +207,7 @@ AC_SUBST(BFD_HOSTPTR_T) BFD_CC_FOR_BUILD -AC_CHECK_HEADERS(alloca.h stddef.h string.h strings.h stdlib.h time.h unistd.h wchar.h) +AC_CHECK_HEADERS(alloca.h stddef.h string.h strings.h stdlib.h time.h unistd.h wchar.h wctype.h) AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h sys/resource.h) GCC_HEADER_STDINT(bfd_stdint.h) AC_HEADER_TIME diff --git a/binutils-2.25/bfd/peXXigen.c b/binutils-2.25/bfd/peXXigen.c index 13e39e48..dae32f66 100644 --- a/binutils-2.25/bfd/peXXigen.c +++ b/binutils-2.25/bfd/peXXigen.c @@ -65,6 +65,9 @@ #ifdef HAVE_WCHAR_H #include #endif +#ifdef HAVE_WCTYPE_H +#include +#endif /* NOTE: it's strange to be including an architecture specific header in what's supposed to be general (to PE/PEI) code. However, that's @@ -3488,7 +3491,11 @@ rsrc_write_directory (rsrc_write_data * data, putting its 'ucs4_t' representation in *PUC. */ static unsigned int +#if defined HAVE_WCTYPE_H +u16_mbtouc (wint_t * puc, const unsigned short * s, unsigned int n) +#else u16_mbtouc (wchar_t * puc, const unsigned short * s, unsigned int n) +#endif { unsigned short c = * s; @@ -3560,20 +3567,34 @@ rsrc_cmp (bfd_boolean is_name, rsrc_entry * a, rsrc_entry * b) #elif defined HAVE_WCHAR_H { unsigned int i; + res = 0; for (i = min (alen, blen); i--; astring += 2, bstring += 2) { +#if defined HAVE_WCTYPE_H + wint_t awc; + wint_t bwc; +#else wchar_t awc; wchar_t bwc; +#endif - /* Convert UTF-16 unicode characters into wchar_t characters so - that we can then perform a case insensitive comparison. */ - int Alen = u16_mbtouc (& awc, (const unsigned short *) astring, 2); - int Blen = u16_mbtouc (& bwc, (const unsigned short *) bstring, 2); + /* Convert UTF-16 unicode characters into wchar_t characters + so that we can then perform a case insensitive comparison. */ + unsigned int Alen = u16_mbtouc (& awc, (const unsigned short *) astring, 2); + unsigned int Blen = u16_mbtouc (& bwc, (const unsigned short *) bstring, 2); if (Alen != Blen) return Alen - Blen; + +#ifdef HAVE_WCTYPE_H + awc = towlower (awc); + bwc = towlower (bwc); + + res = awc - bwc; +#else res = wcsncasecmp (& awc, & bwc, 1); +#endif if (res) break; } -- cgit v1.2.3