master
 1/**
 2 * This file has no copyright assigned and is placed in the Public Domain.
 3 * This file is part of the mingw-w64 runtime package.
 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 5 */
 6
 7#undef __MSVCRT_VERSION__
 8#define _UCRT
 9#include <stdio.h>
10
11int __cdecl swprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...)
12{
13  __builtin_va_list __ap;
14  int __ret;
15  /*
16   * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and
17   * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is
18   * executed in "standard snprintf behavior" and returns number of (wide)
19   * chars required to allocate. For all other cases it is executed in a way
20   * that returns negative value on error. But C95+ compliant swprintf() for
21   * case _Count == 0 returns negative value, so handle this case specially.
22   */
23  if (_Dest == NULL && _Count == 0)
24    return -1;
25  __builtin_va_start(__ap, _Format);
26  __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, _Count, _Format, NULL, __ap);
27  __builtin_va_end(__ap);
28  return __ret < 0 ? -1 : __ret;
29}