git-merge-changelog: Simplify installation instructions.
[gnulib.git] / m4 / snprintf.m4
blob6dbe146f7b879379dd29215ead4dc5fb0e726c9d
1 # snprintf.m4
2 # serial 7
3 dnl Copyright (C) 2002-2004, 2007-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 dnl Libintl 0.17 will replace snprintf only if it does not support %1$s,
9 dnl but defers to any gnulib snprintf replacements.  Therefore, gnulib
10 dnl must guarantee that the decision for replacing snprintf is a superset
11 dnl of the reasons checked by libintl.
12 AC_DEFUN([gl_FUNC_SNPRINTF],
14   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
15   gl_cv_func_snprintf_usable=no
16   AC_CHECK_FUNCS([snprintf])
17   if test $ac_cv_func_snprintf = yes; then
18     gl_SNPRINTF_SIZE1
19     case "$gl_cv_func_snprintf_size1" in
20       *yes)
21         gl_SNPRINTF_RETVAL_C99
22         case "$gl_cv_func_snprintf_retval_c99" in
23           *yes)
24             gl_PRINTF_POSITIONS
25             case "$gl_cv_func_printf_positions" in
26               *yes)
27                 gl_cv_func_snprintf_usable=yes
28                 ;;
29             esac
30             ;;
31         esac
32         ;;
33     esac
34   fi
35   if test $gl_cv_func_snprintf_usable = no; then
36     gl_REPLACE_SNPRINTF
37   fi
38   AC_CHECK_DECLS_ONCE([snprintf])
39   if test $ac_cv_have_decl_snprintf = no; then
40     HAVE_DECL_SNPRINTF=0
41   fi
44 AC_DEFUN([gl_REPLACE_SNPRINTF],
46   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
47   AC_LIBOBJ([snprintf])
48   if test $ac_cv_func_snprintf = yes; then
49     REPLACE_SNPRINTF=1
50   else
51     AC_CHECK_DECLS_ONCE([snprintf])
52     if test $ac_cv_have_decl_snprintf = yes; then
53       dnl If the function is declared but does not appear to exist, it may be
54       dnl defined as an inline function. In order to avoid a conflict, we have
55       dnl to define rpl_snprintf, not snprintf.
56       REPLACE_SNPRINTF=1
57     fi
58   fi
59   gl_PREREQ_SNPRINTF
62 # Prerequisites of lib/snprintf.c.
63 AC_DEFUN([gl_PREREQ_SNPRINTF], [:])