[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: use of thread-unsafe localeconv in vasprintf
From: |
Bruno Haible |
Subject: |
Re: use of thread-unsafe localeconv in vasprintf |
Date: |
Mon, 26 Mar 2007 04:18:35 +0200 |
User-agent: |
KMail/1.5.4 |
After testing on a few platforms, I applied this patch now.
2007-03-25 Bruno Haible <address@hidden>
* lib/vasnprintf.c: Include langinfo.h.
(VASNPRINTF): Prefer nl_langinfo over localeconv, since it's more
multithread-safe.
* m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_DIRECTIVE_A): New macro.
* m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_POSIX): Invoke it.
* m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_POSIX): Likewise.
* m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_POSIX): Likewise.
* m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_POSIX): Likewise.
* m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_POSIX): Likewise.
* m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_POSIX): Likewise.
* m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_POSIX: Likewise.
* m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_POSIX): Likewise.
Reported by Simon Josefsson.
*** lib/vasnprintf.c 25 Mar 2007 02:30:04 -0000 1.35
--- lib/vasnprintf.c 26 Mar 2007 02:08:17 -0000
***************
*** 41,46 ****
--- 41,49 ----
#include <errno.h> /* errno */
#include <limits.h> /* CHAR_BIT */
#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
+ #if HAVE_NL_LANGINFO
+ # include <langinfo.h>
+ #endif
#if WIDE_CHAR_VERSION
# include "wprintf-parse.h"
#else
***************
*** 507,514 ****
if ((flags & FLAG_ALT)
|| mantissa > 0.0L || precision > 0)
{
! const char *point =
! localeconv () -> decimal_point;
/* The decimal point is always a single byte:
either '.' or ','. */
*p++ = (point[0] != '\0' ? point[0] : '.');
--- 510,524 ----
if ((flags & FLAG_ALT)
|| mantissa > 0.0L || precision > 0)
{
! const char *point;
! /* Prefer nl_langinfo() over localeconv(),
! since the latter is not multithread-
! safe. */
! # if HAVE_NL_LANGINFO
! point = nl_langinfo (RADIXCHAR);
! # else
! point = localeconv () -> decimal_point;
! # endif
/* The decimal point is always a single byte:
either '.' or ','. */
*p++ = (point[0] != '\0' ? point[0] : '.');
***************
*** 657,664 ****
if ((flags & FLAG_ALT)
|| mantissa > 0.0 || precision > 0)
{
! const char *point =
! localeconv () -> decimal_point;
/* The decimal point is always a single byte:
either '.' or ','. */
*p++ = (point[0] != '\0' ? point[0] : '.');
--- 667,681 ----
if ((flags & FLAG_ALT)
|| mantissa > 0.0 || precision > 0)
{
! const char *point;
! /* Prefer nl_langinfo() over localeconv(),
! since the latter is not multithread-
! safe. */
! # if HAVE_NL_LANGINFO
! point = nl_langinfo (RADIXCHAR);
! # else
! point = localeconv () -> decimal_point;
! # endif
/* The decimal point is always a single byte:
either '.' or ','. */
*p++ = (point[0] != '\0' ? point[0] : '.');
*** m4/vasnprintf.m4 7 Mar 2007 01:34:55 -0000 1.13
--- m4/vasnprintf.m4 26 Mar 2007 02:08:17 -0000
***************
*** 1,4 ****
! # vasnprintf.m4 serial 9
dnl Copyright (C) 2002-2004, 2006-2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # vasnprintf.m4 serial 10
dnl Copyright (C) 2002-2004, 2006-2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 62,67 ****
--- 62,79 ----
AC_CHECK_FUNCS(snprintf wcslen)
])
+ # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
+ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
+ [
+ AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+ if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
+ AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
+ [Define if the vasnprintf implementation needs special code for
+ the 'a' and 'A' directives.])
+ AC_CHECK_FUNCS([nl_langinfo])
+ fi
+ ])
+
# Prerequisites of lib/asnprintf.c.
AC_DEFUN([gl_PREREQ_ASNPRINTF],
[
*** m4/fprintf-posix.m4 9 Mar 2007 02:59:39 -0000 1.1
--- m4/fprintf-posix.m4 26 Mar 2007 02:08:17 -0000
***************
*** 1,4 ****
! # fprintf-posix.m4 serial 1
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # fprintf-posix.m4 serial 2
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 31,41 ****
;;
esac
if test $gl_cv_func_fprintf_posix = no; then
! if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
! AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
! [Define if the vasnprintf implementation needs special code for
! the 'a' and 'A' directives.])
! fi
gl_REPLACE_VASNPRINTF
gl_REPLACE_FPRINTF
fi
--- 31,37 ----
;;
esac
if test $gl_cv_func_fprintf_posix = no; then
! gl_PREREQ_VASNPRINTF_DIRECTIVE_A
gl_REPLACE_VASNPRINTF
gl_REPLACE_FPRINTF
fi
*** m4/snprintf-posix.m4 9 Mar 2007 01:24:32 -0000 1.2
--- m4/snprintf-posix.m4 26 Mar 2007 02:08:17 -0000
***************
*** 1,4 ****
! # snprintf-posix.m4 serial 1
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # snprintf-posix.m4 serial 2
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 50,60 ****
esac
fi
if test $gl_cv_func_snprintf_posix = no; then
! if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
! AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
! [Define if the vasnprintf implementation needs special code for
! the 'a' and 'A' directives.])
! fi
gl_REPLACE_VASNPRINTF
gl_REPLACE_SNPRINTF
fi
--- 50,56 ----
esac
fi
if test $gl_cv_func_snprintf_posix = no; then
! gl_PREREQ_VASNPRINTF_DIRECTIVE_A
gl_REPLACE_VASNPRINTF
gl_REPLACE_SNPRINTF
fi
*** m4/sprintf-posix.m4 9 Mar 2007 01:24:32 -0000 1.2
--- m4/sprintf-posix.m4 26 Mar 2007 02:08:17 -0000
***************
*** 1,4 ****
! # sprintf-posix.m4 serial 1
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # sprintf-posix.m4 serial 2
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 31,41 ****
;;
esac
if test $gl_cv_func_sprintf_posix = no; then
! if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
! AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
! [Define if the vasnprintf implementation needs special code for
! the 'a' and 'A' directives.])
! fi
gl_REPLACE_VASNPRINTF
gl_REPLACE_SPRINTF
fi
--- 31,37 ----
;;
esac
if test $gl_cv_func_sprintf_posix = no; then
! gl_PREREQ_VASNPRINTF_DIRECTIVE_A
gl_REPLACE_VASNPRINTF
gl_REPLACE_SPRINTF
fi
*** m4/vasnprintf-posix.m4 9 Mar 2007 01:24:32 -0000 1.5
--- m4/vasnprintf-posix.m4 26 Mar 2007 02:08:17 -0000
***************
*** 1,4 ****
! # vasnprintf-posix.m4 serial 2
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # vasnprintf-posix.m4 serial 3
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 34,44 ****
;;
esac
if test $gl_cv_func_vasnprintf_posix = no; then
! if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
! AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
! [Define if the vasnprintf implementation needs special code for
! the 'a' and 'A' directives.])
! fi
gl_REPLACE_VASNPRINTF
fi
])
--- 34,40 ----
;;
esac
if test $gl_cv_func_vasnprintf_posix = no; then
! gl_PREREQ_VASNPRINTF_DIRECTIVE_A
gl_REPLACE_VASNPRINTF
fi
])
*** m4/vasprintf-posix.m4 9 Mar 2007 01:24:32 -0000 1.3
--- m4/vasprintf-posix.m4 26 Mar 2007 02:08:17 -0000
***************
*** 1,4 ****
! # vasprintf-posix.m4 serial 2
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # vasprintf-posix.m4 serial 3
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 34,44 ****
;;
esac
if test $gl_cv_func_vasprintf_posix = no; then
! if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
! AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
! [Define if the vasnprintf implementation needs special code for
! the 'a' and 'A' directives.])
! fi
gl_REPLACE_VASNPRINTF
gl_REPLACE_VASPRINTF
fi
--- 34,40 ----
;;
esac
if test $gl_cv_func_vasprintf_posix = no; then
! gl_PREREQ_VASNPRINTF_DIRECTIVE_A
gl_REPLACE_VASNPRINTF
gl_REPLACE_VASPRINTF
fi
*** m4/vfprintf-posix.m4 9 Mar 2007 02:40:14 -0000 1.1
--- m4/vfprintf-posix.m4 26 Mar 2007 02:08:17 -0000
***************
*** 1,4 ****
! # vfprintf-posix.m4 serial 1
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # vfprintf-posix.m4 serial 2
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 31,41 ****
;;
esac
if test $gl_cv_func_vfprintf_posix = no; then
! if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
! AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
! [Define if the vasnprintf implementation needs special code for
! the 'a' and 'A' directives.])
! fi
gl_REPLACE_VASNPRINTF
gl_REPLACE_VFPRINTF
fi
--- 31,37 ----
;;
esac
if test $gl_cv_func_vfprintf_posix = no; then
! gl_PREREQ_VASNPRINTF_DIRECTIVE_A
gl_REPLACE_VASNPRINTF
gl_REPLACE_VFPRINTF
fi
*** m4/vsnprintf-posix.m4 9 Mar 2007 01:24:32 -0000 1.2
--- m4/vsnprintf-posix.m4 26 Mar 2007 02:08:17 -0000
***************
*** 1,4 ****
! # vsnprintf-posix.m4 serial 1
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # vsnprintf-posix.m4 serial 2
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 51,61 ****
esac
fi
if test $gl_cv_func_vsnprintf_posix = no; then
! if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
! AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
! [Define if the vasnprintf implementation needs special code for
! the 'a' and 'A' directives.])
! fi
gl_REPLACE_VASNPRINTF
gl_REPLACE_VSNPRINTF
fi
--- 51,57 ----
esac
fi
if test $gl_cv_func_vsnprintf_posix = no; then
! gl_PREREQ_VASNPRINTF_DIRECTIVE_A
gl_REPLACE_VASNPRINTF
gl_REPLACE_VSNPRINTF
fi
*** m4/vsprintf-posix.m4 9 Mar 2007 01:24:32 -0000 1.2
--- m4/vsprintf-posix.m4 26 Mar 2007 02:08:17 -0000
***************
*** 1,4 ****
! # vsprintf-posix.m4 serial 1
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # vsprintf-posix.m4 serial 2
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 31,41 ****
;;
esac
if test $gl_cv_func_vsprintf_posix = no; then
! if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
! AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
! [Define if the vasnprintf implementation needs special code for
! the 'a' and 'A' directives.])
! fi
gl_REPLACE_VASNPRINTF
gl_REPLACE_VSPRINTF
fi
--- 31,37 ----
;;
esac
if test $gl_cv_func_vsprintf_posix = no; then
! gl_PREREQ_VASNPRINTF_DIRECTIVE_A
gl_REPLACE_VASNPRINTF
gl_REPLACE_VSPRINTF
fi
- use of thread-unsafe localeconv in vasprintf, Simon Josefsson, 2007/03/17
- Re: use of thread-unsafe localeconv in vasprintf, Simon Josefsson, 2007/03/22
- Re: use of thread-unsafe localeconv in vasprintf, Bruno Haible, 2007/03/22
- Re: use of thread-unsafe localeconv in vasprintf,
Bruno Haible <=
- Re: use of thread-unsafe localeconv in vasprintf, Ralf Wildenhues, 2007/03/26
- Re: use of thread-unsafe localeconv in vasprintf, Bruno Haible, 2007/03/26
- Re: use of thread-unsafe localeconv in vasprintf, Eric Blake, 2007/03/26
- Re: use of thread-unsafe localeconv in vasprintf, Eric Blake, 2007/03/26
- Re: use of thread-unsafe localeconv in vasprintf, Bruno Haible, 2007/03/26
- Re: use of thread-unsafe localeconv in vasprintf, Simon Josefsson, 2007/03/27
- Re: use of thread-unsafe localeconv in vasprintf, Bruno Haible, 2007/03/27
- Re: use of thread-unsafe localeconv in vasprintf, Simon Josefsson, 2007/03/27
- Re: use of thread-unsafe localeconv in vasprintf, Bruno Haible, 2007/03/27