Skip to content

Commit

Permalink
Added extra version of snprintf for old Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ethouris committed May 27, 2024
1 parent 4e39fd7 commit 5199746
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions srtcore/sfmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,18 +617,24 @@ class obufstream

namespace internal
{
#if defined(_MSC_VER) && _MSC_VER < 1900
#define FMT_SYM_SNPRINTF _snprintf
#define FMT_SIZE_SNPRINTF(bufsize) (bufsize-1)
#else
#define FMT_SYM_SNPRINTF std::snprintf
#define FMT_SIZE_SNPRINTF(bufsize) bufsize
#endif

template<class ValueType>
static inline size_t SNPrintfOne(char* buf, size_t bufsize, const char* fmt, const ValueType& val)
{
return std::snprintf(buf, bufsize, fmt, val);
}

{ return FMT_SYM_SNPRINTF (buf, FMT_SIZE_SNPRINTF(bufsize), fmt, val); }

static inline size_t SNPrintfOne(char* buf, size_t bufsize, const char* fmt, const std::string& val)
{
return std::snprintf(buf, bufsize, fmt, val.c_str());
}
{ return FMT_SYM_SNPRINTF(buf, FMT_SIZE_SNPRINTF(bufsize), fmt, val.c_str()); }

}
#undef FMT_SYM_SNPRINTF
#undef FMT_SIZE_SNPRINTF

template <class Value> inline
internal::form_memory_buffer<> sfmt(const Value& val, const char* fmtspec = 0)
Expand Down

0 comments on commit 5199746

Please sign in to comment.