mirror of
https://github.com/yquake2/ctf.git
synced 2024-11-10 06:31:34 +00:00
Rewrite COM_FileExtention()
COM_FileExtension() was parsing strings from beginning to end, bailing out as soon as '.' was found and treating everything thereafter as the file extension. That behavior caused problem with relatives pathes like models/monsters/tank/../ctank/skin.pcx. The new implementation uses strrchr() to determine the last '.'.
This commit is contained in:
parent
5caf9c980f
commit
017bc7276f
1 changed files with 5 additions and 19 deletions
|
@ -666,31 +666,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
|
||||
|
|
Loading…
Reference in a new issue