Changeset - r21407:7c26f4904e46
[Not reviewed]
master
0 14 0
rubidium - 10 years ago 2014-04-24 19:51:45
rubidium@openttd.org
(svn r26506) -Codechange: replace most of vsnprintf with vseprintf
14 files changed with 25 insertions and 20 deletions:
0 comments (0 inline, 0 general)
src/console.cpp
Show inline comments
 
@@ -137,7 +137,7 @@ void CDECL IConsolePrintF(TextColour col
 
	char buf[ICON_MAX_STREAMSIZE];
 

	
 
	va_start(va, format);
 
	vsnprintf(buf, sizeof(buf), format, va);
 
	vseprintf(buf, lastof(buf), format, va);
 
	va_end(va);
 

	
 
	IConsolePrint(colour_code, buf);
src/debug.cpp
Show inline comments
 
@@ -163,7 +163,7 @@ void CDECL debug(const char *dbg, const 
 

	
 
	va_list va;
 
	va_start(va, format);
 
	vsnprintf(buf, lengthof(buf), format, va);
 
	vseprintf(buf, lastof(buf), format, va);
 
	va_end(va);
 

	
 
	debug_print(dbg, buf);
src/game/game_text.cpp
Show inline comments
 
@@ -31,7 +31,7 @@ void CDECL strgen_warning(const char *s,
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 
	DEBUG(script, 0, "%s:%d: warning: %s", _file, _cur_line, buf);
 
	_warnings++;
 
@@ -42,7 +42,7 @@ void CDECL strgen_error(const char *s, .
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 
	DEBUG(script, 0, "%s:%d: error: %s", _file, _cur_line, buf);
 
	_errors++;
 
@@ -53,7 +53,7 @@ void NORETURN CDECL strgen_fatal(const c
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 
	DEBUG(script, 0, "%s:%d: FATAL: %s", _file, _cur_line, buf);
 
	throw std::exception();
src/misc/str.hpp
Show inline comments
 
@@ -100,7 +100,7 @@ struct CStrA : public CBlobT<char>
 
		int err = 0;
 
		for (;;) {
 
			char *buf = MakeFreeSpace(addSize);
 
			ret = vsnprintf(buf, base::GetReserve(), format, args);
 
			ret = vseprintf(buf, buf + base::GetReserve() - 1, format, args);
 
			if (ret >= (int)base::GetReserve()) {
 
				/* Greater return than given count means needed buffer size. */
 
				addSize = ret + 1;
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -86,7 +86,7 @@ void CDECL NetworkAddChatMessage(TextCol
 
	va_list va;
 

	
 
	va_start(va, message);
 
	vsnprintf(buf, lengthof(buf), message, va);
 
	vseprintf(buf, lastof(buf), message, va);
 
	va_end(va);
 

	
 
	Utf8TrimString(buf, DRAW_STRING_BUFFER);
src/newgrf.cpp
Show inline comments
 
@@ -377,7 +377,7 @@ void CDECL grfmsg(int severity, const ch
 
	va_list va;
 

	
 
	va_start(va, str);
 
	vsnprintf(buf, sizeof(buf), str, va);
 
	vseprintf(buf, lastof(buf), str, va);
 
	va_end(va);
 

	
 
	DEBUG(grf, severity, "[%s:%d] %s", _cur.grfconfig->filename, _cur.nfo_line, buf);
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -400,7 +400,7 @@ struct NewGRFInspectWindow : Window {
 

	
 
		va_list va;
 
		va_start(va, format);
 
		vsnprintf(buf, lengthof(buf), format, va);
 
		vseprintf(buf, lastof(buf), format, va);
 
		va_end(va);
 

	
 
		offset -= this->vscroll->GetPosition();
src/openttd.cpp
Show inline comments
 
@@ -93,7 +93,7 @@ void CDECL usererror(const char *s, ...)
 
	char buf[512];
 

	
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 

	
 
	ShowOSErrorBox(buf, false);
 
@@ -113,7 +113,7 @@ void CDECL error(const char *s, ...)
 
	char buf[512];
 

	
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 

	
 
	ShowOSErrorBox(buf, true);
 
@@ -132,7 +132,7 @@ void CDECL ShowInfoF(const char *str, ..
 
	va_list va;
 
	char buf[1024];
 
	va_start(va, str);
 
	vsnprintf(buf, lengthof(buf), str, va);
 
	vseprintf(buf, lastof(buf), str, va);
 
	va_end(va);
 
	ShowInfo(buf);
 
}
src/script/squirrel.cpp
Show inline comments
 
@@ -21,9 +21,10 @@
 

	
 
/* Due to the different characters for Squirrel, the scsnprintf might be a simple
 
 * snprint which triggers the safeguard. But it isn't always a simple snprintf.
 
 * Likewise for scstrcat. */
 
 * Likewise for scvsnprintf and scstrcat. */
 
#include "../safeguards.h"
 
#undef snprintf
 
#undef vsnprintf
 
#undef strcat
 

	
 
void Squirrel::CompileError(HSQUIRRELVM vm, const SQChar *desc, const SQChar *source, SQInteger line, SQInteger column)
src/settingsgen/settingsgen.cpp
Show inline comments
 
@@ -42,7 +42,7 @@ void NORETURN CDECL error(const char *s,
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 
	fprintf(stderr, "FATAL: %s\n", buf);
 
	exit(1);
src/strgen/strgen.cpp
Show inline comments
 
@@ -53,7 +53,7 @@ void CDECL strgen_warning(const char *s,
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 
	fprintf(stderr, LINE_NUM_FMT("warning"), _file, _cur_line, buf);
 
	_warnings++;
 
@@ -64,7 +64,7 @@ void CDECL strgen_error(const char *s, .
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 
	fprintf(stderr, LINE_NUM_FMT("error"), _file, _cur_line, buf);
 
	_errors++;
 
@@ -75,7 +75,7 @@ void NORETURN CDECL strgen_fatal(const c
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 
	fprintf(stderr, LINE_NUM_FMT("FATAL"), _file, _cur_line, buf);
 
#ifdef _MSC_VER
 
@@ -89,7 +89,7 @@ void NORETURN CDECL error(const char *s,
 
	char buf[1024];
 
	va_list va;
 
	va_start(va, s);
 
	vsnprintf(buf, lengthof(buf), s, va);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 
	fprintf(stderr, LINE_NUM_FMT("FATAL"), _file, _cur_line, buf);
 
#ifdef _MSC_VER
src/string.cpp
Show inline comments
 
@@ -32,7 +32,10 @@
 
#include "gfx_func.h"
 
#endif /* WITH_ICU */
 

	
 
/* The function vsnprintf is used internally to perform the required formatting
 
 * tasks. As such this one must be allowed, and makes sure it's terminated. */
 
#include "safeguards.h"
 
#undef vsnprintf
 

	
 
/**
 
 * Safer implementation of vsnprintf; same as vsnprintf except:
 
@@ -44,7 +47,7 @@
 
 * @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)
 
int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap)
 
{
 
	ptrdiff_t diff = last - str;
 
	if (diff < 0) return 0;
src/string_func.h
Show inline comments
 
@@ -34,6 +34,7 @@ char *strecpy(char *dst, const char *src
 
char *stredup(const char *src, const char *last = NULL);
 

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

	
 
char *CDECL str_fmt(const char *str, ...) WARN_FORMAT(1, 2);
 

	
src/textbuf.cpp
Show inline comments
 
@@ -419,7 +419,7 @@ void Textbuf::Print(const char *format, 
 
{
 
	va_list va;
 
	va_start(va, format);
 
	vsnprintf(this->buf, this->max_bytes, format, va);
 
	vseprintf(this->buf, &this->buf[this->max_bytes - 1], format, va);
 
	va_end(va);
 
	this->UpdateSize();
 
}
0 comments (0 inline, 0 general)