diff options
Diffstat (limited to 'ACE/ace')
-rw-r--r-- | ACE/ace/Argv_Type_Converter.cpp | 20 | ||||
-rw-r--r-- | ACE/ace/Log_Msg.cpp | 2 | ||||
-rw-r--r-- | ACE/ace/OS_NS_ctype.inl | 7 | ||||
-rw-r--r-- | ACE/ace/OS_NS_stdio.cpp | 38 | ||||
-rw-r--r-- | ACE/ace/config-win32-msvc.h | 1 |
5 files changed, 56 insertions, 12 deletions
diff --git a/ACE/ace/Argv_Type_Converter.cpp b/ACE/ace/Argv_Type_Converter.cpp index 178d25d9156..e16076818a4 100644 --- a/ACE/ace/Argv_Type_Converter.cpp +++ b/ACE/ace/Argv_Type_Converter.cpp @@ -108,10 +108,11 @@ ACE_Argv_Type_Converter::initialize (void) void ACE_Argv_Type_Converter::align_char_with_wchar (void) { - for (int wchar_argv_index = 0; wchar_argv_index < this->saved_argc_; - ++wchar_argv_index) + int wchar_argv_index = 0; + wchar_t* match_argv = this->wchar_argv_[0]; // pick the initial entry + + while (wchar_argv_index < this->saved_argc_) { - wchar_t *match_argv = this->wchar_argv_[wchar_argv_index]; // if n'th entries of both argv lists are different if (ACE_OS::strcmp (this->char_argv_[wchar_argv_index], ACE_TEXT_ALWAYS_CHAR (match_argv)) != 0) @@ -131,6 +132,9 @@ ACE_Argv_Type_Converter::align_char_with_wchar (void) } } } + + // move to the next wchar argv list entry + match_argv = this->wchar_argv_[++wchar_argv_index]; } this->cleanup (); @@ -139,10 +143,11 @@ ACE_Argv_Type_Converter::align_char_with_wchar (void) void ACE_Argv_Type_Converter::align_wchar_with_char (void) { - for (int char_argv_index = 0; char_argv_index < saved_argc_; - ++char_argv_index) + int char_argv_index = 0; + char* match_argv = this->char_argv_[0]; // pick the initial entry + + while (char_argv_index < saved_argc_) { - char* match_argv = this->char_argv_[char_argv_index]; // if n'th entries of both argv lists are different if (ACE_OS::strcmp ( ACE_TEXT_ALWAYS_CHAR (this->wchar_argv_[char_argv_index]), @@ -163,6 +168,9 @@ ACE_Argv_Type_Converter::align_wchar_with_char (void) } } } + + // move to the next wchar argv list entry + match_argv = this->char_argv_[++char_argv_index]; } this->cleanup(); diff --git a/ACE/ace/Log_Msg.cpp b/ACE/ace/Log_Msg.cpp index 5c6d75287ac..ce445120de9 100644 --- a/ACE/ace/Log_Msg.cpp +++ b/ACE/ace/Log_Msg.cpp @@ -1025,7 +1025,7 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str, // bp is pointer to where to put next part of logged message. // bspace is the number of characters remaining in msg_. ACE_TCHAR *bp = const_cast<ACE_TCHAR *> (this->msg ()); - size_t bspace = ACE_MAXLOGMSGLEN; // Leave room for Nul term. + size_t bspace = ACE_Log_Record::MAXLOGMSGLEN; // Leave room for Nul term. if (this->msg_off_ <= ACE_Log_Record::MAXLOGMSGLEN) bspace -= static_cast<size_t> (this->msg_off_); diff --git a/ACE/ace/OS_NS_ctype.inl b/ACE/ace/OS_NS_ctype.inl index 977ce001ad5..dce7425a0a6 100644 --- a/ACE/ace/OS_NS_ctype.inl +++ b/ACE/ace/OS_NS_ctype.inl @@ -123,10 +123,9 @@ ACE_INLINE int ACE_OS::ace_isprint (ACE_TCHAR c) { #if defined (ACE_USES_WCHAR) -# if defined (ACE_LACKS_CORRECT_ISWPRINT_TAB) - /* The MS CRT has the bug that for tab (\t) iswprint returns true instead of - * false. This has been reported to Microsoft: - * https://connect.microsoft.com/VisualStudio/feedback ID# 381915 +# if defined (_WIN32_WCE) && (_WIN32_WCE <= 0x600) + /* WinCE 6 and earlier have the bug that for tab (\t) the + * iswprint returns true instead of false */ if (c == 0x9) { diff --git a/ACE/ace/OS_NS_stdio.cpp b/ACE/ace/OS_NS_stdio.cpp index 5e53976c5bd..1e5c75dce85 100644 --- a/ACE/ace/OS_NS_stdio.cpp +++ b/ACE/ace/OS_NS_stdio.cpp @@ -74,6 +74,38 @@ ACE_OS::ace_flock_t::dump (void) const /*****************************************************************************/ +#if defined (ACE_USES_WCHAR) +void ACE_OS::checkUnicodeFormat (FILE* fp) +{ + if (fp != 0) + { + // Due to the ACE_TCHAR definition, all default input files, such as + // svc.conf, have to be in Unicode format (small endian) on WinCE + // because ACE has all 'char' converted into ACE_TCHAR. + // However, for TAO, ASCII files, such as IOR file, can still be read + // and be written without any error since given buffers are all in 'char' + // type instead of ACE_TCHAR. Therefore, it is user's reponsibility to + // select correct buffer type. + + // At this point, check if the file is Unicode or not. + ACE_UINT16 first_two_bytes = 0; + size_t const numRead = + ACE_OS::fread(&first_two_bytes, sizeof (first_two_bytes), 1, fp); + + if (numRead <= 1) + { + if ((first_two_bytes != 0xFFFE) && // not a small endian Unicode file + (first_two_bytes != 0xFEFF)) // not a big endian Unicode file + { + // set file pointer back to the beginning + ACE_OS::fseek(fp, 0, SEEK_SET); + } + } + // if it is a Unicode file, file pointer will be right next to the first + // two-bytes + } +} +#endif // ACE_USES_WCHAR #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) namespace @@ -161,6 +193,9 @@ ACE_OS::fopen (const char *filename, # endif /* defined(ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)) */ if (fp != 0) { +# if defined (ACE_USES_WCHAR) + checkUnicodeFormat(fp); +# endif // ACE_USES_WCHAR return fp; } ::_close (fd); @@ -216,6 +251,9 @@ ACE_OS::fopen (const wchar_t *filename, # endif /* defined(ACE_HAS_NONCONST_FDOPEN) && !defined (ACE_USES_WCHAR)) */ if (fp != 0) { +# if defined (ACE_USES_WCHAR) + checkUnicodeFormat(fp); +# endif // ACE_USES_WCHAR return fp; } ::_close (fd); diff --git a/ACE/ace/config-win32-msvc.h b/ACE/ace/config-win32-msvc.h index 21fc60a2e58..8fe6272e977 100644 --- a/ACE/ace/config-win32-msvc.h +++ b/ACE/ace/config-win32-msvc.h @@ -133,7 +133,6 @@ #define ACE_LACKS_ISBLANK #define ACE_LACKS_ISWBLANK -#define ACE_LACKS_CORRECT_ISWPRINT_TAB #define ACE_ISCTYPE_EQUIVALENT ::_isctype // Turn off warnings for /W4 |