]> granicus.if.org Git - curl/commitdiff
test557: set a known good numeric locale
authorDan Fandrich <dan@coneharvesters.com>
Thu, 4 May 2017 16:03:03 +0000 (18:03 +0200)
committerDan Fandrich <dan@coneharvesters.com>
Thu, 4 May 2017 16:17:08 +0000 (18:17 +0200)
Windows does not allow setting the locale with environment variables (as
the test attempted to do), so the test failed when run with a user
locale that has a comma as radixchar. Changed the test to call
setlocale() explicitly to ensure that a known working locale is set even
on Windows.

tests/data/test557
tests/libtest/lib557.c

index 123bbeade3061e494fafc616a5b8933a18605bef..ad9350f6e216c8f639aba53dcabb993078cf47ef 100644 (file)
@@ -15,10 +15,6 @@ unittest
 <server>
 none
 </server>
-<setenv>
-LC_ALL=
-LC_NUMERIC=C
-</setenv>
 # tool is what to use instead of 'curl'
 <tool>
 lib557
index 68fdfa2b1f7f1133190edc960be68a4c14fb14f4..ca3118aec296116ab0fd5c892a14cb800fe6b313 100644 (file)
  */
 
 #include "test.h"
-#include "memdebug.h"
 
+#ifdef HAVE_LOCALE_H
+#  include <locale.h> /* for setlocale() */
+#endif
+
+#include "memdebug.h"
 
 #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
 #  define MPRNT_SUFFIX_CURL_OFF_T  LL
@@ -1656,6 +1660,14 @@ int test(char *URL)
   int errors = 0;
   (void)URL; /* not used */
 
+#ifdef HAVE_SETLOCALE
+  /*
+   * The test makes assumptions about the numeric locale (specifically,
+   * RADIXCHAR) so set it to a known working (and portable) one.
+   */
+  setlocale(LC_NUMERIC, "C");
+#endif
+
   errors += test_weird_arguments();
 
   errors += test_unsigned_short_formatting();