2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-16 00:28:20 +03:00

Reworked COM_FileExtension for consider some case.

This commit is contained in:
s1lent 2019-08-30 06:07:00 +07:00
parent 6520ab54b0
commit 4e4690bd6b
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C

View File

@ -1355,21 +1355,31 @@ void COM_StripExtension(char *in, char *out)
char *COM_FileExtension(char *in)
{
#ifdef REHLDS_FIXES
char *src = in + Q_strlen(in) - 1;
int len = Q_strlen(in);
if (len <= 0)
return ""; // no extension
char *src = in + len - 1;
// back up until a . or the start
while (src != in && *(src - 1) != '.')
while (src >= in && !PATHSEPARATOR(*src))
{
if (*src == '.')
{
src++; // skip dot
if (*src != '\0')
{
return src;
}
break;
}
src--;
}
// check to see if the '.' is part of a input buffer
if (src == in || PATHSEPARATOR(*src))
{
return ""; // no extension
}
return src;
return ""; // no extension
#else // #ifdef REHLDS_FIXES
static char exten[MAX_PATH];
char *c, *d = NULL;