summaryrefslogtreecommitdiff
path: root/ace/OS_NS_strings.cpp
diff options
context:
space:
mode:
authordhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-11-01 11:15:26 +0000
committerdhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-11-01 11:15:26 +0000
commitb38582354ed287367fd93be229ae5e9dbf9188e7 (patch)
tree9a2cd7fff6f9e796968703bf3bb2cb7ca5c5bf82 /ace/OS_NS_strings.cpp
parent6a0568c32aa670b9d9c216c18ae796749c816819 (diff)
downloadATCD-b38582354ed287367fd93be229ae5e9dbf9188e7.tar.gz
ChangeLogTag:Sat Nov 1 05:40:21 UTC 2003 Don Hinton <dhinton@dresystems.com>
Diffstat (limited to 'ace/OS_NS_strings.cpp')
-rw-r--r--ace/OS_NS_strings.cpp75
1 files changed, 74 insertions, 1 deletions
diff --git a/ace/OS_NS_strings.cpp b/ace/OS_NS_strings.cpp
index fc532b41367..ec2ab0ee4a0 100644
--- a/ace/OS_NS_strings.cpp
+++ b/ace/OS_NS_strings.cpp
@@ -1,4 +1,77 @@
// -*- C++ -*-
// $Id$
-// This is a placeholder.
+#include "ace/OS_NS_strings.h"
+
+ACE_RCSID(ace, OS_NS_strings, "$Id$")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/OS_NS_strings.inl"
+#endif /* ACE_HAS_INLINED_OS_CALLS */
+
+#if defined (ACE_LACKS_STRCASECMP)
+int
+ACE_OS::strcasecmp_emulation (const char *s, const char *t)
+{
+ const char *scan1 = s;
+ const char *scan2 = t;
+
+ while (*scan1 != 0
+ && ACE_OS::to_lower (*scan1)
+ == ACE_OS::to_lower (*scan2))
+ {
+ ++scan1;
+ ++scan2;
+ }
+
+ // The following case analysis is necessary so that characters which
+ // look negative collate low against normal characters but high
+ // against the end-of-string NUL.
+
+ if (*scan1 == '\0' && *scan2 == '\0')
+ return 0;
+ else if (*scan1 == '\0')
+ return -1;
+ else if (*scan2 == '\0')
+ return 1;
+ else
+ return ACE_OS::to_lower (*scan1) - ACE_OS::to_lower (*scan2);
+}
+#endif /* ACE_LACKS_STRCASECMP */
+
+#if defined (ACE_LACKS_STRCASECMP)
+int
+ACE_OS::strncasecmp_emulation (const char *s,
+ const char *t,
+ size_t len)
+{
+ const char *scan1 = s;
+ const char *scan2 = t;
+ size_t count = 0;
+
+ while (count++ < len
+ && *scan1 != 0
+ && ACE_OS::to_lower (*scan1)
+ == ACE_OS::to_lower (*scan2))
+ {
+ ++scan1;
+ ++scan2;
+ }
+
+ if (count > len)
+ return 0;
+
+ // The following case analysis is necessary so that characters which
+ // look negative collate low against normal characters but high
+ // against the end-of-string NUL.
+
+ if (*scan1 == '\0' && *scan2 == '\0')
+ return 0;
+ else if (*scan1 == '\0')
+ return -1;
+ else if (*scan2 == '\0')
+ return 1;
+ else
+ return ACE_OS::to_lower (*scan1) - ACE_OS::to_lower (*scan2);
+}
+#endif /* ACE_LACKS_STRCASECMP */