Browse Source

public: simplified strings operations.

pull/2/head
Andrey Akhmichin 2 years ago committed by Alibek Omarov
parent
commit
3488d4e65f
  1. 18
      public/crtlib.c

18
public/crtlib.c

@ -560,14 +560,14 @@ char *Q_pretifymem( float value, int digitsafterdecimal ) @@ -560,14 +560,14 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
if( value > onemb )
{
value /= onemb;
Q_sprintf( suffix, " Mb" );
Q_strcpy( suffix, " Mb" );
}
else if( value > onekb )
{
value /= onekb;
Q_sprintf( suffix, " Kb" );
Q_strcpy( suffix, " Kb" );
}
else Q_sprintf( suffix, " bytes" );
else Q_strcpy( suffix, " bytes" );
// clamp to >= 0
digitsafterdecimal = Q_max( digitsafterdecimal, 0 );
@ -591,8 +591,8 @@ char *Q_pretifymem( float value, int digitsafterdecimal ) @@ -591,8 +591,8 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
o = out;
// search for decimal or if it was integral, find the space after the raw number
dot = Q_strstr( i, "." );
if( !dot ) dot = Q_strstr( i, " " );
dot = Q_strchr( i, '.' );
if( !dot ) dot = Q_strchr( i, ' ' );
pos = dot - i; // compute position of dot
pos -= 3; // don't put a comma if it's <= 3 long
@ -750,7 +750,7 @@ void COM_ExtractFilePath( const char *path, char *dest ) @@ -750,7 +750,7 @@ void COM_ExtractFilePath( const char *path, char *dest )
memcpy( dest, path, src - path );
dest[src - path - 1] = 0; // cutoff backslash
}
else Q_strcpy( dest, "" ); // file without path
else dest[0] = 0; // file without path
}
/*
@ -785,10 +785,12 @@ COM_DefaultExtension @@ -785,10 +785,12 @@ COM_DefaultExtension
void COM_DefaultExtension( char *path, const char *extension )
{
const char *src;
size_t len;
// if path doesn't have a .EXT, append extension
// (extension should include the .)
src = path + Q_strlen( path ) - 1;
len = Q_strlen( path );
src = path + len - 1;
while( *src != '/' && src != path )
{
@ -797,7 +799,7 @@ void COM_DefaultExtension( char *path, const char *extension ) @@ -797,7 +799,7 @@ void COM_DefaultExtension( char *path, const char *extension )
src--;
}
Q_strcat( path, extension );
Q_strcpy( &path[len], extension );
}
/*

Loading…
Cancel
Save