OS_NS_strings.cpp

Go to the documentation of this file.
00001 // OS_NS_strings.cpp,v 1.5 2005/10/28 16:14:54 ossama Exp
00002 
00003 #include "ace/OS_NS_strings.h"
00004 
00005 ACE_RCSID(ace, OS_NS_strings, "OS_NS_strings.cpp,v 1.5 2005/10/28 16:14:54 ossama Exp")
00006 
00007 #if !defined (ACE_HAS_INLINED_OSCALLS)
00008 # include "ace/OS_NS_strings.inl"
00009 #endif /* ACE_HAS_INLINED_OS_CALLS */
00010 
00011 #if defined (ACE_LACKS_STRCASECMP)
00012 #  include "ace/OS_NS_ctype.h"
00013 #endif /* ACE_LACKS_STRCASECMP */
00014 
00015 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00016 
00017 #if defined (ACE_LACKS_STRCASECMP)
00018 int
00019 ACE_OS::strcasecmp_emulation (const char *s, const char *t)
00020 {
00021   const char *scan1 = s;
00022   const char *scan2 = t;
00023 
00024   while (*scan1 != 0
00025          && ACE_OS::ace_tolower (*scan1)
00026             == ACE_OS::ace_tolower (*scan2))
00027     {
00028       ++scan1;
00029       ++scan2;
00030     }
00031 
00032   // The following case analysis is necessary so that characters which
00033   // look negative collate low against normal characters but high
00034   // against the end-of-string NUL.
00035 
00036   if (*scan1 == '\0' && *scan2 == '\0')
00037     return 0;
00038   else if (*scan1 == '\0')
00039     return -1;
00040   else if (*scan2 == '\0')
00041     return 1;
00042   else
00043     return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_tolower (*scan2);
00044 }
00045 #endif /* ACE_LACKS_STRCASECMP */
00046 
00047 #if defined (ACE_LACKS_STRCASECMP)
00048 int
00049 ACE_OS::strncasecmp_emulation (const char *s,
00050                                const char *t,
00051                                size_t len)
00052 {
00053   const char *scan1 = s;
00054   const char *scan2 = t;
00055   size_t count = 0;
00056 
00057   while (count++ < len
00058          && *scan1 != 0
00059          && ACE_OS::ace_tolower (*scan1)
00060             == ACE_OS::ace_tolower (*scan2))
00061     {
00062       ++scan1;
00063       ++scan2;
00064     }
00065 
00066   if (count > len)
00067     return 0;
00068 
00069   // The following case analysis is necessary so that characters which
00070   // look negative collate low against normal characters but high
00071   // against the end-of-string NUL.
00072 
00073   if (*scan1 == '\0' && *scan2 == '\0')
00074     return 0;
00075   else if (*scan1 == '\0')
00076     return -1;
00077   else if (*scan2 == '\0')
00078     return 1;
00079   else
00080     return ACE_OS::ace_tolower (*scan1) - ACE_OS::ace_tolower (*scan2);
00081 }
00082 #endif /* ACE_LACKS_STRCASECMP */
00083 
00084 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:58 2006 for ACE by doxygen 1.3.6