Blame src/c99func.c

Packit Service 7770af
/*
Packit Service 7770af
  Copyright (C) 2011 Joseph A. Adams (joeyadams3.14159@gmail.com)
Packit Service 7770af
  All rights reserved.
Packit Service 7770af
Packit Service 7770af
  Permission is hereby granted, free of charge, to any person obtaining a copy
Packit Service 7770af
  of this software and associated documentation files (the "Software"), to deal
Packit Service 7770af
  in the Software without restriction, including without limitation the rights
Packit Service 7770af
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Packit Service 7770af
  copies of the Software, and to permit persons to whom the Software is
Packit Service 7770af
  furnished to do so, subject to the following conditions:
Packit Service 7770af
Packit Service 7770af
  The above copyright notice and this permission notice shall be included in
Packit Service 7770af
  all copies or substantial portions of the Software.
Packit Service 7770af
Packit Service 7770af
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Packit Service 7770af
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Packit Service 7770af
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Packit Service 7770af
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Packit Service 7770af
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Packit Service 7770af
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Packit Service 7770af
  THE SOFTWARE.
Packit Service 7770af
*/
Packit Service 7770af
Packit Service 7770af
#if defined(_MSC_VER) && _MSC_VER < 1900
Packit Service 7770af
Packit Service 7770af
#include <stdio.h>
Packit Service 7770af
#include <stdlib.h>
Packit Service 7770af
#include <stdarg.h>
Packit Service 7770af
Packit Service 7770af
static int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap)
Packit Service 7770af
{
Packit Service 7770af
    int count = -1;
Packit Service 7770af
Packit Service 7770af
    if (size != 0)
Packit Service 7770af
        count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
Packit Service 7770af
    if (count == -1)
Packit Service 7770af
        count = _vscprintf(format, ap);
Packit Service 7770af
Packit Service 7770af
    return count;
Packit Service 7770af
}
Packit Service 7770af
Packit Service 7770af
int snprintf(char* str, size_t size, const char* format, ...)
Packit Service 7770af
{
Packit Service 7770af
    int count;
Packit Service 7770af
    va_list ap;
Packit Service 7770af
Packit Service 7770af
    va_start(ap, format);
Packit Service 7770af
    count = c99_vsnprintf(str, size, format, ap);
Packit Service 7770af
    va_end(ap);
Packit Service 7770af
Packit Service 7770af
    return count;
Packit Service 7770af
}
Packit Service 7770af
Packit Service 7770af
#endif