diff options
64 files changed, 924 insertions, 291 deletions
diff --git a/ChangeLog b/ChangeLog index 8dcac8e53d9..e51a60e78ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,211 @@ +Tue Aug 24 14:07:22 2004 Steve Huston <shuston@riverace.com> + + Changes to improve the functionality of wide-char operation on + non-Windows platforms: + + * ace/ace_wchar.h: If ACE_HAS_XPG4_MULTIBYTE_CHAR is defined, but not + ACE_HAS_WCHAR, set ACE_HAS_WCHAR. + + * ace/ACE.cpp (timestamp): Use ACE_TCHAR for temp char arrays, + not char. If ACE_USES_WCHAR on non-Windows, use %ls for printf + strings, not %s. + + * ace/ARGV.cpp (constructor): Replaced most of the body with a call + to ACE_OS::argv_to_string(). + + * ace/Basic_Types.h: + * ace/Cleanup.h: + * ace/Object_Manager_Base.h: + * ace/OS_NS_string.h: + * ace/os_include/os_float.h: + * ace/os_include/os_inttypes.h: + * ace/os_include/os_limits.h: + * ace/os_include/os_signal.h: + * ace/os_include/os_stdint.h: + * ace/os_include/os_stdlib.h: + * ace/os_include/os_time.h: + * ace/os_include/os_ucontext.h: + * ace/os_include/os_unistd.h: + * ace/os_include/sys/os_ipc.h: + * ace/os_include/sys/os_mman.h: + * ace/os_include/sys/os_msg.h: + * ace/os_include/sys/os_resource.h: + * ace/os_include/sys/os_select.h: + * ace/os_include/sys/os_sem.h: + * ace/os_include/sys/os_shm.h: + * ace/os_include/sys/os_socket.h: + * ace/os_include/sys/os_stat.h: + * ace/os_include/sys/os_statvfs.h: + * ace/os_include/sys/os_timeb.h: + * ace/os_include/sys/os_time.h: + * ace/os_include/sys/os_times.h: + * ace/os_include/sys/os_types.h: + * ace/os_include/sys/os_uio.h: + * ace/os_include/sys/os_un.h: + * ace/os_include/sys/os_utsname.h: + * ace/os_include/sys/os_wait.h: #include "config-lite.h" rather than + "config-all.h". Only need the user config.h and "lite" things. + Including config-all.h introduces a circular include + dependency from OS_main.h. + + * ace/Default_Constants.h: Add ACE_LIB_TEXT() to ACE_DEFAULT_SVC_CONF + strings. + + * ace/Env_Value_T.i (fetch_value): For non-Win32, force the env var + name to narrow-char then convert the result back to ACE_TCHAR. + + * ace/FILE_Connector.cpp (connect): When generating a temp name, + convert it to ACE_TCHAR for ACE_FILE_Addr. + + * ace/Get_Opt.cpp (constructor): When checking for POSIXLY_CORRECT, + must always use char *, not ACE_TCHAR*, on non-Win32. + + * ace/High_Res_Timer.cpp: Added ACE_LIB_TEXT to naked string literals. + Use 'char' when it must be narrow char; ACE_TCHAR when it has to + change based on ACE_USES_WCHAR. + + * ace/Lib_Find.cpp (ldfind, get_temp_dir): Environment variables on + non-Windows are always narrow char, so account for that. + + * ace/Log_Msg_UNIX_Syslog.cpp: Operate internally with all narrow + chars because the underlying OS APIs are only narrow char. + + * ace/Log_Msg.cpp (log): For 'D', 'M', 'm', 'N', and 'p', use the + proper 's' format code for the platform/char width. Similar to + Log_Record.cpp below. + + * ace/Log_Msg.h (ACE_ASSERT): Convert __FILE__ name to proper char + width when necessary. + + * ace/Log_Record.cpp: When formatting log strings, have to change + printf formats if using wide chars on non-Windows. Wide-char + strings are printed with %ls, whereas Windows uses %s for + wide-char strings if the format is wide-char. + + * ace/Memory_Pool.cpp (ctor): Change backing_store_name to narrow + char when needed to pass it to sscanf(). + + * ace/Object_Manager_Base.cpp (print_error_message): Add + ACE_TEXT_ALWAYS_CHAR to the message arg to convert on wide-char + builds. + + * ace/OS_main.h: For ACE_MAIN on non-Windows ACE_USES_WCHAR platforms, + convert the argv to wchar_t, and pass the wide-char strings to the + ACE_TCHAR[]-expecting real main program. + + * ace/OS_NS_dirent.inl (opendir): Moved the const_cast-needing + VxWorks part to its own #elif section. Added ACE_TEXT_ALWAYS_CHAR + to the other invocation of ::opendir(). + + * ace/OS_NS_dlfcn.inl (dlerror, dlopen, dlsym): Corrected use of + narrow/wide-char. + + * ace/OS_NS_stdio.inl (cuserid, fdopen, freopen): Don't use + ACE_TCHAR when a char is always needed. + (fgets, fputs, perror, puts): Changed to have both narrow- and + wide-char variants. + (checkUnicodeFormat): Use a platform-neutral 2-byte type to + read 2 bytes. Need a non-Windows 'whence' arg for fseek(). + (vsprintf (wchar_t)): Added the non-Windows, XPG5 code for this to + use the XPG5 vswprintf() when equippped. + + * ace/OS_NS_stdlib.{h inl cpp}: + (ACE_OS::mktemp() and mkstemp()): Changed to have both narrow- + and wide-char variants for the !ACE_LACKS_MKTEMP case. + Offering both for the ACE_LACKS_MKTEMP case is a low-return + use of time since the wide-char variant will probably never be used. + (strenvdup): Handle ACE_USES_WCHAR on non-Windows by converting + back and forth to narrow-char. + (system): On non-Windows, convert command line string to narrow-char. + (getcwd): Changed to have both narrow- and wide-char variants. + + * ace/OS_NS_sys_stat.inl (creat, mkfifo): For non-Windows, convert + name to narrow-char when needed. + (lstat): Change from a single ACE_TCHAR-based interface to both + char* and wchar_t*. + + * ace/OS_NS_time.inl (ctime, ctime_r): Corrected narrow/wide char + usage. + + * ace/OS_NS_unistd.inl (truncate): For non-Windows, convert the path + to narrow-char when needed. + (realpath): Changed to have both narrow- and wide-char variants. + + * ace/OS_NS_unistd.{h inl cpp}: + (rmdir): Changed to have both narrow- and wide-char variants. + (argv_to_string): Handle narrow and wide-char environment variables. + (fork_exec): Convert path and argv to narrow-char when needed. + + * ace/Process.cpp (spawn): Convert argv, procname, env vars to narrow + char for non-Windows wide-char builds. + + * ace/Process.i (setreugid): Convert user name to narrow char for + getpwnam(). + + * ace/Process_Mutex.cpp (ctor): Don't convert name to ACE_TCHAR for + ACE_SV_Semaphore case - it requires char*. + + * ace/Process_Semaphore.cpp (ctor): Convert name to narrow char + for ACE_SV_Semaphore_Complex case. + + * ace/Sock_Connect.cpp (get_bcast_addr): + * ace/SOCK_Dgram_Bcast.cpp (mk_broadcast): Host name needs to be + converted to narrow-char for wide-char builds. + + * ace/SOCK_Dgram_Mcast.cpp (make_multicast_ifaddr): Interface name + needs to be converted to narrow-char for wide-char builds. + + * ace/SV_Semaphore_Simple.{h,i,cpp}: Added wide-char versions of + the named constructor and open() methods. They forward to the + narrow-char versions. + + * tests/Dirent_Test.cpp: Account for dirent's d_name is an ACE_TCHAR + when ACE_LACKS_STRUCT_DIR and a char* otherwise. + + * tests/FIFO_Test.cpp: Change ACE_ALPHABET to char[]. + + * tests/Proactor_Test.cpp: Change complete_message from ACE_TCHAR + to char. This is easier to handle; as ACE_TCHAR, we'd need to + correct all the message block pointer adjustments to take the + charset width into account. + + * tests/Log_Msg_Test.cpp: + * tests/MEM_Stream_Test.cpp: + * tests/Message_Queue_Test.cpp: + * tests/Pipe_Test.cpp: + * tests/Process_Manager_Test.cpp: + * tests/Process_Mutex_Test.cpp: + * tests/Process_Strategy_Test.cpp: + * tests/Signal_Test.cpp: + * tests/SOCK_Connector_Test.cpp: + * tests/SOCK_Dgram_Test.cpp: + * tests/SOCK_Send_Recv_Test.cpp: + * tests/SOCK_Test.cpp: + * tests/SV_Shared_Memory_Test.cpp: Char width correction. + + * tests/Service_Config_Test.cpp: + * tests/Service_Config_Test.WCHAR_T.conf: + * tests/Service_Config_Test.WCHAR_T.conf.xml: Added WCHAR_T-coded + versions of the test input file and changed the test to use + them on non-Windows ACE_USES_WCHAR builds. + + * tests/Test_Output.cpp (set_output): Handle env var and filepath + building correctly even on wide-char non-Windows builds. + + * ACEXML/common/XML_Types.h: typedef ACEXML_Char as ACE_TCHAR, else + it doesn't match any char interfaces when wchar_t is not 2 bytes. + + * ACEXML/parser/parser/Parser.cpp (parse_char_reference): Add the + case where wide-char is 4 bytes. + + Also brought in this fix: + Mon Mar 8 15:52:33 2004 Steve Huston <shuston@riverace.com> + + * ace/POSIX_Proactor.cpp: Comment out the signal setup; this should + not be necessary and, indeed, is erroneous, at least on Linux. + It's commented out instead of removed in case further testing on + other platforms determines that it is needed sometimes. + Tue Aug 24 10:22:18 2004 Steve Huston <shuston@riverace.com> * ace/config-linux-common.h: Added ACE_HAS_SCANDIR and a new diff --git a/ace/ACE.cpp b/ace/ACE.cpp index a24394283e3..a943b41f50b 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -2698,16 +2698,20 @@ ACE::timestamp (ACE_TCHAR date_and_time[], ACE_OS::strsncpy (date_and_time, timebuf, date_and_timelen); - char yeartmp[5]; + ACE_TCHAR yeartmp[5]; ACE_OS::strsncpy (yeartmp, &date_and_time[20], 5); - char timetmp[9]; + ACE_TCHAR timetmp[9]; ACE_OS::strsncpy (timetmp, &date_and_time[11], 9); ACE_OS::sprintf (&date_and_time[11], - "%s %s.%06ld", +# if defined (ACE_USES_WCHAR) + ACE_LIB_TEXT ("%ls %ls.%06ld"), +# else + ACE_LIB_TEXT ("%s %s.%06ld"), +# endif /* ACE_USES_WCHAR */ yeartmp, timetmp, cur_time.usec ()); diff --git a/ace/ARGV.cpp b/ace/ARGV.cpp index 16f8ee14dc2..7e7b323fbdc 100644 --- a/ace/ARGV.cpp +++ b/ace/ARGV.cpp @@ -105,61 +105,7 @@ ACE_ARGV::ACE_ARGV (ACE_TCHAR *argv[], if (argv == 0 || argv[0] == 0) return; - size_t buf_len = 0; - - // Determine the length of the buffer. - - for (int i = 0; argv[i] != 0; i++) - { -#if !defined (ACE_LACKS_ENV) - ACE_TCHAR *temp = 0; - - // Account for environment variables. - if (this->substitute_env_args_ - && (argv[i][0] == '$' - && (temp = ACE_OS::getenv (&argv[i][1])) != 0)) - buf_len += ACE_OS::strlen (temp); - else -#endif /* !ACE_LACKS_ENV */ - buf_len += ACE_OS::strlen (argv[i]); - - // Add one for the extra space between each string. - buf_len++; - } - - // Step through all argv params and copy each one into buf; separate - // each param with white space. - - ACE_NEW (this->buf_, - ACE_TCHAR[buf_len + 1]); - - ACE_TCHAR *end = this->buf_; - int j; - - for (j = 0; argv[j] != 0; j++) - { -#if !defined (ACE_LACKS_ENV) - ACE_TCHAR *temp = 0; - - // Account for environment variables. - if (this->substitute_env_args_ - && (argv[j][0] == '$' - && (temp = ACE_OS::getenv (&argv[j][1])) != 0)) - end = ACE_OS::strecpy (end, temp); - else -#endif /* ACE_LACKS_ENV */ - end = ACE_OS::strecpy (end, argv[j]); - - // Replace the null char that strecpy copies with white space as - // a separator. - *(end - 1) = ACE_LIB_TEXT (' '); - } - - // Remember how many arguments there are - this->argc_ = j; - - // Null terminate the string. - *end = '\0'; + this->argc_ = ACE_OS::argv_to_string (argv, this->buf_, substitute_env_args); } ACE_ARGV::ACE_ARGV (ACE_TCHAR *first_argv[], @@ -182,10 +128,10 @@ ACE_ARGV::ACE_ARGV (ACE_TCHAR *first_argv[], ACE_TCHAR *second_buf; // convert the first argv to a string - first_argc = this->argv_to_string (first_argv,first_buf); + first_argc = this->argv_to_string (first_argv, first_buf); // convert the second argv to a string - second_argc = this->argv_to_string (second_argv,second_buf); + second_argc = this->argv_to_string (second_argv, second_buf); // Add the number of arguments in both the argvs. this->argc_ = first_argc + second_argc; diff --git a/ace/Basic_Types.h b/ace/Basic_Types.h index 21922c008af..7853632c553 100644 --- a/ace/Basic_Types.h +++ b/ace/Basic_Types.h @@ -41,7 +41,7 @@ */ //============================================================================= -#include "ace/config-all.h" +#include "ace/config-lite.h" #ifndef ACE_BASIC_TYPES_H # define ACE_BASIC_TYPES_H diff --git a/ace/Cleanup.h b/ace/Cleanup.h index 117c65f60e3..4cf7629ac4a 100644 --- a/ace/Cleanup.h +++ b/ace/Cleanup.h @@ -19,7 +19,7 @@ # include /**/ "ace/pre.h" -# include "ace/config-all.h" +# include "ace/config-lite.h" # if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Default_Constants.h b/ace/Default_Constants.h index f1d99a59b9b..b483d4152c2 100644 --- a/ace/Default_Constants.h +++ b/ace/Default_Constants.h @@ -500,9 +500,9 @@ const unsigned int ACE_CONNECTOR_HANDLER_MAP_SIZE = 16; // Used for dynamic linking. #if !defined (ACE_DEFAULT_SVC_CONF) # if (ACE_USES_CLASSIC_SVC_CONF == 1) -# define ACE_DEFAULT_SVC_CONF "./svc.conf" +# define ACE_DEFAULT_SVC_CONF ACE_LIB_TEXT ("./svc.conf") # else -# define ACE_DEFAULT_SVC_CONF "./svc.conf.xml" +# define ACE_DEFAULT_SVC_CONF ACE_LIB_TEXT ("./svc.conf.xml") # endif /* ACE_USES_CLASSIC_SVC_CONF ==1 */ #endif /* ACE_DEFAULT_SVC_CONF */ diff --git a/ace/Env_Value_T.inl b/ace/Env_Value_T.inl index 9f98f0fdb45..2a58036c2f3 100644 --- a/ace/Env_Value_T.inl +++ b/ace/Env_Value_T.inl @@ -33,10 +33,15 @@ ACE_Env_Value<T>::open (const ACE_TCHAR *varname, template <class T> ACE_INLINE void ACE_Env_Value<T>::fetch_value (void) { - const ACE_TCHAR *env = ACE_OS::getenv (varname_); - +#if defined (ACE_WIN32) + const ACE_TCHAR *env = ACE_OS::getenv (this->varname_); if (env != 0) ACE_Convert (env, value_); +#else + char *nenv = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (this->varname_)); + if (nenv != 0) + ACE_Convert (ACE_TEXT_CHAR_TO_TCHAR (nenv), value_); +#endif } template <class T> ACE_INLINE const ACE_TCHAR* diff --git a/ace/FILE_Connector.cpp b/ace/FILE_Connector.cpp index 6f1240e7178..446be74fdf5 100644 --- a/ace/FILE_Connector.cpp +++ b/ace/FILE_Connector.cpp @@ -65,7 +65,7 @@ ACE_FILE_Connector::connect (ACE_FILE_IO &new_io, handle = ACE_OS::mkstemp (filename); // mkstemp() replaces "XXXXXX" if (handle == ACE_INVALID_HANDLE - || new_io.addr_.set (filename) != 0) + || new_io.addr_.set (ACE_TEXT_CHAR_TO_TCHAR (filename)) != 0) return -1; new_io.set_handle (handle); diff --git a/ace/Get_Opt.cpp b/ace/Get_Opt.cpp index e95ef4701ad..3492b31c263 100644 --- a/ace/Get_Opt.cpp +++ b/ace/Get_Opt.cpp @@ -118,7 +118,13 @@ ACE_Get_Opt::ACE_Get_Opt (int argc, ACE_NEW (this->last_option_, ACE_TString (ACE_LIB_TEXT (""))); // First check to see if POSIXLY_CORRECT was set. - if (ACE_OS::getenv (ACE_LIB_TEXT ("POSIXLY_CORRECT")) != 0) + // Win32 is the only platform capable of wide-char env var. +#if defined (ACE_WIN32) + const ACE_TCHAR *env_check = ACE_LIB_TEXT ("POSIXLY_CORRECT"); +#else + const char *env_check = "POSIXLY_CORRECT"; +#endif + if (ACE_OS::getenv (env_check) != 0) this->ordering_ = REQUIRE_ORDER; // Now, check to see if any or the following were passed at diff --git a/ace/High_Res_Timer.cpp b/ace/High_Res_Timer.cpp index 57ece6e2f05..c2d69bbbc52 100644 --- a/ace/High_Res_Timer.cpp +++ b/ace/High_Res_Timer.cpp @@ -75,11 +75,12 @@ ACE_High_Res_Timer::get_cpuinfo (void) int supported = 0; #endif /* __alpha__ */ - FILE *cpuinfo = ACE_OS::fopen ("/proc/cpuinfo", "r"); + FILE *cpuinfo = ACE_OS::fopen (ACE_LIB_TEXT ("/proc/cpuinfo"), + ACE_LIB_TEXT ("r")); if (cpuinfo != 0) { - ACE_TCHAR buf[128]; + char buf[128]; // ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nReading /proc/cpuinfo..."))); @@ -103,7 +104,7 @@ ACE_High_Res_Timer::get_cpuinfo (void) #else double mhertz = 1; double bmips = 1; - ACE_TCHAR arg[128]; + char arg[128]; // CPU type? if (::sscanf (buf, "cpu : %s\n", arg) == 1) @@ -513,7 +514,7 @@ ACE_High_Res_Timer::get_env_global_scale_factor (const ACE_TCHAR *env) #if !defined (ACE_HAS_WINCE) if (env != 0) { - const ACE_TCHAR *env_value = ACE_OS::getenv (env); + const char *env_value = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (env)); if (env_value != 0) { int value = ACE_OS::atoi (env_value); diff --git a/ace/Lib_Find.cpp b/ace/Lib_Find.cpp index 429d9a4784b..2a78e8cc94c 100644 --- a/ace/Lib_Find.cpp +++ b/ace/Lib_Find.cpp @@ -309,12 +309,20 @@ ACE::ldfind (const ACE_TCHAR* filename, else if (pathlen > 0) return 0; #else - ACE_TCHAR *ld_path = -#if defined ACE_DEFAULT_LD_SEARCH_PATH - ACE_DEFAULT_LD_SEARCH_PATH; -#else - ACE_OS::getenv (ACE_LD_SEARCH_PATH); -#endif /* ACE_DEFAULT_LD_SEARCH_PATH */ + ACE_TCHAR *ld_path; +# if defined ACE_DEFAULT_LD_SEARCH_PATH + ld_path = ACE_DEFAULT_LD_SEARCH_PATH; +# else +# if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) + ld_path = ACE_OS::getenv (ACE_LD_SEARCH_PATH); +# else + // Wide-char, non-Windows only offers char * getenv. So capture + // it, translate to wide-char, and continue. + ACE_Ascii_To_Wide wide_ldpath + (ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (ACE_LD_SEARCH_PATH))); + ld_path = wide_ldpath.wchar_rep (); +# endif /* ACE_WIN32 || !ACE_USES_WCHAR */ +# endif /* ACE_DEFAULT_LD_SEARCH_PATH */ #if defined (ACE_HAS_WINCE) ACE_TCHAR *ld_path_temp = 0; @@ -532,12 +540,16 @@ ACE::get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len) #else /* ACE_WIN32 */ + // NOTE! Non-Windows platforms don't deal with wide chars for env. + // variables, so do this narrow-char and convert to wide for the + // caller if necessary. + // On non-win32 platforms, check to see what the TMPDIR environment // variable is defined to be. If it doesn't exist, just use /tmp - const ACE_TCHAR *tmpdir = ACE_OS::getenv (ACE_LIB_TEXT ("TMPDIR")); + const char *tmpdir = ACE_OS::getenv ("TMPDIR"); if (tmpdir == 0) - tmpdir = ACE_LIB_TEXT ("/tmp"); + tmpdir = "/tmp"; size_t len = ACE_OS::strlen (tmpdir); @@ -549,11 +561,11 @@ ACE::get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len) } else { - ACE_OS::strcpy (buffer, tmpdir); + ACE_OS::strcpy (buffer, ACE_TEXT_CHAR_TO_TCHAR (tmpdir)); // Add a trailing slash because we cannot assume there is already one // at the end. And having an extra one should not cause problems. - buffer[len] = '/'; + buffer[len] = ACE_LIB_TEXT ('/'); buffer[len + 1] = 0; result = 0; } diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp index 23bd504a178..9094c1bbe54 100644 --- a/ace/Log_Msg.cpp +++ b/ace/Log_Msg.cpp @@ -1174,8 +1174,11 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, break; case 'N': // Source file name - // @@ UNICODE +#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls")); +#else ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s")); +#endif if (can_check) this_len = ACE_OS::snprintf (bp, bspace, format, this->file () ? @@ -1190,8 +1193,11 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, break; case 'n': // Program name - // @@ UNICODE +#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls")); +#else /* ACE_WIN32 && ACE_USES_WCHAR */ ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s")); +#endif if (can_check) this_len = ACE_OS::snprintf (bp, bspace, format, ACE_Log_Msg::program_name_ ? @@ -1228,7 +1234,11 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, # endif /* !__GLIBC__ */ ) { +# if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls: %ls")); +# else ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s: %s")); +# endif if (can_check) this_len = ACE_OS::snprintf (bp, bspace, format, va_arg (argp, ACE_TCHAR *), @@ -1321,7 +1331,11 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, } case 'M': // Print the name of the priority of the message. +#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls")); +#else ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s")); +#endif if (can_check) this_len = ACE_OS::snprintf (bp, bspace, format, @@ -1344,7 +1358,11 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, # endif /* !__GLIBC__ */ ) { +#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls")); +#else /* ACE_WIN32 && ACE_USES_WCHAR */ ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s")); +#endif if (can_check) this_len = ACE_OS::snprintf (bp, bspace, format, @@ -1543,7 +1561,11 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, ACE_TCHAR day_and_time[35]; ACE::timestamp (day_and_time, sizeof day_and_time); +#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OS::strcpy (fp, ACE_LIB_TEXT ("ls")); +#else ACE_OS::strcpy (fp, ACE_LIB_TEXT ("s")); +#endif if (can_check) this_len = ACE_OS::snprintf (bp, bspace, format, day_and_time); @@ -2221,11 +2243,11 @@ ACE_Log_Msg::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("status_ = %d\n"), this->status_)); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nerrnum_ = %d\n"), this->errnum_)); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nlinenum_ = %d\n"), this->linenum_)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nfile_ = %s\n"), this->file_)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nfile_ = %C\n"), this->file_)); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmsg_ = %s\n"), this->msg_)); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nrestart_ = %d\n"), this->restart_)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nostream_ = %x\n"), this->ostream_)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmsg_callback_ = %x\n"), + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nostream_ = %@\n"), this->ostream_)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nmsg_callback_ = %@\n"), this->msg_callback_)); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nprogram_name_ = %s\n"), this->program_name_ ? this->program_name_ @@ -2234,14 +2256,14 @@ ACE_Log_Msg::dump (void) const this->local_host_ ? this->local_host_ : ACE_LIB_TEXT ("<unknown>"))); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\npid_ = %d\n"), this->getpid ())); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nflags_ = %x\n"), this->flags_)); + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nflags_ = 0x%x\n"), this->flags_)); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntrace_depth_ = %d\n"), this->trace_depth_)); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntrace_active_ = %d\n"), this->trace_active_)); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntracing_enabled_ = %d\n"), this->tracing_enabled_)); - ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\npriority_mask_ = %x\n"), + ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\npriority_mask_ = 0x%x\n"), this->priority_mask_)); if (this->thr_desc_ != 0 && this->thr_desc_->state () != 0) ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nthr_state_ = %d\n"), diff --git a/ace/Log_Msg.h b/ace/Log_Msg.h index 258612c27fc..567af30fa9e 100644 --- a/ace/Log_Msg.h +++ b/ace/Log_Msg.h @@ -36,7 +36,7 @@ ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \ ace___->set (__FILE__, __LINE__, -1, __ace_error, ace___->restart (), \ ace___->msg_ostream (), ace___->msg_callback ()); \ - ace___->log (LM_ERROR, ACE_LIB_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), #X, -1); \ + ace___->log (LM_ERROR, ACE_LIB_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), ACE_TEXT_CHAR_TO_TCHAR (#X), -1); \ } } while (0) #endif /* ACE_NDEBUG */ diff --git a/ace/Log_Msg_UNIX_Syslog.cpp b/ace/Log_Msg_UNIX_Syslog.cpp index 9957ae90575..b502d1dd185 100644 --- a/ace/Log_Msg_UNIX_Syslog.cpp +++ b/ace/Log_Msg_UNIX_Syslog.cpp @@ -41,9 +41,15 @@ ACE_Log_Msg_UNIX_Syslog::open (const ACE_TCHAR * logger_key) // options LOG_CONS and LOG_PID to be set. There really should be a // logging strategy option to control the syslog log options, // however, we'll take the easy way out for now. +#if defined (ACE_USES_WCHAR) + openlog (ACE_TEXT_ALWAYS_CHAR (logger_key), + LOG_CONS|LOG_PID, + ACE_DEFAULT_SYSLOG_FACILITY); +#else openlog (const_cast<char *> (logger_key), LOG_CONS|LOG_PID, ACE_DEFAULT_SYSLOG_FACILITY); +#endif /* ACE_USES_WCHAR */ // Enable logging of all syslog priorities. If logging of all // priorities is not desired, use the ACE_Log_Msg::priority_mask() @@ -103,14 +109,18 @@ ACE_Log_Msg_UNIX_Syslog::log (ACE_Log_Record &log_record) || ACE_BIT_ENABLED (flags, ACE_Log_Msg::VERBOSE_LITE)) { ACE_TCHAR date_and_time[35]; + if (0 == ACE::timestamp (date_and_time, sizeof (date_and_time), 1)) + ACE_OS::strcpy (date_and_time, ACE_LIB_TEXT ("<time error>")); + const ACE_TCHAR *prio_name = + ACE_Log_Record::priority_name(ACE_Log_Priority(log_record.type())); syslog (syslog_priority, - ACE_LIB_TEXT ("%s: %s: %s"), - ACE::timestamp (date_and_time, sizeof (date_and_time), 1), - ACE_Log_Record::priority_name (ACE_Log_Priority(log_record.type ())), - line); + "%s: %s: %s", + ACE_TEXT_ALWAYS_CHAR (date_and_time), + ACE_TEXT_ALWAYS_CHAR (prio_name), + ACE_TEXT_ALWAYS_CHAR (line)); } else // No formatting required. - syslog (syslog_priority, ACE_LIB_TEXT ("%s"), line); + syslog (syslog_priority, "%s", ACE_TEXT_ALWAYS_CHAR (line)); } return 0; diff --git a/ace/Log_Record.cpp b/ace/Log_Record.cpp index d5ca1493b4a..326628ae6a1 100644 --- a/ace/Log_Record.cpp +++ b/ace/Log_Record.cpp @@ -174,6 +174,18 @@ ACE_Log_Record::format_msg (const ACE_TCHAR host_name[], /* Oct 18 14:25:36.000 1989<nul> */ ACE_TCHAR timestamp[26]; // Only used by VERBOSE and VERBOSE_LITE. + // The sprintf format needs to be different for Windows and POSIX + // in the wide-char case. +#if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) + const ACE_TCHAR *time_fmt = ACE_LIB_TEXT ("%s.%03ld %s"); + const ACE_TCHAR *verbose_fmt = ACE_LIB_TEXT ("%s@%s@%u@%s@%s"); + const ACE_TCHAR *verbose_lite_fmt = ACE_LIB_TEXT ("%s@%s@%s"); +#else + const ACE_TCHAR *time_fmt = ACE_LIB_TEXT ("%ls.%03ld %ls"); + const ACE_TCHAR *verbose_fmt = ACE_LIB_TEXT ("%ls@%ls@%u@%ls@%ls"); + const ACE_TCHAR *verbose_lite_fmt = ACE_LIB_TEXT ("%ls@%ls@%ls"); +#endif + if (ACE_BIT_ENABLED (verbose_flag, ACE_Log_Msg::VERBOSE) || ACE_BIT_ENABLED (verbose_flag, @@ -192,7 +204,7 @@ ACE_Log_Record::format_msg (const ACE_TCHAR host_name[], ctp[24] = '\0'; // NUL-terminate after the date. ACE_OS::sprintf (timestamp, - ACE_LIB_TEXT ("%s.%03ld %s"), + time_fmt, ctp + 4, ((long) this->usecs_) / 1000, ctp + 20); @@ -211,7 +223,7 @@ ACE_Log_Record::format_msg (const ACE_TCHAR host_name[], : host_name); # endif /* ! defined (ACE_HAS_BROKEN_CONDITIONAL_STRING_CASTS) */ ACE_OS::sprintf (verbose_msg, - ACE_LIB_TEXT ("%s@%s@%u@%s@%s"), + verbose_fmt, timestamp, lhost_name, this->pid_, @@ -220,14 +232,12 @@ ACE_Log_Record::format_msg (const ACE_TCHAR host_name[], } else if (ACE_BIT_ENABLED (verbose_flag, ACE_Log_Msg::VERBOSE_LITE)) ACE_OS::sprintf (verbose_msg, - ACE_LIB_TEXT ("%s@%s@%s"), + verbose_lite_fmt, timestamp, ACE_Log_Record::priority_name (ACE_Log_Priority (this->type_)), this->msg_data_); else - ACE_OS::sprintf (verbose_msg, - ACE_LIB_TEXT ("%s"), - this->msg_data_); + ACE_OS::strcpy (verbose_msg, this->msg_data_); return 0; } diff --git a/ace/Memory_Pool.cpp b/ace/Memory_Pool.cpp index 72bfd262693..28826577d52 100644 --- a/ace/Memory_Pool.cpp +++ b/ace/Memory_Pool.cpp @@ -862,14 +862,15 @@ ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool (const ACE_TCHAR *backing_store_n // key. int segment_key; - int result = ::sscanf (backing_store_name, + int result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (backing_store_name), "%d", &segment_key); if (result == 0 || result == EOF) // The conversion to a number failed so hash with crc32 // ACE::crc32 is also used in <SV_Semaphore_Simple>. - this->base_shm_key_ = (key_t) ACE::crc32 (backing_store_name); + this->base_shm_key_ = + (key_t) ACE::crc32 (ACE_TEXT_ALWAYS_CHAR (backing_store_name)); else this->base_shm_key_ = segment_key; diff --git a/ace/OS_NS_stdio.cpp b/ace/OS_NS_stdio.cpp index a5bcfae03f0..10208d96a34 100644 --- a/ace/OS_NS_stdio.cpp +++ b/ace/OS_NS_stdio.cpp @@ -77,8 +77,9 @@ void ACE_OS::checkUnicodeFormat (FILE* fp) // select correct buffer type. // At this point, check if the file is Unicode or not. - WORD first_two_bytes; - size_t numRead = ACE_OS::fread(&first_two_bytes, sizeof(WORD), 1, fp); + ACE_UINT16 first_two_bytes; + size_t numRead = + ACE_OS::fread(&first_two_bytes, sizeof (first_two_bytes), 1, fp); if (numRead == 1) { @@ -86,7 +87,11 @@ void ACE_OS::checkUnicodeFormat (FILE* fp) (first_two_bytes != 0xFEFF)) // not a big endian Unicode file { // set file pointer back to the beginning +#if defined (ACE_WIN32) ACE_OS::fseek(fp, 0, FILE_BEGIN); +#else + ACE_OS::fseek(fp, 0, SEEK_SET); +#endif /* ACE_WIN32 */ } } // if it is a Unicode file, file pointer will be right next to the first @@ -423,6 +428,6 @@ ACE_OS::sprintf (wchar_t *buf, const wchar_t *format, ...) ACE_UNUSED_ARG (format); ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_VSWPRINTF */ +# endif /* XPG5 || ACE_HAS_DINKUM_STL */ } #endif /* ACE_HAS_WCHAR */ diff --git a/ace/OS_NS_stdio.h b/ace/OS_NS_stdio.h index 6d2596a12a4..eb242cc7bda 100644 --- a/ace/OS_NS_stdio.h +++ b/ace/OS_NS_stdio.h @@ -177,7 +177,12 @@ namespace ACE_OS { int fgetpos (FILE* fp, fpos_t* pos); ACE_NAMESPACE_INLINE_FUNCTION - ACE_TCHAR *fgets (ACE_TCHAR *buf, int size, FILE *fp); + char *fgets (char *buf, int size, FILE *fp); + +# if defined (ACE_HAS_WCHAR) + ACE_NAMESPACE_INLINE_FUNCTION + wchar_t *fgets (wchar_t *buf, int size, FILE *fp); +# endif /* ACE_HAS_WCHAR */ //@{ @name A set of wrappers for file locks. @@ -294,9 +299,15 @@ namespace ACE_OS { # endif /* ACE_HAS_WCHAR */ ACE_NAMESPACE_INLINE_FUNCTION - int fputs (const ACE_TCHAR *s, + int fputs (const char *s, FILE *stream); +# if defined (ACE_HAS_WCHAR) + ACE_NAMESPACE_INLINE_FUNCTION + int fputs (const wchar_t *s, + FILE *stream); +#endif /* ACE_HAS_WCHAR */ + ACE_NAMESPACE_INLINE_FUNCTION size_t fread (void *ptr, size_t size, @@ -338,13 +349,23 @@ namespace ACE_OS { char *gets (char *str, int n = 0); ACE_NAMESPACE_INLINE_FUNCTION - void perror (const ACE_TCHAR *s); + void perror (const char *s); + +#if defined (ACE_HAS_WCHAR) + ACE_NAMESPACE_INLINE_FUNCTION + void perror (const wchar_t *s); +#endif /* ACE_HAS_WCHAR */ extern ACE_Export int printf (const char *format, ...); ACE_NAMESPACE_INLINE_FUNCTION - int puts (const ACE_TCHAR *s); + int puts (const char *s); + +#if defined (ACE_HAS_WCHAR) + ACE_NAMESPACE_INLINE_FUNCTION + int puts (const wchar_t *s); +#endif /* ACE_HAS_WCHAR */ ACE_NAMESPACE_INLINE_FUNCTION int rename (const char *old_name, diff --git a/ace/OS_NS_stdio.inl b/ace/OS_NS_stdio.inl index d21702850e6..3cd8c0eac8f 100644 --- a/ace/OS_NS_stdio.inl +++ b/ace/OS_NS_stdio.inl @@ -558,7 +558,7 @@ ACE_OS::cuserid (char *user, size_t maxlen) const size_t ACE_L_cuserid = 9; // 8 character user ID + NULL #endif /* _POSIX_SOURCE */ - static ACE_TCHAR tmp[ACE_L_cuserid] = { '\0' }; + static char tmp[ACE_L_cuserid] = { '\0' }; max_length = ACE_L_cuserid - 1; // Do not include NULL in length userid = tmp; @@ -670,7 +670,8 @@ ACE_OS::fdopen (ACE_HANDLE handle, const ACE_TCHAR *mode) ACE_UNUSED_ARG (mode); ACE_NOTSUP_RETURN (0); # else - ACE_OSCALL_RETURN (::fdopen (handle, mode), FILE *, 0); + ACE_OSCALL_RETURN + (::fdopen (handle, ACE_TEXT_ALWAYS_CHAR (mode)), FILE *, 0); # endif /* ACE_HAS_WINCE */ } @@ -701,17 +702,22 @@ ACE_OS::fgetpos (FILE* fp, fpos_t* pos) ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetpos (fp, pos), int, -1); } -ACE_INLINE ACE_TCHAR * -ACE_OS::fgets (ACE_TCHAR *buf, int size, FILE *fp) +ACE_INLINE char * +ACE_OS::fgets (char *buf, int size, FILE *fp) { ACE_OS_TRACE ("ACE_OS::fgets"); -#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::fgetws (buf, size, fp), wchar_t *, 0); -#else /* ACE_WIN32 */ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgets (buf, size, fp), char *, 0); -#endif /* ACE_WIN32 && ACE_USES_WCHAR */ } +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS::fgets (wchar_t *buf, int size, FILE *fp) +{ + ACE_OS_TRACE ("ACE_OS::fgets"); + ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetws (buf, size, fp), wchar_t *, 0); +} +#endif /* ACE_HAS_WCHAR */ + #if !defined (ACE_WIN32) // Win32 implementation of fopen () is in OS_NS_stdio.cpp. ACE_INLINE FILE * @@ -737,16 +743,21 @@ ACE_OS::fopen (const wchar_t *filename, const ACE_TCHAR *mode) #endif /* ACE_WIN32 */ ACE_INLINE int -ACE_OS::fputs (const ACE_TCHAR *s, FILE *stream) +ACE_OS::fputs (const char *s, FILE *stream) { ACE_OS_TRACE ("ACE_OS::fputs"); -#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ACE_OSCALL_RETURN (::fputws (s, stream), int, -1); -#else /* ACE_WIN32 */ ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputs (s, stream), int, -1); -#endif /* ACE_WIN32 && ACE_USES_WCHAR */ } +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::fputs (const wchar_t *s, FILE *stream) +{ + ACE_OS_TRACE ("ACE_OS::fputs"); + ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputws (s, stream), int, -1); +} +#endif /* ACE_HAS_WCHAR */ + ACE_INLINE size_t ACE_OS::fread (void *ptr, size_t size, size_t nelems, FILE *fp) { @@ -761,7 +772,11 @@ ACE_OS::freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE* stream) #if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) ACE_OSCALL_RETURN (::_wfreopen (filename, mode, stream), FILE *, 0); #else - ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::freopen (filename, mode, stream), FILE *, 0); + ACE_OSCALL_RETURN + (ACE_STD_NAMESPACE::freopen (ACE_TEXT_ALWAYS_CHAR (filename), + ACE_TEXT_ALWAYS_CHAR (mode), + stream), + FILE *, 0); #endif /* ACE_WIN32 && ACE_USES_WCHAR */ } @@ -824,29 +839,55 @@ ACE_OS::gets (char *str) #endif /* 0 */ ACE_INLINE void -ACE_OS::perror (const ACE_TCHAR *s) +ACE_OS::perror (const char *s) { ACE_OS_TRACE ("ACE_OS::perror"); #if defined (ACE_HAS_WINCE) // @@ WINCE: How should this be handled ACE_UNUSED_ARG (s); -#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - ::_wperror (s); #else ::perror (s); #endif /* ACE_HAS_WINCE */ } +#if defined (ACE_HAS_WCHAR) +ACE_INLINE void +ACE_OS::perror (const wchar_t *s) +{ + ACE_OS_TRACE ("ACE_OS::perror"); +#if defined (ACE_HAS_WINCE) + // @@ WINCE: How should this be handled + ACE_UNUSED_ARG (s); +#elif defined (ACE_WIN32) + ::_wperror (s); +#else + ACE_Wide_To_Ascii n_s (s); + ::perror (n_s.char_rep ()); +#endif /* ACE_HAS_WINCE */ +} +#endif /* ACE_HAS_WCHAR */ + ACE_INLINE int -ACE_OS::puts (const ACE_TCHAR *s) +ACE_OS::puts (const char *s) { ACE_OS_TRACE ("ACE_OS::puts"); -#if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_OSCALL_RETURN (::puts (s), int, -1); +} + +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::puts (const wchar_t *s) +{ + ACE_OS_TRACE ("ACE_OS::puts"); +#if defined (ACE_WIN32) ACE_OSCALL_RETURN (::_putws (s), int, -1); #else /* ACE_WIN32 */ - ACE_OSCALL_RETURN (::puts (s), int, -1); -#endif /* ACE_WIN32 && ACE_USES_WCHAR */ + // There's no putws()... + ACE_Wide_To_Ascii n_s (s); + ACE_OSCALL_RETURN (::puts (n_s.char_rep ()), int, -1); +#endif /* ACE_WIN32 */ } +#endif /* ACE_HAS_WCHAR */ ACE_INLINE int ACE_OS::rename (const char *old_name, @@ -994,12 +1035,21 @@ ACE_OS::vsprintf (char *buffer, const char *format, va_list argptr) ACE_INLINE int ACE_OS::vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr) { -# if defined (ACE_HAS_VSWPRINTF) -# if defined (ACE_HAS_DINKUM_STL) - return ACE_STD_NAMESPACE::vswprintf (buffer, ULONG_MAX, format, argptr); -#else - return ::vswprintf (buffer, format, argptr); -# endif /* ACE_HAS_DINKUM_STL */ +# if (defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) || \ + (defined (sun) && !(defined(_XOPEN_SOURCE) && (_XOPEN_VERSION-0==4))) || \ + (defined (ACE_HAS_DINKUM_STL)) + + // The XPG4/UNIX98/C99 signature of the wide-char sprintf has a + // maxlen argument. Since this method doesn't supply one, pass in + // a length that works (ULONG_MAX doesn't). If this isn't ok, use + // ACE_OS::snprintf(). + return vswprintf (buffer, 4096, format, argptr); + +# elif defined (ACE_WIN32) + // Windows has vswprintf, but the signature is from the older ISO C + // standard. Also see ACE_OS::snprintf() for more info on this. + + return vswprintf (buffer, format, argptr); # else ACE_UNUSED_ARG (buffer); @@ -1007,7 +1057,7 @@ ACE_OS::vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr) ACE_UNUSED_ARG (argptr); ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_VSWPRINTF */ +# endif /* XPG5 || ACE_HAS_DINKUM_STL */ } #endif /* ACE_HAS_WCHAR */ diff --git a/ace/OS_NS_stdlib.cpp b/ace/OS_NS_stdlib.cpp index 991d336b475..dcca545dc69 100644 --- a/ace/OS_NS_stdlib.cpp +++ b/ace/OS_NS_stdlib.cpp @@ -260,13 +260,13 @@ ACE_OS::realloc (void *ptr, size_t nbytes) } #if defined (ACE_LACKS_REALPATH) -ACE_TCHAR * -ACE_OS::realpath (const ACE_TCHAR *file_name, - ACE_TCHAR *resolved_name) +char * +ACE_OS::realpath (const char *file_name, + char *resolved_name) { ACE_OS_TRACE ("ACE_OS::realpath"); - - if(file_name == 0) + + if (file_name == 0) { // Single Unix Specification V3: // Return an error if parameter is a null pointer. diff --git a/ace/OS_NS_stdlib.h b/ace/OS_NS_stdlib.h index 7ec04d9962c..3e2dca3f051 100644 --- a/ace/OS_NS_stdlib.h +++ b/ace/OS_NS_stdlib.h @@ -146,17 +146,26 @@ namespace ACE_OS { #if !defined (ACE_LACKS_MKSTEMP) ACE_NAMESPACE_INLINE_FUNCTION -#else - extern ACE_Export + ACE_HANDLE mkstemp (char *t); + +# if defined (ACE_HAS_WCHAR) + ACE_NAMESPACE_INLINE_FUNCTION + ACE_HANDLE mkstemp (wchar_t *t); +# endif /* ACE_HAS_WCHAR */ #endif /* !ACE_LACKS_MKSTEMP */ - ACE_HANDLE mkstemp (ACE_TCHAR *t); #if !defined (ACE_LACKS_MKTEMP) ACE_NAMESPACE_INLINE_FUNCTION + char *mktemp (char *t); + +# if defined (ACE_HAS_WCHAR) + ACE_NAMESPACE_INLINE_FUNCTION + wchar_t *mktemp (wchar_t *t); +# endif /* ACE_HAS_WCHAR */ #else extern ACE_Export -#endif /* !ACE_LACKS_MSTEMP */ ACE_TCHAR *mktemp (ACE_TCHAR *t); +#endif /* !ACE_LACKS_MSTEMP */ ACE_NAMESPACE_INLINE_FUNCTION int putenv (const char *string); @@ -190,7 +199,12 @@ namespace ACE_OS { #else extern ACE_Export #endif /* !ACE_LACKS_REALPATH */ - ACE_TCHAR *realpath (const ACE_TCHAR *file_name, ACE_TCHAR *resolved_name); + char *realpath (const char *file_name, char *resolved_name); + +#if defined (ACE_HAS_WCHAR) + ACE_NAMESPACE_INLINE_FUNCTION + wchar_t *realpath (const wchar_t *file_name, wchar_t *resolved_name); +#endif /* ACE_HAS_WCHAR */ // exit_hook and set_exit_hook not in spec /// Function that is called by <ACE_OS::exit>, if non-null. diff --git a/ace/OS_NS_string.h b/ace/OS_NS_string.h index 4b87c6153f6..a1bca281806 100644 --- a/ace/OS_NS_string.h +++ b/ace/OS_NS_string.h @@ -19,7 +19,7 @@ # include /**/ "ace/pre.h" -# include "ace/config-all.h" +# include "ace/config-lite.h" # if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/OS_NS_sys_stat.h b/ace/OS_NS_sys_stat.h index 670de445470..f954938b816 100644 --- a/ace/OS_NS_sys_stat.h +++ b/ace/OS_NS_sys_stat.h @@ -63,9 +63,15 @@ namespace ACE_OS { ACE_stat *); ACE_NAMESPACE_INLINE_FUNCTION - int lstat (const ACE_TCHAR *, + int lstat (const char *, ACE_stat *); +#if defined (ACE_HAS_WCHAR) + ACE_NAMESPACE_INLINE_FUNCTION + int lstat (const wchar_t *, + ACE_stat *); +#endif /* ACE_HAS_WCHAR */ + ACE_NAMESPACE_INLINE_FUNCTION int mkdir (const char *path, mode_t mode = ACE_DEFAULT_DIR_PERMS); diff --git a/ace/OS_NS_sys_stat.inl b/ace/OS_NS_sys_stat.inl index 19e06b7715b..c3a433b96c3 100644 --- a/ace/OS_NS_sys_stat.inl +++ b/ace/OS_NS_sys_stat.inl @@ -24,7 +24,7 @@ ACE_OS::creat (const ACE_TCHAR *filename, mode_t mode) ACE_UNUSED_ARG (mode); ACE_NOTSUP_RETURN (-1); #else - ACE_OSCALL_RETURN (::creat (filename, mode), + ACE_OSCALL_RETURN (::creat (ACE_TEXT_ALWAYS_CHAR (filename), mode), ACE_HANDLE, ACE_INVALID_HANDLE); #endif /* ACE_WIN32 */ } @@ -137,7 +137,7 @@ ACE_OS::filesize (const ACE_TCHAR *filename) } ACE_INLINE int -ACE_OS::lstat (const ACE_TCHAR *file, ACE_stat *stp) +ACE_OS::lstat (const char *file, ACE_stat *stp) { ACE_OS_TRACE ("ACE_OS::lstat"); # if defined (ACE_LACKS_LSTAT) @@ -151,6 +151,19 @@ ACE_OS::lstat (const ACE_TCHAR *file, ACE_stat *stp) # endif /* ACE_LACKS_LSTAT */ } +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::lstat (const wchar_t *file, ACE_stat *stp) +{ + ACE_OS_TRACE ("ACE_OS::lstat"); +# if defined (ACE_LACKS_LSTAT) + return ACE_OS::stat (file, stp); +# else + return ACE_OS::lstat (ACE_Wide_To_Ascii (file).char_rep (), stp); +# endif /* ACE_LACKS_LSTAT */ +} +#endif /* ACE_HAS_WCHAR */ + ACE_INLINE int ACE_OS::mkdir (const char *path, mode_t mode) { @@ -241,7 +254,7 @@ ACE_OS::mkfifo (const ACE_TCHAR *file, mode_t mode) ACE_UNUSED_ARG (mode); ACE_NOTSUP_RETURN (-1); #else - ACE_OSCALL_RETURN (::mkfifo (file, mode), int, -1); + ACE_OSCALL_RETURN (::mkfifo (ACE_TEXT_ALWAYS_CHAR (file), mode), int, -1); #endif /* ACE_LACKS_MKFIFO */ } diff --git a/ace/OS_NS_time.inl b/ace/OS_NS_time.inl index 294f802bbfe..ac13858669c 100644 --- a/ace/OS_NS_time.inl +++ b/ace/OS_NS_time.inl @@ -91,10 +91,26 @@ ACE_OS::ctime (const time_t *t) return ACE_OS::ctime_r (t, buf, ctime_buf_size); -#elif defined (ACE_USES_WCHAR) +#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) ACE_OSCALL_RETURN (::_wctime (t), wchar_t *, 0); #else +# if defined (ACE_USES_WCHAR) /* Not Win32, else it would do the above */ + char *narrow_time; + ACE_OSCALL (::ctime (t), char *, 0, narrow_time); + if (narrow_time == 0) + return 0; + // ACE_Ascii_To_Wide::convert allocates (via new []) a wchar_t[]. If + // we've done this before, free the previous one. Yes, this leaves a + // small memory leak (26 characters) but there's no way around this + // that I know of. (Steve Huston, 12-Feb-2003). + static wchar_t *wide_time = 0; + if (wide_time != 0) + delete [] wide_time; + wide_time = ACE_Ascii_To_Wide::convert (narrow_time); + return wide_time; +# else ACE_OSCALL_RETURN (::ctime (t), char *, 0); +# endif /* ACE_USES_WCHAR */ # endif /* ACE_HAS_BROKEN_CTIME */ } @@ -105,6 +121,15 @@ ACE_OS::ctime_r (const time_t *t, ACE_TCHAR *buf, int buflen) ACE_OS_TRACE ("ACE_OS::ctime_r"); #if defined (ACE_HAS_REENTRANT_FUNCTIONS) + + char *bufp = 0; +# if defined (ACE_USES_WCHAR) + char narrow_buf[ctime_buf_size]; + bufp = narrow_buf; +# else + bufp = buf; +# endif /* ACE_USES_WCHAR */ + # if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) if (buflen < ctime_buf_size) { @@ -112,20 +137,31 @@ ACE_OS::ctime_r (const time_t *t, ACE_TCHAR *buf, int buflen) return 0; } # if defined (DIGITAL_UNIX) - ACE_OSCALL_RETURN (::_Pctime_r (t, buf), ACE_TCHAR *, 0); + ACE_OSCALL (::_Pctime_r (t, bufp), ACE_TCHAR *, 0, bufp); # else /* DIGITAL_UNIX */ - ACE_OSCALL_RETURN (::ctime_r (t, buf), ACE_TCHAR *, 0); + ACE_OSCALL (::ctime_r (t, bufp), char *, 0, bufp); # endif /* DIGITAL_UNIX */ - return buf; # else /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ # if defined (ACE_CTIME_R_RETURNS_INT) - return (::ctime_r (t, buf, buflen) == -1 ? 0 : buf); + bufp = ::ctime_r (t, bufp, buflen) == -1 ? 0 : bufp; # else /* ACE_CTIME_R_RETURNS_INT */ - ACE_OSCALL_RETURN (::ctime_r (t, buf, buflen), ACE_TCHAR *, 0); + bufp = ::ctime_r (t, bufp, buflen); # endif /* ACE_CTIME_R_RETURNS_INT */ # endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ + + if (bufp == 0) + return 0; + +# if defined (ACE_USES_WCHAR) + ACE_Ascii_To_Wide wide_buf (bufp); + ACE_OS_String::strcpy (buf, wide_buf.wchar_rep ()); + return buf; +# else + return bufp; +# endif /* ACE_USES_WCHAR */ + #else /* ACE_HAS_REENTRANT_FUNCTIONS */ # if defined(ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME) ACE_OS::strsncpy (buf, "ctime-return", buflen); diff --git a/ace/OS_NS_unistd.cpp b/ace/OS_NS_unistd.cpp index c472f5d7cca..97ad6d5150d 100644 --- a/ace/OS_NS_unistd.cpp +++ b/ace/OS_NS_unistd.cpp @@ -55,14 +55,30 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv, for (int i = 0; argv[i] != 0; i++) { - ACE_TCHAR *temp = 0; - #if !defined (ACE_LACKS_ENV) // Account for environment variables. - if (substitute_env_args - && (argv[i][0] == '$' - && (temp = ACE_OS::getenv (&argv[i][1])) != 0)) - buf_len += ACE_OS::strlen (temp); + if (substitute_env_args && argv[i][0] == ACE_LIB_TEXT ('$')) + { +# if defined (ACE_WIN32) || !defined (ACE_HAS_WCHAR) + ACE_TCHAR *temp = 0; + // Win32 is the only platform with a wide-char ACE_OS::getenv(). + if ((temp = ACE_OS::getenv (&argv[i][1])) != 0) + buf_len += ACE_OS::strlen (temp); + else + buf_len += ACE_OS::strlen (argv[i]); +# else + // This is an ACE_HAS_WCHAR platform and not ACE_WIN32. + // Convert the env variable name for getenv(), then add + // the length of the returned char *string. Later, when we + // actually use the returned env variable value, convert it + // as well. + char *ctemp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (&argv[i][1])); + if (ctemp == 0) + buf_len += ACE_OS::strlen (argv[i]); + else + buf_len += ACE_OS::strlen (ctemp); +# endif /* ACE_WIN32 || !ACE_HAS_WCHAR */ + } else #endif /* ACE_LACKS_ENV */ buf_len += ACE_OS::strlen (argv[i]); @@ -85,14 +101,29 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv, for (j = 0; argv[j] != 0; j++) { - ACE_TCHAR *temp = 0; #if !defined (ACE_LACKS_ENV) // Account for environment variables. - if (substitute_env_args - && (argv[j][0] == '$' - && (temp = ACE_OS::getenv (&argv[j][1])) != 0)) - end = ACE_OS::strecpy (end, temp); + if (substitute_env_args && argv[j][0] == ACE_LIB_TEXT ('$')) + { +# if defined (ACE_WIN32) || !defined (ACE_HAS_WCHAR) + // Win32 is the only platform with a wide-char ACE_OS::getenv(). + ACE_TCHAR *temp = ACE_OS::getenv (&argv[j][1]); + if (temp != 0) + end = ACE_OS::strecpy (end, temp); + else + end = ACE_OS::strecpy (end, argv[j]); +# else + // This is an ACE_HAS_WCHAR platform and not ACE_WIN32. + // Convert the env variable name for getenv(), then convert + // the returned char *string back to wchar_t. + char *ctemp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (&argv[j][1])); + if (ctemp == 0) + end = ACE_OS::strecpy (end, argv[j]); + else + end = ACE_OS::strecpy (end, ACE_TEXT_CHAR_TO_TCHAR (ctemp)); +# endif /* ACE_WIN32 || !ACE_HAS_WCHAR */ + } else #endif /* ACE_LACKS_ENV */ end = ACE_OS::strecpy (end, argv[j]); @@ -229,6 +260,13 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[]) # else pid_t result = ACE_OS::fork (); +# if defined (ACE_USES_WCHAR) + // Wide-char builds need to convert the command-line args to + // narrow char strings for execv(). + char **cargv; + int arg_count; +# endif /* ACE_HAS_WCHAR */ + switch (result) { case -1: @@ -236,6 +274,22 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[]) return -1; case 0: // Child process. +# if defined (ACE_USES_WCHAR) + for (arg_count = 0; argv[arg_count] != 0; ++arg_count) + ; + ++arg_count; // Need a 0-pointer end-of-array marker + ACE_NEW_NORETURN (cargv, char*[arg_count]); + if (cargv == 0) + ACE_OS::exit (errno); + --arg_count; // Back to 0-indexed + cargv[arg_count] = 0; + while (--arg_count >= 0) + cargv[arg_count] = ACE_Wide_To_Ascii::convert (argv[arg_count]); + // Don't worry about freeing the cargv or the strings it points to. + // Either the process will be replaced, or we'll exit. + if (ACE_OS::execv (cargv[0], cargv) == -1) + ACE_OS::exit (errno); +# else if (ACE_OS::execv (argv[0], argv) == -1) { // The OS layer should not print stuff out @@ -245,6 +299,8 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[]) // If the execv fails, this child needs to exit. ACE_OS::exit (errno); } +# endif /* ACE_HAS_WCHAR */ + default: // Server process. The fork succeeded. return result; diff --git a/ace/OS_NS_unistd.h b/ace/OS_NS_unistd.h index 54200f5e648..bc75ef75be8 100644 --- a/ace/OS_NS_unistd.h +++ b/ace/OS_NS_unistd.h @@ -74,7 +74,12 @@ namespace ACE_OS { #endif /* ACE_LACKS_CHDIR */ ACE_NAMESPACE_INLINE_FUNCTION - int rmdir (const ACE_TCHAR * path); + int rmdir (const char *path); + +#if defined (ACE_HAS_WCHAR) + ACE_NAMESPACE_INLINE_FUNCTION + int rmdir (const wchar_t *path); +#endif /* ACE_HAS_WCHAR */ ACE_NAMESPACE_INLINE_FUNCTION int close (ACE_HANDLE handle); @@ -134,7 +139,12 @@ namespace ACE_OS { off_t); ACE_NAMESPACE_INLINE_FUNCTION - ACE_TCHAR *getcwd (ACE_TCHAR *, size_t); + char *getcwd (char *, size_t); + +#if defined (ACE_HAS_WCHAR) + ACE_NAMESPACE_INLINE_FUNCTION + wchar_t *getcwd (wchar_t *, size_t); +#endif /* ACE_HAS_WCHAR */ ACE_NAMESPACE_INLINE_FUNCTION gid_t getgid (void); diff --git a/ace/OS_NS_unistd.inl b/ace/OS_NS_unistd.inl index 52cde10e856..55275f50c18 100644 --- a/ace/OS_NS_unistd.inl +++ b/ace/OS_NS_unistd.inl @@ -145,7 +145,7 @@ ACE_OS::chdir (const wchar_t *path) #endif /* ACE_LACKS_CHDIR */ ACE_INLINE int -ACE_OS::rmdir (const ACE_TCHAR * path) +ACE_OS::rmdir (const char *path) { #if defined (ACE_PSOS_LACKS_PHILE) ACE_UNUSED_ARG (path); @@ -199,6 +199,23 @@ ACE_OS::rmdir (const ACE_TCHAR * path) #endif /* ACE_HAS_PACE */ } +#if defined (ACE_HAS_WCHAR) +ACE_INLINE int +ACE_OS::rmdir (const wchar_t *path) +{ +#if defined (ACE_HAS_WINCE) + ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::RemoveDirectory (path, NULL), + ace_result_), + int, -1); +#elif defined (ACE_WIN32) + ACE_OSCALL_RETURN (::_wrmdir (path), int, -1); +#else + ACE_Wide_To_Ascii n_path (path); + return ACE_OS::rmdir (n_path.char_rep ()); +#endif /* ACE_HAS_WINCE */ +} +#endif /* ACE_HAS_WCHAR */ + // @todo: which 4 and why??? dhinton // NOTE: The following four function definitions must appear before // ACE_OS::sema_init (). @@ -400,8 +417,8 @@ ACE_OS::ftruncate (ACE_HANDLE handle, off_t offset) #endif /* ACE_WIN32 */ } -ACE_INLINE ACE_TCHAR * -ACE_OS::getcwd (ACE_TCHAR *buf, size_t size) +ACE_INLINE char * +ACE_OS::getcwd (char *buf, size_t size) { ACE_OS_TRACE ("ACE_OS::getcwd"); #if defined (ACE_PSOS_LACKS_PHILE) @@ -493,16 +510,31 @@ ACE_OS::getcwd (ACE_TCHAR *buf, size_t size) ACE_UNUSED_ARG (size); ACE_NOTSUP_RETURN (0); #elif defined (ACE_WIN32) -# if defined (ACE_USES_WCHAR) - return ::_wgetcwd (buf, static_cast<int> (size)); -# else return ::getcwd (buf, static_cast<int> (size)); -# endif /* ACE_USES_WCHAR */ #else ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0); #endif /* ACE_PSOS_LACKS_PHILE */ } +#if defined (ACE_HAS_WCHAR) +ACE_INLINE wchar_t * +ACE_OS::getcwd (wchar_t *buf, size_t size) +{ +# if defined (ACE_WIN32) + return ::_wgetcwd (buf, ACE_static_cast (int, size)); +# else + char *narrow_buf = new char[size]; + char *result = 0; + result = ACE_OS::getcwd (narrow_buf, size); + ACE_Ascii_To_Wide wide_buf (result); + delete [] narrow_buf; + if (result != 0) + ACE_OS::strsncpy (buf, wide_buf.wchar_rep (), size); + return result == 0 ? 0 : buf; +# endif /* ACE_WIN32 */ +} +#endif /* ACE_HAS_WCHAR */ + ACE_INLINE gid_t ACE_OS::getgid (void) { @@ -1194,7 +1226,8 @@ ACE_OS::truncate (const ACE_TCHAR *filename, } /* NOTREACHED */ #elif !defined (ACE_LACKS_TRUNCATE) - ACE_OSCALL_RETURN (::truncate (filename, offset), int, -1); + ACE_OSCALL_RETURN + (::truncate (ACE_TEXT_ALWAYS_CHAR (filename), offset), int, -1); #else ACE_UNUSED_ARG (filename); ACE_UNUSED_ARG (offset); diff --git a/ace/OS_main.h b/ace/OS_main.h index 4a80cb624d7..87e932a4dd9 100644 --- a/ace/OS_main.h +++ b/ace/OS_main.h @@ -36,7 +36,20 @@ # if defined (ACE_WIN32) && defined (ACE_USES_WCHAR) # define ACE_TMAIN wmain # else -# define ACE_TMAIN main +# if defined (ACE_USES_WCHAR) /* Not Win32, but uses wchar */ + // Replace main() with a version that converts the char** argv to + // ACE_TCHAR and calls the ACE_TMAIN entrypoint. +# include "ace/Argv_Type_Converter.h" +# define ACE_TMAIN \ + ace_main_i (int, ACE_TCHAR *[]); /* forward declaration */ \ + int main (int argc, char *argv[]) { \ + ACE_Argv_Type_Converter wide_argv (argc, argv); \ + return ace_main_i (argc, wide_argv.get_TCHAR_argv ()); \ + } \ + int ace_main_i +# else +# define ACE_TMAIN main +# endif /* ACE_USES_WCHAR */ # endif # if defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER) diff --git a/ace/Object_Manager_Base.cpp b/ace/Object_Manager_Base.cpp index 32d2e1f5482..6a2b512ef67 100644 --- a/ace/Object_Manager_Base.cpp +++ b/ace/Object_Manager_Base.cpp @@ -408,7 +408,7 @@ ACE_OS_Object_Manager::print_error_message (u_int line_number, #if !defined (ACE_HAS_WINCE) fprintf (stderr, "ace/OS.cpp, line %u: %s ", line_number, - message); + ACE_TEXT_ALWAYS_CHAR (message)); perror ("failed"); #else // @@ Need to use the following information. diff --git a/ace/Object_Manager_Base.h b/ace/Object_Manager_Base.h index 5619b3af323..dc09e8daeb5 100644 --- a/ace/Object_Manager_Base.h +++ b/ace/Object_Manager_Base.h @@ -18,7 +18,7 @@ #define ACE_OBJECT_MANAGER_BASE_H #include /**/ "ace/pre.h" -#include "ace/config-all.h" +#include "ace/config-lite.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once diff --git a/ace/Process.cpp b/ace/Process.cpp index ac1339f25c3..3ff8c38a1f2 100644 --- a/ace/Process.cpp +++ b/ace/Process.cpp @@ -344,31 +344,56 @@ ACE_Process::spawn (ACE_Process_Options &options) // Child process executes the command. int result = 0; + // Wide-char builds not on Windows need narrow-char strings for + // exec() and environment variables. Don't need to worry about + // releasing any of the converted string memory since this + // process will either exec() or exit() shortly. +# if defined (ACE_USES_WCHAR) + ACE_Wide_To_Ascii n_procname (options.process_name ()); + const char *procname = n_procname.char_rep (); + + wchar_t * const *wargv = options.command_line_argv (); + size_t vcount, i; + for (vcount = 0; wargv[vcount] != 0; ++vcount) + ; + char **procargv = new char *[vcount + 1]; // Need 0 at the end + procargv[vcount] = 0; + for (i = 0; i < vcount; ++i) + procargv[i] = ACE_Wide_To_Ascii::convert (wargv[i]); + + wargv = options.env_argv (); + for (vcount = 0; wargv[vcount] != 0; ++vcount) + ; + char **procenv = new char *[vcount + 1]; // Need 0 at the end + procenv[vcount] = 0; + for (i = 0; i < vcount; ++i) + procenv[i] = ACE_Wide_To_Ascii::convert (wargv[i]); +# else + const char *procname = options.process_name (); + char *const *procargv = options.command_line_argv (); + char *const *procenv = options.env_argv (); +# endif /* ACE_USES_WCHAR */ + if (options.inherit_environment ()) { // Add the new environment variables to the environment // context of the context before doing an <execvp>. - for (char *const *user_env = options.env_argv (); - *user_env != 0; - user_env++) - if (ACE_OS::putenv (*user_env) != 0) + for (size_t i = 0; procenv[i] != 0; i++) + if (ACE_OS::putenv (procenv[i]) != 0) return ACE_INVALID_PID; // Now the forked process has both inherited variables and // the user's supplied variables. - result = ACE_OS::execvp (options.process_name (), - options.command_line_argv ()); + result = ACE_OS::execvp (procname, procargv); } else { -#if defined (ghs) +# if defined (ghs) // GreenHills 1.8.8 (for VxWorks 5.3.x) can't compile this // code. Processes aren't supported on VxWorks anyways. ACE_NOTSUP_RETURN (ACE_INVALID_PID); -#else - result = ACE_OS::execve (options.process_name (), - options.command_line_argv (), - options.env_argv ()); +# else + result = ACE_OS::execve (procname, procargv, procenv); # endif /* ghs */ } if (result == -1) diff --git a/ace/Process.inl b/ace/Process.inl index cf0c17b6f60..7b561b5c59d 100644 --- a/ace/Process.inl +++ b/ace/Process.inl @@ -247,7 +247,7 @@ ACE_INLINE int ACE_Process_Options::setreugid (const ACE_TCHAR* user) { #if !defined (ACE_LACKS_PWD_FUNCTIONS) - struct passwd *ent = ACE_OS::getpwnam (user); + struct passwd *ent = ACE_OS::getpwnam (ACE_TEXT_ALWAYS_CHAR (user)); if (ent != 0) { diff --git a/ace/Process_Mutex.cpp b/ace/Process_Mutex.cpp index 7d762c9e6c4..1cf0aaa1902 100644 --- a/ace/Process_Mutex.cpp +++ b/ace/Process_Mutex.cpp @@ -38,8 +38,7 @@ ACE_Process_Mutex::unique_name (void) ACE_Process_Mutex::ACE_Process_Mutex (const char *name, void *arg, mode_t mode) #if defined (_ACE_USE_SV_SEM) - : lock_ (name ? - ACE_TEXT_CHAR_TO_TCHAR (name) : this->unique_name (), + : lock_ (name ? name : ACE_TEXT_ALWAYS_CHAR (this->unique_name ()), ACE_SV_Semaphore_Complex::ACE_CREATE, 1, 1, @@ -63,7 +62,8 @@ ACE_Process_Mutex::ACE_Process_Mutex (const wchar_t *name, mode_t mode) #if defined (_ACE_USE_SV_SEM) : lock_ (name ? - ACE_TEXT_WCHAR_TO_TCHAR (name) : this->unique_name (), + ACE_Wide_To_Ascii (name).char_rep () : + ACE_TEXT_ALWAYS_CHAR (this->unique_name ()), ACE_SV_Semaphore_Complex::ACE_CREATE, 1, 1, diff --git a/ace/Process_Semaphore.cpp b/ace/Process_Semaphore.cpp index 88355398384..0e78f9b7ea5 100644 --- a/ace/Process_Semaphore.cpp +++ b/ace/Process_Semaphore.cpp @@ -30,7 +30,9 @@ ACE_Process_Semaphore::ACE_Process_Semaphore (u_int count, #if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) || defined (ACE_PSOS) : lock_ (count, USYNC_PROCESS, name, arg, max) #else - : lock_ (name, ACE_SV_Semaphore_Complex::ACE_CREATE, count) + : lock_ (ACE_TEXT_ALWAYS_CHAR (name), + ACE_SV_Semaphore_Complex::ACE_CREATE, + count) #endif /* ACE_WIN32 || ACE_HAS_POSIX_SEM || ACE_PSOS */ { arg = arg; diff --git a/ace/SOCK_Dgram_Bcast.cpp b/ace/SOCK_Dgram_Bcast.cpp index 67e6507ab23..7ccea2233ed 100644 --- a/ace/SOCK_Dgram_Bcast.cpp +++ b/ace/SOCK_Dgram_Bcast.cpp @@ -142,7 +142,7 @@ ACE_SOCK_Dgram_Bcast::mk_broadcast (const ACE_TCHAR *host_name) //Get host ip address if (host_name) { - hostent *hp = ACE_OS::gethostbyname (host_name); + hostent *hp = ACE_OS::gethostbyname (ACE_TEXT_ALWAYS_CHAR (host_name)); if (hp == 0) return -1; diff --git a/ace/SOCK_Dgram_Mcast.cpp b/ace/SOCK_Dgram_Mcast.cpp index cbbe9b27f8c..f63bf302777 100644 --- a/ace/SOCK_Dgram_Mcast.cpp +++ b/ace/SOCK_Dgram_Mcast.cpp @@ -975,7 +975,7 @@ ACE_SOCK_Dgram_Mcast::make_multicast_ifaddr (ip_mreq *ret_mreq, // Look up the interface by number, not name. if_address.ifr_ifno = ACE_OS::atoi (net_if); #else - ACE_OS::strcpy (if_address.ifr_name, net_if); + ACE_OS::strcpy (if_address.ifr_name, ACE_TEXT_ALWAYS_CHAR (net_if)); #endif /* defined (ACE_PSOS) */ if (ACE_OS::ioctl (this->get_handle (), diff --git a/ace/SV_Semaphore_Simple.cpp b/ace/SV_Semaphore_Simple.cpp index f54a843cc96..e28ba4a923c 100644 --- a/ace/SV_Semaphore_Simple.cpp +++ b/ace/SV_Semaphore_Simple.cpp @@ -187,6 +187,25 @@ ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (const char *name, ACE_LIB_TEXT ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple"))); } +#if defined (ACE_HAS_WCHAR) +ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (const wchar_t *name, + int flags, + int initial_value, + u_short nsems, + int perms) +{ + ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple(wchar_t)"); + if (this->open (ACE_Wide_To_Ascii (name).char_rep (), + flags, + initial_value, + nsems, + perms) == -1) + ACE_ERROR ((LM_ERROR, + ACE_LIB_TEXT ("%p\n"), + ACE_LIB_TEXT ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple"))); +} +#endif /* ACE_HAS_WCHAR */ + ACE_SV_Semaphore_Simple::~ACE_SV_Semaphore_Simple (void) { ACE_TRACE ("ACE_SV_Semaphore_Simple::~ACE_SV_Semaphore_Simple"); diff --git a/ace/SV_Semaphore_Simple.h b/ace/SV_Semaphore_Simple.h index d6d28374434..85ba4c0daa0 100644 --- a/ace/SV_Semaphore_Simple.h +++ b/ace/SV_Semaphore_Simple.h @@ -67,6 +67,14 @@ public: int initial_value = 1, u_short nsems = 1, int perms = ACE_DEFAULT_FILE_PERMS); +#if defined (ACE_HAS_WCHAR) + ACE_SV_Semaphore_Simple (const wchar_t *name, + int flags = ACE_SV_Semaphore_Simple::ACE_CREATE, + int initial_value = 1, + u_short nsems = 1, + int perms = ACE_DEFAULT_FILE_PERMS); +#endif /* ACE_HAS_WCHAR */ + ~ACE_SV_Semaphore_Simple (void); int open (const char *name, @@ -75,6 +83,14 @@ public: u_short nsems = 1, int perms = ACE_DEFAULT_FILE_PERMS); +#if defined (ACE_HAS_WCHAR) + int open (const wchar_t *name, + int flags = ACE_SV_Semaphore_Simple::ACE_CREATE, + int initial_value = 1, + u_short nsems = 1, + int perms = ACE_DEFAULT_FILE_PERMS); +#endif /* ACE_HAS_WCHAR */ + /// Open or create one or more SV_Semaphores. We return 0 if all is /// OK, else -1. int open (key_t key, diff --git a/ace/SV_Semaphore_Simple.inl b/ace/SV_Semaphore_Simple.inl index a6490c18ac8..85aad8d5b0c 100644 --- a/ace/SV_Semaphore_Simple.inl +++ b/ace/SV_Semaphore_Simple.inl @@ -6,6 +6,25 @@ #include "ace/Global_Macros.h" #include "ace/OS_NS_Thread.h" +#if defined (ACE_HAS_WCHAR) +// Semaphores don't offer wide-char names, so convert the name and forward +// to the narrow-char open(). +ACE_INLINE int +ACE_SV_Semaphore_Simple::open (const wchar_t *name, + int flags, + int initial_value, + u_short nsems, + int perms) +{ + ACE_TRACE ("ACE_SV_Semaphore_Simple::open (wchar_t)"); + return this->open (ACE_Wide_To_Ascii (name).char_rep (), + flags, + initial_value, + nsems, + perms); +} +#endif /* ACE_HAS_WCHAR */ + ACE_INLINE int ACE_SV_Semaphore_Simple::control (int cmd, semun arg, diff --git a/ace/Sock_Connect.cpp b/ace/Sock_Connect.cpp index ee794a746fc..249f656e0a9 100644 --- a/ace/Sock_Connect.cpp +++ b/ace/Sock_Connect.cpp @@ -388,7 +388,7 @@ ACE::get_bcast_addr (ACE_UINT32 &bcast_addr, // Get host ip address if necessary. if (host_name) { - hostent *hp = ACE_OS::gethostbyname (host_name); + hostent *hp = ACE_OS::gethostbyname (ACE_TEXT_ALWAYS_CHAR (host_name)); if (hp == 0) return -1; diff --git a/ace/ace.mpc b/ace/ace.mpc index b010fc6ca43..58bdf1fece2 100644 --- a/ace/ace.mpc +++ b/ace/ace.mpc @@ -5,6 +5,7 @@ project(ACE) : acedefaults, aceversion, core, qt_reactor, other, codecs, token, libout = $(ACE_ROOT)/lib sharedname = ACE dynamicflags = ACE_BUILD_DLL + install = $(ACE_ROOT)/lib // This mpc file could be greatly simplified by putting the separate components // in subdirectories. diff --git a/ace/ace_wchar.h b/ace/ace_wchar.h index a2eb7b91511..dc30dea3049 100644 --- a/ace/ace_wchar.h +++ b/ace/ace_wchar.h @@ -50,6 +50,9 @@ #endif /* ACE_LEGACY_MODE */ #if defined (ACE_HAS_XPG4_MULTIBYTE_CHAR) +# if !defined (ACE_HAS_WCHAR) +# define ACE_HAS_WCHAR +# endif # include /**/ <wchar.h> #endif /* ACE_HAS_XPG4_MULTIBYPTE_CHAR */ diff --git a/tests/Dirent_Test.cpp b/tests/Dirent_Test.cpp index dcd2879b979..ba2f45cbe29 100644 --- a/tests/Dirent_Test.cpp +++ b/tests/Dirent_Test.cpp @@ -41,8 +41,16 @@ ACE_RCSID (tests, #define TEST_DIR "log" #define TEST_ENTRY ".." #else -#define TEST_DIR "../tests" -#define TEST_ENTRY "run_test.lst" +# define TEST_DIR "../tests" +# if defined (ACE_LACKS_STRUCT_DIR) || !defined (ACE_HAS_SCANDIR) +# define DIR_DOT ACE_TEXT (".") +# define DIR_DOT_DOT ACE_TEXT ("..") +# define TEST_ENTRY ACE_TEXT ("run_test.lst") +# else +# define DIR_DOT "." +# define DIR_DOT_DOT ".." +# define TEST_ENTRY "run_test.lst" +# endif /* ACE_LACKS_STRUCT_DIR */ #endif /* VXWORKS || CHORUS */ static const int RECURSION_INDENT = 3; @@ -53,13 +61,13 @@ static int entrycount = 0; static int selector (const dirent *d) { - return ACE_OS_String::strcmp (d->d_name, ACE_TEXT (TEST_ENTRY)) == 0; + return ACE_OS::strcmp (d->d_name, TEST_ENTRY) == 0; } static int comparator (const dirent **d1, const dirent **d2) { - return ACE_OS_String::strcmp ((*d1)->d_name, (*d2)->d_name); + return ACE_OS::strcmp ((*d1)->d_name, (*d2)->d_name); } static int @@ -79,7 +87,7 @@ dirent_selector_test (void) for (n = 0; n < sds.length (); ++n) ACE_DEBUG ((LM_DEBUG, - "Sorted: %d: %s\n", + ACE_TEXT ("Sorted: %d: %C\n"), n, sds[n]->d_name)); @@ -96,7 +104,7 @@ dirent_selector_test (void) for (n = 0; n < ds.length (); ++n) ACE_DEBUG ((LM_DEBUG, - "Entry %d: %s\n", + ACE_TEXT ("Entry %d: %C\n"), n, ds[n]->d_name)); @@ -115,24 +123,24 @@ dirent_test (void) (directory = dir.read ()) != 0; entrycount++) ACE_DEBUG ((LM_DEBUG, - "Entry %d: %s\n", + ACE_TEXT ("Entry %d: %C\n"), entrycount, directory->d_name)); switch (entrycount) { case 0: - ACE_ERROR_RETURN ((LM_ERROR, - "readdir failed to read anything\n"), - -1); + ACE_ERROR_RETURN + ((LM_ERROR, ACE_TEXT ("readdir failed to read anything\n")), -1); /* NOTREACHED */ case 1: - ACE_ERROR_RETURN ((LM_ERROR, - "readdir failed, only matched directory name\n"), - -1); + ACE_ERROR_RETURN + ((LM_ERROR, + ACE_TEXT ("readdir failed, only matched directory name\n")), + -1); /* NOTREACHED */ default: ACE_DEBUG ((LM_DEBUG, - "readdir succeeded, read %d entries\n", + ACE_TEXT ("readdir succeeded, read %d entries\n"), entrycount)); } return 0; @@ -146,29 +154,42 @@ dirent_count (const ACE_TCHAR *dir_path, { if (ACE_OS::chdir (dir_path) == -1) ACE_ERROR_RETURN ((LM_ERROR, - "chdir: %p\n", + ACE_TEXT ("chdir: %p\n"), dir_path), -1); ACE_Dirent dir (ACE_TEXT (".")); + // Since the dir struct d_name type changes depending on the setting + // of ACE_LACKS_STRUCT_DIR, copy each name into a neutral format + // array to work on it. + const size_t maxnamlen = MAXNAMLEN; + ACE_TCHAR tname[maxnamlen + 1]; + int entry_count = 0; for (dirent *directory; (directory = dir.read ()) != 0;) { // Skip the ".." and "." files. - if (ACE_OS_String::strcmp (directory->d_name, ACE_TEXT (".")) == 0 - || ACE_OS_String::strcmp (directory->d_name, ACE_TEXT ("..")) == 0) + if (ACE_OS::strcmp (directory->d_name, DIR_DOT) == 0 + || ACE_OS::strcmp (directory->d_name, DIR_DOT_DOT) == 0) continue; entry_count++; +#if !defined (ACE_LACKS_STRUCT_DIR) + ACE_OS::strncpy (tname, + ACE_TEXT_CHAR_TO_TCHAR (directory->d_name), + maxnamlen); +#else + ACE_OS::strncpy (tname, directory->d_name, maxnamlen); +#endif /* ACE_LACKS_STRUCT_DIR */ + int local_file_count = 0; int local_dir_count = 0; ACE_stat stat_buf; - if (ACE_OS::lstat (directory->d_name, &stat_buf) == -1) ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - directory->d_name), + ACE_TEXT ("%p\n"), + tname), -1); switch (stat_buf.st_mode & S_IFMT) @@ -180,8 +201,8 @@ dirent_count (const ACE_TCHAR *dir_path, case S_IFLNK: // Either a file or directory link, so let's find out. if (ACE_OS::stat (directory->d_name, &stat_buf) == -1) ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - directory->d_name), + ACE_TEXT ("%p\n"), + tname), -1); if ((stat_buf.st_mode & S_IFMT) == S_IFDIR) @@ -194,26 +215,27 @@ dirent_count (const ACE_TCHAR *dir_path, default: // Must be a directory. ACE_DEBUG ((LM_DEBUG, "%*sentering subdirectory %s\n", recursion_level * RECURSION_INDENT, - "", - directory->d_name)); - if (dirent_count (directory->d_name, + ACE_TEXT (""), + tname)); + if (dirent_count (tname, local_dir_count, local_file_count, recursion_level + 1) != -1) { - ACE_DEBUG ((LM_DEBUG, - "%*ssubdirectory %s has %d files and %d subdirectories.\n", - recursion_level * RECURSION_INDENT, - "", - directory->d_name, - local_file_count, - local_dir_count)); + ACE_DEBUG + ((LM_DEBUG, + ACE_TEXT ("%*ssubdirectory %s has %d files and %d subdirectories.\n"), + recursion_level * RECURSION_INDENT, + ACE_TEXT (""), + tname, + local_file_count, + local_dir_count)); dir_count++; // Move back up a level. if (ACE_OS::chdir (ACE_TEXT ("..")) == -1) ACE_ERROR_RETURN ((LM_ERROR, - "chdir: %p\n", + ACE_TEXT ("chdir: %p\n"), dir_path), -1); } @@ -231,7 +253,7 @@ dirent_recurse_test (void) int total_files = 0; ACE_DEBUG ((LM_DEBUG, - "Starting directory recursion test for %s\n", + ACE_TEXT ("Starting directory recursion test for %s\n"), ACE_TEXT (TEST_DIR))); if (dirent_count (ACE_TEXT (TEST_DIR), @@ -239,11 +261,11 @@ dirent_recurse_test (void) total_files, 1) == -1) ACE_ERROR_RETURN ((LM_ERROR, - "Directory recursion test failed for %s\n", + ACE_TEXT ("Directory recursion test failed for %s\n"), ACE_TEXT (TEST_DIR)), -1); ACE_DEBUG ((LM_DEBUG, - "Directory recursion test succeeded for %s, read %d files %d dirs\n", + ACE_TEXT ("Directory recursion test succeeded for %s, read %d files %d dirs\n"), ACE_TEXT (TEST_DIR), total_files, total_dirs)); diff --git a/tests/Env_Value_Test.cpp b/tests/Env_Value_Test.cpp index 131197fdd45..ca9674127a0 100644 --- a/tests/Env_Value_Test.cpp +++ b/tests/Env_Value_Test.cpp @@ -44,8 +44,15 @@ run_main (int argc, ACE_TCHAR* []) { ACE_UNUSED_ARG (argc); + // Only Win32 can set wide-char environment strings. So, for all + // others, use char string literals regardless of ACE_USES_WCHAR. +# if defined (ACE_WIN32) ACE_OS::putenv (ACE_TEXT ("TEST_VALUE_POSITIVE=10.2")); ACE_OS::putenv (ACE_TEXT ("TEST_VALUE_NEGATIVE=-10.2")); +# else + ACE_OS::putenv ("TEST_VALUE_POSITIVE=10.2"); + ACE_OS::putenv ("TEST_VALUE_NEGATIVE=-10.2"); +# endif /* ACE_WIN32 */ #else /* ! ACE_HAS_NONSTATIC_OBJECT_MANAGER && ! ACE_LACKS_FORK */ run_main (int argc, ACE_TCHAR * [], ACE_TCHAR *envp[]) { diff --git a/tests/FIFO_Test.cpp b/tests/FIFO_Test.cpp index c1cdef66186..439fb14878d 100644 --- a/tests/FIFO_Test.cpp +++ b/tests/FIFO_Test.cpp @@ -36,8 +36,7 @@ ACE_RCSID(tests, SOCK_Test, "$Id$") #if !defined (ACE_WIN32) -static const ACE_TCHAR ACE_ALPHABET[] = - ACE_TEXT ("abcdefghijklmnopqrstuvwxyz"); +static const char ACE_ALPHABET[] = "abcdefghijklmnopqrstuvwxyz"; // This length is used for the "big buffer" send/receive. static const size_t big_size = (BUFSIZ * 4); @@ -225,7 +224,7 @@ test_fifo_msg (void) int status = 0; // Test status; innocent until proven guilty. #if !defined (ACE_LACKS_FORK) - switch (ACE_OS::fork ("child")) + switch (ACE_OS::fork (ACE_TEXT ("child"))) { case -1: ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("fork failed"))); diff --git a/tests/Log_Msg_Test.cpp b/tests/Log_Msg_Test.cpp index 1afdfb6c737..daff113d3b4 100644 --- a/tests/Log_Msg_Test.cpp +++ b/tests/Log_Msg_Test.cpp @@ -225,7 +225,7 @@ test_log_msg_features (const ACE_TCHAR *program) if (ACE_OS::open (badname, O_RDONLY) == ACE_INVALID_HANDLE) ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%n: (%x), can't open %s%r\n"), + ACE_TEXT ("%n: (%x), can't open %C%r\n"), 10000, badname, cleanup)); @@ -415,7 +415,7 @@ test_ostream (void) ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%s"), + ACE_TEXT ("%C"), buffer)); #endif /* ACE_LACKS_IOSTREAM_TOTALLY */ diff --git a/tests/MEM_Stream_Test.cpp b/tests/MEM_Stream_Test.cpp index 3570fd54960..f9f02627ba1 100644 --- a/tests/MEM_Stream_Test.cpp +++ b/tests/MEM_Stream_Test.cpp @@ -288,7 +288,12 @@ test_reactive (const ACE_TCHAR *prog, ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("spawn_n ()"))); #else ACE_Process_Options opts; - opts.command_line (ACE_TEXT ("%s -p%d -r"), prog, sport); +# if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) + const ACE_TCHAR *cmdline_fmt = ACE_TEXT ("%s -p%d -r"); +# else + const ACE_TCHAR *cmdline_fmt = ACE_TEXT ("%ls -p%d -r"); +# endif /* ACE_WIN32 || !ACE_USES_WCHAR */ + opts.command_line (cmdline_fmt, prog, sport); if (ACE_Process_Manager::instance ()->spawn_n (NUMBER_OF_REACTIVE_CONNECTIONS, opts) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("spawn_n ()"))); @@ -374,7 +379,12 @@ test_concurrent (const ACE_TCHAR *prog, ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("spawn_n()"))); #else ACE_Process_Options opts; - opts.command_line (ACE_TEXT ("%s -p%d -m"), prog, sport); +# if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) + const ACE_TCHAR *cmdline_fmt = ACE_TEXT ("%s -p%d -m"); +# else + const ACE_TCHAR *cmdline_fmt = ACE_TEXT ("%ls -p%d -m"); +# endif /* ACE_WIN32 || !ACE_USES_WCHAR */ + opts.command_line (cmdline_fmt, prog, sport); if (ACE_Process_Manager::instance ()->spawn_n (NUMBER_OF_MT_CONNECTIONS, opts) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("spawn_n()"))); diff --git a/tests/Message_Queue_Test.cpp b/tests/Message_Queue_Test.cpp index 26b50b3f501..af5f2faf0e6 100644 --- a/tests/Message_Queue_Test.cpp +++ b/tests/Message_Queue_Test.cpp @@ -87,11 +87,11 @@ iterator_test (void) { const int ITERATIONS = 5; ACE_TCHAR buffer[ITERATIONS][BUFSIZ]; - // Use queue size from of 32 Kb, instead of the default of 16 Kb - // (defined by ACE_Message_Queue_Base::DEFAULT_HWM), so that the - // test runs on machines with 8Kb pagesizes. + // Use queue size from of 32 Kb (more if using wide-char), instead of the + // default of 16 Kb (defined by ACE_Message_Queue_Base::DEFAULT_HWM), + // so that the test runs on machines with 8Kb pagesizes. #if !defined(_UNICOS) - QUEUE queue (32 * 1024); + QUEUE queue (32 * 1024 * sizeof (ACE_TCHAR)); #else // this works on the Cray, where BUFSIZ is defined as 32Kb QUEUE queue (ITERATIONS * BUFSIZ - 1); diff --git a/tests/Proactor_Test.cpp b/tests/Proactor_Test.cpp index e368a9f5c89..9e1012cd594 100644 --- a/tests/Proactor_Test.cpp +++ b/tests/Proactor_Test.cpp @@ -96,14 +96,14 @@ static int loglevel; // 0 full , 1 only errors static size_t xfer_limit; // Number of bytes for Sender to send. -static ACE_TCHAR complete_message[] = - ACE_TEXT ("GET / HTTP/1.1\r\n") - ACE_TEXT ("Accept: */*\r\n") - ACE_TEXT ("Accept-Language: C++\r\n") - ACE_TEXT ("Accept-Encoding: gzip, deflate\r\n") - ACE_TEXT ("User-Agent: Proactor_Test/1.0 (non-compatible)\r\n") - ACE_TEXT ("Connection: Keep-Alive\r\n") - ACE_TEXT ("\r\n"); +static char complete_message[] = + "GET / HTTP/1.1\r\n" + "Accept: */*\r\n" + "Accept-Language: C++\r\n" + "Accept-Encoding: gzip, deflate\r\n" + "User-Agent: Proactor_Test/1.0 (non-compatible)\r\n" + "Connection: Keep-Alive\r\n" + "\r\n"; class LogLocker { diff --git a/tests/Proactor_Test_IPV6.cpp b/tests/Proactor_Test_IPV6.cpp index c3896bb44de..45d32db07c5 100644 --- a/tests/Proactor_Test_IPV6.cpp +++ b/tests/Proactor_Test_IPV6.cpp @@ -90,14 +90,14 @@ static int loglevel; // 0 full , 1 only errors static size_t xfer_limit; // Number of bytes for Sender to send. -static ACE_TCHAR complete_message[] = - ACE_TEXT ("GET / HTTP/1.1\r\n") - ACE_TEXT ("Accept: */*\r\n") - ACE_TEXT ("Accept-Language: C++\r\n") - ACE_TEXT ("Accept-Encoding: gzip, deflate\r\n") - ACE_TEXT ("User-Agent: Proactor_Test_IPv6/1.0 (non-compatible)\r\n") - ACE_TEXT ("Connection: Keep-Alive\r\n") - ACE_TEXT ("\r\n"); +static char complete_message[] = + "GET / HTTP/1.1\r\n" + "Accept: */*\r\n" + "Accept-Language: C++\r\n" + "Accept-Encoding: gzip, deflate\r\n" + "User-Agent: Proactor_Test_IPv6/1.0 (non-compatible)\r\n" + "Connection: Keep-Alive\r\n" + "\r\n"; class LogLocker { diff --git a/tests/Process_Manager_Test.cpp b/tests/Process_Manager_Test.cpp index 34c3010640e..f42ff34aec2 100644 --- a/tests/Process_Manager_Test.cpp +++ b/tests/Process_Manager_Test.cpp @@ -76,9 +76,16 @@ spawn_child (const ACE_TCHAR *argv0, ACE_Process_Manager &mgr, int sleep_time = 0) { +#if defined (ACE_WIN32) +const ACE_TCHAR *cmdline_format = ACE_TEXT("\"%s\" %s %d"); +#elif !defined (ACE_USES_WCHAR) +const ACE_TCHAR *cmdline_format = ACE_TEXT("%s %s %d"); +#else +const ACE_TCHAR *cmdline_format = ACE_TEXT("%ls %ls %d"); +#endif ACE_Process_Options opts; - opts.command_line (ACE_TEXT("%s %s %d"), + opts.command_line (cmdline_format, argv0, debug_test ? ACE_TEXT ("-d") : ACE_TEXT (""), sleep_time); diff --git a/tests/Process_Mutex_Test.cpp b/tests/Process_Mutex_Test.cpp index 900d44e2fcb..279e1a40b6f 100644 --- a/tests/Process_Mutex_Test.cpp +++ b/tests/Process_Mutex_Test.cpp @@ -157,13 +157,21 @@ run_main (int argc, ACE_TCHAR *argv[]) options.command_line (ACE_TEXT (".") ACE_DIRECTORY_SEPARATOR_STR ACE_TEXT ("Process_Mutex_Test") ACE_PLATFORM_EXE_SUFFIX +#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_TEXT (" -c -n %ls -d"), +#else ACE_TEXT (" -c -n %s -d"), +#endif /* !ACE_WIN32 && ACE_USES_WCHAR */ mutex_name); else options.command_line (ACE_TEXT (".") ACE_DIRECTORY_SEPARATOR_STR ACE_TEXT ("Process_Mutex_Test") ACE_PLATFORM_EXE_SUFFIX +#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) + ACE_TEXT (" -c -n %ls"), +#else ACE_TEXT (" -c -n %s"), +#endif /* !ACE_WIN32 && ACE_USES_WCHAR */ mutex_name); // Spawn <n_processes> child processes that will contend for the diff --git a/tests/Process_Strategy_Test.cpp b/tests/Process_Strategy_Test.cpp index 4bba7e29cfa..46104a724f0 100644 --- a/tests/Process_Strategy_Test.cpp +++ b/tests/Process_Strategy_Test.cpp @@ -680,7 +680,7 @@ run_main (int argc, ACE_TCHAR *argv[]) #if !defined (ACE_LACKS_FORK) // We're running the client and serve as separate processes. - pid_t pid = ACE::fork ("child", + pid_t pid = ACE::fork (ACE_TEXT ("child"), 1); // Avoid zombies. switch (pid) diff --git a/tests/SOCK_Connector_Test.cpp b/tests/SOCK_Connector_Test.cpp index 997621ec257..c59ff63e537 100644 --- a/tests/SOCK_Connector_Test.cpp +++ b/tests/SOCK_Connector_Test.cpp @@ -113,18 +113,20 @@ find_another_host (ACE_TCHAR other_host[]) // an infinite loop on Linux --mas 03-08-2001 while ((h = gethostent ()) != NULL) { - if (ACE_OS::strcmp (h->h_name, ACE_DEFAULT_SERVER_HOST) == 0) + if (ACE_OS::strcmp (h->h_name, + ACE_TEXT_ALWAYS_CHAR (ACE_DEFAULT_SERVER_HOST)) == 0) continue; // AIX just _has_ to be different if (ACE_OS::strcmp (h->h_name, "loopback") == 0) continue; // If not me. - if (ACE_OS::strcmp (h->h_name, other_host) != 0 + if (ACE_OS::strcmp + (h->h_name, ACE_TEXT_ALWAYS_CHAR (other_host)) != 0 && ACE_OS::strcmp (h->h_name, un.nodename) != 0) { ACE_OS::strcpy (candidate[candidate_count].host_name, - h->h_name); + ACE_TEXT_CHAR_TO_TCHAR (h->h_name)); if (++candidate_count >= MAX_CANDIDATES) break; } diff --git a/tests/SOCK_Dgram_Test.cpp b/tests/SOCK_Dgram_Test.cpp index 3f600b18ef2..54bbd705204 100644 --- a/tests/SOCK_Dgram_Test.cpp +++ b/tests/SOCK_Dgram_Test.cpp @@ -1,4 +1,4 @@ -// // $Id$ +// $Id$ // =========================================================================== // // = LIBRARY @@ -152,7 +152,7 @@ spawn (int proto) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) started server at port %d\n"), server_addr.get_port_number ())); #if !defined (ACE_LACKS_FORK) - switch (ACE_OS::fork ("child")) + switch (ACE_OS::fork (ACE_TEXT ("child"))) { case -1: ACE_ERROR ((LM_ERROR, diff --git a/tests/SOCK_Send_Recv_Test.cpp b/tests/SOCK_Send_Recv_Test.cpp index 8b393e86534..5ceb4ca60c7 100644 --- a/tests/SOCK_Send_Recv_Test.cpp +++ b/tests/SOCK_Send_Recv_Test.cpp @@ -338,7 +338,7 @@ spawn (void) server_addr.get_port_number ())); #if !defined (ACE_LACKS_FORK) - switch (ACE_OS::fork ("child")) + switch (ACE_OS::fork (ACE_TEXT ("child"))) { case -1: ACE_ERROR ((LM_ERROR, diff --git a/tests/SOCK_Test.cpp b/tests/SOCK_Test.cpp index bbd39ee6748..6472711a857 100644 --- a/tests/SOCK_Test.cpp +++ b/tests/SOCK_Test.cpp @@ -226,7 +226,7 @@ spawn (void) server_addr.get_port_number ())); #if !defined (ACE_LACKS_FORK) - switch (ACE_OS::fork ("child")) + switch (ACE_OS::fork (ACE_TEXT ("child"))) { case -1: ACE_ERROR ((LM_ERROR, diff --git a/tests/SV_Shared_Memory_Test.cpp b/tests/SV_Shared_Memory_Test.cpp index 9e11ef2d443..7f22a2da468 100644 --- a/tests/SV_Shared_Memory_Test.cpp +++ b/tests/SV_Shared_Memory_Test.cpp @@ -174,7 +174,7 @@ run_main (int, ACE_TCHAR *[]) ACE_ASSERT (parent_synch->open (SEM_KEY_2, ACE_SV_Semaphore_Complex::ACE_CREATE, 0) != -1); - switch (ACE_OS::fork ("SV_Shared_Memory_Test.cpp")) + switch (ACE_OS::fork (ACE_TEXT ("SV_Shared_Memory_Test.cpp"))) { case -1: ACE_ERROR_RETURN ((LM_ERROR, diff --git a/tests/Service_Config_Test.WCHAR_T.conf b/tests/Service_Config_Test.WCHAR_T.conf Binary files differnew file mode 100644 index 00000000000..a36db0600c9 --- /dev/null +++ b/tests/Service_Config_Test.WCHAR_T.conf diff --git a/tests/Service_Config_Test.WCHAR_T.conf.xml b/tests/Service_Config_Test.WCHAR_T.conf.xml Binary files differnew file mode 100644 index 00000000000..88e7c26e8eb --- /dev/null +++ b/tests/Service_Config_Test.WCHAR_T.conf.xml diff --git a/tests/Service_Config_Test.cpp b/tests/Service_Config_Test.cpp index 1a9e4fe7817..6006d661a6f 100644 --- a/tests/Service_Config_Test.cpp +++ b/tests/Service_Config_Test.cpp @@ -122,23 +122,29 @@ run_test (int argc, ACE_TCHAR *argv[]) { ACE_ARGV new_argv; - const ACE_TCHAR svc_conf[] = #if defined (ACE_USES_WCHAR) - // When using full Unicode support, use the version of the Service - // Configurator file that is UTF-16 encoded. - // - // @@ Note: Some platforms may want other encoding (e.g. UTF-32). - // - // iconv(1) found on Linux and Solaris, for example, can - // be used to convert between encodings. - // - // Byte ordering is also an issue, so we should be - // generating this file on-the-fly from the UTF-8 encoded - // file by using functions like iconv(1) or iconv(3). + // When using full Unicode support, use the version of the Service + // Configurator file appropriate to the platform. + // For example, Windows Unicode uses UTF-16. + // + // iconv(1) found on Linux and Solaris, for example, can + // be used to convert between encodings. + // + // Byte ordering is also an issue, so we should be + // generating this file on-the-fly from the UTF-8 encoded + // file by using functions like iconv(1) or iconv(3). +# if defined (ACE_WIN32) + const ACE_TCHAR svc_conf[] = ACE_TEXT ("Service_Config_Test.UTF-16") ACE_TEXT (ACE_DEFAULT_SVC_CONF_EXT); +# else + const ACE_TCHAR svc_conf[] = + ACE_TEXT ("Service_Config_Test.WCHAR_T") + ACE_TEXT (ACE_DEFAULT_SVC_CONF_EXT); +# endif /* ACE_WIN32 */ #else // ASCII (UTF-8) encoded Service Configurator file. + const ACE_TCHAR svc_conf[] = ACE_TEXT ("Service_Config_Test") ACE_TEXT (ACE_DEFAULT_SVC_CONF_EXT); #endif /* ACE_USES_WCHAR */ diff --git a/tests/Signal_Test.cpp b/tests/Signal_Test.cpp index 5d8ddda4b1f..c13467e6773 100644 --- a/tests/Signal_Test.cpp +++ b/tests/Signal_Test.cpp @@ -244,7 +244,7 @@ worker_parent (void *arg) // Store the parent's process id so we can pass it to the child // portably. Also, pass the test number, as well. ACE_OS::sprintf (pid_str, - "-p %ld -t %d", + ACE_TEXT ("-p %ld -t %d"), ACE_static_cast (long, parent_pid), test_number); @@ -370,9 +370,9 @@ run_test (ACE_THR_FUNC worker, // Parse the command-line arguments and set options. static void -parse_args (int argc, char *argv[]) +parse_args (int argc, ACE_TCHAR *argv[]) { - ACE_Get_Opt get_opt (argc, argv, "i:chp:t:"); + ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("i:chp:t:")); int c; diff --git a/tests/test_config.h b/tests/test_config.h index f8e0c38ed85..74e6934f5da 100644 --- a/tests/test_config.h +++ b/tests/test_config.h @@ -120,9 +120,14 @@ const size_t ACE_MAX_THREADS = 4; # define ACE_MAIN ace_main #endif /* ghs */ #else /* ! VXWORKS */ +# if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR) +# define ACE_INIT_LOG_FMT ACE_TEXT ("%ls%ls%ls") +# else +# define ACE_INIT_LOG_FMT ACE_TEXT ("%s%s%s") +# endif /* !ACE_WIN32 && ACE_USES_WCHAR */ #define ACE_INIT_LOG(NAME) \ ACE_TCHAR temp[MAXPATHLEN]; \ - ACE_OS::sprintf (temp, ACE_TEXT ("%s%s%s"), \ + ACE_OS::sprintf (temp, ACE_INIT_LOG_FMT, \ ACE_LOG_DIRECTORY, \ ACE::basename (NAME, ACE_DIRECTORY_SEPARATOR_CHAR), \ ACE_LOG_FILE_EXT_NAME); \ |