diff options
Diffstat (limited to 'binutils-2.25/bfd/peXXigen.c')
-rw-r--r-- | binutils-2.25/bfd/peXXigen.c | 29 |
1 files changed, 25 insertions, 4 deletions
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 <wchar.h> #endif +#ifdef HAVE_WCTYPE_H +#include <wctype.h> +#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; } |