Back to index

lightning-sunbird  0.9+nobinonly
Functions
StringUtils.cpp File Reference
#include "StringUtils.h"
#include <string.h>

Go to the source code of this file.

Functions

unsigned char toupper (unsigned char c)
int strcasecmp (const char *str1, const char *str2)
 Case-insensitive string comparison.
char * strdup (const char *str)
 Duplicates a C string, returns NULL if failed, or passed NULL.

Function Documentation

int strcasecmp ( const char *  str1,
const char *  str2 
)

Case-insensitive string comparison.

Definition at line 50 of file StringUtils.cpp.

{
#if !__POWERPC__
       
       const  unsigned char * p1 = (unsigned char *) str1;
       const  unsigned char * p2 = (unsigned char *) str2;
                            unsigned char        c1, c2;
       
       while (toupper(c1 = *p1++) == toupper(c2 = *p2++))
              if (!c1)
                     return(0);

#else
       
       const  unsigned char * p1 = (unsigned char *) str1 - 1;
       const  unsigned char * p2 = (unsigned char *) str2 - 1;
                            unsigned long        c1, c2;
              
       while (toupper(c1 = *++p1) == toupper(c2 = *++p2))
              if (!c1)
                     return(0);

#endif
       
       return(toupper(c1) - toupper(c2));
}

Here is the call graph for this function:

char* strdup ( const char *  str)

Duplicates a C string, returns NULL if failed, or passed NULL.

Definition at line 77 of file StringUtils.cpp.

{
       if (str != NULL) {
              char* result = new char[::strlen(str) + 1];
              if (result != NULL)
                     ::strcpy(result, str);
              return result;
       }
       return NULL;
}
unsigned char toupper ( unsigned char  c) [inline]

Definition at line 45 of file StringUtils.cpp.

{
       return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;
}