summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-04-12 20:59:47 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-12 20:59:47 +0000
commit36956568bca616ad500235d4bc445a25f119c9fc (patch)
tree1c7fd7b0f542b52156bdfff44011643e30947106
parentf096ced10cceea9db63fb5e8eabc16f8f0cf31fd (diff)
parent36aed904bc49bbe23a7d69d6b26bf65eee5de597 (diff)
downloadbase-android12-hostruntime-dev.tar.gz
Merge "Use "C" numeric locale for consistency in strtof" into android12-hostruntime-devandroid12-hostruntime-dev
-rw-r--r--core/jni/RobolectricNativeRuntime.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/jni/RobolectricNativeRuntime.cpp b/core/jni/RobolectricNativeRuntime.cpp
index d11a4b71ecef..fcbc89e788fb 100644
--- a/core/jni/RobolectricNativeRuntime.cpp
+++ b/core/jni/RobolectricNativeRuntime.cpp
@@ -4,6 +4,7 @@
#include <vector>
#include <android/graphics/jni_runtime.h>
+#include <locale.h>
#include <sys/stat.h>
#include <unicode/putil.h>
#include <unicode/udata.h>
@@ -214,5 +215,10 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
}
env->ReleaseStringUTFChars(stringPath, icuPath);
env->ReleaseStringUTFChars(stringLanguageTag, languageTag);
+
+ // Use minimal "C" locale for number format to ensure correct parsing of floats when using
+ // strtof (e.g. in PathParser).
+ setlocale(LC_NUMERIC, "C");
+
return JNI_VERSION_1_6;
}