mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-01 23:20:44 +00:00
Merge pull request #94 from dekadenZ/size-format-macros
Attempt at removing the kludge concerning non-standard printf format references
This commit is contained in:
commit
740cc0d2e8
5 changed files with 33 additions and 52 deletions
|
@ -48,6 +48,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "../sys/sys_savegame.h"
|
||||
|
||||
#include "idlib/sys/sys_defines.h"
|
||||
|
||||
#if defined( _DEBUG )
|
||||
#define BUILD_DEBUG "-debug"
|
||||
#else
|
||||
|
@ -2020,12 +2022,7 @@ CONSOLE_COMMAND( testSIMD, "test SIMD code", NULL )
|
|||
// RB begin
|
||||
CONSOLE_COMMAND( testFormattingSizes, "test printf format security", 0 )
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
common->Printf( " sizeof( int32 ): %Iu bytes\n", sizeof( int32 ) );
|
||||
common->Printf( " sizeof( int64 ): %Iu bytes\n", sizeof( int64 ) );
|
||||
#else
|
||||
common->Printf( " sizeof( int32 ): %zu bytes\n", sizeof( int32 ) );
|
||||
common->Printf( " sizeof( int64 ): %zu bytes\n", sizeof( int64 ) );
|
||||
#endif
|
||||
common->Printf( " sizeof( int32 ): %" PRIuSIZE " bytes\n", sizeof( int32 ) );
|
||||
common->Printf( " sizeof( int64 ): %" PRIuSIZE " bytes\n", sizeof( int64 ) );
|
||||
}
|
||||
// RB end
|
||||
|
|
|
@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#pragma hdrstop
|
||||
|
||||
#include "Unzip.h"
|
||||
#include "idlib/sys/sys_defines.h"
|
||||
|
||||
/*
|
||||
=================
|
||||
|
@ -844,11 +845,7 @@ int idFile_Memory::Write( const void* buffer, int len )
|
|||
{
|
||||
if( maxSize != 0 )
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
common->Error( "idFile_Memory::Write: exceeded maximum size %Iu", maxSize );
|
||||
#else
|
||||
common->Error( "idFile_Memory::Write: exceeded maximum size %zu", maxSize );
|
||||
#endif
|
||||
common->Error( "idFile_Memory::Write: exceeded maximum size %" PRIuSIZE "", maxSize );
|
||||
return 0;
|
||||
}
|
||||
int extra = granularity * ( 1 + alloc / granularity );
|
||||
|
@ -934,13 +931,7 @@ void idFile_Memory::PreAllocate( size_t len )
|
|||
{
|
||||
if( maxSize != 0 )
|
||||
{
|
||||
// RB begin
|
||||
#ifdef _MSC_VER
|
||||
idLib::Error( "idFile_Memory::SetLength: exceeded maximum size %Iu", maxSize );
|
||||
#else
|
||||
idLib::Error( "idFile_Memory::SetLength: exceeded maximum size %zu", maxSize );
|
||||
#endif
|
||||
// RB end
|
||||
idLib::Error( "idFile_Memory::SetLength: exceeded maximum size %" PRIuSIZE "", maxSize );
|
||||
}
|
||||
char* newPtr = ( char* )Mem_Alloc( len, TAG_IDFILE );
|
||||
if( allocated > 0 )
|
||||
|
@ -1126,13 +1117,7 @@ void idFile_Memory::TruncateData( size_t len )
|
|||
{
|
||||
if( len > allocated )
|
||||
{
|
||||
// RB begin
|
||||
#ifdef _MSV_VER
|
||||
idLib::Error( "idFile_Memory::TruncateData: len (%Iu) exceeded allocated size (%Iu)", len, allocated );
|
||||
#else
|
||||
idLib::Error( "idFile_Memory::TruncateData: len (%zu) exceeded allocated size (%zu)", len, allocated );
|
||||
#endif
|
||||
// RB end
|
||||
idLib::Error( "idFile_Memory::TruncateData: len (%" PRIuSIZE ") exceeded allocated size (%" PRIuSIZE ")", len, allocated );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2126,5 +2111,3 @@ CONSOLE_COMMAND( testEndianNessReset, "Tests the read/write compatibility betwee
|
|||
{
|
||||
fileSystem->RemoveFile( testEndianNessFilename );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ Contains external code for building ZipFiles.
|
|||
*/
|
||||
|
||||
#include "Zip.h"
|
||||
#include "idlib/sys/sys_defines.h"
|
||||
|
||||
// #undef STDC
|
||||
|
||||
|
@ -504,13 +505,7 @@ bool idZipBuilder::CreateZipFileFromFiles( const idList< idFile_Memory* >& srcFi
|
|||
errcode = zipWriteInFileInZip( zf, buffer.Ptr(), ( unsigned int )bytesRead );
|
||||
if( errcode != ZIP_OK )
|
||||
{
|
||||
// RB begin
|
||||
#ifdef _MSC_VER
|
||||
idLib::Warning( "Error writing to zipfile (%Iu bytes)!", bytesRead );
|
||||
#else
|
||||
idLib::Warning( "Error writing to zipfile (%zu bytes)!", bytesRead );
|
||||
#endif
|
||||
// RB end
|
||||
idLib::Warning( "Error writing to zipfile (%" PRIuSIZE " bytes)!", bytesRead );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -618,13 +613,7 @@ bool idZipBuilder::AddFile( zipFile zf, idFile_Memory* src, bool deleteFile )
|
|||
errcode = zipWriteInFileInZip( zf, buffer.Ptr(), ( unsigned int )bytesRead );
|
||||
if( errcode != ZIP_OK )
|
||||
{
|
||||
// RB begin
|
||||
#ifdef _MSC_VER
|
||||
idLib::Warning( "Error writing to zipfile (%Iu bytes)!", bytesRead );
|
||||
#else
|
||||
idLib::Warning( "Error writing to zipfile (%zu bytes)!", bytesRead );
|
||||
#endif
|
||||
// RB end
|
||||
idLib::Warning( "Error writing to zipfile (%" PRIuSIZE " bytes)!", bytesRead );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,3 +257,22 @@ extern volatile int ignoredReturnValue;
|
|||
#define MIN_UNSIGNED_TYPE( x ) 0
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Macros for format conversion specifications for integer arguments of type
|
||||
* size_t or ssize_t.
|
||||
*/
|
||||
#ifdef _MSV_VER
|
||||
|
||||
#define PRIiSIZE "Ii"
|
||||
#define PRIuSIZE "Iu"
|
||||
#define PRIxSIZE "Ix"
|
||||
|
||||
#else // ifdef _MSV_VER
|
||||
|
||||
#define PRIiSIZE "zi"
|
||||
#define PRIuSIZE "zu"
|
||||
#define PRIxSIZE "zx"
|
||||
|
||||
#endif // ifdef _MSV_VER
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
/* #define GEN_TREES_H */
|
||||
|
||||
#include "deflate.h"
|
||||
#include "idlib/sys/sys_defines.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
# include <ctype.h>
|
||||
|
@ -940,17 +941,9 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|||
/* Determine the best encoding. Compute the block lengths in bytes. */
|
||||
opt_lenb = (s->opt_len+3+7)>>3;
|
||||
static_lenb = (s->static_len+3+7)>>3;
|
||||
// RB begin
|
||||
#ifdef _MSC_VER
|
||||
Tracev((stderr, "\nopt %Iu(%Iu) stat %Iu(%Iu) stored %Iu lit %u ",
|
||||
Tracev((stderr, "\nopt %" PRIuSIZE "(%" PRIuSIZE ") stat %" PRIuSIZE "(%" PRIuSIZE ") stored %" PRIuSIZE " lit %u ",
|
||||
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
||||
s->last_lit));
|
||||
#else
|
||||
Tracev((stderr, "\nopt %zu(%zu) stat %zu(%zu) stored %zu lit %u ",
|
||||
opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
||||
s->last_lit));
|
||||
#endif
|
||||
// RB end
|
||||
if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
|
||||
|
||||
} else {
|
||||
|
@ -1009,7 +1002,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|||
Tracev((stderr,"\ncomprlen %Iu(%Iu) ", s->compressed_len>>3,
|
||||
s->compressed_len-7*last));
|
||||
#else
|
||||
Tracev((stderr,"\ncomprlen %zu(%zu) ", s->compressed_len>>3,
|
||||
Tracev((stderr,"\ncomprlen %" PRIuSIZE "(%" PRIuSIZE ") ", s->compressed_len>>3,
|
||||
s->compressed_len-7*last));
|
||||
#endif
|
||||
// RB end
|
||||
|
|
Loading…
Reference in a new issue