mirror of
https://github.com/SWG-Source/src.git
synced 2026-08-01 01:16:03 -04:00
in theory this will "normalize" these chars...worst case i turn this into
an lower case only version since the hard coded strings generally aren't slashes
This commit is contained in:
+36
@@ -65,5 +65,41 @@ constexpr const uint32 constcrc(const char *string)
|
||||
return (crc ^ CRC_INIT);
|
||||
}
|
||||
|
||||
constexpr const uint32 constcrcnormalizecalc(const char *input)
|
||||
{
|
||||
char* output = (char*) malloc( input + 1 );
|
||||
bool previousIsSlash = true;
|
||||
for ( ; *input; ++input)
|
||||
{
|
||||
const char c = *input;
|
||||
if (c == '\\' || c == '/')
|
||||
{
|
||||
if (!previousIsSlash)
|
||||
{
|
||||
// convert all backslashes to forward slashes and disallow multiple slashes in a row
|
||||
*(output++) = '/';
|
||||
previousIsSlash = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (c == '.')
|
||||
{
|
||||
// disallow dots after slashes. this will also handle multiple dots, and slashes following the dots
|
||||
if (!previousIsSlash)
|
||||
*(output++) = '.';
|
||||
}
|
||||
else
|
||||
{
|
||||
// lowercase all other characters
|
||||
*(output++) = static_cast<char>(tolower(c));
|
||||
previousIsSlash = false;
|
||||
}
|
||||
}
|
||||
|
||||
*output = '\0';
|
||||
|
||||
return constcrc(output);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user