2009年9月18日 星期五

如何讓你的程式更難理解(5)

int uglystrieq( const char * l, const char * r ) {
    while(*l&&*r&&(*l++|32)==(*r++|32));return *l--||*r--||(*l|32)!=(*r|32);
}
Compare the equivalence of two strings. Case insensitive.
[Edit]
This implementation while crash when passing a 0-lengthed string. Another version:
int _(const char*l,const char*O) {
    return ((*l|32)-(*O|32))?1:*l?_(l+1,O+1):0;
}

3 則留言: