Bug 522299 - fix linux bustage.
[mozilla-central.git] / dbm / src / snprintf.c
blob96696d8e8721c43c3ef82e4e26b4d001f5a8fa26
1 #ifndef HAVE_SNPRINTF
3 #include <sys/types.h>
4 #include <stddef.h>
5 #include <stdio.h>
7 #ifdef HAVE_SYS_CDEFS_H
8 #include <sys/cdefs.h>
9 #else
10 #include "cdefs.h"
11 #endif
13 #include "prtypes.h"
15 #include <ncompat.h>
17 #ifdef __STDC__
18 #include <stdarg.h>
19 #else
20 #include <varargs.h>
21 #endif
23 int
24 #ifdef __STDC__
25 snprintf(char *str, size_t n, const char *fmt, ...)
26 #else
27 snprintf(str, n, fmt, va_alist)
28 char *str;
29 size_t n;
30 const char *fmt;
31 va_dcl
32 #endif
34 va_list ap;
35 #ifdef VSPRINTF_CHARSTAR
36 char *rp;
37 #else
38 int rval;
39 #endif
40 #ifdef __STDC__
41 va_start(ap, fmt);
42 #else
43 va_start(ap);
44 #endif
45 #ifdef VSPRINTF_CHARSTAR
46 rp = vsprintf(str, fmt, ap);
47 va_end(ap);
48 return (strlen(rp));
49 #else
50 rval = vsprintf(str, fmt, ap);
51 va_end(ap);
52 return (rval);
53 #endif
56 int
57 vsnprintf(str, n, fmt, ap)
58 char *str;
59 size_t n;
60 const char *fmt;
61 va_list ap;
63 #ifdef VSPRINTF_CHARSTAR
64 return (strlen(vsprintf(str, fmt, ap)));
65 #else
66 return (vsprintf(str, fmt, ap));
67 #endif
70 #endif /* HAVE_SNPRINTF */
72 /* Some compilers don't like an empty source file. */
73 static int dummy = 0;