Ignore:
Timestamp:
Mar 10, 2006, 6:56:40 PM (14 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • wrote strcasecmp for fun
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/kernel/kernel.c

    r578 r589  
    2424#ifdef __KERNEL__
    2525
     26#define IS_DIGIT(x) (x>='0' && x<='9')
     27#define IS_ALPHA(x) (x>='A' && x<='z')
     28#define IS_UPPER(x) (x>='A' && x<='Z')
     29#define IS_LOWER(x) (x>='a' && x<='z')
     30#define UPPER(x) (IS_LOWER(x)?(x+('a'-'A')):x)
     31#define LOWER(x) (IS_UPPER(x)?(x-('a'-'A')):x)
     32
    2633/* Our memory mapping */
    2734static uint32_t *freemem = (uint32_t*) 0x00200000;
     
    131138int strcasecmp(const char *s1, const char *s2)
    132139{
    133     /* FIXME */
    134     return -1;
     140    while((*s1++) && (*s2++)) {
     141        char c1 = UPPER(*s1);
     142        char c2 = UPPER(*s2);
     143        if((*s1)>(*s2))
     144            return (*s1)>(*s2);
     145        if((*s1)<(*s2))
     146            return (*s1)<(*s2);
     147    }
     148    if((*s1==0) && (*s2==0))
     149        return 0;
     150
     151    return 1; /* FIXME */
    135152}
    136153
Note: See TracChangeset for help on using the changeset viewer.