diff options
-rwxr-xr-x | TAO/orbsvcs/tests/Bug_2248_Regression/Bug_2248_Regression.mpc | 3 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/IOR_MCast/IOR_MCast.mpc | 3 | ||||
-rw-r--r-- | ace/OS_NS_ctype.h | 46 | ||||
-rw-r--r-- | ace/OS_NS_ctype.inl | 112 | ||||
-rw-r--r-- | ace/OS_NS_ctype_T.inl | 165 | ||||
-rw-r--r-- | ace/OS_NS_unistd.cpp | 129 | ||||
-rw-r--r-- | ace/OS_NS_unistd.h | 8 | ||||
-rw-r--r-- | ace/OS_NS_unistd_T.inl | 140 |
8 files changed, 341 insertions, 265 deletions
diff --git a/TAO/orbsvcs/tests/Bug_2248_Regression/Bug_2248_Regression.mpc b/TAO/orbsvcs/tests/Bug_2248_Regression/Bug_2248_Regression.mpc index b3ba87fb27c..7f5ddb09532 100755 --- a/TAO/orbsvcs/tests/Bug_2248_Regression/Bug_2248_Regression.mpc +++ b/TAO/orbsvcs/tests/Bug_2248_Regression/Bug_2248_Regression.mpc @@ -3,6 +3,7 @@ project(*idl): taoidldefaults { idlflags += -Sc + avoids += uses_wchar IDL_Files { test.idl @@ -14,6 +15,7 @@ project(*idl): taoidldefaults { project(*Server): taoserver, orbsvcsexe, iormanip, pi_server, ftorb, messaging, minimum_corba { after += *idl + avoids += uses_wchar Source_Files { test_i.cpp @@ -32,6 +34,7 @@ project(*Server): taoserver, orbsvcsexe, iormanip, pi_server, ftorb, messaging, project(*Client): taoclient, orbsvcsexe, iormanip, pi_server, ftorb, minimum_corba { after += *idl + avoids += uses_wchar Source_Files { testC.cpp diff --git a/TAO/orbsvcs/tests/IOR_MCast/IOR_MCast.mpc b/TAO/orbsvcs/tests/IOR_MCast/IOR_MCast.mpc index 01fcb2cd41a..1cab9bda0ea 100644 --- a/TAO/orbsvcs/tests/IOR_MCast/IOR_MCast.mpc +++ b/TAO/orbsvcs/tests/IOR_MCast/IOR_MCast.mpc @@ -2,6 +2,7 @@ // $Id$ project(*idl): taoidldefaults { + avoids += uses_wchar IDL_Files { MCast.idl } @@ -10,6 +11,7 @@ project(*idl): taoidldefaults { project(*server): namingexe, iortable, svc_utils { exename = server + avoids += uses_wchar after += *idl Source_Files { @@ -25,6 +27,7 @@ project(*server): namingexe, iortable, svc_utils { project(*client): namingexe, iortable, svc_utils { exename = client + avoids += uses_wchar after += *idl Source_Files { diff --git a/ace/OS_NS_ctype.h b/ace/OS_NS_ctype.h index bd0b9edcdf4..d240f620abd 100644 --- a/ace/OS_NS_ctype.h +++ b/ace/OS_NS_ctype.h @@ -47,48 +47,48 @@ namespace ACE_OS { //@{ /// Returns true if the character is an alphanumeric character. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_isalnum (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_isalnum (CHAR_TYPE c); /// Returns true if the character is an alphabetic character. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_isalpha (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_isalpha (CHAR_TYPE c); /// Returns true if the character is a control character. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_iscntrl (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_iscntrl (CHAR_TYPE c); /// Returns true if the character is a decimal-digit character. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_isdigit (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_isdigit (CHAR_TYPE c); /// Returns true if the character is a printable character other than a space. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_isgraph (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_isgraph (CHAR_TYPE c); /// Returns true if the character is a lowercase character. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_islower (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_islower (CHAR_TYPE c); /// Returns true if the character is a printable character. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_isprint (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_isprint (CHAR_TYPE c); /// Returns true if the character is a punctuation character. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_ispunct (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_ispunct (CHAR_TYPE c); /// Returns true if the character is a space character. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_isspace (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_isspace (CHAR_TYPE c); /// Returns true if the character is an uppercase character. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_isupper (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_isupper (CHAR_TYPE c); /// Returns true if the character is a hexadecimal-digit character. - ACE_NAMESPACE_INLINE_FUNCTION - int ace_isxdigit (ACE_TCHAR c); + template <typename CHAR_TYPE> inline + int ace_isxdigit (CHAR_TYPE c); /// Converts a character to lower case (char version). ACE_NAMESPACE_INLINE_FUNCTION @@ -118,5 +118,7 @@ namespace ACE_OS { # include "ace/OS_NS_ctype.inl" # endif /* ACE_HAS_INLINED_OSCALLS */ +#include "ace/OS_NS_ctype_T.inl" + # include /**/ "ace/post.h" #endif /* ACE_OS_NS_CTYPE_H */ diff --git a/ace/OS_NS_ctype.inl b/ace/OS_NS_ctype.inl index e8141bfaa15..e0235d5285d 100644 --- a/ace/OS_NS_ctype.inl +++ b/ace/OS_NS_ctype.inl @@ -2,117 +2,7 @@ // $Id$ #include "ace/os_include/os_ctype.h" -# include "ace/os_include/os_wctype.h" - -ACE_INLINE int -ACE_OS::ace_isalnum (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswalnum (c); -#else /* ACE_USES_WCHAR */ - return isalnum ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::ace_isalpha (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswalpha (c); -#else /* ACE_USES_WCHAR */ - return isalpha ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::ace_iscntrl (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswcntrl (c); -#else /* ACE_USES_WCHAR */ - return iscntrl ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::ace_isdigit (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswdigit (c); -#else /* ACE_USES_WCHAR */ - return isdigit ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::ace_isgraph (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswgraph (c); -#else /* ACE_USES_WCHAR */ - return isgraph ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::ace_islower (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswlower (c); -#else /* ACE_USES_WCHAR */ - return islower ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::ace_isprint (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswprint (c); -#else /* ACE_USES_WCHAR */ - return isprint ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::ace_ispunct (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswpunct (c); -#else /* ACE_USES_WCHAR */ - return ispunct ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::ace_isspace (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswspace (c); -#else /* ACE_USES_WCHAR */ - return isspace ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::ace_isupper (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswupper (c); -#else /* ACE_USES_WCHAR */ - return isupper ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} - -ACE_INLINE int -ACE_OS::ace_isxdigit (ACE_TCHAR c) -{ -#if defined (ACE_USES_WCHAR) - return iswxdigit (c); -#else /* ACE_USES_WCHAR */ - return isxdigit ((unsigned char) c); -#endif /* ACE_USES_WCHAR */ -} +#include "ace/os_include/os_wctype.h" ACE_INLINE int ACE_OS::ace_tolower (int c) diff --git a/ace/OS_NS_ctype_T.inl b/ace/OS_NS_ctype_T.inl new file mode 100644 index 00000000000..097ae85b480 --- /dev/null +++ b/ace/OS_NS_ctype_T.inl @@ -0,0 +1,165 @@ +// -*- C++ -*- +// $Id$ + +#include "ace/os_include/os_ctype.h" +#include "ace/os_include/os_wctype.h" + +// For the time being we are safe lumping the wchar specializations +// with ACE_USES_WCHAR. When the time comes that they are needed +// outside of a "wide" build, then we will need to us appropriate +// ACE_LACKS_XXXX. + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_isalnum (CHAR_TYPE c) +{ + return isalnum (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_isalnum (wchar_t c) +{ + return iswalnum (c); +} +#endif /* ACE_USES_WCHAR */ + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_isalpha (CHAR_TYPE c) +{ + return isalpha (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_isalpha (wchar_t c) +{ + return iswalpha (c); +} +#endif /* ACE_USES_WCHAR */ + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_iscntrl (CHAR_TYPE c) +{ + return iscntrl (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_iscntrl (wchar_t c) +{ + return iswcntrl (c); +} +#endif /* ACE_USES_WCHAR */ + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_isdigit (CHAR_TYPE c) +{ + return isdigit (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_isdigit (wchar_t c) +{ + return iswdigit (c); +} +#endif /* ACE_USES_WCHAR */ + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_isgraph (CHAR_TYPE c) +{ + return isgraph (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_isgraph (wchar_t c) +{ + return iswgraph (c); +} +#endif /* ACE_USES_WCHAR */ + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_islower (CHAR_TYPE c) +{ + return islower (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_islower (wchar_t c) +{ + return iswlower (c); +} +#endif /* ACE_USES_WCHAR */ + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_isprint (CHAR_TYPE c) +{ + return isprint (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_isprint (wchar_t c) +{ + return iswprint (c); +} +#endif /* ACE_USES_WCHAR */ + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_ispunct (CHAR_TYPE c) +{ + return ispunct (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_ispunct (wchar_t c) +{ + return iswpunct (c); +} +#endif /* ACE_USES_WCHAR */ + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_isspace (CHAR_TYPE c) +{ + return isspace (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_isspace (wchar_t c) +{ + return iswspace (c); +} +#endif /* ACE_USES_WCHAR */ + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_isupper (CHAR_TYPE c) +{ + return isupper (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_isupper (wchar_t c) +{ + return iswupper (c); +} +#endif /* ACE_USES_WCHAR */ + +template <typename CHAR_TYPE> inline int +ACE_OS::ace_isxdigit (CHAR_TYPE c) +{ + return isxdigit (static_cast<unsigned char> (c)); +} + +#if defined (ACE_USES_WCHAR) +template <> inline int +ACE_OS::ace_isxdigit (wchar_t c) +{ + return iswxdigit (c); +} +#endif /* ACE_USES_WCHAR */ + diff --git a/ace/OS_NS_unistd.cpp b/ace/OS_NS_unistd.cpp index 4233b19afce..5bddc627589 100644 --- a/ace/OS_NS_unistd.cpp +++ b/ace/OS_NS_unistd.cpp @@ -619,135 +619,6 @@ ACE_OS::pwrite (ACE_HANDLE handle, # endif /* ACE_HAD_P_READ_WRITE */ } -int -ACE_OS::string_to_argv (ACE_TCHAR *buf, - int &argc, - ACE_TCHAR **&argv, - int substitute_env_args) -{ - // Reset the number of arguments - argc = 0; - - if (buf == 0) - return -1; - - ACE_TCHAR *cp = buf; - - // First pass: count arguments. - - // '#' is the start-comment token.. - while (*cp != ACE_LIB_TEXT ('\0') && *cp != ACE_LIB_TEXT ('#')) - { - // Skip whitespace.. - while (ACE_OS::ace_isspace (*cp)) - cp++; - - // Increment count and move to next whitespace.. - if (*cp != ACE_LIB_TEXT ('\0')) - argc++; - - while (*cp != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*cp)) - { - // Grok quotes.... - if (*cp == ACE_LIB_TEXT ('\'') || *cp == ACE_LIB_TEXT ('"')) - { - ACE_TCHAR quote = *cp; - - // Scan past the string.. - for (cp++; *cp != ACE_LIB_TEXT ('\0') && *cp != quote; cp++) - continue; - - // '\0' implies unmatched quote.. - if (*cp == ACE_LIB_TEXT ('\0')) - { - argc--; - break; - } - else - cp++; - } - else - cp++; - } - } - - // Second pass: copy arguments. - ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ]; - ACE_TCHAR *argp = arg; - - // Make sure that the buffer we're copying into is always large - // enough. - if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ) - ACE_NEW_RETURN (argp, - ACE_TCHAR[cp - buf + 1], - -1); - - // Make a new argv vector of argc + 1 elements. - ACE_NEW_RETURN (argv, - ACE_TCHAR *[argc + 1], - -1); - - ACE_TCHAR *ptr = buf; - - for (int i = 0; i < argc; i++) - { - // Skip whitespace.. - while (ACE_OS::ace_isspace (*ptr)) - ptr++; - - // Copy next argument and move to next whitespace.. - cp = argp; - while (*ptr != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr)) - if (*ptr == ACE_LIB_TEXT ('\'') || *ptr == ACE_LIB_TEXT ('"')) - { - ACE_TCHAR quote = *ptr++; - - while (*ptr != ACE_LIB_TEXT ('\0') && *ptr != quote) - *cp++ = *ptr++; - - if (*ptr == quote) - ptr++; - } - else - *cp++ = *ptr++; - - *cp = ACE_LIB_TEXT ('\0'); - -#if !defined (ACE_LACKS_ENV) - // Check for environment variable substitution here. - if (substitute_env_args) { - argv[i] = ACE_OS::strenvdup(argp); - - if (argv[i] == 0) - { - if (argp != arg) - delete [] argp; - errno = ENOMEM; - return -1; - } - } - else -#endif /* ACE_LACKS_ENV */ - { - argv[i] = ACE_OS::strdup(argp); - - if (argv[i] == 0) - { - if (argp != arg) - delete [] argp; - errno = ENOMEM; - return -1; - } - } - } - - if (argp != arg) - delete [] argp; - - argv[argc] = 0; - return 0; -} - // Write <len> bytes from <buf> to <handle> (uses the <write> // system call on UNIX and the <WriteFile> call on Win32). diff --git a/ace/OS_NS_unistd.h b/ace/OS_NS_unistd.h index 72e83d978bc..1e4d5cb16eb 100644 --- a/ace/OS_NS_unistd.h +++ b/ace/OS_NS_unistd.h @@ -269,10 +269,10 @@ namespace ACE_OS { int sleep (const ACE_Time_Value &tv); // used by ARGV::string_to_argv - extern ACE_Export - int string_to_argv (ACE_TCHAR *buf, + template <typename CHAR_TYPE> + int string_to_argv (CHAR_TYPE *buf, int &argc, - ACE_TCHAR **&argv, + CHAR_TYPE **&argv, int substitute_env_args = 1); ACE_NAMESPACE_INLINE_FUNCTION @@ -338,5 +338,7 @@ namespace ACE_OS { # include "ace/OS_NS_unistd.inl" # endif /* ACE_HAS_INLINED_OSCALLS */ +#include "ace/OS_NS_unistd_T.inl" + # include /**/ "ace/post.h" #endif /* ACE_OS_NS_UNISTD_H */ diff --git a/ace/OS_NS_unistd_T.inl b/ace/OS_NS_unistd_T.inl new file mode 100644 index 00000000000..b56eb16a3c4 --- /dev/null +++ b/ace/OS_NS_unistd_T.inl @@ -0,0 +1,140 @@ +// -*- C++ -*- +// +// $Id$ + +#include "ace/OS_NS_ctype.h" +#include "ace/Default_Constants.h" +#include "ace/os_include/os_errno.h" +#include "ace/OS_Memory.h" + +template <typename CHAR_TYPE> int +ACE_OS::string_to_argv (CHAR_TYPE *buf, + int &argc, + CHAR_TYPE **&argv, + int substitute_env_args) +{ + // Reset the number of arguments + argc = 0; + + if (buf == 0) + return -1; + + CHAR_TYPE *cp = buf; + + // First pass: count arguments. + + // '#' is the start-comment token.. + while (*cp != CHAR_TYPE ('\0') && *cp != CHAR_TYPE ('#')) + { + // Skip whitespace.. + while (ACE_OS::ace_isspace (*cp)) + cp++; + + // Increment count and move to next whitespace.. + if (*cp != CHAR_TYPE ('\0')) + argc++; + + while (*cp != CHAR_TYPE ('\0') && !ACE_OS::ace_isspace (*cp)) + { + // Grok quotes.... + if (*cp == CHAR_TYPE ('\'') || *cp == CHAR_TYPE ('"')) + { + CHAR_TYPE quote = *cp; + + // Scan past the string.. + for (cp++; *cp != CHAR_TYPE ('\0') && *cp != quote; cp++) + continue; + + // '\0' implies unmatched quote.. + if (*cp == CHAR_TYPE ('\0')) + { + argc--; + break; + } + else + cp++; + } + else + cp++; + } + } + + // Second pass: copy arguments. + CHAR_TYPE arg[ACE_DEFAULT_ARGV_BUFSIZ]; + CHAR_TYPE *argp = arg; + + // Make sure that the buffer we're copying into is always large + // enough. + if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ) + ACE_NEW_RETURN (argp, + CHAR_TYPE[cp - buf + 1], + -1); + + // Make a new argv vector of argc + 1 elements. + ACE_NEW_RETURN (argv, + CHAR_TYPE *[argc + 1], + -1); + + CHAR_TYPE *ptr = buf; + + for (int i = 0; i < argc; i++) + { + // Skip whitespace.. + while (ACE_OS::ace_isspace (*ptr)) + ptr++; + + // Copy next argument and move to next whitespace.. + cp = argp; + while (*ptr != CHAR_TYPE ('\0') && !ACE_OS::ace_isspace (*ptr)) + if (*ptr == CHAR_TYPE ('\'') || *ptr == CHAR_TYPE ('"')) + { + CHAR_TYPE quote = *ptr++; + + while (*ptr != CHAR_TYPE ('\0') && *ptr != quote) + *cp++ = *ptr++; + + if (*ptr == quote) + ptr++; + } + else + *cp++ = *ptr++; + + *cp = CHAR_TYPE ('\0'); + +#if !defined (ACE_LACKS_ENV) + // Check for environment variable substitution here. + if (substitute_env_args) + { + ACE_TCHAR* dup = ACE_OS::strenvdup(ACE_TEXT_TO_TCHAR_IN(argp)); + argv[i] = ACE::String_Conversion::Convert_Out< CHAR_TYPE >(dup).c_str(); + delete[] dup; + + if (argv[i] == 0) + { + if (argp != arg) + delete [] argp; + errno = ENOMEM; + return -1; + } + } + else +#endif /* ACE_LACKS_ENV */ + { + argv[i] = ACE_OS::strdup(argp); + + if (argv[i] == 0) + { + if (argp != arg) + delete [] argp; + errno = ENOMEM; + return -1; + } + } + } + + if (argp != arg) + delete [] argp; + + argv[argc] = 0; + return 0; +} |