• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* sprintf.c
2  *
3  * $Id: sprintf.c,v 1.1 2008/08/11 22:41:55 keithmarshall Exp $
4  *
5  * Provides an implementation of the "sprintf" function, conforming
6  * generally to C99 and SUSv3/POSIX specifications, with extensions
7  * to support Microsoft's non-standard format specifications.  This
8  * is included in libmingwex.a, whence it may replace the Microsoft
9  * function of the same name.
10  *
11  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
12  *
13  * This implementation of "sprintf" will normally be invoked by calling
14  * "__mingw_sprintf()" in preference to a direct reference to "sprintf()"
15  * itself; this leaves the MSVCRT implementation as the default, which
16  * will be deployed when user code invokes "sprint()".  Users who then
17  * wish to use this implementation may either call "__mingw_sprintf()"
18  * directly, or may use conditional preprocessor defines, to redirect
19  * references to "sprintf()" to "__mingw_sprintf()".
20  *
21  * Compiling this module with "-D INSTALL_AS_DEFAULT" will change this
22  * recommended convention, such that references to "sprintf()" in user
23  * code will ALWAYS be redirected to "__mingw_sprintf()"; if this option
24  * is adopted, then users wishing to use the MSVCRT implementation of
25  * "sprintf()" will be forced to use a "back-door" mechanism to do so.
26  * Such a "back-door" mechanism is provided with MinGW, allowing the
27  * MSVCRT implementation to be called as "__msvcrt_sprintf()"; however,
28  * since users may not expect this behaviour, a standard libmingwex.a
29  * installation does not employ this option.
30  *
31  *
32  * This is free software.  You may redistribute and/or modify it as you
33  * see fit, without restriction of copyright.
34  *
35  * This software is provided "as is", in the hope that it may be useful,
36  * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of
37  * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE.  At no
38  * time will the author accept any form of liability for any damages,
39  * however caused, resulting from the use of this software.
40  *
41  */
42 #include <stdio.h>
43 #include <stdarg.h>
44 
45 #include "mingw_pformat.h"
46 
47 int __cdecl __sprintf (APICHAR *, const APICHAR *, ...) __MINGW_NOTHROW;
48 
__sprintf(APICHAR * buf,const APICHAR * fmt,...)49 int __cdecl __sprintf(APICHAR *buf, const APICHAR *fmt, ...)
50 {
51   register int retval;
52   va_list argv; va_start( argv, fmt );
53   buf[retval = __pformat( PFORMAT_NOLIMIT, buf, 0, fmt, argv )] = '\0';
54   va_end( argv );
55   return retval;
56 }
57