Initial push
[termux-packages] / packages / transmission / no_setlocale_in_variant_c.patch
1 diff -u -r ../transmission-2.82/libtransmission/variant.c ./libtransmission/variant.c
2 --- ../transmission-2.82/libtransmission/variant.c 2013-08-09 04:45:40.000000000 +0200
3 +++ ./libtransmission/variant.c 2014-02-10 17:30:57.000000000 +0100
4 @@ -22,7 +22,9 @@
5 #include <sys/stat.h>
6 #endif
7
8 +#ifndef __ANDROID__
9 #include <locale.h> /* setlocale() */
10 +#endif
11 #include <unistd.h> /* write() */
12
13 #include <event2/buffer.h>
14 @@ -308,14 +310,20 @@
15 if (!success && tr_variantIsString (v))
16 {
17 char * endptr;
18 +#ifndef __ANDROID__
19 char locale[128];
20 +#endif
21 double d;
22
23 /* the json spec requires a '.' decimal point regardless of locale */
24 +#ifndef __ANDROID__
25 tr_strlcpy (locale, setlocale (LC_NUMERIC, NULL), sizeof (locale));
26 setlocale (LC_NUMERIC, "POSIX");
27 +#endif
28 d = strtod (getStr (v), &endptr);
29 +#ifndef __ANDROID__
30 setlocale (LC_NUMERIC, locale);
31 +#endif
32
33 if ((success = (getStr (v) != endptr) && !*endptr))
34 *setme = d;
35 @@ -1088,12 +1096,16 @@
36 struct evbuffer *
37 tr_variantToBuf (const tr_variant * v, tr_variant_fmt fmt)
38 {
39 +#ifndef __ANDROID__
40 char lc_numeric[128];
41 +#endif
42 struct evbuffer * buf = evbuffer_new();
43
44 +#ifndef __ANDROID__
45 /* parse with LC_NUMERIC="C" to ensure a "." decimal separator */
46 tr_strlcpy (lc_numeric, setlocale (LC_NUMERIC, NULL), sizeof (lc_numeric));
47 setlocale (LC_NUMERIC, "C");
48 +#endif
49
50 evbuffer_expand (buf, 4096); /* alloc a little memory to start off with */
51
52 @@ -1113,7 +1125,9 @@
53 }
54
55 /* restore the previous locale */
56 +#ifndef __ANDROID__
57 setlocale (LC_NUMERIC, lc_numeric);
58 +#endif
59 return buf;
60 }
61
62 @@ -1272,9 +1286,11 @@
63 int err;
64 char lc_numeric[128];
65
66 +#ifndef __ANDROID__
67 /* parse with LC_NUMERIC="C" to ensure a "." decimal separator */
68 tr_strlcpy (lc_numeric, setlocale (LC_NUMERIC, NULL), sizeof (lc_numeric));
69 setlocale (LC_NUMERIC, "C");
70 +#endif
71
72 switch (fmt)
73 {
74 @@ -1288,7 +1304,9 @@
75 break;
76 }
77
78 +#ifndef __ANDROID__
79 /* restore the previous locale */
80 setlocale (LC_NUMERIC, lc_numeric);
81 +#endif
82 return err;
83 }