Skip to content
Snippets Groups Projects
Select Git revision
  • 30ad48d89f79d7eb91e6e67d9eb30e75a9e280c4
  • master default protected
  • next
  • 14-multiplayer-demo-recording
  • netplus_2.2.9
5 results

fastcmp.h

Blame
  • Alam Ed Arias's avatar
    Alam Ed Arias authored and Alam Arias committed
    b93cb1b6
    History
    fastcmp.h 790 B
    #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 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 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