aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorJaromir Wysoglad2019-08-24 20:32:53 +0200
committerDavid Turner2019-08-24 21:43:57 +0100
commitc2e0e90c276f6ca98bb32e8258ac2a729651e99a (patch)
treea03ca999b73338cccd123f28b8bf2bc53a158560 /backends
parentfb54cc1f7799a1097f880a51f60d62e09250ada9 (diff)
downloadscummvm-rg350-c2e0e90c276f6ca98bb32e8258ac2a729651e99a.tar.gz
scummvm-rg350-c2e0e90c276f6ca98bb32e8258ac2a729651e99a.tar.bz2
scummvm-rg350-c2e0e90c276f6ca98bb32e8258ac2a729651e99a.zip
SDL: Use a non-const string for SDL_iconv_string
With some older versions of SDL1, the SDL_iconv_string takes char * instead of const char * as it's argument. This should fix the build issue with gp2xwiz.
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/sdl/sdl.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index b9cccbf5e8..c89a560976 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -774,6 +774,17 @@ char *OSystem_SDL::convertEncoding(const char *to, const char *from, const char
zeroBytes = 2;
if (Common::String(from).hasPrefixIgnoreCase("utf-32"))
zeroBytes = 4;
+
+ // SDL_iconv_string() takes char * instead of const char * as it's third parameter
+ // with some older versions of SDL.
+#if SDL_VERSION_ATLEAST(2, 0, 0)
return SDL_iconv_string(to, from, string, length + zeroBytes);
+#else
+ char *stringCopy = (char *) calloc(sizeof(char), length + zeroBytes);
+ memcpy(stringCopy, string, length);
+ char *result = SDL_iconv_string(to, from, stringCopy, length + zeroBytes);
+ free(stringCopy);
+ return result;
+#endif
}