Changeset 13861
- Timestamp:
- Jan 24, 2013, 4:33:49 PM (8 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/json-test.c
r13860 r13861 227 227 int n; 228 228 int rv; 229 char lc_numeric[128]; 230 const char * comma_locales[] = { "da_DK.UTF-8", "fr_FR.UTF-8", "ru_RU.UTF-8"}; 229 230 const char * comma_locales[] = { "da_DK.UTF-8", 231 "fr_FR.UTF-8", 232 "ru_RU.UTF-8"}; 231 233 232 234 const testFunc tests[] = { test_elements, … … 238 240 239 241 /* run the tests in a locale with a decimal point of '.' */ 240 tr_strlcpy (lc_numeric, setlocale (LC_NUMERIC, NULL), sizeof (lc_numeric));241 242 setlocale (LC_NUMERIC, "C"); 242 243 if ((rv = runTests (tests, NUM_TESTS (tests)))) … … 252 253 else if ((rv = runTests (tests, NUM_TESTS(tests)))) 253 254 return rv; 254 setlocale (LC_NUMERIC, lc_numeric);255 255 256 256 /* success */ -
trunk/libtransmission/variant.c
r13860 r13861 802 802 int stackSize = 0; 803 803 int stackAlloc = 64; 804 char lc_numeric[128];805 804 struct SaveNode * stack = tr_new (struct SaveNode, stackAlloc); 806 807 /* always use a '.' decimal point s.t. locale-hopping doesn't bite us */808 tr_strlcpy (lc_numeric, setlocale (LC_NUMERIC, NULL), sizeof (lc_numeric));809 setlocale (LC_NUMERIC, "C");810 805 811 806 nodeConstruct (&stack[stackSize++], v, sort_dicts); … … 898 893 } 899 894 } 900 901 /* restore the locale... */902 setlocale (LC_NUMERIC, lc_numeric);903 895 904 896 tr_free (stack); … … 1096 1088 tr_variantToBuf (const tr_variant * v, tr_variant_fmt fmt) 1097 1089 { 1090 char lc_numeric[128]; 1098 1091 struct evbuffer * buf = evbuffer_new(); 1092 1093 /* parse with LC_NUMERIC="C" to ensure a "." decimal separator */ 1094 tr_strlcpy (lc_numeric, setlocale (LC_NUMERIC, NULL), sizeof (lc_numeric)); 1095 setlocale (LC_NUMERIC, "C"); 1099 1096 1100 1097 evbuffer_expand (buf, 4096); /* alloc a little memory to start off with */ … … 1115 1112 } 1116 1113 1114 /* restore the previous locale */ 1115 setlocale (LC_NUMERIC, lc_numeric); 1117 1116 return buf; 1118 1117 } … … 1262 1261 { 1263 1262 int err; 1263 char lc_numeric[128]; 1264 1265 /* parse with LC_NUMERIC="C" to ensure a "." decimal separator */ 1266 tr_strlcpy (lc_numeric, setlocale (LC_NUMERIC, NULL), sizeof (lc_numeric)); 1267 setlocale (LC_NUMERIC, "C"); 1264 1268 1265 1269 switch (fmt) … … 1275 1279 } 1276 1280 1281 /* restore the previous locale */ 1282 setlocale (LC_NUMERIC, lc_numeric); 1277 1283 return err; 1278 1284 }
Note: See TracChangeset
for help on using the changeset viewer.