]>
Commit | Line | Data |
---|---|---|
1 | diff --git a/Python/fileutils.c b/Python/fileutils.c | |
2 | index b7c42e8..40db4f9 100644 | |
3 | --- a/Python/fileutils.c | |
4 | +++ b/Python/fileutils.c | |
5 | @@ -43,7 +43,7 @@ _Py_device_encoding(int fd) | |
6 | Py_RETURN_NONE; | |
7 | } | |
8 | ||
9 | -#if !defined(__APPLE__) && !defined(MS_WINDOWS) | |
10 | +#if !defined(__APPLE__) && !defined(MS_WINDOWS) && !defined(__ANDROID__) | |
11 | extern int _Py_normalize_encoding(const char *, char *, size_t); | |
12 | ||
13 | /* Workaround FreeBSD and OpenIndiana locale encoding issue with the C locale. | |
14 | @@ -260,7 +260,7 @@ _Py_char2wchar(const char* arg, size_t *size) | |
15 | mbstate_t mbs; | |
16 | #endif | |
17 | ||
18 | -#ifndef MS_WINDOWS | |
19 | +#if !(defined(MS_WINDOWS) || defined(__ANDROID__)) | |
20 | if (force_ascii == -1) | |
21 | force_ascii = check_force_ascii(); | |
22 | ||
23 | @@ -419,7 +419,7 @@ _Py_wchar2char(const wchar_t *text, size_t *error_pos) | |
24 | size_t i, size, converted; | |
25 | wchar_t c, buf[2]; | |
26 | ||
27 | -#ifndef MS_WINDOWS | |
28 | +#if !(defined(MS_WINDOWS) || defined(__ANDROID__)) | |
29 | if (force_ascii == -1) | |
30 | force_ascii = check_force_ascii(); | |
31 | ||
32 | diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c | |
33 | index a6516dc..f06c2a0 100644 | |
34 | --- a/Python/formatter_unicode.c | |
35 | +++ b/Python/formatter_unicode.c | |
36 | @@ -664,6 +664,9 @@ static int | |
37 | get_locale_info(int type, LocaleInfo *locale_info) | |
38 | { | |
39 | switch (type) { | |
40 | +#ifdef __ANDROID__ | |
41 | + case LT_CURRENT_LOCALE: | |
42 | +#else | |
43 | case LT_CURRENT_LOCALE: { | |
44 | struct lconv *locale_data = localeconv(); | |
45 | locale_info->decimal_point = PyUnicode_DecodeLocale( | |
46 | @@ -681,6 +684,7 @@ get_locale_info(int type, LocaleInfo *locale_info) | |
47 | locale_info->grouping = locale_data->grouping; | |
48 | break; | |
49 | } | |
50 | +#endif | |
51 | case LT_DEFAULT_LOCALE: | |
52 | locale_info->decimal_point = PyUnicode_FromOrdinal('.'); | |
53 | locale_info->thousands_sep = PyUnicode_FromOrdinal(','); | |
54 | diff --git a/Python/pystrtod.c b/Python/pystrtod.c | |
55 | index 4ab8f08..22b01a1 100644 | |
56 | --- a/Python/pystrtod.c | |
57 | +++ b/Python/pystrtod.c | |
58 | @@ -177,8 +177,12 @@ _PyOS_ascii_strtod(const char *nptr, char **endptr) | |
59 | ||
60 | fail_pos = NULL; | |
61 | ||
62 | +#ifdef __ANDROID__ | |
63 | + decimal_point = "."; | |
64 | +#else | |
65 | locale_data = localeconv(); | |
66 | decimal_point = locale_data->decimal_point; | |
67 | +#endif | |
68 | decimal_point_len = strlen(decimal_point); | |
69 | ||
70 | assert(decimal_point_len != 0); | |
71 | @@ -378,8 +382,12 @@ PyOS_string_to_double(const char *s, | |
72 | Py_LOCAL_INLINE(void) | |
73 | change_decimal_from_locale_to_dot(char* buffer) | |
74 | { | |
75 | +#ifdef __ANDROID__ | |
76 | + const char *decimal_point = "."; | |
77 | +#else | |
78 | struct lconv *locale_data = localeconv(); | |
79 | const char *decimal_point = locale_data->decimal_point; | |
80 | +#endif | |
81 | ||
82 | if (decimal_point[0] != '.' || decimal_point[1] != 0) { | |
83 | size_t decimal_point_len = strlen(decimal_point); | |
84 | diff --git a/Python/pythonrun.c b/Python/pythonrun.c | |
85 | index 832df53..c43e5e9 100644 | |
86 | --- a/Python/pythonrun.c | |
87 | +++ b/Python/pythonrun.c | |
88 | @@ -810,6 +810,51 @@ Py_SetPythonHome(wchar_t *home) | |
89 | default_home = home; | |
90 | } | |
91 | ||
92 | +#ifdef __ANDROID__ | |
93 | +size_t mbstowcs(wchar_t *dest, const char * in, size_t maxlen) | |
94 | +{ | |
95 | + wchar_t *out = dest; | |
96 | + size_t size = 0; | |
97 | + if (in) | |
98 | + { | |
99 | + while(*in && (!out || size<maxlen)) { | |
100 | + if (out) { | |
101 | + if(*in < 128) | |
102 | + *out++ = *in++; | |
103 | + else | |
104 | + *out++ = 0xdc00 + *in++; | |
105 | + } else { | |
106 | + in++; | |
107 | + } | |
108 | + size += 1; | |
109 | + } | |
110 | + } | |
111 | + if (out && size<maxlen) | |
112 | + *out = 0; | |
113 | + return size; | |
114 | +} | |
115 | + | |
116 | +size_t wcstombs(char * dest, const wchar_t *source, size_t maxlen) | |
117 | +{ | |
118 | + wchar_t c; | |
119 | + size_t i; | |
120 | + for (i=0; (!dest || i<maxlen) && source[i]; i++) | |
121 | + { | |
122 | + c=source[i]; | |
123 | + if (c >= 0xdc80 && c <= 0xdcff) | |
124 | + { | |
125 | + /* UTF-8b surrogate */ | |
126 | + c-=0xdc00; | |
127 | + } | |
128 | + if (dest) | |
129 | + dest[i]=c; | |
130 | + } | |
131 | + if (dest && i<maxlen) | |
132 | + dest[i] = 0; | |
133 | + return i; | |
134 | +} | |
135 | +#endif | |
136 | + | |
137 | wchar_t * | |
138 | Py_GetPythonHome(void) | |
139 | { | |
140 | --- a/configure.ac 2013-11-17 07:23:09.000000000 +0000 | |
141 | +++ b/configure.ac 2013-12-05 14:27:43.166191803 +0000 | |
142 | @@ -2829,7 +2829,7 @@ | |
143 | getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \ | |
144 | getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ | |
145 | if_nameindex \ | |
146 | - initgroups kill killpg lchmod lchown lockf linkat lstat lutimes mmap \ | |
147 | + initgroups kill killpg lchmod lchown localeconv lockf linkat lstat lutimes mmap \ | |
148 | memrchr mbrtowc mkdirat mkfifo \ | |
149 | mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \ | |
150 | posix_fallocate posix_fadvise pread \ | |
151 | --- a/Modules/_localemodule.c 2013-12-05 14:29:33.643662167 +0000 | |
152 | +++ b/Modules/_localemodule.c 2013-12-05 14:31:41.069332495 +0000 | |
153 | @@ -88,6 +88,7 @@ | |
154 | return result_object; | |
155 | } | |
156 | ||
157 | +#if defined(HAVE_LOCALECONV) | |
158 | PyDoc_STRVAR(localeconv__doc__, | |
159 | "() -> dict. Returns numeric and monetary locale-specific parameters."); | |
160 | ||
161 | @@ -144,6 +145,7 @@ | |
162 | Py_XDECREF(x); | |
163 | return NULL; | |
164 | } | |
165 | +#endif | |
166 | ||
167 | #if defined(HAVE_WCSCOLL) | |
168 | PyDoc_STRVAR(strcoll__doc__, | |
169 | @@ -566,8 +566,10 @@ | |
170 | static struct PyMethodDef PyLocale_Methods[] = { | |
171 | {"setlocale", (PyCFunction) PyLocale_setlocale, | |
172 | METH_VARARGS, setlocale__doc__}, | |
173 | +#ifdef HAVE_LOCALECONV | |
174 | {"localeconv", (PyCFunction) PyLocale_localeconv, | |
175 | METH_NOARGS, localeconv__doc__}, | |
176 | +#endif | |
177 | #ifdef HAVE_WCSCOLL | |
178 | {"strcoll", (PyCFunction) PyLocale_strcoll, | |
179 | METH_VARARGS, strcoll__doc__}, | |
180 | --- a/Modules/pwdmodule.c 2013-12-05 14:41:59.065464798 +0000 | |
181 | +++ b/Modules/pwdmodule.c 2013-12-05 14:42:17.045681049 +0000 | |
182 | @@ -76,7 +76,7 @@ | |
183 | #endif | |
184 | PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromUid(p->pw_uid)); | |
185 | PyStructSequence_SET_ITEM(v, setIndex++, _PyLong_FromGid(p->pw_gid)); | |
186 | -#ifdef __VMS | |
187 | +#if defined(__VMS) || defined(__ANDROID__) | |
188 | SETS(setIndex++, ""); | |
189 | #else | |
190 | SETS(setIndex++, p->pw_gecos); | |
191 | --- a/Python/bltinmodule.c 2014-04-13 10:14:13.053260705 +0200 | |
192 | +++ b/Python/bltinmodule.c 2014-04-26 15:18:24.094444817 +0200 | |
193 | @@ -24,7 +24,7 @@ | |
194 | #ifdef HAVE_MBCS | |
195 | const char *Py_FileSystemDefaultEncoding = "mbcs"; | |
196 | int Py_HasFileSystemDefaultEncoding = 1; | |
197 | -#elif defined(__APPLE__) | |
198 | +#elif defined(__APPLE__) || defined(__ANDROID__) | |
199 | const char *Py_FileSystemDefaultEncoding = "utf-8"; | |
200 | int Py_HasFileSystemDefaultEncoding = 1; | |
201 | #else | |
202 | --- a/Lib/locale.py 2014-04-26 14:35:53.243526608 +0200 | |
203 | +++ b/Lib/locale.py 2014-04-26 14:36:53.752085946 +0200 | |
204 | @@ -46,6 +46,7 @@ | |
205 | try: | |
206 | ||
207 | from _locale import * | |
208 | + raise ImportError("") | |
209 | ||
210 | except ImportError: | |
211 | ||
212 | --- a/Misc/python.pc.in 2014-04-26 23:16:09.108514880 +0200 | |
213 | +++ b/Misc/python.pc.in 2014-04-26 23:24:48.845467012 +0200 | |
214 | @@ -9,5 +9,5 @@ | |
215 | Requires: | |
216 | Version: @VERSION@ | |
217 | Libs.private: @LIBS@ | |
218 | -Libs: -L${libdir} -lpython@VERSION@@ABIFLAGS@ | |
219 | +Libs: -L${libdir} -lpython@VERSION@@ABIFLAGS@ -lz | |
220 | Cflags: -I${includedir}/python@VERSION@@ABIFLAGS@ |