src/string.cpp
changeset 5630 2bbfa6ea3545
parent 5609 dc6a58930ba4
child 5631 fd4e111c7ce2
equal deleted inserted replaced
5629:6c255b78703f 5630:2bbfa6ea3545
   158 	va_end(ap);
   158 	va_end(ap);
   159 	return ret;
   159 	return ret;
   160 }
   160 }
   161 
   161 
   162 #ifdef _MSC_VER
   162 #ifdef _MSC_VER
       
   163 /* *nprintf broken, not POSIX compliant, MSDN description
       
   164  * - If len < count, then len characters are stored in buffer, a null-terminator is appended, and len is returned.
       
   165  * - If len = count, then len characters are stored in buffer, no null-terminator is appended, and len is returned.
       
   166  * - If len > count, then count characters are stored in buffer, no null-terminator is appended, and a negative value is returned
       
   167  */
   163 int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap)
   168 int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap)
   164 {
   169 {
   165 	int ret;
   170 	int ret;
   166 	ret = _vsnprintf(str, size, format, ap);
   171 	ret = _vsnprintf(str, size, format, ap);
   167 	if (ret < 0) str[size - 1] = '\0';
   172 	if (ret < 0 || ret == 0) str[size - 1] = '\0';
   168 	return ret;
   173 	return ret;
   169 }
   174 }
   170 #endif /* _MSC_VER */
   175 #endif /* _MSC_VER */
   171 
   176 
   172 #endif /* WIN32 */
   177 #endif /* WIN32 */