1*a1acfa9bSespie# printf-posix.m4 serial 2 (gettext-0.13.1) 2*a1acfa9bSespiednl Copyright (C) 2003 Free Software Foundation, Inc. 3*a1acfa9bSespiednl This file is free software, distributed under the terms of the GNU 4*a1acfa9bSespiednl General Public License. As a special exception to the GNU General 5*a1acfa9bSespiednl Public License, this file may be distributed as part of a program 6*a1acfa9bSespiednl that contains a configuration script generated by Autoconf, under 7*a1acfa9bSespiednl the same distribution terms as the rest of that program. 8*a1acfa9bSespie 9*a1acfa9bSespiednl From Bruno Haible. 10*a1acfa9bSespiednl Test whether the printf() function supports POSIX/XSI format strings with 11*a1acfa9bSespiednl positions. 12*a1acfa9bSespie 13*a1acfa9bSespieAC_DEFUN([gt_PRINTF_POSIX], 14*a1acfa9bSespie[ 15*a1acfa9bSespie AC_REQUIRE([AC_PROG_CC]) 16*a1acfa9bSespie AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings], 17*a1acfa9bSespie gt_cv_func_printf_posix, 18*a1acfa9bSespie [ 19*a1acfa9bSespie AC_TRY_RUN([ 20*a1acfa9bSespie#include <stdio.h> 21*a1acfa9bSespie#include <string.h> 22*a1acfa9bSespie/* The string "%2$d %1$d", with dollar characters protected from the shell's 23*a1acfa9bSespie dollar expansion (possibly an autoconf bug). */ 24*a1acfa9bSespiestatic char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; 25*a1acfa9bSespiestatic char buf[100]; 26*a1acfa9bSespieint main () 27*a1acfa9bSespie{ 28*a1acfa9bSespie sprintf (buf, format, 33, 55); 29*a1acfa9bSespie return (strcmp (buf, "55 33") != 0); 30*a1acfa9bSespie}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, 31*a1acfa9bSespie [ 32*a1acfa9bSespie AC_EGREP_CPP(notposix, [ 33*a1acfa9bSespie#if defined __NetBSD__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ 34*a1acfa9bSespie notposix 35*a1acfa9bSespie#endif 36*a1acfa9bSespie ], gt_cv_func_printf_posix="guessing no", 37*a1acfa9bSespie gt_cv_func_printf_posix="guessing yes") 38*a1acfa9bSespie ]) 39*a1acfa9bSespie ]) 40*a1acfa9bSespie case $gt_cv_func_printf_posix in 41*a1acfa9bSespie *yes) 42*a1acfa9bSespie AC_DEFINE(HAVE_POSIX_PRINTF, 1, 43*a1acfa9bSespie [Define if your printf() function supports format strings with positions.]) 44*a1acfa9bSespie ;; 45*a1acfa9bSespie esac 46*a1acfa9bSespie]) 47