[Scummvm-cvs-logs] scummvm master -> 007a33515f532bea20f13ed07c1c5340c58046ba

lordhoto lordhoto at gmail.com
Wed Jun 1 17:33:58 CEST 2011


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2f8e9b954e COMMON: Add comment about MSVC's _snprintf.
007a33515f COMMON: Add note about us defining vsnprintf as _vsnprintf for older MSVC versions.


Commit: 2f8e9b954ef94fbdf48ec5c2a1a0801d651da7e6
    https://github.com/scummvm/scummvm/commit/2f8e9b954ef94fbdf48ec5c2a1a0801d651da7e6
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-06-01T08:28:59-07:00

Commit Message:
COMMON: Add comment about MSVC's _snprintf.

This includes a FIXME, since _snprintf behaves differently to snprintf.
Not only in the return value (which is a minor difference, since we usually
do not use it), but also since it does not always include a terminating null.

Changed paths:
    common/scummsys.h



diff --git a/common/scummsys.h b/common/scummsys.h
index b6912504..8ed61c2 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -44,8 +44,18 @@
 		#if (_MSC_VER < 1500)
 			#define vsnprintf _vsnprintf
 		#endif
-		// FIXME: Is this actually necessary for WinCE or Windows?
-		// If yes, please add corresponding comments. Otherwise, let's get rid of it!
+		// Visual Studio does not include snprintf in its standard C library.
+		// Instead it includes a function called _snprintf with somewhat
+		// similar semantics. The minor difference is that the return value in
+		// case the formatted string exceeds the buffer size is different.
+		// A much more dangerous one is that _snprintf does not always include
+		// a terminating null (Whoops!).
+		//
+		// FIXME: Provide a proper snprintf function for MSVC. It should at
+		// least always include a terminating null!
+		//
+		// See here for more details:
+		// http://msdn.microsoft.com/en-us/library/2ts7cx93%28v=VS.100%29.aspx
 		#define snprintf _snprintf
 		#endif
 


Commit: 007a33515f532bea20f13ed07c1c5340c58046ba
    https://github.com/scummvm/scummvm/commit/007a33515f532bea20f13ed07c1c5340c58046ba
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-06-01T08:31:33-07:00

Commit Message:
COMMON: Add note about us defining vsnprintf as _vsnprintf for older MSVC versions.

Changed paths:
    common/scummsys.h



diff --git a/common/scummsys.h b/common/scummsys.h
index 8ed61c2..b6d5263 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -40,7 +40,10 @@
 	#if defined(WIN32)
 
 		#ifdef _MSC_VER
-		// vsnprintf is already defined in Visual Studio 2008
+		// vnsprintf was introduced with Visual Studio 2008. The 2003 edition
+		// only included a function called _vsnprintf. We do not officially
+		// support MSVC 2003 anymore, but it should not hurt to still have
+		// this around here.
 		#if (_MSC_VER < 1500)
 			#define vsnprintf _vsnprintf
 		#endif






More information about the Scummvm-git-logs mailing list