From 1496ef1851bd95279a6c0eae83218e7512c414c8 Mon Sep 17 00:00:00 2001 From: phil Date: Tue, 17 Dec 1996 18:55:08 +0000 Subject: [PATCH] Import of libg++ 2.7.2. --- gnu/lib/libg++/include/gen/VHMap.ccP | 2 +- gnu/lib/libg++/include/gen/Vec.ccP | 18 +++- gnu/lib/libg++/libg++/genclass/genclass.sh | 4 +- gnu/lib/libg++/libg++/src/AllocRing.cc | 2 +- gnu/lib/libg++/libg++/src/Binomial.h | 4 +- gnu/lib/libg++/libg++/src/BitSet.cc | 27 ++--- gnu/lib/libg++/libg++/src/BitSet.h | 86 +++++++-------- gnu/lib/libg++/libg++/src/Integer.h | 69 +++++++----- gnu/lib/libg++/libg++/src/Makefile | 8 +- gnu/lib/libg++/libg++/src/Regex.cc | 9 ++ gnu/lib/libg++/libg++/src/String.cc | 12 +-- gnu/lib/libg++/libg++/src/bitlcomp.c | 4 +- gnu/lib/libg++/libg++/src/bitprims.h | 5 +- gnu/lib/libg++/libg++/src/shlib_version | 2 +- gnu/lib/libg++/libio/Makefile | 18 ++-- gnu/lib/libg++/libio/_G_config.h | 41 +++++++- gnu/lib/libg++/libio/cleanup.c | 2 + gnu/lib/libg++/libio/filebuf.cc | 8 ++ gnu/lib/libg++/libio/filedoalloc.c | 10 +- gnu/lib/libg++/libio/fileops.c | 77 ++++++++------ gnu/lib/libg++/libio/floatconv.c | 1 + gnu/lib/libg++/libio/fstream.h | 4 +- gnu/lib/libg++/libio/genops.c | 23 +++- gnu/lib/libg++/libio/indstream.cc | 7 +- gnu/lib/libg++/libio/indstream.h | 1 + gnu/lib/libg++/libio/iopopen.c | 4 +- gnu/lib/libg++/libio/iosetvbuf.c | 3 +- gnu/lib/libg++/libio/iostdio.h | 12 ++- gnu/lib/libg++/libio/iostream.h | 8 +- gnu/lib/libg++/libio/libio.h | 1 + gnu/lib/libg++/libio/libioP.h | 13 +++ gnu/lib/libg++/libio/shlib_version | 2 +- gnu/lib/libg++/libio/stdiostream.h | 4 +- gnu/lib/libg++/libio/stdstreams.cc | 14 ++- gnu/lib/libg++/libio/stream.cc | 26 +++++ gnu/lib/libg++/libio/stream.h | 2 + gnu/lib/libg++/libio/streambuf.h | 4 +- gnu/lib/libg++/libio/strfile.h | 10 +- gnu/lib/libg++/libio/strops.c | 117 +++++++++++---------- gnu/lib/libg++/libio/strstream.cc | 66 ++---------- gnu/lib/libg++/libio/strstream.h | 22 ++-- gnu/lib/libg++/libiostream/shlib_version | 2 +- gnu/lib/libg++/librx/rx.c | 5 +- gnu/lib/libg++/libstdc++/queue | 2 +- gnu/lib/libg++/libstdc++/shlib_version | 2 +- gnu/lib/libg++/libstdc++/std/bastring.cc | 14 ++- gnu/lib/libg++/libstdc++/std/bastring.h | 12 +-- gnu/lib/libg++/libstdc++/stl/deque.h | 3 + gnu/lib/libg++/libstdc++/typeinfoi.cc | 20 ++-- 49 files changed, 471 insertions(+), 341 deletions(-) diff --git a/gnu/lib/libg++/include/gen/VHMap.ccP b/gnu/lib/libg++/include/gen/VHMap.ccP index d3f2fcfc835e..a24be1e5bfa0 100644 --- a/gnu/lib/libg++/include/gen/VHMap.ccP +++ b/gnu/lib/libg++/include/gen/VHMap.ccP @@ -169,7 +169,7 @@ void VHMap::resize(unsigned int newsize) (*this)[oldtab[i]] = oldcont[i]; delete [] oldtab; delete [] oldcont; - delete oldstatus; + delete [] oldstatus; } Pix VHMap::first() diff --git a/gnu/lib/libg++/include/gen/Vec.ccP b/gnu/lib/libg++/include/gen/Vec.ccP index ac3825b0b8de..d03e0bba4c4b 100644 --- a/gnu/lib/libg++/include/gen/Vec.ccP +++ b/gnu/lib/libg++/include/gen/Vec.ccP @@ -332,9 +332,9 @@ static int gsort ( *base_ptr, int total_elems, Comparator cmp) *left_ptr; *right_ptr; stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */ - stack_node *top = stack + 1; + stack_node *top = stack; - while (STACK_NOT_EMPTY) + for (;;) { { *pivot = &pivot_buffer; @@ -362,7 +362,10 @@ static int gsort ( *base_ptr, int total_elems, Comparator cmp) /* Here's the famous ``collapse the walls'' section of quicksort. Gotta like those tight inner loops! They are the main reason - that this algorithm runs much faster than others. */ + that this algorithm runs much faster than others. + + [Yeah, but there is a function call in the inner loop, + which makes the speed claim rather dubious. --Per Bothner] */ do { while ((*cmp) (*left_ptr, *pivot) < 0) @@ -395,8 +398,13 @@ static int gsort ( *base_ptr, int total_elems, Comparator cmp) if ((right_ptr - lo) <= max_thresh) { - if ((hi - left_ptr) <= max_thresh) /* Ignore both small partitions. */ - POP (lo, hi); + if ((hi - left_ptr) <= max_thresh) + { /* Ignore both small partitions. */ + if (STACK_NOT_EMPTY) + POP (lo, hi); + else + break; /* No pending partitions - we're done. */ + } else /* Ignore small left partition. */ lo = left_ptr; } diff --git a/gnu/lib/libg++/libg++/genclass/genclass.sh b/gnu/lib/libg++/libg++/genclass/genclass.sh index 5db4bca4dff0..b740a317d51e 100644 --- a/gnu/lib/libg++/libg++/genclass/genclass.sh +++ b/gnu/lib/libg++/libg++/genclass/genclass.sh @@ -49,9 +49,9 @@ case "$1" in # # -version # - # 2.7.1 is substituted by the build process. + # 2.7.2 is substituted by the build process. # We currently use the libg++ version number (extracted from ../Makefile). - echo "$name: version 2.7.1" ; + echo "$name: version 2.7.2" ; exit 0; ;; -requires) diff --git a/gnu/lib/libg++/libg++/src/AllocRing.cc b/gnu/lib/libg++/libg++/src/AllocRing.cc index 519f36486d1a..883288ab0480 100644 --- a/gnu/lib/libg++/libg++/src/AllocRing.cc +++ b/gnu/lib/libg++/libg++/src/AllocRing.cc @@ -24,7 +24,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include AllocRing::AllocRing(int max) - :n(max), current(0), nodes(new AllocQNode[max]) + :nodes(new AllocQNode[max]), n(max), current(0) { for (int i = 0; i < n; ++i) { diff --git a/gnu/lib/libg++/libg++/src/Binomial.h b/gnu/lib/libg++/libg++/src/Binomial.h index 8ce241d6f4e0..58afa854caf7 100644 --- a/gnu/lib/libg++/libg++/src/Binomial.h +++ b/gnu/lib/libg++/libg++/src/Binomial.h @@ -34,7 +34,7 @@ public: int n(int xn); double u(); - double u(int xu); + double u(double xu); virtual double operator()(); @@ -50,6 +50,6 @@ inline int Binomial::n() { return pN; } inline int Binomial::n(int xn) { int tmp = pN; pN = xn; return tmp; } inline double Binomial::u() { return pU; } -inline double Binomial::u(int xu) { double tmp = pU; pU = xu; return tmp; } +inline double Binomial::u(double xu) { double tmp = pU; pU = xu; return tmp; } #endif diff --git a/gnu/lib/libg++/libg++/src/BitSet.cc b/gnu/lib/libg++/libg++/src/BitSet.cc index dd1f6503990d..15096e2d28be 100644 --- a/gnu/lib/libg++/libg++/src/BitSet.cc +++ b/gnu/lib/libg++/libg++/src/BitSet.cc @@ -44,7 +44,8 @@ void BitSet::error(const char* msg) const BitSetRep _nilBitSetRep = { 0, 1, 0, {0} }; // nil BitSets point here #define ONES ((_BS_word)(~0L)) -#define MAXBitSetRep_SIZE ((1U << (sizeof(unsigned short)*CHAR_BIT - 1)) - 1) +#define MASK1(BITNO) ((_BS_word)1 << (BITNO)) +#define MAXBitSetRep_SIZE (((_BS_word)1 << (sizeof(unsigned short)*CHAR_BIT - 1)) - 1) #define MINBitSetRep_SIZE (sizeof(_BS_word)*CHAR_BIT) #ifndef MALLOC_MIN_OVERHEAD @@ -102,7 +103,8 @@ BitSetRep* BitSetalloc(BitSetRep* old, const _BS_word* src, int srclen, memcpy(rep->s, src, srclen * sizeof(_BS_word)); // BUG fix: extend virtual bit! 20 Oct 1992 Kevin Karplus if (rep->virt) - memset(&rep->s[srclen], ONES, (newlen - srclen) * sizeof(_BS_word)); + memset(&rep->s[srclen], (char)ONES, + (newlen - srclen) * sizeof(_BS_word)); if (old != rep && old != 0) delete old; return rep; } @@ -122,7 +124,8 @@ BitSetRep* BitSetresize(BitSetRep* old, int newlen) rep->virt = old->virt; // BUG fix: extend virtual bit! 20 Oct 1992 Kevin Karplus if (rep->virt) - memset(&rep->s[old->len], ONES, (newlen - old->len) * sizeof(_BS_word)); + memset(&rep->s[old->len], (char)ONES, + (newlen - old->len) * sizeof(_BS_word)); delete old; } else @@ -130,7 +133,7 @@ BitSetRep* BitSetresize(BitSetRep* old, int newlen) rep = old; if (rep->len < newlen) memset(&rep->s[rep->len], - rep->virt ? ONES : 0, + rep->virt ? (char)ONES : (char)0, (newlen - rep->len) * sizeof(_BS_word)); } @@ -416,7 +419,7 @@ int BitSet::count(int b) const } else { - _BS_word maxbit = 1U << (BITSETBITS - 1); + _BS_word maxbit = MASK1 (BITSETBITS - 1); while (s < tops) { _BS_word a = *s++; @@ -557,7 +560,7 @@ void BitSet::set(int p) rep = BitSetresize(rep, index+1); } - rep->s[index] |= (1U << pos); + rep->s[index] |= MASK1 (pos); } void BitSet::clear() @@ -577,7 +580,7 @@ void BitSet::clear(int p) else rep = BitSetresize(rep, index+1); } - rep->s[index] &= ~(1U << BitSet_pos(p)); + rep->s[index] &= ~MASK1(BitSet_pos(p)); } void BitSet::invert(int p) @@ -585,7 +588,7 @@ void BitSet::invert(int p) if (p < 0) error("Illegal bit index"); int index = BitSet_index(p); if (index >= rep->len) rep = BitSetresize(rep, index+1); - rep->s[index] ^= (1U << BitSet_pos(p)); + rep->s[index] ^= MASK1(BitSet_pos(p)); } void BitSet::set(int from, int to) @@ -822,7 +825,7 @@ int BitSet::prev(int p, int b) const _BS_word a = s[j]; int i = pos; - _BS_word maxbit = 1U << pos; + _BS_word maxbit = MASK1(pos); if (b == 1) { @@ -832,7 +835,7 @@ int BitSet::prev(int p, int b) const return j * BITSETBITS + i; a <<= 1; } - maxbit = 1U << (BITSETBITS - 1); + maxbit = MASK1(BITSETBITS - 1); for (--j; j >= 0; --j) { a = s[j]; @@ -856,7 +859,7 @@ int BitSet::prev(int p, int b) const a <<= 1; } } - maxbit = 1U << (BITSETBITS - 1); + maxbit = MASK1(BITSETBITS - 1); for (--j; j >= 0; --j) { a = s[j]; @@ -1074,7 +1077,7 @@ void BitSet::printon(ostream& os, char f, char t, char star) const { _BS_word a = *s; _BS_word mask = ONES; - _BS_word himask = (1U << (BITSETBITS - 1)) - 1; + _BS_word himask = MASK1(BITSETBITS - 1) - 1; if (rep->len != 0) { for (int j = 0; j < BITSETBITS && a != mask; ++j) diff --git a/gnu/lib/libg++/libg++/src/BitSet.h b/gnu/lib/libg++/libg++/src/BitSet.h index 491102d50e8e..3ff982a8ebab 100644 --- a/gnu/lib/libg++/libg++/src/BitSet.h +++ b/gnu/lib/libg++/libg++/src/BitSet.h @@ -46,8 +46,6 @@ extern BitSetRep* BitSetresize(BitSetRep*, int); extern BitSetRep* BitSetop(const BitSetRep*, const BitSetRep*, BitSetRep*, char); extern BitSetRep* BitSetcmpl(const BitSetRep*, BitSetRep*); - - extern BitSetRep _nilBitSetRep; class BitSet; @@ -72,7 +70,18 @@ class BitSet protected: BitSetRep* rep; - + enum BS_op { + BS_and = (int) '&', + BS_or = (int) '|', + BS_xor = (int) '^', + BS_diff = (int) '-', + BS_inv = (int) '~' + }; + BitSet(const BitSet& x, const BitSet& y, enum BS_op op) + { rep = BitSetop (x.rep, y.rep, NULL, (char) op); } + BitSet(const BitSet& x, enum BS_op /* op */) + { rep = BitSetcmpl (x.rep, NULL); } + public: // constructors @@ -93,7 +102,6 @@ public: friend int operator >= (const BitSet& x, const BitSet& y); friend int lcompare(const BitSet& x, const BitSet& y); - // operations on self BitSet& operator |= (const BitSet& y); @@ -103,6 +111,14 @@ public: void complement(); +// functional operators + + friend BitSet operator & (const BitSet& x, const BitSet& y); + friend BitSet operator | (const BitSet& x, const BitSet& y); + friend BitSet operator ^ (const BitSet& x, const BitSet& y); + friend BitSet operator - (const BitSet& x, const BitSet& y); + friend BitSet operator ~ (const BitSet& x); + // individual bit manipulation void set(int pos); @@ -152,13 +168,17 @@ public: void printon(ostream& s, char f='0', char t='1', char star='*') const; -// procedural versions of operators +#ifndef __STRICT_ANSI__ + // procedural versions of operators + // The first three of these are incompatible with ANSI C++ digraphs. + // In any case, it's not a great interface. friend void and(const BitSet& x, const BitSet& y, BitSet& r); friend void or(const BitSet& x, const BitSet& y, BitSet& r); friend void xor(const BitSet& x, const BitSet& y, BitSet& r); friend void diff(const BitSet& x, const BitSet& y, BitSet& r); friend void complement(const BitSet& x, BitSet& r); +#endif // misc @@ -181,7 +201,6 @@ inline int BitSet_pos(int l) return l & (BITSETBITS - 1); } - inline BitSet::BitSet() : rep(&_nilBitSetRep) {} inline BitSet::BitSet(const BitSet& x) :rep(BitSetcopy(0, x.rep)) {} @@ -200,6 +219,7 @@ inline int operator > (const BitSet& x, const BitSet& y) { return y < x; } inline int operator >= (const BitSet& x, const BitSet& y) { return y <= x; } +#ifndef __STRICT_ANSI__ inline void and(const BitSet& x, const BitSet& y, BitSet& r) { r.rep = BitSetop(x.rep, y.rep, r.rep, '&'); @@ -224,91 +244,61 @@ inline void complement(const BitSet& x, BitSet& r) { r.rep = BitSetcmpl(x.rep, r.rep); } - -#if defined(__GNUG__) && !defined(_G_NO_NRV) - -inline BitSet operator & (const BitSet& x, const BitSet& y) return r -{ - and(x, y, r); -} - -inline BitSet operator | (const BitSet& x, const BitSet& y) return r -{ - or(x, y, r); -} - -inline BitSet operator ^ (const BitSet& x, const BitSet& y) return r -{ - xor(x, y, r); -} - -inline BitSet operator - (const BitSet& x, const BitSet& y) return r -{ - diff(x, y, r); -} - -inline BitSet operator ~ (const BitSet& x) return r -{ - ::complement(x, r); -} - -#else /* NO_NRV */ +#endif inline BitSet operator & (const BitSet& x, const BitSet& y) { - BitSet r; and(x, y, r); return r; + return BitSet::BitSet(x, y, BitSet::BS_and); } inline BitSet operator | (const BitSet& x, const BitSet& y) { - BitSet r; or(x, y, r); return r; + return BitSet::BitSet(x, y, BitSet::BS_or); } inline BitSet operator ^ (const BitSet& x, const BitSet& y) { - BitSet r; xor(x, y, r); return r; + return BitSet::BitSet(x, y, BitSet::BS_xor); } inline BitSet operator - (const BitSet& x, const BitSet& y) { - BitSet r; diff(x, y, r); return r; + return BitSet::BitSet(x, y, BitSet::BS_diff); } inline BitSet operator ~ (const BitSet& x) { - BitSet r; ::complement(x, r); return r; + return BitSet::BitSet(x, BitSet::BS_inv); } -#endif - inline BitSet& BitSet::operator &= (const BitSet& y) { - and(*this, y, *this); + rep = BitSetop(rep, y.rep, rep, '&'); return *this; } inline BitSet& BitSet::operator |= (const BitSet& y) { - or(*this, y, *this); + rep = BitSetop(rep, y.rep, rep, '|'); return *this; } inline BitSet& BitSet::operator ^= (const BitSet& y) { - xor(*this, y, *this); + rep = BitSetop(rep, y.rep, rep, '^'); return *this; } inline BitSet& BitSet::operator -= (const BitSet& y) { - diff(*this, y, *this); + rep = BitSetop(rep, y.rep, rep, '-'); return *this; } inline void BitSet::complement() { - ::complement(*this, *this); + rep = BitSetcmpl(rep, rep); } inline int BitSet::virtual_bit() const @@ -326,7 +316,7 @@ inline int BitSet::test(int p) const if (p < 0) error("Illegal bit index"); int index = BitSet_index(p); return (index >= rep->len)? rep->virt : - ((rep->s[index] & (1 << BitSet_pos(p))) != 0); + ((rep->s[index] & ((_BS_word)1 << BitSet_pos(p))) != 0); } diff --git a/gnu/lib/libg++/libg++/src/Integer.h b/gnu/lib/libg++/libg++/src/Integer.h index f2e9b160a630..b98a349272c8 100644 --- a/gnu/lib/libg++/libg++/src/Integer.h +++ b/gnu/lib/libg++/libg++/src/Integer.h @@ -163,9 +163,11 @@ public: friend void mod(const Integer& x, const Integer& y, Integer& dest); friend void divide(const Integer& x, const Integer& y, Integer& q, Integer& r); +#ifndef __STRICT_ANSI__ friend void and(const Integer& x, const Integer& y, Integer& dest); friend void or(const Integer& x, const Integer& y, Integer& dest); - friend void xor(const Integer& x, const Integer& y, Integer& dest); + friend void xor(const Integer& x, const Integer& y, Integer& dest); +#endif friend void lshift(const Integer& x, const Integer& y, Integer& dest); friend void rshift(const Integer& x, const Integer& y, Integer& dest); friend void pow(const Integer& x, const Integer& y, Integer& dest); @@ -178,9 +180,11 @@ public: friend void div(const Integer& x, long y, Integer& dest); friend void mod(const Integer& x, long y, Integer& dest); friend void divide(const Integer& x, long y, Integer& q, long& r); +#ifndef __STRICT_ANSI__ friend void and(const Integer& x, long y, Integer& dest); friend void or(const Integer& x, long y, Integer& dest); friend void xor(const Integer& x, long y, Integer& dest); +#endif friend void lshift(const Integer& x, long y, Integer& dest); friend void rshift(const Integer& x, long y, Integer& dest); friend void pow(const Integer& x, long y, Integer& dest); @@ -190,9 +194,21 @@ public: friend void add(long x, const Integer& y, Integer& dest); friend void sub(long x, const Integer& y, Integer& dest); friend void mul(long x, const Integer& y, Integer& dest); +#ifndef __STRICT_ANSI__ friend void and(long x, const Integer& y, Integer& dest); friend void or(long x, const Integer& y, Integer& dest); friend void xor(long x, const Integer& y, Integer& dest); +#endif + + friend Integer operator & (const Integer&, const Integer&); + friend Integer operator & (const Integer&, long); + friend Integer operator & (long, const Integer&); + friend Integer operator | (const Integer&, const Integer&); + friend Integer operator | (const Integer&, long); + friend Integer operator | (long, const Integer&); + friend Integer operator ^ (const Integer&, const Integer&); + friend Integer operator ^ (const Integer&, long); + friend Integer operator ^ (long, const Integer&); // coercion & conversion @@ -250,15 +266,6 @@ public: Integer operator << (const Integer&, long); Integer operator >> (const Integer&, const Integer&); Integer operator >> (const Integer&, long); - Integer operator & (const Integer&, const Integer&); - Integer operator & (const Integer&, long); - Integer operator & (long, const Integer&); - Integer operator | (const Integer&, const Integer&); - Integer operator | (const Integer&, long); - Integer operator | (long, const Integer&); - Integer operator ^ (const Integer&, const Integer&); - Integer operator ^ (const Integer&, long); - Integer operator ^ (long, const Integer&); Integer abs(const Integer&); // absolute value Integer sqr(const Integer&); // square @@ -365,6 +372,7 @@ inline void mod(const Integer& x, const Integer& y, Integer& dest) dest.rep = mod(x.rep, y.rep, dest.rep); } +#ifndef __STRICT_ANSI__ inline void and(const Integer& x, const Integer& y, Integer& dest) { dest.rep = bitop(x.rep, y.rep, dest.rep, '&'); @@ -379,6 +387,7 @@ inline void xor(const Integer& x, const Integer& y, Integer& dest) { dest.rep = bitop(x.rep, y.rep, dest.rep, '^'); } +#endif inline void lshift(const Integer& x, const Integer& y, Integer& dest) { @@ -420,6 +429,7 @@ inline void mod(const Integer& x, long y, Integer& dest) dest.rep = mod(x.rep, y, dest.rep); } +#ifndef __STRICT_ANSI__ inline void and(const Integer& x, long y, Integer& dest) { dest.rep = bitop(x.rep, y, dest.rep, '&'); @@ -434,6 +444,7 @@ inline void xor(const Integer& x, long y, Integer& dest) { dest.rep = bitop(x.rep, y, dest.rep, '^'); } +#endif inline void lshift(const Integer& x, long y, Integer& dest) { @@ -480,6 +491,7 @@ inline void mul(long x, const Integer& y, Integer& dest) dest.rep = multiply(y.rep, x, dest.rep); } +#ifndef __STRICT_ANSI__ inline void and(long x, const Integer& y, Integer& dest) { dest.rep = bitop(y.rep, x, dest.rep, '&'); @@ -494,6 +506,7 @@ inline void xor(long x, const Integer& y, Integer& dest) { dest.rep = bitop(y.rep, x, dest.rep, '^'); } +#endif // operator versions @@ -613,38 +626,38 @@ inline Integer& Integer::operator *= (long y) inline Integer& Integer::operator &= (const Integer& y) { - and(*this, y, *this); + rep = bitop(rep, y.rep, rep, '&'); return *this; } inline Integer& Integer::operator &= (long y) { - and(*this, y, *this); + rep = bitop(rep, y, rep, '&'); return *this; } inline Integer& Integer::operator |= (const Integer& y) { - or(*this, y, *this); + rep = bitop(rep, y.rep, rep, '|'); return *this; } inline Integer& Integer::operator |= (long y) { - or(*this, y, *this); + rep = bitop(rep, y, rep, '|'); return *this; } inline Integer& Integer::operator ^= (const Integer& y) { - xor(*this, y, *this); + rep = bitop(rep, y.rep, rep, '^'); return *this; } inline Integer& Integer::operator ^= (long y) { - xor(*this, y, *this); + rep = bitop(rep, y, rep, '^'); return *this; } @@ -801,47 +814,47 @@ inline Integer sqr(const Integer& x) return r inline Integer operator & (const Integer& x, const Integer& y) return r { - and(x, y, r); + r.rep = bitop(x.rep, y.rep, r.rep, '&'); } inline Integer operator & (const Integer& x, long y) return r { - and(x, y, r); + r.rep = bitop(x.rep, y, r.rep, '&'); } inline Integer operator & (long x, const Integer& y) return r { - and(x, y, r); + r.rep = bitop(y.rep, x, r.rep, '&'); } inline Integer operator | (const Integer& x, const Integer& y) return r { - or(x, y, r); + r.rep = bitop(x.rep, y.rep, r.rep, '|'); } inline Integer operator | (const Integer& x, long y) return r { - or(x, y, r); + r.rep = bitop(x.rep, y, r.rep, '|'); } inline Integer operator | (long x, const Integer& y) return r { - or(x, y, r); + r.rep = bitop(y.rep, x, r.rep, '|'); } inline Integer operator ^ (const Integer& x, const Integer& y) return r { - xor(x, y, r); + r.rep = bitop(x.rep, y.rep, r.rep, '^'); } inline Integer operator ^ (const Integer& x, long y) return r { - xor(x, y, r); + r.rep = bitop (x.rep, y, r.rep, '^'); } inline Integer operator ^ (long x, const Integer& y) return r { - xor(x, y, r); + r.rep = bitop (y.rep, x, r.rep, '^'); } inline Integer operator / (const Integer& x, const Integer& y) return r @@ -1010,17 +1023,17 @@ inline Integer operator | (long x, const Integer& y) inline Integer operator ^ (const Integer& x, const Integer& y) { - Integer r; xor(x, y, r); return r; + Integer r; r.rep = bitop(x.rep, y.rep, r.rep, '^'); return r; } inline Integer operator ^ (const Integer& x, long y) { - Integer r; xor(x, y, r); return r; + Integer r; r.rep = bitop(x.rep, y, r.rep, '^'); return r; } inline Integer operator ^ (long x, const Integer& y) { - Integer r; xor(x, y, r); return r; + Integer r; r.rep = bitop(y.rep, x, r.rep, '^'); return r; } inline Integer operator / (const Integer& x, const Integer& y) diff --git a/gnu/lib/libg++/libg++/src/Makefile b/gnu/lib/libg++/libg++/src/Makefile index f0a7aba04f15..cf85afd76568 100644 --- a/gnu/lib/libg++/libg++/src/Makefile +++ b/gnu/lib/libg++/libg++/src/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1.1.1 1996/03/09 00:01:20 phil Exp $ +# $NetBSD: Makefile,v 1.1.1.2 1996/12/17 18:57:01 phil Exp $ LIB= g++ @@ -9,9 +9,9 @@ MLCG.cc NegExp.cc Normal.cc Obstack.cc Poisson.cc RNG.cc \ Random.cc Rational.cc Regex.cc RndInt.cc SLList.cc SmplHist.cc \ SmplStat.cc String.cc Uniform.cc Weibull.cc bitand.c bitany.c \ bitblt.c bitclear.c bitcopy.c bitcount.c bitinvert.c bitlcomp.c \ -bitset1.c bitxor.c builtin.cc chr.cc compare.cc error.cc \ -fmtq.cc gcd.cc hash.cc ioob.cc lg.cc pow.cc \ -sqrt.cc str.cc timer.c +bitset1.c bitxor.c builtin.cc compare.cc error.cc fmtq.cc \ +gcd.cc hash.cc ioob.cc lg.cc pow.cc sqrt.cc \ +timer.c CXXFLAGS+= -nostdinc++ -I$(.CURDIR)/../../include \ -I$(.CURDIR)/../../libio -I$(.CURDIR)/../../libstdc++ diff --git a/gnu/lib/libg++/libg++/src/Regex.cc b/gnu/lib/libg++/libg++/src/Regex.cc index 1c27dd0e0287..642fd88e245c 100644 --- a/gnu/lib/libg++/libg++/src/Regex.cc +++ b/gnu/lib/libg++/libg++/src/Regex.cc @@ -41,6 +41,13 @@ Regex::~Regex() { if (buf->buffer) free(buf->buffer); if (buf->fastmap) free(buf->fastmap); + if (buf->translate) free (buf->translate); + + if (reg->start) + free (reg->start); + if (reg->end) + free (reg->end); + delete(buf); delete(reg); } @@ -52,6 +59,8 @@ Regex::Regex(const char* t, int fast, int bufsize, buf = new re_pattern_buffer; memset (buf, 0, sizeof(re_pattern_buffer)); reg = new re_registers; + reg->start = 0; + reg->end = 0; if (fast) buf->fastmap = (char*)malloc(256); else diff --git a/gnu/lib/libg++/libg++/src/String.cc b/gnu/lib/libg++/libg++/src/String.cc index 6ab515ca9393..cda827317916 100644 --- a/gnu/lib/libg++/libg++/src/String.cc +++ b/gnu/lib/libg++/libg++/src/String.cc @@ -326,7 +326,7 @@ inline static int scmp(const char* a, const char* b) return *a != 0; else { - signed char diff = 0; + int diff = 0; while ((diff = *a - *b++) == 0 && *a++ != 0); return diff; } @@ -336,7 +336,7 @@ inline static int scmp(const char* a, const char* b) inline static int ncmp(const char* a, int al, const char* b, int bl) { int n = (al <= bl)? al : bl; - signed char diff; + int diff; while (n-- > 0) if ((diff = *a++ - *b++) != 0) return diff; return al - bl; } @@ -348,7 +348,7 @@ int fcompare(const String& x, const String& y) int al = x.length(); int bl = y.length(); int n = (al <= bl)? al : bl; - signed char diff = 0; + int diff = 0; while (n-- > 0) { char ac = *a++; @@ -402,7 +402,7 @@ int compare(const SubString& x, const char* b) { const char* a = x.chars(); int n = x.length(); - signed char diff; + int diff; while (n-- > 0) if ((diff = *a++ - *b++) != 0) return diff; return (*b == 0) ? 0 : -1; } @@ -1165,7 +1165,7 @@ String common_prefix(const String& x, const String& y, int startpos) const char* ys = &(ychars[startpos]); const char* topy = &(ychars[y.length()]); int l; - for (int l; xs < topx && ys < topy && *xs++ == *ys++; ++l); + for (l = 0; xs < topx && ys < topy && *xs++ == *ys++; ++l); r.rep = Salloc(r.rep, ss, l, l); return r; } @@ -1180,7 +1180,7 @@ String common_suffix(const String& x, const String& y, int startpos) const char* ys = &(ychars[y.length() + startpos]); const char* boty = ychars; int l; - for (int l; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l); + for (l = 0; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l); r.rep = Salloc(r.rep, ++xs, l, l); return r; } diff --git a/gnu/lib/libg++/libg++/src/bitlcomp.c b/gnu/lib/libg++/libg++/src/bitlcomp.c index 8b52943aa727..3fbfdb72c83b 100644 --- a/gnu/lib/libg++/libg++/src/bitlcomp.c +++ b/gnu/lib/libg++/libg++/src/bitlcomp.c @@ -32,9 +32,9 @@ the executable file might be covered by the GNU General Public License. */ int _BS_lcompare_0 (ptr0, len0, ptr1, len1) - register _BS_word *ptr0; + register const _BS_word *ptr0; _BS_size_t len0; - register _BS_word *ptr1; + register const _BS_word *ptr1; _BS_size_t len1; { _BS_size_t nwords0 = len0 / _BS_BITS_PER_WORD; diff --git a/gnu/lib/libg++/libg++/src/bitprims.h b/gnu/lib/libg++/libg++/src/bitprims.h index 737562dce89f..25b809b68952 100644 --- a/gnu/lib/libg++/libg++/src/bitprims.h +++ b/gnu/lib/libg++/libg++/src/bitprims.h @@ -45,7 +45,7 @@ typedef unsigned long _BS_word; ( (NEW_PTR) = (_BS_word*)(((char*)(PTR)-(char*)0) & ~(sizeof(_BS_word)-1)), \ (OFFSET) += (char*)(PTR) - (char*)(NEW_PTR) ) -/* Given a bit point (PTR, OFFSET) normalize it so that +/* Given a bit pointer (PTR, OFFSET) normalize it so that OFFSET < _BS_BITS_PER_WORD. */ #define _BS_NORMALIZE(PTR, OFFSET) \ { _BS_size_t __tmp_ind = _BS_INDEX (OFFSET); \ @@ -114,7 +114,8 @@ extern int _BS_any __P((const _BS_word*, int, _BS_size_t)); extern void _BS_clear __P((_BS_word*, int, _BS_size_t)); extern void _BS_set __P((_BS_word*, int, _BS_size_t)); extern void _BS_invert __P((_BS_word*, int, _BS_size_t)); -int _BS_lcompare_0 __P((_BS_word*, _BS_size_t, _BS_word*, _BS_size_t)); +int _BS_lcompare_0 __P((const _BS_word*, _BS_size_t, + const _BS_word*, _BS_size_t)); extern void _BS_xor __P((_BS_word*,int, const _BS_word*,int, _BS_size_t)); #ifdef __cplusplus diff --git a/gnu/lib/libg++/libg++/src/shlib_version b/gnu/lib/libg++/libg++/src/shlib_version index 012c14171d3a..d9961ea9feff 100644 --- a/gnu/lib/libg++/libg++/src/shlib_version +++ b/gnu/lib/libg++/libg++/src/shlib_version @@ -1,2 +1,2 @@ -major=3 +major=4 minor=0 diff --git a/gnu/lib/libg++/libio/Makefile b/gnu/lib/libg++/libio/Makefile index 158971bbbfc2..28c6c41e15c8 100644 --- a/gnu/lib/libg++/libio/Makefile +++ b/gnu/lib/libg++/libio/Makefile @@ -1,15 +1,15 @@ -# $NetBSD: Makefile,v 1.1.1.1 1996/03/09 00:01:31 phil Exp $ +# $NetBSD: Makefile,v 1.1.1.2 1996/12/17 18:58:06 phil Exp $ LIB= io -SRCS= cleanup.c filedoalloc.c fileops.c floatconv.c genops.c iofclose.c \ -iofdopen.c iofflush.c iofgetpos.c iofgets.c iofopen.c iofprintf.c \ -iofputs.c iofread.c iofscanf.c iofsetpos.c ioftell.c iofwrite.c \ -iogetdelim.c iogetline.c iogets.c ioignore.c iopadn.c ioperror.c \ -iopopen.c ioprims.c ioprintf.c ioputs.c ioscanf.c ioseekoff.c \ -ioseekpos.c iosetbuffer.c iosetvbuf.c iosprintf.c iosscanf.c iostrerror.c \ -ioungetc.c iovfprintf.c iovfscanf.c iovsprintf.c iovsscanf.c outfloat.c \ -stdfiles.c strops.c +SRCS= chr.cc cleanup.c filedoalloc.c fileops.c floatconv.c genops.c \ +iofclose.c iofdopen.c iofflush.c iofgetpos.c iofgets.c iofopen.c \ +iofprintf.c iofputs.c iofread.c iofscanf.c iofsetpos.c ioftell.c \ +iofwrite.c iogetdelim.c iogetline.c iogets.c ioignore.c iopadn.c \ +ioperror.c iopopen.c ioprims.c ioprintf.c ioputs.c ioscanf.c \ +ioseekoff.c ioseekpos.c iosetbuffer.c iosetvbuf.c iosprintf.c iosscanf.c \ +iostrerror.c ioungetc.c iovfprintf.c iovfscanf.c iovsprintf.c iovsscanf.c \ +outfloat.c str.cc stdfiles.c strops.c CXXFLAGS+= -nostdinc++ -I$(.CURDIR)/../include CFLAGS+= -I$(.CURDIR) diff --git a/gnu/lib/libg++/libio/_G_config.h b/gnu/lib/libg++/libio/_G_config.h index a8b1066e716c..1b62125280d2 100644 --- a/gnu/lib/libg++/libio/_G_config.h +++ b/gnu/lib/libg++/libio/_G_config.h @@ -1,35 +1,74 @@ /* AUTOMATICALLY GENERATED; DO NOT EDIT! */ #ifndef _G_config_h #define _G_config_h -#define _G_LIB_VERSION "2.7.1" +#define _G_LIB_VERSION "2.7.2" +#ifndef __alpha__ #define _G_NAMES_HAVE_UNDERSCORE 1 +#else /* __alpha__ */ +#define _G_NAMES_HAVE_UNDERSCORE 0 +#endif /* __alpha__ */ #define _G_VTABLE_LABEL_HAS_LENGTH 1 +#ifndef __alpha__ #define _G_VTABLE_LABEL_PREFIX "__vt$" +#else /* __alpha__ */ +#define _G_VTABLE_LABEL_PREFIX "_vt$" +#endif /* __alpha__ */ #define _G_HAVE_ST_BLKSIZE 1 +#ifndef __alpha__ typedef unsigned long _G_clock_t; +#else /* __alpha__ */ +typedef int _G_clock_t; +#endif /* __alpha__ */ typedef int _G_dev_t; +#ifndef __alpha__ typedef long long _G_fpos_t; +#else /* __alpha__ */ +typedef long _G_fpos_t; +#endif /* __alpha__ */ typedef unsigned int _G_gid_t; typedef unsigned int _G_ino_t; typedef unsigned short _G_mode_t; typedef unsigned short _G_nlink_t; +#ifndef __alpha__ typedef long long _G_off_t; +#else /* __alpha__ */ +typedef long _G_off_t; +#endif /* __alpha__ */ typedef int _G_pid_t; #ifndef __PTRDIFF_TYPE__ +#ifndef __alpha__ #define __PTRDIFF_TYPE__ int +#else /* __alpha__ */ +#define __PTRDIFF_TYPE__ long +#endif /* __alpha__ */ #endif typedef __PTRDIFF_TYPE__ _G_ptrdiff_t; typedef unsigned int _G_sigset_t; #ifndef __SIZE_TYPE__ +#ifndef __alpha__ #define __SIZE_TYPE__ unsigned int +#else /* __alpha__ */ +#define __SIZE_TYPE__ unsigned long +#endif /* __alpha__ */ #endif typedef __SIZE_TYPE__ _G_size_t; +#ifndef __alpha__ typedef long _G_time_t; +#else /* __alpha__ */ +typedef int _G_time_t; +#endif /* __alpha__ */ typedef unsigned int _G_uid_t; typedef int _G_wchar_t; +#ifndef __alpha__ typedef int _G_ssize_t; typedef int /* default */ _G_wint_t; typedef char * _G_va_list; +#else /* __alpha__ */ +typedef long _G_ssize_t; +typedef unsigned int /* default */ _G_wint_t; +#define _G_NEED_STDARG_H +#define _G_va_list va_list +#endif /* __alpha__ */ #define _G_signal_return_type void #define _G_sprintf_return_type int diff --git a/gnu/lib/libg++/libio/cleanup.c b/gnu/lib/libg++/libio/cleanup.c index b4c8be927f90..a0c5052d3958 100644 --- a/gnu/lib/libg++/libio/cleanup.c +++ b/gnu/lib/libg++/libio/cleanup.c @@ -12,4 +12,6 @@ DEFUN_VOID(_IO_register_cleanup) } void (*_IO_cleanup_registration_needed)() = _IO_register_cleanup; +#else +void (*_IO_cleanup_registration_needed)() = NULL; #endif /* _G_HAVE_ATEXIT */ diff --git a/gnu/lib/libg++/libio/filebuf.cc b/gnu/lib/libg++/libio/filebuf.cc index 8f4bdc8a020f..1e2682fbce95 100644 --- a/gnu/lib/libg++/libio/filebuf.cc +++ b/gnu/lib/libg++/libio/filebuf.cc @@ -95,6 +95,14 @@ filebuf* filebuf::open(const char *filename, ios::openmode mode, int prot) posix_mode = O_RDONLY, read_write = _IO_NO_WRITES; else posix_mode = 0, read_write = _IO_NO_READS+_IO_NO_WRITES; + if (mode & ios::binary) + { + mode &= ~ios::binary; +#ifdef O_BINARY + /* This is a (mis-)feature of DOS/Windows C libraries. */ + posix_mode |= O_BINARY; +#endif + } if ((mode & (int)ios::trunc) || mode == (int)ios::out) posix_mode |= O_TRUNC; if (mode & ios::app) diff --git a/gnu/lib/libg++/libio/filedoalloc.c b/gnu/lib/libg++/libio/filedoalloc.c index 6218135eaed6..f838bb3458f7 100644 --- a/gnu/lib/libg++/libio/filedoalloc.c +++ b/gnu/lib/libg++/libio/filedoalloc.c @@ -50,12 +50,6 @@ the executable file might be covered by the GNU General Public License. */ #include #endif -/* If this function pointer is non-zero, we should call it. - It's supposed to make sure _IO_cleanup gets called on exit. - We call it from _IO_file_doallocate, since that is likely - to get called by any program that does buffered I/O. */ -void (*_IO_cleanup_registration_needed)(); - /* * Allocate a file buffer, or switch to unbuffered I/O. * Per the ANSI C standard, ALL tty devices default to line buffered. @@ -73,6 +67,10 @@ DEFUN(_IO_file_doallocate, (fp), register char *p; struct stat st; + /* If _IO_cleanup_registration_needed is non-zero, we should call the + function it points to. This is to make sure _IO_cleanup gets called + on exit. We call it from _IO_file_doallocate, since that is likely + to get called by any program that does buffered I/O. */ if (_IO_cleanup_registration_needed) (*_IO_cleanup_registration_needed)(); diff --git a/gnu/lib/libg++/libio/fileops.c b/gnu/lib/libg++/libio/fileops.c index 89381ec69977..812af94d0f95 100644 --- a/gnu/lib/libg++/libio/fileops.c +++ b/gnu/lib/libg++/libio/fileops.c @@ -43,21 +43,26 @@ extern int errno; is that of gptr(); in put mode that of pptr(). The position in the buffer that corresponds to the position - in external file system is file_ptr(). - This is normally _IO_read_end, except in putback mode, - when it is _IO_save_end. + in external file system is normally _IO_read_end, except in putback + mode, when it is _IO_save_end. If the field _fb._offset is >= 0, it gives the offset in the file as a whole corresponding to eGptr(). (?) PUT MODE: - If a filebuf is in put mode, pbase() is non-NULL and equal to base(). - Also, epptr() == ebuf(). - Also, eback() == gptr() && gptr() == egptr(). - The un-flushed character are those between pbase() and pptr(). + If a filebuf is in put mode, then all of _IO_read_ptr, _IO_read_end, + and _IO_read_base are equal to each other. These are usually equal + to _IO_buf_base, though not necessarily if we have switched from + get mode to put mode. (The reason is to maintain the invariant + that _IO_read_end corresponds to the external file position.) + _IO_write_base is non-NULL and usually equal to _IO_base_base. + We also have _IO_write_end == _IO_buf_end, but only in fully buffered mode. + The un-flushed character are those between _IO_write_base and _IO_write_ptr. + GET MODE: If a filebuf is in get or putback mode, eback() != egptr(). In get mode, the unread characters are between gptr() and egptr(). The OS file position corresponds to that of egptr(). + PUTBACK MODE: Putback mode is used to remember "excess" characters that have been sputbackc'd in a separate putback buffer. @@ -70,7 +75,7 @@ extern int errno; The OS position corresponds to that of save_egptr(). LINE BUFFERED OUTPUT: - During line buffered output, pbase()==base() && epptr()==base(). + During line buffered output, _IO_write_base==base() && epptr()==base(). However, ptr() may be anywhere between base() and ebuf(). This forces a call to filebuf::overflow(int C) on every put. If there is more space in the buffer, and C is not a '\n', @@ -102,11 +107,11 @@ int DEFUN(_IO_file_close_it, (fp), register _IO_FILE* fp) { - int sync_status, close_status; + int write_status, close_status; if (!_IO_file_is_open(fp)) return EOF; - sync_status = _IO_file_sync (fp); + write_status = _IO_do_flush (fp); _IO_unsave_markers(fp); @@ -122,7 +127,7 @@ DEFUN(_IO_file_close_it, (fp), fp->_fileno = EOF; fp->_offset = _IO_pos_BAD; - return close_status ? close_status : sync_status; + return close_status ? close_status : write_status; } void @@ -211,7 +216,7 @@ DEFUN(_IO_file_setbuf, (fp, p, len), } /* Write TO_DO bytes from DATA to FP. - Then mark FP has having empty buffers. */ + Then mark FP as having empty buffers. */ int DEFUN(_IO_do_write, (fp, data, to_do), @@ -220,24 +225,28 @@ DEFUN(_IO_do_write, (fp, data, to_do), _IO_size_t count; if (to_do == 0) return 0; - if (fp->_flags & _IO_IS_APPENDING) - /* On a system without a proper O_APPEND implementation, - you would need to sys_seek(0, SEEK_END) here, but is - is not needed nor desirable for Unix- or Posix-like systems. - Instead, just indicate that offset (before and after) is - unpredictable. */ - fp->_offset = _IO_pos_BAD; - else if (fp->_IO_read_end != fp->_IO_write_base) - { - _IO_pos_t new_pos - = _IO_SYSSEEK(fp, fp->_IO_write_base - fp->_IO_read_end, 1); - if (new_pos == _IO_pos_BAD) - return EOF; - fp->_offset = new_pos; + else + { + if (fp->_flags & _IO_IS_APPENDING) + /* On a system without a proper O_APPEND implementation, + you would need to sys_seek(0, SEEK_END) here, but is + is not needed nor desirable for Unix- or Posix-like systems. + Instead, just indicate that offset (before and after) is + unpredictable. */ + fp->_offset = _IO_pos_BAD; + else if (fp->_IO_read_end != fp->_IO_write_base) + { + _IO_pos_t new_pos + = _IO_SYSSEEK(fp, fp->_IO_write_base - fp->_IO_read_end, 1); + if (new_pos == _IO_pos_BAD) + return EOF; + fp->_offset = new_pos; + } + count = _IO_SYSWRITE (fp, data, to_do); + if (fp->_cur_column) + fp->_cur_column + = _IO_adjust_column (fp->_cur_column - 1, data, to_do) + 1; } - count = _IO_SYSWRITE (fp, data, to_do); - if (fp->_cur_column) - fp->_cur_column = _IO_adjust_column(fp->_cur_column - 1, data, to_do) + 1; _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base; fp->_IO_write_end = (fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) ? fp->_IO_buf_base @@ -306,7 +315,15 @@ DEFUN(_IO_file_overflow, (f, ch), _IO_doallocbuf(f); _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base); } - /* Otherwise must be currently reading. */ + /* Otherwise must be currently reading. + If _IO_read_ptr (and hence also _IO_read_end) is at the buffer end, + logically slide the buffer forwards one block (by setting the + read pointers to all point at the beginning of the block). This + makes room for subsequent output. + Otherwise, set the read pointers to _IO_read_end (leaving that + alone, so it can continue to correspond to the external position). */ + if (f->_IO_read_ptr == f->_IO_buf_end) + f->_IO_read_end = f->_IO_read_ptr = f->_IO_buf_base; f->_IO_write_ptr = f->_IO_read_ptr; f->_IO_write_base = f->_IO_write_ptr; f->_IO_write_end = f->_IO_buf_end; diff --git a/gnu/lib/libg++/libio/floatconv.c b/gnu/lib/libg++/libio/floatconv.c index a6183f9e9de0..def7269d97f1 100644 --- a/gnu/lib/libg++/libio/floatconv.c +++ b/gnu/lib/libg++/libio/floatconv.c @@ -1102,6 +1102,7 @@ _IO_strtod TEST_ENDIANNESS; sign = nz0 = nz = 0; rv = 0.; + (void)&rv; /* Force rv into the stack */ for(s = s00;;s++) switch(*s) { case '-': sign = 1; diff --git a/gnu/lib/libg++/libio/fstream.h b/gnu/lib/libg++/libio/fstream.h index 398cd31d75af..ea98f5caed05 100644 --- a/gnu/lib/libg++/libio/fstream.h +++ b/gnu/lib/libg++/libio/fstream.h @@ -32,7 +32,7 @@ the executable file might be covered by the GNU General Public License. */ extern "C++" { class fstreambase : virtual public ios { #ifdef _IO_NEW_STREAMS - filebuf __my_fb; + mutable filebuf __my_fb; // mutable so rdbuf() can be const #endif void __fb_init (); public: @@ -42,7 +42,7 @@ class fstreambase : virtual public ios { fstreambase(const char *name, int mode, int prot=0664); void close(); #ifdef _IO_NEW_STREAMS - filebuf* rdbuf() const { return (filebuf*)&__my_fb; } + filebuf* rdbuf() const { return &__my_fb; } #else filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); } #endif diff --git a/gnu/lib/libg++/libio/genops.c b/gnu/lib/libg++/libio/genops.c index 7eb2d43ee195..23a6fdeaeac7 100644 --- a/gnu/lib/libg++/libio/genops.c +++ b/gnu/lib/libg++/libio/genops.c @@ -511,26 +511,41 @@ int DEFUN(_IO_sputbackc, (fp, c), register _IO_FILE *fp AND int c) { + int result; + if (fp->_IO_read_ptr > fp->_IO_read_base && (unsigned char)fp->_IO_read_ptr[-1] == (unsigned char)c) { fp->_IO_read_ptr--; - return (unsigned char)c; + result = (unsigned char)c; } - return _IO_PBACKFAIL (fp, c); + else + result = _IO_PBACKFAIL (fp, c); + + if (result != EOF) + fp->_flags &= ~_IO_EOF_SEEN; + + return result; } int DEFUN(_IO_sungetc, (fp), register _IO_FILE *fp) { + int result; + if (fp->_IO_read_ptr > fp->_IO_read_base) { fp->_IO_read_ptr--; - return (unsigned char)*fp->_IO_read_ptr; + result = (unsigned char)*fp->_IO_read_ptr; } else - return _IO_PBACKFAIL (fp, EOF); + result = _IO_PBACKFAIL (fp, EOF); + + if (result != EOF) + fp->_flags &= ~_IO_EOF_SEEN; + + return result; } #if 0 /* Work in progress */ diff --git a/gnu/lib/libg++/libio/indstream.cc b/gnu/lib/libg++/libio/indstream.cc index e74f4dbac4fc..15a1bb2778d3 100644 --- a/gnu/lib/libg++/libio/indstream.cc +++ b/gnu/lib/libg++/libio/indstream.cc @@ -63,6 +63,11 @@ int indirectbuf::overflow(int c /* = EOF */) } int indirectbuf::underflow() +{ + return get_stream()->sgetc(); +} + +int indirectbuf::uflow() { return get_stream()->sbumpc(); } @@ -90,7 +95,7 @@ streampos indirectbuf::seekpos(streampos pos, int mode) int select = mode == 0 ? (ios::in|ios::out) : mode; streambuf *gbuf = (select & ios::in) ? get_stream() : (streambuf*)NULL; streambuf *pbuf = (select & ios::out) ? put_stream() : (streambuf*)NULL; - if (gbuf == pbuf) + if (gbuf == pbuf && gbuf != NULL) ret_val = gbuf->seekpos(pos, mode); else { if (gbuf) diff --git a/gnu/lib/libg++/libio/indstream.h b/gnu/lib/libg++/libio/indstream.h index 6afffdd9bc98..c4558623d079 100644 --- a/gnu/lib/libg++/libio/indstream.h +++ b/gnu/lib/libg++/libio/indstream.h @@ -65,6 +65,7 @@ class indirectbuf : public streambuf { virtual streamsize xsputn(const char* s, streamsize n); virtual streamsize xsgetn(char* s, streamsize n); virtual int underflow(); + virtual int uflow(); virtual int overflow(int c = EOF); virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out); diff --git a/gnu/lib/libg++/libio/iopopen.c b/gnu/lib/libg++/libio/iopopen.c index d2030028d1fd..ef6ad12449f1 100644 --- a/gnu/lib/libg++/libio/iopopen.c +++ b/gnu/lib/libg++/libio/iopopen.c @@ -26,13 +26,13 @@ the executable file might be covered by the GNU General Public License. */ #define _POSIX_SOURCE #include "libioP.h" +#include #if _IO_HAVE_SYS_WAIT #include #include #ifdef __STDC__ #include #endif -#include #include #ifndef _IO_fork @@ -118,7 +118,7 @@ DEFUN(_IO_proc_open, (fp, command, mode), proc_file_chain = proc_file_chain->next; } - _IO_execl("/bin/sh", "sh", "-c", command, NULL); + _IO_execl("/bin/sh", "sh", "-c", command, (char *)0); _IO__exit(127); } _IO_close(child_end); diff --git a/gnu/lib/libg++/libio/iosetvbuf.c b/gnu/lib/libg++/libio/iosetvbuf.c index cc664b419104..1b2da4f104c9 100644 --- a/gnu/lib/libg++/libio/iosetvbuf.c +++ b/gnu/lib/libg++/libio/iosetvbuf.c @@ -36,7 +36,7 @@ DEFUN(_IO_setvbuf, (fp, buf, mode, size), switch (mode) { case _IOFBF: - fp->_IO_file_flags &= ~_IO_LINE_BUF; + fp->_IO_file_flags &= ~_IO_LINE_BUF|_IO_UNBUFFERED; if (buf == NULL) { if (fp->_IO_buf_base == NULL) @@ -62,6 +62,7 @@ DEFUN(_IO_setvbuf, (fp, buf, mode, size), } break; case _IOLBF: + fp->_IO_file_flags &= ~_IO_UNBUFFERED; fp->_IO_file_flags |= _IO_LINE_BUF; if (buf == NULL) return 0; diff --git a/gnu/lib/libg++/libio/iostdio.h b/gnu/lib/libg++/libio/iostdio.h index 8f90d9eedfee..9ed47a4654a4 100644 --- a/gnu/lib/libg++/libio/iostdio.h +++ b/gnu/lib/libg++/libio/iostdio.h @@ -82,8 +82,6 @@ typedef _IO_FILE FILE; #define perror _IO_perror #define printf _IO_printf #define puts _IO_puts -#define remove ??? __P((const char*)) -#define rename ??? __P((const char* _old, const char* _new)) #define rewind _IO_rewind #define scanf _IO_scanf #define setbuf _IO_setbuf @@ -91,13 +89,19 @@ typedef _IO_FILE FILE; #define setvbuf _IO_setvbuf #define sprintf _IO_sprintf #define sscanf _IO_sscanf -#define tmpfile ??? __P((void)) -#define tmpnam ??? __P((char*)) #define ungetc _IO_ungetc #define vfprintf _IO_vfprintf #define vprintf(__fmt, __args) vfprintf(stdout, __fmt, __args) #define vsprintf _IO_vsprintf +#if 0 +/* We can use the libc versions of these, since they don't pass FILE*s. */ +#define remove ??? __P((const char*)) +#define rename ??? __P((const char* _old, const char* _new)) +#define tmpfile ??? __P((void)) +#define tmpnam ??? __P((char*)) +#endif + #if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE) #define fdopen _IO_fdopen #define fileno _IO_fileno diff --git a/gnu/lib/libg++/libio/iostream.h b/gnu/lib/libg++/libio/iostream.h index fc3aaa84dd65..3c20aa5b26d6 100644 --- a/gnu/lib/libg++/libio/iostream.h +++ b/gnu/lib/libg++/libio/iostream.h @@ -233,7 +233,13 @@ public: extern _IO_istream_withassign cin; // clog->rdbuf() == cerr->rdbuf() -extern _IO_ostream_withassign cout, cerr, clog; +extern _IO_ostream_withassign cout, cerr; + +extern _IO_ostream_withassign clog +#if _G_CLOG_CONFLICT +__asm__ ("__IO_clog") +#endif +; struct Iostream_init { } ; // Compatibility hack for AT&T library. diff --git a/gnu/lib/libg++/libio/libio.h b/gnu/lib/libg++/libio/libio.h index 7080d1359d7d..84a8217ba495 100644 --- a/gnu/lib/libg++/libio/libio.h +++ b/gnu/lib/libg++/libio/libio.h @@ -169,6 +169,7 @@ struct _IO_FILE { #define _IO_file_flags _flags /* The following pointers correspond to the C++ streambuf protocol. */ + /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */ char* _IO_read_ptr; /* Current read pointer */ char* _IO_read_end; /* End of get area. */ char* _IO_read_base; /* Start of putback+get area. */ diff --git a/gnu/lib/libg++/libio/libioP.h b/gnu/lib/libg++/libio/libioP.h index 1b32a59de641..c7bc5224cabe 100644 --- a/gnu/lib/libg++/libio/libioP.h +++ b/gnu/lib/libg++/libio/libioP.h @@ -78,6 +78,15 @@ extern "C" { */ #define _IO_JUMPS(THIS) ((struct _IO_FILE_plus*)(THIS))->vtable +#ifdef _G_USING_THUNKS +#define JUMP_FIELD(TYPE, NAME) TYPE NAME +#define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC(THIS) +#define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC(THIS, X1) +#define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC(THIS, X1, X2) +#define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC(THIS, X1,X2, X3) +#define JUMP_INIT(NAME, VALUE) VALUE +#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT(dummy2, 0) +#else /* These macros will change when we re-implement vtables to use "thunks"! */ #define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME #define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC.pfn(THIS) @@ -86,6 +95,7 @@ extern "C" { #define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1,X2, X3) #define JUMP_INIT(NAME, VALUE) {0, 0, VALUE} #define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0) +#endif /* The 'finish' function does any final cleaning up of an _IO_FILE object. It does not delete (free) it, but does everything else to finalize it/ @@ -217,6 +227,9 @@ typedef int (*_IO_stat_t) __P((_IO_FILE*, void*)); struct _IO_jump_t { JUMP_FIELD(_G_size_t, __dummy); +#ifdef _G_USING_THUNKS + JUMP_FIELD(_G_size_t, __dummy2); +#endif JUMP_FIELD(_IO_finish_t, __finish); JUMP_FIELD(_IO_overflow_t, __overflow); JUMP_FIELD(_IO_underflow_t, __underflow); diff --git a/gnu/lib/libg++/libio/shlib_version b/gnu/lib/libg++/libio/shlib_version index 97c9f92d6b8f..3d7c908e43d6 100644 --- a/gnu/lib/libg++/libio/shlib_version +++ b/gnu/lib/libg++/libio/shlib_version @@ -1,2 +1,2 @@ major=0 -minor=0 +minor=1 diff --git a/gnu/lib/libg++/libio/stdiostream.h b/gnu/lib/libg++/libio/stdiostream.h index 73d49f96c22a..b973d7a39b62 100644 --- a/gnu/lib/libg++/libio/stdiostream.h +++ b/gnu/lib/libg++/libio/stdiostream.h @@ -58,7 +58,7 @@ class istdiostream : public istream private: stdiobuf _file; public: - istdiostream (FILE* __f) : _file(__f), istream() { init(&_file); } + istdiostream (FILE* __f) : istream(), _file(__f) { init(&_file); } stdiobuf* rdbuf()/* const */ { return &_file; } int buffered () const { return _file.buffered (); } void buffered (int _i) { _file.buffered (_i); } @@ -69,7 +69,7 @@ class ostdiostream : public ostream private: stdiobuf _file; public: - ostdiostream (FILE* __f) : _file(__f), ostream() { init(&_file); } + ostdiostream (FILE* __f) : ostream(), _file(__f) { init(&_file); } stdiobuf* rdbuf() /* const */ { return &_file; } int buffered () const { return _file.buffered (); } void buffered (int _i) { _file.buffered (_i); } diff --git a/gnu/lib/libg++/libio/stdstreams.cc b/gnu/lib/libg++/libio/stdstreams.cc index 051ca574fc8f..a5889d738e22 100644 --- a/gnu/lib/libg++/libio/stdstreams.cc +++ b/gnu/lib/libg++/libio/stdstreams.cc @@ -101,8 +101,8 @@ struct _fake_ostream { #endif #ifdef __GNUC__ -#define OSTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \ - _fake_ostream NAME = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }}; +#define OSTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS, ASM) \ + _fake_ostream NAME ASM = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }}; #define ISTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \ _fake_istream NAME = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }}; #else @@ -112,12 +112,16 @@ struct _fake_ostream { _fake_istream NAME = {{0, 0, &NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS)}}; #endif -OSTREAM_DEF(cout, COUT_SBUF, NULL, 0) -OSTREAM_DEF(cerr, CERR_SBUF,(ostream*)&cout, ios::unitbuf) +OSTREAM_DEF(cout, COUT_SBUF, NULL, 0, ) +OSTREAM_DEF(cerr, CERR_SBUF,(ostream*)&cout, ios::unitbuf, ) ISTREAM_DEF(cin, CIN_SBUF, (ostream*)&cout, 0) /* Only for (partial) compatibility with AT&T's library. */ -OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0) +#if _G_CLOG_CONFLICT +OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0, __asm__ ("__IO_clog")) +#else +OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0, ) +#endif // Switches between using _IO_std{in,out,err} and __std{in,out,err}_buf // for standard streams. This does not normally need to be called diff --git a/gnu/lib/libg++/libio/stream.cc b/gnu/lib/libg++/libio/stream.cc index db57bb476432..3440a0c9bdb4 100644 --- a/gnu/lib/libg++/libio/stream.cc +++ b/gnu/lib/libg++/libio/stream.cc @@ -23,6 +23,7 @@ This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */ #include +#include #include "libioP.h" #include "stream.h" #include "strstream.h" @@ -142,3 +143,28 @@ char* oct(unsigned int i, int len /* = 0 */) { return itoa(i, len, 0, 8); } + +static char *str(const char* s, int len, int width) +{ + if (width < len) + width = len; + int space_left = EndBuffer - next_chunk; + if (space_left <= width + 1) + next_chunk = Buffer; // start over. + char* buf = next_chunk; + memset (buf, ' ', width - len); + memcpy (buf + width - len, s, len); + buf[width] = 0; + return buf; +} + +char* str(const char* s, int width) +{ + return str (s, strlen (s), width); +} + +char* chr(char ch, int width) +{ + char c = ch; + return str (&c, 1, width); +} diff --git a/gnu/lib/libg++/libio/stream.h b/gnu/lib/libg++/libio/stream.h index 2a791dffebe6..0859802ade69 100644 --- a/gnu/lib/libg++/libio/stream.h +++ b/gnu/lib/libg++/libio/stream.h @@ -26,6 +26,8 @@ the executable file might be covered by the GNU General Public License. */ #define _COMPAT_STREAM_H // Compatibility with old library. +// DO NOT USE THESE FUNCTIONS IN NEW CODE! +// They are obsolete, non-standard, and non-reentrant. #define _STREAM_COMPAT #include diff --git a/gnu/lib/libg++/libio/streambuf.h b/gnu/lib/libg++/libio/streambuf.h index 9eab279759c9..688c891280e2 100644 --- a/gnu/lib/libg++/libio/streambuf.h +++ b/gnu/lib/libg++/libio/streambuf.h @@ -116,6 +116,7 @@ enum open_mode { class ios : public _ios_fields { ios& operator=(ios&); /* Not allowed! */ + ios (const ios&); /* Not allowed! */ public: typedef __fmtflags fmtflags; typedef int iostate; @@ -134,7 +135,8 @@ class ios : public _ios_fields { trunc = _IO_TRUNC, nocreate = _IO_NOCREATE, noreplace = _IO_NOREPLACE, - bin = _IOS_BIN }; + bin = _IOS_BIN, // Deprecated - ANSI uses ios::binary. + binary = _IOS_BIN }; enum seek_dir { beg, cur, end}; // ANSI: typedef enum seek_dir seekdir; etc // NOTE: If adding flags here, before to update ios::bitalloc(). diff --git a/gnu/lib/libg++/libio/strfile.h b/gnu/lib/libg++/libio/strfile.h index 55783bb5c1c7..d2ae4c028694 100644 --- a/gnu/lib/libg++/libio/strfile.h +++ b/gnu/lib/libg++/libio/strfile.h @@ -32,8 +32,6 @@ typedef void (*_IO_free_type) __P((void*)); struct _IO_str_fields { - /* The current length is max(_len, _IO_write_ptr-_IO_write_base). */ - _IO_size_t _len; _IO_alloc_type _allocate_buffer; _IO_free_type _free_buffer; }; @@ -44,3 +42,11 @@ typedef struct _IO_strfile_ const void *_vtable; struct _IO_str_fields _s; } _IO_strfile; + +/* dynamic: set when the array object is allocated (or reallocated) as + necessary to hold a character sequence that can change in length. */ +#define _IO_STR_DYNAMIC(FP) ((FP)->_s._allocate_buffer != (_IO_alloc_type)0) + +/* frozen: set when the program has requested that the array object not + be altered, reallocated, or freed. */ +#define _IO_STR_FROZEN(FP) ((FP)->_f._IO_file_flags & _IO_USER_BUF) diff --git a/gnu/lib/libg++/libio/strops.c b/gnu/lib/libg++/libio/strops.c index f4f45259fb32..c88a1335ffd6 100644 --- a/gnu/lib/libg++/libio/strops.c +++ b/gnu/lib/libg++/libio/strops.c @@ -26,7 +26,31 @@ the executable file might be covered by the GNU General Public License. */ #include "libioP.h" #include -#define LEN(fp) (((_IO_strfile*)(fp))->_s._len) +#if 0 +/* The following definitions are for exposition only. + They map the terminlogy used in the ANSI/ISO C++ draft standard + to the implementation. */ + +/* allocated: set when a dynamic array object has been allocated, and + hence should be freed by the destructor for the strstreambuf object. */ +#define ALLOCATED(FP) ((FP)->_f._IO_buf_base && DYNAMIC(FP)) + +/* constant: set when the array object has const elements, + so the output sequence cannot be written. */ +#define CONSTANT(FP) ((FP)->_f._IO_file_flags & _IO_NO_WRITES) + +/* alsize: the suggested minimum size for a dynamic array object. */ +#define ALSIZE(FP) ??? /* not stored */ + +/* palloc: points to the function to call to allocate a dynamic array object.*/ +#define PALLOC(FP) \ + ((FP)->_s._allocate_buffer == default_alloc ? 0 : (FP)->_s._allocate_buffer) + +/* pfree: points to the function to call to free a dynamic array object. */ +#define PFREE(FP) \ + ((FP)->_s._free_buffer == default_free ? 0 : (FP)->_s._free_buffer) + +#endif #ifdef TODO /* An "unbounded buffer" is when a buffer is supplied, but with no @@ -44,27 +68,17 @@ DEFUN(_IO_str_init_static, (fp, ptr, size, pstart), { /* If size is negative 'the characters are assumed to continue indefinitely.' This is kind of messy ... */ -#if 1 int s; size = 512; - /* Try increasing powers of 2, as long as we don't wrap around. - This can lose in pathological cases (ptr near the end - of the address space). A better solution might be to - adjust the size on underflow/overflow. FIXME. */ - for (s; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; ) + /* Try increasing powers of 2, as long as we don't wrap around. */ + for (; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; ) size = s; - size = s; -#else - /* The following semi-portable kludge assumes that - sizeof(unsigned long) == sizeof(char*). Hence, - (unsigned long)(-1) should be the largest possible address. */ - unsigned long highest = (unsigned long)(-1); - /* Pointers are signed on some brain-damaged systems, in - which case we divide by two to get the maximum signed address. */ - if ((char*)highest < ptr) - highest >>= 1; - size = (char*)highest - ptr; -#endif + /* Try increasing size as much as we can without wrapping around. */ + for (s = size >> 1; s > 0; s >>= 1) + { + if (ptr + size + s > ptr) + size += s; + } } _IO_setb(fp, ptr, ptr+size, 0); @@ -83,7 +97,6 @@ DEFUN(_IO_str_init_static, (fp, ptr, size, pstart), fp->_IO_write_end = ptr; fp->_IO_read_end = ptr+size; } - LEN(fp) = size; /* A null _allocate_buffer function flags the strfile as being static. */ (((_IO_strfile*)(fp))->_s._allocate_buffer) = (_IO_alloc_type)0; } @@ -101,34 +114,25 @@ DEFUN(_IO_str_overflow, (fp, c), register _IO_FILE* fp AND int c) { int flush_only = c == EOF; - _IO_size_t pos = fp->_IO_write_ptr - fp->_IO_write_base; - _IO_size_t get_pos = fp->_IO_read_ptr - fp->_IO_read_base; + _IO_size_t pos; if (fp->_flags & _IO_NO_WRITES) return flush_only ? 0 : EOF; - if (pos > LEN(fp)) LEN(fp) = pos; if ((fp->_flags & _IO_TIED_PUT_GET) && !(fp->_flags & _IO_CURRENTLY_PUTTING)) { - pos = get_pos; fp->_flags |= _IO_CURRENTLY_PUTTING; - get_pos = LEN(fp); + fp->_IO_write_ptr = fp->_IO_read_ptr; + fp->_IO_read_ptr = fp->_IO_read_end; } + pos = fp->_IO_write_ptr - fp->_IO_write_base; if (pos >= _IO_blen(fp) + flush_only) { if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */ - { -#ifdef TODO - if (indefinite size) - { - fp->_IO_buf_end += 512; - } - else -#endif - return EOF; - } + return EOF; else { char *new_buf; - _IO_size_t new_size = 2 * _IO_blen(fp); + char *old_buf = fp->_IO_buf_base; + _IO_size_t new_size = 2 * _IO_blen(fp) + 100; new_buf = (char*)(*((_IO_strfile*)fp)->_s._allocate_buffer)(new_size); if (new_buf == NULL) @@ -136,31 +140,32 @@ DEFUN(_IO_str_overflow, (fp, c), /* __ferror(fp) = 1; */ return EOF; } - memcpy(new_buf, fp->_IO_buf_base, _IO_blen(fp)); -#if 0 - if (lenp == &LEN(fp)) /* use '\0'-filling */ - memset(new_buf + pos, 0, blen() - pos); -#endif if (fp->_IO_buf_base) { + memcpy(new_buf, old_buf, _IO_blen(fp)); (*((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base); /* Make sure _IO_setb won't try to delete _IO_buf_base. */ fp->_IO_buf_base = NULL; } +#if 0 + if (lenp == &LEN(fp)) /* use '\0'-filling */ + memset(new_buf + pos, 0, blen() - pos); +#endif _IO_setb(fp, new_buf, new_buf + new_size, 1); + fp->_IO_read_base = new_buf + (fp->_IO_read_base - old_buf); + fp->_IO_read_ptr = new_buf + (fp->_IO_read_ptr - old_buf); + fp->_IO_read_end = new_buf + (fp->_IO_read_end - old_buf); + fp->_IO_write_ptr = new_buf + (fp->_IO_write_ptr - old_buf); + fp->_IO_write_base = new_buf; + fp->_IO_write_end = fp->_IO_buf_end; } - fp->_IO_write_end = fp->_IO_buf_end; } - fp->_IO_write_ptr = fp->_IO_buf_base + pos; - - fp->_IO_read_base = fp->_IO_buf_base; - fp->_IO_read_ptr = fp->_IO_buf_base + get_pos; - fp->_IO_read_end = fp->_IO_buf_base + LEN(fp); - if (!flush_only) *fp->_IO_write_ptr++ = (unsigned char) c; + if (fp->_IO_write_ptr > fp->_IO_read_end) + fp->_IO_read_end = fp->_IO_write_ptr; return c; } @@ -168,28 +173,29 @@ int DEFUN(_IO_str_underflow, (fp), register _IO_FILE* fp) { - _IO_size_t ppos = fp->_IO_write_ptr - fp->_IO_write_base; - if (ppos > LEN(fp)) LEN(fp) = ppos; + if (fp->_IO_write_ptr > fp->_IO_read_end) + fp->_IO_read_end = fp->_IO_write_ptr; if ((fp->_flags & _IO_TIED_PUT_GET) && (fp->_flags & _IO_CURRENTLY_PUTTING)) { fp->_flags &= ~_IO_CURRENTLY_PUTTING; + fp->_IO_read_ptr = fp->_IO_write_ptr; fp->_IO_write_ptr = fp->_IO_write_end; } - fp->_IO_read_end = fp->_IO_read_base + LEN(fp); if (fp->_IO_read_ptr < fp->_IO_read_end) return *fp->_IO_read_ptr; else return EOF; } +/* The size of the valid part of the buffer. */ + _IO_ssize_t DEFUN(_IO_str_count, (fp), register _IO_FILE *fp) { - _IO_ssize_t put_len = fp->_IO_write_ptr - fp->_IO_write_base; - if (put_len < LEN(fp)) - put_len = LEN(fp); - return put_len; + return (fp->_IO_write_ptr > fp->_IO_read_end ? fp->_IO_write_ptr + : fp->_IO_read_end) + - fp->_IO_read_base; } _IO_pos_t @@ -236,7 +242,6 @@ DEFUN(_IO_str_seekoff, (fp, offset, dir, mode), } if (offset < 0 || (_IO_size_t)offset > cur_size) return EOF; - LEN(fp) = cur_size; fp->_IO_write_ptr = fp->_IO_write_base + offset; new_pos = offset; } diff --git a/gnu/lib/libg++/libio/strstream.cc b/gnu/lib/libg++/libio/strstream.cc index 3e1d5a6bfa6d..a32e811c9d94 100644 --- a/gnu/lib/libg++/libio/strstream.cc +++ b/gnu/lib/libg++/libio/strstream.cc @@ -41,68 +41,16 @@ static void default_free(void* ptr) delete [] (char*)ptr; } -#if _IO_UNIFIED_JUMPTABLES -#define SET_STR_JUMPS(STRBUF) /* Nothing */ -#else -/* Set to use the _IO_str_jump jumptable, for efficiency */ - -#define SET_STR_JUMPS(STRBUF) \ - (STRBUF)->_jumps = &_IO_str_jumps,\ - (STRBUF)->_vtable() = builtinbuf_vtable; -#endif - istrstream::istrstream(const char *cp, int n) { -#ifdef _IO_NEW_STREAMS __my_sb.init_readonly (cp, n); - init (&__my_sb); -#else - init(new strstreambuf(cp, n)); - _flags &= ~ios::dont_close; -#endif - SET_STR_JUMPS(_strbuf); -} - -ostrstream::ostrstream() -{ -#ifdef _IO_NEW_STREAMS - init (&__my_sb); -#else - init(new strstreambuf()); - _flags &= ~ios::dont_close; -#endif - SET_STR_JUMPS(_strbuf); -} - -strstream::strstream() -{ -#ifdef _IO_NEW_STREAMS - init (&__my_sb); -#else - init(new strstreambuf()); - _flags &= ~ios::dont_close; -#endif - SET_STR_JUMPS(_strbuf); } strstreambase::strstreambase(char *cp, int n, int mode) -#ifdef _IO_NEW_STREAMS : __my_sb (cp, n, (mode == ios::app || mode == ios::ate) ? cp + strlen(cp) : cp) -#endif { -#ifdef _IO_NEW_STREAMS init (&__my_sb); -#else - char *pstart; - if (mode == ios::app || mode == ios::ate) - pstart = cp + strlen(cp); - else - pstart = cp; - init(new strstreambuf(cp, n, pstart)); - _flags &= ~ios::dont_close; -#endif - SET_STR_JUMPS(_strbuf); } char *strstreambuf::str() @@ -128,15 +76,15 @@ void strstreambuf::init_dynamic(_IO_alloc_type alloc, _IO_free_type free, int initial_size) { - _s._len = 0; - if (initial_size < 16) - initial_size = 16; _s._allocate_buffer = alloc ? alloc : default_alloc; _s._free_buffer = free ? free : default_free; - char * buf = (char*)(*_s._allocate_buffer)(initial_size); - setb(buf, buf + initial_size, 1); - setp(buf, buf + initial_size); - setg(buf, buf, buf); + if (initial_size > 0) + { + char * buf = (char*)(*_s._allocate_buffer)(initial_size); + setb(buf, buf + initial_size, 1); + setp(buf, buf + initial_size); + setg(buf, buf, buf); + } } void strstreambuf::init_static(char *ptr, int size, char *pstart) diff --git a/gnu/lib/libg++/libio/strstream.h b/gnu/lib/libg++/libio/strstream.h index 86a8a687587a..d549b4547588 100644 --- a/gnu/lib/libg++/libio/strstream.h +++ b/gnu/lib/libg++/libio/strstream.h @@ -39,11 +39,10 @@ class strstreambuf : public streambuf friend class istrstream; void init_dynamic(_IO_alloc_type alloc, _IO_free_type free, - int initial_size = 128); + int initial_size = 0); void init_static(char *ptr, int size, char *pstart); void init_readonly(const char *ptr, int size); protected: - int is_static() const { return _s._allocate_buffer == (_IO_alloc_type)0; } virtual int overflow(int = EOF); virtual int underflow(); virtual int pbackfail(int c); @@ -65,10 +64,10 @@ class strstreambuf : public streambuf { init_static((char*)ptr, size, (char*)pstart); } strstreambuf(const signed char *ptr, int size) { init_readonly((const char*)ptr, size); } - // Note: frozen() is always true if is_static(). + // Note: frozen() is always true if !_IO_STR_DYNAMIC(this). int frozen() { return _flags & _IO_USER_BUF ? 1 : 0; } void freeze(int n=1) - { if (!is_static()) + { if (_IO_STR_DYNAMIC(this)) { if (n) _flags |= _IO_USER_BUF; else _flags &= ~_IO_USER_BUF; } } _IO_ssize_t pcount(); char *str(); @@ -76,21 +75,12 @@ class strstreambuf : public streambuf }; class strstreambase : virtual public ios { -#ifdef _IO_NEW_STREAMS protected: strstreambuf __my_sb; -#endif public: -#ifdef _IO_NEW_STREAMS strstreambuf* rdbuf() { return &__my_sb; } -#else - strstreambuf* rdbuf() { return (strstreambuf*)ios::rdbuf(); } -#endif protected: - strstreambase() { } -#ifdef _IO_NEW_STREAMS - strstreambase(char *cp, int n); -#endif + strstreambase() { init (&__my_sb); } strstreambase(char *cp, int n, int mode=ios::out); }; @@ -101,7 +91,7 @@ class istrstream : public strstreambase, public istream { class ostrstream : public strstreambase, public ostream { public: - ostrstream(); + ostrstream() { } ostrstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){} _IO_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); } char *str() { return ((strstreambuf*)_strbuf)->str(); } @@ -111,7 +101,7 @@ class ostrstream : public strstreambase, public ostream { class strstream : public strstreambase, public iostream { public: - strstream(); + strstream() { } strstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){} _IO_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); } char *str() { return ((strstreambuf*)_strbuf)->str(); } diff --git a/gnu/lib/libg++/libiostream/shlib_version b/gnu/lib/libg++/libiostream/shlib_version index 97c9f92d6b8f..3d7c908e43d6 100644 --- a/gnu/lib/libg++/libiostream/shlib_version +++ b/gnu/lib/libg++/libiostream/shlib_version @@ -1,2 +1,2 @@ major=0 -minor=0 +minor=1 diff --git a/gnu/lib/libg++/librx/rx.c b/gnu/lib/libg++/librx/rx.c index c021e0a2c8c3..6a93834f55d4 100644 --- a/gnu/lib/libg++/librx/rx.c +++ b/gnu/lib/libg++/librx/rx.c @@ -5148,9 +5148,10 @@ rx_compile (pattern, size, syntax, rxb) if (!zero_times_ok) { struct rexp_node * concat - = rx_mk_r_concat (&rxb->rx, inner_exp, + = rx_mk_r_concat (&rxb->rx, rx_copy_rexp (&rxb->rx, - *last_expression)); + inner_exp), + *last_expression); if (!concat) return REG_ESPACE; *last_expression = concat; diff --git a/gnu/lib/libg++/libstdc++/queue b/gnu/lib/libg++/libstdc++/queue index 9b2b6d6c1564..e71ce343067c 100644 --- a/gnu/lib/libg++/libstdc++/queue +++ b/gnu/lib/libg++/libstdc++/queue @@ -3,5 +3,5 @@ #ifndef __QUEUE__ #define __QUEUE__ -#include +#include #endif diff --git a/gnu/lib/libg++/libstdc++/shlib_version b/gnu/lib/libg++/libstdc++/shlib_version index 97c9f92d6b8f..3d7c908e43d6 100644 --- a/gnu/lib/libg++/libstdc++/shlib_version +++ b/gnu/lib/libg++/libstdc++/shlib_version @@ -1,2 +1,2 @@ major=0 -minor=0 +minor=1 diff --git a/gnu/lib/libg++/libstdc++/std/bastring.cc b/gnu/lib/libg++/libstdc++/std/bastring.cc index d3317c500840..92c69d845b22 100644 --- a/gnu/lib/libg++/libstdc++/std/bastring.cc +++ b/gnu/lib/libg++/libstdc++/std/bastring.cc @@ -86,7 +86,7 @@ template inline bool basic_string :: check_realloc (size_t s) const { - ++s; + s += sizeof (charT); return (rep ()->ref > 1 || s > capacity () || Rep::excess_slop (s, capacity ())); @@ -154,7 +154,7 @@ replace (size_t pos, size_t n1, const charT* s, size_t n2) OUTOFRANGE (pos > len); if (n1 > len - pos) n1 = len - pos; - LENGTHERROR (len - n1 >= npos - n2); + LENGTHERROR (len - n1 > max_size () - n2); size_t newlen = len - n1 + n2; if (check_realloc (newlen)) @@ -190,7 +190,7 @@ replace (size_t pos, size_t n1, size_t n2, charT c) OUTOFRANGE (pos > len); if (n1 > len - pos) n1 = len - pos; - LENGTHERROR (len - n1 >= npos - n2); + LENGTHERROR (len - n1 > max_size () - n2); size_t newlen = len - n1 + n2; if (check_realloc (newlen)) @@ -215,7 +215,7 @@ template void basic_string :: resize (size_t n, charT c) { - LENGTHERROR (n == npos); + LENGTHERROR (n > max_size ()); if (n > length ()) append (n - length (), c); @@ -269,6 +269,9 @@ template size_t basic_string :: rfind (const charT* s, size_t pos, size_t n) const { + if (n > length ()) + return npos; + size_t xpos = length () - n; if (xpos > pos) xpos = pos; @@ -284,6 +287,9 @@ template size_t basic_string :: rfind (charT c, size_t pos) const { + if (1 > length ()) + return npos; + size_t xpos = length () - 1; if (xpos > pos) xpos = pos; diff --git a/gnu/lib/libg++/libstdc++/std/bastring.h b/gnu/lib/libg++/libstdc++/std/bastring.h index 6361ef27cca8..d6174a21f92d 100644 --- a/gnu/lib/libg++/libstdc++/std/bastring.h +++ b/gnu/lib/libg++/libstdc++/std/bastring.h @@ -139,7 +139,7 @@ public: size_type capacity () const { return rep ()->res; } size_type max_size () const - { return npos - 1; } // XXX + { return (npos - 1)/sizeof (charT); } // XXX bool empty () const { return size () == 0; } @@ -221,20 +221,20 @@ public: basic_string& insert (size_type pos, size_type n, charT c) { return replace (pos, 0, n, c); } iterator insert(iterator p, charT c) - { insert (p - begin (), 1, c); return p; } + { size_type pos = p - begin (); insert (pos, 1, c); return pos +begin (); } iterator insert(iterator p, size_type n, charT c) - { insert (p - begin (), n, c); return p; } + { size_type pos = p - begin (); insert (pos, n, c); return pos +begin (); } #if 0 template void insert(iterator p, InputIterator first, InputIterator last); #endif basic_string& remove (size_type pos = 0, size_type n = npos) - { return replace (pos, n, 0, (charT)0); } + { return replace (pos, n, (size_type)0, (charT)0); } basic_string& remove (iterator pos) - { return replace (pos - begin (), 1, 0, (charT)0); } + { return replace (pos - begin (), 1, (size_type)0, (charT)0); } basic_string& remove (iterator first, iterator last) - { return replace (first - begin (), last - first, 0, (charT)0); } + { return replace (first - begin (), last - first, (size_type)0, (charT)0);} basic_string& replace (size_type pos1, size_type n1, const basic_string& str, size_type pos2 = 0, size_type n2 = npos); diff --git a/gnu/lib/libg++/libstdc++/stl/deque.h b/gnu/lib/libg++/libstdc++/stl/deque.h index f05de7b09f0c..dc790142b54d 100644 --- a/gnu/lib/libg++/libstdc++/stl/deque.h +++ b/gnu/lib/libg++/libstdc++/stl/deque.h @@ -374,6 +374,9 @@ public: friend T* value_type(const iterator&) { return (T*)(0); } + friend inline difference_type* distance_type(const iterator&) { + return (difference_type*)(0); + } #endif }; diff --git a/gnu/lib/libg++/libstdc++/typeinfoi.cc b/gnu/lib/libg++/libstdc++/typeinfoi.cc index 01274e009f40..8daa17764f4a 100644 --- a/gnu/lib/libg++/libstdc++/typeinfoi.cc +++ b/gnu/lib/libg++/libstdc++/typeinfoi.cc @@ -38,10 +38,11 @@ // object pointer that points to the sub-object that is matched is // returned. -void* __class_type_info::__rtti_match(const type_info& desired, int is_public, - void *objptr) const +void* +__class_type_info::__rtti_match (const type_info& desired, int is_public, + void *objptr) const { - if (__rtti_compare(desired) == 0) + if (__rtti_compare (desired) == 0) return objptr; void *match_found = 0; @@ -52,7 +53,7 @@ void* __class_type_info::__rtti_match(const type_info& desired, int is_public, if (is_virtual_list[i]) p = *(void **)p; - if ((p=base_list[i]->__rtti_match(desired, is_public, p)) + if ((p=base_list[i]->__rtti_match (desired, is_public, p)) != 0) if (match_found == 0) match_found = p; @@ -66,8 +67,9 @@ void* __class_type_info::__rtti_match(const type_info& desired, int is_public, return match_found; } -void* __pointer_type_info::__rtti_match(const type_info& catch_type, int, - void *objptr) const +void* +__pointer_type_info::__rtti_match (const type_info& catch_type, int, + void *objptr) const { if (catch_type.__rtti_get_node_type () == __rtti_get_node_type()) { @@ -113,15 +115,15 @@ __throw_type_match_rtti (void *catch_type_r, void *throw_type_r, void *objptr) return 0; #if 0 - printf("We want to match a %s against a %s!\n", - throw_type.name(), catch_type.name()); + printf ("We want to match a %s against a %s!\n", + throw_type.name (), catch_type.name ()); #endif /* The 1 skips conversions to private bases. */ new_objptr = throw_type.__rtti_match (catch_type, 1, objptr); #if 0 if (new_objptr) - printf("It converts, delta is %d\n", new_objptr-objptr); + printf ("It converts, delta is %d\n", new_objptr-objptr); #endif return new_objptr; }