mirror of
https://github.com/termux/termux-packages.git
synced 2025-03-02 19:15:59 +00:00
92 lines
2.0 KiB
Diff
92 lines
2.0 KiB
Diff
https://github.com/termux/termux-packages/issues/15929
|
|
|
|
--- a/awk.h
|
|
+++ b/awk.h
|
|
@@ -80,6 +80,11 @@
|
|
|
|
#ifdef STDC_HEADERS
|
|
#include <stdlib.h>
|
|
+#if defined __ANDROID__ && defined __TERMUX__
|
|
+#undef MB_CUR_MAX
|
|
+#define MB_CUR_MAX __ctype_get_mb_cur_max()
|
|
+size_t __ctype_get_mb_cur_max(void);
|
|
+#endif
|
|
#endif /* not STDC_HEADERS */
|
|
|
|
|
|
--- a/support/localeinfo.c
|
|
+++ b/support/localeinfo.c
|
|
@@ -28,6 +28,11 @@
|
|
#include <limits.h>
|
|
#include <locale.h>
|
|
#include <stdlib.h>
|
|
+#if defined __ANDROID__ && defined __TERMUX__
|
|
+#undef MB_CUR_MAX
|
|
+#define MB_CUR_MAX __ctype_get_mb_cur_max()
|
|
+size_t __ctype_get_mb_cur_max(void);
|
|
+#endif
|
|
#include <string.h>
|
|
#include <wctype.h>
|
|
|
|
--- a/support/regex_internal.h
|
|
+++ b/support/regex_internal.h
|
|
@@ -23,6 +23,11 @@
|
|
#include <ctype.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
+#if defined __ANDROID__ && defined __TERMUX__
|
|
+#undef MB_CUR_MAX
|
|
+#define MB_CUR_MAX __ctype_get_mb_cur_max()
|
|
+size_t __ctype_get_mb_cur_max(void);
|
|
+#endif
|
|
#include <string.h>
|
|
|
|
#include <langinfo.h>
|
|
--- a/main.c
|
|
+++ b/main.c
|
|
@@ -30,6 +30,15 @@
|
|
#include "awk.h"
|
|
#include "getopt.h"
|
|
|
|
+#ifdef __ANDROID__
|
|
+static __inline__ char *setlocale_(int category, const char *locale_name) {
|
|
+ return setlocale(category, locale_name);
|
|
+}
|
|
+#define setlocale(category, locale_name) /* */
|
|
+#else
|
|
+#define setlocale_ setlocale
|
|
+#endif
|
|
+
|
|
#ifdef HAVE_MCHECK_H
|
|
#include <mcheck.h>
|
|
#endif
|
|
@@ -230,6 +239,19 @@
|
|
#if defined(LOCALEDEBUG)
|
|
const char *initial_locale;
|
|
#endif
|
|
+#ifdef __ANDROID__
|
|
+ locale = getenv("LC_ALL");
|
|
+ if (locale == NULL || locale[0] == '\0')
|
|
+ locale = getenv("LC_CTYPE");
|
|
+ if (locale == NULL || locale[0] == '\0')
|
|
+ locale = getenv("LANG");
|
|
+ if (locale == NULL)
|
|
+ locale = "";
|
|
+ if (strcmp(locale, "C") == 0 || strcmp(locale, "POSIX") == 0)
|
|
+ setlocale_(LC_CTYPE, "C");
|
|
+ else
|
|
+ setlocale_(LC_CTYPE, "C.UTF-8");
|
|
+#endif
|
|
|
|
myname = gawk_name(argv[0]);
|
|
|
|
@@ -384,7 +406,7 @@
|
|
else {
|
|
gawk_mb_cur_max = 1; /* hands off my data! */
|
|
#if defined(LC_ALL)
|
|
- setlocale(LC_ALL, "C");
|
|
+ setlocale_(LC_ALL, "C");
|
|
#endif
|
|
}
|
|
}
|