diff options
-rw-r--r-- | ChangeLog | 62 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-02a | 62 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-03a | 62 | ||||
-rw-r--r-- | ace/OS_String.cpp | 283 | ||||
-rw-r--r-- | ace/OS_String.h | 530 | ||||
-rw-r--r-- | ace/OS_String.inl | 711 | ||||
-rw-r--r-- | ace/ace_dll.dsp | 14 | ||||
-rw-r--r-- | ace/config-win32-borland.h | 3 | ||||
-rw-r--r-- | ace/config-win32-msvc.h | 4 | ||||
-rw-r--r-- | tests/Buffer_Stream_Test.cpp | 6 | ||||
-rw-r--r-- | tests/Conn_Test.cpp | 6 | ||||
-rw-r--r-- | tests/MM_Shared_Memory_Test.cpp | 5 | ||||
-rw-r--r-- | tests/Mem_Map_Test.cpp | 5 | ||||
-rw-r--r-- | tests/OS_Test.cpp | 323 | ||||
-rw-r--r-- | tests/Priority_Buffer_Test.cpp | 4 | ||||
-rw-r--r-- | tests/Priority_Reactor_Test.cpp | 2 | ||||
-rw-r--r-- | tests/Reactor_Performance_Test.cpp | 2 | ||||
-rw-r--r-- | tests/SOCK_Test.cpp | 6 | ||||
-rw-r--r-- | tests/SPIPE_Test.cpp | 7 | ||||
-rw-r--r-- | tests/run_test.lst | 1 | ||||
-rw-r--r-- | tests/test_config.h | 2 |
21 files changed, 1619 insertions, 481 deletions
diff --git a/ChangeLog b/ChangeLog index d6ec5c882f0..3fd1ae0fae9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,65 @@ +Sun Oct 22 15:07:42 2000 Darrell Brunsch <brunsch@uci.edu> + + * ace/ace_dll.dsp: + + While playing with doxygen, I found some old .h files listed + in the project but no longer existed. Removed these. + + * ace/OS_String.cpp: + * ace/OS_String.h: + * ace/OS_String.inl: + + Added quite a few emulation macros for wcs* functions that + often do not exist on platforms. Since these wcs* functions + just play with wchar_t's, they are not difficult to put in. + Some, such as to_upper and strtod/l/ul are more difficult, + so they are not present on platforms without support for + them. + + Also updated the docs to doxygen style. Someday I'll get + around to writing a script to do this... + + * ace/config-win32-borland.h: + * ace/config-win32-msvc.h: + + Added a couple of macros: + - ACE_HAS_STRCASECMP_EQUIVALENT + - ACE_HAS_STRNCASECMP_EQUIVALENT + - ACE_ITOA_EQUIVALENT + + These are used to specify different names for functions + that differ in names across different compilers. + + * tests/OS_Test.cpp: + + Added tests to test OS_String methods so I can make sure + the emulations work. + + * tests/Buffer_Stream_Test.cpp: + * tests/Conn_Test.cpp: + * tests/MM_Shared_Memory_Test.cpp: + * tests/Mem_Map_Test.cpp: + * tests/Priority_Buffer_Test.cpp: + * tests/Priority_Reactor_Test.cpp: + * tests/Reactor_Performance_Test.cpp: + * tests/SOCK_Test.cpp: + * tests/SPIPE_Test.cpp: + * tests/test_config.h: + + In order to get the test_config.h to work when a project + has more than one .cpp file that includes it (and some + compilers give warnings about a static char[]) I moved + ACE_ALPHABET into the tests that need it. Also I changed + it to a static const char[] in places that allowed it. + + So it could be possible to move it back to test_config.h + now that it can be static const char[], but I'm not 100% + sure that will keep all compilers from complaining. + + * tests/run_test.lst: + + Added OS_Test to the list of tests run. + Sun Oct 22 17:11:16 2000 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu> * ace/Malloc_T.h: Added a default value of sizeof (T) to the diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a index d6ec5c882f0..3fd1ae0fae9 100644 --- a/ChangeLogs/ChangeLog-02a +++ b/ChangeLogs/ChangeLog-02a @@ -1,3 +1,65 @@ +Sun Oct 22 15:07:42 2000 Darrell Brunsch <brunsch@uci.edu> + + * ace/ace_dll.dsp: + + While playing with doxygen, I found some old .h files listed + in the project but no longer existed. Removed these. + + * ace/OS_String.cpp: + * ace/OS_String.h: + * ace/OS_String.inl: + + Added quite a few emulation macros for wcs* functions that + often do not exist on platforms. Since these wcs* functions + just play with wchar_t's, they are not difficult to put in. + Some, such as to_upper and strtod/l/ul are more difficult, + so they are not present on platforms without support for + them. + + Also updated the docs to doxygen style. Someday I'll get + around to writing a script to do this... + + * ace/config-win32-borland.h: + * ace/config-win32-msvc.h: + + Added a couple of macros: + - ACE_HAS_STRCASECMP_EQUIVALENT + - ACE_HAS_STRNCASECMP_EQUIVALENT + - ACE_ITOA_EQUIVALENT + + These are used to specify different names for functions + that differ in names across different compilers. + + * tests/OS_Test.cpp: + + Added tests to test OS_String methods so I can make sure + the emulations work. + + * tests/Buffer_Stream_Test.cpp: + * tests/Conn_Test.cpp: + * tests/MM_Shared_Memory_Test.cpp: + * tests/Mem_Map_Test.cpp: + * tests/Priority_Buffer_Test.cpp: + * tests/Priority_Reactor_Test.cpp: + * tests/Reactor_Performance_Test.cpp: + * tests/SOCK_Test.cpp: + * tests/SPIPE_Test.cpp: + * tests/test_config.h: + + In order to get the test_config.h to work when a project + has more than one .cpp file that includes it (and some + compilers give warnings about a static char[]) I moved + ACE_ALPHABET into the tests that need it. Also I changed + it to a static const char[] in places that allowed it. + + So it could be possible to move it back to test_config.h + now that it can be static const char[], but I'm not 100% + sure that will keep all compilers from complaining. + + * tests/run_test.lst: + + Added OS_Test to the list of tests run. + Sun Oct 22 17:11:16 2000 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu> * ace/Malloc_T.h: Added a default value of sizeof (T) to the diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index d6ec5c882f0..3fd1ae0fae9 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,65 @@ +Sun Oct 22 15:07:42 2000 Darrell Brunsch <brunsch@uci.edu> + + * ace/ace_dll.dsp: + + While playing with doxygen, I found some old .h files listed + in the project but no longer existed. Removed these. + + * ace/OS_String.cpp: + * ace/OS_String.h: + * ace/OS_String.inl: + + Added quite a few emulation macros for wcs* functions that + often do not exist on platforms. Since these wcs* functions + just play with wchar_t's, they are not difficult to put in. + Some, such as to_upper and strtod/l/ul are more difficult, + so they are not present on platforms without support for + them. + + Also updated the docs to doxygen style. Someday I'll get + around to writing a script to do this... + + * ace/config-win32-borland.h: + * ace/config-win32-msvc.h: + + Added a couple of macros: + - ACE_HAS_STRCASECMP_EQUIVALENT + - ACE_HAS_STRNCASECMP_EQUIVALENT + - ACE_ITOA_EQUIVALENT + + These are used to specify different names for functions + that differ in names across different compilers. + + * tests/OS_Test.cpp: + + Added tests to test OS_String methods so I can make sure + the emulations work. + + * tests/Buffer_Stream_Test.cpp: + * tests/Conn_Test.cpp: + * tests/MM_Shared_Memory_Test.cpp: + * tests/Mem_Map_Test.cpp: + * tests/Priority_Buffer_Test.cpp: + * tests/Priority_Reactor_Test.cpp: + * tests/Reactor_Performance_Test.cpp: + * tests/SOCK_Test.cpp: + * tests/SPIPE_Test.cpp: + * tests/test_config.h: + + In order to get the test_config.h to work when a project + has more than one .cpp file that includes it (and some + compilers give warnings about a static char[]) I moved + ACE_ALPHABET into the tests that need it. Also I changed + it to a static const char[] in places that allowed it. + + So it could be possible to move it back to test_config.h + now that it can be static const char[], but I'm not 100% + sure that will keep all compilers from complaining. + + * tests/run_test.lst: + + Added OS_Test to the list of tests run. + Sun Oct 22 17:11:16 2000 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu> * ace/Malloc_T.h: Added a default value of sizeof (T) to the diff --git a/ace/OS_String.cpp b/ace/OS_String.cpp index c77165ed4a6..21d0f96aa83 100644 --- a/ace/OS_String.cpp +++ b/ace/OS_String.cpp @@ -1,9 +1,17 @@ -// $Id$ +//============================================================================= +/** + * @file OS_String.cpp + * + * $Id$ + * + * @brief Contains definitions for class ACE_OS_String. + */ +//============================================================================= #include "ace/OS_String.h" #include "ace/OS_Memory.h" -ACE_RCSID(ace, OS_String, "$Id$") +ACE_RCSID (ace, OS_String, "$Id$") #if !defined (ACE_HAS_INLINED_OSCALLS) # include "ace/OS_String.inl" @@ -13,6 +21,7 @@ ACE_RCSID(ace, OS_String, "$Id$") extern "C" wchar_t *wcsdup __P ((__const wchar_t *__s)); #endif /* ACE_LACKS_WCSDUP_PROTOTYPE */ + const char * ACE_OS_String::strnstr (const char *s1, const char *s2, size_t len2) { @@ -91,6 +100,7 @@ ACE_OS_String::strdup (const wchar_t *s) } #endif /* ACE_HAS_WCHAR */ +#if defined (ACE_LACKS_STRCHR) char * ACE_OS_String::strchr_emulation (char *s, int c) { @@ -114,6 +124,7 @@ ACE_OS_String::strchr_emulation (const char *s, int c) return 0; } } +#endif /* ACE_LACKS_STRCHR */ const char * ACE_OS_String::strnchr (const char *s, int c, size_t len) @@ -137,6 +148,7 @@ ACE_OS_String::strnchr (const wchar_t *s, wint_t c, size_t len) } #endif /* ACE_HAS_WCHAR */ +#if defined (ACE_LACKS_STRRCHR) char * ACE_OS_String::strrchr_emulation (char *s, int c) { @@ -164,10 +176,11 @@ ACE_OS_String::strrchr_emulation (const char *s, int c) return p; } +#endif /* ACE_LACKS_STRRCHR */ -#if defined (ACE_HAS_WCHAR) +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSRCHR) const wchar_t * -ACE_OS_String::strrchr_emulation (const wchar_t *s, wint_t c) +ACE_OS_String::wcsrchr_emulation (const wchar_t *s, wint_t c) { const wchar_t *p = s + ACE_OS_String::strlen (s); @@ -181,7 +194,7 @@ ACE_OS_String::strrchr_emulation (const wchar_t *s, wint_t c) } wchar_t * -ACE_OS_String::strrchr_emulation (wchar_t *s, wint_t c) +ACE_OS_String::wcsrchr_emulation (wchar_t *s, wint_t c) { wchar_t *p = s + ACE_OS_String::strlen (s); @@ -193,7 +206,7 @@ ACE_OS_String::strrchr_emulation (wchar_t *s, wint_t c) return p; } -#endif /* ACE_HAS_WCHAR */ +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSRCHR */ char * ACE_OS_String::strecpy (char *s, const char *t) @@ -221,6 +234,7 @@ ACE_OS_String::strecpy (wchar_t *s, const wchar_t *t) } #endif /* ACE_HAS_WCHAR */ +#if defined (ACE_LACKS_STRCSPN) size_t ACE_OS_String::strcspn_emulation (const char *s, const char *reject) { @@ -240,7 +254,9 @@ ACE_OS_String::strcspn_emulation (const char *s, const char *reject) return count; } +#endif /* ACE_LACKS_STRCSPN */ +#if defined (ACE_LACKS_STRCASECMP) int ACE_OS_String::strcasecmp_emulation (const char *s, const char *t) { @@ -268,10 +284,11 @@ ACE_OS_String::strcasecmp_emulation (const char *s, const char *t) else return ACE_OS_String::to_lower (*scan1) - ACE_OS_String::to_lower (*scan2); } +#endif /* ACE_LACKS_STRCASECMP */ -#if defined (ACE_HAS_WCHAR) +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSICMP) int -ACE_OS_String::strcasecmp_emulation (const wchar_t *s, const wchar_t *t) +ACE_OS_String::wcsicmp_emulation (const wchar_t *s, const wchar_t *t) { const wchar_t *scan1 = s; const wchar_t *scan2 = t; @@ -297,8 +314,9 @@ ACE_OS_String::strcasecmp_emulation (const wchar_t *s, const wchar_t *t) else return ACE_OS_String::to_lower (*scan1) - ACE_OS_String::to_lower (*scan2); } -#endif /* ACE_HAS_WCHAR */ +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSICMP */ +#if defined (ACE_LACKS_STRCASECMP) int ACE_OS_String::strncasecmp_emulation (const char *s, const char *t, @@ -333,18 +351,19 @@ ACE_OS_String::strncasecmp_emulation (const char *s, else return ACE_OS_String::to_lower (*scan1) - ACE_OS_String::to_lower (*scan2); } +#endif /* ACE_LACKS_STRCASECMP */ -#if defined (ACE_HAS_WCHAR) +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNICMP) int -ACE_OS_String::strncasecmp_emulation (const wchar_t *s, - const wchar_t *t, - size_t len) +ACE_OS_String::wcsnicmp_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 + while (count++ < len && *scan1 != 0 && ACE_OS_String::to_lower (*scan1) == ACE_OS_String::to_lower (*scan2)) @@ -369,7 +388,7 @@ ACE_OS_String::strncasecmp_emulation (const wchar_t *s, else return ACE_OS_String::to_lower (*scan1) - ACE_OS_String::to_lower (*scan2); } -#endif /* ACE_HAS_WCHAR */ +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSNICMP */ char * ACE_OS_String::strtok_r_emulation (char *s, const char *tokens, char **lasts) @@ -453,10 +472,11 @@ ACE_OS_String::itoa_emulation (int value, char *string, int radix) return string; } +#endif /* !ACE_HAS_ITOA */ -#if defined (ACE_HAS_WCHAR) +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW) wchar_t * -ACE_OS_String::itoa_emulation (int value, wchar_t *string, int radix) +ACE_OS_String::itow_emulation (int value, wchar_t *string, int radix) { wchar_t *e = string; wchar_t *b = string; @@ -504,5 +524,230 @@ ACE_OS_String::itoa_emulation (int value, wchar_t *string, int radix) return string; } -#endif /* ACE_HAS_WCHAR */ -#endif /* !ACE_HAS_ITOA */ +#endif /* ACE_HAS_WCHAR && ACE_LACKS_ITOW */ + + +// The following wcs*_emulation methods were created based on BSD code: +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * James W. Williams of NASA Goddard Space Flight Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + + + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCAT) +wchar_t * +ACE_OS_String::wcscat_emulation (wchar_t *destination, + const wchar_t *source) +{ + wchar_t *save = destination; + + for (; *destination; ++destination); + while (*destination++ = *source++); + return save; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCAT */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSPN) +size_t +ACE_OS_String::wcsspn_emulation (const wchar_t *string, + const wchar_t *charset) +{ + const wchar_t *p = string; + const wchar_t *spanp; + wchar_t c, sc; + + // Skip any characters in charset, excluding the terminating \0. +cont: + c = *p++; + for (spanp = charset; (sc = *spanp++) != 0;) + if (sc == c) + goto cont; + return (p - 1 - string); +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSPN */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSTR) +wchar_t * +ACE_OS_String::wcsstr_emulation (const wchar_t *string, + const wchar_t *charset) +{ + wchar_t c, sc; + size_t len; + + if ((c = *charset++) != 0) + { + len = strlen(charset); + do + { + do + { + if ((sc = *string++) == 0) + return NULL; + } while (sc != c); + } while (strncmp(string, charset, len) != 0); + string--; + } + + return ACE_const_cast (wchar_t *, string); +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSTR */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSLEN) +size_t +ACE_OS_String::wcslen_emulation (const wchar_t *string) +{ + const wchar_t *s; + + for (s = string; *s; ++s); + return s - string; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSLEN */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNCPY) +wchar_t * +ACE_OS_String::wcsncpy_emulation (wchar_t *destination, + const wchar_t *source, + size_t len) +{ + if (len != 0) + { + wchar_t *d = destination; + const wchar_t *s = source; + + do + { + if ((*d++ = *s++) == 0) + { + // NUL pad the remaining n-1 bytes + while (--len != 0) + *d++ = 0; + break; + } + } while (--len != 0); + } + + return destination; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSNCPY */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCMP) +int +ACE_OS_String::wcscmp_emulation (const wchar_t *string1, + const wchar_t *string2) +{ + while (*string1 == *string2++) + if (*string1++ == 0) + return (0); + return (*string1 - *--string2); +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCMP */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCPY) +wchar_t * +ACE_OS_String::wcscpy_emulation (wchar_t *destination, + const wchar_t *source) +{ + wchar_t *save = destination; + + for (; *destination = *source; ++source, ++destination); + return save; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCPY */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSPBRK) +wchar_t * +ACE_OS_String::wcspbrk_emulation (const wchar_t *string, + const wchar_t *charset) +{ + const wchar_t *scanp; + int c, sc; + + while ((c = *string++) != 0) + { + for (scanp = charset; (sc = *scanp++) != 0;) + if (sc == c) + return ACE_const_cast (wchar_t *, string - 1); + } + + return NULL; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSPBRK */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNCAT) +wchar_t * +ACE_OS_String::wcsncat_emulation (wchar_t *destination, + const wchar_t *source, + size_t count) +{ + if (count != 0) + { + wchar_t *d = destination; + const wchar_t *s = source; + + while (*d != 0) + d++; + + do + { + if ((*d = *s++) == 0) + break; + + d++; + } while (--count != 0); + + *d = 0; + } + + return destination; +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCAT */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCHR) +wchar_t * +ACE_OS_String::wcschr_emulation (const wchar_t *string, wint_t c) +{ + for (;*string ; ++string) + if (*string == c) + return ACE_const_cast (wchar_t *, string); + + return ACE_const_cast (wchar_t *, NULL); +} +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCHR */ + + + + + diff --git a/ace/OS_String.h b/ace/OS_String.h index e9a9f82239b..9bc1b0a789a 100644 --- a/ace/OS_String.h +++ b/ace/OS_String.h @@ -1,20 +1,17 @@ // -*- C++ -*- -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// OS_String.h -// -// = AUTHOR -// (Originally in OS.h) -// Doug Schmidt <schmidt@cs.wustl.edu>, Jesper S. M|ller -// <stophph@diku.dk>, and a cast of thousands... -// -// ============================================================================ +//============================================================================= +/** + * @file OS_String.h + * + * $Id$ + * + * @brief Contains definition of class ACE_OS_String. + * + * @author Doug Schmidt <schmidt@cs.wustl.edu> + * @author Jesper S. M|ller <stophph@diku.dk> + * @author and a cast of thousands... + */ +//============================================================================= #ifndef ACE_OS_STRING_H #define ACE_OS_STRING_H @@ -35,160 +32,497 @@ using std::size_t; using std::wint_t; #endif /* ACE_USES_STD_NAMESPACE_FOR_STDC_LIB */ +/** + * @class ACE_OS_String + * + * @brief This class includes functions available in string.h and ctype.h. + */ class ACE_OS_Export ACE_OS_String - // = TITLE - // This class is a wrapper for string operations - // Mainly includes the stuff found in string.h and ctype.h - // - // = DESCRIPTION { public: + /** @name Functions from <cstring> + * + * Included are the functions defined in <cstring> and their <cwchar> + * equivalents. + * + * @todo To be complete, we should add strcoll, strerror, and strxfrm. + */ + //@{ + + /// Finds characters in a buffer (const void version). + static const void *memchr (const void *s, int c, size_t len); + + /// Finds characters in a buffer (void version). + static void *memchr (void *s, int c, size_t len); + + /// Compares two buffers. + static int memcmp (const void *t, const void *s, size_t len); + + /// Copies one buffer to another. + static void *memcpy (void *t, const void *s, size_t len); + + /// Moves one buffer to another. + static void *memmove (void *t, const void *s, size_t len); + + /// Fills a buffer with a character value. + static void *memset (void *s, int c, size_t len); + + /// Appends a string to another string (char version). static char *strcat (char *s, const char *t); - static char *strncat (char *s, const char *t, size_t len); + #if defined (ACE_HAS_WCHAR) + /// Appends a string to another string (wchar_t version). static wchar_t *strcat (wchar_t *s, const wchar_t *t); - static wchar_t *strncat (wchar_t *s, const wchar_t *t, size_t len); #endif /* ACE_HAS_WCHAR */ - static char *strchr (char *s, int c); + /// Finds the first occurance of a character in a string (const char + /// version). static const char *strchr (const char *s, int c); - static char *strrchr (char *s, int c); - static const char *strrchr (const char *s, int c); - static char *strnchr (char *s, int c, size_t len); - static const char *strnchr (const char *s, int c, size_t len); + #if defined (ACE_HAS_WCHAR) - static wchar_t *strchr (wchar_t *s, wint_t c); + /// Finds the first occurance of a character in a string (const wchar_t + /// version). static const wchar_t *strchr (const wchar_t *s, wint_t c); - static wchar_t *strrchr (wchar_t *s, wint_t c); - static const wchar_t *strrchr (const wchar_t *s, wint_t c); - static wchar_t *strnchr (wchar_t *s, wint_t c, size_t len); - static const wchar_t *strnchr (const wchar_t *s, wint_t c, size_t len); #endif /* ACE_HAS_WCHAR */ + /// Finds the first occurance of a character in a string (char version). + static char *strchr (char *s, int c); + +#if defined (ACE_HAS_WCHAR) + /// Finds the first occurance of a character in a string (wchar_t version). + static wchar_t *strchr (wchar_t *s, wint_t c); +#endif /* ACE_HAS_WCHAR */ + + /// Compares two strings (char version). static int strcmp (const char *s, const char *t); - static int strncmp (const char *s, const char *t, size_t len); - static int strcasecmp (const char *s, const char *t); - static int strncasecmp (const char *s, const char *t, size_t len); + #if defined (ACE_HAS_WCHAR) + /// Compares two strings (wchar_t version). static int strcmp (const wchar_t *s, const wchar_t *t); - static int strncmp (const wchar_t *s, const wchar_t *t, size_t len); - static int strcasecmp (const wchar_t *s, const wchar_t *t); - static int strncasecmp (const wchar_t *s, const wchar_t *t, size_t len); #endif /* ACE_HAS_WCHAR */ + /// Copies a string (char version). static char *strcpy (char *s, const char *t); - static char *strecpy (char *des, const char *src); - // Copies <src> to <des>, returning a pointer to the end of the - // copied region, rather than the beginning, as <strcpy> does. - static char *strncpy (char *s, const char *t, size_t len); + #if defined (ACE_HAS_WCHAR) + /// Copies a string (wchar_t version). static wchar_t *strcpy (wchar_t *s, const wchar_t *t); - static wchar_t *strecpy (wchar_t *s, const wchar_t *t); +#endif /* ACE_HAS_WCHAR */ + + /// Searches for the first substring without any of the specified + /// characters and returns the size of the substring (char version). + static size_t strcspn (const char *s, const char *reject); + +#if defined (ACE_HAS_WCHAR) + /// Searches for the first substring without any of the specified + /// characters and returns the size of the substring (wchar_t version). + static size_t strcspn (const wchar_t *s, const wchar_t *reject); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the length of a string (char version). + static size_t strlen (const char *s); + +#if defined (ACE_HAS_WCHAR) + /// Finds the length of a string (wchar_t version). + static size_t strlen (const wchar_t *s); +#endif /* ACE_HAS_WCHAR */ + + /// Appends part of a string to another string (char version). + static char *strncat (char *s, const char *t, size_t len); + +#if defined (ACE_HAS_WCHAR) + /// Appends part of a string to another string (wchar_t version). + static wchar_t *strncat (wchar_t *s, const wchar_t *t, size_t len); +#endif /* ACE_HAS_WCHAR */ + + /// Compares two arrays (char version). + static int strncmp (const char *s, const char *t, size_t len); + +#if defined (ACE_HAS_WCHAR) + /// Compares two arrays (wchar_t version). + static int strncmp (const wchar_t *s, const wchar_t *t, size_t len); +#endif /* ACE_HAS_WCHAR */ + + /// Copies an array (char version) + static char *strncpy (char *s, const char *t, size_t len); + +#if defined (ACE_HAS_WCHAR) + /// Copies an array (wchar_t version) static wchar_t *strncpy (wchar_t *s, const wchar_t *t, size_t len); #endif /* ACE_HAS_WCHAR */ - static char *strpbrk (char *s1, const char *s2); + /// Searches for characters in a string (const char version). static const char *strpbrk (const char *s1, const char *s2); + #if defined (ACE_HAS_WCHAR) - static wchar_t *strpbrk (wchar_t *s1, const wchar_t *s2); + /// Searches for characters in a string (const wchar_t version). static const wchar_t *strpbrk (const wchar_t *s1, const wchar_t *s2); #endif /* ACE_HAS_WCHAR */ - static size_t strcspn (const char *s, const char *reject); + /// Searches for characters in a string (char version). + static char *strpbrk (char *s1, const char *s2); +#if defined (ACE_HAS_WCHAR) + /// Searches for characters in a string (wchar_t version). + static wchar_t *strpbrk (wchar_t *s1, const wchar_t *s2); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the last occurance of a character in a string (const char + /// version). + static const char *strrchr (const char *s, int c); + +#if defined (ACE_HAS_WCHAR) + /// Finds the last occurance of a character in a string (const wchar_t + /// version). + static const wchar_t *strrchr (const wchar_t *s, wint_t c); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the last occurance of a character in a string (char version). + static char *strrchr (char *s, int c); + +#if defined (ACE_HAS_WCHAR) + /// Finds the last occurance of a character in a string (wchar_t version). + static wchar_t *strrchr (wchar_t *s, wint_t c); +#endif /* ACE_HAS_WCHAR */ + + /// Searches for the first substring containing only the specified + /// characters and returns the size of the substring (char version). static size_t strspn (const char *s1, const char *s2); + #if defined (ACE_HAS_WCHAR) + /// Searches for the first substring containing only the specified + /// characters and returns the size of the substring (wchar_t version). static size_t strspn (const wchar_t *s1, const wchar_t *s2); #endif /* ACE_HAS_WCHAR */ - static char *strstr (char *s, const char *t); + /// Finds the first occurance of a substring in a string (const char + /// version). static const char *strstr (const char *s, const char *t); - static char *strnstr (char *s, const char *t, size_t len); - static const char *strnstr (const char *s, const char *t, size_t len); + #if defined (ACE_HAS_WCHAR) - static wchar_t *strstr (wchar_t *s, const wchar_t *t); + /// Finds the first occurance of a substring in a string (const wchar_t + /// version). static const wchar_t *strstr (const wchar_t *s, const wchar_t *t); - static wchar_t *strnstr (wchar_t *s, const wchar_t *t, size_t len); - static const wchar_t *strnstr (const wchar_t *s, - const wchar_t *t, - size_t len); #endif /* ACE_HAS_WCHAR */ - static char *strdup (const char *s); // Uses malloc -#if defined (ACE_HAS_WCHAR) - static wchar_t *strdup (const wchar_t *s); -#endif /* ACE_HAS_WCHAR */ + /// Finds the first occurance of a substring in a string (char version). + static char *strstr (char *s, const char *t); - static size_t strlen (const char *s); #if defined (ACE_HAS_WCHAR) - static size_t strlen (const wchar_t *s); + /// Finds the first occurance of a substring in a string (wchar_t version). + static wchar_t *strstr (wchar_t *s, const wchar_t *t); #endif /* ACE_HAS_WCHAR */ + /// Finds the next token in a string (char version). static char *strtok (char *s, const char *tokens); - static char *strtok_r (char *s, const char *tokens, char **lasts); + #if defined (ACE_HAS_WCHAR) + /// Finds the next token in a string (wchar_t version). static wchar_t *strtok (wchar_t *s, const wchar_t *tokens); #endif /* ACE_HAS_WCHAR */ - static long strtol (const char *s, char **ptr, int base); - static unsigned long strtoul (const char *s, char **ptr, int base); - static double strtod (const char *s, char **endptr); -#if defined (ACE_HAS_WCHAR) - static long strtol (const wchar_t *s, wchar_t **ptr, int base); - static unsigned long strtoul (const wchar_t *s, wchar_t **ptr, int base); - static double strtod (const wchar_t *s, wchar_t **endptr); -#endif /* ACE_HAS_WCHAR */ + //@} + /** @name Functions from <cctype> + * + * Included are the functions defined in <cctype> and their <cwctype> + * equivalents. + * + * Since they are often implemented as macros, we don't use the same name + * here. Instead, we change by prepending "ace_" (with the exception of + * to_lower). + * + * @todo To be complete, we should add: isalnum, isalpha, iscntrl + * isdigit, isgraph, islower, ispunct, isupper, isxdigit, and + * toupper. + */ + //@{ + + /// Returns true if the character is a printable character. + static int ace_isprint (const ACE_TCHAR s); + + /// Returns true if the character is a space character. + static int ace_isspace (const ACE_TCHAR s); + + /// Converts a character to lower case (char version). static int to_lower (int c); -#if defined (ACE_HAS_WCHAR) + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_TOWLOWER) + /// Converts a character to lower case (wchar_t version). static wint_t to_lower (wint_t c); -#endif /* ACE_HAS_WCHAR */ +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_TOWLOWER */ - // = A set of wrappers for memory copying operations. - static int memcmp (const void *t, const void *s, size_t len); - static const void *memchr (const void *s, int c, size_t len); - static void *memcpy (void *t, const void *s, size_t len); - static void *memmove (void *t, const void *s, size_t len); - static void *memset (void *s, int c, size_t len); + //@} - static int ace_isspace (const ACE_TCHAR s); - static int ace_isprint (const ACE_TCHAR s); + /** @name Non-standard functions + * + * These functions aren't in the standard. + * + */ + //@{ + /// Converts an integer to a string. static char *itoa (int value, char *string, int radix); + #if defined (ACE_HAS_WCHAR) + /// Converts an integer to a string. static wchar_t *itoa (int value, wchar_t *string, int radix); #endif /* ACE_HAS_WCHAR */ + /// Compares two strings (case insensitive const char version). + static int strcasecmp (const char *s, const char *t); + +#if defined (ACE_HAS_WCHAR) + /// Compares two strings (case insensitive const wchar_t version). + static int strcasecmp (const wchar_t *s, const wchar_t *t); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the first occurance of a character in an array (const char + /// version). + static const char *strnchr (const char *s, int c, size_t len); + +#if defined (ACE_HAS_WCHAR) + /// Finds the first occurance of a character in an array (const wchar_t + /// version). + static const wchar_t *strnchr (const wchar_t *s, wint_t c, size_t len); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the first occurance of a character in an array (char version). + static char *strnchr (char *s, int c, size_t len); + +#if defined (ACE_HAS_WCHAR) + /// Finds the first occurance of a character in an array (wchar_t version). + static wchar_t *strnchr (wchar_t *s, wint_t c, size_t len); +#endif /* ACE_HAS_WCHAR */ + + /// Compares two arrays (case insensitive const char version). + static int strncasecmp (const char *s, const char *t, size_t len); + +#if defined (ACE_HAS_WCHAR) + /// Compares two arrays (case insensitive const wchar_t version). + static int strncasecmp (const wchar_t *s, const wchar_t *t, size_t len); +#endif /* ACE_HAS_WCHAR */ + + /// Copies a string, but returns a pointer to the end of the + /// copied region (char version). + static char *strecpy (char *des, const char *src); + +#if defined (ACE_HAS_WCHAR) + /// Copies a string, but returns a pointer to the end of the + /// copied region (wchar_t version). + static wchar_t *strecpy (wchar_t *s, const wchar_t *t); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the first occurance of a substring in an array (const char + /// version). + static const char *strnstr (const char *s, const char *t, size_t len); + +#if defined (ACE_HAS_WCHAR) + /// Finds the first occurance of a substring in an array (const wchar_t + /// version). + static const wchar_t *strnstr (const wchar_t *s, + const wchar_t *t, + size_t len); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the first occurance of a substring in an array (char version). + static char *strnstr (char *s, const char *t, size_t len); + +#if defined (ACE_HAS_WCHAR) + /// Finds the first occurance of a substring in an array (wchar_t version). + static wchar_t *strnstr (wchar_t *s, const wchar_t *t, size_t len); +#endif /* ACE_HAS_WCHAR */ + + /// Returns a malloced duplicated string (char version). + static char *strdup (const char *s); + +#if defined (ACE_HAS_WCHAR) + /// Returns a malloced duplicated string (wchar_t version). + static wchar_t *strdup (const wchar_t *s); +#endif /* ACE_HAS_WCHAR */ + + /// Finds the next token in a string (safe char version). + static char *strtok_r (char *s, const char *tokens, char **lasts); + + /// Converts a string to a double value (char version). + static double strtod (const char *s, char **endptr); + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD) + /// Converts a string to a double value (wchar_t version). + static double strtod (const wchar_t *s, wchar_t **endptr); +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOD */ + + /// Converts a string to a long value (char version). + static long strtol (const char *s, char **ptr, int base); + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOL) + /// Converts a string to a long value (wchar_t version). + static long strtol (const wchar_t *s, wchar_t **ptr, int base); +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOL */ + + /// Converts a string to an unsigned long value (char version). + static unsigned long strtoul (const char *s, char **ptr, int base); + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOUL) + /// Converts a string to an unsigned long value (wchar_t version). + static unsigned long strtoul (const wchar_t *s, wchar_t **ptr, int base); +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOUL */ + + //@} + private: - // = These are emulation or platform specific versions of methods. + + /** @name Emulation + * + * These methods are provided for platforms that do not have a native + * implementation. + */ + //@{ + +#if !defined (ACE_HAS_ITOA) + /// Emulated itoa - Converts an integer to a string. + static char *itoa_emulation (int value, char *string, int radix); +#endif /* !ACE_HAS_ITOA */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW) + /// Emulated itow - Converts an integer to a string. + static wchar_t *itow_emulation (int value, wchar_t *string, int radix); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_ITOW */ + +#if !defined (ACE_HAS_MEMCHR) + /// Emulated memchr - Finds a character in a buffer. static const void *memchr_emulation (const void *s, int c, size_t len); +#endif /* ACE_HAS_MEMCHR */ +#if defined (ACE_LACKS_STRCASECMP) + /// Emulated strcasecmp - Performs a case insensitive comparison of strings. + static int strcasecmp_emulation (const char *s, const char *t); + + /// Emulated strncasecmp - Performs a case insensitvie comparison of arrays. + static int strncasecmp_emulation (const char *s, const char *t, size_t len); +#endif /* ACE_LACKS_STRCASECMP */ + +#if defined (ACE_LACKS_STRCSPN) + /// Emulated strcspn - Finds a substring in a string. + static size_t strcspn_emulation (const char *s, const char *reject); +#endif /* ACE_LACKS_STRCSPN */ + +#if defined (ACE_LACKS_STRCHR) + /// Emulated strchr (char version) - Finds the first occurance of a + /// character in a string. static char *strchr_emulation (char *s, int c); + + /// Emulated strchr (const char version) - Finds the first occurance of a + /// character in a string. static const char *strchr_emulation (const char *s, int c); +#endif /* ACE_LACKS_STRCHR */ + +#if defined (ACE_LACKS_STRRCHR) + /// Emulated strrchr (char version) - Finds the last occurance of a + /// character in a string. static char *strrchr_emulation (char *s, int c); + + /// Emulated strrchr (const char version) - Finds the last occurance of a + /// character in a string. 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); +#endif /* ACE_LACKS_STRRCHR */ + +#if !defined (ACE_HAS_REENTRANT_FUNCTIONS) + /// Emulated strtok_r. static char *strtok_r_emulation (char *s, const char *tokens, char **lasts); +#endif /* !ACE_HAS_REENTRANT_FUNCTIONS */ -#if defined (ACE_HAS_WCHAR) - 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_WCHAR) && defined (ACE_LACKS_WCSCAT) + /// Emulated wcscat - Appends a string. + static wchar_t *wcscat_emulation (wchar_t *destination, + const wchar_t *source); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCAT */ +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCHR) + /// Emulated wcschr - Finds a character in a string. + static wchar_t *wcschr_emulation (const wchar_t *string, wint_t c); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCHR */ -#if !defined (ACE_HAS_ITOA) - static char *itoa_emulation (int value, char *string, int radix); -# if defined (ACE_HAS_WCHAR) - static wchar_t *itoa_emulation (int value, wchar_t *string, int radix); -# endif /* ACE_HAS_WCHAR */ -#endif /* ACE_HAS_ITOA */ +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCMP) + /// Emulated wcscmp - Compares strings. + static int wcscmp_emulation (const wchar_t *string1, const wchar_t *string2); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCMP */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSCPY) + /// Emulated wcscpy - Copies a string. + static wchar_t *wcscpy_emulation (wchar_t *destination, + const wchar_t *source); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCPY */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSICMP) + /// Emulated wcsicmp - Performs a case insensitive comparison of strings. + static int wcsicmp_emulation (const wchar_t *string1, + const wchar_t *string2); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSICMP */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSLEN) + /// Emulated wcslen - Returns the length of a string. + static size_t wcslen_emulation (const wchar_t *string); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSLEN */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNCAT) + /// Emulated wcscat - Appends a string. + static wchar_t *wcsncat_emulation (wchar_t *destination, + const wchar_t *source, + size_t count); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSCAT */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNCMP) + /// Emulated wcsncmp - Compares two arrays. + static int wcsncmp_emulation (const wchar_t string1, + const wchar_t *string2, + size_t len); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSNCMP */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNCPY) + /// Emulated wcsncpy - Copies an array. + static wchar_t *wcsncpy_emulation (wchar_t *destination, + const wchar_t *source, + size_t len); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSNCPY */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSNICMP) + /// Emulated wcsnicmp - Performs a case insensitive comparison of two + /// arrays + static int wcsnicmp_emulation (const wchar_t *string1, + const wchar_t *string2, + size_t len); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSNICMP */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSPBRK) + /// Emulated wcspbrk - Searches for characters in a string. + static wchar_t *wcspbrk_emulation (const wchar_t *string, + const wchar_t *charset); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSPBRK */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSRCHR) + /// Emulated wcsrchr (wchar_t version) - Finds the last occurance of a + /// character in a string. + static wchar_t *wcsrchr_emulation (wchar_t *string, wint_t c); + + /// Emulated wcsrchr (const wchar_t version) - Finds the last occurance of a + /// character in a string. + static const wchar_t *wcsrchr_emulation (const wchar_t *string, wint_t c); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSRCHR */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSPN) + /// Emulated wcsspn. + static size_t wcsspn_emulation (const wchar_t *string, + const wchar_t *charset); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSPN */ + +#if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_WCSSTR) + /// Emulated wcsstr - Performs a case insensitive comparison of two strings. + static wchar_t *wcsstr_emulation (const wchar_t *string, + const wchar_t *charset); +#endif /* ACE_HAS_WCHAR && ACE_LACKS_WCSSTR */ + //@} }; # if defined (ACE_HAS_INLINED_OSCALLS) diff --git a/ace/OS_String.inl b/ace/OS_String.inl index d81ae33e17f..0e101089e12 100644 --- a/ace/OS_String.inl +++ b/ace/OS_String.inl @@ -1,7 +1,13 @@ // -*- C++ -*- -// $Id$ - -// Matthew Stevens 7-10-95 Fix GNU GCC 2.7 for memchr() problem. +//============================================================================= +/** + * @file OS_String.inl + * + * $Id$ + * + * @brief Contains inline definitions for class ACE_OS_String. + */ +//============================================================================= #if defined (ACE_HAS_PACE) # include "pace/string.h" @@ -9,6 +15,7 @@ # include "pace/stdlib.h" #endif /* ACE_HAS_PACE */ +// Matthew Stevens 7-10-95 Fix GNU GCC 2.7 for memchr() problem. #if defined (ACE_HAS_GNU_CSTRING_H) // Define this file to keep /usr/include/memory.h from being included. # include /**/ <cstring> @@ -31,16 +38,6 @@ #include /**/ <ctype.h> -ACE_INLINE int -ACE_OS_String::memcmp (const void *t, const void *s, size_t len) -{ -#if defined (ACE_HAS_PACE) - return pace_memcmp (t, s, len); -#else - return ::memcmp (t, s, len); -#endif /* ACE_HAS_PACE */ -} - ACE_INLINE const void * ACE_OS_String::memchr (const void *s, int c, size_t len) { @@ -54,6 +51,25 @@ ACE_OS_String::memchr (const void *s, int c, size_t len) } ACE_INLINE void * +ACE_OS_String::memchr (void *s, int c, size_t len) +{ + return ACE_const_cast (void *, + ACE_OS_String::memchr (ACE_static_cast (const void *, s), c, len)); +} + + +ACE_INLINE int +ACE_OS_String::memcmp (const void *t, const void *s, size_t len) +{ +#if defined (ACE_HAS_PACE) + return pace_memcmp (t, s, len); +#else + return ::memcmp (t, s, len); +#endif /* ACE_HAS_PACE */ +} + + +ACE_INLINE void * ACE_OS_String::memcpy (void *t, const void *s, size_t len) { #if defined (ACE_HAS_PACE) @@ -83,24 +99,6 @@ ACE_OS_String::memset (void *s, int c, size_t len) #endif /* ACE_HAS_PACE */ } -ACE_INLINE int -ACE_OS_String::to_lower (int c) -{ -#if defined (ACE_HAS_PACE) - return pace_tolower (c); -#else - return tolower (c); -#endif /* ACE_HAS_PACE */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wint_t -ACE_OS_String::to_lower (wint_t c) -{ - return ::towlower (c); -} -#endif /* ACE_HAS_WCHAR */ - ACE_INLINE char * ACE_OS_String::strcat (char *s, const char *t) { @@ -115,29 +113,35 @@ ACE_OS_String::strcat (char *s, const char *t) ACE_INLINE wchar_t * ACE_OS_String::strcat (wchar_t *s, const wchar_t *t) { +# if defined (ACE_LACKS_WCSCAT) + return ACE_OS_String::wcscat_emulation (s, t); +# else /* ACE_LACKS_WCSCAT */ return ::wcscat (s, t); +# endif /* ACE_LACKS_WCSCAT */ } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE size_t -ACE_OS_String::strspn (const char *s, const char *t) +ACE_INLINE const char * +ACE_OS_String::strchr (const char *s, int c) { #if defined (ACE_HAS_PACE) - return pace_strspn (s, t); -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (t); - ACE_NOTSUP_RETURN (-1); -#else /* ! ACE_HAS_WINCE */ - return ::strspn (s, t); + return pace_strchr (s, c); +#elif defined (ACE_LACKS_STRCHR) + return ACE_OS_String::strchr_emulation (s, c); +#else /* ! ACE_LACKS_STRCHR */ + return (const char *) ::strchr (s, c); #endif /* ACE_HAS_PACE */ } #if defined (ACE_HAS_WCHAR) -ACE_INLINE size_t -ACE_OS_String::strspn (const wchar_t*s, const wchar_t *t) +ACE_INLINE const wchar_t * +ACE_OS_String::strchr (const wchar_t *s, wint_t c) { - return ::wcsspn (s, t); +# if defined (ACE_LACKS_WCSCHR) + return ACE_OS_String::wcschr_emulation (s, c); +# else /* ACE_LACKS_WCSCHR */ + return ::wcschr (s, c); +# endif /* ACE_LACKS_WCSCHR */ } #endif /* ACE_HAS_WCHAR */ @@ -150,143 +154,224 @@ ACE_OS_String::strchr (char *s, int c) return ACE_OS_String::strchr_emulation (s, c); #else /* ! ACE_HAS_WINCE */ return ::strchr (s, c); -#endif /* ACE_HAS_PACE */ +#endif /* ACE_HAS_PACE */} } #if defined (ACE_HAS_WCHAR) ACE_INLINE wchar_t * ACE_OS_String::strchr (wchar_t *s, wint_t c) { - return ::wcschr (s, c); + return ACE_const_cast (wchar_t *, + ACE_OS_String::strchr (ACE_static_cast (const wchar_t *, s), c)); } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE const char * -ACE_OS_String::strchr (const char *s, int c) +ACE_INLINE int +ACE_OS_String::strcmp (const char *s, const char *t) { #if defined (ACE_HAS_PACE) - return pace_strchr (s, c); -#elif defined (ACE_HAS_WINCE) - return ACE_OS_String::strchr_emulation (s, c); -#else /* ! ACE_HAS_WINCE */ - return (const char *) ::strchr (s, c); + return pace_strcmp (s, t); +#else + return ::strcmp (s, t); #endif /* ACE_HAS_PACE */ } #if defined (ACE_HAS_WCHAR) -ACE_INLINE const wchar_t * -ACE_OS_String::strchr (const wchar_t *s, wint_t c) +ACE_INLINE int +ACE_OS_String::strcmp (const wchar_t *s, const wchar_t *t) { - return (const wchar_t *) ::wcschr (s, c); +# if defined (ACE_LACKS_WCSCMP) + return ACE_OS_String::wcscmp_emulation (s, t); +# else /* ACE_LACKS_WCSCMP */ + return ::wcscmp (s, t); +# endif /* ACE_LACKS_WCSCMP */ } #endif /* ACE_HAS_WCHAR */ ACE_INLINE char * -ACE_OS_String::strnchr (char *s, int c, size_t len) +ACE_OS_String::strcpy (char *s, const char *t) { -#if defined ACE_PSOS_DIAB_PPC /* Compiler problem Diab 4.2b */ - const char *const_char_s=s; - return (char *) ACE_OS_String::strnchr (const_char_s, c, len); -#else - return (char *) ACE_OS_String::strnchr ((const char *) s, c, len); -#endif +#if defined (ACE_HAS_PACE) + return pace_strcpy (s, t); +#else /* ACE_HAS_PACE */ + return ::strcpy (s, t); +#endif /* ACE_HAS_PACE */ } #if defined (ACE_HAS_WCHAR) ACE_INLINE wchar_t * -ACE_OS_String::strnchr (wchar_t *s, wint_t c, size_t len) +ACE_OS_String::strcpy (wchar_t *s, const wchar_t *t) { -#if defined ACE_PSOS_DIAB_PPC /* Compiler problem Diab 4.2b */ - const wchar_t *const_wchar_s=s; - return (wchar_t *) ACE_OS_String::strnchr (const_wchar_s, c, len); -#else - return (wchar_t *) ACE_OS_String::strnchr ((const wchar_t *) s, c, len); -#endif +# if defined (ACE_LACKS_WCSCMP) + return ACE_OS_String::wcscpy_emulation (s, t); +# else /* ACE_LACKS_WCSCMP */ + return ::wcscpy (s, t); +# endif /* ACE_LACKS_WCSCMP */ } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE const char * -ACE_OS_String::strstr (const char *s, const char *t) +ACE_INLINE size_t +ACE_OS_String::strcspn (const char *s, const char *reject) { #if defined (ACE_HAS_PACE) - return pace_strstr (s, t); -#else - return (const char *) ::strstr (s, t); + return pace_strcspn (s, reject); +#elif defined (ACE_LACKS_STRCSPN) + return ACE_OS_String::strcspn_emulation (s, reject); +#else /* ACE_LACKS_STRCSPN */ + return ::strcspn (s, reject); +#endif /* ACE_LACKS_STRCSPN */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE size_t +ACE_OS_String::strcspn (const wchar_t *s, const wchar_t *reject) +{ +# if defined (ACE_LACKS_WCSCSPN) + return ACE_OS_String::wcscspn_emulation (s, reject); +# else /* ACE_LACKS_WCSCSPN */ + return ::wcscspn (s, reject); +# endif /* ACE_LACKS_WCSCSPN */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE size_t +ACE_OS_String::strlen (const char *s) +{ +#if defined (ACE_HAS_PACE) + return pace_strlen (s); +#else /* ACE_HAS_PACE */ + return ::strlen (s); #endif /* ACE_HAS_PACE */ } #if defined (ACE_HAS_WCHAR) -ACE_INLINE const wchar_t * -ACE_OS_String::strstr (const wchar_t *s, const wchar_t *t) +ACE_INLINE size_t +ACE_OS_String::strlen (const wchar_t *s) { - return (const wchar_t *) ::wcsstr (s, t); +# if defined (ACE_LACKS_WCSLEN) + return ACE_OS_String::wcslen_emulation (s); +# else /* ACE_LACKS_WCSLEN */ + return ::wcslen (s); +# endif /* ACE_LACKS_WCSLEN */ } #endif /* ACE_HAS_WCHAR */ ACE_INLINE char * -ACE_OS_String::strstr (char *s, const char *t) +ACE_OS_String::strncat (char *s, const char *t, size_t len) { #if defined (ACE_HAS_PACE) - return pace_strstr (s, t); -#else - return ::strstr (s, t); + return pace_strncat (s, t, len); +#else /* ACE_HAS_PACE */ + return ::strncat (s, t, len); #endif /* ACE_HAS_PACE */ } #if defined (ACE_HAS_WCHAR) ACE_INLINE wchar_t * -ACE_OS_String::strstr (wchar_t *s, const wchar_t *t) +ACE_OS_String::strncat (wchar_t *s, const wchar_t *t, size_t len) { - return ::wcsstr (s, t); +# if defined (ACE_LACKS_WCSNCAT) + return ACE_OS_String::wcsncat_emulation (s, t, len); +# else /* ACE_LACKS_WCSNCAT */ + return ::wcsncat (s, t, len); +# endif /* ACE_LACKS_WCSNCAT */ } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE size_t -ACE_OS_String::strlen (const char *s) +ACE_INLINE int +ACE_OS_String::strncmp (const char *s, const char *t, size_t len) { #if defined (ACE_HAS_PACE) - return pace_strlen (s); -#else - return ::strlen (s); + return pace_strncmp (s, t, len); +#else /* ACE_HAS_PACE */ + return ::strncmp (s, t, len); #endif /* ACE_HAS_PACE */ } #if defined (ACE_HAS_WCHAR) -ACE_INLINE size_t -ACE_OS_String::strlen (const wchar_t *s) +ACE_INLINE int +ACE_OS_String::strncmp (const wchar_t *s, const wchar_t *t, size_t len) { - return ::wcslen (s); +# if defined (ACE_LACKS_WCSNCMP) + return ACE_OS_String::wcsncmp_emulation (s, t, len); +# else /* ACE_LACKS_WCSNCMP */ + return ::wcsncmp (s, t, len); +# endif /* ACE_LACKS_WCSNCMP */ } -#endif +#endif /* ACE_HAS_WCHAR */ ACE_INLINE char * -ACE_OS_String::strnstr (char *s, const char *t, size_t len) +ACE_OS_String::strncpy (char *s, const char *t, size_t len) { -#if defined ACE_PSOS_DIAB_PPC /* Compiler problem Diab 4.2b */ - const char *const_char_s=s; - return (char *) ACE_OS_String::strnstr (const_char_s, t, len); -#else - return (char *) ACE_OS_String::strnstr ((const char *) s, t, len); -#endif +#if defined (ACE_HAS_PACE) + return pace_strncpy (s, t, len); +#else /* ACE_HAS_PACE */ + return ::strncpy (s, t, len); +#endif /* ACE_HAS_PACE */ } #if defined (ACE_HAS_WCHAR) ACE_INLINE wchar_t * -ACE_OS_String::strnstr (wchar_t *s, const wchar_t *t, size_t len) +ACE_OS_String::strncpy (wchar_t *s, const wchar_t *t, size_t len) { - return (wchar_t *) ACE_OS_String::strnstr ((const wchar_t *) s, t, len); +# if defined (ACE_LACKS_WCSNCPY) + return ACE_OS_String::wcsncpy_emulation (s, t, len); +# else /* ACE_LACKS_WCSNCPY */ + return ::wcsncpy (s, t, len); +# endif /* ACE_LACKS_WCSNCPY */ +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE const char * +ACE_OS_String::strpbrk (const char *s1, const char *s2) +{ +#if defined (ACE_HAS_PACE) + return (const char*) pace_strpbrk (s1, s2); +#else /* ACE_HAS_PACE */ + return (const char *) ::strpbrk (s1, s2); +#endif /* ACE_HAS_PACE */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE const wchar_t * +ACE_OS_String::strpbrk (const wchar_t *s, const wchar_t *t) +{ +# if defined (ACE_LACKS_WCSPBRK) + return ACE_OS_String::wcspbrk_emulation (s, t); +# else /* ACE_LACKS_WCSPBRK */ + return ::wcspbrk (s, t); +# endif /* ACE_LACKS_WCSPBRK */ } #endif /* ACE_HAS_WCHAR */ ACE_INLINE char * -ACE_OS_String::strrchr (char *s, int c) +ACE_OS_String::strpbrk (char *s1, const char *s2) { #if defined (ACE_HAS_PACE) - return pace_strrchr (s, c); + return pace_strpbrk (s1, s2); +#else /* ACE_HAS_PACE */ + return ::strpbrk (s1, s2); +#endif /* ! ACE_HAS_WINCE */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS_String::strpbrk (wchar_t *s, const wchar_t *t) +{ + return ACE_const_cast (wchar_t *, + ACE_OS_String::strpbrk (ACE_static_cast (const wchar_t *, s), t)); +} +#endif /* ACE_HAS_WCHAR */ + +ACE_INLINE const char * +ACE_OS_String::strrchr (const char *s, int c) +{ +#if defined (ACE_HAS_PACE) + return (const char*) pace_strrchr (s, c); #elif defined (ACE_LACKS_STRRCHR) return ACE_OS_String::strrchr_emulation (s, c); #else /* ! ACE_LACKS_STRRCHR */ - return ::strrchr (s, c); + return (const char *) ::strrchr (s, c); #endif /* ! ACE_LACKS_STRRCHR */ } @@ -295,22 +380,22 @@ ACE_INLINE const wchar_t * ACE_OS_String::strrchr (const wchar_t *s, wint_t c) { #if defined (ACE_LACKS_WCSRCHR) - return ACE_OS_String::strrchr_emulation (s, c); + return ACE_OS_String::wcsrchr_emulation (s, c); #else /* ! ACE_LACKS_WCSRCHR */ return (const wchar_t *) ::wcsrchr (s, c); #endif /* ! ACE_LACKS_WCSRCHR */ } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE const char * -ACE_OS_String::strrchr (const char *s, int c) +ACE_INLINE char * +ACE_OS_String::strrchr (char *s, int c) { #if defined (ACE_HAS_PACE) - return (const char*) pace_strrchr (s, c); + return pace_strrchr (s, c); #elif defined (ACE_LACKS_STRRCHR) return ACE_OS_String::strrchr_emulation (s, c); #else /* ! ACE_LACKS_STRRCHR */ - return (const char *) ::strrchr (s, c); + return ::strrchr (s, c); #endif /* ! ACE_LACKS_STRRCHR */ } @@ -318,229 +403,258 @@ ACE_OS_String::strrchr (const char *s, int c) ACE_INLINE wchar_t * ACE_OS_String::strrchr (wchar_t *s, wint_t c) { -#if defined (ACE_LACKS_WCSRCHR) - return ACE_OS_String::strrchr_emulation (s, c); -#else /* ! ACE_LACKS_WCSRCHR */ - return (wchar_t *) ::wcsrchr (s, c); -#endif /* ! ACE_LACKS_WCSRCHR */ + return ACE_const_cast (wchar_t *, + ACE_OS_String::strrchr (ACE_static_cast (const wchar_t *, s), c)); } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE int -ACE_OS_String::strcmp (const char *s, const char *t) +ACE_INLINE size_t +ACE_OS_String::strspn (const char *s, const char *t) { #if defined (ACE_HAS_PACE) - return pace_strcmp (s, t); -#else - return ::strcmp (s, t); + return pace_strspn (s, t); +#else /* ACE_HAS_PACE */ + return ::strspn (s, t); #endif /* ACE_HAS_PACE */ } #if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS_String::strcmp (const wchar_t *s, const wchar_t *t) +ACE_INLINE size_t +ACE_OS_String::strspn (const wchar_t *s, const wchar_t *t) { - return ::wcscmp (s, t); +# if defined (ACE_LACKS_WCSSPN) + return ACE_OS_String::wcsspn_emulation (s, t); +# else /* ACE_LACKS_WCSSPN */ + return ::wcsspn (s, t); +# endif /* ACE_LACKS_WCSSPN */ } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE char * -ACE_OS_String::strcpy (char *s, const char *t) +ACE_INLINE const char * +ACE_OS_String::strstr (const char *s, const char *t) { #if defined (ACE_HAS_PACE) - return pace_strcpy (s, t); -#else - return ::strcpy (s, t); + return pace_strstr (s, t); +#else /* ACE_HAS_PACE */ + return (const char *) ::strstr (s, t); #endif /* ACE_HAS_PACE */ } #if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS_String::strcpy (wchar_t *s, const wchar_t *t) +ACE_INLINE const wchar_t * +ACE_OS_String::strstr (const wchar_t *s, const wchar_t *t) { - return ::wcscpy (s, t); +# if defined (ACE_LACKS_WCSSTR) + return ACE_OS_String::wcsstr_emulation (s, t); +# else /* ACE_LACKS_WCSSTR */ + return (const wchar_t *) ::wcsstr (s, t); +# endif /* ACE_LACKS_WCSSTR */ } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE size_t -ACE_OS_String::strcspn (const char *s, const char *reject) +ACE_INLINE char * +ACE_OS_String::strstr (char *s, const char *t) { #if defined (ACE_HAS_PACE) - return pace_strcspn (s, reject); -#elif defined (ACE_HAS_WINCE) - return ACE_OS_String::strcspn_emulation (s, reject); -#else /* ! ACE_HAS_WINCE */ - return ::strcspn (s, reject); -#endif /* ! ACE_HAS_WINCE */ + return pace_strstr (s, t); +#else /* ACE_HAS_PACE */ + return ::strstr (s, t); +#endif /* ACE_HAS_PACE */ +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS_String::strstr (wchar_t *s, const wchar_t *t) +{ +# if defined (ACE_LACKS_WCSSTR) + return ACE_OS_String::wcsstr_emulation (s, t); +# else /* ACE_LACKS_WCSSTR */ + return ::wcsstr (s, t); +# endif /* ACE_LACKS_WCSSTR */ } +#endif /* ACE_HAS_WCHAR */ ACE_INLINE char * -ACE_OS_String::strpbrk (char *s1, const char *s2) +ACE_OS_String::strtok (char *s, const char *tokens) { #if defined (ACE_HAS_PACE) - return pace_strpbrk (s1, s2); -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (s1); - ACE_UNUSED_ARG (s2); - ACE_NOTSUP_RETURN (0); -#else /* ! ACE_HAS_WINCE */ - return ::strpbrk (s1, s2); -#endif /* ! ACE_HAS_WINCE */ + return pace_strtok (s, tokens); +#else /* ACE_HAS_PACE */ + return ::strtok (s, tokens); +#endif /* ACE_HAS_PACE */ } #if defined (ACE_HAS_WCHAR) ACE_INLINE wchar_t * -ACE_OS_String::strpbrk (wchar_t *s, const wchar_t *t) +ACE_OS_String::strtok (wchar_t *s, const wchar_t *tokens) { - return ::wcspbrk (s, t); +# if defined (ACE_HAS_SAFE_WCSTOK) + ACE_UNUSED_ARG(s); + ACE_UNUSED_ARG(tokens); + ACE_NOTSUP_RETURN (0); +# else + return ::wcstok (s, tokens); +# endif /* ACE_HAS_SAFE_WCSTOK */ } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE const char * -ACE_OS_String::strpbrk (const char *s1, const char *s2) + +ACE_INLINE int +ACE_OS_String::ace_isprint (const ACE_TCHAR s) { -#if defined (ACE_HAS_PACE) - return (const char*) pace_strpbrk (s1, s2); -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (s1); - ACE_UNUSED_ARG (s2); - ACE_NOTSUP_RETURN (0); -#else /* ! ACE_HAS_WINCE */ - return (const char *) ::strpbrk (s1, s2); -#endif /* ! ACE_HAS_WINCE */ +#if defined (ACE_USES_WCHAR) + return ::iswprint (s); +#elif defined (ACE_HAS_PACE) + return pace_isprint (s); +#else /* ACE_USES_WCHAR */ + return isprint (s); +#endif /* ACE_USES_WCHAR */ } ACE_INLINE int -ACE_OS_String::strcasecmp (const char *s, const char *t) +ACE_OS_String::ace_isspace (const ACE_TCHAR s) { -#if defined (ACE_LACKS_STRCASECMP) - return ACE_OS_String::strcasecmp_emulation (s, t); -#elif defined(__BORLANDC__) - return ::stricmp (s, t); -#elif defined (ACE_WIN32) - return ::_stricmp (s, t); -#else /* !ACE_LACKS_STRCASECMP && !__BORLANDC__ && !ACE_WIN32 */ - return ::strcasecmp (s, t); -#endif /* !ACE_LACKS_STRCASECMP && !__BORLANDC__ && !ACE_WIN32 */ +#if defined (ACE_USES_WCHAR) + return ::iswspace (s); +#elif defined (ACE_HAS_PACE) + return pace_isspace (s); +#else /* ACE_HAS_PACE */ + return isspace (s); +#endif /* ACE_HAS_PACE */ } -#if defined (ACE_HAS_WCHAR) ACE_INLINE int -ACE_OS_String::strcasecmp (const wchar_t *s, const wchar_t *t) +ACE_OS_String::to_lower (int c) { -#if defined (ACE_WIN32) - return ::_wcsicmp (s, t); -#else /* ! ACE_WIN32 */ - return ACE_OS_String::strcasecmp_emulation (s, t); -#endif /* ! ACE_WIN32 */ +#if defined (ACE_HAS_PACE) + return pace_tolower (c); +#else /* ACE_HAS_PACE */ + return tolower (c); +#endif /* ACE_HAS_PACE */ } -#endif /* ACE_HAS_WCHAR */ -ACE_INLINE int -ACE_OS_String::strncasecmp (const char *s, const char *t, size_t len) +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_TOWLOWER) +ACE_INLINE wint_t +ACE_OS_String::to_lower (wint_t c) { -#if defined (ACE_LACKS_STRCASECMP) - return ACE_OS_String::strncasecmp_emulation (s, t, len); -#elif defined(__BORLANDC__) - return ::strnicmp (s, t, len); -#elif defined (ACE_WIN32) - return ::_strnicmp (s, t, len); -#else /* !ACE_LACKS_STRCASECMP && !__BORLANDC__ && !ACE_WIN32 */ - return ::strncasecmp (s, t, len); -#endif /* !ACE_LACKS_STRCASECMP && !__BORLANDC__ && !ACE_WIN32 */ + return ::towlower (c); +} +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_TOWLOWER */ + +ACE_INLINE char * +ACE_OS_String::itoa (int value, char *string, int radix) +{ +#if !defined (ACE_HAS_ITOA) + return ACE_OS_String::itoa_emulation (value, string, radix); +#elif defined (ACE_ITOA_EQUIVALENT) + return ACE_ITOA_EQUIVALENT (value, string, radix); +#else /* !ACE_HAS_ITOA */ + return ::itoa (value, string, radix); +#endif /* !ACE_HAS_ITOA */ } #if defined (ACE_HAS_WCHAR) -ACE_INLINE int -ACE_OS_String::strncasecmp (const wchar_t *s, const wchar_t *t, size_t len) +ACE_INLINE wchar_t * +ACE_OS_String::itoa (int value, wchar_t *string, int radix) { -#if defined (ACE_WIN32) - return ::_wcsnicmp (s, t, len); -#else /* ! ACE_WIN32 */ - return ACE_OS_String::strncasecmp_emulation (s, t, len); -#endif /* ! ACE_WIN32 */ +#if defined (ACE_LACKS_ITOW) + return ACE_OS_String::itow_emulation (value, string, radix); +#else /* ACE_LACKS_ITOW */ + return ::_itow (value, string, radix); +#endif /* ACE_LACKS_ITOW */ } #endif /* ACE_HAS_WCHAR */ ACE_INLINE int -ACE_OS_String::strncmp (const char *s, const char *t, size_t len) +ACE_OS_String::strcasecmp (const char *s, const char *t) { -#if defined (ACE_HAS_PACE) - return pace_strncmp (s, t, len); -#else - return ::strncmp (s, t, len); -#endif /* ACE_HAS_PACE */ +#if defined (ACE_LACKS_STRCASECMP) + return ACE_OS_String::strcasecmp_emulation (s, t); +#elif defined (ACE_STRCASECMP_EQUIVALENT) + return ACE_STRCASECMP_EQUIVALENT (s, t); +#else /* ACE_LACKS_STRCASECMP */ + return ::strcasecmp (s, t); +#endif /* ACE_LACKS_STRCASECMP */ } #if defined (ACE_HAS_WCHAR) ACE_INLINE int -ACE_OS_String::strncmp (const wchar_t *s, const wchar_t *t, size_t len) +ACE_OS_String::strcasecmp (const wchar_t *s, const wchar_t *t) { - return ::wcsncmp (s, t, len); +# if defined (ACE_LACKS_WCSICMP) + return ACE_OS_String::wcsicmp_emulation (s, t); +# else /* ACE_LACKS_WCSICMP */ + return ::_wcsicmp (s, t); +# endif /* ACE_LACKS_WCSICMP */ } #endif /* ACE_HAS_WCHAR */ ACE_INLINE char * -ACE_OS_String::strncpy (char *s, const char *t, size_t len) +ACE_OS_String::strnchr (char *s, int c, size_t len) { -#if defined (ACE_HAS_PACE) - return pace_strncpy (s, t, len); +#if defined ACE_PSOS_DIAB_PPC /* Compiler problem Diab 4.2b */ + const char *const_char_s = s; + return ACE_const_cast (char *, + ACE_OS_String::strnchr (const_char_s, c, len)); #else - return ::strncpy (s, t, len); -#endif /* ACE_HAS_PACE */ + return ACE_const_cast (char *, + ACE_OS_String::strnchr (ACE_static_cast (const char *, s), c, len)); +#endif } #if defined (ACE_HAS_WCHAR) ACE_INLINE wchar_t * -ACE_OS_String::strncpy (wchar_t *s, const wchar_t *t, size_t len) +ACE_OS_String::strnchr (wchar_t *s, wint_t c, size_t len) { - return ::wcsncpy (s, t, len); + return ACE_const_cast (wchar_t *, + ACE_OS_String::strnchr (ACE_static_cast (const wchar_t *, s), c, len)); } #endif /* ACE_HAS_WCHAR */ -ACE_INLINE char * -ACE_OS_String::strncat (char *s, const char *t, size_t len) +ACE_INLINE int +ACE_OS_String::strncasecmp (const char *s, const char *t, size_t len) { -#if defined (ACE_HAS_PACE) - return pace_strncat (s, t, len); -#else - return ::strncat (s, t, len); -#endif /* ACE_HAS_PACE */ +#if defined (ACE_LACKS_STRCASECMP) + return ACE_OS_String::strncasecmp_emulation (s, t, len); +#elif defined (ACE_STRNCASECMP_EQUIVALENT) + return ACE_STRNCASECMP_EQUIVALENT (s, t, len); +#else /* ACE_LACKS_STRCASECMP */ + return ::strncasecmp (s, t, len); +#endif /* ACE_LACKS_STRCASECMP */ } #if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS_String::strncat (wchar_t *s, const wchar_t *t, size_t len) +ACE_INLINE int +ACE_OS_String::strncasecmp (const wchar_t *s, const wchar_t *t, size_t len) { - return ::wcsncat (s, t, len); +#if defined (ACE_LACKS_WCSNICMP) + return ACE_OS_String::wcsnicmp_emulation (s, t, len); +#else /* ACE_LACKS_WCSNICMP */ + return ::_wcsnicmp (s, t, len); +#endif /* ACE_LACKS_WCSNICMP */ } #endif /* ACE_HAS_WCHAR */ ACE_INLINE char * -ACE_OS_String::strtok (char *s, const char *tokens) +ACE_OS_String::strnstr (char *s, const char *t, size_t len) { -#if defined (ACE_HAS_PACE) - return pace_strtok (s, tokens); +#if defined ACE_PSOS_DIAB_PPC /* Compiler problem Diab 4.2b */ + const char *const_char_s=s; + return (char *) ACE_OS_String::strnstr (const_char_s, t, len); #else - return ::strtok (s, tokens); -#endif /* ACE_HAS_PACE */ + return (char *) ACE_OS_String::strnstr ((const char *) s, t, len); +#endif } #if defined (ACE_HAS_WCHAR) ACE_INLINE wchar_t * -ACE_OS_String::strtok (wchar_t *s, const wchar_t *tokens) +ACE_OS_String::strnstr (wchar_t *s, const wchar_t *t, size_t len) { -# if defined (ACE_HAS_SAFE_WCSTOK) - ACE_UNUSED_ARG(s); - ACE_UNUSED_ARG(tokens); - ACE_NOTSUP_RETURN (0); -# else - return ::wcstok (s, tokens); -# endif /* ACE_HAS_SAFE_WCSTOK */ + return ACE_const_cast (wchar_t *, + ACE_OS_String::strnstr (ACE_static_cast (const wchar_t *, s), t, len)); } #endif /* ACE_HAS_WCHAR */ - ACE_INLINE char * ACE_OS_String::strtok_r (char *s, const char *tokens, char **lasts) { @@ -553,132 +667,57 @@ ACE_OS_String::strtok_r (char *s, const char *tokens, char **lasts) #endif /* (ACE_HAS_REENTRANT_FUNCTIONS) */ } +ACE_INLINE double +ACE_OS_String::strtod (const char *s, char **endptr) +{ +#if defined (ACE_HAS_PACE) + return pace_strtod (s, endptr); +#else /* ACE_HAS_PACE */ + return ::strtod (s, endptr); +#endif /* ACE_HAS_PACE */ +} + +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD) +ACE_INLINE double +ACE_OS_String::strtod (const wchar_t *s, wchar_t **endptr) +{ + return ::wcstod (s, endptr); +} +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOD */ + ACE_INLINE long ACE_OS_String::strtol (const char *s, char **ptr, int base) { #if defined (ACE_HAS_PACE) return pace_strtol (s, ptr, base); - // @@ We must implement this function for WinCE also. - // Notice WinCE support wcstol. -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (ptr); - ACE_UNUSED_ARG (base); - ACE_NOTSUP_RETURN (0); -#else /* ! ACE_HAS_WINCE */ +#else /* ACE_HAS_PACE */ return ::strtol (s, ptr, base); -#endif /* ! ACE_HAS_WINCE */ +#endif /* ACE_HAS_PACE */ } -#if defined (ACE_HAS_WCHAR) +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOL) ACE_INLINE long ACE_OS_String::strtol (const wchar_t *s, wchar_t **ptr, int base) { return ::wcstol (s, ptr, base); } -#endif /* ACE_HAS_WCHAR */ +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOL */ ACE_INLINE unsigned long ACE_OS_String::strtoul (const char *s, char **ptr, int base) { #if defined (ACE_HAS_PACE) return pace_strtoul (s, ptr, base); - // @@ WINCE: We must implement this function for WinCE also. - // Notice WinCE support wcstoul. -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (ptr); - ACE_UNUSED_ARG (base); - ACE_NOTSUP_RETURN (0); -#else /* ! ACE_HAS_WINCE */ +#else /* ACE_HAS_PACE */ return ::strtoul (s, ptr, base); -#endif /* ! ACE_HAS_WINCE */ +#endif /* ACE_HAS_PACE */ } - -#if defined (ACE_HAS_WCHAR) +#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOUL) ACE_INLINE unsigned long ACE_OS_String::strtoul (const wchar_t *s, wchar_t **ptr, int base) { return ::wcstoul (s, ptr, base); } -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE double -ACE_OS_String::strtod (const char *s, char **endptr) -{ -#if defined (ACE_HAS_PACE) - return pace_strtod (s, endptr); - // @@ WinCE only support wcstod -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (s); - ACE_UNUSED_ARG (endptr); - ACE_NOTSUP_RETURN (0); -#else /* ! ACE_HAS_WINCE */ - return ::strtod (s, endptr); -#endif /* ! ACE_HAS_WINCE */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE double -ACE_OS_String::strtod (const wchar_t *s, wchar_t **endptr) -{ - return ::wcstod (s, endptr); -} -#endif /* ACE_HAS_WCHAR */ - -ACE_INLINE int -ACE_OS_String::ace_isspace (const ACE_TCHAR s) -{ -#if defined (ACE_HAS_PACE) - return pace_isspace (s); -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (s); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_USES_WCHAR) - return iswspace (s); -#else - return isspace (s); -#endif /* ACE_HAS_WINCE */ -} - -ACE_INLINE int -ACE_OS_String::ace_isprint (const ACE_TCHAR s) -{ -#if defined (ACE_HAS_PACE) - return pace_isprint (s); -#elif defined (ACE_HAS_WINCE) - ACE_UNUSED_ARG (s); - ACE_NOTSUP_RETURN (0); -#elif defined (ACE_USES_WCHAR) - return iswprint (s); -#else - return isprint (s); -#endif /* ACE_HAS_WINCE */ -} +#endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOUL */ -ACE_INLINE char * -ACE_OS_String::itoa (int value, char *string, int radix) -{ -#if defined (ACE_HAS_ITOA) -#if defined (_MSC_VER) - return ::_itoa (value, string, radix); -#else - return ::itoa (value, string, radix); -#endif /* _MSC_VER */ -#else - return ACE_OS_String::itoa_emulation (value, string, radix); -#endif /* ACE_HAS_ITOA */ -} - -#if defined (ACE_HAS_WCHAR) -ACE_INLINE wchar_t * -ACE_OS_String::itoa (int value, wchar_t *string, int radix) -{ -#if defined (ACE_HAS_ITOA) - return ::_itow (value, string, radix); -#else - return ACE_OS_String::itoa_emulation (value, string, radix); -#endif /* ACE_HAS_ITOA */ -} -#endif /* ACE_HAS_WCHAR */ diff --git a/ace/ace_dll.dsp b/ace/ace_dll.dsp index 2b586009b03..c80f5e66a86 100644 --- a/ace/ace_dll.dsp +++ b/ace/ace_dll.dsp @@ -4314,10 +4314,6 @@ SOURCE=.\Auto_Ptr.h # End Source File
# Begin Source File
-SOURCE=.\Base_Pointer_T.h
-# End Source File
-# Begin Source File
-
SOURCE=.\Base_Thread_Adapter.h
# End Source File
# Begin Source File
@@ -4346,7 +4342,7 @@ SOURCE=.\Caching_Strategies_T.h # End Source File
# Begin Source File
-SOURCE=.\Caching_Strategy_Utility_T.h
+SOURCE=.\Caching_Utility_T.h
# End Source File
# Begin Source File
@@ -4906,10 +4902,6 @@ SOURCE=.\Reactor_Impl.h # End Source File
# Begin Source File
-SOURCE=.\ReactorEx.h
-# End Source File
-# Begin Source File
-
SOURCE=.\Read_Buffer.h
# End Source File
# Begin Source File
@@ -5070,10 +5062,6 @@ SOURCE=.\Stats.h # End Source File
# Begin Source File
-SOURCE=.\stdcpp.h
-# End Source File
-# Begin Source File
-
SOURCE=.\Strategies.h
# End Source File
# Begin Source File
diff --git a/ace/config-win32-borland.h b/ace/config-win32-borland.h index a42868756c2..e9b00a4377f 100644 --- a/ace/config-win32-borland.h +++ b/ace/config-win32-borland.h @@ -29,6 +29,9 @@ # define ACE_CC_PREPROCESSOR_ARGS "-P- -ocon -w-" # define ACE_HAS_ITOA 1 +# define ACE_STRCASECMP_EQUIVALENT ::stricmp +# define ACE_STRNCASECMP_EQUIVALENT ::strnicmp + # define ACE_EXPORT_NESTED_CLASSES 1 # define ACE_HAS_ANSI_CASTS 1 # define ACE_HAS_CPLUSPLUS_HEADERS 1 diff --git a/ace/config-win32-msvc.h b/ace/config-win32-msvc.h index 5efbaf628fe..a5042f70222 100644 --- a/ace/config-win32-msvc.h +++ b/ace/config-win32-msvc.h @@ -66,6 +66,10 @@ #define ACE_HAS_ITOA +#define ACE_ITOA_EQUIVALENT ::_itoa +#define ACE_STRCASECMP_EQUIVALENT ::_stricmp +#define ACE_STRNCASECMP_EQUIVALENT ::_strnicmp + // VC5 doesn't support operator placement delete # if defined (_MSC_VER) && (_MSC_VER < 1200) # define ACE_LACKS_PLACEMENT_OPERATOR_DELETE diff --git a/tests/Buffer_Stream_Test.cpp b/tests/Buffer_Stream_Test.cpp index dd0b6eb740d..9be7ca0e74d 100644 --- a/tests/Buffer_Stream_Test.cpp +++ b/tests/Buffer_Stream_Test.cpp @@ -31,6 +31,8 @@ ACE_RCSID(tests, Buffer_Stream_Test, "$Id$") #if defined (ACE_HAS_THREADS) +static const char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; + typedef ACE_Stream<ACE_MT_SYNCH> MT_Stream; typedef ACE_Module<ACE_MT_SYNCH> MT_Module; typedef ACE_Task<ACE_MT_SYNCH> MT_Task; @@ -114,7 +116,7 @@ Supplier::svc (void) // Send one message for each letter of the alphabet, then send an empty // message to mark the end. - for (char *c = ACE_ALPHABET; *c != '\0'; c++) + for (const char *c = ACE_ALPHABET; *c != '\0'; c++) { // Allocate a new message. char d[2]; @@ -157,7 +159,7 @@ Consumer::svc (void) { ACE_Message_Block *mb = 0; int result; - char *c = ACE_ALPHABET; + const char *c = ACE_ALPHABET; char *output; // Keep looping, reading a message out of the queue, until we diff --git a/tests/Conn_Test.cpp b/tests/Conn_Test.cpp index 12cfcab0eea..1ca72aa5570 100644 --- a/tests/Conn_Test.cpp +++ b/tests/Conn_Test.cpp @@ -37,6 +37,8 @@ ACE_RCSID(tests, Conn_Test, "$Id$") +static const char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; + // The following works around bugs with some operating systems, which // don't allow multiple threads/process to call accept() on the same // listen-mode port/socket. Also, note that since timed accept is @@ -247,7 +249,7 @@ Svc_Handler::send_data (void) { // Send data to server. - for (char *c = ACE_ALPHABET; *c != '\0'; c++) + for (const char *c = ACE_ALPHABET; *c != '\0'; c++) if (this->peer ().send_n (c, 1) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), @@ -262,7 +264,7 @@ Svc_Handler::recv_data (void) ACE_Handle_Set handle_set; handle_set.set_bit (new_stream.get_handle ()); - char *t = ACE_ALPHABET; + const char *t = ACE_ALPHABET; // Read data from client (terminate on error). diff --git a/tests/MM_Shared_Memory_Test.cpp b/tests/MM_Shared_Memory_Test.cpp index f02c1cd5406..4366a137128 100644 --- a/tests/MM_Shared_Memory_Test.cpp +++ b/tests/MM_Shared_Memory_Test.cpp @@ -30,6 +30,7 @@ ACE_RCSID(tests, MM_Shared_Memory_Test, "$Id$") +static const char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; const int SHMSZ = 27; static ACE_TCHAR *shm_key; @@ -65,7 +66,7 @@ child (void * = 0) result = synchronizer->acquire (); ACE_ASSERT (result != -1); - char *t = ACE_ALPHABET; + const char *t = ACE_ALPHABET; ACE_Shared_Memory_MM shm_child; result = shm_child.open (shm_key); @@ -102,7 +103,7 @@ parent (void * = 0) char *s = shm; - for (char *c = ACE_ALPHABET; *c != '\0'; c++) + for (const char *c = ACE_ALPHABET; *c != '\0'; c++) *s++ = *c; *s = '\0'; diff --git a/tests/Mem_Map_Test.cpp b/tests/Mem_Map_Test.cpp index 8c43bd4e3b7..79758df2aad 100644 --- a/tests/Mem_Map_Test.cpp +++ b/tests/Mem_Map_Test.cpp @@ -24,6 +24,7 @@ ACE_RCSID(tests, Mem_Map_Test, "$Id$") +static const char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; static const int LINE_LENGTH = 10; static const int NUM_LINES = 15; @@ -61,8 +62,8 @@ create_test_file (ACE_TCHAR *filename, int line_length, int num_lines) char *mybuf = 0; ACE_NEW_RETURN (mybuf, char[line_length + 1], -1); - char *c = ACE_ALPHABET; - char *d = c; + const char *c = ACE_ALPHABET; + const char *d = c; ACE_HANDLE file_handle = ACE_OS::open (filename, O_RDWR | O_CREAT | O_TRUNC, diff --git a/tests/OS_Test.cpp b/tests/OS_Test.cpp index 2660736bd33..a9e413a4fed 100644 --- a/tests/OS_Test.cpp +++ b/tests/OS_Test.cpp @@ -125,6 +125,326 @@ rename_test (void) #endif /* ACE_LACKS_RENAME */ } +// +int +string_emulation_test (void) +{ + { + // ======================================================================== + // Test memchr + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing memchr"))); + + const char memchr1[] = "abcdefghijklmnopqrstuvwxyz"; + + ACE_ASSERT (ACE_OS_String::memchr (NULL, 'a', 0) == NULL); + ACE_ASSERT (ACE_OS_String::memchr (memchr1, 'a', sizeof (memchr1)) != NULL); + ACE_ASSERT (ACE_OS_String::memchr (memchr1, '1', sizeof (memchr1)) == NULL); + + // ======================================================================== + // Test strchr + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strchr"))); + + const char strchr1[] = "abcdefghijkabcdefghijk"; + + ACE_ASSERT (*ACE_OS_String::strchr (strchr1, 'h') == 'h'); + ACE_ASSERT (ACE_OS_String::strchr (strchr1, 'h') == strchr1 + 7); + ACE_ASSERT (ACE_OS_String::strchr (strchr1, '1') == NULL); + + // ======================================================================== + // Test strrchr + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strrchr"))); + + const char strrchr1[] = "abcdefghijkabcdefghijk"; + + ACE_ASSERT (*ACE_OS_String::strrchr (strrchr1, 'h') == 'h'); + ACE_ASSERT (ACE_OS_String::strrchr (strrchr1, 'h') == strrchr1 + 18); + ACE_ASSERT (ACE_OS_String::strrchr (strrchr1, '1') == NULL); + + // ======================================================================== + // Test strcspn + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strcspn"))); + + const char strcspn1[] = "abcdefghijkabcdefghijk"; + + ACE_ASSERT (ACE_OS_String::strcspn (strcspn1, "d") == 3); + ACE_ASSERT (ACE_OS_String::strcspn (strcspn1, "abcdefghijk") == 0); + + // ======================================================================== + // Test strcasecmp + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strcasecmp"))); + + const char strcasecmp1[] = "stringf"; + const char strcasecmp2[] = "stringfe"; // An extra character + const char strcasecmp3[] = "stringg"; // The last letter is higher + const char strcasecmp4[] = "STRINGF"; // Different case + const char strcasecmp5[] = "stringe"; // The last letter is lower + + ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp1) == 0); + ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp2) < 0); + ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp3) < 0); + ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp4) == 0); + ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp5) > 0); + + // ======================================================================== + // Test strtok_r + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strtok_r"))); + + char *strtok_r1 = "A string of tokens"; + + ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok_r (strtok_r1, + " ", + &strtok_r1), + "A") == 0); + ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok_r (strtok_r1, + " ", + &strtok_r1), + "string") == 0); + ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok_r (strtok_r1, + " ", + &strtok_r1), + "of") == 0); + ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::strtok_r (strtok_r1, + " ", + &strtok_r1), + "tokens") == 0); + ACE_ASSERT (ACE_OS_String::strtok_r (strtok_r1, " ", &strtok_r1) == 0); + + // Test itoa + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing itoa"))); + + char itoa1[33]; + + ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itoa1, 2), + "101010") == 0); + + ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itoa1, 3), + "1120") == 0); + + ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itoa1, 16), + "2a") == 0); + } + +#if defined (ACE_HAS_WCHAR) + { + // ======================================================================== + // Test itoa (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing itoa (wchar_t version)"))); + + wchar_t itow1[33]; + + ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itow1, 2), + ACE_TEXT_WIDE ("101010")) == 0); + + ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itow1, 3), + ACE_TEXT_WIDE ("1120")) == 0); + + ACE_ASSERT (ACE_OS_String::strcmp (ACE_OS_String::itoa (42, itow1, 16), + ACE_TEXT_WIDE ("2a")) == 0); + + + // ======================================================================== + // Test strcmp (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strcmp (wchar_t version)"))); + + const wchar_t strcmp1[] = ACE_TEXT_WIDE ("stringf"); + const wchar_t strcmp2[] = ACE_TEXT_WIDE ("stringfe"); + const wchar_t strcmp3[] = ACE_TEXT_WIDE ("stringg"); + const wchar_t strcmp4[] = ACE_TEXT_WIDE ("STRINGF"); + const wchar_t strcmp5[] = ACE_TEXT_WIDE ("stringe"); + + ACE_ASSERT (ACE_OS_String::strcmp (strcmp1, strcmp1) == 0); + ACE_ASSERT (ACE_OS_String::strcmp (strcmp1, strcmp2) < 0); + ACE_ASSERT (ACE_OS_String::strcmp (strcmp1, strcmp3) < 0); + ACE_ASSERT (ACE_OS_String::strcmp (strcmp1, strcmp4) != 0); + ACE_ASSERT (ACE_OS_String::strcmp (strcmp1, strcmp5) > 0); + + // ======================================================================== + // Test strcpy (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strcpy (wchar_t version)"))); + + const wchar_t strcpy1[] = ACE_TEXT_WIDE ("abcdefghijklmnopqrstuvwxyz"); + wchar_t strcpy2[27]; + + ACE_ASSERT + (ACE_OS_String::strcmp (ACE_OS_String::strcpy (strcpy2, strcpy1), + strcpy1) == 0); + ACE_ASSERT (ACE_OS_String::strcmp (strcpy2, strcpy1) == 0); + + // ======================================================================== + // Test strcat (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strcat (wchar_t version)"))); + + const wchar_t strcat1[] = ACE_TEXT_WIDE ("abcdefghijklmnopqrstuvwxyz"); + wchar_t strcat2[27] = ACE_TEXT_WIDE ("abcdefghijkl"); + const wchar_t strcat3[] = ACE_TEXT_WIDE ("mnopqrstuvwxyz"); + + ACE_ASSERT + (ACE_OS_String::strcmp (ACE_OS_String::strcat (strcat2, strcat3), + strcat1) == 0); + ACE_ASSERT (ACE_OS_String::strcmp (strcat2, strcat1) == 0); + + // ======================================================================== + // Test strncat (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strncat (wchar_t version)"))); + + const wchar_t strncat1[] = ACE_TEXT_WIDE ("abcdefghijklmnopqrstuvwxyz"); + wchar_t strncat2[27] = ACE_TEXT_WIDE ("abcdefghijkl"); + const wchar_t strncat3[] = ACE_TEXT_WIDE ("mnopqrstuvwxyzabc"); + + ACE_ASSERT + (ACE_OS_String::strcmp (ACE_OS_String::strncat (strncat2, strncat3, 14), + strncat1) == 0); + ACE_ASSERT (ACE_OS_String::strcmp (strncat2, strncat1) == 0); + + // ======================================================================== + // Test strspn (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strspn (wchar_t version)"))); + + const wchar_t strspn1[] = ACE_TEXT_WIDE ("abcdefghijkabcdefghijk"); + + ACE_ASSERT (ACE_OS_String::strspn (strspn1, + ACE_TEXT_WIDE ("abcdf")) == 4); + ACE_ASSERT (ACE_OS_String::strspn (strspn1, + ACE_TEXT_WIDE ("mno")) == 0); + + // ======================================================================== + // Test strchr (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strchr (wchar_t version)"))); + + const wchar_t strchr1[] = ACE_TEXT_WIDE ("abcdefghijkabcdefghijk"); + + ACE_ASSERT (*ACE_OS_String::strchr (strchr1, ACE_TEXT_WIDE ('h')) + == ACE_TEXT_WIDE ('h')); + ACE_ASSERT (ACE_OS_String::strchr (strchr1, ACE_TEXT_WIDE ('h')) + == strchr1 + 7); + ACE_ASSERT (ACE_OS_String::strchr (strchr1, ACE_TEXT_WIDE ('1')) == NULL); + + // ======================================================================== + // Test strstr (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strstr (wchar_t version)"))); + + const wchar_t strstr1[] = ACE_TEXT_WIDE ("abcdefghijkabcdefghijk"); + + ACE_ASSERT (ACE_OS_String::strncmp ( + ACE_OS_String::strstr (strstr1, ACE_TEXT_WIDE ("def")), + ACE_TEXT_WIDE ("def"), + 3) + == 0); + ACE_ASSERT (ACE_OS_String::strstr (strstr1, + ACE_TEXT_WIDE ("mno")) == 0); + + // ======================================================================== + // Test strlen (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strlen (wchar_t version)"))); + + const wchar_t strlen1[] = ACE_TEXT_WIDE (""); + const wchar_t strlen2[] = ACE_TEXT_WIDE ("12345"); + + ACE_ASSERT (ACE_OS_String::strlen (strlen1) == 0); + ACE_ASSERT (ACE_OS_String::strlen (strlen2) == 5); + + // ======================================================================== + // Test strpbrk (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strpbrk (wchar_t version)"))); + + const wchar_t strpbrk1[] = ACE_TEXT_WIDE ("abcdefghijkabcdefghijk"); + + ACE_ASSERT (ACE_OS_String::strpbrk (strpbrk1, ACE_TEXT_WIDE ("ijkb")) + == strpbrk1 + 1); + ACE_ASSERT (ACE_OS_String::strpbrk (strpbrk1, + ACE_TEXT_WIDE ("mno")) == 0); + + // ======================================================================== + // Test strrchr (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strrchr (wchar_t version)"))); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strrchr"))); + + const wchar_t strrchr1[] = ACE_TEXT_WIDE ("abcdefghijkabcdefghijk"); + + ACE_ASSERT (*ACE_OS_String::strrchr (strrchr1, ACE_TEXT_WIDE ('h')) + == ACE_TEXT_WIDE ('h')); + ACE_ASSERT (ACE_OS_String::strrchr (strrchr1, ACE_TEXT_WIDE ('h')) + == strrchr1 + 18); + ACE_ASSERT (ACE_OS_String::strrchr (strrchr1, ACE_TEXT_WIDE ('1')) + == NULL); + + // ======================================================================== + // Test strcasecmp (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strcasecmp (wchar_t version)"))); + + const wchar_t strcasecmp1[] = ACE_TEXT_WIDE ("stringf"); + const wchar_t strcasecmp2[] = ACE_TEXT_WIDE ("stringfe"); + const wchar_t strcasecmp3[] = ACE_TEXT_WIDE ("stringg"); + const wchar_t strcasecmp4[] = ACE_TEXT_WIDE ("STRINGF"); + const wchar_t strcasecmp5[] = ACE_TEXT_WIDE ("stringe"); + + ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp1) == 0); + ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp2) < 0); + ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp3) < 0); + ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp4) == 0); + ACE_ASSERT (ACE_OS_String::strcasecmp (strcasecmp1, strcasecmp5) > 0); + + // ======================================================================== + // Test strncasecmp (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strncasecmp (wchar_t version)"))); + + const wchar_t strncasecmp1[] = ACE_TEXT_WIDE ("stringf"); + const wchar_t strncasecmp2[] = ACE_TEXT_WIDE ("stringfe"); + const wchar_t strncasecmp3[] = ACE_TEXT_WIDE ("stringg"); + const wchar_t strncasecmp4[] = ACE_TEXT_WIDE ("STRINGF"); + const wchar_t strncasecmp5[] = ACE_TEXT_WIDE ("stringe"); + + ACE_ASSERT + (ACE_OS_String::strncasecmp (strncasecmp1, strncasecmp2, 7) == 0); + ACE_ASSERT + (ACE_OS_String::strncasecmp (strncasecmp1, strncasecmp2, 8) < 0); + ACE_ASSERT + (ACE_OS_String::strncasecmp (strncasecmp1, strncasecmp3, 7) < 0); + ACE_ASSERT + (ACE_OS_String::strncasecmp (strncasecmp1, strncasecmp4, 7) == 0); + ACE_ASSERT + (ACE_OS_String::strncasecmp (strncasecmp1, strncasecmp5, 7) > 0); + + // ======================================================================== + // Test strncmp (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strncmp (wchar_t version)"))); + + const wchar_t strncmp1[] = ACE_TEXT_WIDE ("stringf"); + const wchar_t strncmp2[] = ACE_TEXT_WIDE ("stringfe"); + const wchar_t strncmp3[] = ACE_TEXT_WIDE ("stringg"); + const wchar_t strncmp4[] = ACE_TEXT_WIDE ("STRINGF"); + const wchar_t strncmp5[] = ACE_TEXT_WIDE ("stringe"); + + ACE_ASSERT (ACE_OS_String::strncmp (strncmp1, strncmp2, 7) == 0); + ACE_ASSERT (ACE_OS_String::strncmp (strncmp1, strncmp2, 8) < 0); + ACE_ASSERT (ACE_OS_String::strncmp (strncmp1, strncmp3, 7) < 0); + ACE_ASSERT (ACE_OS_String::strncmp (strncmp1, strncmp4, 7) != 0); + ACE_ASSERT (ACE_OS_String::strncmp (strncmp1, strncmp5, 7) > 0); + + // ======================================================================== + // Test strncpy (wchar_t version) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strncpy (wchar_t version)"))); + + wchar_t strncpy1[] = ACE_TEXT_WIDE ("abcdefghijklmnopqrstuvwxyzabc"); + wchar_t strncpy2[27]; + + ACE_ASSERT + (ACE_OS_String::strncmp (ACE_OS_String::strncpy (strncpy2, + strncpy1, + 26), + strncpy1, + 26) == 0); + + strncpy1[26] = 0; + strncpy2[26] = 0; + ACE_ASSERT (ACE_OS_String::strcmp (strncpy2, strncpy1) == 0); + + } +#endif /* ACE_HAS_WCHAR */ + + return 0; +} int main (int, ACE_TCHAR *[]) @@ -137,6 +457,9 @@ main (int, ACE_TCHAR *[]) if ((result = rename_test ()) != 0) status = result; + if ((result = string_emulation_test ()) != 0) + status = result; + ACE_END_TEST; return status; } diff --git a/tests/Priority_Buffer_Test.cpp b/tests/Priority_Buffer_Test.cpp index 7f4b6089dbe..8e660e7c4dc 100644 --- a/tests/Priority_Buffer_Test.cpp +++ b/tests/Priority_Buffer_Test.cpp @@ -28,6 +28,8 @@ ACE_RCSID(tests, Priority_Buffer_Test, "$Id$") #if defined (ACE_HAS_THREADS) +static const char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; + // Global message count. static int count = 0; @@ -106,7 +108,7 @@ producer (void *args) ACE_Message_Block *mb; - for (char *c = ACE_ALPHABET; *c != '\0'; c++) + for (const char *c = ACE_ALPHABET; *c != '\0'; c++) { count++; diff --git a/tests/Priority_Reactor_Test.cpp b/tests/Priority_Reactor_Test.cpp index 68fd91ddaa7..64eaaf0c23b 100644 --- a/tests/Priority_Reactor_Test.cpp +++ b/tests/Priority_Reactor_Test.cpp @@ -38,6 +38,8 @@ ACE_RCSID(tests, Priority_Reactor_Test, "$Id$") +static const char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; + // The number of children to run, it can be changed using the -c // option. static int opt_nchildren = diff --git a/tests/Reactor_Performance_Test.cpp b/tests/Reactor_Performance_Test.cpp index b655fd1385b..c3940b71ad6 100644 --- a/tests/Reactor_Performance_Test.cpp +++ b/tests/Reactor_Performance_Test.cpp @@ -35,6 +35,8 @@ ACE_RCSID(tests, Reactor_Performance_Test, "$Id$") #if defined (ACE_HAS_THREADS) +static const char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; + // Number of client (user) threads static int opt_nconnections = 5; diff --git a/tests/SOCK_Test.cpp b/tests/SOCK_Test.cpp index 20dd1b82bc7..2da259365b6 100644 --- a/tests/SOCK_Test.cpp +++ b/tests/SOCK_Test.cpp @@ -30,6 +30,8 @@ ACE_RCSID(tests, SOCK_Test, "$Id$") +static const char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; + static void * client (void *arg) { @@ -66,7 +68,7 @@ client (void *arg) // Send data to server (correctly handles "incomplete writes"). - for (char *c = ACE_ALPHABET; *c != '\0'; c++) + for (const char *c = ACE_ALPHABET; *c != '\0'; c++) if (cli_stream.send_n (c, 1) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"), ACE_TEXT ("send_n"))); @@ -104,7 +106,7 @@ server (void *arg) ACE_Time_Value tv (def_timeout); char buf[BUFSIZ]; - char *t = ACE_ALPHABET; + const char *t = ACE_ALPHABET; handle_set.reset (); handle_set.set_bit (peer_acceptor->get_handle ()); diff --git a/tests/SPIPE_Test.cpp b/tests/SPIPE_Test.cpp index d13e9fcdec8..70d868a1f99 100644 --- a/tests/SPIPE_Test.cpp +++ b/tests/SPIPE_Test.cpp @@ -32,6 +32,9 @@ ACE_RCSID(tests, SPIPE_Test, "$Id$") #if defined (ACE_HAS_STREAM_PIPES) || defined (ACE_WIN32) + +static const char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; + // pipe name to use static const ACE_TCHAR *PIPE_NAME = ACE_TEXT ("ace_pipe_name"); @@ -47,7 +50,7 @@ client (void *) if (con.connect (cli_stream, ACE_SPIPE_Addr (rendezvous)) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), rendezvous)); - for (char *c = ACE_ALPHABET; *c != '\0'; c++) + for (const char *c = ACE_ALPHABET; *c != '\0'; c++) if (cli_stream.send (c, 1) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send_n"))); @@ -66,7 +69,7 @@ server (void *) ACE_SPIPE_Acceptor acceptor; ACE_SPIPE_Stream new_stream; char buf[BUFSIZ]; - char *t = ACE_ALPHABET; + const char *t = ACE_ALPHABET; const ACE_TCHAR *rendezvous = PIPE_NAME; diff --git a/tests/run_test.lst b/tests/run_test.lst index 4771036e9c2..a41c0dcfaa2 100644 --- a/tests/run_test.lst +++ b/tests/run_test.lst @@ -47,6 +47,7 @@ New_Fail_Test: MSVC Notify_Performance_Test Object_Manager_Test OrdMultiSet_Test +OS_Test Pipe_Test: MSVC Priority_Buffer_Test Priority_Reactor_Test diff --git a/tests/test_config.h b/tests/test_config.h index 05c16500b71..2d65f9a28c6 100644 --- a/tests/test_config.h +++ b/tests/test_config.h @@ -78,8 +78,6 @@ const size_t ACE_MAX_ITERATIONS = 10; const size_t ACE_MAX_PROCESSES = 10; const size_t ACE_MAX_THREADS = 4; -char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; - #define ACE_START_TEST(NAME) \ const ACE_TCHAR *program = NAME; \ ACE_LOG_MSG->open (program, ACE_Log_Msg::OSTREAM | ACE_Log_Msg::VERBOSE_LITE); \ |