Files
SRB2Kart-Saturn/src/fastcmp.h
T
Alug 6c98440f27 Remove pure attribute from fasticmp
While i assume this to be fine currently, i quite frankly dont trust the srb2 codebase enough aswell as preventing any future issues if there should ever be need to switch locales, since toupper WILL change behaviour in such cases which does not qualify as pure
2025-12-16 17:52:13 +01:00

28 lines
808 B
C

#ifndef __FASTCMP_H__
#define __FASTCMP_H__
// returns false if s != c
// returns true if s == c
FUNCINLINE static ATTRINLINE boolean fasticmp(const char *s, const char *c)
{
for (; *s && toupper(*s) == toupper(*c); s++, c++) ;
return (*s == *c); // make sure both strings ended
}
// case-sensitive of the above
FUNCINLINE static ATTRINLINE PUREFUNC boolean fastcmp(const char *s, const char *c)
{
for (; *s && *s == *c; s++, c++) ;
return (*s == *c); // make sure both strings ended
}
// length-limited of the above
// only true if both strings are at least l characters long AND match, case-sensitively!
FUNCINLINE static ATTRINLINE PUREFUNC boolean fastncmp(const char *s, const char *c, UINT16 l)
{
for (; *s && *s == *c && --l; s++, c++) ;
return !l; // make sure you reached the end
}
#endif