Debian Codegraph @

texk/xdvik/m4/xdvi-func-working-vsnprintf.m4

raw
1 # Autoconf macros for xdvik.
2 # Copyright (C) 2002 Paul Vojta <[email protected]>
3 # Copyright (C) 2002 - 2009 Stefan Ulrich <[email protected]>
4 #
5 # This file is free software; the copyright holder
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # XDVI_FUNC_WORKING_VSNPRINTF
10 # ---------------------------
11 # Check for a working implementation of (v)snprintf()
12 # which should either return a negative result or the size actually needed
13 # (latter is C99 standard).
14 AC_DEFUN([XDVI_FUNC_WORKING_VSNPRINTF],
15 [AC_CACHE_CHECK([for a working implementation of (v)snprintf()],
16 [xdvi_cv_func_good_vsnprintf],
17 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
18 #ifdef IRIX
19 #define _XOPEN_SOURCE 500
20 #endif
21 #include <stdio.h>]],
22 [[char s[2];
23 int retval = snprintf(s, 2, "test");
24 if (retval > -1 && retval != 4) /* neither negative nor desired size, not OK */
25 return 1;]])],
26 [xdvi_cv_func_good_vsnprintf=yes],
27 [xdvi_cv_func_good_vsnprintf=no],
28 [xdvi_cv_func_good_vsnprintf=no # safe value for cross-compiling])])
29 if test "x$xdvi_cv_func_good_vsnprintf" = xyes; then
30 AC_DEFINE([HAVE_GOOD_VSNPRINTF], 1, [Define if the vsnprintf function works.])
31 fi
32 ]) # XDVI_FUNC_WORKING_VSNPRINTF