(svn r10562) -Fix: most of the MorphOS issues; MorphOS doesn't know about wchars, so disable all code that has to use wchars for MorphOS.
authorrubidium
Sat, 14 Jul 2007 20:30:35 +0000
changeset 7751 99bcdf28a226
parent 7750 0faa5536deb0
child 7752 6e8fa98d98d3
(svn r10562) -Fix: most of the MorphOS issues; MorphOS doesn't know about wchars, so disable all code that has to use wchars for MorphOS.
src/misc/blob.hpp
src/misc/str.hpp
src/misc/strapi.hpp
src/stdafx.h
--- a/src/misc/blob.hpp	Sat Jul 14 20:21:02 2007 +0000
+++ b/src/misc/blob.hpp	Sat Jul 14 20:30:35 2007 +0000
@@ -59,7 +59,9 @@
 	/** type used as class member */
 	union {
 		bitem_t    *m_pData;    ///< ptr to the first byte of data
+#if defined(HAS_WCHAR)
 		wchar_t    *m_pwData;   ///< ptr to the first byte of data
+#endif /* HAS_WCHAR */
 		CHdr       *m_pHdr_1;   ///< ptr just after the CHdr holding m_size and m_max_size
 	} ptr_u;
 
--- a/src/misc/str.hpp	Sat Jul 14 20:21:02 2007 +0000
+++ b/src/misc/str.hpp	Sat Jul 14 20:30:35 2007 +0000
@@ -183,7 +183,9 @@
 
 typedef CStrT<char   , false> CStrA;   ///< Case sensitive ANSI/UTF-8 string
 typedef CStrT<char   , true > CStrCiA; ///< Case insensitive ANSI/UTF-8 string
+#if defined(HAS_WCHAR)
 typedef CStrT<wchar_t, false> CStrW;   ///< Case sensitive unicode string
 typedef CStrT<wchar_t, true > CStrCiW; ///< Case insensitive unicode string
+#endif /* HAS_WCHAR */
 
 #endif /* STR_HPP */
--- a/src/misc/strapi.hpp	Sat Jul 14 20:21:02 2007 +0000
+++ b/src/misc/strapi.hpp	Sat Jul 14 20:30:35 2007 +0000
@@ -6,12 +6,15 @@
 #define  STRAPI_HPP
 
 #include <string.h>
+
+#if defined(HAS_WCHAR)
 #include <wchar.h>
 
 #if !defined(_MSC_VER)
 #define _stricmp strcmp
 #define _wcsicmp wcscmp
-#endif //!_MSC_VER
+#endif /* !defined(_MSC_VER) */
+#endif /* HAS_WCHAR */
 
 /** String API mapper base - just mapping by character type, not by case sensitivity yet.
 	* Class template CStrApiBaseT declaration is general, but following inline method
@@ -32,35 +35,37 @@
 	return ::strlen(s);
 }
 
-/** ::strlen wrapper specialization for wchar_t */
-template <> /*static*/ inline size_t CStrApiBaseT<wchar_t>::StrLen(const wchar_t *s)
-{
-	return ::wcslen(s);
-}
-
 /** ::vsprintf wrapper specialization for char */
 template <> /*static*/ inline int CStrApiBaseT<char>::SPrintFL(char *buf, size_t count, const char *fmt, va_list args)
 {
 #if defined(_MSC_VER) && (_MSC_VER >= 1400) // VC 8.0 and above
 	return ::vsnprintf_s(buf, count, count - 1, fmt, args);
-#else // ! VC 8.0 and above
+#else /* ! VC 8.0 and above */
 	return ::vsnprintf(buf, count, fmt, args);
 #endif
 }
 
+#if defined(HAS_WCHAR)
+/** ::strlen wrapper specialization for wchar_t */
+template <> /*static*/ inline size_t CStrApiBaseT<wchar_t>::StrLen(const wchar_t *s)
+{
+	return ::wcslen(s);
+}
+
 /** ::vsprintf wrapper specialization for wchar_t */
 template <> /*static*/ inline int CStrApiBaseT<wchar_t>::SPrintFL(wchar_t *buf, size_t count, const wchar_t *fmt, va_list args)
 {
 #if defined(_MSC_VER) && (_MSC_VER >= 1400) // VC 8.0 and above
 	return ::_vsnwprintf_s(buf, count, count - 1, fmt, args);
-#else // ! VC 8.0 and above
+#else /* ! VC 8.0 and above */
 # if defined(_WIN32)
 	 return ::_vsnwprintf(buf, count, fmt, args);
-# else // !_WIN32
+# else /* !_WIN32 */
 	 return ::vswprintf(buf, count, fmt, args);
-# endif // !_WIN32
+# endif /* !_WIN32 */
 #endif
 }
+#endif /* HAS_WCHAR */
 
 
 
@@ -81,6 +86,7 @@
 	return ::_stricmp(s1, s2);
 }
 
+#if defined(HAS_WCHAR)
 template <> /*static*/ inline int CStrApiT<wchar_t, false>::StrCmp(const wchar_t *s1, const wchar_t *s2)
 {
 	return ::wcscmp(s1, s2);
@@ -90,5 +96,6 @@
 {
 	return ::_wcsicmp(s1, s2);
 }
+#endif /* HAS_WCHAR */
 
 #endif /* STRAPI_HPP */
--- a/src/stdafx.h	Sat Jul 14 20:21:02 2007 +0000
+++ b/src/stdafx.h	Sat Jul 14 20:30:35 2007 +0000
@@ -341,4 +341,12 @@
 CDECL error(const char *str, ...);
 #define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__)
 
+#if !defined(MORPHOS)
+/* MorphOS doesn't know wchars, the rest does :( */
+#define HAS_WCHAR
+#else
+/* And MorphOS doesn't have C++ conformant _stricmp... */
+#define _stricmp stricmp
+#endif /* !defined(MORHPOS) */
+
 #endif /* STDAFX_H */