⛏️ index : buildtools.git

author Adrien Destugues - PulkoMandy <pulkomandy@pulkomandy.tk> 2012-10-27 15:56:05.0 +02:00:00
committer Adrien Destugues - PulkoMandy <pulkomandy@pulkomandy.tk> 2012-10-27 15:56:05.0 +02:00:00
commit
5f2852400d6c63ab5d63c9a19ae3338151ebf3fb [patch]
tree
df0beadeb500ea06cff9e997fc107f0d28a689ab
parent
72f47ffea0536ad5aa38bc5395d3eee959d8002c
download
5f2852400d6c63ab5d63c9a19ae3338151ebf3fb.tar.gz

Allow use of c_str() when <charT> != char http://gcc.gnu.org/ml/libstdc++-prs/2000-q4/msg00004.html This allows use on std::wstring, and others.



Diff

 legacy/gcc/libstdc++/std/bastring.h | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/legacy/gcc/libstdc++/std/bastring.h b/legacy/gcc/libstdc++/std/bastring.h
index 9749c3c..774f7be 100644
--- a/legacy/gcc/libstdc++/std/bastring.h
+++ a/legacy/gcc/libstdc++/std/bastring.h
@@ -38,6 +38,10 @@
// NOTE : This does NOT conform to the draft standard and is likely to change
#include <alloc.h>

#ifdef __HAIKU__
#	include <config/types.h>
#endif

extern "C++" {
class istream; class ostream;

@@ -61,12 +65,10 @@

#endif

#if defined(__BEOS__) || defined(__HAIKU__)

// Needed for atomic_add():
typedef long int32;
typedef volatile long vint32;
extern "C" int32 atomic_add(vint32* value, int32 addvalue);
#endif	/* __BEOS__ || __HAIKU__ */
#ifdef __HAIKU__
extern "C" __haiku_int32 atomic_add(volatile __haiku_int32* value,
	__haiku_int32 addvalue);
#endif	/* __HAIKU__ */

template <class charT, class traits = string_char_traits<charT>,
	  class Allocator = alloc >
@@ -79,9 +81,9 @@

    charT* data () { return reinterpret_cast<charT *>(this + 1); }
    charT& operator[] (size_t s) { return data () [s]; }
#if defined(__BEOS__) || defined(__HAIKU__)

    charT* grab () { if (selfish) return clone (); atomic_add((vint32*) &ref, 1); return data (); }
    void release() { if (atomic_add((int32*) &ref, -1) == 1) delete this; }
#ifdef __HAIKU__
    charT* grab () { if (selfish) return clone (); atomic_add((volatile __haiku_int32*) &ref, 1); return data (); }
    void release() { if (atomic_add((__haiku_int32*) &ref, -1) == 1) delete this; }
#else
    charT* grab () { if (selfish) return clone (); ++ref; return data (); }
#if defined __i486__ || defined __i586__ || defined __i686__

@@ -119,7 +121,7 @@
#else
    void release () { if (--ref == 0) delete this; }
#endif
#endif /* __BEOS__ || __HAIKU__ */
#endif /* __HAIKU__ */
    inline static void * operator new (size_t, size_t);
    inline static void operator delete (void *);
    inline static Rep* create (size_t);
@@ -348,7 +350,10 @@

public:
  const charT* c_str () const
    { if (length () == 0) return ""; terminate (); return data (); }
    {
	  static const charT null_str[1] = {0};
	  if (length () == 0) return null_str; terminate (); return data ();
	}
  void resize (size_type n, charT c);
  void resize (size_type n)
    { resize (n, eos ()); }
@@ -405,7 +410,13 @@

  int compare (const basic_string& str, size_type pos = 0, size_type n = npos) const;
  // There is no 'strncmp' equivalent for charT pointers.

  // BeOS bogus version
  int compare (const charT* s, size_type pos, size_type n) const;

  // Correct std C++ prototype
  int compare (size_type pos, size_type n, const charT* s) const
    { return compare(s, pos, n); }
  int compare (const charT* s, size_type pos = 0) const
    { return compare (s, pos, traits::length (s)); }