Work against 64-bit builds
[termux-packages] / packages / libandroid-support / setlocale.c.patch32
1 diff -u -r /home/fornwall/lib/android-ndk/sources/android/support/src/locale/setlocale.c ./src/locale/setlocale.c
2 --- /home/fornwall/lib/android-ndk/sources/android/support/src/locale/setlocale.c 2013-07-26 23:37:59.000000000 -0400
3 +++ ./src/locale/setlocale.c 2015-01-01 17:16:29.488323212 -0500
4 @@ -25,23 +25,18 @@
5 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6 * SUCH DAMAGE.
7 */
8 -#include <errno.h>
9 +#include <string.h>
10 #include "locale_impl.h"
11
12 char *setlocale(int category, const char *locale) {
13 - // Sanity check.
14 - if (locale == NULL) {
15 - errno = EINVAL;
16 - return NULL;
17 - }
18 - // Only accept "", "C" or "POSIX", all equivalent on Android.
19 - if (*locale && strcmp(locale, "C") && strcmp(locale, "POSIX")) {
20 - errno = EINVAL;
21 - return NULL;
22 - }
23 + // setlocale(3): "If locale is NULL, the current locale is only queried, not modified."
24 + if (locale == NULL) return "en_US.UTF-8";
25 +
26 + // Only accept "", "C" or "POSIX", all equivalent on Android, and any locale with UTF-8/UTF8 in it.
27 + if (*locale && strcmp(locale, "C") && strcmp(locale, "POSIX") && strstr(locale, "UTF-8") == 0 && strstr(locale, "UTF8") == 0) return NULL;
28 +
29 // The function returns a char* but the caller is not supposed to
30 // modify it. Just to a type cast. If the caller tries to write to
31 // it, it will simply segfault.
32 - static const char C_LOCALE_SETTING[] = "C";
33 - return (char*) C_LOCALE_SETTING;
34 + return "en_US.UTF-8";
35 }