00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "pent_include.h"
00025 #include "istring.h"
00026
00027 namespace Pentagram {
00028
00029 int strncasecmp (const char *s1, const char *s2, uint32 length)
00030 {
00031 uint32 c1, c2;
00032
00033 do
00034 {
00035 c1 = *s1++;
00036 c2 = *s2++;
00037
00038 if (!length--)
00039 return 0;
00040
00041 if (c1 != c2)
00042 {
00043 if (c1 >= 'a' && c1 <= 'z')
00044 c1 -= ('a' - 'A');
00045 if (c2 >= 'a' && c2 <= 'z')
00046 c2 -= ('a' - 'A');
00047 if (c1 != c2)
00048 return (c1 < c2) ? -1 : 1;
00049 }
00050 } while (c1);
00051
00052 return 0;
00053 }
00054
00055 int strcasecmp (const char *s1, const char *s2)
00056 {
00057 return strncasecmp (s1, s2, 2147483647);
00058 }
00059
00060 #ifndef UNDER_CE
00061
00062 bool ichar_traits::eq(const char_type & c1, const char_type & c2)
00063 {
00064 uint32 c3 = c1;
00065 uint32 c4 = c2;
00066 if (c3 >= 'a' && c3 <= 'z')
00067 c3 -= ('a' - 'A');
00068 if (c4 >= 'a' && c4 <= 'z')
00069 c4 -= ('a' - 'A');
00070 return c3 == c4;
00071 }
00072
00073 bool ichar_traits::lt(const char_type & c1, const char_type & c2)
00074 {
00075 uint32 c3 = c1;
00076 uint32 c4 = c2;
00077 if (c3 >= 'a' && c3 <= 'z')
00078 c3 -= ('a' - 'A');
00079 if (c4 >= 'a' && c4 <= 'z')
00080 c4 -= ('a' - 'A');
00081 return c3 < c4;
00082 }
00083
00084 int ichar_traits::compare(const char_type * s1, const char_type * s2, size_t length)
00085 {
00086 return strncasecmp(s1, s2, length);
00087 }
00088
00089 #endif
00090
00091 };
00092