Blame m4/printf-posix.m4

Packit Service 9f2c4a
# printf-posix.m4 serial 2 (gettext-0.13.1)
Packit Service 9f2c4a
dnl Copyright (C) 2003 Free Software Foundation, Inc.
Packit Service 9f2c4a
dnl This file is free software, distributed under the terms of the GNU
Packit Service 9f2c4a
dnl General Public License.  As a special exception to the GNU General
Packit Service 9f2c4a
dnl Public License, this file may be distributed as part of a program
Packit Service 9f2c4a
dnl that contains a configuration script generated by Autoconf, under
Packit Service 9f2c4a
dnl the same distribution terms as the rest of that program.
Packit Service 9f2c4a
Packit Service 9f2c4a
dnl From Bruno Haible.
Packit Service 9f2c4a
dnl Test whether the printf() function supports POSIX/XSI format strings with
Packit Service 9f2c4a
dnl positions.
Packit Service 9f2c4a
Packit Service 9f2c4a
AC_DEFUN([gt_PRINTF_POSIX],
Packit Service 9f2c4a
[
Packit Service 9f2c4a
  AC_REQUIRE([AC_PROG_CC])
Packit Service 9f2c4a
  AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings],
Packit Service 9f2c4a
    gt_cv_func_printf_posix,
Packit Service 9f2c4a
    [
Packit Service 9f2c4a
      AC_TRY_RUN([
Packit Service 9f2c4a
#include <stdio.h>
Packit Service 9f2c4a
#include <string.h>
Packit Service 9f2c4a
/* The string "%2$d %1$d", with dollar characters protected from the shell's
Packit Service 9f2c4a
   dollar expansion (possibly an autoconf bug).  */
Packit Service 9f2c4a
static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
Packit Service 9f2c4a
static char buf[100];
Packit Service 9f2c4a
int main ()
Packit Service 9f2c4a
{
Packit Service 9f2c4a
  sprintf (buf, format, 33, 55);
Packit Service 9f2c4a
  return (strcmp (buf, "55 33") != 0);
Packit Service 9f2c4a
}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no,
Packit Service 9f2c4a
      [
Packit Service 9f2c4a
        AC_EGREP_CPP(notposix, [
Packit Service 9f2c4a
#if defined __NetBSD__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__
Packit Service 9f2c4a
  notposix
Packit Service 9f2c4a
#endif
Packit Service 9f2c4a
        ], gt_cv_func_printf_posix="guessing no",
Packit Service 9f2c4a
           gt_cv_func_printf_posix="guessing yes")
Packit Service 9f2c4a
      ])
Packit Service 9f2c4a
    ])
Packit Service 9f2c4a
  case $gt_cv_func_printf_posix in
Packit Service 9f2c4a
    *yes)
Packit Service 9f2c4a
      AC_DEFINE(HAVE_POSIX_PRINTF, 1,
Packit Service 9f2c4a
        [Define if your printf() function supports format strings with positions.])
Packit Service 9f2c4a
      ;;
Packit Service 9f2c4a
  esac
Packit Service 9f2c4a
])