Blame m4/printf-posix.m4

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