diff options
author | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-06-05 17:13:22 +0000 |
---|---|---|
committer | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-06-05 17:13:22 +0000 |
commit | 15b97fdd4115f3b154ba0610e7d10005dcc9ba30 (patch) | |
tree | 0e9b500473b3686826479b4ae66b2aa5b358d116 /ace | |
parent | ae76dd14f27249dbf382f2f580e1237d1c29d0a5 (diff) | |
download | ATCD-15b97fdd4115f3b154ba0610e7d10005dcc9ba30.tar.gz |
ChangeLogTag:Mon Jun 5 09:55:20 2000 Darrell Brunsch <brunsch@uci.edu>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/OS_String.cpp | 82 | ||||
-rw-r--r-- | ace/OS_String.h | 12 | ||||
-rw-r--r-- | ace/OS_String.inl | 34 |
3 files changed, 98 insertions, 30 deletions
diff --git a/ace/OS_String.cpp b/ace/OS_String.cpp index a2668869bc4..ab2f2b5065c 100644 --- a/ace/OS_String.cpp +++ b/ace/OS_String.cpp @@ -217,10 +217,8 @@ ACE_OS_String::strecpy (wchar_t *s, const wchar_t *t) } #endif /* ACE_HAS_WCHAR */ -#if defined (ACE_HAS_WINCE) -// ACE_HAS_WINCE version in .cpp file size_t -ACE_OS_String::strcspn (const char *s, const char *reject) +ACE_OS_String::strcspn_emulation (const char *s, const char *reject) { const char *scan; const char *rej_scan; @@ -238,7 +236,6 @@ ACE_OS_String::strcspn (const char *s, const char *reject) return count; } -#endif /* ACE_HAS_WINCE */ int ACE_OS_String::strcasecmp_emulation (const char *s, const char *t) @@ -269,7 +266,6 @@ ACE_OS_String::strcasecmp_emulation (const char *s, const char *t) } #if defined (ACE_HAS_WCHAR) -// ACE_WIN32 version in .cpp file int ACE_OS_String::strcasecmp_emulation (const wchar_t *s, const wchar_t *t) { @@ -299,6 +295,78 @@ ACE_OS_String::strcasecmp_emulation (const wchar_t *s, const wchar_t *t) } #endif /* ACE_HAS_WCHAR */ +int +ACE_OS_String::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_String::to_lower (*scan1) + == ACE_OS_String::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_String::to_lower (*scan1) - ACE_OS_String::to_lower (*scan2); +} + +#if defined (ACE_HAS_WCHAR) +int +ACE_OS_String::strncasecmp_emulation (const wchar_t *s, + const wchar_t *t, + size_t len) +{ + const wchar_t *scan1 = s; + const wchar_t *scan2 = t; + size_t count = 0; + + while (count++ > len + && *scan1 != 0 + && ACE_OS_String::to_lower (*scan1) + == ACE_OS_String::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_String::to_lower (*scan1) - ACE_OS_String::to_lower (*scan2); +} +#endif /* ACE_HAS_WCHAR */ + char * ACE_OS_String::strtok_r_emulation (char *s, const char *tokens, char **lasts) { @@ -319,8 +387,8 @@ ACE_OS_String::strtok_r_emulation (char *s, const char *tokens, char **lasts) const void * ACE_OS_String::memchr_emulation (const void *s, int c, size_t len) { - const u_char *t = (const u_char *) s; - const u_char *e = (const u_char *) s + len; + const unsigned char *t = (const unsigned char *) s; + const unsigned char *e = (const unsigned char *) s + len; while (t < e) if (((int) *t) == c) diff --git a/ace/OS_String.h b/ace/OS_String.h index 04292217791..91e90c517b6 100644 --- a/ace/OS_String.h +++ b/ace/OS_String.h @@ -151,21 +151,25 @@ public: private: // = These are emulation or platform specific versions of methods. static const void *memchr_emulation (const void *s, int c, size_t len); + static char *strchr_emulation (char *s, int c); static const char *strchr_emulation (const char *s, int c); - static char *strtok_r_emulation (char *s, const char *tokens, char **lasts); static char *strrchr_emulation (char *s, int c); static const char *strrchr_emulation (const char *s, int c); + static size_t strcspn_emulation (const char *s, const char *reject); static int strcasecmp_emulation (const char *s, const char *t); + static int strncasecmp_emulation (const char *s, const char *t, size_t len); + static char *strtok_r_emulation (char *s, const char *tokens, char **lasts); #if defined (ACE_HAS_WCHAR) - static wchar_t *strchr_emulation (wchar_t *s, wint_t c); - static const wchar_t *strchr_emulation (const wchar_t *s, wint_t c); static wchar_t *strrchr_emulation (wchar_t *s, wint_t c); static const wchar_t *strrchr_emulation (const wchar_t *s, wint_t c); static int strcasecmp_emulation (const wchar_t *s, const wchar_t *t); + static int strncasecmp_emulation (const wchar_t *s, + const wchar_t *t, + size_t len); #endif /* ACE_HAS_WCHAR */ -}; +}; # if defined (ACE_HAS_INLINED_OSCALLS) # if defined (ACE_INLINE) diff --git a/ace/OS_String.inl b/ace/OS_String.inl index fdcd1dd1ca0..e3eb5c13517 100644 --- a/ace/OS_String.inl +++ b/ace/OS_String.inl @@ -111,7 +111,7 @@ ACE_OS_String::strchr (char *s, int c) #if !defined (ACE_HAS_WINCE) return ::strchr (s, c); #else - return ACE_OS::strchr_emulation (s, c); + return ACE_OS_String::strchr_emulation (s, c); #endif /* ACE_HAS_WINCE */ } @@ -243,7 +243,7 @@ ACE_OS_String::strrchr (const wchar_t *s, wint_t c) #if !defined (ACE_LACKS_WCSRCHR) return (const wchar_t *) ::wcsrchr (s, c); #else - return ACE_OS_String::strrchr (s, c); + return ACE_OS_String::strrchr_emulation (s, c); #endif /* ACE_LACKS_WCSRCHR */ } #endif /* ACE_HAS_WCHAR */ @@ -265,7 +265,7 @@ ACE_OS_String::strrchr (wchar_t *s, wint_t c) #if !defined (ACE_LACKS_WCSRCHR) return (wchar_t *) ::wcsrchr (s, c); #else - return ACE_OS_String::strrchr (s, c); + return ACE_OS_String::strrchr_emulation (s, c); #endif /* ACE_LACKS_WCSRCHR */ } #endif /* ACE_HAS_WCHAR */ @@ -343,17 +343,15 @@ ACE_OS_String::strpbrk (const char *s1, const char *s2) ACE_INLINE int ACE_OS_String::strcasecmp (const char *s, const char *t) { -#if !defined (ACE_WIN32) || defined (ACE_HAS_WINCE) -# if defined (ACE_LACKS_STRCASECMP) +#if defined (ACE_LACKS_STRCASECMP) return ACE_OS_String::strcasecmp_emulation (s, t); -# else - return ::strcasecmp (s, t); -# endif /* ACE_LACKS_STRCASECMP */ #elif defined(__BORLANDC__) return ::stricmp (s, t); -#else /* !ACE_WIN32 && !__BORLANDC__ */ +#elif defined (ACE_WIN32) return ::_stricmp (s, t); -#endif /* ACE_WIN32 */ +#else /* !ACE_LACKS_STRCASECMP && !__BORLANDC__ && !ACE_WIN32 */ + return ::strcasecmp (s, t); +#endif /* !ACE_LACKS_STRCASECMP && !__BORLANDC__ && !ACE_WIN32 */ } #if defined (ACE_HAS_WCHAR) @@ -366,22 +364,20 @@ ACE_OS_String::strcasecmp (const wchar_t *s, const wchar_t *t) return ::_wcsicmp (s, t); #endif /* ACE_WIN32 */ } -#endif /* ACE_HAS_WCHAR*/ +#endif /* ACE_HAS_WCHAR */ ACE_INLINE int ACE_OS_String::strncasecmp (const char *s, const char *t, size_t len) { -#if !defined (ACE_WIN32) || defined (ACE_HAS_WINCE) -# if defined (ACE_LACKS_STRCASECMP) +#if defined (ACE_LACKS_STRCASECMP) return ACE_OS_String::strncasecmp_emulation (s, t, len); -# else - return ::strncasecmp (s, t, len); -# endif /* ACE_LACKS_STRCASECMP */ #elif defined(__BORLANDC__) return ::strnicmp (s, t, len); -#else /* !ACE_WIN32 && !__BORLANDC__ */ +#elif defined defined (ACE_WIN32) return ::_strnicmp (s, t, len); -#endif /* ACE_WIN32 */ +#else /* !ACE_LACKS_STRCASECMP && !__BORLANDC__ && !ACE_WIN32 */ + return ::strncasecmp (s, t, len); +#endif /* !ACE_LACKS_STRCASECMP && !__BORLANDC__ && !ACE_WIN32 */ } #if defined (ACE_HAS_WCHAR) @@ -389,7 +385,7 @@ ACE_INLINE int ACE_OS_String::strncasecmp (const wchar_t *s, const wchar_t *t, size_t len) { #if !defined (ACE_WIN32) - return ACE_OS::strncasecmp_emulation (s, t, len); + return ACE_OS_String::strncasecmp_emulation (s, t, len); #else /* ACE_WIN32 */ return ::_wcsnicmp (s, t, len); #endif /* ACE_WIN32 */ |