static char buf[ 4096 ];
struct passwd pw, *pwp;
char *home;
- static char homeBuf[MAX_OS_PATH];
-
/* get the home environment variable */
home = getenv( "HOME" );
/* look up home dir in password database */
- if(!home)
+ if( home == NULL )
{
if ( getpwuid_r( getuid(), &pw, buf, sizeof( buf ), &pwp ) == 0 ) {
return pw.pw_dir;
}
}
- snprintf( homeBuf, sizeof( homeBuf ), "%s/.", home );
-
/* return it */
- return homeBuf;
+ return home;
#endif
}
void LokiInitPaths( char *argv0 ){
char *home;
- if ( !homePath ) {
+ if ( homePath == NULL ) {
/* get home dir */
home = LokiGetHomeDir();
if ( home == NULL ) {
/* set home path */
homePath = home;
}
- else{
+ else {
home = homePath;
}
if ( strrchr( temp, '/' ) ) {
argv0 = strrchr( argv0, '/' ) + 1;
}
- else if ( path ) {
+ else if ( path != NULL ) {
/*
This code has a special behavior when q3map2 is a symbolic link.
void AddHomeBasePath( char *path ){
int i;
char temp[ MAX_OS_PATH ];
- int homePathLen;
- if ( !homePath ) {
+ if ( homePath == NULL ) {
return;
}
return;
}
- /* strip leading dot, if homePath does not end in /. */
- homePathLen = strlen( homePath );
- if ( !strcmp( path, "." ) ) {
+ if ( strcmp( path, "." ) == 0 ) {
/* -fs_homebase . means that -fs_home is to be used as is */
strcpy( temp, homePath );
}
- else if ( homePathLen >= 2 && !strcmp( homePath + homePathLen - 2, "/." ) ) {
- /* remove trailing /. of homePath */
- homePathLen -= 2;
-
- /* concatenate home dir and path */
- sprintf( temp, "%.*s/%s", homePathLen, homePath, path );
- }
- else
- {
- /* remove leading . of path */
- if ( path[0] == '.' ) {
- ++path;
- }
-
+ else {
/* concatenate home dir and path */
sprintf( temp, "%s/%s", homePath, path );
}