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