Work around lack of support of grouping flag.
[gnulib.git] / m4 / sprintf-posix.m4
1 # sprintf-posix.m4 serial 4
2 dnl Copyright (C) 2007 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.
6
7 AC_DEFUN([gl_FUNC_SPRINTF_POSIX],
8 [
9   AC_REQUIRE([gl_EOVERFLOW])
10   AC_REQUIRE([gl_PRINTF_SIZES_C99])
11   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
12   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
13   AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
14   AC_REQUIRE([gl_PRINTF_POSITIONS])
15   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
16   gl_cv_func_sprintf_posix=no
17   case "$gl_cv_func_printf_sizes_c99" in
18     *yes)
19       case "$gl_cv_func_printf_directive_a" in
20         *yes)
21           case "$gl_cv_func_printf_directive_f" in
22             *yes)
23               case "$gl_cv_func_printf_directive_n" in
24                 *yes)
25                   case "$gl_cv_func_printf_positions" in
26                     *yes)
27                       case "$gl_cv_func_printf_flag_grouping" in
28                         *yes)
29                           # sprintf exists and is already POSIX compliant.
30                           gl_cv_func_sprintf_posix=yes
31                           ;;
32                       esac
33                       ;;
34                   esac
35                   ;;
36               esac
37               ;;
38           esac
39           ;;
40       esac
41       ;;
42   esac
43   if test $gl_cv_func_sprintf_posix = no; then
44     gl_PREREQ_VASNPRINTF_DIRECTIVE_A
45     gl_PREREQ_VASNPRINTF_DIRECTIVE_F
46     gl_PREREQ_VASNPRINTF_FLAG_GROUPING
47     gl_REPLACE_VASNPRINTF
48     gl_REPLACE_SPRINTF
49   fi
50 ])
51
52 AC_DEFUN([gl_REPLACE_SPRINTF],
53 [
54   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
55   AC_LIBOBJ([sprintf])
56   REPLACE_SPRINTF=1
57   gl_PREREQ_SPRINTF
58 ])
59
60 AC_DEFUN([gl_PREREQ_SPRINTF], [:])