use capital letter in strClear, strEmpty, strIstr to lessen names collision probability
This commit is contained in:
parent
37ae7f0794
commit
e6ce77d031
|
|
@ -431,14 +431,14 @@ static void ASE_KeyMAP_DIFFUSE( const char *token ){
|
||||||
FixDOSName( bitmap );
|
FixDOSName( bitmap );
|
||||||
|
|
||||||
/* remove filename from path */
|
/* remove filename from path */
|
||||||
strclear( path_get_last_separator( filename ) );
|
strClear( path_get_last_separator( filename ) );
|
||||||
|
|
||||||
/* replaces a relative path with a full path */
|
/* replaces a relative path with a full path */
|
||||||
if ( !strncmp( bitmap, "../", 3 ) ) {
|
if ( !strncmp( bitmap, "../", 3 ) ) {
|
||||||
while ( !strncmp( bitmap, "../", 3 ) )
|
while ( !strncmp( bitmap, "../", 3 ) )
|
||||||
{
|
{
|
||||||
/* remove last item from path */
|
/* remove last item from path */
|
||||||
strclear( path_get_last_separator( filename ) );
|
strClear( path_get_last_separator( filename ) );
|
||||||
memmove( bitmap, &bitmap[3], sizeof( bitmap ) - 3 );
|
memmove( bitmap, &bitmap[3], sizeof( bitmap ) - 3 );
|
||||||
}
|
}
|
||||||
strcat( filename, "/" );
|
strcat( filename, "/" );
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ void SetQdirFromPath( const char *path ){
|
||||||
// so we need to add up how much to the next separator
|
// so we need to add up how much to the next separator
|
||||||
sep = c + len;
|
sep = c + len;
|
||||||
count = 1;
|
count = 1;
|
||||||
while ( !strempty( sep ) && !path_separator( *sep ) )
|
while ( !strEmpty( sep ) && !path_separator( *sep ) )
|
||||||
{
|
{
|
||||||
sep++;
|
sep++;
|
||||||
count++;
|
count++;
|
||||||
|
|
@ -201,7 +201,7 @@ void SetQdirFromPath( const char *path ){
|
||||||
FixDOSName( gamedir );
|
FixDOSName( gamedir );
|
||||||
Sys_Printf( "gamedir: %s\n", gamedir );
|
Sys_Printf( "gamedir: %s\n", gamedir );
|
||||||
|
|
||||||
if ( strempty( writedir ) ) {
|
if ( strEmpty( writedir ) ) {
|
||||||
strcpy( writedir, gamedir );
|
strcpy( writedir, gamedir );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -279,7 +279,7 @@ void Q_getwd( char *out ){
|
||||||
#else
|
#else
|
||||||
// Gef: Changed from getwd() to getcwd() to avoid potential buffer overflow
|
// Gef: Changed from getwd() to getcwd() to avoid potential buffer overflow
|
||||||
if ( !getcwd( out, 256 ) ) {
|
if ( !getcwd( out, 256 ) ) {
|
||||||
strclear( out );
|
strClear( out );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
path_add_slash( out );
|
path_add_slash( out );
|
||||||
|
|
@ -305,7 +305,7 @@ void Q_mkdir( const char *path ){
|
||||||
if ( errno == ENOENT ) {
|
if ( errno == ENOENT ) {
|
||||||
p = path_get_last_separator( path );
|
p = path_get_last_separator( path );
|
||||||
}
|
}
|
||||||
if ( !strempty( p ) ) {
|
if ( !strEmpty( p ) ) {
|
||||||
strcpyQ( parentbuf, path, p - path + 1 );
|
strcpyQ( parentbuf, path, p - path + 1 );
|
||||||
if ( ( p - path ) < (ptrdiff_t) sizeof( parentbuf ) ) {
|
if ( ( p - path ) < (ptrdiff_t) sizeof( parentbuf ) ) {
|
||||||
Sys_Printf( "mkdir: %s: creating parent %s first\n", path, parentbuf );
|
Sys_Printf( "mkdir: %s: creating parent %s first\n", path, parentbuf );
|
||||||
|
|
@ -419,7 +419,7 @@ skipwhite:
|
||||||
|
|
||||||
//http://stackoverflow.com/questions/27303062/strstr-function-like-that-ignores-upper-or-lower-case
|
//http://stackoverflow.com/questions/27303062/strstr-function-like-that-ignores-upper-or-lower-case
|
||||||
//chux: Somewhat tricky to match the corner cases of strstr() with inputs like "x","", "","x", "",""
|
//chux: Somewhat tricky to match the corner cases of strstr() with inputs like "x","", "","x", "",""
|
||||||
char *stristr( const char* haystack, const char* needle ) {
|
char *strIstr( const char* haystack, const char* needle ) {
|
||||||
do {
|
do {
|
||||||
const char* h = haystack;
|
const char* h = haystack;
|
||||||
const char* n = needle;
|
const char* n = needle;
|
||||||
|
|
@ -750,7 +750,7 @@ void path_set_extension( char *path, const char *extension ){
|
||||||
//
|
//
|
||||||
void DefaultExtension( char *path, const char *extension ){
|
void DefaultExtension( char *path, const char *extension ){
|
||||||
char* ext = path_get_filename_base_end( path );
|
char* ext = path_get_filename_base_end( path );
|
||||||
if( strempty( ext ) )
|
if( strEmpty( ext ) )
|
||||||
strcpy( ext, extension );
|
strcpy( ext, extension );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -765,11 +765,11 @@ void DefaultPath( char *path, const char *basepath ){
|
||||||
|
|
||||||
|
|
||||||
void StripFilename( char *path ){
|
void StripFilename( char *path ){
|
||||||
strclear( path_get_filename_start( path ) );
|
strClear( path_get_filename_start( path ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void StripExtension( char *path ){
|
void StripExtension( char *path ){
|
||||||
strclear( path_get_filename_base_end( path ) );
|
strClear( path_get_filename_base_end( path ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,10 +80,10 @@ void *safe_calloc_info( size_t size, const char* info );
|
||||||
extern int myargc;
|
extern int myargc;
|
||||||
extern char **myargv;
|
extern char **myargv;
|
||||||
|
|
||||||
static inline qboolean strempty( const char* string ){
|
static inline qboolean strEmpty( const char* string ){
|
||||||
return *string == '\0';
|
return *string == '\0';
|
||||||
}
|
}
|
||||||
static inline void strclear( char* string ){
|
static inline void strClear( char* string ){
|
||||||
*string = '\0';
|
*string = '\0';
|
||||||
}
|
}
|
||||||
static inline char *strlower( char *string ){
|
static inline char *strlower( char *string ){
|
||||||
|
|
@ -95,7 +95,7 @@ static inline char *copystring( const char *src ){ // version of strdup() with s
|
||||||
const size_t size = strlen( src ) + 1;
|
const size_t size = strlen( src ) + 1;
|
||||||
return memcpy( safe_malloc( size ), src, size );
|
return memcpy( safe_malloc( size ), src, size );
|
||||||
}
|
}
|
||||||
char* stristr( const char* haystack, const char* needle );
|
char* strIstr( const char* haystack, const char* needle );
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define Q_stricmp stricmp
|
#define Q_stricmp stricmp
|
||||||
#define Q_strncasecmp strnicmp
|
#define Q_strncasecmp strnicmp
|
||||||
|
|
|
||||||
|
|
@ -144,8 +144,8 @@ void vfsInitDirectory( const char *path ){
|
||||||
for ( j = 0; j < g_numForbiddenDirs; ++j )
|
for ( j = 0; j < g_numForbiddenDirs; ++j )
|
||||||
{
|
{
|
||||||
char* dbuf = strdup( path );
|
char* dbuf = strdup( path );
|
||||||
if ( !strempty( dbuf ) && path_separator( dbuf[strlen( dbuf ) - 1] ) ) // del trailing slash
|
if ( !strEmpty( dbuf ) && path_separator( dbuf[strlen( dbuf ) - 1] ) ) // del trailing slash
|
||||||
strclear( &dbuf[strlen( dbuf ) - 1] );
|
strClear( &dbuf[strlen( dbuf ) - 1] );
|
||||||
if ( matchpattern( path_get_filename_start( dbuf ), g_strForbiddenDirs[j], TRUE ) ) {
|
if ( matchpattern( path_get_filename_start( dbuf ), g_strForbiddenDirs[j], TRUE ) ) {
|
||||||
free( dbuf );
|
free( dbuf );
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ static inline void tex2list( StrList* texlist, StrList* EXtex, StrList* rEXtex )
|
||||||
//StripExtension( token );
|
//StripExtension( token );
|
||||||
char* dot = path_get_filename_base_end( token );
|
char* dot = path_get_filename_base_end( token );
|
||||||
if( !Q_stricmp( dot, ".tga" ) || !Q_stricmp( dot, ".jpg" ) || !Q_stricmp( dot, ".png" ) ){ //? might want to also warn on png in non png run
|
if( !Q_stricmp( dot, ".tga" ) || !Q_stricmp( dot, ".jpg" ) || !Q_stricmp( dot, ".png" ) ){ //? might want to also warn on png in non png run
|
||||||
strclear( dot );
|
strClear( dot );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Sys_FPrintf( SYS_WRN, "WARNING4: %s : weird or missing extension in shader image path\n", token );
|
Sys_FPrintf( SYS_WRN, "WARNING4: %s : weird or missing extension in shader image path\n", token );
|
||||||
|
|
@ -107,7 +107,7 @@ static inline void res2list( StrList* list, const char* res ){
|
||||||
while ( path_separator( *res ) ){ // kill prepended slashes
|
while ( path_separator( *res ) ){ // kill prepended slashes
|
||||||
++res;
|
++res;
|
||||||
}
|
}
|
||||||
if ( strempty( res ) )
|
if ( strEmpty( res ) )
|
||||||
return;
|
return;
|
||||||
if( !StrList_find( list, res ) )
|
if( !StrList_find( list, res ) )
|
||||||
StrList_append( list, res );
|
StrList_append( list, res );
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ void LokiInitPaths( char *argv0 ){
|
||||||
|
|
||||||
/* do some path divining */
|
/* do some path divining */
|
||||||
strcpyQ( temp, argv0, sizeof( temp ) );
|
strcpyQ( temp, argv0, sizeof( temp ) );
|
||||||
if ( strempty( path_get_last_separator( temp ) ) && path ) {
|
if ( strEmpty( path_get_last_separator( temp ) ) && path ) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This code has a special behavior when q3map2 is a symbolic link.
|
This code has a special behavior when q3map2 is a symbolic link.
|
||||||
|
|
@ -147,10 +147,10 @@ void LokiInitPaths( char *argv0 ){
|
||||||
last = path;
|
last = path;
|
||||||
|
|
||||||
/* go through each : segment of path */
|
/* go through each : segment of path */
|
||||||
while ( !strempty( last ) && found == qfalse )
|
while ( !strEmpty( last ) && found == qfalse )
|
||||||
{
|
{
|
||||||
/* null out temp */
|
/* null out temp */
|
||||||
strclear( temp );
|
strClear( temp );
|
||||||
|
|
||||||
/* find next chunk */
|
/* find next chunk */
|
||||||
last = strchr( path, ':' );
|
last = strchr( path, ':' );
|
||||||
|
|
@ -186,8 +186,8 @@ void LokiInitPaths( char *argv0 ){
|
||||||
if "q3map2" is "/opt/radiant/tools/q3map2",
|
if "q3map2" is "/opt/radiant/tools/q3map2",
|
||||||
installPath is "/opt/radiant"
|
installPath is "/opt/radiant"
|
||||||
*/
|
*/
|
||||||
strclear( path_get_last_separator( installPath ) );
|
strClear( path_get_last_separator( installPath ) );
|
||||||
strclear( path_get_last_separator( installPath ) );
|
strClear( path_get_last_separator( installPath ) );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -510,12 +510,12 @@ void InitPaths( int *argc, char **argv ){
|
||||||
FixDOSName( temp );
|
FixDOSName( temp );
|
||||||
Sys_FPrintf( SYS_VRB, "Searching for \"%s\" in \"%s\" (%d)...\n", game->magic, temp, i );
|
Sys_FPrintf( SYS_VRB, "Searching for \"%s\" in \"%s\" (%d)...\n", game->magic, temp, i );
|
||||||
/* check for the game's magic word */
|
/* check for the game's magic word */
|
||||||
char* found = stristr( temp, game->magic );
|
char* found = strIstr( temp, game->magic );
|
||||||
if( found ){
|
if( found ){
|
||||||
/* now find the next slash and nuke everything after it */
|
/* now find the next slash and nuke everything after it */
|
||||||
found = strchr( found, '/' );
|
found = strchr( found, '/' );
|
||||||
if( found )
|
if( found )
|
||||||
strclear( found );
|
strClear( found );
|
||||||
/* add this as a base path */
|
/* add this as a base path */
|
||||||
AddBasePath( temp );
|
AddBasePath( temp );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user