annotate m4/snprintf-posix.m4 @ 8763:39bb5430fc0e

Guard against vsnprintf implementations that mishandle a size=0 argument.
author Bruno Haible <bruno@clisp.org>
date Sun, 29 Apr 2007 15:40:30 +0000
parents 40c507f55b0f
children 6c1d98929550
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8763
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8664
diff changeset
1 # snprintf-posix.m4 serial 4
8366
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 dnl Copyright (C) 2007 Free Software Foundation, Inc.
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_SNPRINTF_POSIX],
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 AC_REQUIRE([gl_EOVERFLOW])
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 AC_REQUIRE([gl_PRINTF_SIZES_C99])
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
12 AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
8366
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 AC_REQUIRE([gl_PRINTF_DIRECTIVE_N])
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 AC_REQUIRE([gl_PRINTF_POSITIONS])
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 gl_cv_func_snprintf_posix=no
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 AC_CHECK_FUNCS([snprintf])
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 if test $ac_cv_func_snprintf = yes; then
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 gl_SNPRINTF_TRUNCATION_C99
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 gl_SNPRINTF_RETVAL_C99
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 gl_SNPRINTF_DIRECTIVE_N
8763
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8664
diff changeset
21 gl_VSNPRINTF_ZEROSIZE_C99
8389
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
22 case "$gl_cv_func_printf_sizes_c99" in
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
23 *yes)
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
24 case "$gl_cv_func_printf_directive_a" in
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
25 *yes)
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
26 case "$gl_cv_func_printf_directive_f" in
8389
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
27 *yes)
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
28 case "$gl_cv_func_printf_directive_n" in
8389
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
29 *yes)
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
30 case "$gl_cv_func_printf_positions" in
8389
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
31 *yes)
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
32 case "$gl_cv_func_snprintf_truncation_c99" in
8389
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
33 *yes)
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
34 case "$gl_cv_func_snprintf_retval_c99" in
8389
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
35 *yes)
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
36 case "$gl_cv_func_snprintf_directive_n" in
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
37 *yes)
8763
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8664
diff changeset
38 case "$gl_cv_func_vsnprintf_zerosize_c99" in
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8664
diff changeset
39 *yes)
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8664
diff changeset
40 # snprintf exists and is already POSIX
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8664
diff changeset
41 # compliant.
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8664
diff changeset
42 gl_cv_func_snprintf_posix=yes
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8664
diff changeset
43 ;;
39bb5430fc0e Guard against vsnprintf implementations that mishandle a size=0 argument.
Bruno Haible <bruno@clisp.org>
parents: 8664
diff changeset
44 esac
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
45 ;;
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
46 esac
8389
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
47 ;;
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
48 esac
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
49 ;;
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
50 esac
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
51 ;;
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
52 esac
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
53 ;;
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
54 esac
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
55 ;;
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
56 esac
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
57 ;;
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
58 esac
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
59 ;;
e7c9cf0455da Use 'case' statements instead of 'expr' invocations.
Bruno Haible <bruno@clisp.org>
parents: 8366
diff changeset
60 esac
8366
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 fi
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 if test $gl_cv_func_snprintf_posix = no; then
8554
35eb5062216c Prefer nl_langinfo over localeconv.
Bruno Haible <bruno@clisp.org>
parents: 8389
diff changeset
63 gl_PREREQ_VASNPRINTF_DIRECTIVE_A
8664
40c507f55b0f Implement the %F directive if the system doesn't implement it correctly.
Bruno Haible <bruno@clisp.org>
parents: 8554
diff changeset
64 gl_PREREQ_VASNPRINTF_DIRECTIVE_F
8366
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 gl_REPLACE_VASNPRINTF
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 gl_REPLACE_SNPRINTF
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 fi
9b66860c2482 New module 'snprintf-posix'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 ])