1 # strfmon_l.m4 serial 2
2 dnl Copyright (C) 2017-2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_STRFMON_L],
9 AC_REQUIRE([gl_MONETARY_H_DEFAULTS])
10 AC_REQUIRE([gt_LOCALE_FR_UTF8])
12 dnl Persuade glibc <monetary.h> to declare strfmon_l().
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 dnl On Mac OS X 10.12, <monetary.h> may declare strfmon_l() if
15 dnl _USE_EXTENDED_LOCALES_ is defined. But this symbol is supposed
16 dnl to be defined by <xlocale.h>, not by us.
18 AC_CHECK_FUNCS_ONCE([strfmon_l])
19 if test $ac_cv_func_strfmon_l = yes; then
20 dnl Test for bug <https://sourceware.org/bugzilla/show_bug.cgi?id=19633>
21 dnl which was fixed in glibc-2.24.
22 AC_CACHE_CHECK([whether strfmon_l works],
23 [gl_cv_strfmon_l_works],
25 dnl Initial guess, used when cross-compiling or when no suitable locale
28 # Guess no on glibc versions < 2.24.
30 AC_EGREP_CPP([Unlucky],
33 #ifdef __GNU_LIBRARY__
34 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24)
39 [gl_cv_strfmon_l_works="guessing no"],
40 [gl_cv_strfmon_l_works="guessing yes"])
42 # Guess no on FreeBSD and Cygwin.
43 freebsd* | cygwin*) gl_cv_strfmon_l_works="guessing no" ;;
44 # Guess yes otherwise.
45 *) gl_cv_strfmon_l_works="guessing yes" ;;
47 if test $LOCALE_FR_UTF8 != none; then
48 AC_CHECK_HEADERS_ONCE([xlocale.h])
59 /* On older glibc systems: expected_buf="$123.50" buf="$123,50"
60 On FreeBSD 12.0, Cygwin 2.9: expected_buf="$123.50" buf="123,50 $"
62 if (setlocale (LC_ALL, "en_US.UTF-8") != NULL)
64 char expected_buf[80];
65 if (strfmon (expected_buf, sizeof (expected_buf), "%.2n", 123.5) >= 0)
66 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
68 locale_t loc = newlocale (LC_ALL_MASK, "en_US.UTF-8", NULL);
69 if (loc != (locale_t) 0)
72 if (strfmon_l (buf, sizeof (buf), loc, "%.2n", 123.5) >= 0)
73 return strcmp (buf, expected_buf) != 0;
79 [gl_cv_strfmon_l_works=yes],
80 [gl_cv_strfmon_l_works=no],
84 if test "$gl_cv_strfmon_l_works" = no; then
92 # Prerequisites of lib/strfmon_l.c.
93 AC_DEFUN([gl_PREREQ_STRFMON_L], [