1*946379e7Schristos# printf-posix.m4 serial 2 (gettext-0.13.1) 2*946379e7Schristosdnl Copyright (C) 2003 Free Software Foundation, Inc. 3*946379e7Schristosdnl This file is free software; the Free Software Foundation 4*946379e7Schristosdnl gives unlimited permission to copy and/or distribute it, 5*946379e7Schristosdnl with or without modifications, as long as this notice is preserved. 6*946379e7Schristos 7*946379e7Schristosdnl From Bruno Haible. 8*946379e7Schristosdnl Test whether the printf() function supports POSIX/XSI format strings with 9*946379e7Schristosdnl positions. 10*946379e7Schristos 11*946379e7SchristosAC_DEFUN([gt_PRINTF_POSIX], 12*946379e7Schristos[ 13*946379e7Schristos AC_REQUIRE([AC_PROG_CC]) 14*946379e7Schristos AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings], 15*946379e7Schristos gt_cv_func_printf_posix, 16*946379e7Schristos [ 17*946379e7Schristos AC_TRY_RUN([ 18*946379e7Schristos#include <stdio.h> 19*946379e7Schristos#include <string.h> 20*946379e7Schristos/* The string "%2$d %1$d", with dollar characters protected from the shell's 21*946379e7Schristos dollar expansion (possibly an autoconf bug). */ 22*946379e7Schristosstatic char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; 23*946379e7Schristosstatic char buf[100]; 24*946379e7Schristosint main () 25*946379e7Schristos{ 26*946379e7Schristos sprintf (buf, format, 33, 55); 27*946379e7Schristos return (strcmp (buf, "55 33") != 0); 28*946379e7Schristos}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, 29*946379e7Schristos [ 30*946379e7Schristos AC_EGREP_CPP(notposix, [ 31*946379e7Schristos#if defined __NetBSD__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ 32*946379e7Schristos notposix 33*946379e7Schristos#endif 34*946379e7Schristos ], gt_cv_func_printf_posix="guessing no", 35*946379e7Schristos gt_cv_func_printf_posix="guessing yes") 36*946379e7Schristos ]) 37*946379e7Schristos ]) 38*946379e7Schristos case $gt_cv_func_printf_posix in 39*946379e7Schristos *yes) 40*946379e7Schristos AC_DEFINE(HAVE_POSIX_PRINTF, 1, 41*946379e7Schristos [Define if your printf() function supports format strings with positions.]) 42*946379e7Schristos ;; 43*946379e7Schristos esac 44*946379e7Schristos]) 45