Fixed typos
[ACE_TAO.git] / ACE / ace / OS_NS_strings.cpp
blobd09d152fd2e581c2d4c62241b10a0723bc2cef0d
1 #include "ace/OS_NS_strings.h"
5 #if !defined (ACE_HAS_INLINED_OSCALLS)
6 # include "ace/OS_NS_strings.inl"
7 #endif /* ACE_HAS_INLINED_OSCALLS */
9 #if defined (ACE_LACKS_STRCASECMP)
10 # include "ace/OS_NS_ctype.h"
11 #endif /* ACE_LACKS_STRCASECMP */
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 #if defined (ACE_LACKS_STRCASECMP)
16 int
17 ACE_OS::strcasecmp_emulation (const char *s, const char *t)
19 const char *scan1 = s;
20 const char *scan2 = t;
22 while (*scan1 != 0
23 && ACE_OS::ace_tolower (*scan1)
24 == ACE_OS::ace_tolower (*scan2))
26 ++scan1;
27 ++scan2;
30 // The following case analysis is necessary so that characters which
31 // look negative collate low against normal characters but high
32 // against the end-of-string NUL.
34 if (*scan1 == '\0' && *scan2 == '\0')
35 return 0;
36 else if (*scan1 == '\0')
37 return -1;
38 else if (*scan2 == '\0')
39 return 1;
40 else
41 return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_tolower (*scan2);
43 #endif /* ACE_LACKS_STRCASECMP */
45 #if defined (ACE_LACKS_STRCASECMP)
46 int
47 ACE_OS::strncasecmp_emulation (const char *s,
48 const char *t,
49 size_t len)
51 const char *scan1 = s;
52 const char *scan2 = t;
53 size_t count = 0;
55 while (count++ < len
56 && *scan1 != 0
57 && ACE_OS::ace_tolower (*scan1)
58 == ACE_OS::ace_tolower (*scan2))
60 ++scan1;
61 ++scan2;
64 if (count > len)
65 return 0;
67 // The following case analysis is necessary so that characters which
68 // look negative collate low against normal characters but high
69 // against the end-of-string NUL.
71 if (*scan1 == '\0' && *scan2 == '\0')
72 return 0;
73 else if (*scan1 == '\0')
74 return -1;
75 else if (*scan2 == '\0')
76 return 1;
77 else
78 return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_tolower (*scan2);
80 #endif /* ACE_LACKS_STRCASECMP */
82 ACE_END_VERSIONED_NAMESPACE_DECL