File: pa_func_vsnprintf.m4

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (50 lines) | stat: -rw-r--r-- 1,582 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
dnl --------------------------------------------------------------------------
dnl PA_FUNC_VSNPRINTF
dnl
dnl See if we have [_]vsnprintf(), using the proper prototypes in case
dnl it is a builtin of some kind.
dnl --------------------------------------------------------------------------
AC_DEFUN([PA_FUNC_VSNPRINTF],
[AC_CACHE_CHECK([for vsnprintf], [pa_cv_func_vsnprintf],
 [pa_cv_func_vsnprintf=no
  for pa_try_func_vsnprintf in vsnprintf _vsnprintf
  do
  AS_IF([test $pa_cv_func_vsnprintf = no],
        [AC_LINK_IFELSE([AC_LANG_SOURCE([
AC_INCLUDES_DEFAULT
const char *vsnprintf_test(const char *fmt, va_list va);
const char *vsnprintf_test(const char *fmt, va_list va)
{
    static char buf[[256]];
    size_t sz;
    sz = $pa_try_func_vsnprintf(buf, sizeof buf, fmt, va);
    return (sz < sizeof buf) ? buf : NULL;
}

const char *vsnprintf_caller(const char *fmt, ...);
const char *vsnprintf_caller(const char *fmt, ...)
{
    const char *what;
    va_list va;
    va_start(va, fmt);
    what = vsnprintf_test(fmt, va);
    va_end(va);
    return what;
}

int main(void) {
    puts(vsnprintf_caller("Hello = %d", 33));
    return 0;
}
])],
 [pa_cv_func_vsnprintf=$pa_try_func_vsnprintf])])
 done
 ])
 AS_IF([test $pa_cv_func_vsnprintf = no],
       [],
       [AC_DEFINE([HAVE_VSNPRINTF], 1,
         [Define to 1 if you have some version of the vsnprintf function.])
	 AS_IF([test $pa_cv_func_vsnprintf = vsnprintf],
	       [],
	       [AC_DEFINE_UNQUOTED([vsnprintf], [$pa_cv_func_vsnprintf],
	         [Define if your vsnprintf function is not named vsnprintf.])])])])