Restore Android-conditioning on nl_langinfo() definition

QCoreApplicationPrivate::initLocale()'s check that the selected locale
is UTF-8-based was added with an initial work-around for Android,
specific to NDK <= 15, which Qt 5.15 did not support.

Later the Android-specific #if-ery was changed to test for Qt taking
UTF-8 for granted, for a given reason having to do with QNX; and later
the #if-ery for that was removed. However, we still support versions
of Android that lack nl_langinfo(), so restore the Android #if-ery.
It presently seems that NDK 26 (Android 8) does contain nl_langinfo(),
so we should be able to drop the nl_langinfo() kludge for this and
later versions. That way we'll at least use the real nl_langinfo()
where we have it.

In the process, fix the indentation of #if-ery.

Change-Id: Ie9e83c3397955c24cea1e9a9ff6bb0187e47dda2
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 10117f78d72498e19683e69b439ca7c931532261)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Edward Welbourne 2022-10-31 15:25:55 +01:00 committed by Qt Cherry-pick Bot
parent e3daea6f17
commit 65f8f50b10

View File

@ -593,9 +593,11 @@ void QCoreApplicationPrivate::initLocale()
# ifdef Q_OS_INTEGRITY
setlocale(LC_CTYPE, "UTF-8");
# else
// Android's Bionic didn't get nl_langinfo until NDK 15 (Android 8.0),
// which is too new for Qt, so we just assume it's always UTF-8.
# if defined(Q_OS_QNX) || (defined(Q_OS_ANDROID) && __ANDROID_API__ < __ANDROID_API_O__)
// Android 6 still lacks nl_langinfo(), as does QNX, so we just assume it's
// always UTF-8 on these platforms.
auto nl_langinfo = [](int) { return "UTF-8"; };
# endif // QNX or Android NDK < 26, "O".
const char *locale = setlocale(LC_ALL, "");
const char *codec = nl_langinfo(CODESET);
@ -624,8 +626,8 @@ void QCoreApplicationPrivate::initLocale()
"reconfigure your locale. See the locale(1) manual for more information.",
codec, oldLocale.constData(), newLocale.constData());
}
#endif
#endif
# endif // Integrity
#endif // Unix
}