diff --git a/src/common/header/shared.h b/src/common/header/shared.h index 67bd234d..70b551cd 100644 --- a/src/common/header/shared.h +++ b/src/common/header/shared.h @@ -202,7 +202,7 @@ void RotatePointAroundVector(vec3_t dst, char *COM_SkipPath(char *pathname); void COM_StripExtension(char *in, char *out); -char *COM_FileExtension(char *in); +const char *COM_FileExtension(const char *in); void COM_FileBase(char *in, char *out); void COM_FilePath(const char *in, char *out); void COM_DefaultExtension(char *path, const char *extension); diff --git a/src/common/shared/shared.c b/src/common/shared/shared.c index 93323137..6caee678 100644 --- a/src/common/shared/shared.c +++ b/src/common/shared/shared.c @@ -668,31 +668,17 @@ COM_StripExtension(char *in, char *out) *out = 0; } -char * -COM_FileExtension(char *in) +const char * +COM_FileExtension(const char *in) { - static char exten[8]; - int i; + const char *ext = strrchr(in, '.'); - while (*in && *in != '.') - { - in++; - } - - if (!*in) + if (!ext || ext == in) { return ""; } - in++; - - for (i = 0; i < 7 && *in; i++, in++) - { - exten[i] = *in; - } - - exten[i] = 0; - return exten; + return ext + 1; } void diff --git a/src/game/savegame/tables/gamefunc_decs.h b/src/game/savegame/tables/gamefunc_decs.h index ae76da54..0e6b95c6 100644 --- a/src/game/savegame/tables/gamefunc_decs.h +++ b/src/game/savegame/tables/gamefunc_decs.h @@ -73,7 +73,7 @@ extern short BigShort ( short l ) ; extern void COM_DefaultExtension ( char * path , const char * extension ) ; extern void COM_FilePath ( const char * in , char * out ) ; extern void COM_FileBase ( char * in , char * out ) ; -extern char * COM_FileExtension ( char * in ) ; +extern const char * COM_FileExtension ( const char * in ) ; extern void COM_StripExtension ( char * in , char * out ) ; extern char * COM_SkipPath ( char * pathname ) ; extern int Q_log2 ( int val ) ;