Skip to content

Commit d35c080

Browse files
committed
add cdecimal recipe
1 parent eba92ab commit d35c080

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
from pythonforandroid.toolchain import CompiledComponentsPythonRecipe
3+
from pythonforandroid.patching import is_darwin
4+
5+
6+
class CdecimalRecipe(CompiledComponentsPythonRecipe):
7+
name = 'cdecimal'
8+
version = '2.3'
9+
url = 'http://www.bytereef.org/software/mpdecimal/releases/cdecimal-{version}.tar.gz'
10+
11+
depends = ['python2']
12+
13+
patches = ['locale.patch']
14+
15+
def prebuild_arch(self, arch):
16+
super(CdecimalRecipe, self).prebuild_arch(arch)
17+
if not is_darwin():
18+
self.setup_extra_args = ['--with-machine=ansi32']
19+
20+
21+
recipe = CdecimalRecipe()
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
diff -Naur a/io.c b/io.c
2+
--- a/io.c 2012-02-01 14:29:49.000000000 -0600
3+
+++ b/io.c 2015-12-09 17:04:00.060579230 -0600
4+
@@ -34,7 +34,7 @@
5+
#include <limits.h>
6+
#include <assert.h>
7+
#include <errno.h>
8+
-#include <locale.h>
9+
+#include "locale.h"
10+
#include "bits.h"
11+
#include "constants.h"
12+
#include "memory.h"
13+
@@ -792,15 +792,14 @@
14+
}
15+
else if (*cp == 'N' || *cp == 'n') {
16+
/* locale specific conversion */
17+
- struct lconv *lc;
18+
spec->type = *cp++;
19+
/* separator has already been specified */
20+
if (*spec->sep) return 0;
21+
spec->type = (spec->type == 'N') ? 'G' : 'g';
22+
- lc = localeconv();
23+
- spec->dot = lc->decimal_point;
24+
- spec->sep = lc->thousands_sep;
25+
- spec->grouping = lc->grouping;
26+
+ /* TODO: Android does not have localeconv(); we'll just use C locale values for now */
27+
+ spec->dot = ".";
28+
+ spec->sep = "";
29+
+ spec->grouping = "";
30+
}
31+
32+
/* check correctness */
33+
diff -Naur a/locale.h b/locale.h
34+
--- a/locale.h 1969-12-31 18:00:00.000000000 -0600
35+
+++ b/locale.h 2015-12-09 17:04:11.128762784 -0600
36+
@@ -0,0 +1,136 @@
37+
+/*
38+
+ * Copyright (C) 2008 The Android Open Source Project
39+
+ * All rights reserved.
40+
+ *
41+
+ * Redistribution and use in source and binary forms, with or without
42+
+ * modification, are permitted provided that the following conditions
43+
+ * are met:
44+
+ * * Redistributions of source code must retain the above copyright
45+
+ * notice, this list of conditions and the following disclaimer.
46+
+ * * Redistributions in binary form must reproduce the above copyright
47+
+ * notice, this list of conditions and the following disclaimer in
48+
+ * the documentation and/or other materials provided with the
49+
+ * distribution.
50+
+ *
51+
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52+
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53+
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
54+
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
55+
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
56+
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
57+
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
58+
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
59+
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
60+
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
61+
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62+
+ * SUCH DAMAGE.
63+
+ */
64+
+#ifndef _LOCALE_H_
65+
+#define _LOCALE_H_
66+
+
67+
+#include <sys/cdefs.h>
68+
+
69+
+__BEGIN_DECLS
70+
+
71+
+enum {
72+
+ LC_CTYPE = 0,
73+
+ LC_NUMERIC = 1,
74+
+ LC_TIME = 2,
75+
+ LC_COLLATE = 3,
76+
+ LC_MONETARY = 4,
77+
+ LC_MESSAGES = 5,
78+
+ LC_ALL = 6,
79+
+ LC_PAPER = 7,
80+
+ LC_NAME = 8,
81+
+ LC_ADDRESS = 9,
82+
+
83+
+ LC_TELEPHONE = 10,
84+
+ LC_MEASUREMENT = 11,
85+
+ LC_IDENTIFICATION = 12
86+
+};
87+
+
88+
+extern char *setlocale(int category, const char *locale);
89+
+
90+
+#if 1 /* MISSING FROM BIONIC - DEFINED TO MAKE libstdc++-v3 happy */
91+
+/*struct lconv { };*/
92+
+
93+
+__BEGIN_NAMESPACE_STD;
94+
+
95+
+/* Structure giving information about numeric and monetary notation. */
96+
+struct lconv
97+
+{
98+
+ /* Numeric (non-monetary) information. */
99+
+
100+
+ char *decimal_point; /* Decimal point character. */
101+
+ char *thousands_sep; /* Thousands separator. */
102+
+ /* Each element is the number of digits in each group;
103+
+ elements with higher indices are farther left.
104+
+ An element with value CHAR_MAX means that no further grouping is done.
105+
+ An element with value 0 means that the previous element is used
106+
+ for all groups farther left. */
107+
+ char *grouping;
108+
+
109+
+ /* Monetary information. */
110+
+
111+
+ /* First three chars are a currency symbol from ISO 4217.
112+
+ Fourth char is the separator. Fifth char is '\0'. */
113+
+ char *int_curr_symbol;
114+
+ char *currency_symbol; /* Local currency symbol. */
115+
+ char *mon_decimal_point; /* Decimal point character. */
116+
+ char *mon_thousands_sep; /* Thousands separator. */
117+
+ char *mon_grouping; /* Like `grouping' element (above). */
118+
+ char *positive_sign; /* Sign for positive values. */
119+
+ char *negative_sign; /* Sign for negative values. */
120+
+ char int_frac_digits; /* Int'l fractional digits. */
121+
+ char frac_digits; /* Local fractional digits. */
122+
+ /* 1 if currency_symbol precedes a positive value, 0 if succeeds. */
123+
+ char p_cs_precedes;
124+
+ /* 1 iff a space separates currency_symbol from a positive value. */
125+
+ char p_sep_by_space;
126+
+ /* 1 if currency_symbol precedes a negative value, 0 if succeeds. */
127+
+ char n_cs_precedes;
128+
+ /* 1 iff a space separates currency_symbol from a negative value. */
129+
+ char n_sep_by_space;
130+
+ /* Positive and negative sign positions:
131+
+ 0 Parentheses surround the quantity and currency_symbol.
132+
+ 1 The sign string precedes the quantity and currency_symbol.
133+
+ 2 The sign string follows the quantity and currency_symbol.
134+
+ 3 The sign string immediately precedes the currency_symbol.
135+
+ 4 The sign string immediately follows the currency_symbol. */
136+
+ char p_sign_posn;
137+
+ char n_sign_posn;
138+
+#ifdef __USE_ISOC99
139+
+ /* 1 if int_curr_symbol precedes a positive value, 0 if succeeds. */
140+
+ char int_p_cs_precedes;
141+
+ /* 1 iff a space separates int_curr_symbol from a positive value. */
142+
+ char int_p_sep_by_space;
143+
+ /* 1 if int_curr_symbol precedes a negative value, 0 if succeeds. */
144+
+ char int_n_cs_precedes;
145+
+ /* 1 iff a space separates int_curr_symbol from a negative value. */
146+
+ char int_n_sep_by_space;
147+
+ /* Positive and negative sign positions:
148+
+ 0 Parentheses surround the quantity and int_curr_symbol.
149+
+ 1 The sign string precedes the quantity and int_curr_symbol.
150+
+ 2 The sign string follows the quantity and int_curr_symbol.
151+
+ 3 The sign string immediately precedes the int_curr_symbol.
152+
+ 4 The sign string immediately follows the int_curr_symbol. */
153+
+ char int_p_sign_posn;
154+
+ char int_n_sign_posn;
155+
+#else
156+
+ char __int_p_cs_precedes;
157+
+ char __int_p_sep_by_space;
158+
+ char __int_n_cs_precedes;
159+
+ char __int_n_sep_by_space;
160+
+ char __int_p_sign_posn;
161+
+ char __int_n_sign_posn;
162+
+#endif
163+
+};
164+
+
165+
+__END_NAMESPACE_STD;
166+
+
167+
+struct lconv *localeconv(void);
168+
+#endif /* MISSING */
169+
+
170+
+__END_DECLS
171+
+
172+
+#endif /* _LOCALE_H_ */

0 commit comments

Comments
 (0)