• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
2# This file is free software; the Free Software Foundation
3# gives unlimited permission to copy and/or distribute it,
4# with or without modifications, as long as this notice is preserved.
5
6# Test whether the *printf family of functions supports padding of non-finite
7# values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
8# <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html>
9# Result is gl_cv_func_printf_flag_zero.
10
11printf_flag_zero_test = '''
12#include <stdio.h>
13#include <string.h>
14static char buf[100];
15static double zero = 0.0;
16int main ()
17{
18  if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
19      || (strcmp (buf, "       inf") != 0
20          && strcmp (buf, "  infinity") != 0))
21    return 1;
22  return 0;
23}
24'''
25
26if not meson.is_cross_build() or meson.has_exe_wrapper()
27  run_result = cc.run(printf_flag_zero_test,
28      name : 'printf supports the zero flag correctly')
29  gl_cv_func_printf_flag_zero = run_result.compiled() and run_result.returncode() == 0
30else
31  if host_system in ['linux', 'android']
32    gl_cv_func_printf_flag_zero = true
33  elif host_system.startswith ('beos')
34    gl_cv_func_printf_flag_zero = true
35  elif host_system == 'windows'
36    gl_cv_func_printf_flag_zero = false
37  else
38    gl_cv_func_printf_flag_zero = false
39  endif
40endif
41