From 854783ea93d89a28c0bf1617dfd89c84e30d6423 Mon Sep 17 00:00:00 2001 From: md5 Date: Fri, 13 May 2011 20:52:33 +0300 Subject: SWORD25 (LUA): Hopefully fixed compilation for the Android platform --- engines/sword25/util/lua/llex.cpp | 8 ++++++++ engines/sword25/util/lua/lvm.cpp | 7 +++++++ 2 files changed, 15 insertions(+) (limited to 'engines/sword25/util') diff --git a/engines/sword25/util/lua/llex.cpp b/engines/sword25/util/lua/llex.cpp index fdde2b8e5f..91413ba55c 100644 --- a/engines/sword25/util/lua/llex.cpp +++ b/engines/sword25/util/lua/llex.cpp @@ -176,9 +176,17 @@ static void buffreplace (LexState *ls, char from, char to) { static void trydecpoint (LexState *ls, SemInfo *seminfo) { /* format error: try to update decimal point separator */ +#if defined(__ANDROID__) + // Android is missing the decimal_point member from the lconv struct. + // For more information, refer to: + // http://www.damonkohler.com/2008/12/lua-on-android.html + char old = ls->decpoint; + ls->decpoint = '.'; +#else struct lconv *cv = localeconv(); char old = ls->decpoint; ls->decpoint = (cv ? cv->decimal_point[0] : '.'); +#endif buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { /* format error with correct decimal point: no more options */ diff --git a/engines/sword25/util/lua/lvm.cpp b/engines/sword25/util/lua/lvm.cpp index ae70fe2645..15013397ba 100644 --- a/engines/sword25/util/lua/lvm.cpp +++ b/engines/sword25/util/lua/lvm.cpp @@ -202,7 +202,14 @@ static int l_strcmp (const TString *ls, const TString *rs) { const char *r = getstr(rs); size_t lr = rs->tsv.len; for (;;) { +#if defined(__ANDROID__) + // Android is missing strcoll(). + // For more information, refer to: + // http://www.damonkohler.com/2008/12/lua-on-android.html + int temp = strcmp(l, r); +#else int temp = strcoll(l, r); +#endif if (temp != 0) return temp; else { /* strings are equal up to a `\0' */ size_t len = strlen(l); /* index of first `\0' in both strings */ -- cgit v1.2.3