ANDROID: Override UTF-8 compliant definition of vsn_printf
This sets Android as a non-standard port in configure in order to override the definition for vsn_printf The vsn_printf implementation is taken from https://github.com/weiss/c99-snprintf
This commit is contained in:
parent
fe296f1c47
commit
3e9504856f
12 changed files with 1387 additions and 11 deletions
|
@ -58,7 +58,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__ANDROID__) && !defined(ANDROIDSDL)
|
#if defined(__ANDROID__) && !defined(ANDROIDSDL)
|
||||||
#include "backends/platform/android/jni.h"
|
#include "backends/platform/android/jni-android.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool POSIXFilesystemNode::exists() const {
|
bool POSIXFilesystemNode::exists() const {
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
#include "backends/saves/default/default-saves.h"
|
#include "backends/saves/default/default-saves.h"
|
||||||
#include "backends/timer/default/default-timer.h"
|
#include "backends/timer/default/default-timer.h"
|
||||||
|
|
||||||
#include "backends/platform/android/jni.h"
|
#include "backends/platform/android/jni-android.h"
|
||||||
#include "backends/platform/android/android.h"
|
#include "backends/platform/android/android.h"
|
||||||
#include "backends/platform/android/graphics.h"
|
#include "backends/platform/android/graphics.h"
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,14 @@
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
|
|
||||||
|
#include "backends/platform/android/portdefs.h"
|
||||||
#include "common/fs.h"
|
#include "common/fs.h"
|
||||||
#include "common/archive.h"
|
#include "common/archive.h"
|
||||||
#include "audio/mixer_intern.h"
|
#include "audio/mixer_intern.h"
|
||||||
#include "backends/modular-backend.h"
|
#include "backends/modular-backend.h"
|
||||||
#include "backends/plugins/posix/posix-provider.h"
|
#include "backends/plugins/posix/posix-provider.h"
|
||||||
#include "backends/fs/posix/posix-fs-factory.h"
|
#include "backends/fs/posix/posix-fs-factory.h"
|
||||||
|
#include "backends/fs/posix/posix-fs-factory.h"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
|
|
||||||
#include "backends/platform/android/jni.h"
|
#include "backends/platform/android/jni-android.h"
|
||||||
#include "backends/platform/android/asset-archive.h"
|
#include "backends/platform/android/asset-archive.h"
|
||||||
|
|
||||||
#include <android/asset_manager.h>
|
#include <android/asset_manager.h>
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "backends/platform/android/android.h"
|
#include "backends/platform/android/android.h"
|
||||||
#include "backends/platform/android/graphics.h"
|
#include "backends/platform/android/graphics.h"
|
||||||
#include "backends/platform/android/events.h"
|
#include "backends/platform/android/events.h"
|
||||||
#include "backends/platform/android/jni.h"
|
#include "backends/platform/android/jni-android.h"
|
||||||
|
|
||||||
// floating point. use sparingly
|
// floating point. use sparingly
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
#include "backends/platform/android/android.h"
|
#include "backends/platform/android/android.h"
|
||||||
#include "backends/platform/android/graphics.h"
|
#include "backends/platform/android/graphics.h"
|
||||||
#include "backends/platform/android/jni.h"
|
#include "backends/platform/android/jni-android.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// AndroidGraphicsManager
|
// AndroidGraphicsManager
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
#include "backends/platform/android/android.h"
|
#include "backends/platform/android/android.h"
|
||||||
#include "backends/platform/android/asset-archive.h"
|
#include "backends/platform/android/asset-archive.h"
|
||||||
#include "backends/platform/android/jni.h"
|
#include "backends/platform/android/jni-android.h"
|
||||||
|
|
||||||
__attribute__ ((visibility("default")))
|
__attribute__ ((visibility("default")))
|
||||||
jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
||||||
|
@ -228,7 +228,6 @@ void JNI::getDPI(float *values) {
|
||||||
void JNI::displayMessageOnOSD(const char *msg) {
|
void JNI::displayMessageOnOSD(const char *msg) {
|
||||||
// called from common/osd_message_queue, method: OSDMessageQueue::pollEvent()
|
// called from common/osd_message_queue, method: OSDMessageQueue::pollEvent()
|
||||||
JNIEnv *env = JNI::getEnv();
|
JNIEnv *env = JNI::getEnv();
|
||||||
// LOGD("OSD orig MESSAGE: %s", msg);
|
|
||||||
Common::String fromEncoding = "ISO-8859-1";
|
Common::String fromEncoding = "ISO-8859-1";
|
||||||
#ifdef USE_TRANSLATION
|
#ifdef USE_TRANSLATION
|
||||||
if (TransMan.getCurrentCharset() != "ASCII") {
|
if (TransMan.getCurrentCharset() != "ASCII") {
|
||||||
|
@ -239,10 +238,10 @@ void JNI::displayMessageOnOSD(const char *msg) {
|
||||||
|
|
||||||
const char *utf8Msg = converter.convert(msg, converter.stringLength(msg, fromEncoding) );
|
const char *utf8Msg = converter.convert(msg, converter.stringLength(msg, fromEncoding) );
|
||||||
if (utf8Msg == nullptr) {
|
if (utf8Msg == nullptr) {
|
||||||
|
// Show a placeholder indicative of the translation error instead of silent failing
|
||||||
|
utf8Msg = "?";
|
||||||
LOGE("Failed to convert message to UTF-8 for OSD!");
|
LOGE("Failed to convert message to UTF-8 for OSD!");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// LOGD("OSD target MESSAGE: %s", utf8Msg);
|
|
||||||
jstring java_msg = env->NewStringUTF(utf8Msg);
|
jstring java_msg = env->NewStringUTF(utf8Msg);
|
||||||
|
|
||||||
env->CallVoidMethod(_jobj, _MID_displayMessageOnOSD, java_msg);
|
env->CallVoidMethod(_jobj, _MID_displayMessageOnOSD, java_msg);
|
|
@ -1,11 +1,12 @@
|
||||||
MODULE := backends/platform/android
|
MODULE := backends/platform/android
|
||||||
|
|
||||||
MODULE_OBJS := \
|
MODULE_OBJS := \
|
||||||
jni.o \
|
jni-android.o \
|
||||||
asset-archive.o \
|
asset-archive.o \
|
||||||
android.o \
|
android.o \
|
||||||
graphics.o \
|
graphics.o \
|
||||||
events.o
|
events.o \
|
||||||
|
snprintf.o
|
||||||
|
|
||||||
# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
|
# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
|
||||||
MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
|
MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
|
||||||
|
|
48
backends/platform/android/portdefs.h
Normal file
48
backends/platform/android/portdefs.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _PORTDEFS_H_
|
||||||
|
#define _PORTDEFS_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
// This is defined in snprintf.c
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
int rpl_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define vsnprintf rpl_vsnprintf
|
||||||
|
|
||||||
|
#endif // _PORTDEFS_H_
|
1323
backends/platform/android/snprintf.cpp
Normal file
1323
backends/platform/android/snprintf.cpp
Normal file
File diff suppressed because it is too large
Load diff
3
configure
vendored
3
configure
vendored
|
@ -3075,6 +3075,7 @@ if test -n "$_host"; then
|
||||||
_port_mk="backends/platform/3ds/3ds.mk"
|
_port_mk="backends/platform/3ds/3ds.mk"
|
||||||
;;
|
;;
|
||||||
android | android-arm | android-v7a | android-arm-v7a | android-arm64-v8a | android-mips | android-mips64 | android-x86 | android-x86_64 | ouya)
|
android | android-arm | android-v7a | android-arm-v7a | android-arm64-v8a | android-mips | android-mips64 | android-x86 | android-x86_64 | ouya)
|
||||||
|
# also __ANDROID__ is defined by Clang in the NDK
|
||||||
DEFINES="$DEFINES -D__ANDROID_PLAIN_PORT__ -DANDROID_PLAIN_PORT"
|
DEFINES="$DEFINES -D__ANDROID_PLAIN_PORT__ -DANDROID_PLAIN_PORT"
|
||||||
# we link a .so as default
|
# we link a .so as default
|
||||||
append_var LDFLAGS "-shared"
|
append_var LDFLAGS "-shared"
|
||||||
|
@ -3561,6 +3562,8 @@ case $_backend in
|
||||||
;;
|
;;
|
||||||
android)
|
android)
|
||||||
append_var DEFINES "-DREDUCE_MEMORY_USAGE"
|
append_var DEFINES "-DREDUCE_MEMORY_USAGE"
|
||||||
|
append_var DEFINES "-DNONSTANDARD_PORT"
|
||||||
|
append_var INCLUDES '-I$(srcdir)/backends/platform/android'
|
||||||
append_var CXXFLAGS "-Wa,--noexecstack"
|
append_var CXXFLAGS "-Wa,--noexecstack"
|
||||||
append_var LDFLAGS "-Wl,-z,noexecstack"
|
append_var LDFLAGS "-Wl,-z,noexecstack"
|
||||||
# removed the following directive - was causing compilation issues when not also explicitly using --disable-mt32emu
|
# removed the following directive - was causing compilation issues when not also explicitly using --disable-mt32emu
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue