// Copyright (C) 2010, Guy Barrand. All rights reserved.
// See the file tools.license for terms.

#ifndef tools_snpf
#define tools_snpf

#include <cstdarg>
#include <cstdio>

namespace tools {

inline int vsnpf(char* a_s,size_t a_n,const char* a_fmt,va_list args){
#ifdef _MSC_VER
#if _MSC_VER < 1900
  unsigned int old = _set_output_format(_TWO_DIGIT_EXPONENT);
  int status = _vsnprintf(a_s,a_n,a_fmt,args);
  _set_output_format(old);
  return status;
#else
  return _vsnprintf(a_s,a_n,a_fmt,args);
#endif
#else
  return ::vsnprintf(a_s,a_n,a_fmt,args);
#endif
}

inline int snpf(char* a_s,size_t a_n,const char* a_fmt,...){
  va_list args;
  va_start(args,a_fmt);
  int n = vsnpf(a_s,a_n,a_fmt,args);
  va_end(args);
  return n;
}


}

#endif
