mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
public: crtlib: fix Q_pretifymem so it compiles with -Wformat-nonliteral
This commit is contained in:
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
Submodule 3rdparty/mainui updated: e0d3b84184...81f6cd7cd9
@@ -220,7 +220,7 @@ void HPAK_AddLump( qboolean bUseQueue, const char *name, resource_t *pResource,
|
||||
|
||||
if( pResource->nDownloadSize < HPAK_ENTRY_MIN_SIZE || pResource->nDownloadSize > HPAK_ENTRY_MAX_SIZE )
|
||||
{
|
||||
Con_Printf( S_ERROR "%s: invalid size %s\n", name, Q_pretifymem( pResource->nDownloadSize, 2 ));
|
||||
Con_Printf( S_ERROR "%s: invalid size %s\n", name, Q_memprint( pResource->nDownloadSize ));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet, qboolean de
|
||||
if( dataDir[i].disksize < HPAK_ENTRY_MIN_SIZE || dataDir[i].disksize > HPAK_ENTRY_MAX_SIZE )
|
||||
{
|
||||
// odd max size
|
||||
Con_DPrintf( S_ERROR "%s: lump %i has invalid size %s\n", __func__, i, Q_pretifymem( dataDir[i].disksize, 2 ));
|
||||
Con_DPrintf( S_ERROR "%s: lump %i has invalid size %s\n", __func__, i, Q_memprint( dataDir[i].disksize ));
|
||||
Mem_Free( dataDir );
|
||||
FS_Close( f );
|
||||
if( delete ) FS_Delete( pakname );
|
||||
@@ -462,7 +462,7 @@ static qboolean HPAK_Validate( const char *filename, qboolean quiet, qboolean de
|
||||
if( !quiet )
|
||||
{
|
||||
Con_Printf( "%i: %s %s %s: ", i, COM_ResourceTypeFromIndex( pRes->type ),
|
||||
Q_pretifymem( pRes->nDownloadSize, 2 ), pRes->szFileName );
|
||||
Q_memprint( pRes->nDownloadSize ), pRes->szFileName );
|
||||
}
|
||||
|
||||
if( memcmp( md5, pRes->rgucMD5_hash, 0x10 ))
|
||||
|
||||
@@ -407,34 +407,23 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
|
||||
if( value > onemb )
|
||||
{
|
||||
value /= onemb;
|
||||
suffix = " Mb";
|
||||
suffix = "Mb";
|
||||
}
|
||||
else if( value > onekb )
|
||||
{
|
||||
value /= onekb;
|
||||
suffix = " Kb";
|
||||
suffix = "Kb";
|
||||
}
|
||||
else
|
||||
{
|
||||
suffix = " bytes";
|
||||
suffix = "bytes";
|
||||
}
|
||||
|
||||
// clamp to >= 0
|
||||
digitsafterdecimal = Q_max( digitsafterdecimal, 0 );
|
||||
|
||||
// if it's basically integral, don't do any decimals
|
||||
if( fabs( value - (int)value ) < 0.00001f )
|
||||
{
|
||||
Q_snprintf( val, sizeof( val ), "%i%s", (int)value, suffix );
|
||||
}
|
||||
else
|
||||
{
|
||||
char fmt[32];
|
||||
|
||||
// otherwise, create a format string for the decimals
|
||||
Q_snprintf( fmt, sizeof( fmt ), "%%.%if%s", digitsafterdecimal, suffix );
|
||||
Q_snprintf( val, sizeof( val ), fmt, (double)value );
|
||||
}
|
||||
if( fabs( value - (int)value ) < 0.00001f || digitsafterdecimal <= 0 )
|
||||
Q_snprintf( val, sizeof( val ), "%i %s", (int)round( value ), suffix );
|
||||
else if( digitsafterdecimal >= 1 )
|
||||
Q_snprintf( val, sizeof( val ), "%.*f %s", digitsafterdecimal, (double)value, suffix );
|
||||
|
||||
// copy from in to out
|
||||
i = val;
|
||||
|
||||
Reference in New Issue
Block a user