Commit | Line | Data |
---|---|---|
c9be6cfe KB |
1 | /*- |
2 | * Copyright (c) 1990 The Regents of the University of California. | |
6f109318 KB |
3 | * All rights reserved. |
4 | * | |
c9be6cfe KB |
5 | * This code is derived from software contributed to Berkeley by |
6 | * Chris Torek. | |
7 | * | |
019bea33 | 8 | * %sccs.include.redist.c% |
6f109318 KB |
9 | */ |
10 | ||
2ce81398 | 11 | #if defined(LIBC_SCCS) && !defined(lint) |
c9be6cfe | 12 | static char sccsid[] = "@(#)sprintf.c 5.7 (Berkeley) %G%"; |
6f109318 | 13 | #endif /* LIBC_SCCS and not lint */ |
b8f253e8 | 14 | |
6f109318 | 15 | #include <stdio.h> |
c9be6cfe KB |
16 | #if __STDC__ |
17 | #include <stdarg.h> | |
18 | #else | |
19 | #include <varargs.h> | |
20 | #endif | |
21 | #include <limits.h> | |
22 | #include "local.h" | |
a156cccf | 23 | |
c9be6cfe KB |
24 | #if __STDC__ |
25 | sprintf(char *str, char const *fmt, ...) | |
26 | #else | |
27 | sprintf(str, fmt, va_alist) | |
28 | char *str; | |
29 | char *fmt; | |
30 | va_dcl | |
31 | #endif | |
a156cccf | 32 | { |
c9be6cfe KB |
33 | int ret; |
34 | va_list ap; | |
35 | FILE f; | |
a156cccf | 36 | |
c9be6cfe KB |
37 | f._flags = __SWR | __SSTR; |
38 | f._bf._base = f._p = (unsigned char *)str; | |
39 | f._bf._size = f._w = INT_MAX; | |
40 | #if __STDC__ | |
41 | va_start(ap, fmt); | |
42 | #else | |
43 | va_start(ap); | |
44 | #endif | |
45 | ret = vfprintf(&f, fmt, ap); | |
46 | va_end(ap); | |
47 | *f._p = 0; | |
48 | return (ret); | |
a156cccf | 49 | } |