Blame m4/printf-posix.m4

Packit 575503
# printf-posix.m4 serial 6 (gettext-0.18.2)
Packit 575503
dnl Copyright (C) 2003, 2007, 2009-2014 Free Software Foundation, Inc.
Packit 575503
dnl This file is free software; the Free Software Foundation
Packit 575503
dnl gives unlimited permission to copy and/or distribute it,
Packit 575503
dnl with or without modifications, as long as this notice is preserved.
Packit 575503
Packit 575503
dnl From Bruno Haible.
Packit 575503
dnl Test whether the printf() function supports POSIX/XSI format strings with
Packit 575503
dnl positions.
Packit 575503
Packit 575503
AC_DEFUN([gt_PRINTF_POSIX],
Packit 575503
[
Packit 575503
  AC_REQUIRE([AC_PROG_CC])
Packit 575503
  AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings],
Packit 575503
    gt_cv_func_printf_posix,
Packit 575503
    [
Packit 575503
      AC_RUN_IFELSE(
Packit 575503
        [AC_LANG_SOURCE([[
Packit 575503
#include <stdio.h>
Packit 575503
#include <string.h>
Packit 575503
/* The string "%2$d %1$d", with dollar characters protected from the shell's
Packit 575503
   dollar expansion (possibly an autoconf bug).  */
Packit 575503
static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
Packit 575503
static char buf[100];
Packit 575503
int main ()
Packit 575503
{
Packit 575503
  sprintf (buf, format, 33, 55);
Packit 575503
  return (strcmp (buf, "55 33") != 0);
Packit 575503
}]])],
Packit 575503
        [gt_cv_func_printf_posix=yes],
Packit 575503
        [gt_cv_func_printf_posix=no],
Packit 575503
        [
Packit 575503
          AC_EGREP_CPP([notposix], [
Packit 575503
#if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__
Packit 575503
  notposix
Packit 575503
#endif
Packit 575503
            ],
Packit 575503
            [gt_cv_func_printf_posix="guessing no"],
Packit 575503
            [gt_cv_func_printf_posix="guessing yes"])
Packit 575503
        ])
Packit 575503
    ])
Packit 575503
  case $gt_cv_func_printf_posix in
Packit 575503
    *yes)
Packit 575503
      AC_DEFINE([HAVE_POSIX_PRINTF], [1],
Packit 575503
        [Define if your printf() function supports format strings with positions.])
Packit 575503
      ;;
Packit 575503
  esac
Packit 575503
])