Changeset - r10300:566a7441c264
[Not reviewed]
master
0 2 0
rubidium - 16 years ago 2008-10-28 15:47:42
rubidium@openttd.org
(svn r14541) -Fix (r14540): mingw didn't like it :(
2 files changed with 17 insertions and 19 deletions:
0 comments (0 inline, 0 general)
src/string.cpp
Show inline comments
 
@@ -14,6 +14,23 @@
 
#include <stdarg.h>
 
#include <ctype.h> // required for tolower()
 

	
 
/**
 
 * Safer implementation of vsnprintf; same as vsnprintf except:
 
 * - last instead of size, i.e. replace sizeof with lastof.
 
 * - return gives the amount of characters added, not what it would add.
 
 * @param str    buffer to write to up to last
 
 * @param last   last character we may write to
 
 * @param format the formatting (see snprintf)
 
 * @param ap     the list of arguments for the format
 
 * @return the number of added characters
 
 */
 
static int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap)
 
{
 
	if (str >= last) return 0;
 
	size_t size = last - str;
 
	return min((int)size, vsnprintf(str, size, format, ap));
 
}
 

	
 
void ttd_strlcat(char *dst, const char *src, size_t size)
 
{
 
	assert(size > 0);
 
@@ -204,24 +221,6 @@ int CDECL seprintf(char *str, const char
 
	return ret;
 
}
 

	
 
/**
 
 * Safer implementation of vsnprintf; same as vsnprintf except:
 
 * - last instead of size, i.e. replace sizeof with lastof.
 
 * - return gives the amount of characters added, not what it would add.
 
 * @param str    buffer to write to up to last
 
 * @param last   last character we may write to
 
 * @param format the formatting (see snprintf)
 
 * @param ap     the list of arguments for the format
 
 * @return the number of added characters
 
 */
 
int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap)
 
{
 
	if (str >= last) return 0;
 
	size_t size = last - str;
 
	return min((int)size, vsnprintf(str, size, format, ap));
 
}
 

	
 

	
 

	
 
/** Convert the md5sum to a hexadecimal string representation
 
 * @param buf buffer to put the md5sum into
src/string_func.h
Show inline comments
 
@@ -42,7 +42,6 @@ char *strecat(char *dst, const char *src
 
char *strecpy(char *dst, const char *src, const char *last);
 

	
 
int CDECL seprintf(char *str, const char *last, const char *format, ...);
 
int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap);
 

	
 
char *CDECL str_fmt(const char *str, ...);
 

	
0 comments (0 inline, 0 general)