X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=binutils%2Fwinduni.c;h=36d699358b8ed715014932e99fabd30dd1acba75;hb=cf6f3e86ded2cd950f59a0f2c164f2c953ef534b;hp=76404cace9f9826576b08620f91c16c5def4848d;hpb=81472056d738c3b07914f3dad5edb0f4af45a050;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/winduni.c b/binutils/winduni.c index 76404cace9..36d699358b 100644 --- a/binutils/winduni.c +++ b/binutils/winduni.c @@ -1,6 +1,5 @@ /* winduni.c -- unicode support for the windres program. - Copyright 1997, 1998, 2000, 2001, 2003, 2005, 2007, 2009 - Free Software Foundation, Inc. + Copyright (C) 1997-2020 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. Rewritten by Kai Tietz, Onevision. @@ -52,13 +51,13 @@ static int unichar_isascii (const unichar *, rc_uint_type); /* Convert an ASCII string to a unicode string. We just copy it, expanding chars to shorts, rather than doing something intelligent. */ - + #if !defined (_WIN32) && !defined (__CYGWIN__) /* Codepages mapped. */ static local_iconv_map codepages[] = { - { 0, "MS-ANSI" }, + { 0, "cp1252" }, { 1, "WINDOWS-1252" }, { 437, "MS-ANSI" }, { 737, "MS-GREEK" }, @@ -85,7 +84,7 @@ static local_iconv_map codepages[] = { 1258, "WINDOWS-1258" }, { CP_UTF7, "UTF-7" }, { CP_UTF8, "UTF-8" }, - { CP_UTF16, "UTF-16" }, + { CP_UTF16, "UTF-16LE" }, { (rc_uint_type) -1, NULL } }; @@ -102,7 +101,7 @@ static const wind_language_t languages[] = { 0x040D, 862, 1255, "Hebrew", "Israel" }, { 0x040E, 852, 1250, "Hungarian", "Hungary" }, { 0x040F, 850, 1252, "Icelandic", "Iceland" }, { 0x0410, 850, 1252, "Italian", "Italy" }, { 0x0411, 932, 932, "Japanese", "Japan" }, { 0x0412, 949, 949, "Korean", "Korea (south)" }, - { 0x0413, 850, 1252, "Dutch", "Netherlands" }, { 0x0414, 850, 1252, "Norwegian (Bokmål)", "Norway" }, + { 0x0413, 850, 1252, "Dutch", "Netherlands" }, { 0x0414, 850, 1252, "Norwegian (Bokm\345l)", "Norway" }, { 0x0415, 852, 1250, "Polish", "Poland" }, { 0x0416, 850, 1252, "Portuguese", "Brazil" }, { 0x0418, 852, 1250, "Romanian", "Romania" }, { 0x0419, 866, 1251, "Russian", "Russia" }, { 0x041A, 852, 1250, "Croatian", "Croatia" }, { 0x041B, 852, 1250, "Slovak", "Slovakia" }, @@ -214,7 +213,7 @@ unicode_from_ascii_len (rc_uint_type *length, unichar **unicode, const char *asc } /* Make sure we have zero terminated string. */ - p = tmp = (char *) alloca (a_length + 1); + p = tmp = (char *) xmalloc (a_length + 1); memcpy (tmp, ascii, a_length); tmp[a_length] = 0; @@ -280,6 +279,8 @@ unicode_from_ascii_len (rc_uint_type *length, unichar **unicode, const char *asc if (length) *length = idx; + + free (tmp); } /* Convert an unicode string to an ASCII string. We just copy it, @@ -751,7 +752,7 @@ wind_MultiByteToWideChar (rc_uint_type cp, const char *mb, #if defined (_WIN32) || defined (__CYGWIN__) rc_uint_type conv_flags = MB_PRECOMPOSED; - /* MB_PRECOMPOSED is not allowed for UTF-7 or UTF-8. + /* MB_PRECOMPOSED is not allowed for UTF-7 or UTF-8. MultiByteToWideChar will set the last error to ERROR_INVALID_FLAGS if we do. */ if (cp == CP_UTF8 || cp == CP_UTF7) @@ -770,7 +771,7 @@ wind_MultiByteToWideChar (rc_uint_type cp, const char *mb, if (!mb || !iconv_name) return 0; - iconv_t cd = iconv_open ("UTF-16", iconv_name); + iconv_t cd = iconv_open ("UTF-16LE", iconv_name); while (1) { @@ -843,7 +844,7 @@ wind_WideCharToMultiByte (rc_uint_type cp, const unichar *u, char *mb, rc_uint_t if (!u || !iconv_name) return 0; - iconv_t cd = iconv_open (iconv_name, "UTF-16"); + iconv_t cd = iconv_open (iconv_name, "UTF-16LE"); while (1) {