aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sword25/util/lua/llex.cpp8
-rw-r--r--engines/sword25/util/lua/lvm.cpp7
2 files changed, 15 insertions, 0 deletions
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 */