From 395e256889836e5b36c954e2bd1629fad7931fe2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 3 May 2012 19:39:37 +0200 Subject: [PATCH] unix: don't use setlocale() setlocale() is not inherently thread-safe. We'll have to live with the fact that test/test-dlerror.c fails on systems with localized error messages. --- src/unix/dl.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/unix/dl.c b/src/unix/dl.c index bf0c74a1..9eb66001 100644 --- a/src/unix/dl.c +++ b/src/unix/dl.c @@ -65,23 +65,18 @@ const char* uv_dlerror(uv_lib_t* lib) { static int uv__dlerror(uv_lib_t* lib) { char* errmsg; - char* locale; - - /* Make error message independent of locale. */ - locale = setlocale(LC_MESSAGES, NULL); - if (strcmp(locale, "C") == 0) { - errmsg = dlerror(); - } else { - setlocale(LC_MESSAGES, "C"); - errmsg = dlerror(); - setlocale(LC_MESSAGES, locale); - } if (lib->errmsg) free(lib->errmsg); - if (errmsg) - return lib->errmsg = strdup(errmsg), -1; - else - return lib->errmsg = NULL, 0; + errmsg = dlerror(); + + if (errmsg) { + lib->errmsg = strdup(errmsg); + return -1; + } + else { + lib->errmsg = NULL; + return 0; + } }