premake/patches/713.patch
author Sam Lantinga <slouken@libsdl.org>
Fri, 28 Nov 2014 04:51:33 -0800
changeset 9246 a761913e5e91
parent 7925 f090a47eb7f7
permissions -rwxr-xr-x
Fixed bug 2786 - "UCS-2-INTERNAL" iconv encoding is not supported everywhere, use UTF-16LE instead

Jonas Kulla

src/main/windows/SDL_windows_main.c:137:
cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR));

I'm trying to compile an SDL2 application for windows using the mingw-w64 32bit toolchain provided by my distro (Fedora 19). However, even the simplest test program that does nothing at all fails to startup with a "Fatal error - out of memory" message because the mingw iconv library provided by my distro does not support the "UCS-2-INTERNAL" encoding and the conversion returns null.

From my little bit of research, it turns out that even though this encoding is supported by the external GNU libiconv library, some glibc versions (?) don't support it with their internal iconv routines, and will instead provide the native endian encoding when "UCS-2" is specified.

Nonetheless, I wonder why the native endianness is considered in the first place when Windows doesn't even run on any big endian archs (to my knowledge). And true enough, 'WIN_StringToUTF8' from core/windows/SDL_windows.h is used everywhere else in the windows backend, which is just a macro to iconv with "UTF-16LE" as source. Therefore it would IMO make sense to use this macro here as well, which would solve my problem (patch attached).
     1 # HG changeset patch
     2 # User Ben Henning
     3 # Date 1376606083 25200
     4 #      Thu Aug 15 15:34:43 2013 -0700
     5 # Node ID 8c9cd352c70012a64779356bff3c81998c3fb6a0
     6 # Parent  e8558df4fbdb173a2b9ed0d354d6c3e76b376698
     7 Implemented the option to set custom source trees for Xcode frameworks (links)
     8 using Visual Studio-esque variables, such as "$(SDKROOT)/OpenGLES.framework".
     9 
    10 diff --git a/src/actions/xcode/xcode_common.lua b/src/actions/xcode/xcode_common.lua
    11 --- a/src/actions/xcode/xcode_common.lua
    12 +++ b/src/actions/xcode/xcode_common.lua
    13 @@ -318,18 +318,36 @@
    14  					local pth, src
    15  					if xcode.isframework(node.path) then
    16  						--respect user supplied paths
    17 -						if string.find(node.path,'/')  then
    18 -							if string.find(node.path,'^%.')then
    19 +						-- look for special variable-starting paths for different sources
    20 +						local nodePath = node.path
    21 +						local _, matchEnd, variable = string.find(nodePath, "^%$%((.+)%)/")
    22 +						if variable then
    23 +							-- by skipping the last '/' we support the same absolute/relative
    24 +							-- paths as before
    25 +							nodePath = string.sub(nodePath, matchEnd + 1)
    26 +						end
    27 +						if string.find(nodePath,'/')  then
    28 +							if string.find(nodePath,'^%.')then
    29  								error('relative paths are not currently supported for frameworks')
    30  							end
    31 -							pth = node.path
    32 +							pth = nodePath
    33  						else
    34 -							pth = "/System/Library/Frameworks/" .. node.path
    35 +							pth = "/System/Library/Frameworks/" .. nodePath
    36  						end
    37 -						src = "absolute"
    38 +						-- if it starts with a variable, use that as the src instead
    39 +						if variable then
    40 +							src = variable
    41 +							-- if we are using a different source tree, it has to be relative
    42 +							-- to that source tree, so get rid of any leading '/'
    43 +							if string.find(pth, '^/') then
    44 +								pth = string.sub(pth, 2)
    45 +							end
    46 +						else
    47 +							src = "<absolute>"
    48 +						end
    49  					else
    50  						-- something else; probably a source code file
    51 -						src = "group"
    52 +						src = "<group>"
    53  
    54  						-- if the parent node is virtual, it won't have a local path
    55  						-- of its own; need to use full relative path from project
    56 @@ -340,7 +358,7 @@
    57  						end
    58  					end
    59  					
    60 -					_p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = %s; name = "%s"; path = "%s"; sourceTree = "<%s>"; };',
    61 +					_p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = %s; name = "%s"; path = "%s"; sourceTree = "%s"; };',
    62  						node.id, node.name, xcode.getfiletype(node), node.name, pth, src)
    63  				end
    64  			end