36 lines
1.4 KiB
Plaintext
36 lines
1.4 KiB
Plaintext
diff -u -r /home/fornwall/lib/android-ndk/sources/android/support/src/locale/setlocale.c ./src/locale/setlocale.c
|
|
--- /home/fornwall/lib/android-ndk/sources/android/support/src/locale/setlocale.c 2013-07-26 23:37:59.000000000 -0400
|
|
+++ ./src/locale/setlocale.c 2015-01-01 17:16:29.488323212 -0500
|
|
@@ -25,23 +25,18 @@
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*/
|
|
-#include <errno.h>
|
|
+#include <string.h>
|
|
#include "locale_impl.h"
|
|
|
|
char *setlocale(int category, const char *locale) {
|
|
- // Sanity check.
|
|
- if (locale == NULL) {
|
|
- errno = EINVAL;
|
|
- return NULL;
|
|
- }
|
|
- // Only accept "", "C" or "POSIX", all equivalent on Android.
|
|
- if (*locale && strcmp(locale, "C") && strcmp(locale, "POSIX")) {
|
|
- errno = EINVAL;
|
|
- return NULL;
|
|
- }
|
|
+ // setlocale(3): "If locale is NULL, the current locale is only queried, not modified."
|
|
+ if (locale == NULL) return "en_US.UTF-8";
|
|
+
|
|
+ // Only accept "", "C" or "POSIX", all equivalent on Android, and any locale with UTF-8/UTF8 in it.
|
|
+ if (*locale && strcmp(locale, "C") && strcmp(locale, "POSIX") && strstr(locale, "UTF-8") == 0 && strstr(locale, "UTF8") == 0) return NULL;
|
|
+
|
|
// The function returns a char* but the caller is not supposed to
|
|
// modify it. Just to a type cast. If the caller tries to write to
|
|
// it, it will simply segfault.
|
|
- static const char C_LOCALE_SETTING[] = "C";
|
|
- return (char*) C_LOCALE_SETTING;
|
|
+ return "en_US.UTF-8";
|
|
}
|