diff options
author | Daiki Ueno <dueno@redhat.com> | 2018-04-27 10:00:52 +0200 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2018-05-01 13:30:43 +0200 |
commit | a625dfa4f2456b1a866489e5be15fb46578237a5 (patch) | |
tree | d0959e03eeeec6d331aa0451fe6f9199f70eb4b3 /common/library.c | |
parent | 6202903b261dfae740af3f8e985244bab48470ba (diff) |
library: Use dedicated locale object for printing error
Diffstat (limited to 'common/library.c')
-rw-r--r-- | common/library.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/common/library.c b/common/library.c index 37cb1c8..52c3347 100644 --- a/common/library.c +++ b/common/library.c @@ -44,6 +44,9 @@ #include "message.h" #include <assert.h> +#ifdef HAVE_LOCALE_H +#include <locale.h> +#endif #include <stdarg.h> #include <stdlib.h> #include <stdio.h> @@ -67,6 +70,10 @@ pthread_once_t p11_library_once = PTHREAD_ONCE_INIT; unsigned int p11_forkid = 1; +#ifdef HAVE_LOCALE_H +extern locale_t p11_message_locale; +#endif + static char * thread_local_message (void) { @@ -123,6 +130,9 @@ p11_library_init_impl (void) p11_mutex_init (&p11_virtual_mutex); pthread_key_create (&thread_local, free); p11_message_storage = thread_local_message; +#ifdef HAVE_NEWLOCALE + p11_message_locale = newlocale (LC_ALL_MASK, "POSIX", (locale_t) 0); +#endif pthread_atfork (NULL, NULL, count_forks); } @@ -142,6 +152,9 @@ p11_library_uninit (void) free (pthread_getspecific (thread_local)); pthread_setspecific (thread_local, NULL); +#ifdef HAVE_NEWLOCALE + freelocale (p11_message_locale); +#endif p11_message_storage = dont_store_message; pthread_key_delete (thread_local); p11_mutex_uninit (&p11_virtual_mutex); |