src/string.cpp
branchNewGRF_ports
changeset 6872 1c4a4a609f85
parent 6871 5a9dc001e1ad
child 10724 68a692eacf22
equal deleted inserted replaced
6871:5a9dc001e1ad 6872:1c4a4a609f85
     2 
     2 
     3 /** @file string.cpp */
     3 /** @file string.cpp */
     4 
     4 
     5 #include "stdafx.h"
     5 #include "stdafx.h"
     6 #include "openttd.h"
     6 #include "openttd.h"
     7 #include "functions.h"
     7 #include "debug.h"
     8 #include "string.h"
     8 #include "core/alloc_func.hpp"
     9 #include "macros.h"
     9 #include "string_func.h"
       
    10 
    10 #include "table/control_codes.h"
    11 #include "table/control_codes.h"
    11 #include "helpers.hpp"
       
    12 #include "debug.h"
       
    13 
    12 
    14 #include <stdarg.h>
    13 #include <stdarg.h>
    15 #include <ctype.h> // required for tolower()
    14 #include <ctype.h> // required for tolower()
    16 
    15 
    17 void ttd_strlcat(char *dst, const char *src, size_t size)
    16 void ttd_strlcat(char *dst, const char *src, size_t size)
   153 
   152 
   154 	return false;
   153 	return false;
   155 }
   154 }
   156 
   155 
   157 #ifdef WIN32
   156 #ifdef WIN32
       
   157 /* Since version 3.14, MinGW Runtime has snprintf() and vsnprintf() conform to C99 but it's not the case for older versions */
       
   158 #if (__MINGW32_MAJOR_VERSION < 3) || ((__MINGW32_MAJOR_VERSION == 3) && (__MINGW32_MINOR_VERSION < 14))
   158 int CDECL snprintf(char *str, size_t size, const char *format, ...)
   159 int CDECL snprintf(char *str, size_t size, const char *format, ...)
   159 {
   160 {
   160 	va_list ap;
   161 	va_list ap;
   161 	int ret;
   162 	int ret;
   162 
   163 
   163 	va_start(ap, format);
   164 	va_start(ap, format);
   164 	ret = vsnprintf(str, size, format, ap);
   165 	ret = vsnprintf(str, size, format, ap);
   165 	va_end(ap);
   166 	va_end(ap);
   166 	return ret;
   167 	return ret;
   167 }
   168 }
       
   169 #endif /* MinGW Runtime < 3.14 */
   168 
   170 
   169 #ifdef _MSC_VER
   171 #ifdef _MSC_VER
   170 /* *nprintf broken, not POSIX compliant, MSDN description
   172 /* *nprintf broken, not POSIX compliant, MSDN description
   171  * - If len < count, then len characters are stored in buffer, a null-terminator is appended, and len is returned.
   173  * - If len < count, then len characters are stored in buffer, a null-terminator is appended, and len is returned.
   172  * - If len = count, then len characters are stored in buffer, no null-terminator is appended, and len is returned.
   174  * - If len = count, then len characters are stored in buffer, no null-terminator is appended, and len is returned.