Bug/Fix for egcs 1.1.1 STL wstring
Baron Roberts
baron@peanut.engr.sgi.com
Thu Jan 28 22:48:00 GMT 1999
BUG: STL wstring support broken in egcs 1.1.1 on RedHat Linux 5.2
-----------------------------------------------------------------
The STL wstring class is commented out in the <string> header file
thereby preventing its use. Since wstring is part of the ISO standard
STL this was a real showstopper for development. It turns out that
there were a few trivial bugs in a few supporting header files that
prevented programs from compiling that used wstring.
The fixes effect three files:
libstdc++/string
libstdc++/std/straits.h
libstdc++/std/bastring.h
ChangeLog entries and diff -cp follow.
libstdc++ ChangeLog
-------------------
Thu Jan 28 21:31:58 1999 Baron Roberts <baron@sgi.com>
* string: Uncomment wstring declaration
* std/straits.h: Remove #if 0/#endif from around
struct string_char_traits <wchar_t>.
#include <wchar.h>.
Add missing definition for wchar_t move method.
Add empty() method for trait-based empty string return.
* std/bastring.h (c_str): Change return of "" to return of
traits::empty() call so that proper empty string is returned
based on the character type (i.e. "" or L"").
egcs-1.1.1/libstdc++/string
---------------------------
*** ../../egcs-1.1.1/libstdc++/string Thu Oct 9 23:56:52 1997
--- string Thu Jan 28 21:31:58 1999
***************
*** 7,13 ****
extern "C++" {
typedef basic_string <char> string;
! // typedef basic_string <wchar_t> wstring;
} // extern "C++"
#endif
--- 7,13 ----
extern "C++" {
typedef basic_string <char> string;
! typedef basic_string <wchar_t> wstring;
} // extern "C++"
#endif
egcs-1.1.1/libstdc++/std/straits.h
----------------------------------
*** ../../../egcs-1.1.1/libstdc++/std/straits.h Thu Aug 21 15:58:36 1997
--- straits.h Thu Jan 28 21:45:24 1999
*************** struct string_char_traits {
*** 51,56 ****
--- 51,57 ----
static bool lt (const char_type& c1, const char_type& c2)
{ return (c1 < c2); }
static char_type eos () { return char_type(); } // the null character
+ static char_type* empty() { return ""; }
static bool is_del(char_type a) { return 0; }
// characteristic function for delimiters of charT
*************** struct string_char_traits <char> {
*** 117,122 ****
--- 118,124 ----
static bool lt (const char_type& c1, const char_type& c2)
{ return (c1 < c2); }
static char_type eos () { return 0; }
+ static char_type* empty() { return ""; }
static bool is_del(char_type a) { return isspace(a); }
static int compare (const char_type* s1, const char_type* s2, size_t n)
*************** struct string_char_traits <char> {
*** 131,138 ****
{ return (char_type*) memset (s1, c, n); }
};
- #if 0
#include <cwctype>
struct string_char_traits <wchar_t> {
typedef wchar_t char_type;
--- 133,140 ----
{ return (char_type*) memset (s1, c, n); }
};
#include <cwctype>
+ #include <wchar.h>
struct string_char_traits <wchar_t> {
typedef wchar_t char_type;
*************** struct string_char_traits <wchar_t> {
*** 145,150 ****
--- 147,153 ----
static bool lt (const char_type& c1, const char_type& c2)
{ return (c1 < c2); }
static char_type eos () { return 0; }
+ static char_type* empty() { return L""; }
static bool is_del(char_type a) { return iswspace(a); }
static int compare (const char_type* s1, const char_type* s2, size_t n)
*************** struct string_char_traits <wchar_t> {
*** 153,161 ****
{ return wcslen (s); }
static char_type* copy (char_type* s1, const char_type* s2, size_t n)
{ return wmemcpy (s1, s2, n); }
static char_type* set (char_type* s1, const char_type& c, size_t n)
{ return wmemset (s1, c, n); }
};
- #endif
} // extern "C++"
#endif
--- 156,165 ----
{ return wcslen (s); }
static char_type* copy (char_type* s1, const char_type* s2, size_t n)
{ return wmemcpy (s1, s2, n); }
+ static char_type* move (char_type* s1, const char_type* s2, size_t n)
+ { return (char_type*) wmemmove (s1, s2, n); }
static char_type* set (char_type* s1, const char_type& c, size_t n)
{ return wmemset (s1, c, n); }
};
} // extern "C++"
#endif
egcs-1.1.1/libstdc++/std/bastring.h
-----------------------------------
*** ../../../egcs-1.1.1/libstdc++/std/bastring.h Mon Jul 6 03:35:56 1998
--- bastring.h Thu Jan 28 22:14:35 1999
*************** private:
*** 298,304 ****
public:
const charT* c_str () const
! { if (length () == 0) return ""; terminate (); return data (); }
void resize (size_type n, charT c);
void resize (size_type n)
{ resize (n, eos ()); }
--- 298,304 ----
public:
const charT* c_str () const
! { if (length () == 0) return traits::empty(); terminate (); return data (); }
void resize (size_type n, charT c);
void resize (size_type n)
{ resize (n, eos ()); }
____________________________________________________
Baron Roberts Phone (650) 933-1653
http://www.sgi.com mailto:baron@sgi.com
Application Technology Group, Silicon Graphics Inc.
____________________________________________________
More information about the Gcc-bugs
mailing list