diff options
Diffstat (limited to 'gnu/lib/libg++/include')
72 files changed, 0 insertions, 15468 deletions
diff --git a/gnu/lib/libg++/include/ACG.h b/gnu/lib/libg++/include/ACG.h deleted file mode 100644 index fc16e2a82044..000000000000 --- a/gnu/lib/libg++/include/ACG.h +++ /dev/null @@ -1,68 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _ACG_h -#define _ACG_h 1 - -#include <RNG.h> -#include <math.h> -#ifdef __GNUG__ -#pragma interface -#endif - -// -// Additive number generator. This method is presented in Volume II -// of The Art of Computer Programming by Knuth. I've coded the algorithm -// and have added the extensions by Andres Nowatzyk of CMU to randomize -// the result of algorithm M a bit by using an LCG & a spatial -// permutation table. -// -// The version presented uses the same constants for the LCG that Andres -// uses (chosen by trial & error). The spatial permutation table is -// the same size (it's based on word size). This is for 32-bit words. -// -// The ``auxillary table'' used by the LCG table varies in size, and -// is chosen to be the the smallest power of two which is larger than -// twice the size of the state table. -// - -class ACG : public RNG { - - _G_uint32_t initialSeed; // used to reset generator - int initialTableEntry; - - _G_uint32_t *state; - _G_uint32_t *auxState; - short stateSize; - short auxSize; - _G_uint32_t lcgRecurr; - short j; - short k; - -protected: - -public: - ACG(_G_uint32_t seed = 0, int size = 55); - virtual ~ACG(); - // - // Return a long-words word of random bits - // - virtual _G_uint32_t asLong(); - virtual void reset(); -}; - -#endif diff --git a/gnu/lib/libg++/include/AllocRing.h b/gnu/lib/libg++/include/AllocRing.h deleted file mode 100644 index f2f5db57d0e3..000000000000 --- a/gnu/lib/libg++/include/AllocRing.h +++ /dev/null @@ -1,62 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1989 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -#ifndef _AllocRing_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _AllocRing_h 1 - - -/* - An AllocRing holds the last n malloc'ed strings, reallocating/reusing - one only when the queue wraps around. It thus guarantees that the - last n allocations are intact. It is useful for things like I/O - formatting where reasonable restrictions may be made about the - number of allowable live allocations before auto-deletion. -*/ - -class AllocRing -{ - - struct AllocQNode - { - void* ptr; - int sz; - }; - - AllocQNode* nodes; - int n; - int current; - - int find(void* p); - -public: - - AllocRing(int max); - ~AllocRing(); - - void* alloc(int size); - int contains(void* ptr); - void clear(); - void free(void* p); -}; - - -#endif diff --git a/gnu/lib/libg++/include/Binomial.h b/gnu/lib/libg++/include/Binomial.h deleted file mode 100644 index f02730bf49aa..000000000000 --- a/gnu/lib/libg++/include/Binomial.h +++ /dev/null @@ -1,55 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _Binomial_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Binomial_h 1 - -#include <Random.h> - -class Binomial: public Random { -protected: - int pN; - double pU; -public: - Binomial(int n, double u, RNG *gen); - - int n(); - int n(int xn); - - double u(); - double u(int xu); - - virtual double operator()(); - -}; - - -inline Binomial::Binomial(int n, double u, RNG *gen) -: Random(gen){ - pN = n; pU = u; -} - -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; } - -#endif diff --git a/gnu/lib/libg++/include/BitSet.h b/gnu/lib/libg++/include/BitSet.h deleted file mode 100644 index c80e3274bae4..000000000000 --- a/gnu/lib/libg++/include/BitSet.h +++ /dev/null @@ -1,374 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _BitSet_h -#ifdef __GNUG__ -#pragma interface -#endif - -#define _BitSet_h 1 - -#include <iostream.h> -#include <limits.h> - -#define BITSETBITS (sizeof(short) * CHAR_BIT) - -struct BitSetRep -{ - unsigned short len; // number of shorts in s - unsigned short sz; // allocated slots - unsigned short virt; // virtual 0 or 1 - unsigned short s[1]; // bits start here -}; - -extern BitSetRep* BitSetalloc(BitSetRep*, const unsigned short*, - int, int, int); -extern BitSetRep* BitSetcopy(BitSetRep*, const BitSetRep*); -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; - -class BitSetBit -{ -protected: - BitSet* src; - unsigned long pos; - - public: - BitSetBit(BitSet* v, int p); - BitSetBit(const BitSetBit& b); - ~BitSetBit(); - operator int() const; - int operator = (int b); - int operator = (const BitSetBit& b); -}; - -class BitSet -{ -protected: - BitSetRep* rep; - - -public: - -// constructors - BitSet(); - BitSet(const BitSet&); - - ~BitSet(); - - BitSet& operator = (const BitSet& y); - -// equality & subset tests - - friend int operator == (const BitSet& x, const BitSet& y); - friend int operator != (const BitSet& x, const BitSet& y); - friend int operator < (const BitSet& x, const BitSet& y); - friend int operator <= (const BitSet& x, const BitSet& y); - friend int operator > (const BitSet& x, const BitSet& y); - friend int operator >= (const BitSet& x, const BitSet& y); - - -// operations on self - - BitSet& operator |= (const BitSet& y); - BitSet& operator &= (const BitSet& y); - BitSet& operator -= (const BitSet& y); - BitSet& operator ^= (const BitSet& y); - - void complement(); - -// individual bit manipulation - - void set(int pos); - void set(int from, int to); - void set(); // set all - - void clear(int pos); - void clear(int from, int to); - void clear(); // clear all - - void invert(int pos); - void invert(int from, int to); - - int test(int pos) const; - int test(int from, int to) const; - - BitSetBit operator [] (int i); - -// iterators - - int first(int b = 1) const; - int last(int b = 1) const; - - int next(int pos, int b = 1) const; - int prev(int pos, int b = 1) const; - int previous(int pos, int b = 1) const /* Obsolete synonym */ - { return prev(pos, b); } - -// status - - int empty() const; - int virtual_bit() const; - int count(int b = 1) const; - -// convertors & IO - - friend BitSet atoBitSet(const char* s, - char f='0', char t='1', char star='*'); - // BitSettoa is deprecated; do not use in new programs. - friend const char* BitSettoa(const BitSet& x, - char f='0', char t='1', char star='*'); - - friend BitSet shorttoBitSet(unsigned short w); - friend BitSet longtoBitSet(unsigned long w); - - friend ostream& operator << (ostream& s, const BitSet& x); - void printon(ostream& s, - char f='0', char t='1', char star='*') const; - -// procedural versions of operators - - 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); - -// misc - - void error(const char* msg) const; - int OK() const; -}; - - -typedef BitSet BitSetTmp; - - - BitSet operator | (const BitSet& x, const BitSet& y); - BitSet operator & (const BitSet& x, const BitSet& y); - BitSet operator - (const BitSet& x, const BitSet& y); - BitSet operator ^ (const BitSet& x, const BitSet& y); - - BitSet operator ~ (const BitSet& x); - -// These are inlined regardless of optimization - -inline int BitSet_index(int l) -{ - return (unsigned)(l) / BITSETBITS; -} - -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)) {} - -inline BitSet::~BitSet() { if (rep != &_nilBitSetRep) delete rep; } - -inline BitSet& BitSet::operator = (const BitSet& y) -{ - rep = BitSetcopy(rep, y.rep); - return *this; -} - -inline int operator != (const BitSet& x, const BitSet& y) { return !(x == y); } - -inline int operator > (const BitSet& x, const BitSet& y) { return y < x; } - -inline int operator >= (const BitSet& x, const BitSet& y) { return y <= x; } - -inline void and(const BitSet& x, const BitSet& y, BitSet& r) -{ - r.rep = BitSetop(x.rep, y.rep, r.rep, '&'); -} - -inline void or(const BitSet& x, const BitSet& y, BitSet& r) -{ - r.rep = BitSetop(x.rep, y.rep, r.rep, '|'); -} - -inline void xor(const BitSet& x, const BitSet& y, BitSet& r) -{ - r.rep = BitSetop(x.rep, y.rep, r.rep, '^'); -} - -inline void diff(const BitSet& x, const BitSet& y, BitSet& r) -{ - r.rep = BitSetop(x.rep, y.rep, r.rep, '-'); -} - -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 */ - -inline BitSet operator & (const BitSet& x, const BitSet& y) -{ - BitSet r; and(x, y, r); return r; -} - -inline BitSet operator | (const BitSet& x, const BitSet& y) -{ - BitSet r; or(x, y, r); return r; -} - -inline BitSet operator ^ (const BitSet& x, const BitSet& y) -{ - BitSet r; xor(x, y, r); return r; -} - -inline BitSet operator - (const BitSet& x, const BitSet& y) -{ - BitSet r; diff(x, y, r); return r; -} - -inline BitSet operator ~ (const BitSet& x) -{ - BitSet r; ::complement(x, r); return r; -} - -#endif - -inline BitSet& BitSet::operator &= (const BitSet& y) -{ - and(*this, y, *this); - return *this; -} - -inline BitSet& BitSet::operator |= (const BitSet& y) -{ - or(*this, y, *this); - return *this; -} - -inline BitSet& BitSet::operator ^= (const BitSet& y) -{ - xor(*this, y, *this); - return *this; -} - -inline BitSet& BitSet::operator -= (const BitSet& y) -{ - diff(*this, y, *this); - return *this; -} - - -inline void BitSet::complement() -{ - ::complement(*this, *this); -} - -inline int BitSet::virtual_bit() const -{ - return rep->virt; -} - -inline int BitSet::first(int b) const -{ - return next(-1, b); -} - -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); -} - - -inline void BitSet::set() -{ - rep = BitSetalloc(rep, 0, 0, 1, 0); -} - -inline BitSetBit::BitSetBit(const BitSetBit& b) :src(b.src), pos(b.pos) {} - -inline BitSetBit::BitSetBit(BitSet* v, int p) -{ - src = v; pos = p; -} - -inline BitSetBit::~BitSetBit() {} - -inline BitSetBit::operator int() const -{ - return src->test(pos); -} - -inline int BitSetBit::operator = (int b) -{ - if (b) src->set(pos); else src->clear(pos); return b; -} - -inline int BitSetBit::operator = (const BitSetBit& b) -{ - int i = (int)b; - *this = i; - return i; -} - -inline BitSetBit BitSet::operator [] (int i) -{ - if (i < 0) error("illegal bit index"); - return BitSetBit(this, i); -} - -#endif diff --git a/gnu/lib/libg++/include/BitString.h b/gnu/lib/libg++/include/BitString.h deleted file mode 100644 index f30b440afaa3..000000000000 --- a/gnu/lib/libg++/include/BitString.h +++ /dev/null @@ -1,761 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _BitString_h -#ifdef __GNUG__ -#pragma interface -#endif - -#define _BitString_h 1 - -#include <stream.h> -#include <limits.h> - -#include <bitprims.h> -#define BITSTRBITS _BS_BITS_PER_WORD - -struct BitStrRep -{ - unsigned int len; // length in bits - unsigned short sz; // allocated slots - _BS_word s[1]; // bits start here -}; - -extern BitStrRep* BStr_alloc(BitStrRep*, const _BS_word*, int, int,int); -extern BitStrRep* BStr_resize(BitStrRep*, int); -extern BitStrRep* BStr_copy(BitStrRep*, const BitStrRep*); -extern BitStrRep* cmpl(const BitStrRep*, BitStrRep*); -extern BitStrRep* and(const BitStrRep*, const BitStrRep*, BitStrRep*); -extern BitStrRep* or(const BitStrRep*, const BitStrRep*, BitStrRep*); -extern BitStrRep* xor(const BitStrRep*, const BitStrRep*, BitStrRep*); -extern BitStrRep* diff(const BitStrRep*, const BitStrRep*, BitStrRep*); -extern BitStrRep* cat(const BitStrRep*, const BitStrRep*, BitStrRep*); -extern BitStrRep* cat(const BitStrRep*, unsigned int, BitStrRep*); -extern BitStrRep* lshift(const BitStrRep*, int, BitStrRep*); - - -class BitString; -class BitPattern; - -class BitStrBit -{ -protected: - BitString& src; - unsigned int pos; - - public: - BitStrBit(BitString& v, int p); - BitStrBit(const BitStrBit& b); - ~BitStrBit(); - operator unsigned int() const; - int operator = (unsigned int b); -}; - -class BitSubString -{ - friend class BitString; - friend class BitPattern; - -protected: - - BitString& S; - unsigned int pos; - unsigned int len; - - BitSubString(BitString& x, int p, int l); - BitSubString(const BitSubString& x); -public: - ~BitSubString(); - - BitSubString& operator = (const BitString&); - BitSubString& operator = (const BitSubString&); - - int length() const; - int empty() const; - - int OK() const; -}; - -class BitString -{ - friend class BitSubString; - friend class BitPattern; -protected: - BitStrRep* rep; - - int search(int, int, const _BS_word*, int, int) const; - int match(int, int, int, const _BS_word*,int,int) const; - BitSubString _substr(int first, int l); - -public: - -// constructors - BitString(); - BitString(const BitString&); - BitString(const BitSubString& y); - - ~BitString(); - - BitString& operator = (unsigned int bit); - BitString& operator = (const BitString& y); - BitString& operator = (const BitSubString& y); - -// equality & subset tests - - friend int operator == (const BitString&, const BitString&); - friend int operator != (const BitString&, const BitString&); - friend int operator < (const BitString&, const BitString&); - friend int operator <= (const BitString&, const BitString&); - friend int operator > (const BitString&, const BitString&); - friend int operator >= (const BitString&, const BitString&); - -// procedural versions of operators - - - friend void and(const BitString&, const BitString&, BitString&); - friend void or(const BitString&, const BitString&, BitString&); - friend void xor(const BitString&, const BitString&, BitString&); - friend void diff(const BitString&, const BitString&, BitString&); - friend void cat(const BitString&, const BitString&, BitString&); - friend void cat(const BitString&, unsigned int, BitString&); - friend void lshift(const BitString&, int, BitString&); - friend void rshift(const BitString&, int, BitString&); - - friend void complement(const BitString&, BitString&); - - friend int lcompare(const BitString&, const BitString&); - -// assignment-based operators -// (constuctive versions decalred inline below - - BitString& operator |= (const BitString&); - BitString& operator &= (const BitString&); - BitString& operator -= (const BitString&); - BitString& operator ^= (const BitString&); - BitString& operator += (const BitString&); - BitString& operator += (unsigned int b); - BitString& operator <<=(int s); - BitString& operator >>=(int s); - - void complement(); - -// individual bit manipulation - - void set(int pos); - void set(int from, int to); - void set(); - - void clear(int pos); - void clear(int from, int to); - void clear(); - - void invert(int pos); - void invert(int from, int to); - - int test(int pos) const; - int test(int from, int to) const; - - void assign(int p, unsigned int bit); - -// indexing - - BitStrBit operator [] (int pos); - -// iterators - - int first(unsigned int bit = 1) const; - int last(unsigned int b = 1) const; - - int next(int pos, unsigned int b = 1) const; - int prev(int pos, unsigned int b = 1) const; - int previous(int pos, unsigned int b = 1) const - { return prev(pos, b); } /* Obsolete synonym */ - -// searching & matching - - int index(unsigned int bit, int startpos = 0) const ; - int index(const BitString&, int startpos = 0) const; - int index(const BitSubString&, int startpos = 0) const; - int index(const BitPattern&, int startpos = 0) const; - - int contains(const BitString&) const; - int contains(const BitSubString&) const; - int contains(const BitPattern&) const; - - int contains(const BitString&, int pos) const; - int contains(const BitSubString&, int pos) const; - int contains(const BitPattern&, int pos) const; - - int matches(const BitString&, int pos = 0) const; - int matches(const BitSubString&, int pos = 0) const; - int matches(const BitPattern&, int pos = 0) const; - -// BitSubString extraction - - BitSubString at(int pos, int len); - BitSubString at(const BitString&, int startpos = 0); - BitSubString at(const BitSubString&, int startpos = 0); - BitSubString at(const BitPattern&, int startpos = 0); - - BitSubString before(int pos); - BitSubString before(const BitString&, int startpos = 0); - BitSubString before(const BitSubString&, int startpos = 0); - BitSubString before(const BitPattern&, int startpos = 0); - - BitSubString after(int pos); - BitSubString after(const BitString&, int startpos = 0); - BitSubString after(const BitSubString&, int startpos = 0); - BitSubString after(const BitPattern&, int startpos = 0); - -// other friends & utilities - - friend BitString common_prefix(const BitString&, const BitString&, - int pos = 0); - friend BitString common_suffix(const BitString&, const BitString&, - int pos = -1); - friend BitString reverse(const BitString&); - - void right_trim(unsigned int bit); - void left_trim(unsigned int bit); - -// status - - int empty() const ; - int count(unsigned int bit = 1) const; - int length() const; - -// convertors & IO - - friend BitString atoBitString(const char* s, char f='0', char t='1'); - // BitStringtoa is deprecated; do not use in new programs! - friend const char* BitStringtoa(const BitString&, char f='0', char t='1'); - void printon(ostream&, char f='0', char t='1') const; - - friend BitString shorttoBitString(unsigned short); - friend BitString longtoBitString(unsigned long); - - friend ostream& operator << (ostream& s, const BitString&); - -// misc - - void error(const char* msg) const; - -// indirect friends - - friend BitPattern atoBitPattern(const char* s, - char f='0',char t='1',char x='X'); - friend const char* BitPatterntoa(const BitPattern& p, - char f='0',char t='1',char x='X'); - int OK() const; -}; - - -class BitPattern -{ -public: - BitString pattern; - BitString mask; - - BitPattern(); - BitPattern(const BitPattern&); - BitPattern(const BitString& p, const BitString& m); - - ~BitPattern(); - - friend const char* BitPatterntoa(const BitPattern& p, - char f/*='0'*/,char t/*='1'*/,char x/*='X'*/); - void printon(ostream&, char f='0',char t='1',char x='X') const; - friend BitPattern atoBitPattern(const char* s, char f,char t, char x); - friend ostream& operator << (ostream& s, const BitPattern&); - - int search(const _BS_word*, int, int) const; - int match(const _BS_word* xs, int, int, int) const; - - int OK() const; -}; - -BitString operator & (const BitString& x, const BitString& y); -BitString operator | (const BitString& x, const BitString& y); -BitString operator ^ (const BitString& x, const BitString& y); -BitString operator << (const BitString& x, int y); -BitString operator >> (const BitString& x, int y); -BitString operator - (const BitString& x, const BitString& y); -BitString operator + (const BitString& x, const BitString& y); -BitString operator + (const BitString& x, unsigned int y); -BitString operator ~ (const BitString& x); -int operator != (const BitString& x, const BitString& y); -int operator>(const BitString& x, const BitString& y); -int operator>=(const BitString& x, const BitString& y); - -extern BitStrRep _nilBitStrRep; -extern BitString _nil_BitString; - -// primitive bit extraction - -// These must be inlined regardless of optimization. - -inline int BitStr_index(int l) { return (unsigned)(l) / BITSTRBITS; } - -inline int BitStr_pos(int l) { return l & (BITSTRBITS - 1); } - - -// constructors & assignment - -inline BitString::BitString() :rep(&_nilBitStrRep) {} - -inline BitString::BitString(const BitString& x) :rep(BStr_copy(0, x.rep)) {} - -inline BitString::BitString(const BitSubString& y) - :rep (BStr_alloc(0, y.S.rep->s, y.pos, y.pos+y.len, y.len)) {} - -inline BitString::~BitString() -{ - if (rep != &_nilBitStrRep) delete rep; -} - -inline BitString shorttoBitString(unsigned short w) -{ - BitString r; - _BS_word ww = w; -#if _BS_BIGENDIAN - abort(); -#endif - r.rep = BStr_alloc(0, &ww, 0, 8 * sizeof(short), 8 * sizeof(short)); - return r; -} - -inline BitString longtoBitString(unsigned long w) -{ - BitString r; -#if 1 - _BS_word u = w; - r.rep = BStr_alloc(0, &u, 0, BITSTRBITS, BITSTRBITS); -#else - unsigned short u[2]; - u[0] = w & ((unsigned short)(~(0))); - u[1] = w >> BITSTRBITS; - r.rep = BStr_alloc(0, &u[0], 0, 2*BITSTRBITS, 2*BITSTRBITS); -#endif - return r; -} - -inline BitString& BitString::operator = (const BitString& y) -{ - rep = BStr_copy(rep, y.rep); - return *this; -} - -inline BitString& BitString::operator = (unsigned int b) -{ - _BS_word bit = b; - rep = BStr_alloc(rep, &bit, 0, 1, 1); - return *this; -} - -inline BitString& BitString::operator=(const BitSubString& y) -{ - rep = BStr_alloc(rep, y.S.rep->s, y.pos, y.pos+y.len, y.len); - return *this; -} - -inline BitSubString::BitSubString(const BitSubString& x) - :S(x.S), pos(x.pos), len(x.len) {} - -inline BitSubString::BitSubString(BitString& x, int p, int l) - : S(x), pos(p), len(l) {} - -inline BitSubString::~BitSubString() {} - -inline BitPattern::BitPattern(const BitString& p, const BitString& m) - :pattern(p), mask(m) {} - -inline BitPattern::BitPattern(const BitPattern& b) - :pattern(b.pattern), mask(b.mask) {} - -inline BitPattern::BitPattern() {} -inline BitPattern::~BitPattern() {} - - -// procedural versions of operators - -inline void and(const BitString& x, const BitString& y, BitString& r) -{ - r.rep = and(x.rep, y.rep, r.rep); -} - -inline void or(const BitString& x, const BitString& y, BitString& r) -{ - r.rep = or(x.rep, y.rep, r.rep); -} - -inline void xor(const BitString& x, const BitString& y, BitString& r) -{ - r.rep = xor(x.rep, y.rep, r.rep); -} - -inline void diff(const BitString& x, const BitString& y, BitString& r) -{ - r.rep = diff(x.rep, y.rep, r.rep); -} - -inline void cat(const BitString& x, const BitString& y, BitString& r) -{ - r.rep = cat(x.rep, y.rep, r.rep); -} - -inline void cat(const BitString& x, unsigned int y, BitString& r) -{ - r.rep = cat(x.rep, y, r.rep); -} - -inline void rshift(const BitString& x, int y, BitString& r) -{ - r.rep = lshift(x.rep, -y, r.rep); -} - -inline void lshift(const BitString& x, int y, BitString& r) -{ - r.rep = lshift(x.rep, y, r.rep); -} - -inline void complement(const BitString& x, BitString& r) -{ - r.rep = cmpl(x.rep, r.rep); -} - -// operators - - -inline BitString& BitString::operator &= (const BitString& y) -{ - and(*this, y, *this); - return *this; -} - - -inline BitString& BitString::operator |= (const BitString& y) -{ - or(*this, y, *this); - return *this; -} - -inline BitString& BitString::operator ^= (const BitString& y) -{ - xor(*this, y, *this); - return *this; -} - -inline BitString& BitString::operator <<= (int y) -{ - lshift(*this, y, *this); - return *this; -} - -inline BitString& BitString::operator >>= (int y) -{ - rshift(*this, y, *this); - return *this; -} - -inline BitString& BitString::operator -= (const BitString& y) -{ - diff(*this, y, *this); - return *this; -} - -inline BitString& BitString::operator += (const BitString& y) -{ - cat(*this, y, *this); - return *this; -} - -inline BitString& BitString::operator += (unsigned int y) -{ - cat(*this, y, *this); - return *this; -} - -inline void BitString::complement() -{ - ::complement(*this, *this); -} - -#if defined(__GNUG__) && !defined(_G_NO_NRV) - -inline BitString operator & (const BitString& x, const BitString& y) return r -{ - and(x, y, r); -} - -inline BitString operator | (const BitString& x, const BitString& y) return r -{ - or(x, y, r); -} - -inline BitString operator ^ (const BitString& x, const BitString& y) return r -{ - xor(x, y, r); -} - -inline BitString operator << (const BitString& x, int y) return r -{ - lshift(x, y, r); -} - -inline BitString operator >> (const BitString& x, int y) return r -{ - rshift(x, y, r); -} - -inline BitString operator - (const BitString& x, const BitString& y) return r -{ - diff(x, y, r); -} - -inline BitString operator + (const BitString& x, const BitString& y) return r -{ - cat(x, y, r); -} - -inline BitString operator + (const BitString& x, unsigned int y) return r -{ - cat(x, y, r); -} - -inline BitString operator ~ (const BitString& x) return r -{ - complement(x, r); -} - -#else /* NO_NRV */ - -inline BitString operator & (const BitString& x, const BitString& y) -{ - BitString r; and(x, y, r); return r; -} - -inline BitString operator | (const BitString& x, const BitString& y) -{ - BitString r; or(x, y, r); return r; -} - -inline BitString operator ^ (const BitString& x, const BitString& y) -{ - BitString r; xor(x, y, r); return r; -} - -inline BitString operator << (const BitString& x, int y) -{ - BitString r; lshift(x, y, r); return r; -} - -inline BitString operator >> (const BitString& x, int y) -{ - BitString r; rshift(x, y, r); return r; -} - -inline BitString operator - (const BitString& x, const BitString& y) -{ - BitString r; diff(x, y, r); return r; -} - -inline BitString operator + (const BitString& x, const BitString& y) -{ - BitString r; cat(x, y, r); return r; -} - -inline BitString operator + (const BitString& x, unsigned int y) -{ - BitString r; cat(x, y, r); return r; -} - -inline BitString operator ~ (const BitString& x) -{ - BitString r; complement(x, r); return r; -} - -#endif - -// status, matching - -inline int BitString::length() const -{ - return rep->len; -} - -inline int BitString::empty() const -{ - return rep->len == 0; -} - -inline int BitString::index(const BitString& y, int startpos) const -{ - return search(startpos, rep->len, y.rep->s, 0, y.rep->len); -} - -inline int BitString::index(const BitSubString& y, int startpos) const -{ - return search(startpos, rep->len, y.S.rep->s, y.pos, y.pos+y.len); -} - -inline int BitString::contains(const BitString& y) const -{ - return search(0, rep->len, y.rep->s, 0, y.rep->len) >= 0; -} - -inline int BitString::contains(const BitSubString& y) const -{ - return search(0, rep->len, y.S.rep->s, y.pos, y.pos+y.len) >= 0; -} - -inline int BitString::contains(const BitString& y, int p) const -{ - return match(p, rep->len, 0, y.rep->s, 0, y.rep->len); -} - -inline int BitString::matches(const BitString& y, int p) const -{ - return match(p, rep->len, 1, y.rep->s, 0, y.rep->len); -} - -inline int BitString::contains(const BitSubString& y, int p) const -{ - return match(p, rep->len, 0, y.S.rep->s, y.pos, y.pos+y.len); -} - -inline int BitString::matches(const BitSubString& y, int p) const -{ - return match(p, rep->len, 1, y.S.rep->s, y.pos, y.pos+y.len); -} - -inline int BitString::contains(const BitPattern& r) const -{ - return r.search(rep->s, 0, rep->len) >= 0; -} - -inline int BitString::contains(const BitPattern& r, int p) const -{ - return r.match(rep->s, p, rep->len, 0); -} - -inline int BitString::matches(const BitPattern& r, int p) const -{ - return r.match(rep->s, p, rep->len, 1); -} - -inline int BitString::index(const BitPattern& r, int startpos) const -{ - return r.search(rep->s, startpos, rep->len); -} - -inline int BitSubString::length() const -{ - return len; -} - -inline int BitSubString::empty() const -{ - return len == 0; -} - -inline int operator != (const BitString& x, const BitString& y) -{ - return !(x == y); -} - -inline int operator>(const BitString& x, const BitString& y) -{ - return y < x; -} - -inline int operator>=(const BitString& x, const BitString& y) -{ - return y <= x; -} - -inline int BitString::first(unsigned int b) const -{ - return next(-1, b); -} - -inline int BitString::last(unsigned int b) const -{ - return prev(rep->len, b); -} - -inline int BitString::index(unsigned int bit, int startpos) const -{ - if (startpos >= 0) - return next(startpos - 1, bit); - else - return prev(rep->len + startpos + 1, bit); -} - -inline void BitString::right_trim(unsigned int b) -{ - int nb = (b == 0)? 1 : 0; - rep = BStr_resize(rep, prev(rep->len, nb) + 1); -} - -inline void BitString::left_trim(unsigned int b) -{ - int nb = (b == 0)? 1 : 0; - int p = next(-1, nb); - rep = BStr_alloc(rep, rep->s, p, rep->len, rep->len - p); -} - -inline int BitString::test(int i) const -{ - return ((unsigned)(i) >= rep->len)? 0 : - ((rep->s[BitStr_index(i)] & (1 << (BitStr_pos(i)))) != 0); -} - - -// subscripting - -inline BitStrBit::BitStrBit(const BitStrBit& b) :src(b.src), pos(b.pos) {} - -inline BitStrBit::BitStrBit(BitString& v, int p) :src(v), pos(p) {} - -inline BitStrBit::~BitStrBit() {} - -inline BitStrBit::operator unsigned int() const -{ - return src.test(pos); -} - -inline int BitStrBit::operator = (unsigned int b) -{ - src.assign(pos, b); return b; -} - -inline BitStrBit BitString::operator [] (int i) -{ - if ((unsigned)(i) >= rep->len) error("illegal bit index"); - return BitStrBit(*this, i); -} - -inline BitSubString BitString::_substr(int first, int l) -{ - if (first < 0 || l <= 0 || (unsigned)(first + l) > rep->len) - return BitSubString(_nil_BitString, 0, 0) ; - else - return BitSubString(*this, first, l); -} - -#endif diff --git a/gnu/lib/libg++/include/Complex.h b/gnu/lib/libg++/include/Complex.h deleted file mode 100644 index 128227bc3cc5..000000000000 --- a/gnu/lib/libg++/include/Complex.h +++ /dev/null @@ -1,249 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _Complex_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Complex_h 1 - - -#include <iostream.h> -#include <math.h> - -class Complex -{ -#ifdef __ATT_complex__ -public: -#else -protected: -#endif - - double re; - double im; - -public: - - double real() const; - double imag() const; - - Complex(); - Complex(const Complex& y); - Complex(double r, double i=0); - - ~Complex(); - - Complex& operator = (const Complex& y); - - Complex& operator += (const Complex& y); - Complex& operator += (double y); - Complex& operator -= (const Complex& y); - Complex& operator -= (double y); - Complex& operator *= (const Complex& y); - Complex& operator *= (double y); - - Complex& operator /= (const Complex& y); - Complex& operator /= (double y); - - void error(const char* msg) const; -}; - - -// non-inline functions - -Complex operator / (const Complex& x, const Complex& y); -Complex operator / (const Complex& x, double y); -Complex operator / (double x, const Complex& y); - -Complex cos(const Complex& x); -Complex sin(const Complex& x); - -Complex cosh(const Complex& x); -Complex sinh(const Complex& x); - -Complex exp(const Complex& x); -Complex log(const Complex& x); - -Complex pow(const Complex& x, int p); -Complex pow(const Complex& x, const Complex& p); -Complex pow(const Complex& x, double y); -Complex sqrt(const Complex& x); - -istream& operator >> (istream& s, Complex& x); -ostream& operator << (ostream& s, const Complex& x); - - -// inline members - -inline double Complex::real() const { return re; } -inline double Complex::imag() const { return im; } - -inline Complex::Complex() {} -inline Complex::Complex(const Complex& y) :re(y.real()), im(y.imag()) {} -inline Complex::Complex(double r, double i) :re(r), im(i) {} - -inline Complex::~Complex() {} - -inline Complex& Complex::operator = (const Complex& y) -{ - re = y.real(); im = y.imag(); return *this; -} - -inline Complex& Complex::operator += (const Complex& y) -{ - re += y.real(); im += y.imag(); return *this; -} - -inline Complex& Complex::operator += (double y) -{ - re += y; return *this; -} - -inline Complex& Complex::operator -= (const Complex& y) -{ - re -= y.real(); im -= y.imag(); return *this; -} - -inline Complex& Complex::operator -= (double y) -{ - re -= y; return *this; -} - -inline Complex& Complex::operator *= (const Complex& y) -{ - double r = re * y.real() - im * y.imag(); - im = re * y.imag() + im * y.real(); - re = r; - return *this; -} - -inline Complex& Complex::operator *= (double y) -{ - re *= y; im *= y; return *this; -} - - -// functions - -inline int operator == (const Complex& x, const Complex& y) -{ - return x.real() == y.real() && x.imag() == y.imag(); -} - -inline int operator == (const Complex& x, double y) -{ - return x.imag() == 0.0 && x.real() == y; -} - -inline int operator != (const Complex& x, const Complex& y) -{ - return x.real() != y.real() || x.imag() != y.imag(); -} - -inline int operator != (const Complex& x, double y) -{ - return x.imag() != 0.0 || x.real() != y; -} - -inline Complex operator - (const Complex& x) -{ - return Complex(-x.real(), -x.imag()); -} - -inline Complex conj(const Complex& x) -{ - return Complex(x.real(), -x.imag()); -} - -inline Complex operator + (const Complex& x, const Complex& y) -{ - return Complex(x.real() + y.real(), x.imag() + y.imag()); -} - -inline Complex operator + (const Complex& x, double y) -{ - return Complex(x.real() + y, x.imag()); -} - -inline Complex operator + (double x, const Complex& y) -{ - return Complex(x + y.real(), y.imag()); -} - -inline Complex operator - (const Complex& x, const Complex& y) -{ - return Complex(x.real() - y.real(), x.imag() - y.imag()); -} - -inline Complex operator - (const Complex& x, double y) -{ - return Complex(x.real() - y, x.imag()); -} - -inline Complex operator - (double x, const Complex& y) -{ - return Complex(x - y.real(), -y.imag()); -} - -inline Complex operator * (const Complex& x, const Complex& y) -{ - return Complex(x.real() * y.real() - x.imag() * y.imag(), - x.real() * y.imag() + x.imag() * y.real()); -} - -inline Complex operator * (const Complex& x, double y) -{ - return Complex(x.real() * y, x.imag() * y); -} - -inline Complex operator * (double x, const Complex& y) -{ - return Complex(x * y.real(), x * y.imag()); -} - -inline double real(const Complex& x) -{ - return x.real(); -} - -inline double imag(const Complex& x) -{ - return x.imag(); -} - -inline double abs(const Complex& x) -{ - return hypot(x.real(), x.imag()); -} - -inline double norm(const Complex& x) -{ - return (x.real() * x.real() + x.imag() * x.imag()); -} - -inline double arg(const Complex& x) -{ - return atan2(x.imag(), x.real()); -} - -inline Complex polar(double r, double t) -{ - return Complex(r * cos(t), r * sin(t)); -} - -#endif diff --git a/gnu/lib/libg++/include/CursesW.h b/gnu/lib/libg++/include/CursesW.h deleted file mode 100644 index 8ac6f3c4af6d..000000000000 --- a/gnu/lib/libg++/include/CursesW.h +++ /dev/null @@ -1,595 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1989 Free Software Foundation - written by Eric Newton (newton@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _CursesWindow_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _CursesWindow_h - -#include <_G_config.h> -#if _G_HAVE_CURSES -// Even many system which mostly have C++-ready header files, -// do not have C++-ready curses.h. -extern "C" { -#include <curses.h> -} - -/* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro. - Undefine it here, because CursesWindow uses lines as a method. */ -#undef lines - -// "Convert" macros to inlines, if needed. -#ifdef addch -inline int (addch)(char ch) { return addch(ch); } -#undef addch -#endif -#ifdef addstr -/* The (char*) cast is to hack around missing const's */ -inline int (addstr)(const char * str) { return addstr((char*)str); } -#undef addstr -#endif -#ifdef clear -inline int (clear)() { return clear(); } -#undef clear -#endif -#ifdef clearok -inline int (clearok)(WINDOW* win, int bf) { return clearok(win, bf); } -#undef clearok -#else -extern "C" int clearok(WINDOW*, int); -#endif -#ifdef clrtobot -inline int (clrtobot)() { return clrtobot(); } -#undef clrtobot -#endif -#ifdef clrtoeol -inline int (clrtoeol)() { return clrtoeol(); } -#undef clrtoeol -#endif -#ifdef delch -inline int (delch)() { return delch(); } -#undef delch -#endif -#ifdef deleteln -inline int (deleteln)() { return deleteln(); } -#undef deleteln -#endif -#ifdef erase -inline int (erase)() { return erase(); } -#undef erase -#endif -#ifdef flushok -inline int (flushok)(WINDOW* _win, int _bf) { return flushok(_win, _bf); } -#undef flushok -#else -#define _no_flushok -#endif -#ifdef getch -inline int (getch)() { return getch(); } -#undef getch -#endif -#ifdef getstr -inline int (getstr)(char *_str) { return getstr(_str); } -#undef getstr -#endif -#ifdef getyx -inline void (getyx)(WINDOW* win, int& y, int& x) { getyx(win, y, x); } -#undef getyx -#endif -#ifdef inch -inline int (inch)() { return inch(); } -#undef inch -#endif -#ifdef insch -inline int (insch)(char c) { return insch(c); } -#undef insch -#endif -#ifdef insertln -inline int (insertln)() { return insertln(); } -#undef insertln -#endif -#ifdef leaveok -inline int (leaveok)(WINDOW* win, int bf) { return leaveok(win, bf); } -#undef leaveok -#else -extern "C" int leaveok(WINDOW* win, int bf); -#endif -#ifdef move -inline int (move)(int x, int y) { return move(x, y); } -#undef move -#endif -#ifdef refresh -inline int (rfresh)() { return refresh(); } -#undef refresh -#endif -#ifdef scrollok -inline int (scrollok)(WINDOW* win, int bf) { return scrollok(win, bf); } -#undef scrollok -#else -#ifndef hpux -extern "C" int scrollok(WINDOW*, int); -#else -extern "C" int scrollok(WINDOW*, char); -#endif -#endif -#ifdef standend -inline int (standend)() { return standend(); } -#undef standend -#endif -#ifdef standout -inline int (standout)() { return standout(); } -#undef standout -#endif -#ifdef wstandend -inline int (wstandend)(WINDOW *win) { return wstandend(win); } -#undef wstandend -#endif -#ifdef wstandout -inline int (wstandout)(WINDOW *win) { return wstandout(win); } -#undef wstandout -#endif -#ifdef winch -inline int (winch)(WINDOW* win) { return winch(win); } -#undef winch -#endif - -/* deal with conflicting macros in ncurses.h which is SYSV based*/ -#ifdef box -inline _G_box(WINDOW* win, chtype v, chtype h) {return box(win, v, h); } -#undef box -inline box(WINDOW* win, chtype v, chtype h) {return _G_box(win, v, h); } -#endif -#ifdef scroll -inline (scroll)(WINDOW* win) { return scroll(win); } -#undef scroll -#endif -#ifdef touchwin -inline (touchwin)(WINDOW* win) { return touchwin(win); } -#undef touchwin -#endif - -#ifdef mvwaddch -inline int (mvwaddch)(WINDOW *win, int y, int x, char ch) -{ return mvwaddch(win, y, x, ch); } -#undef mvwaddch -#endif -#ifdef mvwaddstr -inline int (mvwaddstr)(WINDOW *win, int y, int x, const char * str) -{ return mvwaddstr(win, y, x, (char*)str); } -#undef mvwaddstr -#endif -#ifdef mvwdelch -inline int (mvwdelch)(WINDOW *win, int y, int x) { return mvwdelch(win, y, x);} -#undef mvwdelch -#endif -#ifdef mvwgetch -inline int (mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);} -#undef mvwgetch -#endif -#ifdef mvwgetstr -inline int (mvwgetstr)(WINDOW *win, int y, int x, char *str) -{return mvwgetstr(win,y,x, str);} -#undef mvwgetstr -#endif -#ifdef mvwinch -inline int (mvwinch)(WINDOW *win, int y, int x) { return mvwinch(win, y, x);} -#undef mvwinch -#endif -#ifdef mvwinsch -inline int (mvwinsch)(WINDOW *win, int y, int x, char c) -{ return mvwinsch(win, y, x, c); } -#undef mvwinsch -#endif - -#ifdef mvaddch -inline int (mvaddch)(int y, int x, char ch) -{ return mvaddch(y, x, ch); } -#undef mvaddch -#endif -#ifdef mvaddstr -inline int (mvaddstr)(int y, int x, const char * str) -{ return mvaddstr(y, x, (char*)str); } -#undef mvaddstr -#endif -#ifdef mvdelch -inline int (mvdelch)(int y, int x) { return mvdelch(y, x);} -#undef mvdelch -#endif -#ifdef mvgetch -inline int (mvgetch)(int y, int x) { return mvgetch(y, x);} -#undef mvgetch -#endif -#ifdef mvgetstr -inline int (mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);} -#undef mvgetstr -#endif -#ifdef mvinch -inline int (mvinch)(int y, int x) { return mvinch(y, x);} -#undef mvinch -#endif -#ifdef mvinsch -inline int (mvinsch)(int y, int x, char c) -{ return mvinsch(y, x, c); } -#undef mvinsch -#endif - -/* - * - * C++ class for windows. - * - * - */ - -class CursesWindow -{ -protected: - static int count; // count of all active windows: - // We rely on the c++ promise that - // all otherwise uninitialized - // static class vars are set to 0 - - WINDOW * w; // the curses WINDOW - - int alloced; // true if we own the WINDOW - - CursesWindow* par; // parent, if subwindow - CursesWindow* subwins; // head of subwindows list - CursesWindow* sib; // next subwindow of parent - - void kill_subwindows(); // disable all subwindows - -public: - CursesWindow(WINDOW* &window); // useful only for stdscr - - CursesWindow(int lines, // number of lines - int cols, // number of columns - int begin_y, // line origin - int begin_x); // col origin - - CursesWindow(CursesWindow& par, // parent window - int lines, // number of lines - int cols, // number of columns - int by, // absolute or relative - int bx, // origins: - char absrel = 'a'); // if `a', by & bx are - // absolute screen pos, - // else if `r', they are - // relative to par origin - ~CursesWindow(); - -// terminal status - int lines(); // number of lines on terminal, *not* window - int cols(); // number of cols on terminal, *not* window - -// window status - int height(); // number of lines in this window - int width(); // number of cols in this window - int begx(); // smallest x coord in window - int begy(); // smallest y coord in window - int maxx(); // largest x coord in window - int maxy(); // largest x coord in window - -// window positioning - int move(int y, int x); - -// coordinate positioning - void getyx(int& y, int& x); - int mvcur(int sy, int ey, int sx, int ex); - -// input - int getch(); - int getstr(char * str); - int scanw(const char *, ...); - -// input + positioning - int mvgetch(int y, int x); - int mvgetstr(int y, int x, char * str); - int mvscanw(int, int, const char*, ...); - -// output - int addch(const char ch); - int addstr(const char * str); - int printw(const char * fmt, ...); - int inch(); - int insch(char c); - int insertln(); - -// output + positioning - int mvaddch(int y, int x, char ch); - int mvaddstr(int y, int x, const char * str); - int mvprintw(int y, int x, const char * fmt, ...); - int mvinch(int y, int x); - int mvinsch(int y, int x, char ch); - -// borders - int box(char vert, char hor); - -// erasure - int erase(); - int clear(); - int clearok(int bf); - int clrtobot(); - int clrtoeol(); - int delch(); - int mvdelch(int y, int x); - int deleteln(); - -// screen control - int scroll(); - int scrollok(int bf); - int touchwin(); - int refresh(); - int leaveok(int bf); -#ifndef _no_flushok - int flushok(int bf); -#endif - int standout(); - int standend(); - -// multiple window control - int overlay(CursesWindow &win); - int overwrite(CursesWindow &win); - - -// traversal support - CursesWindow* child(); - CursesWindow* sibling(); - CursesWindow* parent(); -}; - - -inline int CursesWindow::begx() -{ - return w->_begx; -} - -inline int CursesWindow::begy() -{ - return w->_begy; -} - -inline int CursesWindow::maxx() -{ - return w->_maxx; -} - -inline int CursesWindow::maxy() -{ - return w->_maxy; -} - -inline int CursesWindow::height() -{ - return maxy() - begy() + 1; -} - -inline int CursesWindow::width() -{ - return maxx() - begx() + 1; -} - -inline int CursesWindow::box(char vert, char hor) -{ - return ::box(w, vert, hor); -} - -inline int CursesWindow::overlay(CursesWindow &win) -{ - return ::overlay(w, win.w); -} - -inline int CursesWindow::overwrite(CursesWindow &win) -{ - return ::overwrite(w, win.w); -} - -inline int CursesWindow::scroll() -{ - return ::scroll(w); -} - - -inline int CursesWindow::touchwin() -{ - return ::touchwin(w); -} - -inline int CursesWindow::addch(const char ch) -{ - return ::waddch(w, ch); -} - -inline int CursesWindow::addstr(const char * str) -{ - // The (char*) cast is to hack around prototypes in curses.h that - // have const missing in the parameter lists. [E.g. SVR4] - return ::waddstr(w, (char*)str); -} - -inline int CursesWindow::clear() -{ - return ::wclear(w); -} - -inline int CursesWindow::clrtobot() -{ - return ::wclrtobot(w); -} - -inline int CursesWindow::clrtoeol() -{ - return ::wclrtoeol(w); -} - -inline int CursesWindow::delch() -{ - return ::wdelch(w); -} - -inline int CursesWindow::deleteln() -{ - return ::wdeleteln(w); -} - -inline int CursesWindow::erase() -{ - return ::werase(w); -} - -inline int CursesWindow::getch() -{ - return ::wgetch(w); -} - -inline int CursesWindow::getstr(char * str) -{ - return ::wgetstr(w, str); -} - -inline int CursesWindow::inch() -{ - return winch(w); -} - -inline int CursesWindow::insch(char c) -{ - return ::winsch(w, c); -} - -inline int CursesWindow::insertln() -{ - return ::winsertln(w); -} - -inline int CursesWindow::move(int y, int x) -{ - return ::wmove(w, y, x); -} - - -inline int CursesWindow::mvcur(int sy, int ey, int sx, int ex) -{ - return ::mvcur(sy, ey, sx,ex); -} - -inline int CursesWindow::mvaddch(int y, int x, char ch) -{ - return (::wmove(w, y, x)==ERR) ? ERR : ::waddch(w, ch); -} - -inline int CursesWindow::mvgetch(int y, int x) -{ - return (::wmove(w, y, x)==ERR) ? ERR : ::wgetch(w); -} - -inline int CursesWindow::mvaddstr(int y, int x, const char * str) -{ - return (::wmove(w, y, x)==ERR) ? ERR : ::waddstr(w, (char*)str); -} - -inline int CursesWindow::mvgetstr(int y, int x, char * str) -{ - return (::wmove(w, y, x)==ERR) ? ERR : ::wgetstr(w, str); -} - -inline int CursesWindow::mvinch(int y, int x) -{ - return (::wmove(w, y, x)==ERR) ? ERR : ::winch(w); -} - -inline int CursesWindow::mvdelch(int y, int x) -{ - return (::wmove(w, y, x)==ERR) ? ERR : ::wdelch(w); -} - -inline int CursesWindow::mvinsch(int y, int x, char ch) -{ - return (::wmove(w, y, x)==ERR) ? ERR : ::winsch(w, ch); -} - -inline int CursesWindow::refresh() -{ - return ::wrefresh(w); -} - -inline int CursesWindow::clearok(int bf) -{ - return ::clearok(w,bf); -} - -inline int CursesWindow::leaveok(int bf) -{ - return ::leaveok(w,bf); -} - -inline int CursesWindow::scrollok(int bf) -{ - return ::scrollok(w,bf); -} - -#ifndef _no_flushok -inline int CursesWindow::flushok(int bf) -{ - return ::flushok(w, bf); -} -#endif - -inline void CursesWindow::getyx(int& y, int& x) -{ - ::getyx(w, y, x); -} - -inline int CursesWindow::standout() -{ - return ::wstandout(w); -} - -inline int CursesWindow::standend() -{ - return ::wstandend(w); -} - -inline int CursesWindow::lines() -{ - return LINES; -} - -inline int CursesWindow::cols() -{ - return COLS; -} - -inline CursesWindow* CursesWindow::child() -{ - return subwins; -} - -inline CursesWindow* CursesWindow::parent() -{ - return par; -} - -inline CursesWindow* CursesWindow::sibling() -{ - return sib; -} - -#endif /* _G_HAVE_CURSES */ -#endif diff --git a/gnu/lib/libg++/include/DLList.h b/gnu/lib/libg++/include/DLList.h deleted file mode 100644 index ba7ee868fa9f..000000000000 --- a/gnu/lib/libg++/include/DLList.h +++ /dev/null @@ -1,137 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -#ifndef _DLList_h -#ifdef __GNUG__ -//#pragma interface -#endif -#define _DLList_h 1 - -#include <Pix.h> - -struct BaseDLNode { - BaseDLNode *bk; - BaseDLNode *fd; - void *item() {return (void*)(this+1);} //Return ((DLNode<T>*)this)->hd -}; - -template<class T> -class DLNode : public BaseDLNode -{ - public: - T hd; - DLNode() { } - DLNode(const T& h, DLNode* p = 0, DLNode* n = 0) - : hd(h) { bk = p; fd = n; } - ~DLNode() { } -}; - -class BaseDLList { - protected: - BaseDLNode *h; - - BaseDLList() { h = 0; } - void copy(const BaseDLList&); - BaseDLList& operator= (const BaseDLList& a); - virtual void delete_node(BaseDLNode*node) = 0; - virtual BaseDLNode* copy_node(const void* datum) = 0; - virtual void copy_item(void *dst, void *src) = 0; - virtual ~BaseDLList() { } - - Pix prepend(const void*); - Pix append(const void*); - Pix ins_after(Pix p, const void *datum); - Pix ins_before(Pix p, const void *datum); - void remove_front(void *dst); - void remove_rear(void *dst); - void join(BaseDLList&); - - public: - int empty() const { return h == 0; } - int length() const; - void clear(); - void error(const char* msg) const; - int owns(Pix p) const; - int OK() const; - void del(Pix& p, int dir = 1); - void del_after(Pix& p); - void del_front(); - void del_rear(); -}; - -template <class T> -class DLList : public BaseDLList { - //friend class <T>DLListTrav; - - virtual void delete_node(BaseDLNode *node) { delete (DLNode<T>*)node; } - virtual BaseDLNode* copy_node(const void *datum) - { return new DLNode<T>(*(const T*)datum); } - virtual void copy_item(void *dst, void *src) { *(T*)dst = *(T*)src; } - - public: - DLList() : BaseDLList() { } - DLList(const DLList<T>& a) : BaseDLList() { copy(a); } - - DLList<T>& operator = (const DLList<T>& a) - { BaseDLList::operator=((const BaseDLList&) a); return *this; } - virtual ~DLList() { clear(); } - - Pix prepend(const T& item) {return BaseDLList::prepend(&item);} - Pix append(const T& item) {return BaseDLList::append(&item);} - - void join(DLList<T>& a) { BaseDLList::join(a); } - - T& front() { - if (h == 0) error("front: empty list"); - return ((DLNode<T>*)h)->hd; } - T& rear() { - if (h == 0) error("rear: empty list"); - return ((DLNode<T>*)h->bk)->hd; - } - const T& front() const { - if (h == 0) error("front: empty list"); - return ((DLNode<T>*)h)->hd; } - const T& rear() const { - if (h == 0) error("rear: empty list"); - return ((DLNode<T>*)h->bk)->hd; - } - T remove_front() { T dst; BaseDLList::remove_front(&dst); return dst; } - T remove_rear() { T dst; BaseDLList::remove_rear(&dst); return dst; } - - T& operator () (Pix p) { - if (p == 0) error("null Pix"); - return ((DLNode<T>*)p)->hd; - } - const T& operator () (Pix p) const { - if (p == 0) error("null Pix"); - return ((DLNode<T>*)p)->hd; - } - Pix first() const { return Pix(h); } - Pix last() const { return (h == 0) ? 0 : Pix(h->bk); } - void next(Pix& p) const - { p = (p == 0 || p == h->bk)? 0 : Pix(((DLNode<T>*)p)->fd); } - void prev(Pix& p) const - { p = (p == 0 || p == h)? 0 : Pix(((DLNode<T>*)p)->bk); } - Pix ins_after(Pix p, const T& item) - {return BaseDLList::ins_after(p, &item); } - Pix ins_before(Pix p, const T& item) - {return BaseDLList::ins_before(p, &item);} -}; - -#endif diff --git a/gnu/lib/libg++/include/DiscUnif.h b/gnu/lib/libg++/include/DiscUnif.h deleted file mode 100644 index 0cd6a0f07097..000000000000 --- a/gnu/lib/libg++/include/DiscUnif.h +++ /dev/null @@ -1,72 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _DiscreteUniform_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _DiscreteUniform_h 1 - -#include <Random.h> - -// -// The interval [lo..hi) -// - -class DiscreteUniform: public Random { - long pLow; - long pHigh; - double delta; -public: - DiscreteUniform(long low, long high, RNG *gen); - - long low(); - long low(long x); - long high(); - long high(long x); - - virtual double operator()(); -}; - - -inline DiscreteUniform::DiscreteUniform(long low, long high, RNG *gen) -: Random(gen) -{ - pLow = (low < high) ? low : high; - pHigh = (low < high) ? high : low; - delta = (pHigh - pLow) + 1; -} - -inline long DiscreteUniform::low() { return pLow; } - -inline long DiscreteUniform::low(long x) { - long tmp = pLow; - pLow = x; - delta = (pHigh - pLow) + 1; - return tmp; -} - -inline long DiscreteUniform::high() { return pHigh; } - -inline long DiscreteUniform::high(long x) { - long tmp = pHigh; - pHigh = x; - delta = (pHigh - pLow) + 1; - return tmp; -} - -#endif diff --git a/gnu/lib/libg++/include/Erlang.h b/gnu/lib/libg++/include/Erlang.h deleted file mode 100644 index 18838fc44af5..000000000000 --- a/gnu/lib/libg++/include/Erlang.h +++ /dev/null @@ -1,68 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _Erlang_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Erlang_h 1 - -#include <Random.h> - -class Erlang: public Random { -protected: - double pMean; - double pVariance; - int k; - double a; - void setState(); -public: - Erlang(double mean, double variance, RNG *gen); - - double mean(); - double mean(double x); - double variance(); - double variance(double x); - - virtual double operator()(); - -}; - - -inline void Erlang::setState() { - k = int( (pMean * pMean ) / pVariance + 0.5 ); - k = (k > 0) ? k : 1; - a = k / pMean; -} - -inline Erlang::Erlang(double mean, double variance, RNG *gen) : Random(gen) -{ - pMean = mean; pVariance = variance; - setState(); -} - -inline double Erlang::mean() { return pMean; } -inline double Erlang::mean(double x) { - double tmp = pMean; pMean = x; setState(); return tmp; -}; - -inline double Erlang::variance() { return pVariance; } -inline double Erlang::variance(double x) { - double tmp = pVariance; pVariance = x; setState(); return tmp; -} - -#endif diff --git a/gnu/lib/libg++/include/Fix.h b/gnu/lib/libg++/include/Fix.h deleted file mode 100644 index fab91b8e7b26..000000000000 --- a/gnu/lib/libg++/include/Fix.h +++ /dev/null @@ -1,513 +0,0 @@ -// -*- C++ -*- -// Fix.h : variable length fixed point data type -// - -#ifndef _Fix_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Fix_h 1 - -#include <stream.h> -#include <std.h> -#include <stddef.h> -#include <Integer.h> -#include <builtin.h> - -class Fix -{ - struct Rep // internal Fix representation - { - _G_uint16_t len; // length in bits - _G_uint16_t siz; // allocated storage - _G_int16_t ref; // reference count - _G_uint16_t s[1]; // start of ushort array represention - }; - -public: - - typedef void (*PEH)(Rep*); - -private: - - Rep* rep; - - Fix(Rep*); - Fix(int, const Rep*); - - void unique(); - - static const _G_uint16_t min_length = 1; - static const _G_uint16_t max_length = 65535; - static const double min_value = -1.0; - static const double max_value = 1.0; - - static _G_uint16_t default_length; - static int default_print_width; - static Rep Rep_0; - static Rep Rep_m1; - static Rep Rep_quotient_bump; - - // internal class functions - static void mask(Rep*); - static int compare(const Rep*, const Rep* = &Rep_0); - - static Rep* new_Fix(_G_uint16_t); - static Rep* new_Fix(_G_uint16_t, const Rep*); - static Rep* new_Fix(_G_uint16_t, double); - - static Rep* copy(const Rep*, Rep*); - static Rep* negate(const Rep*, Rep* = NULL); - static Rep* add(const Rep*, const Rep*, Rep* = NULL); - static Rep* subtract(const Rep*, const Rep*, Rep* = NULL); - static Rep* multiply(const Rep*, const Rep*, Rep* = NULL); - static Rep* multiply(const Rep*, int, Rep* = NULL); - static Rep* divide(const Rep*, const Rep*, Rep* = NULL, - Rep* = NULL); - static Rep* shift(const Rep*, int, Rep* = NULL); - - static one_arg_error_handler_t error_handler; - static one_arg_error_handler_t range_error_handler; - - static PEH overflow_handler; - -public: - Fix(); - Fix(const Fix&); - Fix(double); - Fix(int); - Fix(int, const Fix&); - Fix(int, double); - - ~Fix(); - - Fix operator = (const Fix&); - Fix operator = (double); - - friend int operator == (const Fix&, const Fix&); - friend int operator != (const Fix&, const Fix&); - - friend int operator < (const Fix&, const Fix&); - friend int operator <= (const Fix&, const Fix&); - friend int operator > (const Fix&, const Fix&); - friend int operator >= (const Fix&, const Fix&); - - Fix& operator + (); - Fix operator - (); - - friend Fix operator + (const Fix&, const Fix&); - friend Fix operator - (const Fix&, const Fix&); - friend Fix operator * (const Fix&, const Fix&); - friend Fix operator / (const Fix&, const Fix&); - - friend Fix operator * (const Fix&, int); - friend Fix operator * (int, const Fix&); - friend Fix operator % (const Fix&, int); - friend Fix operator << (const Fix&, int); - friend Fix operator >> (const Fix&, int); - -#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) - friend Fix operator <? (const Fix&, const Fix&); // min - friend Fix operator >? (const Fix&, const Fix&); // max -#endif - - Fix operator += (const Fix&); - Fix operator -= (const Fix&); - Fix operator *= (const Fix&); - Fix operator /= (const Fix&); - - Fix operator *= (int); - Fix operator %= (int); - Fix operator <<=(int); - Fix operator >>=(int); - - friend char* Ftoa(const Fix&, int width = default_print_width); - void printon(ostream&, int width = default_print_width) const; - friend Fix atoF(const char*, int len = default_length); - - friend istream& operator >> (istream&, Fix&); - friend ostream& operator << (ostream&, const Fix&); - - // built-in functions - friend Fix abs(Fix); // absolute value - friend int sgn(const Fix&); // -1, 0, +1 - friend Integer mantissa(const Fix&); // integer representation - friend double value(const Fix&); // double value - friend int length(const Fix&); // field length - friend void show(const Fix&); // show contents - - // error handlers - static void error(const char* msg); // error handler - static void range_error(const char* msg); // range error handler - - static one_arg_error_handler_t set_error_handler(one_arg_error_handler_t f); - static one_arg_error_handler_t - set_range_error_handler(one_arg_error_handler_t f); - - static void default_error_handler (const char *); - static void default_range_error_handler (const char *); - - // non-operator versions for user - friend void negate(const Fix& x, Fix& r); - friend void add(const Fix& x, const Fix& y, Fix& r); - friend void subtract(const Fix& x, const Fix& y, Fix& r); - friend void multiply(const Fix& x, const Fix& y, Fix& r); - friend void divide(const Fix& x, const Fix& y, Fix& q, Fix& r); - friend void shift(const Fix& x, int y, Fix& r); - - // overflow handlers - static void overflow_saturate(Fix::Rep*); - static void overflow_wrap(Fix::Rep*); - static void overflow_warning_saturate(Fix::Rep*); - static void overflow_warning(Fix::Rep*); - static void overflow_error(Fix::Rep*); - - static PEH set_overflow_handler(PEH); - - static int set_default_length(int); -}; - -// function definitions - -inline void -Fix::unique() -{ - if ( rep->ref > 1 ) - { - rep->ref--; - rep = new_Fix(rep->len,rep); - } -} - -inline void -Fix::mask (Fix::Rep* x) -{ - int n = x->len & 0x0f; - if ( n ) - x->s[x->siz - 1] &= 0xffff0000 >> n; -} - -inline Fix::Rep* -Fix::copy(const Fix::Rep* from, Fix::Rep* to) -{ - _G_uint16_t *ts = to->s; - const _G_uint16_t *fs = from->s; - int ilim = to->siz < from->siz ? to->siz : from->siz; - for ( int i=0; i < ilim; i++ ) - *ts++ = *fs++; - for ( ; i < to->siz; i++ ) - *ts++ = 0; - mask(to); - return to; -} - -inline -Fix::Fix(Rep* f) -{ - rep = f; -} - -inline -Fix::Fix() -{ - rep = new_Fix(default_length); -} - -inline -Fix::Fix(int len) -{ - if ( len < min_length || len > max_length ) - error("illegal length in declaration"); - rep = new_Fix((_G_uint16_t) len); -} - -inline -Fix::Fix(double d) -{ - rep = new_Fix(default_length,d); -} - -inline -Fix::Fix(const Fix& y) -{ - rep = y.rep; rep->ref++; -} - -inline -Fix::Fix(int len, const Fix& y) -{ - if ( len < Fix::min_length || len > Fix::max_length ) - error("illegal length in declaration"); - rep = new_Fix((_G_uint16_t) len,y.rep); -} - -inline -Fix::Fix(int len, const Rep* fr) -{ - if ( len < Fix::min_length || len > Fix::max_length ) - error("illegal length in declaration"); - rep = new_Fix((_G_uint16_t) len,fr); -} - -inline -Fix::Fix(int len, double d) -{ - if ( len < Fix::min_length || len > Fix::max_length ) - error("illegal length in declaration"); - rep = new_Fix((_G_uint16_t) len,d); -} - -inline -Fix::~Fix() -{ - if ( --rep->ref <= 0 ) delete rep; -} - -inline Fix -Fix::operator = (const Fix& y) -{ - if ( rep->len == y.rep->len ) { - ++y.rep->ref; - if ( --rep->ref <= 0 ) delete rep; - rep = y.rep; - } - else { - unique(); - copy(y.rep,rep); - } - return *this; -} - -inline Fix -Fix::operator = (double d) -{ - int oldlen = rep->len; - if ( --rep->ref <= 0 ) delete rep; - rep = new_Fix(oldlen,d); - return *this; -} - -inline int -operator == (const Fix& x, const Fix& y) -{ - return Fix::compare(x.rep, y.rep) == 0; -} - -inline int -operator != (const Fix& x, const Fix& y) -{ - return Fix::compare(x.rep, y.rep) != 0; -} - -inline int -operator < (const Fix& x, const Fix& y) -{ - return Fix::compare(x.rep, y.rep) < 0; -} - -inline int -operator <= (const Fix& x, const Fix& y) -{ - return Fix::compare(x.rep, y.rep) <= 0; -} - -inline int -operator > (const Fix& x, const Fix& y) -{ - return Fix::compare(x.rep, y.rep) > 0; -} - -inline int -operator >= (const Fix& x, const Fix& y) -{ - return Fix::compare(x.rep, y.rep) >= 0; -} - -inline Fix& -Fix::operator + () -{ - return *this; -} - -inline Fix -Fix::operator - () -{ - Rep* r = negate(rep); return r; -} - -inline Fix -operator + (const Fix& x, const Fix& y) -{ - Fix::Rep* r = Fix::add(x.rep, y.rep); return r; -} - -inline Fix -operator - (const Fix& x, const Fix& y) -{ - Fix::Rep* r = Fix::subtract(x.rep, y.rep); return r; -} - -inline Fix -operator * (const Fix& x, const Fix& y) -{ - Fix::Rep* r = Fix::multiply(x.rep, y.rep); return r; -} - -inline Fix -operator * (const Fix& x, int y) -{ - Fix::Rep* r = Fix::multiply(x.rep, y); return r; -} - -inline Fix -operator * (int y, const Fix& x) -{ - Fix::Rep* r = Fix::multiply(x.rep, y); return r; -} - -inline Fix -operator / (const Fix& x, const Fix& y) -{ - Fix::Rep* r = Fix::divide(x.rep, y.rep); return r; -} - -inline Fix -Fix::operator += (const Fix& y) -{ - unique(); Fix::add(rep, y.rep, rep); return *this; -} - -inline Fix -Fix::operator -= (const Fix& y) -{ - unique(); Fix::subtract(rep, y.rep, rep); return *this; -} - -inline Fix -Fix::operator *= (const Fix& y) -{ - unique(); Fix::multiply(rep, y.rep, rep); return *this; -} - -inline Fix -Fix::operator *= (int y) -{ - unique(); Fix::multiply(rep, y, rep); return *this; -} - -inline Fix -Fix::operator /= (const Fix& y) -{ - unique(); Fix::divide(rep, y.rep, rep); return *this; -} - -inline Fix -operator % (const Fix& x, int y) -{ - Fix r((int) x.rep->len + y, x); return r; -} - -inline Fix -operator << (const Fix& x, int y) -{ - Fix::Rep* rep = Fix::shift(x.rep, y); return rep; -} - -inline Fix -operator >> (const Fix& x, int y) -{ - Fix::Rep* rep = Fix::shift(x.rep, -y); return rep; -} - -inline Fix -Fix::operator <<= (int y) -{ - unique(); Fix::shift(rep, y, rep); return *this; -} - -inline Fix -Fix::operator >>= (int y) -{ - unique(); Fix::shift(rep, -y, rep); return *this; -} - -#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) -inline Fix -operator <? (const Fix& x, const Fix& y) -{ - if ( Fix::compare(x.rep, y.rep) <= 0 ) return x; else return y; -} - -inline Fix -operator >? (const Fix& x, const Fix& y) -{ - if ( Fix::compare(x.rep, y.rep) >= 0 ) return x; else return y; -} -#endif - -inline Fix -abs(Fix x) -{ - Fix::Rep* r = (Fix::compare(x.rep) >= 0 ? Fix::new_Fix(x.rep->len,x.rep) : - Fix::negate(x.rep)); - return r; -} - -inline int -sgn(const Fix& x) -{ - int a = Fix::compare(x.rep); - return a == 0 ? 0 : (a > 0 ? 1 : -1); -} - -inline int -length(const Fix& x) -{ - return x.rep->len; -} - -inline ostream& -operator << (ostream& s, const Fix& y) -{ - if (s.opfx()) - y.printon(s); - return s; -} - -inline void -negate (const Fix& x, Fix& r) -{ - Fix::negate(x.rep, r.rep); -} - -inline void -add (const Fix& x, const Fix& y, Fix& r) -{ - Fix::add(x.rep, y.rep, r.rep); -} - -inline void -subtract (const Fix& x, const Fix& y, Fix& r) -{ - Fix::subtract(x.rep, y.rep, r.rep); -} - -inline void -multiply (const Fix& x, const Fix& y, Fix& r) -{ - Fix::multiply(x.rep, y.rep, r.rep); -} - -inline void -divide (const Fix& x, const Fix& y, Fix& q, Fix& r) -{ - Fix::divide(x.rep, y.rep, q.rep, r.rep); -} - -inline void -shift (const Fix& x, int y, Fix& r) -{ - Fix::shift(x.rep, y, r.rep); -} - -#endif diff --git a/gnu/lib/libg++/include/Fix16.h b/gnu/lib/libg++/include/Fix16.h deleted file mode 100644 index 2ab220975d9a..000000000000 --- a/gnu/lib/libg++/include/Fix16.h +++ /dev/null @@ -1,648 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu) - adapted for libg++ by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _Fix16_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Fix16_h 1 - -#include <stream.h> -#include <std.h> - -// constant definitions - -#define Fix16_fs ((double)((unsigned)(1 << 15))) - -#define Fix16_msb (1 << 15) -#define Fix16_m_max ((1 << 15) - 1) -#define Fix16_m_min ((short)(1 << 15)) - -#define Fix16_mult Fix16_fs -#define Fix16_div (1./Fix16_fs) -#define Fix16_max (1. - .5/Fix16_fs) -#define Fix16_min (-1.) - - -#define Fix32_fs ((double)((_G_uint32_t)(1 << 31))) - -#define Fix32_msb ((_G_uint32_t)(1 << 31)) -#define Fix32_m_max ((_G_int32_t)((1 << 31) - 1)) -#define Fix32_m_min ((_G_int32_t)(1 << 31)) - -#define Fix32_mult Fix32_fs -#define Fix32_div (1./Fix32_fs) -#define Fix32_max (1. - .5/Fix32_fs) -#define Fix32_min (-1.) - - -// -// Fix16 class: 16-bit Fixed point data type -// -// consists of a 16-bit mantissa (sign bit & 15 data bits). -// - -class Fix16 -{ - friend class Fix32; - - short m; - - short round(double d); - short assign(double d); - Fix16(short i); - Fix16(int i); - - operator double() const; - - -public: - Fix16(); - Fix16(const Fix16& f); - Fix16(double d); - Fix16(const Fix32& f); - - ~Fix16(); - - Fix16& operator=(const Fix16& f); - Fix16& operator=(double d); - Fix16& operator=(const Fix32& f); - - friend short& mantissa(Fix16& f); - friend const short& mantissa(const Fix16& f); - friend double value(const Fix16& f); - - Fix16 operator + () const; - Fix16 operator - () const; - - friend Fix16 operator + (const Fix16& f, const Fix16& g); - friend Fix16 operator - (const Fix16& f, const Fix16& g); - friend Fix32 operator * (const Fix16& f, const Fix16& g); - friend Fix16 operator / (const Fix16& f, const Fix16& g); - friend Fix16 operator << (const Fix16& f, int b); - friend Fix16 operator >> (const Fix16& f, int b); - - Fix16& operator += (const Fix16& f); - Fix16& operator -= (const Fix16& f); - Fix16& operator *= (const Fix16& ); - Fix16& operator /= (const Fix16& f); - - Fix16& operator <<=(int b); - Fix16& operator >>=(int b); - - friend int operator == (const Fix16& f, const Fix16& g); - friend int operator != (const Fix16& f, const Fix16& g); - friend int operator >= (const Fix16& f, const Fix16& g); - friend int operator <= (const Fix16& f, const Fix16& g); - friend int operator > (const Fix16& f, const Fix16& g); - friend int operator < (const Fix16& f, const Fix16& g); - - friend istream& operator >> (istream& s, Fix16& f); - friend ostream& operator << (ostream& s, const Fix16& f); - - void overflow(short&) const; - void range_error(short&) const; - - friend Fix16 operator * (const Fix16& f, int g); - friend Fix16 operator * (int g, const Fix16& f); - Fix16& operator *= (int g); -}; - - -// -// Fix32 class: 32-bit Fixed point data type -// -// consists of a 32-bit mantissa (sign bit & 31 data bits). -// - -class Fix32 -{ - friend class Fix16; - - _G_int32_t m; - - _G_int32_t round(double d); - _G_int32_t assign(double d); - - Fix32(_G_int32_t i); - operator double() const; - - -public: - Fix32(); - Fix32(const Fix32& f); - Fix32(const Fix16& f); - Fix32(double d); - ~Fix32(); - - Fix32& operator = (const Fix32& f); - Fix32& operator = (const Fix16& f); - Fix32& operator = (double d); - - friend _G_int32_t& mantissa(Fix32& f); - friend const _G_int32_t& mantissa(const Fix32& f); - friend double value(const Fix32& f); - - Fix32 operator + () const; - Fix32 operator - () const; - - friend Fix32 operator + (const Fix32& f, const Fix32& g); - friend Fix32 operator - (const Fix32& f, const Fix32& g); - friend Fix32 operator * (const Fix32& f, const Fix32& g); - friend Fix32 operator / (const Fix32& f, const Fix32& g); - friend Fix32 operator << (const Fix32& f, int b); - friend Fix32 operator >> (const Fix32& f, int b); - - friend Fix32 operator * (const Fix16& f, const Fix16& g); - - Fix32& operator += (const Fix32& f); - Fix32& operator -= (const Fix32& f); - Fix32& operator *= (const Fix32& f); - Fix32& operator /= (const Fix32& f); - Fix32& operator <<=(int b); - Fix32& operator >>=(int b); - - friend int operator == (const Fix32& f, const Fix32& g); - friend int operator != (const Fix32& f, const Fix32& g); - friend int operator >= (const Fix32& f, const Fix32& g); - friend int operator <= (const Fix32& f, const Fix32& g); - friend int operator > (const Fix32& f, const Fix32& g); - friend int operator < (const Fix32& f, const Fix32& g); - - friend istream& operator >> (istream& s, Fix32& f); - friend ostream& operator << (ostream& s, const Fix32& f); - - void overflow(_G_int32_t& i) const; - void range_error(_G_int32_t& i) const; - - friend Fix32 operator * (const Fix32& f, int g); - friend Fix32 operator * (int g, const Fix32& f); - Fix32& operator *= (int g); -}; - -// active error handler declarations - -typedef void (*Fix16_peh)(short&); -typedef void (*Fix32_peh)(_G_int32_t&); - -extern Fix16_peh Fix16_overflow_handler; -extern Fix32_peh Fix32_overflow_handler; - -extern Fix16_peh Fix16_range_error_handler; -extern Fix32_peh Fix32_range_error_handler; - -#if defined(SHORT_NAMES) || defined(VMS) -#define set_overflow_handler sohndl -#define set_range_error_handler srnghdl -#endif - - -// error handler declarations - -extern Fix16_peh set_Fix16_overflow_handler(Fix16_peh); -extern Fix32_peh set_Fix32_overflow_handler(Fix32_peh); -extern void set_overflow_handler(Fix16_peh, Fix32_peh); - -extern Fix16_peh set_Fix16_range_error_handler(Fix16_peh); -extern Fix32_peh set_Fix32_range_error_handler(Fix32_peh); -extern void set_range_error_handler(Fix16_peh, Fix32_peh); - -extern void - Fix16_ignore(short&), - Fix16_overflow_saturate(short&), - Fix16_overflow_warning_saturate(short&), - Fix16_warning(short&), - Fix16_abort(short&); - -extern void - Fix32_ignore(_G_int32_t&), - Fix32_overflow_saturate(_G_int32_t&), - Fix32_overflow_warning_saturate(_G_int32_t&), - Fix32_warning(_G_int32_t&), - Fix32_abort(_G_int32_t&); - - -inline Fix16::~Fix16() {} - -inline short Fix16::round(double d) -{ - return short( (d >= 0)? d + 0.5 : d - 0.5); -} - -inline Fix16::Fix16(short i) -{ - m = i; -} - -inline Fix16::Fix16(int i) -{ - m = i; -} - -inline Fix16::operator double() const -{ - return Fix16_div * m; -} - -inline Fix16::Fix16() -{ - m = 0; -} - -inline Fix16::Fix16(const Fix16& f) -{ - m = f.m; -} - -inline Fix16::Fix16(double d) -{ - m = assign(d); -} - - -inline Fix16& Fix16::operator=(const Fix16& f) -{ - m = f.m; - return *this; -} - -inline Fix16& Fix16::operator=(double d) -{ - m = assign(d); - return *this; -} - - -inline Fix32::Fix32() -{ - m = 0; -} - -inline Fix32::Fix32(_G_int32_t i) -{ - m = i; -} - -inline Fix32:: operator double() const -{ - return Fix32_div * m; -} - - -inline Fix32::Fix32(const Fix32& f) -{ - m = f.m; -} - -inline Fix32::Fix32(const Fix16& f) -{ - m = _G_int32_t(f.m) << 16; -} - -inline Fix32::Fix32(double d) -{ - m = assign(d); -} - -inline Fix16::Fix16(const Fix32& f) -{ - m = f.m >> 16; -} - - -inline Fix16& Fix16::operator=(const Fix32& f) -{ - m = f.m >> 16; - return *this; -} - -inline Fix32& Fix32::operator=(const Fix32& f) -{ - m = f.m; - return *this; -} - -inline Fix32& Fix32::operator=(const Fix16& f) -{ - m = _G_int32_t(f.m) << 16; - return *this; -} - -inline Fix32& Fix32::operator=(double d) -{ - m = assign(d); - return *this; -} - -inline short& mantissa(Fix16& f) -{ - return f.m; -} - -inline const short& mantissa(const Fix16& f) -{ - return f.m; -} - -inline double value(const Fix16& f) -{ - return double(f); -} - -inline Fix16 Fix16::operator+() const -{ - return m; -} - -inline Fix16 Fix16::operator-() const -{ - return -m; -} - -inline Fix16 operator+(const Fix16& f, const Fix16& g) -{ - short sum = f.m + g.m; - if ( (f.m ^ sum) & (g.m ^ sum) & Fix16_msb ) - f.overflow(sum); - return sum; -} - -inline Fix16 operator-(const Fix16& f, const Fix16& g) -{ - short sum = f.m - g.m; - if ( (f.m ^ sum) & (-g.m ^ sum) & Fix16_msb ) - f.overflow(sum); - return sum; -} - -inline Fix32 operator*(const Fix16& f, const Fix16& g) -{ - return Fix32( _G_int32_t( _G_int32_t(f.m) * _G_int32_t(g.m) << 1)); -} - -inline Fix16 operator<<(const Fix16& a, int b) -{ - return a.m << b; -} - -inline Fix16 operator>>(const Fix16& a, int b) -{ - return a.m >> b; -} - -inline Fix16& Fix16:: operator+=(const Fix16& f) -{ - return *this = *this + f; -} - -inline Fix16& Fix16:: operator-=(const Fix16& f) -{ - return *this = *this - f; -} - -inline Fix16& Fix16::operator*=(const Fix16& f) -{ - return *this = *this * f; -} - -inline Fix16& Fix16:: operator/=(const Fix16& f) -{ - return *this = *this / f; -} - -inline Fix16& Fix16:: operator<<=(int b) -{ - return *this = *this << b; -} - -inline Fix16& Fix16:: operator>>=(int b) -{ - return *this = *this >> b; -} - -inline int operator==(const Fix16& f, const Fix16& g) -{ - return f.m == g.m; -} - -inline int operator!=(const Fix16& f, const Fix16& g) -{ - return f.m != g.m; -} - -inline int operator>=(const Fix16& f, const Fix16& g) -{ - return f.m >= g.m; -} - -inline int operator<=(const Fix16& f, const Fix16& g) -{ - return f.m <= g.m; -} - -inline int operator>(const Fix16& f, const Fix16& g) -{ - return f.m > g.m; -} - -inline int operator<(const Fix16& f, const Fix16& g) -{ - return f.m < g.m; -} - -inline istream& operator>>(istream& s, Fix16& f) -{ - double d; - s >> d; - f = d; - return s; -} - -inline ostream& operator<<(ostream& s, const Fix16& f) -{ - return s << double(f); -} - - -inline Fix16 operator*(const Fix16& f, int g) -{ - return Fix16(short(f.m * g)); -} - -inline Fix16 operator*(int g, const Fix16& f) -{ - return f * g; -} - - -inline Fix16& Fix16::operator*=(int g) -{ - return *this = *this * g; -} - -inline Fix32::~Fix32() {} - -inline _G_int32_t Fix32::round(double d) -{ - return _G_int32_t( (d >= 0)? d + 0.5 : d - 0.5); -} - -inline _G_int32_t& mantissa(Fix32& f) -{ - return f.m; -} - -inline const _G_int32_t& mantissa(const Fix32& f) -{ - return f.m; -} - -inline double value(const Fix32& f) -{ - return double(f); -} - -inline Fix32 Fix32::operator+() const -{ - return m; -} - -inline Fix32 Fix32::operator-() const -{ - return -m; -} - -inline Fix32 operator+(const Fix32& f, const Fix32& g) -{ - _G_int32_t sum = f.m + g.m; - if ( (f.m ^ sum) & (g.m ^ sum) & Fix32_msb ) - f.overflow(sum); - return sum; -} - -inline Fix32 operator-(const Fix32& f, const Fix32& g) -{ - _G_int32_t sum = f.m - g.m; - if ( (f.m ^ sum) & (-g.m ^ sum) & Fix32_msb ) - f.overflow(sum); - return sum; -} - -inline Fix32 operator<<(const Fix32& a, int b) -{ - return a.m << b; -} - -inline Fix32 operator>>(const Fix32& a, int b) -{ - return a.m >> b; -} - -inline Fix32& Fix32::operator+=(const Fix32& f) -{ - return *this = *this + f; -} - -inline Fix32& Fix32::operator-=(const Fix32& f) -{ - return *this = *this - f; -} - -inline Fix32& Fix32::operator*=(const Fix32& f) -{ - return *this = *this * f; -} - -inline Fix32& Fix32::operator/=(const Fix32& f) -{ - return *this = *this / f; -} - - -inline Fix32& Fix32::operator<<=(int b) -{ - return *this = *this << b; -} - -inline Fix32& Fix32::operator>>=(int b) -{ - return *this = *this >> b; -} - -inline int operator==(const Fix32& f, const Fix32& g) -{ - return f.m == g.m; -} - -inline int operator!=(const Fix32& f, const Fix32& g) -{ - return f.m != g.m; -} - -inline int operator>=(const Fix32& f, const Fix32& g) -{ - return f.m >= g.m; -} - -inline int operator<=(const Fix32& f, const Fix32& g) -{ - return f.m <= g.m; -} - -inline int operator>(const Fix32& f, const Fix32& g) -{ - return f.m > g.m; -} - -inline int operator<(const Fix32& f, const Fix32& g) -{ - return f.m < g.m; -} - -inline istream& operator>>(istream& s, Fix32& f) -{ - double d; - s >> d; - f = d; - return s; -} - -inline ostream& operator<<(ostream& s, const Fix32& f) -{ - return s << double(f); -} - -inline Fix32 operator*(const Fix32& f, int g) -{ - return Fix32(_G_int32_t(f.m * g)); -} - -inline Fix32 operator*(int g, const Fix32& f) -{ - return f * g; -} - - - -inline Fix32& Fix32::operator*=(int g) -{ - return *this = *this * g; -} - -#endif diff --git a/gnu/lib/libg++/include/Fix24.h b/gnu/lib/libg++/include/Fix24.h deleted file mode 100644 index 0f4daeaa9e6d..000000000000 --- a/gnu/lib/libg++/include/Fix24.h +++ /dev/null @@ -1,597 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu) - adapted for libg++ by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _Fix24_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Fix24_h 1 - -#include <stream.h> -#include <std.h> - -// extra type definitions - -typedef struct { - _G_int32_t u; - _G_uint32_t l; -} twolongs; - -// constant definitions - -static const int - Fix24_shift = 31; - -static const double - Fix24_fs = 2147483648., // 2^Fix24_shift - Fix24_mult = Fix24_fs, - Fix24_div = 1./Fix24_fs, - Fix24_max = 1. - .5/Fix24_fs, - Fix24_min = -1.; - -static const _G_uint32_t - Fix24_msb = 0x80000000L, - Fix24_lsb = 0x00000100L, - Fix24_m_max = 0x7fffff00L, - Fix24_m_min = 0x80000000L; - -static const double - Fix48_fs = 36028797018963968., // 2^(24+Fix24_shift) - Fix48_max = 1. - .5/Fix48_fs, - Fix48_min = -1., - Fix48_div_u = 1./Fix24_fs, - Fix48_div_l = 1./Fix48_fs; - -static const twolongs - Fix48_msb = { 0x80000000L, 0L }, - Fix48_lsb = { 0L, 0x00000100L }, - Fix48_m_max = { 0x7fffff00L, 0xffffff00L }, - Fix48_m_min = { 0x80000000L, 0L }; - -// -// Fix24 class: 24-bit Fixed point data type -// -// consists of a 24-bit mantissa (sign bit & 23 data bits). -// - -class Fix24 -{ - friend class Fix48; - - _G_int32_t m; - - _G_int32_t assign(double d); - operator double() const; - Fix24(long i); - Fix24(int i); - - -public: - Fix24(); - Fix24(const Fix24& f); - Fix24(double d); - Fix24(const Fix48& f); - - ~Fix24(); - - Fix24& operator=(const Fix24& f); - Fix24& operator=(double d); - Fix24& operator=(const Fix48& f); - - friend _G_int32_t& mantissa(Fix24& f); - friend const _G_int32_t& mantissa(const Fix24& f); - friend double value(const Fix24& f); - - Fix24 operator + () const; - Fix24 operator - () const; - - friend Fix24 operator + (const Fix24& f, const Fix24& g); - friend Fix24 operator - (const Fix24& f, const Fix24& g); - friend Fix48 operator * (const Fix24& f, const Fix24& g); - friend Fix24 operator * (const Fix24& f, int g); - friend Fix24 operator * (int g, const Fix24& f); - friend Fix24 operator / (const Fix24& f, const Fix24& g); - friend Fix24 operator << (const Fix24& f, int b); - friend Fix24 operator >> (const Fix24& f, int b); - - Fix24& operator += (const Fix24& f); - Fix24& operator -= (const Fix24& f); - Fix24& operator *= (const Fix24& f); - Fix24& operator *= (int b); - Fix24& operator /= (const Fix24& f); - - Fix24& operator <<=(int b); - Fix24& operator >>=(int b); - - friend int operator == (const Fix24& f, const Fix24& g); - friend int operator != (const Fix24& f, const Fix24& g); - friend int operator >= (const Fix24& f, const Fix24& g); - friend int operator <= (const Fix24& f, const Fix24& g); - friend int operator > (const Fix24& f, const Fix24& g); - friend int operator < (const Fix24& f, const Fix24& g); - - friend istream& operator >> (istream& s, Fix24& f); - friend ostream& operator << (ostream& s, const Fix24& f); - - void overflow(_G_int32_t&) const; - void range_error(_G_int32_t&) const; -}; - - -// -// Fix48 class: 48-bit Fixed point data type -// -// consists of a 48-bit mantissa (sign bit & 47 data bits). -// - -class Fix48 -{ - friend class Fix24; - - twolongs m; - - twolongs assign(double d); - operator double() const; - Fix48(twolongs i); - -public: - Fix48(); - Fix48(const Fix48& f); - Fix48(const Fix24& f); - Fix48(double d); - ~Fix48(); - - Fix48& operator = (const Fix48& f); - Fix48& operator = (const Fix24& f); - Fix48& operator = (double d); - - friend twolongs& mantissa(Fix48& f); - friend const twolongs& mantissa(const Fix48& f); - friend double value(const Fix48& f); - - Fix48 operator + () const; - Fix48 operator - () const; - - friend Fix48 operator + (const Fix48& f, const Fix48& g); - friend Fix48 operator - (const Fix48& f, const Fix48& g); - friend Fix48 operator * (const Fix48& f, int g); - friend Fix48 operator * (int g, const Fix48& f); - friend Fix48 operator << (const Fix48& f, int b); - friend Fix48 operator >> (const Fix48& f, int b); - - friend Fix48 operator * (const Fix24& f, const Fix24& g); - - Fix48& operator += (const Fix48& f); - Fix48& operator -= (const Fix48& f); - Fix48& operator *= (int b); - Fix48& operator <<=(int b); - Fix48& operator >>=(int b); - - friend int operator == (const Fix48& f, const Fix48& g); - friend int operator != (const Fix48& f, const Fix48& g); - friend int operator >= (const Fix48& f, const Fix48& g); - friend int operator <= (const Fix48& f, const Fix48& g); - friend int operator > (const Fix48& f, const Fix48& g); - friend int operator < (const Fix48& f, const Fix48& g); - - friend istream& operator >> (istream& s, Fix48& f); - friend ostream& operator << (ostream& s, const Fix48& f); - - void overflow(twolongs& i) const; - void range_error(twolongs& i) const; -}; - - -// active error handler declarations - -typedef void (*Fix24_peh)(_G_int32_t&); -typedef void (*Fix48_peh)(twolongs&); - -extern Fix24_peh Fix24_overflow_handler; -extern Fix48_peh Fix48_overflow_handler; - -extern Fix24_peh Fix24_range_error_handler; -extern Fix48_peh Fix48_range_error_handler; - - -// error handler declarations - -#if defined(SHORT_NAMES) || defined(VMS) -#define set_overflow_handler sohndl -#define set_range_error_handler srnghdl -#endif - -extern Fix24_peh set_Fix24_overflow_handler(Fix24_peh); -extern Fix48_peh set_Fix48_overflow_handler(Fix48_peh); -extern void set_overflow_handler(Fix24_peh, Fix48_peh); - -extern Fix24_peh set_Fix24_range_error_handler(Fix24_peh); -extern Fix48_peh set_Fix48_range_error_handler(Fix48_peh); -extern void set_range_error_handler(Fix24_peh, Fix48_peh); - -extern void - Fix24_ignore(_G_int32_t&), - Fix24_overflow_saturate(_G_int32_t&), - Fix24_overflow_warning_saturate(_G_int32_t&), - Fix24_warning(_G_int32_t&), - Fix24_abort(_G_int32_t&); - -extern void - Fix48_ignore(twolongs&), - Fix48_overflow_saturate(twolongs&), - Fix48_overflow_warning_saturate(twolongs&), - Fix48_warning(twolongs&), - Fix48_abort(twolongs&); - - -inline Fix24::~Fix24() {} - -inline Fix24::Fix24(long i) -{ - m = i; -} - -inline Fix24::Fix24(int i) -{ - m = i; -} - -inline Fix24::operator double() const -{ - return Fix24_div * m; -} - -inline Fix24::Fix24() -{ - m = 0; -} - -inline Fix24::Fix24(const Fix24& f) -{ - m = f.m; -} - -inline Fix24::Fix24(double d) -{ - m = assign(d); -} - -inline Fix24::Fix24(const Fix48& f) -{ - m = f.m.u; -} - -inline Fix24& Fix24::operator=(const Fix24& f) -{ - m = f.m; - return *this; -} - -inline Fix24& Fix24::operator=(double d) -{ - m = assign(d); - return *this; -} - -inline Fix24& Fix24::operator=(const Fix48& f) -{ - m = f.m.u; - return *this; -} - -inline _G_int32_t& mantissa(Fix24& f) -{ - return f.m; -} - -inline const _G_int32_t& mantissa(const Fix24& f) -{ - return f.m; -} - -inline double value(const Fix24& f) -{ - return double(f); -} - -inline Fix24 Fix24::operator+() const -{ - return m; -} - -inline Fix24 Fix24::operator-() const -{ - return -m; -} - -inline Fix24 operator+(const Fix24& f, const Fix24& g) -{ - _G_int32_t sum = f.m + g.m; - if ( (f.m ^ sum) & (g.m ^ sum) & Fix24_msb ) - f.overflow(sum); - return sum; -} - -inline Fix24 operator-(const Fix24& f, const Fix24& g) -{ - _G_int32_t sum = f.m - g.m; - if ( (f.m ^ sum) & (-g.m ^ sum) & Fix24_msb ) - f.overflow(sum); - return sum; -} - -inline Fix24 operator*(const Fix24& a, int b) -{ - return a.m * b; -} - -inline Fix24 operator*(int b, const Fix24& a) -{ - return a * b; -} - -inline Fix24 operator<<(const Fix24& a, int b) -{ - return a.m << b; -} - -inline Fix24 operator>>(const Fix24& a, int b) -{ - return (a.m >> b) & ~0xff; -} - -inline Fix24& Fix24:: operator+=(const Fix24& f) -{ - return *this = *this + f; -} - -inline Fix24& Fix24:: operator-=(const Fix24& f) -{ - return *this = *this - f; -} - -inline Fix24& Fix24::operator*=(const Fix24& f) -{ - return *this = *this * f; -} - -inline Fix24& Fix24:: operator/=(const Fix24& f) -{ - return *this = *this / f; -} - -inline Fix24& Fix24:: operator<<=(int b) -{ - return *this = *this << b; -} - -inline Fix24& Fix24:: operator>>=(int b) -{ - return *this = *this >> b; -} - -inline Fix24& Fix24::operator*=(int b) -{ - return *this = *this * b; -} - -inline int operator==(const Fix24& f, const Fix24& g) -{ - return f.m == g.m; -} - -inline int operator!=(const Fix24& f, const Fix24& g) -{ - return f.m != g.m; -} - -inline int operator>=(const Fix24& f, const Fix24& g) -{ - return f.m >= g.m; -} - -inline int operator<=(const Fix24& f, const Fix24& g) -{ - return f.m <= g.m; -} - -inline int operator>(const Fix24& f, const Fix24& g) -{ - return f.m > g.m; -} - -inline int operator<(const Fix24& f, const Fix24& g) -{ - return f.m < g.m; -} - -inline istream& operator>>(istream& s, Fix24& f) -{ - double d; - s >> d; - f = d; - return s; -} - -inline ostream& operator<<(ostream& s, const Fix24& f) -{ - return s << double(f); -} - -inline Fix48::~Fix48() {} - -inline Fix48::Fix48(twolongs i) -{ - m = i; -} - -inline Fix48:: operator double() const -{ -/* - * Note: can't simply do Fix48_div_u * m.u + Fix48_div_l * m.l, because - * m.u is signed and m.l is unsigned. - */ - return (m.u >= 0)? Fix48_div_u * m.u + Fix48_div_l * m.l : - (Fix48_div_u * ((_G_uint32_t)(m.u & 0xffffff00)) - + Fix48_div_l * m.l) - 2; -} - -inline Fix48::Fix48() -{ - m.u = 0; - m.l = 0; -} - -inline Fix48::Fix48(const Fix48& f) -{ - m = f.m; -} - -inline Fix48::Fix48(const Fix24& f) -{ - m.u = f.m; - m.l = 0; -} - -inline Fix48::Fix48(double d) -{ - m = assign(d); -} - -inline Fix48& Fix48::operator=(const Fix48& f) -{ - m = f.m; - return *this; -} - -inline Fix48& Fix48::operator=(const Fix24& f) -{ - m.u = f.m; - m.l = 0; - return *this; -} - -inline Fix48& Fix48::operator=(double d) -{ - m = assign(d); - return *this; -} - -inline twolongs& mantissa(Fix48& f) -{ - return f.m; -} - -inline const twolongs& mantissa(const Fix48& f) -{ - return f.m; -} - -inline double value(const Fix48& f) -{ - return double(f); -} - -inline Fix48 Fix48::operator+() const -{ - return m; -} - -inline Fix48 Fix48::operator-() const -{ - twolongs n; - n.l = -m.l; - n.u = ~m.u + ((n.l ^ m.l) & Fix24_msb ? 0 : Fix24_lsb); - return Fix48(n); -} - -inline Fix48 operator*(int b, const Fix48& a) -{ - return a * b; -} - -inline Fix48& Fix48::operator+=(const Fix48& f) -{ - return *this = *this + f; -} - -inline Fix48& Fix48::operator-=(const Fix48& f) -{ - return *this = *this - f; -} - -inline Fix48& Fix48::operator*=(int b) -{ - return *this = *this * b; -} - -inline Fix48& Fix48::operator<<=(int b) -{ - return *this = *this << b; -} - -inline Fix48& Fix48::operator>>=(int b) -{ - return *this = *this >> b; -} - -inline int operator==(const Fix48& f, const Fix48& g) -{ - return f.m.u == g.m.u && f.m.l == g.m.l; -} - -inline int operator!=(const Fix48& f, const Fix48& g) -{ - return f.m.u != g.m.u || f.m.l != g.m.l; -} - -inline int operator>=(const Fix48& f, const Fix48& g) -{ - return f.m.u >= g.m.u || (f.m.u == g.m.u && f.m.l >= g.m.l); -} - -inline int operator<=(const Fix48& f, const Fix48& g) -{ - return f.m.u <= g.m.u || (f.m.u == g.m.u && f.m.l <= g.m.l); -} - -inline int operator>(const Fix48& f, const Fix48& g) -{ - return f.m.u > g.m.u || (f.m.u == g.m.u && f.m.l > g.m.l); -} - -inline int operator<(const Fix48& f, const Fix48& g) -{ - return f.m.u < g.m.u || (f.m.u == g.m.u && f.m.l < g.m.l); -} - -inline istream& operator>>(istream& s, Fix48& f) -{ - double d; - s >> d; - f = d; - return s; -} - -inline ostream& operator<<(ostream& s, const Fix48& f) -{ - return s << double(f); -} - -#endif diff --git a/gnu/lib/libg++/include/Geom.h b/gnu/lib/libg++/include/Geom.h deleted file mode 100644 index 7d05b8388bf5..000000000000 --- a/gnu/lib/libg++/include/Geom.h +++ /dev/null @@ -1,52 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _Geometric_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Geometric_h - -#include <Random.h> - -class Geometric: public Random { -protected: - double pMean; -public: - Geometric(double mean, RNG *gen); - - double mean(); - double mean(double x); - - virtual double operator()(); - -}; - - -inline Geometric::Geometric(double mean, RNG *gen) : Random(gen) -{ - pMean = mean; -} - - -inline double Geometric::mean() { return pMean; } -inline double Geometric::mean(double x) { - double tmp = pMean; pMean = x; return tmp; -} - - -#endif diff --git a/gnu/lib/libg++/include/GetOpt.h b/gnu/lib/libg++/include/GetOpt.h deleted file mode 100644 index 9dfc3c6e6c04..000000000000 --- a/gnu/lib/libg++/include/GetOpt.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Getopt for GNU. - Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. - (Modified by Douglas C. Schmidt for use with GNU G++.) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `getopt' works, it permutes the elements of `argv' so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable _POSIX_OPTION_ORDER disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#ifndef GetOpt_h -#ifdef __GNUG__ -#pragma interface -#endif -#define GetOpt_h 1 - -#include <std.h> -#include <stdio.h> - -class GetOpt -{ -private: - /* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - - static char *nextchar; - - - /* Describe how to deal with options that follow non-option ARGV-elements. - - UNSPECIFIED means the caller did not specify anything; - the default is then REQUIRE_ORDER if the environment variable - _OPTIONS_FIRST is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options. - Stop option processing when the first non-option is seen. - This is what Unix does. - - PERMUTE is the default. We permute the contents of `argv' as we scan, - so that eventually all the options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code zero. - Using `-' as the first character of the list of option characters - requests this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return EOF with `optind' != ARGC. */ - - enum OrderingEnum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER }; - OrderingEnum ordering; - - /* Handle permutation of arguments. */ - - /* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - - static int first_nonopt; - static int last_nonopt; - - void exchange (char **argv); -public: - /* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - - char *optarg; - - /* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns EOF, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - - int optind; - - /* Callers store zero here to inhibit the error message - for unrecognized options. */ - - int opterr; - - int nargc; - char **nargv; - const char *noptstring; - - GetOpt (int argc, char **argv, const char *optstring); - int operator () (void); -}; - -#endif diff --git a/gnu/lib/libg++/include/HypGeom.h b/gnu/lib/libg++/include/HypGeom.h deleted file mode 100644 index 1864e9151a26..000000000000 --- a/gnu/lib/libg++/include/HypGeom.h +++ /dev/null @@ -1,70 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _HyperGeometric_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _HyperGeometric_h - -#include <Random.h> - -class HyperGeometric: public Random { -protected: - double pMean; - double pVariance; - double pP; - void setState(); - -public: - HyperGeometric(double mean, double variance, RNG *gen); - - double mean(); - double mean(double x); - double variance(); - double variance(double x); - - virtual double operator()(); -}; - - -inline void HyperGeometric::setState() { - double z = pVariance / (pMean * pMean); - pP = 0.5 * (1.0 - sqrt((z - 1.0) / ( z + 1.0 ))); -} - -inline HyperGeometric::HyperGeometric(double mean, double variance, RNG *gen) -: Random(gen) { - pMean = mean; pVariance = variance; - setState(); -} - -inline double HyperGeometric::mean() { return pMean; }; - -inline double HyperGeometric::mean(double x) { - double t = pMean; pMean = x; - setState(); return t; -} - -inline double HyperGeometric::variance() { return pVariance; } - -inline double HyperGeometric::variance(double x) { - double t = pVariance; pVariance = x; - setState(); return t; -} - -#endif diff --git a/gnu/lib/libg++/include/Integer.h b/gnu/lib/libg++/include/Integer.h deleted file mode 100644 index b5c1768a7bef..000000000000 --- a/gnu/lib/libg++/include/Integer.h +++ /dev/null @@ -1,1119 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _Integer_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Integer_h 1 - -#include <iostream.h> - -struct IntRep // internal Integer representations -{ - unsigned short len; // current length - unsigned short sz; // allocated space (0 means static). - short sgn; // 1 means >= 0; 0 means < 0 - unsigned short s[1]; // represented as ushort array starting here -}; - -// True if REP is staticly (or manually) allocated, -// and should not be deleted by an Integer destructor. -#define STATIC_IntRep(rep) ((rep)->sz==0) - -extern IntRep* Ialloc(IntRep*, const unsigned short *, int, int, int); -extern IntRep* Icalloc(IntRep*, int); -extern IntRep* Icopy_ulong(IntRep*, unsigned long); -extern IntRep* Icopy_long(IntRep*, long); -extern IntRep* Icopy(IntRep*, const IntRep*); -extern IntRep* Iresize(IntRep*, int); -extern IntRep* add(const IntRep*, int, const IntRep*, int, IntRep*); -extern IntRep* add(const IntRep*, int, long, IntRep*); -extern IntRep* multiply(const IntRep*, const IntRep*, IntRep*); -extern IntRep* multiply(const IntRep*, long, IntRep*); -extern IntRep* lshift(const IntRep*, long, IntRep*); -extern IntRep* lshift(const IntRep*, const IntRep*, int, IntRep*); -extern IntRep* bitop(const IntRep*, const IntRep*, IntRep*, char); -extern IntRep* bitop(const IntRep*, long, IntRep*, char); -extern IntRep* power(const IntRep*, long, IntRep*); -extern IntRep* div(const IntRep*, const IntRep*, IntRep*); -extern IntRep* mod(const IntRep*, const IntRep*, IntRep*); -extern IntRep* div(const IntRep*, long, IntRep*); -extern IntRep* mod(const IntRep*, long, IntRep*); -extern IntRep* compl(const IntRep*, IntRep*); -extern IntRep* abs(const IntRep*, IntRep*); -extern IntRep* negate(const IntRep*, IntRep*); -extern IntRep* pow(const IntRep*, long); -extern IntRep* gcd(const IntRep*, const IntRep* y); -extern int compare(const IntRep*, const IntRep*); -extern int compare(const IntRep*, long); -extern int ucompare(const IntRep*, const IntRep*); -extern int ucompare(const IntRep*, long); -extern char* Itoa(const IntRep* x, int base = 10, int width = 0); -extern char* cvtItoa(const IntRep* x, char* fmt, int& fmtlen, int base, - int showbase, int width, int align_right, - char fillchar, char Xcase, int showpos); -extern IntRep* atoIntRep(const char* s, int base = 10); -extern long Itolong(const IntRep*); -extern int Iislong(const IntRep*); -extern long lg(const IntRep*); - -extern IntRep _ZeroRep, _OneRep, _MinusOneRep; - -class Integer -{ -protected: - IntRep* rep; -public: - Integer(); - Integer(int); - Integer(long); - Integer(unsigned long); - Integer(IntRep*); - Integer(const Integer&); - - ~Integer(); - Integer& operator = (const Integer&); - Integer& operator = (long); - -// unary operations to self - - Integer& operator ++ (); - Integer& operator -- (); - void negate(); // negate in-place - void abs(); // absolute-value in-place - void complement(); // bitwise complement in-place - -// assignment-based operations - - Integer& operator += (const Integer&); - Integer& operator -= (const Integer&); - Integer& operator *= (const Integer&); - Integer& operator /= (const Integer&); - Integer& operator %= (const Integer&); - Integer& operator <<=(const Integer&); - Integer& operator >>=(const Integer&); - Integer& operator &= (const Integer&); - Integer& operator |= (const Integer&); - Integer& operator ^= (const Integer&); - - Integer& operator += (long); - Integer& operator -= (long); - Integer& operator *= (long); - Integer& operator /= (long); - Integer& operator %= (long); - Integer& operator <<=(long); - Integer& operator >>=(long); - Integer& operator &= (long); - Integer& operator |= (long); - Integer& operator ^= (long); - -// (constructive binary operations are inlined below) - -#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) - friend Integer operator <? (const Integer& x, const Integer& y); // min - friend Integer operator >? (const Integer& x, const Integer& y); // max -#endif - -// builtin Integer functions that must be friends - - friend long lg (const Integer&); // floor log base 2 of abs(x) - friend double ratio(const Integer& x, const Integer& y); - // return x/y as a double - - friend Integer gcd(const Integer&, const Integer&); - friend int even(const Integer&); // true if even - friend int odd(const Integer&); // true if odd - friend int sign(const Integer&); // returns -1, 0, +1 - - friend void (setbit)(Integer& x, long b); // set b'th bit of x - friend void clearbit(Integer& x, long b); // clear b'th bit - friend int testbit(const Integer& x, long b); // return b'th bit - -// procedural versions of operators - - friend void abs(const Integer& x, Integer& dest); - friend void negate(const Integer& x, Integer& dest); - friend void complement(const Integer& x, Integer& dest); - - friend int compare(const Integer&, const Integer&); - friend int ucompare(const Integer&, const Integer&); - friend void add(const Integer& x, const Integer& y, Integer& dest); - friend void sub(const Integer& x, const Integer& y, Integer& dest); - friend void mul(const Integer& x, const Integer& y, Integer& dest); - friend void div(const Integer& x, const Integer& y, Integer& dest); - friend void mod(const Integer& x, const Integer& y, Integer& dest); - friend void divide(const Integer& x, const Integer& y, - Integer& q, Integer& r); - 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 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); - - friend int compare(const Integer&, long); - friend int ucompare(const Integer&, long); - friend void add(const Integer& x, long y, Integer& dest); - friend void sub(const Integer& x, long y, Integer& dest); - friend void mul(const Integer& x, long y, Integer& dest); - 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); - 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); - 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); - - friend int compare(long, const Integer&); - friend int ucompare(long, const Integer&); - 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); - 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); - -// coercion & conversion - - int fits_in_long() const { return Iislong(rep); } - int fits_in_double() const; - - long as_long() const { return Itolong(rep); } - double as_double() const; - - friend char* Itoa(const Integer& x, int base = 10, int width = 0); - friend Integer atoI(const char* s, int base = 10); - void printon(ostream& s, int base = 10, int width = 0) const; - - friend istream& operator >> (istream& s, Integer& y); - friend ostream& operator << (ostream& s, const Integer& y); - -// error detection - - int initialized() const; - void error(const char* msg) const; - int OK() const; -}; - - -// (These are declared inline) - - int operator == (const Integer&, const Integer&); - int operator == (const Integer&, long); - int operator != (const Integer&, const Integer&); - int operator != (const Integer&, long); - int operator < (const Integer&, const Integer&); - int operator < (const Integer&, long); - int operator <= (const Integer&, const Integer&); - int operator <= (const Integer&, long); - int operator > (const Integer&, const Integer&); - int operator > (const Integer&, long); - int operator >= (const Integer&, const Integer&); - int operator >= (const Integer&, long); - Integer operator - (const Integer&); - Integer operator ~ (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 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 % (const Integer&, const Integer&); - 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 & (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 - - Integer pow(const Integer& x, const Integer& y); - Integer pow(const Integer& x, long y); - Integer Ipow(long x, long y); // x to the y as Integer - - -extern char* dec(const Integer& x, int width = 0); -extern char* oct(const Integer& x, int width = 0); -extern char* hex(const Integer& x, int width = 0); -extern Integer sqrt(const Integer&); // floor of square root -extern Integer lcm(const Integer& x, const Integer& y); // least common mult - - -typedef Integer IntTmp; // for backward compatibility - -inline Integer::Integer() :rep(&_ZeroRep) {} - -inline Integer::Integer(IntRep* r) :rep(r) {} - -inline Integer::Integer(int y) :rep(Icopy_long(0, (long)y)) {} - -inline Integer::Integer(long y) :rep(Icopy_long(0, y)) {} - -inline Integer::Integer(unsigned long y) :rep(Icopy_ulong(0, y)) {} - -inline Integer::Integer(const Integer& y) :rep(Icopy(0, y.rep)) {} - -inline Integer::~Integer() { if (rep && !STATIC_IntRep(rep)) delete rep; } - -inline Integer& Integer::operator = (const Integer& y) -{ - rep = Icopy(rep, y.rep); - return *this; -} - -inline Integer& Integer::operator = (long y) -{ - rep = Icopy_long(rep, y); - return *this; -} - -inline int Integer::initialized() const -{ - return rep != 0; -} - -// procedural versions - -inline int compare(const Integer& x, const Integer& y) -{ - return compare(x.rep, y.rep); -} - -inline int ucompare(const Integer& x, const Integer& y) -{ - return ucompare(x.rep, y.rep); -} - -inline int compare(const Integer& x, long y) -{ - return compare(x.rep, y); -} - -inline int ucompare(const Integer& x, long y) -{ - return ucompare(x.rep, y); -} - -inline int compare(long x, const Integer& y) -{ - return -compare(y.rep, x); -} - -inline int ucompare(long x, const Integer& y) -{ - return -ucompare(y.rep, x); -} - -inline void add(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = add(x.rep, 0, y.rep, 0, dest.rep); -} - -inline void sub(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = add(x.rep, 0, y.rep, 1, dest.rep); -} - -inline void mul(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = multiply(x.rep, y.rep, dest.rep); -} - -inline void div(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = div(x.rep, y.rep, dest.rep); -} - -inline void mod(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = mod(x.rep, y.rep, dest.rep); -} - -inline void and(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(x.rep, y.rep, dest.rep, '&'); -} - -inline void or(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(x.rep, y.rep, dest.rep, '|'); -} - -inline void xor(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(x.rep, y.rep, dest.rep, '^'); -} - -inline void lshift(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = lshift(x.rep, y.rep, 0, dest.rep); -} - -inline void rshift(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = lshift(x.rep, y.rep, 1, dest.rep); -} - -inline void pow(const Integer& x, const Integer& y, Integer& dest) -{ - dest.rep = power(x.rep, Itolong(y.rep), dest.rep); // not incorrect -} - -inline void add(const Integer& x, long y, Integer& dest) -{ - dest.rep = add(x.rep, 0, y, dest.rep); -} - -inline void sub(const Integer& x, long y, Integer& dest) -{ - dest.rep = add(x.rep, 0, -y, dest.rep); -} - -inline void mul(const Integer& x, long y, Integer& dest) -{ - dest.rep = multiply(x.rep, y, dest.rep); -} - -inline void div(const Integer& x, long y, Integer& dest) -{ - dest.rep = div(x.rep, y, dest.rep); -} - -inline void mod(const Integer& x, long y, Integer& dest) -{ - dest.rep = mod(x.rep, y, dest.rep); -} - -inline void and(const Integer& x, long y, Integer& dest) -{ - dest.rep = bitop(x.rep, y, dest.rep, '&'); -} - -inline void or(const Integer& x, long y, Integer& dest) -{ - dest.rep = bitop(x.rep, y, dest.rep, '|'); -} - -inline void xor(const Integer& x, long y, Integer& dest) -{ - dest.rep = bitop(x.rep, y, dest.rep, '^'); -} - -inline void lshift(const Integer& x, long y, Integer& dest) -{ - dest.rep = lshift(x.rep, y, dest.rep); -} - -inline void rshift(const Integer& x, long y, Integer& dest) -{ - dest.rep = lshift(x.rep, -y, dest.rep); -} - -inline void pow(const Integer& x, long y, Integer& dest) -{ - dest.rep = power(x.rep, y, dest.rep); -} - -inline void abs(const Integer& x, Integer& dest) -{ - dest.rep = abs(x.rep, dest.rep); -} - -inline void negate(const Integer& x, Integer& dest) -{ - dest.rep = negate(x.rep, dest.rep); -} - -inline void complement(const Integer& x, Integer& dest) -{ - dest.rep = compl(x.rep, dest.rep); -} - -inline void add(long x, const Integer& y, Integer& dest) -{ - dest.rep = add(y.rep, 0, x, dest.rep); -} - -inline void sub(long x, const Integer& y, Integer& dest) -{ - dest.rep = add(y.rep, 1, x, dest.rep); -} - -inline void mul(long x, const Integer& y, Integer& dest) -{ - dest.rep = multiply(y.rep, x, dest.rep); -} - -inline void and(long x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(y.rep, x, dest.rep, '&'); -} - -inline void or(long x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(y.rep, x, dest.rep, '|'); -} - -inline void xor(long x, const Integer& y, Integer& dest) -{ - dest.rep = bitop(y.rep, x, dest.rep, '^'); -} - - -// operator versions - -inline int operator == (const Integer& x, const Integer& y) -{ - return compare(x, y) == 0; -} - -inline int operator == (const Integer& x, long y) -{ - return compare(x, y) == 0; -} - -inline int operator != (const Integer& x, const Integer& y) -{ - return compare(x, y) != 0; -} - -inline int operator != (const Integer& x, long y) -{ - return compare(x, y) != 0; -} - -inline int operator < (const Integer& x, const Integer& y) -{ - return compare(x, y) < 0; -} - -inline int operator < (const Integer& x, long y) -{ - return compare(x, y) < 0; -} - -inline int operator <= (const Integer& x, const Integer& y) -{ - return compare(x, y) <= 0; -} - -inline int operator <= (const Integer& x, long y) -{ - return compare(x, y) <= 0; -} - -inline int operator > (const Integer& x, const Integer& y) -{ - return compare(x, y) > 0; -} - -inline int operator > (const Integer& x, long y) -{ - return compare(x, y) > 0; -} - -inline int operator >= (const Integer& x, const Integer& y) -{ - return compare(x, y) >= 0; -} - -inline int operator >= (const Integer& x, long y) -{ - return compare(x, y) >= 0; -} - - -inline Integer& Integer::operator += (const Integer& y) -{ - add(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator += (long y) -{ - add(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator ++ () -{ - add(*this, 1, *this); - return *this; -} - - -inline Integer& Integer::operator -= (const Integer& y) -{ - sub(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator -= (long y) -{ - sub(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator -- () -{ - add(*this, -1, *this); - return *this; -} - - - -inline Integer& Integer::operator *= (const Integer& y) -{ - mul(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator *= (long y) -{ - mul(*this, y, *this); - return *this; -} - - -inline Integer& Integer::operator &= (const Integer& y) -{ - and(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator &= (long y) -{ - and(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator |= (const Integer& y) -{ - or(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator |= (long y) -{ - or(*this, y, *this); - return *this; -} - - -inline Integer& Integer::operator ^= (const Integer& y) -{ - xor(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator ^= (long y) -{ - xor(*this, y, *this); - return *this; -} - - - -inline Integer& Integer::operator /= (const Integer& y) -{ - div(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator /= (long y) -{ - div(*this, y, *this); - return *this; -} - - -inline Integer& Integer::operator <<= (const Integer& y) -{ - lshift(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator <<= (long y) -{ - lshift(*this, y, *this); - return *this; -} - - -inline Integer& Integer::operator >>= (const Integer& y) -{ - rshift(*this, y, *this); - return *this; -} - -inline Integer& Integer::operator >>= (long y) -{ - rshift(*this, y, *this); - return *this; -} - -#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) -inline Integer operator <? (const Integer& x, const Integer& y) -{ - return (compare(x.rep, y.rep) <= 0) ? x : y; -} - -inline Integer operator >? (const Integer& x, const Integer& y) -{ - return (compare(x.rep, y.rep) >= 0)? x : y; -} -#endif - - -inline void Integer::abs() -{ - ::abs(*this, *this); -} - -inline void Integer::negate() -{ - ::negate(*this, *this); -} - - -inline void Integer::complement() -{ - ::complement(*this, *this); -} - - -inline int sign(const Integer& x) -{ - return (x.rep->len == 0) ? 0 : ( (x.rep->sgn == 1) ? 1 : -1 ); -} - -inline int even(const Integer& y) -{ - return y.rep->len == 0 || !(y.rep->s[0] & 1); -} - -inline int odd(const Integer& y) -{ - return y.rep->len > 0 && (y.rep->s[0] & 1); -} - -inline char* Itoa(const Integer& y, int base, int width) -{ - return Itoa(y.rep, base, width); -} - - - -inline long lg(const Integer& x) -{ - return lg(x.rep); -} - -// constructive operations - -#if defined(__GNUG__) && !defined(_G_NO_NRV) - -inline Integer operator + (const Integer& x, const Integer& y) return r -{ - add(x, y, r); -} - -inline Integer operator + (const Integer& x, long y) return r -{ - add(x, y, r); -} - -inline Integer operator + (long x, const Integer& y) return r -{ - add(x, y, r); -} - -inline Integer operator - (const Integer& x, const Integer& y) return r -{ - sub(x, y, r); -} - -inline Integer operator - (const Integer& x, long y) return r -{ - sub(x, y, r); -} - -inline Integer operator - (long x, const Integer& y) return r -{ - sub(x, y, r); -} - -inline Integer operator * (const Integer& x, const Integer& y) return r -{ - mul(x, y, r); -} - -inline Integer operator * (const Integer& x, long y) return r -{ - mul(x, y, r); -} - -inline Integer operator * (long x, const Integer& y) return r -{ - mul(x, y, r); -} - -inline Integer sqr(const Integer& x) return r -{ - mul(x, x, r); -} - -inline Integer operator & (const Integer& x, const Integer& y) return r -{ - and(x, y, r); -} - -inline Integer operator & (const Integer& x, long y) return r -{ - and(x, y, r); -} - -inline Integer operator & (long x, const Integer& y) return r -{ - and(x, y, r); -} - -inline Integer operator | (const Integer& x, const Integer& y) return r -{ - or(x, y, r); -} - -inline Integer operator | (const Integer& x, long y) return r -{ - or(x, y, r); -} - -inline Integer operator | (long x, const Integer& y) return r -{ - or(x, y, r); -} - -inline Integer operator ^ (const Integer& x, const Integer& y) return r -{ - xor(x, y, r); -} - -inline Integer operator ^ (const Integer& x, long y) return r -{ - xor(x, y, r); -} - -inline Integer operator ^ (long x, const Integer& y) return r -{ - xor(x, y, r); -} - -inline Integer operator / (const Integer& x, const Integer& y) return r -{ - div(x, y, r); -} - -inline Integer operator / (const Integer& x, long y) return r -{ - div(x, y, r); -} - -inline Integer operator % (const Integer& x, const Integer& y) return r -{ - mod(x, y, r); -} - -inline Integer operator % (const Integer& x, long y) return r -{ - mod(x, y, r); -} - -inline Integer operator << (const Integer& x, const Integer& y) return r -{ - lshift(x, y, r); -} - -inline Integer operator << (const Integer& x, long y) return r -{ - lshift(x, y, r); -} - -inline Integer operator >> (const Integer& x, const Integer& y) return r; -{ - rshift(x, y, r); -} - -inline Integer operator >> (const Integer& x, long y) return r -{ - rshift(x, y, r); -} - -inline Integer pow(const Integer& x, long y) return r -{ - pow(x, y, r); -} - -inline Integer Ipow(long x, long y) return r(x) -{ - pow(r, y, r); -} - -inline Integer pow(const Integer& x, const Integer& y) return r -{ - pow(x, y, r); -} - - - -inline Integer abs(const Integer& x) return r -{ - abs(x, r); -} - -inline Integer operator - (const Integer& x) return r -{ - negate(x, r); -} - -inline Integer operator ~ (const Integer& x) return r -{ - complement(x, r); -} - -inline Integer atoI(const char* s, int base) return r -{ - r.rep = atoIntRep(s, base); -} - -inline Integer gcd(const Integer& x, const Integer& y) return r -{ - r.rep = gcd(x.rep, y.rep); -} - -#else /* NO_NRV */ - -inline Integer operator + (const Integer& x, const Integer& y) -{ - Integer r; add(x, y, r); return r; -} - -inline Integer operator + (const Integer& x, long y) -{ - Integer r; add(x, y, r); return r; -} - -inline Integer operator + (long x, const Integer& y) -{ - Integer r; add(x, y, r); return r; -} - -inline Integer operator - (const Integer& x, const Integer& y) -{ - Integer r; sub(x, y, r); return r; -} - -inline Integer operator - (const Integer& x, long y) -{ - Integer r; sub(x, y, r); return r; -} - -inline Integer operator - (long x, const Integer& y) -{ - Integer r; sub(x, y, r); return r; -} - -inline Integer operator * (const Integer& x, const Integer& y) -{ - Integer r; mul(x, y, r); return r; -} - -inline Integer operator * (const Integer& x, long y) -{ - Integer r; mul(x, y, r); return r; -} - -inline Integer operator * (long x, const Integer& y) -{ - Integer r; mul(x, y, r); return r; -} - -inline Integer sqr(const Integer& x) -{ - Integer r; mul(x, x, r); return r; -} - -inline Integer operator & (const Integer& x, const Integer& y) -{ - Integer r; and(x, y, r); return r; -} - -inline Integer operator & (const Integer& x, long y) -{ - Integer r; and(x, y, r); return r; -} - -inline Integer operator & (long x, const Integer& y) -{ - Integer r; and(x, y, r); return r; -} - -inline Integer operator | (const Integer& x, const Integer& y) -{ - Integer r; or(x, y, r); return r; -} - -inline Integer operator | (const Integer& x, long y) -{ - Integer r; or(x, y, r); return r; -} - -inline Integer operator | (long x, const Integer& y) -{ - Integer r; or(x, y, r); return r; -} - -inline Integer operator ^ (const Integer& x, const Integer& y) -{ - Integer r; xor(x, y, r); return r; -} - -inline Integer operator ^ (const Integer& x, long y) -{ - Integer r; xor(x, y, r); return r; -} - -inline Integer operator ^ (long x, const Integer& y) -{ - Integer r; xor(x, y, r); return r; -} - -inline Integer operator / (const Integer& x, const Integer& y) -{ - Integer r; div(x, y, r); return r; -} - -inline Integer operator / (const Integer& x, long y) -{ - Integer r; div(x, y, r); return r; -} - -inline Integer operator % (const Integer& x, const Integer& y) -{ - Integer r; mod(x, y, r); return r; -} - -inline Integer operator % (const Integer& x, long y) -{ - Integer r; mod(x, y, r); return r; -} - -inline Integer operator << (const Integer& x, const Integer& y) -{ - Integer r; lshift(x, y, r); return r; -} - -inline Integer operator << (const Integer& x, long y) -{ - Integer r; lshift(x, y, r); return r; -} - -inline Integer operator >> (const Integer& x, const Integer& y) -{ - Integer r; rshift(x, y, r); return r; -} - -inline Integer operator >> (const Integer& x, long y) -{ - Integer r; rshift(x, y, r); return r; -} - -inline Integer pow(const Integer& x, long y) -{ - Integer r; pow(x, y, r); return r; -} - -inline Integer Ipow(long x, long y) -{ - Integer r(x); pow(r, y, r); return r; -} - -inline Integer pow(const Integer& x, const Integer& y) -{ - Integer r; pow(x, y, r); return r; -} - - - -inline Integer abs(const Integer& x) -{ - Integer r; abs(x, r); return r; -} - -inline Integer operator - (const Integer& x) -{ - Integer r; negate(x, r); return r; -} - -inline Integer operator ~ (const Integer& x) -{ - Integer r; complement(x, r); return r; -} - -inline Integer atoI(const char* s, int base) -{ - Integer r; r.rep = atoIntRep(s, base); return r; -} - -inline Integer gcd(const Integer& x, const Integer& y) -{ - Integer r; r.rep = gcd(x.rep, y.rep); return r; -} - -#endif /* NO_NRV */ - -inline Integer& Integer::operator %= (const Integer& y) -{ - *this = *this % y; // mod(*this, y, *this) doesn't work. - return *this; -} - -inline Integer& Integer::operator %= (long y) -{ - *this = *this % y; // mod(*this, y, *this) doesn't work. - return *this; -} -#endif /* !_Integer_h */ diff --git a/gnu/lib/libg++/include/Integer.hP b/gnu/lib/libg++/include/Integer.hP deleted file mode 100644 index b8a803942656..000000000000 --- a/gnu/lib/libg++/include/Integer.hP +++ /dev/null @@ -1,30 +0,0 @@ -// Stuff used to implement the Integer class. -// WARNING: Its internals WILL change! - -/* - Sizes of shifts for multiple-precision arithmetic. - These should not be changed unless Integer representation - as unsigned shorts is changed in the implementation files. -*/ - -#define I_SHIFT (sizeof(short) * CHAR_BIT) -#define I_RADIX ((unsigned long)(1L << I_SHIFT)) -#define I_MAXNUM ((unsigned long)((I_RADIX - 1))) -#define I_MINNUM ((unsigned long)(I_RADIX >> 1)) -#define I_POSITIVE 1 -#define I_NEGATIVE 0 - -/* All routines assume SHORT_PER_LONG > 1 */ -#define SHORT_PER_LONG ((unsigned)(((sizeof(long) + sizeof(short) - 1) / sizeof(short)))) -#define CHAR_PER_LONG ((unsigned)sizeof(long)) - -/* - minimum and maximum sizes for an IntRep -*/ - -#define MINIntRep_SIZE 16 -#define MAXIntRep_SIZE I_MAXNUM - -#ifndef MALLOC_MIN_OVERHEAD -#define MALLOC_MIN_OVERHEAD 4 -#endif diff --git a/gnu/lib/libg++/include/LogNorm.h b/gnu/lib/libg++/include/LogNorm.h deleted file mode 100644 index b5c4b463b151..000000000000 --- a/gnu/lib/libg++/include/LogNorm.h +++ /dev/null @@ -1,78 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _LogNormal_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _LogNormal_h - -#include <Normal.h> - -class LogNormal: public Normal { -protected: - double logMean; - double logVariance; - void setState(); -public: - LogNormal(double mean, double variance, RNG *gen); - double mean(); - double mean(double x); - double variance(); - double variance(double x); - virtual double operator()(); -}; - - -inline void LogNormal::setState() -{ - double m2 = logMean * logMean; - pMean = log(m2 / sqrt(logVariance + m2) ); -// from ch@heike.informatik.uni-dortmund.de: -// (was pVariance = log((sqrt(logVariance + m2)/m2 )); ) - pStdDev = sqrt(log((logVariance + m2)/m2 )); -} - -inline LogNormal::LogNormal(double mean, double variance, RNG *gen) - : Normal(mean, variance, gen) -{ - logMean = mean; - logVariance = variance; - setState(); -} - -inline double LogNormal::mean() { - return logMean; -} - -inline double LogNormal::mean(double x) -{ - double t=logMean; logMean = x; setState(); - return t; -} - -inline double LogNormal::variance() { - return logVariance; -} - -inline double LogNormal::variance(double x) -{ - double t=logVariance; logVariance = x; setState(); - return t; -} - -#endif diff --git a/gnu/lib/libg++/include/MLCG.h b/gnu/lib/libg++/include/MLCG.h deleted file mode 100644 index 9b288a731283..000000000000 --- a/gnu/lib/libg++/include/MLCG.h +++ /dev/null @@ -1,87 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _MLCG_h -#define _MLCG_h 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include <RNG.h> -#include <math.h> - -// -// Multiplicative Linear Conguential Generator -// - -class MLCG : public RNG { - _G_int32_t initialSeedOne; - _G_int32_t initialSeedTwo; - _G_int32_t seedOne; - _G_int32_t seedTwo; - -protected: - -public: - MLCG(_G_int32_t seed1 = 0, _G_int32_t seed2 = 1); - // - // Return a long-words word of random bits - // - virtual _G_uint32_t asLong(); - virtual void reset(); - _G_int32_t seed1(); - void seed1(_G_int32_t); - _G_int32_t seed2(); - void seed2(_G_int32_t); - void reseed(_G_int32_t, _G_int32_t); -}; - -inline _G_int32_t -MLCG::seed1() -{ - return(seedOne); -} - -inline void -MLCG::seed1(_G_int32_t s) -{ - initialSeedOne = s; - reset(); -} - -inline _G_int32_t -MLCG::seed2() -{ - return(seedTwo); -} - -inline void -MLCG::seed2(_G_int32_t s) -{ - initialSeedTwo = s; - reset(); -} - -inline void -MLCG::reseed(_G_int32_t s1, _G_int32_t s2) -{ - initialSeedOne = s1; - initialSeedTwo = s2; - reset(); -} - -#endif diff --git a/gnu/lib/libg++/include/NegExp.h b/gnu/lib/libg++/include/NegExp.h deleted file mode 100644 index 041e083bffde..000000000000 --- a/gnu/lib/libg++/include/NegExp.h +++ /dev/null @@ -1,55 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _NegativeExpntl_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _NegativeExpntl_h 1 - - -// -// Negative Exponential Random Numbers -// -// - -#include <Random.h> - -class NegativeExpntl: public Random { -protected: - double pMean; -public: - NegativeExpntl(double xmean, RNG *gen); - double mean(); - double mean(double x); - - virtual double operator()(); -}; - - -inline NegativeExpntl::NegativeExpntl(double xmean, RNG *gen) -: Random(gen) { - pMean = xmean; -} - -inline double NegativeExpntl::mean() { return pMean; } -inline double NegativeExpntl::mean(double x) { - double t = pMean; pMean = x; - return t; -} - -#endif diff --git a/gnu/lib/libg++/include/Normal.h b/gnu/lib/libg++/include/Normal.h deleted file mode 100644 index ab80f2a14d2d..000000000000 --- a/gnu/lib/libg++/include/Normal.h +++ /dev/null @@ -1,66 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _Normal_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Normal_h - -#include <Random.h> - -class Normal: public Random { - char haveCachedNormal; - double cachedNormal; - -protected: - double pMean; - double pVariance; - double pStdDev; - -public: - Normal(double xmean, double xvariance, RNG *gen); - double mean(); - double mean(double x); - double variance(); - double variance(double x); - virtual double operator()(); -}; - - -inline Normal::Normal(double xmean, double xvariance, RNG *gen) -: Random(gen) { - pMean = xmean; - pVariance = xvariance; - pStdDev = sqrt(pVariance); - haveCachedNormal = 0; -} - -inline double Normal::mean() { return pMean; }; -inline double Normal::mean(double x) { - double t=pMean; pMean = x; - return t; -} - -inline double Normal::variance() { return pVariance; } -inline double Normal::variance(double x) { - double t=pVariance; pVariance = x; - pStdDev = sqrt(pVariance); - return t; -}; - -#endif diff --git a/gnu/lib/libg++/include/Obstack.h b/gnu/lib/libg++/include/Obstack.h deleted file mode 100644 index 6e353fb56a22..000000000000 --- a/gnu/lib/libg++/include/Obstack.h +++ /dev/null @@ -1,216 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -#ifndef _Obstack_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Obstack_h 1 - -#include <std.h> - -class Obstack -{ - struct _obstack_chunk - { - char* limit; - _obstack_chunk* prev; - char contents[4]; - }; - -protected: - long chunksize; - _obstack_chunk* chunk; - char* objectbase; - char* nextfree; - char* chunklimit; - int alignmentmask; - - void _free(void* obj); - void newchunk(int size); - -public: - Obstack(int size = 4080, int alignment = 4); // 4080=4096-mallocslop - - ~Obstack(); - - void* base(); - void* next_free(); - int alignment_mask(); - int chunk_size(); - int size(); - int room(); - int contains(void* p); // does Obstack hold pointer p? - - void grow(const void* data, int size); - void grow(const void* data, int size, char terminator); - void grow(const char* s); - void grow(char c); - void grow_fast(char c); - void blank(int size); - void blank_fast(int size); - - void* finish(); - void* finish(char terminator); - - void* copy(const void* data, int size); - void* copy(const void* data, int size, char terminator); - void* copy(const char* s); - void* copy(char c); - void* alloc(int size); - - void free(void* obj); - void shrink(int size = 1); // suggested by ken@cs.rochester.edu - - int OK(); // rep invariant -}; - - -inline Obstack::~Obstack() -{ - _free(0); -} - -inline void* Obstack::base() -{ - return objectbase; -} - -inline void* Obstack::next_free() -{ - return nextfree; -} - -inline int Obstack::alignment_mask() -{ - return alignmentmask; -} - -inline int Obstack::chunk_size() -{ - return chunksize; -} - -inline int Obstack::size() -{ - return nextfree - objectbase; -} - -inline int Obstack::room() -{ - return chunklimit - nextfree; -} - -inline void Obstack:: grow(const void* data, int size) -{ - if (nextfree+size > chunklimit) - newchunk(size); - memcpy(nextfree, data, size); - nextfree += size; -} - -inline void Obstack:: grow(const void* data, int size, char terminator) -{ - if (nextfree+size+1 > chunklimit) - newchunk(size+1); - memcpy(nextfree, data, size); - nextfree += size; - *(nextfree)++ = terminator; -} - -inline void Obstack:: grow(const char* s) -{ - grow((const void*)s, strlen(s), 0); -} - -inline void Obstack:: grow(char c) -{ - if (nextfree+1 > chunklimit) - newchunk(1); - *(nextfree)++ = c; -} - -inline void Obstack:: blank(int size) -{ - if (nextfree+size > chunklimit) - newchunk(size); - nextfree += size; -} - -inline void* Obstack::finish(char terminator) -{ - grow(terminator); - return finish(); -} - -inline void* Obstack::copy(const void* data, int size) -{ - grow (data, size); - return finish(); -} - -inline void* Obstack::copy(const void* data, int size, char terminator) -{ - grow(data, size, terminator); - return finish(); -} - -inline void* Obstack::copy(const char* s) -{ - grow((const void*)s, strlen(s), 0); - return finish(); -} - -inline void* Obstack::copy(char c) -{ - grow(c); - return finish(); -} - -inline void* Obstack::alloc(int size) -{ - blank(size); - return finish(); -} - -inline void Obstack:: free(void* obj) -{ - if (obj >= (void*)chunk && obj<(void*)chunklimit) - nextfree = objectbase = (char *) obj; - else - _free(obj); -} - -inline void Obstack:: grow_fast(char c) -{ - *(nextfree)++ = c; -} - -inline void Obstack:: blank_fast(int size) -{ - nextfree += size; -} - -inline void Obstack:: shrink(int size) // from ken@cs.rochester.edu -{ - if (nextfree >= objectbase + size) - nextfree -= size; -} - -#endif diff --git a/gnu/lib/libg++/include/Pix.h b/gnu/lib/libg++/include/Pix.h deleted file mode 100644 index be90525c6313..000000000000 --- a/gnu/lib/libg++/include/Pix.h +++ /dev/null @@ -1,5 +0,0 @@ - -#ifndef _Pix_h -#define _Pix_h 1 -typedef void* Pix; -#endif diff --git a/gnu/lib/libg++/include/PlotFile.h b/gnu/lib/libg++/include/PlotFile.h deleted file mode 100644 index 1a401cd57f1f..000000000000 --- a/gnu/lib/libg++/include/PlotFile.h +++ /dev/null @@ -1,121 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -/* - a very simple implementation of a class to output unix "plot" - format plotter files. See corresponding unix man pages for - more details. - - written by Doug Lea (dl@rocky.oswego.edu) - converted to use iostream library by Per Bothner (bothner@cygnus.com) -*/ - -#ifndef _PlotFile_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _PlotFile_h - -#include <fstream.h> - -/* - Some plot libraries have the `box' command to draw boxes. Some don't. - `box' is included here via moves & lines to allow both possiblilties. -*/ - - -class PlotFile : public ofstream -{ -protected: - PlotFile& cmd(char c); - PlotFile& operator << (const int x); - PlotFile& operator << (const char *s); - -public: - - PlotFile() : ofstream() { } - PlotFile(int fd) : ofstream(fd) { } - PlotFile(const char *name, int mode=ios::out, int prot=0664) - : ofstream(name, mode, prot) { } - -// PlotFile& remove() { ofstream::remove(); return *this; } - -// int filedesc() { return ofstream::filedesc(); } -// const char* name() { return File::name(); } -// void setname(const char* newname) { File::setname(newname); } -// int iocount() { return File::iocount(); } - - PlotFile& arc(const int xi, const int yi, - const int x0, const int y0, - const int x1, const int y1); - PlotFile& box(const int x0, const int y0, - const int x1, const int y1); - PlotFile& circle(const int x, const int y, const int r); - PlotFile& cont(const int xi, const int yi); - PlotFile& dot(const int xi, const int yi, const int dx, - int n, const int* pat); - PlotFile& erase(); - PlotFile& label(const char* s); - PlotFile& line(const int x0, const int y0, - const int x1, const int y1); - PlotFile& linemod(const char* s); - PlotFile& move(const int xi, const int yi); - PlotFile& point(const int xi, const int yi); - PlotFile& space(const int x0, const int y0, - const int x1, const int y1); -}; -#endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gnu/lib/libg++/include/Poisson.h b/gnu/lib/libg++/include/Poisson.h deleted file mode 100644 index 895b072fc9d4..000000000000 --- a/gnu/lib/libg++/include/Poisson.h +++ /dev/null @@ -1,51 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _Poisson_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Poisson_h - -#include <Random.h> - -class Poisson: public Random { -protected: - double pMean; -public: - Poisson(double mean, RNG *gen); - - double mean(); - double mean(double x); - - virtual double operator()(); -}; - - -inline Poisson::Poisson(double mean, RNG *gen) -: Random(gen) { - pMean = mean; -} - -inline double Poisson::mean() { return pMean; } -inline double Poisson::mean(double x) { - double t = pMean; - pMean = x; - return t; -} - -#endif diff --git a/gnu/lib/libg++/include/RNG.h b/gnu/lib/libg++/include/RNG.h deleted file mode 100644 index 81b5e16797aa..000000000000 --- a/gnu/lib/libg++/include/RNG.h +++ /dev/null @@ -1,58 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _RNG_h -#define _RNG_h 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include <assert.h> -#include <math.h> -#include <_G_config.h> - -union PrivateRNGSingleType { // used to access floats as unsigneds - float s; - _G_uint32_t u; -}; - -union PrivateRNGDoubleType { // used to access doubles as unsigneds - double d; - _G_uint32_t u[2]; -}; - -// -// Base class for Random Number Generators. See ACG and MLCG for instances. -// -class RNG { - static PrivateRNGSingleType singleMantissa; // mantissa bit vector - static PrivateRNGDoubleType doubleMantissa; // mantissa bit vector -public: - RNG(); - // - // Return a long-words word of random bits - // - virtual _G_uint32_t asLong() = 0; - virtual void reset() = 0; - // - // Return random bits converted to either a float or a double - // - float asFloat(); - double asDouble(); -}; - -#endif diff --git a/gnu/lib/libg++/include/Random.h b/gnu/lib/libg++/include/Random.h deleted file mode 100644 index e3e624acdf51..000000000000 --- a/gnu/lib/libg++/include/Random.h +++ /dev/null @@ -1,54 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _Random_h -#define _Random_h 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include <math.h> -#include <RNG.h> - -class Random { -protected: - RNG *pGenerator; -public: - Random(RNG *generator); - virtual double operator()() = 0; - - RNG *generator(); - void generator(RNG *p); -}; - - -inline Random::Random(RNG *gen) -{ - pGenerator = gen; -} - -inline RNG *Random::generator() -{ - return(pGenerator); -} - -inline void Random::generator(RNG *p) -{ - pGenerator = p; -} - -#endif diff --git a/gnu/lib/libg++/include/Rational.h b/gnu/lib/libg++/include/Rational.h deleted file mode 100644 index 1f8b76b57b03..000000000000 --- a/gnu/lib/libg++/include/Rational.h +++ /dev/null @@ -1,288 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _Rational_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Rational_h 1 - -#include <Integer.h> -#include <math.h> - -class Rational -{ -protected: - Integer num; - Integer den; - - void normalize(); - -public: - Rational(); - Rational(double); - Rational(int n); - Rational(long n); - Rational(int n, int d); - Rational(long n, long d); - Rational(long n, unsigned long d); - Rational(unsigned long n, long d); - Rational(unsigned long n, unsigned long d); - Rational(const Integer& n); - Rational(const Integer& n, const Integer& d); - Rational(const Rational&); - - ~Rational(); - - Rational& operator = (const Rational& y); - - friend int operator == (const Rational& x, const Rational& y); - friend int operator != (const Rational& x, const Rational& y); - friend int operator < (const Rational& x, const Rational& y); - friend int operator <= (const Rational& x, const Rational& y); - friend int operator > (const Rational& x, const Rational& y); - friend int operator >= (const Rational& x, const Rational& y); - - friend Rational operator + (const Rational& x, const Rational& y); - friend Rational operator - (const Rational& x, const Rational& y); - friend Rational operator * (const Rational& x, const Rational& y); - friend Rational operator / (const Rational& x, const Rational& y); - - Rational& operator += (const Rational& y); - Rational& operator -= (const Rational& y); - Rational& operator *= (const Rational& y); - Rational& operator /= (const Rational& y); - -#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) - friend Rational operator <? (const Rational& x, const Rational& y); // min - friend Rational operator >? (const Rational& x, const Rational& y); // max -#endif - - friend Rational operator - (const Rational& x); - - -// builtin Rational functions - - - void negate(); // x = -x - void invert(); // x = 1/x - - friend int sign(const Rational& x); // -1, 0, or +1 - friend Rational abs(const Rational& x); // absolute value - friend Rational sqr(const Rational& x); // square - friend Rational pow(const Rational& x, long y); - friend Rational pow(const Rational& x, const Integer& y); - const Integer& numerator() const; - const Integer& denominator() const; - -// coercion & conversion - - operator double() const; - friend Integer floor(const Rational& x); - friend Integer ceil(const Rational& x); - friend Integer trunc(const Rational& x); - friend Integer round(const Rational& x); - - friend istream& operator >> (istream& s, Rational& y); - friend ostream& operator << (ostream& s, const Rational& y); - - int fits_in_float() const; - int fits_in_double() const; - -// procedural versions of operators - - friend int compare(const Rational& x, const Rational& y); - friend void add(const Rational& x, const Rational& y, Rational& dest); - friend void sub(const Rational& x, const Rational& y, Rational& dest); - friend void mul(const Rational& x, const Rational& y, Rational& dest); - friend void div(const Rational& x, const Rational& y, Rational& dest); - -// error detection - - void error(const char* msg) const; - int OK() const; - -}; - -typedef Rational RatTmp; // backwards compatibility - -inline Rational::Rational() : num(&_ZeroRep), den(&_OneRep) {} -inline Rational::~Rational() {} - -inline Rational::Rational(const Rational& y) :num(y.num), den(y.den) {} - -inline Rational::Rational(const Integer& n) :num(n), den(&_OneRep) {} - -inline Rational::Rational(const Integer& n, const Integer& d) :num(n),den(d) -{ - normalize(); -} - -inline Rational::Rational(long n) :num(n), den(&_OneRep) { } - -inline Rational::Rational(int n) :num(n), den(&_OneRep) { } - -inline Rational::Rational(long n, long d) :num(n), den(d) { normalize(); } -inline Rational::Rational(int n, int d) :num(n), den(d) { normalize(); } -inline Rational::Rational(long n, unsigned long d) :num(n), den(d) -{ - normalize(); -} -inline Rational::Rational(unsigned long n, long d) :num(n), den(d) -{ - normalize(); -} -inline Rational::Rational(unsigned long n, unsigned long d) :num(n), den(d) -{ - normalize(); -} - -inline Rational& Rational::operator = (const Rational& y) -{ - num = y.num; den = y.den; - return *this; -} - -inline int operator == (const Rational& x, const Rational& y) -{ - return compare(x.num, y.num) == 0 && compare(x.den, y.den) == 0; -} - -inline int operator != (const Rational& x, const Rational& y) -{ - return compare(x.num, y.num) != 0 || compare(x.den, y.den) != 0; -} - -inline int operator < (const Rational& x, const Rational& y) -{ - return compare(x, y) < 0; -} - -inline int operator <= (const Rational& x, const Rational& y) -{ - return compare(x, y) <= 0; -} - -inline int operator > (const Rational& x, const Rational& y) -{ - return compare(x, y) > 0; -} - -inline int operator >= (const Rational& x, const Rational& y) -{ - return compare(x, y) >= 0; -} - -inline int sign(const Rational& x) -{ - return sign(x.num); -} - -inline void Rational::negate() -{ - num.negate(); -} - - -inline Rational& Rational::operator += (const Rational& y) -{ - add(*this, y, *this); - return *this; -} - -inline Rational& Rational::operator -= (const Rational& y) -{ - sub(*this, y, *this); - return *this; -} - -inline Rational& Rational::operator *= (const Rational& y) -{ - mul(*this, y, *this); - return *this; -} - -inline Rational& Rational::operator /= (const Rational& y) -{ - div(*this, y, *this); - return *this; -} - -inline const Integer& Rational::numerator() const { return num; } -inline const Integer& Rational::denominator() const { return den; } -inline Rational::operator double() const { return ratio(num, den); } - -#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) -inline Rational operator <? (const Rational& x, const Rational& y) -{ - if (compare(x, y) <= 0) return x; else return y; -} - -inline Rational operator >? (const Rational& x, const Rational& y) -{ - if (compare(x, y) >= 0) return x; else return y; -} -#endif - -#if defined(__GNUG__) && !defined(_G_NO_NRV) - -inline Rational operator + (const Rational& x, const Rational& y) return r -{ - add(x, y, r); -} - -inline Rational operator - (const Rational& x, const Rational& y) return r -{ - sub(x, y, r); -} - -inline Rational operator * (const Rational& x, const Rational& y) return r -{ - mul(x, y, r); -} - -inline Rational operator / (const Rational& x, const Rational& y) return r -{ - div(x, y, r); -} - -#else /* NO_NRV */ - -inline Rational operator + (const Rational& x, const Rational& y) -{ - Rational r; add(x, y, r); return r; -} - -inline Rational operator - (const Rational& x, const Rational& y) -{ - Rational r; sub(x, y, r); return r; -} - -inline Rational operator * (const Rational& x, const Rational& y) -{ - Rational r; mul(x, y, r); return r; -} - -inline Rational operator / (const Rational& x, const Rational& y) -{ - Rational r; div(x, y, r); return r; -} -#endif - -#endif diff --git a/gnu/lib/libg++/include/Regex.h b/gnu/lib/libg++/include/Regex.h deleted file mode 100644 index adc1cea1354d..000000000000 --- a/gnu/lib/libg++/include/Regex.h +++ /dev/null @@ -1,76 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -#ifndef _Regex_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Regex_h 1 - -#if defined(SHORT_NAMES) || defined(VMS) -#define re_compile_pattern recmppat -#define re_pattern_buffer repatbuf -#define re_registers reregs -#endif - -struct re_pattern_buffer; // defined elsewhere -struct re_registers; - -class Regex -{ -private: - - Regex(const Regex&) {} // no X(X&) - void operator = (const Regex&) {} // no assignment - -protected: - re_pattern_buffer* buf; - re_registers* reg; - -public: - Regex(const char* t, - int fast = 0, - int bufsize = 40, - const char* transtable = 0); - - ~Regex(); - - int match(const char* s, int len, int pos = 0) const; - int search(const char* s, int len, - int& matchlen, int startpos = 0) const; - int match_info(int& start, int& length, int nth = 0) const; - - int OK() const; // representation invariant -}; - -// some built in regular expressions - -extern const Regex RXwhite; // = "[ \n\t\r\v\f]+" -extern const Regex RXint; // = "-?[0-9]+" -extern const Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\| - // \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\) - // \\([eE][---+]?[0-9]+\\)?" -extern const Regex RXalpha; // = "[A-Za-z]+" -extern const Regex RXlowercase; // = "[a-z]+" -extern const Regex RXuppercase; // = "[A-Z]+" -extern const Regex RXalphanum; // = "[0-9A-Za-z]+" -extern const Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*" - - -#endif diff --git a/gnu/lib/libg++/include/RndInt.h b/gnu/lib/libg++/include/RndInt.h deleted file mode 100644 index bf0f955db21d..000000000000 --- a/gnu/lib/libg++/include/RndInt.h +++ /dev/null @@ -1,175 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1990 Free Software Foundation - adapted from a submission from John Reidl <riedl@cs.purdue.edu> - - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU CC General Public -License for full details. - -Everyone is granted permission to copy, modify and redistribute -GNU CC, but only under the conditions described in the -GNU CC General Public License. A copy of this license is -supposed to have been given to you along with GNU CC so you -can know your rights and responsibilities. It should be in a -file named COPYING. Among other things, the copyright notice -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _RandomInteger_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _RandomInteger_h 1 - -// RandomInteger uses a random number generator to generate an integer -// in a specified range. By default the range is 0..1. Since in my -// experience random numbers are often needed for a wide variety of -// ranges in the same program, this generator accepts a new low or high value -// as an argument to the asLong and operator() methods to temporarily -// override stored values - -#include <math.h> -#include <RNG.h> - -class RandomInteger -{ - protected: - RNG *pGenerator; - long pLow; - long pHigh; - - long _asLong(long, long); - - public: - - RandomInteger(long low, long high, RNG *gen); - RandomInteger(long high, RNG *gen); - RandomInteger(RNG *gen); - -// read params - - long low() const; - long high() const; - RNG* generator() const; - -// change params - - long low(long x); - long high(long x); - RNG* generator(RNG *gen); - -// get a random number - - long asLong(); - long operator()(); // synonym for asLong - int asInt(); // (possibly) truncate as int - -// override params for one shot - - long asLong(long high); - long asLong(long low, long high); - - long operator () (long high); // synonyms - long operator () (long low, long high); - -}; - - -inline RandomInteger::RandomInteger(long low, long high, RNG *gen) - : pLow((low < high) ? low : high), - pHigh((low < high) ? high : low), - pGenerator(gen) -{} - -inline RandomInteger::RandomInteger(long high, RNG *gen) - : pLow((0 < high) ? 0 : high), - pHigh((0 < high) ? high : 0), - pGenerator(gen) -{} - - -inline RandomInteger::RandomInteger(RNG *gen) - : pLow(0), - pHigh(1), - pGenerator(gen) -{} - -inline RNG* RandomInteger::generator() const { return pGenerator;} -inline long RandomInteger::low() const { return pLow; } -inline long RandomInteger::high() const { return pHigh; } - -inline RNG* RandomInteger::generator(RNG *gen) -{ - RNG *tmp = pGenerator; pGenerator = gen; return tmp; -} - -inline long RandomInteger::low(long x) -{ - long tmp = pLow; pLow = x; return tmp; -} - -inline long RandomInteger:: high(long x) -{ - long tmp = pHigh; pHigh = x; return tmp; -} - -inline long RandomInteger:: _asLong(long low, long high) -{ - return (pGenerator->asLong() % (high-low+1)) + low; -} - - -inline long RandomInteger:: asLong() -{ - return _asLong(pLow, pHigh); -} - -inline long RandomInteger:: asLong(long high) -{ - return _asLong(pLow, high); -} - -inline long RandomInteger:: asLong(long low, long high) -{ - return _asLong(low, high); -} - -inline long RandomInteger:: operator () () -{ - return _asLong(pLow, pHigh); -} - -inline long RandomInteger:: operator () (long high) -{ - return _asLong(pLow, high); -} - -inline long RandomInteger:: operator () (long low, long high) -{ - return _asLong(low, high); -} - - - - -inline int RandomInteger:: asInt() -{ - return int(asLong()); -} - -#endif diff --git a/gnu/lib/libg++/include/SFile.h b/gnu/lib/libg++/include/SFile.h deleted file mode 100644 index d4b4c71fd20a..000000000000 --- a/gnu/lib/libg++/include/SFile.h +++ /dev/null @@ -1,53 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1988, 1992, 1993 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#ifndef _SFile_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _SFile_h 1 - -#include <fstream.h> - -class SFile: public fstream -{ - protected: - int sz; // unit size for structured binary IO - -public: - SFile() : fstream() { } - SFile(int fd, int size); - SFile(const char *name, int size, int mode, int prot=0664); - void open(const char *name, int size, int mode, int prot=0664); - - int size() { return sz; } - int setsize(int s) { int old = sz; sz = s; return old; } - - SFile& get(void* x); - SFile& put(void* x); - SFile& operator[](long i); -}; - -#endif diff --git a/gnu/lib/libg++/include/SLList.h b/gnu/lib/libg++/include/SLList.h deleted file mode 100644 index 4be457fd3524..000000000000 --- a/gnu/lib/libg++/include/SLList.h +++ /dev/null @@ -1,124 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _SLList_h -#ifdef __GNUG__ -//#pragma interface -#endif -#define _SLList_h 1 - -#include <Pix.h> - -struct BaseSLNode -{ - BaseSLNode *tl; - void *item() {return (void*)(this+1);} // Return ((SLNode<T>*)this)->hd -}; - -template<class T> -class SLNode : public BaseSLNode -{ - public: - T hd; // Data part of node - SLNode() { } - SLNode(const T& h, SLNode* t = 0) - : hd(h) { tl = t; } - ~SLNode() { } -}; - -extern int __SLListLength(BaseSLNode *ptr); - -class BaseSLList { - protected: - BaseSLNode *last; - virtual void delete_node(BaseSLNode*node) = 0; - virtual BaseSLNode* copy_node(const void* datum) = 0; - virtual void copy_item(void *dst, void *src) = 0; - virtual ~BaseSLList() { } - BaseSLList() { last = 0; } - void copy(const BaseSLList&); - BaseSLList& operator = (const BaseSLList& a); - Pix ins_after(Pix p, const void *datum); - Pix prepend(const void *datum); - Pix append(const void *datum); - int remove_front(void *dst, int signal_error = 0); - void join(BaseSLList&); - public: - int length() const; - int empty() const { return last == 0; } - void clear(); - Pix prepend(BaseSLNode*); - Pix append(BaseSLNode*); - int OK() const; - void error(const char* msg) const; - void del_after(Pix p); - int owns(Pix p) const; - void del_front(); -}; - -template <class T> -class SLList : public BaseSLList -{ - private: - virtual void delete_node(BaseSLNode *node) { delete (SLNode<T>*)node; } - virtual BaseSLNode* copy_node(const void *datum) - { return new SLNode<T>(*(const T*)datum); } - virtual void copy_item(void *dst, void *src) { *(T*)dst = *(T*)src; } - -public: - SLList() : BaseSLList() { } - SLList(const SLList<T>& a) : BaseSLList() { copy(a); } - SLList<T>& operator = (const SLList<T>& a) - { BaseSLList::operator=((const BaseSLList&) a); return *this; } - virtual ~SLList() { clear(); } - - Pix prepend(const T& item) {return BaseSLList::prepend(&item);} - Pix append(const T& item) {return BaseSLList::append(&item);} - Pix prepend(SLNode<T>* node) {return BaseSLList::prepend(node);} - Pix append(SLNode<T>* node) {return BaseSLList::append(node);} - - T& operator () (Pix p) { - if (p == 0) error("null Pix"); - return ((SLNode<T>*)(p))->hd; } - const T& operator () (Pix p) const { - if (p == 0) error("null Pix"); - return ((SLNode<T>*)(p))->hd; } - inline Pix first() const { return (last == 0) ? 0 : Pix(last->tl); } - void next(Pix& p) const - { p = (p == 0 || p == last) ? 0 : Pix(((SLNode<T>*)(p))->tl); } - Pix ins_after(Pix p, const T& item) - { return BaseSLList::ins_after(p, &item); } - void join(SLList<T>& a) { BaseSLList::join(a); } - - T& front() { - if (last == 0) error("front: empty list"); - return ((SLNode<T>*)last->tl)->hd; } - T& rear() { - if (last == 0) error("rear: empty list"); - return ((SLNode<T>*)last)->hd; } - const T& front() const { - if (last == 0) error("front: empty list"); - return ((SLNode<T>*)last->tl)->hd; } - const T& rear() const { - if (last == 0) error("rear: empty list"); - return ((SLNode<T>*)last)->hd; } - int remove_front(T& x) { return BaseSLList::remove_front(&x); } - T remove_front() { T dst; BaseSLList::remove_front(&dst, 1); return dst; } -}; - -#endif diff --git a/gnu/lib/libg++/include/SmplHist.h b/gnu/lib/libg++/include/SmplHist.h deleted file mode 100644 index 54614b99bd90..000000000000 --- a/gnu/lib/libg++/include/SmplHist.h +++ /dev/null @@ -1,72 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef SampleHistogram_h -#ifdef __GNUG__ -#pragma interface -#endif -#define SampleHistogram_h 1 - -#include <iostream.h> -#include <SmplStat.h> - -extern const int SampleHistogramMinimum; -extern const int SampleHistogramMaximum; - -class SampleHistogram : public SampleStatistic -{ -protected: - short howManyBuckets; - int *bucketCount; - double *bucketLimit; - -public: - - SampleHistogram(double low, double hi, double bucketWidth = -1.0); - - ~SampleHistogram(); - - virtual void reset(); - virtual void operator+=(double); - - int similarSamples(double); - - int buckets(); - - double bucketThreshold(int i); - int inBucket(int i); - void printBuckets(ostream&); - -}; - - -inline int SampleHistogram:: buckets() { return(howManyBuckets); }; - -inline double SampleHistogram:: bucketThreshold(int i) { - if (i < 0 || i >= howManyBuckets) - error("invalid bucket access"); - return(bucketLimit[i]); -} - -inline int SampleHistogram:: inBucket(int i) { - if (i < 0 || i >= howManyBuckets) - error("invalid bucket access"); - return(bucketCount[i]); -} - -#endif diff --git a/gnu/lib/libg++/include/SmplStat.h b/gnu/lib/libg++/include/SmplStat.h deleted file mode 100644 index 2ed5ab984c0b..000000000000 --- a/gnu/lib/libg++/include/SmplStat.h +++ /dev/null @@ -1,66 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef SampleStatistic_h -#ifdef __GNUG__ -#pragma interface -#endif -#define SampleStatistic_h 1 - -#include <builtin.h> - -class SampleStatistic { -protected: - int n; - double x; - double x2; - double minValue, maxValue; - - public : - - SampleStatistic(); - virtual ~SampleStatistic(); - virtual void reset(); - - virtual void operator+=(double); - int samples(); - double mean(); - double stdDev(); - double var(); - double min(); - double max(); - double confidence(int p_percentage); - double confidence(double p_value); - - void error(const char* msg); -}; - -// error handlers - -extern void default_SampleStatistic_error_handler(const char*); -extern one_arg_error_handler_t SampleStatistic_error_handler; - -extern one_arg_error_handler_t - set_SampleStatistic_error_handler(one_arg_error_handler_t f); - -inline SampleStatistic:: SampleStatistic(){ reset();} -inline int SampleStatistic:: samples() {return(n);} -inline double SampleStatistic:: min() {return(minValue);} -inline double SampleStatistic:: max() {return(maxValue);} -inline SampleStatistic::~SampleStatistic() {} - -#endif diff --git a/gnu/lib/libg++/include/String.h b/gnu/lib/libg++/include/String.h deleted file mode 100644 index 7a3d82b5bb19..000000000000 --- a/gnu/lib/libg++/include/String.h +++ /dev/null @@ -1,1282 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -#ifndef _String_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _String_h 1 - -#include <iostream.h> -#include <Regex.h> - -struct StrRep // internal String representations -{ - unsigned short len; // string length - unsigned short sz; // allocated space - char s[1]; // the string starts here - // (at least 1 char for trailing null) - // allocated & expanded via non-public fcts -}; - -// primitive ops on StrReps -- nearly all String fns go through these. - -StrRep* Salloc(StrRep*, const char*, int, int); -StrRep* Scopy(StrRep*, const StrRep*); -StrRep* Scat(StrRep*, const char*, int, const char*, int); -StrRep* Scat(StrRep*, const char*, int,const char*,int, const char*,int); -StrRep* Sprepend(StrRep*, const char*, int); -StrRep* Sreverse(const StrRep*, StrRep*); -StrRep* Supcase(const StrRep*, StrRep*); -StrRep* Sdowncase(const StrRep*, StrRep*); -StrRep* Scapitalize(const StrRep*, StrRep*); - -// These classes need to be defined in the order given - -class String; -class SubString; - -class SubString -{ - friend class String; -protected: - - String& S; // The String I'm a substring of - unsigned short pos; // starting position in S's rep - unsigned short len; // length of substring - - void assign(const StrRep*, const char*, int = -1); - SubString(String& x, int p, int l); - SubString(const SubString& x); - -public: - -// Note there are no public constructors. SubStrings are always -// created via String operations - - ~SubString(); - - SubString& operator = (const String& y); - SubString& operator = (const SubString& y); - SubString& operator = (const char* t); - SubString& operator = (char c); - -// return 1 if target appears anywhere in SubString; else 0 - - int contains(char c) const; - int contains(const String& y) const; - int contains(const SubString& y) const; - int contains(const char* t) const; - int contains(const Regex& r) const; - -// return 1 if target matches entire SubString - - int matches(const Regex& r) const; - -// IO - - friend ostream& operator<<(ostream& s, const SubString& x); - -// status - - unsigned int length() const; - int empty() const; - const char* chars() const; - - int OK() const; - -}; - - -class String -{ - friend class SubString; - -protected: - StrRep* rep; // Strings are pointers to their representations - -// some helper functions - - int search(int, int, const char*, int = -1) const; - int search(int, int, char) const; - int match(int, int, int, const char*, int = -1) const; - int _gsub(const char*, int, const char* ,int); - int _gsub(const Regex&, const char*, int); - SubString _substr(int, int); - -public: - -// constructors & assignment - - String(); - String(const String& x); - String(const SubString& x); - String(const char* t); - String(const char* t, int len); - String(char c); - - ~String(); - - String& operator = (const String& y); - String& operator = (const char* y); - String& operator = (char c); - String& operator = (const SubString& y); - -// concatenation - - String& operator += (const String& y); - String& operator += (const SubString& y); - String& operator += (const char* t); - String& operator += (char c); - - void prepend(const String& y); - void prepend(const SubString& y); - void prepend(const char* t); - void prepend(char c); - - -// procedural versions: -// concatenate first 2 args, store result in last arg - - friend inline void cat(const String&, const String&, String&); - friend inline void cat(const String&, const SubString&, String&); - friend inline void cat(const String&, const char*, String&); - friend inline void cat(const String&, char, String&); - - friend inline void cat(const SubString&, const String&, String&); - friend inline void cat(const SubString&, const SubString&, String&); - friend inline void cat(const SubString&, const char*, String&); - friend inline void cat(const SubString&, char, String&); - - friend inline void cat(const char*, const String&, String&); - friend inline void cat(const char*, const SubString&, String&); - friend inline void cat(const char*, const char*, String&); - friend inline void cat(const char*, char, String&); - -// double concatenation, by request. (yes, there are too many versions, -// but if one is supported, then the others should be too...) -// Concatenate first 3 args, store in last arg - - friend inline void cat(const String&,const String&, const String&,String&); - friend inline void cat(const String&,const String&,const SubString&,String&); - friend inline void cat(const String&,const String&, const char*, String&); - friend inline void cat(const String&,const String&, char, String&); - friend inline void cat(const String&,const SubString&,const String&,String&); - inline friend void cat(const String&,const SubString&,const SubString&,String&); - friend inline void cat(const String&,const SubString&, const char*, String&); - friend inline void cat(const String&,const SubString&, char, String&); - friend inline void cat(const String&,const char*, const String&, String&); - friend inline void cat(const String&,const char*, const SubString&, String&); - friend inline void cat(const String&,const char*, const char*, String&); - friend inline void cat(const String&,const char*, char, String&); - - friend inline void cat(const char*, const String&, const String&,String&); - friend inline void cat(const char*,const String&,const SubString&,String&); - friend inline void cat(const char*,const String&, const char*, String&); - friend inline void cat(const char*,const String&, char, String&); - friend inline void cat(const char*,const SubString&,const String&,String&); - friend inline void cat(const char*,const SubString&,const SubString&,String&); - friend inline void cat(const char*,const SubString&, const char*, String&); - friend inline void cat(const char*,const SubString&, char, String&); - friend inline void cat(const char*,const char*, const String&, String&); - friend inline void cat(const char*,const char*, const SubString&, String&); - friend inline void cat(const char*,const char*, const char*, String&); - friend inline void cat(const char*,const char*, char, String&); - - -// searching & matching - -// return position of target in string or -1 for failure - - int index(char c, int startpos = 0) const; - int index(const String& y, int startpos = 0) const; - int index(const SubString& y, int startpos = 0) const; - int index(const char* t, int startpos = 0) const; - int index(const Regex& r, int startpos = 0) const; - -// return 1 if target appears anyhere in String; else 0 - - int contains(char c) const; - int contains(const String& y) const; - int contains(const SubString& y) const; - int contains(const char* t) const; - int contains(const Regex& r) const; - -// return 1 if target appears anywhere after position pos -// (or before, if pos is negative) in String; else 0 - - int contains(char c, int pos) const; - int contains(const String& y, int pos) const; - int contains(const SubString& y, int pos) const; - int contains(const char* t, int pos) const; - int contains(const Regex& r, int pos) const; - -// return 1 if target appears at position pos in String; else 0 - - int matches(char c, int pos = 0) const; - int matches(const String& y, int pos = 0) const; - int matches(const SubString& y, int pos = 0) const; - int matches(const char* t, int pos = 0) const; - int matches(const Regex& r, int pos = 0) const; - -// return number of occurences of target in String - - int freq(char c) const; - int freq(const String& y) const; - int freq(const SubString& y) const; - int freq(const char* t) const; - -// SubString extraction - -// Note that you can't take a substring of a const String, since -// this leaves open the possiblility of indirectly modifying the -// String through the SubString - - SubString at(int pos, int len); - SubString operator () (int pos, int len); // synonym for at - - SubString at(const String& x, int startpos = 0); - SubString at(const SubString& x, int startpos = 0); - SubString at(const char* t, int startpos = 0); - SubString at(char c, int startpos = 0); - SubString at(const Regex& r, int startpos = 0); - - SubString before(int pos); - SubString before(const String& x, int startpos = 0); - SubString before(const SubString& x, int startpos = 0); - SubString before(const char* t, int startpos = 0); - SubString before(char c, int startpos = 0); - SubString before(const Regex& r, int startpos = 0); - - SubString through(int pos); - SubString through(const String& x, int startpos = 0); - SubString through(const SubString& x, int startpos = 0); - SubString through(const char* t, int startpos = 0); - SubString through(char c, int startpos = 0); - SubString through(const Regex& r, int startpos = 0); - - SubString from(int pos); - SubString from(const String& x, int startpos = 0); - SubString from(const SubString& x, int startpos = 0); - SubString from(const char* t, int startpos = 0); - SubString from(char c, int startpos = 0); - SubString from(const Regex& r, int startpos = 0); - - SubString after(int pos); - SubString after(const String& x, int startpos = 0); - SubString after(const SubString& x, int startpos = 0); - SubString after(const char* t, int startpos = 0); - SubString after(char c, int startpos = 0); - SubString after(const Regex& r, int startpos = 0); - - -// deletion - -// delete len chars starting at pos - void del(int pos, int len); - -// delete the first occurrence of target after startpos - - void del(const String& y, int startpos = 0); - void del(const SubString& y, int startpos = 0); - void del(const char* t, int startpos = 0); - void del(char c, int startpos = 0); - void del(const Regex& r, int startpos = 0); - -// global substitution: substitute all occurrences of pat with repl - - int gsub(const String& pat, const String& repl); - int gsub(const SubString& pat, const String& repl); - int gsub(const char* pat, const String& repl); - int gsub(const char* pat, const char* repl); - int gsub(const Regex& pat, const String& repl); - -// friends & utilities - -// split string into array res at separators; return number of elements - - friend int split(const String& x, String res[], int maxn, - const String& sep); - friend int split(const String& x, String res[], int maxn, - const Regex& sep); - - friend String common_prefix(const String& x, const String& y, - int startpos = 0); - friend String common_suffix(const String& x, const String& y, - int startpos = -1); - friend String replicate(char c, int n); - friend String replicate(const String& y, int n); - friend String join(String src[], int n, const String& sep); - -// simple builtin transformations - - friend inline String reverse(const String& x); - friend inline String upcase(const String& x); - friend inline String downcase(const String& x); - friend inline String capitalize(const String& x); - -// in-place versions of above - - void reverse(); - void upcase(); - void downcase(); - void capitalize(); - -// element extraction - - char& operator [] (int i); - const char& operator [] (int i) const; - char elem(int i) const; - char firstchar() const; - char lastchar() const; - -// conversion - - operator const char*() const; - const char* chars() const; - - -// IO - - friend inline ostream& operator<<(ostream& s, const String& x); - friend ostream& operator<<(ostream& s, const SubString& x); - friend istream& operator>>(istream& s, String& x); - - friend int readline(istream& s, String& x, - char terminator = '\n', - int discard_terminator = 1); - -// status - - unsigned int length() const; - int empty() const; - -// preallocate some space for String - void alloc(int newsize); - -// report current allocation (not length!) - - int allocation() const; - - - void error(const char* msg) const; - - int OK() const; -}; - -typedef String StrTmp; // for backward compatibility - -// other externs - -int compare(const String& x, const String& y); -int compare(const String& x, const SubString& y); -int compare(const String& x, const char* y); -int compare(const SubString& x, const String& y); -int compare(const SubString& x, const SubString& y); -int compare(const SubString& x, const char* y); -int fcompare(const String& x, const String& y); // ignore case - -extern StrRep _nilStrRep; -extern String _nilString; - -// status reports, needed before defining other things - -inline unsigned int String::length() const { return rep->len; } -inline int String::empty() const { return rep->len == 0; } -inline const char* String::chars() const { return &(rep->s[0]); } -inline int String::allocation() const { return rep->sz; } - -inline unsigned int SubString::length() const { return len; } -inline int SubString::empty() const { return len == 0; } -inline const char* SubString::chars() const { return &(S.rep->s[pos]); } - - -// constructors - -inline String::String() - : rep(&_nilStrRep) {} -inline String::String(const String& x) - : rep(Scopy(0, x.rep)) {} -inline String::String(const char* t) - : rep(Salloc(0, t, -1, -1)) {} -inline String::String(const char* t, int tlen) - : rep(Salloc(0, t, tlen, tlen)) {} -inline String::String(const SubString& y) - : rep(Salloc(0, y.chars(), y.length(), y.length())) {} -inline String::String(char c) - : rep(Salloc(0, &c, 1, 1)) {} - -inline String::~String() { if (rep != &_nilStrRep) delete rep; } - -inline SubString::SubString(const SubString& x) - :S(x.S), pos(x.pos), len(x.len) {} -inline SubString::SubString(String& x, int first, int l) - :S(x), pos(first), len(l) {} - -inline SubString::~SubString() {} - -// assignment - -inline String& String::operator = (const String& y) -{ - rep = Scopy(rep, y.rep); - return *this; -} - -inline String& String::operator=(const char* t) -{ - rep = Salloc(rep, t, -1, -1); - return *this; -} - -inline String& String::operator=(const SubString& y) -{ - rep = Salloc(rep, y.chars(), y.length(), y.length()); - return *this; -} - -inline String& String::operator=(char c) -{ - rep = Salloc(rep, &c, 1, 1); - return *this; -} - - -inline SubString& SubString::operator = (const char* ys) -{ - assign(0, ys); - return *this; -} - -inline SubString& SubString::operator = (char ch) -{ - assign(0, &ch, 1); - return *this; -} - -inline SubString& SubString::operator = (const String& y) -{ - assign(y.rep, y.chars(), y.length()); - return *this; -} - -inline SubString& SubString::operator = (const SubString& y) -{ - assign(y.S.rep, y.chars(), y.length()); - return *this; -} - -// Zillions of cats... - -inline void cat(const String& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); -} - -inline void cat(const String& x, char y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); -} - -inline void cat(const SubString& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const SubString& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const SubString& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); -} - -inline void cat(const SubString& x, char y, String& r) -{ - r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); -} - -inline void cat(const char* x, const String& y, String& r) -{ - r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); -} - -inline void cat(const char* x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); -} - -inline void cat(const char* x, const char* y, String& r) -{ - r.rep = Scat(r.rep, x, -1, y, -1); -} - -inline void cat(const char* x, char y, String& r) -{ - r.rep = Scat(r.rep, x, -1, &y, 1); -} - -inline void cat(const String& a, const String& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& a, const String& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& a, const String& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); -} - -inline void cat(const String& a, const String& x, char y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); -} - -inline void cat(const String& a, const SubString& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& a, const SubString& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const String& a, const SubString& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); -} - -inline void cat(const String& a, const SubString& x, char y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); -} - -inline void cat(const String& a, const char* x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); -} - -inline void cat(const String& a, const char* x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); -} - -inline void cat(const String& a, const char* x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1); -} - -inline void cat(const String& a, const char* x, char y, String& r) -{ - r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1); -} - - -inline void cat(const char* a, const String& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const char* a, const String& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const char* a, const String& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); -} - -inline void cat(const char* a, const String& x, char y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); -} - -inline void cat(const char* a, const SubString& x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const char* a, const SubString& x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); -} - -inline void cat(const char* a, const SubString& x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); -} - -inline void cat(const char* a, const SubString& x, char y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); -} - -inline void cat(const char* a, const char* x, const String& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); -} - -inline void cat(const char* a, const char* x, const SubString& y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); -} - -inline void cat(const char* a, const char* x, const char* y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x, -1, y, -1); -} - -inline void cat(const char* a, const char* x, char y, String& r) -{ - r.rep = Scat(r.rep, a, -1, x, -1, &y, 1); -} - - -// operator versions - -inline String& String::operator +=(const String& y) -{ - cat(*this, y, *this); - return *this; -} - -inline String& String::operator +=(const SubString& y) -{ - cat(*this, y, *this); - return *this; -} - -inline String& String::operator += (const char* y) -{ - cat(*this, y, *this); - return *this; -} - -inline String& String:: operator +=(char y) -{ - cat(*this, y, *this); - return *this; -} - -// constructive concatenation - -#if defined(__GNUG__) && !defined(_G_NO_NRV) - -inline String operator + (const String& x, const String& y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const String& x, const SubString& y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const String& x, const char* y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const String& x, char y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const SubString& x, const String& y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const SubString& x, const SubString& y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const SubString& x, const char* y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const SubString& x, char y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const char* x, const String& y) return r; -{ - cat(x, y, r); -} - -inline String operator + (const char* x, const SubString& y) return r; -{ - cat(x, y, r); -} - -inline String reverse(const String& x) return r; -{ - r.rep = Sreverse(x.rep, r.rep); -} - -inline String upcase(const String& x) return r; -{ - r.rep = Supcase(x.rep, r.rep); -} - -inline String downcase(const String& x) return r; -{ - r.rep = Sdowncase(x.rep, r.rep); -} - -inline String capitalize(const String& x) return r; -{ - r.rep = Scapitalize(x.rep, r.rep); -} - -#else /* NO_NRV */ - -inline String operator + (const String& x, const String& y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const String& x, const SubString& y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const String& x, const char* y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const String& x, char y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const SubString& x, const String& y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const SubString& x, const SubString& y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const SubString& x, const char* y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const SubString& x, char y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const char* x, const String& y) -{ - String r; cat(x, y, r); return r; -} - -inline String operator + (const char* x, const SubString& y) -{ - String r; cat(x, y, r); return r; -} - -inline String reverse(const String& x) -{ - String r; r.rep = Sreverse(x.rep, r.rep); return r; -} - -inline String upcase(const String& x) -{ - String r; r.rep = Supcase(x.rep, r.rep); return r; -} - -inline String downcase(const String& x) -{ - String r; r.rep = Sdowncase(x.rep, r.rep); return r; -} - -inline String capitalize(const String& x) -{ - String r; r.rep = Scapitalize(x.rep, r.rep); return r; -} - -#endif - -// prepend - -inline void String::prepend(const String& y) -{ - rep = Sprepend(rep, y.chars(), y.length()); -} - -inline void String::prepend(const char* y) -{ - rep = Sprepend(rep, y, -1); -} - -inline void String::prepend(char y) -{ - rep = Sprepend(rep, &y, 1); -} - -inline void String::prepend(const SubString& y) -{ - rep = Sprepend(rep, y.chars(), y.length()); -} - -// misc transformations - - -inline void String::reverse() -{ - rep = Sreverse(rep, rep); -} - - -inline void String::upcase() -{ - rep = Supcase(rep, rep); -} - - -inline void String::downcase() -{ - rep = Sdowncase(rep, rep); -} - - -inline void String::capitalize() -{ - rep = Scapitalize(rep, rep); -} - -// element extraction - -inline char& String::operator [] (int i) -{ - if (((unsigned)i) >= length()) error("invalid index"); - return rep->s[i]; -} - -inline const char& String::operator [] (int i) const -{ - if (((unsigned)i) >= length()) error("invalid index"); - return rep->s[i]; -} - -inline char String::elem (int i) const -{ - if (((unsigned)i) >= length()) error("invalid index"); - return rep->s[i]; -} - -inline char String::firstchar() const -{ - return elem(0); -} - -inline char String::lastchar() const -{ - return elem(length() - 1); -} - -// searching - -inline int String::index(char c, int startpos) const -{ - return search(startpos, length(), c); -} - -inline int String::index(const char* t, int startpos) const -{ - return search(startpos, length(), t); -} - -inline int String::index(const String& y, int startpos) const -{ - return search(startpos, length(), y.chars(), y.length()); -} - -inline int String::index(const SubString& y, int startpos) const -{ - return search(startpos, length(), y.chars(), y.length()); -} - -inline int String::index(const Regex& r, int startpos) const -{ - int unused; return r.search(chars(), length(), unused, startpos); -} - -inline int String::contains(char c) const -{ - return search(0, length(), c) >= 0; -} - -inline int String::contains(const char* t) const -{ - return search(0, length(), t) >= 0; -} - -inline int String::contains(const String& y) const -{ - return search(0, length(), y.chars(), y.length()) >= 0; -} - -inline int String::contains(const SubString& y) const -{ - return search(0, length(), y.chars(), y.length()) >= 0; -} - -inline int String::contains(char c, int p) const -{ - return match(p, length(), 0, &c, 1) >= 0; -} - -inline int String::contains(const char* t, int p) const -{ - return match(p, length(), 0, t) >= 0; -} - -inline int String::contains(const String& y, int p) const -{ - return match(p, length(), 0, y.chars(), y.length()) >= 0; -} - -inline int String::contains(const SubString& y, int p) const -{ - return match(p, length(), 0, y.chars(), y.length()) >= 0; -} - -inline int String::contains(const Regex& r) const -{ - int unused; return r.search(chars(), length(), unused, 0) >= 0; -} - -inline int String::contains(const Regex& r, int p) const -{ - return r.match(chars(), length(), p) >= 0; -} - - -inline int String::matches(const SubString& y, int p) const -{ - return match(p, length(), 1, y.chars(), y.length()) >= 0; -} - -inline int String::matches(const String& y, int p) const -{ - return match(p, length(), 1, y.chars(), y.length()) >= 0; -} - -inline int String::matches(const char* t, int p) const -{ - return match(p, length(), 1, t) >= 0; -} - -inline int String::matches(char c, int p) const -{ - return match(p, length(), 1, &c, 1) >= 0; -} - -inline int String::matches(const Regex& r, int p) const -{ - int l = (p < 0)? -p : length() - p; - return r.match(chars(), length(), p) == l; -} - - -inline int SubString::contains(const char* t) const -{ - return S.search(pos, pos+len, t) >= 0; -} - -inline int SubString::contains(const String& y) const -{ - return S.search(pos, pos+len, y.chars(), y.length()) >= 0; -} - -inline int SubString::contains(const SubString& y) const -{ - return S.search(pos, pos+len, y.chars(), y.length()) >= 0; -} - -inline int SubString::contains(char c) const -{ - return S.search(pos, pos+len, c) >= 0; -} - -inline int SubString::contains(const Regex& r) const -{ - int unused; return r.search(chars(), len, unused, 0) >= 0; -} - -inline int SubString::matches(const Regex& r) const -{ - return r.match(chars(), len, 0) == len; -} - - -inline int String::gsub(const String& pat, const String& r) -{ - return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); -} - -inline int String::gsub(const SubString& pat, const String& r) -{ - return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); -} - -inline int String::gsub(const Regex& pat, const String& r) -{ - return _gsub(pat, r.chars(), r.length()); -} - -inline int String::gsub(const char* pat, const String& r) -{ - return _gsub(pat, -1, r.chars(), r.length()); -} - -inline int String::gsub(const char* pat, const char* r) -{ - return _gsub(pat, -1, r, -1); -} - - - -inline ostream& operator<<(ostream& s, const String& x) -{ - s << x.chars(); return s; -} - -// a zillion comparison operators - -inline int operator==(const String& x, const String& y) -{ - return compare(x, y) == 0; -} - -inline int operator!=(const String& x, const String& y) -{ - return compare(x, y) != 0; -} - -inline int operator>(const String& x, const String& y) -{ - return compare(x, y) > 0; -} - -inline int operator>=(const String& x, const String& y) -{ - return compare(x, y) >= 0; -} - -inline int operator<(const String& x, const String& y) -{ - return compare(x, y) < 0; -} - -inline int operator<=(const String& x, const String& y) -{ - return compare(x, y) <= 0; -} - -inline int operator==(const String& x, const SubString& y) -{ - return compare(x, y) == 0; -} - -inline int operator!=(const String& x, const SubString& y) -{ - return compare(x, y) != 0; -} - -inline int operator>(const String& x, const SubString& y) -{ - return compare(x, y) > 0; -} - -inline int operator>=(const String& x, const SubString& y) -{ - return compare(x, y) >= 0; -} - -inline int operator<(const String& x, const SubString& y) -{ - return compare(x, y) < 0; -} - -inline int operator<=(const String& x, const SubString& y) -{ - return compare(x, y) <= 0; -} - -inline int operator==(const String& x, const char* t) -{ - return compare(x, t) == 0; -} - -inline int operator!=(const String& x, const char* t) -{ - return compare(x, t) != 0; -} - -inline int operator>(const String& x, const char* t) -{ - return compare(x, t) > 0; -} - -inline int operator>=(const String& x, const char* t) -{ - return compare(x, t) >= 0; -} - -inline int operator<(const String& x, const char* t) -{ - return compare(x, t) < 0; -} - -inline int operator<=(const String& x, const char* t) -{ - return compare(x, t) <= 0; -} - -inline int operator==(const SubString& x, const String& y) -{ - return compare(y, x) == 0; -} - -inline int operator!=(const SubString& x, const String& y) -{ - return compare(y, x) != 0; -} - -inline int operator>(const SubString& x, const String& y) -{ - return compare(y, x) < 0; -} - -inline int operator>=(const SubString& x, const String& y) -{ - return compare(y, x) <= 0; -} - -inline int operator<(const SubString& x, const String& y) -{ - return compare(y, x) > 0; -} - -inline int operator<=(const SubString& x, const String& y) -{ - return compare(y, x) >= 0; -} - -inline int operator==(const SubString& x, const SubString& y) -{ - return compare(x, y) == 0; -} - -inline int operator!=(const SubString& x, const SubString& y) -{ - return compare(x, y) != 0; -} - -inline int operator>(const SubString& x, const SubString& y) -{ - return compare(x, y) > 0; -} - -inline int operator>=(const SubString& x, const SubString& y) -{ - return compare(x, y) >= 0; -} - -inline int operator<(const SubString& x, const SubString& y) -{ - return compare(x, y) < 0; -} - -inline int operator<=(const SubString& x, const SubString& y) -{ - return compare(x, y) <= 0; -} - -inline int operator==(const SubString& x, const char* t) -{ - return compare(x, t) == 0; -} - -inline int operator!=(const SubString& x, const char* t) -{ - return compare(x, t) != 0; -} - -inline int operator>(const SubString& x, const char* t) -{ - return compare(x, t) > 0; -} - -inline int operator>=(const SubString& x, const char* t) -{ - return compare(x, t) >= 0; -} - -inline int operator<(const SubString& x, const char* t) -{ - return compare(x, t) < 0; -} - -inline int operator<=(const SubString& x, const char* t) -{ - return compare(x, t) <= 0; -} - - -// a helper needed by at, before, etc. - -inline SubString String::_substr(int first, int l) -{ - if (first < 0 || (unsigned)(first + l) > length() ) - return SubString(_nilString, 0, 0) ; - else - return SubString(*this, first, l); -} - -#endif diff --git a/gnu/lib/libg++/include/Uniform.h b/gnu/lib/libg++/include/Uniform.h deleted file mode 100644 index 91536ebedf1a..000000000000 --- a/gnu/lib/libg++/include/Uniform.h +++ /dev/null @@ -1,71 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _Uniform_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Uniform_h 1 - -#include <Random.h> - -// -// The interval [lo..hi] -// - -class Uniform: public Random { - double pLow; - double pHigh; - double delta; -public: - Uniform(double low, double high, RNG *gen); - - double low(); - double low(double x); - double high(); - double high(double x); - - virtual double operator()(); -}; - - -inline Uniform::Uniform(double low, double high, RNG *gen) : Random(gen) -{ - pLow = (low < high) ? low : high; - pHigh = (low < high) ? high : low; - delta = pHigh - pLow; -} - -inline double Uniform::low() { return pLow; } - -inline double Uniform::low(double x) { - double tmp = pLow; - pLow = x; - delta = pHigh - pLow; - return tmp; -} - -inline double Uniform::high() { return pHigh; } - -inline double Uniform::high(double x) { - double tmp = pHigh; - pHigh = x; - delta = pHigh - pLow; - return tmp; -} - -#endif diff --git a/gnu/lib/libg++/include/Weibull.h b/gnu/lib/libg++/include/Weibull.h deleted file mode 100644 index c0360dcdfac6..000000000000 --- a/gnu/lib/libg++/include/Weibull.h +++ /dev/null @@ -1,74 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Dirk Grunwald (grunwald@cs.uiuc.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef _Weibull_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _Weibull_h - -#include <Random.h> - -class Weibull: public Random { -protected: - double pAlpha; - double pInvAlpha; - double pBeta; - - void setState(); - -public: - Weibull(double alpha, double beta, RNG *gen); - - double alpha(); - double alpha(double x); - - double beta(); - double beta(double x); - - virtual double operator()(); -}; - - -inline void Weibull::setState() { - pInvAlpha = 1.0 / pAlpha; -} - -inline Weibull::Weibull(double alpha, double beta, RNG *gen) : Random(gen) -{ - pAlpha = alpha; - pBeta = beta; - setState(); -} - -inline double Weibull::alpha() { return pAlpha; } - -inline double Weibull::alpha(double x) { - double tmp = pAlpha; - pAlpha = x; - setState(); - return tmp; -} - -inline double Weibull::beta() { return pBeta; }; -inline double Weibull::beta(double x) { - double tmp = pBeta; - pBeta = x; - return tmp; -}; - -#endif diff --git a/gnu/lib/libg++/include/_G_config.h b/gnu/lib/libg++/include/_G_config.h deleted file mode 100644 index cbd1acf4078f..000000000000 --- a/gnu/lib/libg++/include/_G_config.h +++ /dev/null @@ -1,74 +0,0 @@ -/* AUTOMATICALLY GENERATED; DO NOT EDIT! */ -#include <sys/types.h> -#ifndef _G_config_h -#define _G_config_h -#define _G_LIB_VERSION "0.66" -#define _G_NAMES_HAVE_UNDERSCORE 1 -#define _G_VTABLE_LABEL_HAS_LENGTH 1 -#define _G_VTABLE_LABEL_PREFIX "__vt$" -#define _G_HAVE_ST_BLKSIZE 1 -typedef unsigned long _G_clock_t; -typedef unsigned long _G_dev_t; -typedef quad_t _G_fpos_t; -typedef unsigned long _G_gid_t; -typedef unsigned long _G_ino_t; -typedef unsigned short _G_mode_t; -typedef unsigned short _G_nlink_t; -typedef long long _G_off_t; -typedef long _G_pid_t; -#ifndef __PTRDIFF_TYPE__ -#define __PTRDIFF_TYPE__ int -#endif -typedef __PTRDIFF_TYPE__ _G_ptrdiff_t; -typedef unsigned int _G_sigset_t; -#ifndef __SIZE_TYPE__ -#define __SIZE_TYPE__ unsigned int -#endif -typedef __SIZE_TYPE__ _G_size_t; -typedef long _G_time_t; -typedef unsigned long _G_uid_t; -#ifndef __WCHAR_TYPE__ -#define __WCHAR_TYPE__ int -#endif -typedef __WCHAR_TYPE__ _G_wchar_t; -typedef int _G_ssize_t; -typedef int /* default */ _G_wint_t; -typedef char* /* default */ _G_va_list; -#define _G_signal_return_type void -#define _G_sprintf_return_type int -#ifdef __STDC__ -typedef signed char _G_int8_t; -#endif -typedef unsigned char _G_uint8_t; -typedef short _G_int16_t; -typedef unsigned short _G_uint16_t; -typedef int _G_int32_t; -typedef unsigned long _G_uint32_t; -#define HAVE_INT64 -typedef long long _G_int64_t; -typedef unsigned _G_uint64_t; -#define _G_BUFSIZ 1024 -#define _G_FOPEN_MAX 20 -#define _G_FILENAME_MAX 1024 -#define _G_NULL 0 /* default */ -#if defined (__cplusplus) || defined (__STDC__) -#define _G_ARGS(ARGLIST) ARGLIST -#else -#define _G_ARGS(ARGLIST) () -#endif -#if !defined (__GNUG__) || defined (__STRICT_ANSI__) -#define _G_NO_NRV -#endif -#if !defined (__GNUG__) -#define _G_NO_EXTERN_TEMPLATES -#endif -#define _G_HAVE_ATEXIT 1 -#define _G_HAVE_SYS_RESOURCE 1 -#define _G_HAVE_SYS_SOCKET 1 -#define _G_HAVE_SYS_WAIT 1 -#define _G_HAVE_UNISTD 1 -#define _G_HAVE_DIRENT 1 -#define _G_HAVE_CURSES 1 -#define _G_MATH_H_INLINES 0 -#define _G_HAVE_BOOL 1 -#endif /* !_G_config_h */ diff --git a/gnu/lib/libg++/include/ansidecl.h b/gnu/lib/libg++/include/ansidecl.h deleted file mode 100644 index 3c0dcb3d9fc4..000000000000 --- a/gnu/lib/libg++/include/ansidecl.h +++ /dev/null @@ -1,141 +0,0 @@ -/* ANSI and traditional C compatability macros - Copyright 1991, 1992 Free Software Foundation, Inc. - This file is part of the GNU C Library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* ANSI and traditional C compatibility macros - - ANSI C is assumed if __STDC__ is #defined. - - Macro ANSI C definition Traditional C definition - ----- ---- - ---------- ----------- - ---------- - PTR `void *' `char *' - LONG_DOUBLE `long double' `double' - VOLATILE `volatile' `' - SIGNED `signed' `' - PTRCONST `void *const' `char *' - ANSI_PROTOTYPES 1 not defined - - CONST is also defined, but is obsolete. Just use const. - - DEFUN (name, arglist, args) - - Defines function NAME. - - ARGLIST lists the arguments, separated by commas and enclosed in - parentheses. ARGLIST becomes the argument list in traditional C. - - ARGS list the arguments with their types. It becomes a prototype in - ANSI C, and the type declarations in traditional C. Arguments should - be separated with `AND'. For functions with a variable number of - arguments, the last thing listed should be `DOTS'. - - DEFUN_VOID (name) - - Defines a function NAME, which takes no arguments. - - obsolete -- EXFUN (name, (prototype)) -- obsolete. - - Replaced by PARAMS. Do not use; will disappear someday soon. - Was used in external function declarations. - In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in - parentheses). In traditional C it is `NAME()'. - For a function that takes no arguments, PROTOTYPE should be `(void)'. - - PARAMS ((args)) - - We could use the EXFUN macro to handle prototype declarations, but - the name is misleading and the result is ugly. So we just define a - simple macro to handle the parameter lists, as in: - - static int foo PARAMS ((int, char)); - - This produces: `static int foo();' or `static int foo (int, char);' - - EXFUN would have done it like this: - - static int EXFUN (foo, (int, char)); - - but the function is not external...and it's hard to visually parse - the function name out of the mess. EXFUN should be considered - obsolete; new code should be written to use PARAMS. - - For example: - extern int printf PARAMS ((CONST char *format DOTS)); - int DEFUN(fprintf, (stream, format), - FILE *stream AND CONST char *format DOTS) { ... } - void DEFUN_VOID(abort) { ... } -*/ - -#ifndef _ANSIDECL_H - -#define _ANSIDECL_H 1 - - -/* Every source file includes this file, - so they will all get the switch for lint. */ -/* LINTLIBRARY */ - - -#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) -/* All known AIX compilers implement these things (but don't always - define __STDC__). The RISC/OS MIPS compiler defines these things - in SVR4 mode, but does not define __STDC__. */ - -#define PTR void * -#define PTRCONST void *CONST -#define LONG_DOUBLE long double - -#define AND , -#define NOARGS void -#define CONST const -#define VOLATILE volatile -#define SIGNED signed -#define DOTS , ... - -#define EXFUN(name, proto) name proto -#define DEFUN(name, arglist, args) name(args) -#define DEFUN_VOID(name) name(void) - -#define PROTO(type, name, arglist) type name arglist -#define PARAMS(paramlist) paramlist -#define ANSI_PROTOTYPES 1 - -#else /* Not ANSI C. */ - -#define PTR char * -#define PTRCONST PTR -#define LONG_DOUBLE double - -#define AND ; -#define NOARGS -#define CONST -#ifndef const /* some systems define it in header files for non-ansi mode */ -#define const -#endif -#define VOLATILE -#define SIGNED -#define DOTS - -#define EXFUN(name, proto) name() -#define DEFUN(name, arglist, args) name arglist args; -#define DEFUN_VOID(name) name() -#define PROTO(type, name, arglist) type name () -#define PARAMS(paramlist) () - -#endif /* ANSI C. */ - -#endif /* ansidecl.h */ diff --git a/gnu/lib/libg++/include/bitdo1.h b/gnu/lib/libg++/include/bitdo1.h deleted file mode 100644 index c234d41d4069..000000000000 --- a/gnu/lib/libg++/include/bitdo1.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef ONES -#define ONES ((_BS_word)(~0L)) -#endif - register int nwords; - register _BS_word mask; - if (offset == 0) - ; - else if (offset + length >= _BS_BITS_PER_WORD) - { - mask = ONES _BS_RIGHT offset; - DOIT(*ptr++, mask); - length -= _BS_BITS_PER_WORD - offset; - } - else - { - mask = (ONES _BS_RIGHT (_BS_BITS_PER_WORD - length)) - _BS_LEFT (_BS_BITS_PER_WORD - length - offset); - DOIT(*ptr, mask); - goto done; - } - nwords = _BS_INDEX(length); - while (--nwords >= 0) - { - DOIT(*ptr++, ONES); - } - length = _BS_POS (length); - if (length) - { - mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - length); - DOIT(*ptr, mask); - } - done: ; diff --git a/gnu/lib/libg++/include/bitdo2.h b/gnu/lib/libg++/include/bitdo2.h deleted file mode 100644 index 6e9952353721..000000000000 --- a/gnu/lib/libg++/include/bitdo2.h +++ /dev/null @@ -1,184 +0,0 @@ -#ifndef ONES -#define ONES ((_BS_word)(~0L)) -#endif - -#ifndef DOIT_SOLID -#ifdef DOIT -#define DOIT_SOLID(dst, src) DOIT(dst, src, (_BS_word)(~0)) -#else -#define DOIT_SOLID(dst, src) (dst) = (COMBINE(dst, src)) -#endif -#endif - -#ifndef DOIT -#define DOIT(dst, src, mask) \ - (dst) = ((COMBINE(dst, src)) & (mask)) | ((dst) & ~(mask)) -#endif - - _BS_word word0, mask; - int shift0, shift1; - - if (length == 0) - goto done; - - shift0 = srcbit - dstbit; - - /* First handle the case that only one destination word is touched. */ - if (length + dstbit <= _BS_BITS_PER_WORD) - { - _BS_word mask - = (ONES _BS_LEFT (_BS_BITS_PER_WORD - length)) _BS_RIGHT dstbit; - _BS_word word0 = *psrc++; - if (shift0 <= 0) /* dstbit >= srcbit */ - { - word0 = word0 _BS_RIGHT (-shift0); - } - else - { - word0 = word0 _BS_LEFT shift0; - if (length + srcbit > _BS_BITS_PER_WORD) - word0 = word0 | (*psrc _BS_RIGHT (_BS_BITS_PER_WORD - shift0)); - } - DOIT(*pdst, word0, mask); - goto done; - } - - /* Next optimize the case that the source and destination are aligned. */ - if (shift0 == 0) - { - _BS_word mask; - if (psrc > pdst) - { - if (srcbit) - { - mask = ONES _BS_RIGHT srcbit; - DOIT(*pdst, *psrc, mask); - pdst++; psrc++; - length -= _BS_BITS_PER_WORD - srcbit; - } - for (; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD) - { - DOIT_SOLID(*pdst, *psrc); - pdst++; psrc++; - } - if (length) - { - mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - length); - DOIT(*pdst, *psrc, mask); - } - } - else if (psrc < pdst) - { - _BS_size_t span = srcbit + length; - pdst += span / (_BS_size_t)_BS_BITS_PER_WORD; - psrc += span / (_BS_size_t)_BS_BITS_PER_WORD; - span %= (_BS_size_t)_BS_BITS_PER_WORD; - if (span) - { - mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - span); - DOIT(*pdst, *psrc, mask); - length -= span; - } - pdst--; psrc--; - for (; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD) - { - DOIT_SOLID(*pdst, *psrc); - pdst--; psrc--; - } - if (srcbit) - { - mask = ONES _BS_RIGHT srcbit; - DOIT(*pdst, *psrc, mask); - } - } - /* else if (psrc == pdst) --nothing to do--; */ - goto done; - } - - /* Now we assume shift!=0, and more than on destination word is changed. */ - if (psrc >= pdst) /* Do the updates in forward direction. */ - { - _BS_word word0 = *psrc++; - _BS_word mask = ONES _BS_RIGHT dstbit; - if (shift0 > 0) - { - _BS_word word1 = *psrc++; - shift1 = _BS_BITS_PER_WORD - shift0; - DOIT(*pdst, (word0 _BS_LEFT shift0) | (word1 _BS_RIGHT shift1), mask); - word0 = word1; - } - else /* dstbit > srcbit */ - { - shift1 = -shift0; - shift0 += _BS_BITS_PER_WORD; - DOIT(*pdst, word0 _BS_RIGHT shift1, mask); - } - pdst++; - length -= _BS_BITS_PER_WORD - dstbit; - - for ( ; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD) - { - register _BS_word word1 = *psrc++; - DOIT_SOLID(*pdst, - (word0 _BS_LEFT shift0) | (word1 _BS_RIGHT shift1)); - pdst++; - word0 = word1; - } - if (length > 0) - { - _BS_size_t mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - length); - word0 = word0 _BS_LEFT shift0; - if (length > shift1) - word0 = word0 | (*psrc _BS_RIGHT shift1) ; - DOIT (*pdst, word0, mask); - } - } - else /* Do the updates in backward direction. */ - { - _BS_word word0; - - /* Make (psrc, srcbit) and (pdst, dstbit) point to *last* bit. */ - psrc += (srcbit + length - 1) / _BS_BITS_PER_WORD; - srcbit = (srcbit + length - 1) % _BS_BITS_PER_WORD; - pdst += (dstbit + length - 1) / _BS_BITS_PER_WORD; - dstbit = (dstbit + length - 1) % _BS_BITS_PER_WORD; - - shift0 = srcbit - dstbit; - - word0 = *psrc--; - mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - 1 - dstbit); - if (shift0 < 0) - { - _BS_word word1 = *psrc--; - shift1 = -shift0; - shift0 += _BS_BITS_PER_WORD; - DOIT (*pdst, (word0 _BS_RIGHT shift1) | (word1 _BS_LEFT shift0), - mask); - word0 = word1; - } - else - { - shift1 = _BS_BITS_PER_WORD - shift0; - DOIT(*pdst, word0 _BS_LEFT shift0, mask); - } - pdst--; - length -= dstbit + 1; - - for ( ; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD) - { - register _BS_word word1 = *psrc--; - DOIT_SOLID(*pdst, - (word0 _BS_RIGHT shift1) | (word1 _BS_LEFT shift0)); - pdst--; - word0 = word1; - } - if (length > 0) - { - _BS_size_t mask = ONES _BS_RIGHT (_BS_BITS_PER_WORD - length); - word0 = word0 _BS_RIGHT shift1; - if (length > shift0) - word0 = word0 | (*psrc _BS_LEFT shift0) ; - DOIT (*pdst, word0, mask); - } - } - done: ; diff --git a/gnu/lib/libg++/include/bitprims.h b/gnu/lib/libg++/include/bitprims.h deleted file mode 100644 index 24b30512f42f..000000000000 --- a/gnu/lib/libg++/include/bitprims.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef _BS_PRIMS -#define _BS_PRIMS - -/* For now, use unsigned short for compatibility with old libg++ code. - Later, change to unsigned long as the default. */ -typedef unsigned long _BS_word; - -#define _BS_CHAR_BIT 8 -#define _BS_BITS_PER_WORD (_BS_CHAR_BIT*sizeof(_BS_word)) -#define _BS_WORDS_NEEDED(NBITS) ((NBITS+_BS_BITS_PER_WORD-1)/_BS_BITS_PER_WORD) - -/* For now, we number the bits in a _BS_word in little-endian order. - Later, might use machine order. */ -#ifdef CHILL_LIB -#ifndef BITS_BIG_ENDIAN -#include "config.h" -#endif -#define _BS_BIGENDIAN BITS_BIG_ENDIAN -#else -#define _BS_BIGENDIAN 0 -#endif - -/* By "left" we mean where bit number 0 is. - Hence, so left shift is << if we're numbering the bits in big-endian oder, - and >> if we're numbering the bits in little-endian order. - Currently, we always use little-endian order. - Later, we might use machine-endian order. */ -#if _BS_BIGENDIAN -#define _BS_LEFT << -#define _BS_RIGHT >> -#else -#define _BS_LEFT >> -#define _BS_RIGHT << -#endif - -#if _BS_BIGENDIAN -#define _BS_BITMASK(BITNO) (1 << (_BS_BITS_PER_WORD - 1 - (BITNO))) -#else -#define _BS_BITMASK(BITNO) (1 << (BITNO)) -#endif - -/* Given a PTR which may not be aligned on a _BS_word boundary, - set NEW_PTR to point to (the beginning of) the corresponding _BS_word. - Adjust the bit-offset OFFSET to compensate for the difference. */ -#define _BS_ADJUST_ALIGNED(NEW_PTR, PTR, OFFSET) \ - ( (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 - OFFSET < _BS_BITS_PER_WORD. */ -#define _BS_NORMALIZE(PTR, OFFSET) \ -{ _BS_size_t __tmp_ind = _BS_INDEX (OFFSET); \ - (PTR) += __tmp_ind; \ - (OFFSET) -= __tmp_ind * _BS_BITS_PER_WORD; } - -#define _BS_INDEX(I) ((unsigned)(I) / _BS_BITS_PER_WORD) -#define _BS_POS(I) ((I) & (_BS_BITS_PER_WORD -1 )) - -#ifndef _BS_size_t -#ifdef __GNUC__ -#define _BS_size_t __SIZE_TYPE__ -#else -#define _BS_size_t unsigned long -#endif -#endif - -#ifndef __P -#ifdef __STDC__ -#define __P(paramlist) paramlist -#else -#define __P(paramlist) () -#endif -#endif /*!__P*/ -#if !defined(__STDC__) && !defined(const) -#define const -#endif -#if !defined(__STDC__) && !defined(void) -#define void int -#endif - -/* The 16 2-operand raster-ops: - These match the correspodning GX codes in X11. */ -enum _BS_alu { - _BS_alu_clear = 0 /* 0 */, - _BS_alu_and = 1 /* src & dst */, - _BS_alu_andReverse = 2 /* src & ~dst */, - _BS_alu_copy = 3 /* src */, - _BS_alu_andInverted = 4 /* ~src & dst */, - _BS_alu_noop = 5 /* dst */, - _BS_alu_xor = 6 /* src ^ dst */, - _BS_alu_or = 7 /* src | dst */, - _BS_alu_nor = 8 /* ~src & ~dst */, - _BS_alu_equiv = 9 /* ~(src ^ dst) */, - _BS_alu_invert = 10 /* ~dst */, - _BS_alu_orReverse = 11 /* src | ~dst */, - _BS_alu_copyInverted = 12 /* ~src */, - _BS_alu_orInverted = 13 /* ~src | dst */, - _BS_alu_nand = 14 /* ~src | d~st */, - _BS_alu_set = 15 /* ~src | dst */ -}; -#define _BS -#define _BS - -#ifdef __cplusplus -extern "C" { -#endif - -extern void _BS_and __P((_BS_word*,int, const _BS_word*, int, _BS_size_t)); -extern void _BS_blt __P((enum _BS_alu, - _BS_word*,int, const _BS_word*,int, _BS_size_t)); -extern void _BS_copy __P((_BS_word*,int, const _BS_word*,int, _BS_size_t)); -#define _BS_copy_0(DS, SS, LENGTH) _BS_copy(DS, 0, SS, 0, LENGTH) -extern int _BS_count __P((const _BS_word*, int, _BS_size_t)); -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)); -extern void _BS_xor __P((_BS_word*,int, const _BS_word*,int, _BS_size_t)); - -#ifdef __cplusplus -} -#endif - -#endif /* !_BS_PRIMS */ diff --git a/gnu/lib/libg++/include/builtin.h b/gnu/lib/libg++/include/builtin.h deleted file mode 100644 index e2d7bcee7909..000000000000 --- a/gnu/lib/libg++/include/builtin.h +++ /dev/null @@ -1,144 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/* - arithmetic, etc. functions on built in types -*/ - - -#ifndef _builtin_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _builtin_h 1 - -#include <stddef.h> -#include <std.h> -#include <math.h> - -#ifdef __GNUG__ -#define _VOLATILE_VOID volatile void -#else -#define _VOLATILE_VOID void -#endif - -typedef void (*one_arg_error_handler_t)(const char*); -typedef void (*two_arg_error_handler_t)(const char*, const char*); - -long gcd(long, long); -long lg(unsigned long); -double pow(double, long); -long pow(long, long); - -extern "C" double start_timer(); -extern "C" double return_elapsed_time(double last_time = 0.0); - -char* dtoa(double x, char cvt = 'g', int width = 0, int prec = 6); - -unsigned int hashpjw(const char*); -unsigned int multiplicativehash(int); -unsigned int foldhash(double); - -extern _VOLATILE_VOID default_one_arg_error_handler(const char*); -extern _VOLATILE_VOID default_two_arg_error_handler(const char*, const char*); - -extern two_arg_error_handler_t lib_error_handler; - -extern two_arg_error_handler_t - set_lib_error_handler(two_arg_error_handler_t f); - - -#if !defined(IV) - -#if ! _G_MATH_H_INLINES /* hpux and SCO define this in math.h */ -inline double abs(double arg) -{ - return (arg < 0.0)? -arg : arg; -} -#endif - -inline float abs(float arg) -{ - return (arg < 0.0)? -arg : arg; -} - -inline short abs(short arg) -{ - return (arg < 0)? -arg : arg; -} - -inline long abs(long arg) -{ - return (arg < 0)? -arg : arg; -} - -inline int sign(long arg) -{ - return (arg == 0) ? 0 : ( (arg > 0) ? 1 : -1 ); -} - -inline int sign(double arg) -{ - return (arg == 0.0) ? 0 : ( (arg > 0.0) ? 1 : -1 ); -} - -inline long sqr(long arg) -{ - return arg * arg; -} - -#if ! _G_MATH_H_INLINES /* hpux and SCO define this in math.h */ -inline double sqr(double arg) -{ - return arg * arg; -} -#endif - -inline int even(long arg) -{ - return !(arg & 1); -} - -inline int odd(long arg) -{ - return (arg & 1); -} - -inline long lcm(long x, long y) -{ - return x / gcd(x, y) * y; -} - -inline void (setbit)(long& x, long b) -{ - x |= (1 << b); -} - -inline void clearbit(long& x, long b) -{ - x &= ~(1 << b); -} - -inline int testbit(long x, long b) -{ - return ((x & (1 << b)) != 0); -} - -#endif -#endif diff --git a/gnu/lib/libg++/include/builtinbuf.h b/gnu/lib/libg++/include/builtinbuf.h deleted file mode 100644 index d67629a1de65..000000000000 --- a/gnu/lib/libg++/include/builtinbuf.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#ifndef _BUILTINBUF_H -#define _BUILTINBUF_H - -#ifdef __GNUC__ -#pragma interface -#endif - -#include <streambuf.h> - -// A builtinbuf a a streambuf where all the virtual operations -// call the _IO_jump_t table. - -class builtinbuf : public streambuf { - friend ios; - virtual int overflow(int); - virtual int underflow(); - virtual streamsize xsgetn(char *, streamsize); - virtual streamsize xsputn(const char *, streamsize); - virtual streambuf* setbuf(char*, int); - virtual int doallocate(); - virtual ~builtinbuf(); - virtual int sync(); - - virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); - virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out); - virtual int pbackfail(int c); - virtual streamsize sys_read(char* buf, streamsize size); - virtual streampos sys_seek(streamoff, _seek_dir); - virtual streamsize sys_write(const char*, streamsize); - virtual int sys_stat(void*); // Actually, a (struct stat*) - virtual int sys_close(); -#if 0 - virtual int get_column(); - virtual int set_column(int); -#endif - private: - builtinbuf() { } -}; -#endif /* _BUILTINBUF_H */ diff --git a/gnu/lib/libg++/include/compare.h b/gnu/lib/libg++/include/compare.h deleted file mode 100644 index aec3c30bd679..000000000000 --- a/gnu/lib/libg++/include/compare.h +++ /dev/null @@ -1,91 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- - -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _compare_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _compare_h 1 - -#include <builtin.h> - -int compare(int a, int b); -int compare(short a, short b); -int compare(unsigned long a, unsigned long b); -int compare(unsigned int a, unsigned int b); -int compare(unsigned short a, unsigned short b); -int compare(unsigned char a, unsigned char b); -int compare(signed char a, signed char b); -int compare(float a, float b); -int compare(double a, double b); -int compare(const char* a, const char* b); - - -inline int compare(int a, int b) -{ - return a - b; -} - -inline int compare(short a, short b) -{ - return a - b; -} - - -inline int compare(signed char a, signed char b) -{ - return a - b; -} - -inline int compare(unsigned long a, unsigned long b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(unsigned int a, unsigned int b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(unsigned short a, unsigned short b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(unsigned char a, unsigned char b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(float a, float b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(double a, double b) -{ - return (a < b)? -1 : (a > b)? 1 : 0; -} - -inline int compare(const char* a, const char* b) -{ - return strcmp(a,b); -} - -#endif diff --git a/gnu/lib/libg++/include/complex.h b/gnu/lib/libg++/include/complex.h deleted file mode 100644 index afe2c8bcd967..000000000000 --- a/gnu/lib/libg++/include/complex.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _complex_h -#define _complex_h -#define __ATT_complex__ -#include <Complex.h> -typedef class Complex complex; -#endif diff --git a/gnu/lib/libg++/include/config.h b/gnu/lib/libg++/include/config.h deleted file mode 100644 index b37ee84a78ab..000000000000 --- a/gnu/lib/libg++/include/config.h +++ /dev/null @@ -1 +0,0 @@ -/* !Automatically generated from ./functions.def - DO NOT EDIT! */ diff --git a/gnu/lib/libg++/include/defines.h b/gnu/lib/libg++/include/defines.h deleted file mode 100644 index f5056b69c80b..000000000000 --- a/gnu/lib/libg++/include/defines.h +++ /dev/null @@ -1,35 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1994 Free Software Foundation - written by Jason Merrill (jason@cygnus.com) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _defines_h -#define _defines_h - -#include <_G_config.h> -#include <stddef.h> - -const size_t NPOS = (size_t)(-1); -typedef void fvoid_t(); - -#ifndef _WINT_T -#define _WINT_T -typedef _G_wint_t wint_t; -#endif - -enum capacity { default_size, reserve }; - -#endif diff --git a/gnu/lib/libg++/include/editbuf.h b/gnu/lib/libg++/include/editbuf.h deleted file mode 100644 index 2cac3bb8c2ad..000000000000 --- a/gnu/lib/libg++/include/editbuf.h +++ /dev/null @@ -1,183 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. - -Written by Per Bothner (bothner@cygnus.com). */ - -#ifndef _EDITBUF_H -#define _EDITBUF_H -#ifdef __GNUG__ -#pragma interface -#endif -#include <stdio.h> -#include <fstream.h> - -typedef unsigned long mark_pointer; -// At some point, it might be nice to parameterize this code -// in terms of buf_char. -typedef /*unsigned*/ char buf_char; - -// Logical pos from start of buffer (does not count gap). -typedef long buf_index; - -// Pos from start of buffer, possibly including gap_size. -typedef long buf_offset; - -#if 0 -struct buf_cookie { - FILE *file; - struct edit_string *str; - struct buf_cookie *next; - buf_index tell(); -}; -#endif - -struct edit_buffer; -struct edit_mark; - -// A edit_string is defined as the region between the 'start' and 'end' marks. -// Normally (always?) 'start->insert_before()' should be false, -// and 'end->insert_before()' should be true. - -struct edit_string { - struct edit_buffer *buffer; // buffer that 'start' and 'end' belong to - struct edit_mark *start, *end; - int length() const; // count of buf_chars currently in string - edit_string(struct edit_buffer *b, - struct edit_mark *ms, struct edit_mark *me) - { buffer = b; start = ms; end = me; } -/* Make a fresh, contiguous copy of the data in STR. - Assign length of STR to *LENP. - (Output has extra NUL at out[*LENP].) */ - buf_char *copy_bytes(int *lenp) const; -// FILE *open_file(char *mode); - void assign(struct edit_string *src); // copy bytes from src to this -}; - -struct edit_streambuf : public streambuf { - friend edit_buffer; - edit_string *str; - edit_streambuf* next; // Chain of edit_streambuf's for a edit_buffer. - short _mode; - edit_streambuf(edit_string* bstr, int mode); - ~edit_streambuf(); - virtual int underflow(); - virtual int overflow(int c = EOF); - virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); - void flush_to_buffer(); - void flush_to_buffer(edit_buffer* buffer); - int _inserting; - int inserting() { return _inserting; } - void inserting(int i) { _inserting = i; } -// int delete_chars(int count, char* cut_buf); Not implemented. - int truncate(); - int is_reading() { return gptr() != NULL; } - buf_char* current() { return is_reading() ? gptr() : pptr(); } - void set_current(char *p, int is_reading); - protected: - void disconnect_gap_from_file(edit_buffer* buffer); -}; - -// A 'edit_mark' indicates a position in a buffer. -// It is "attached" the text (rather than the offset). -// There are two kinds of mark, which have different behavior -// when text is inserted at the mark: -// If 'insert_before()' is true the mark will be adjusted to be -// *after* the new text. - -struct edit_mark { - struct edit_mark *chain; - mark_pointer _pos; - inline int insert_before() { return _pos & 1; } - inline unsigned long index_in_buffer(struct edit_buffer *buffer) - { return _pos >> 1; } - inline buf_char *ptr(struct edit_buffer *buf); - buf_index tell(); - edit_mark() { } - edit_mark(struct edit_string *str, long delta); - edit_buffer *buffer(); - ~edit_mark(); -}; - -// A 'edit_buffer' consists of a sequence of buf_chars (the data), -// a list of edit_marks pointing into the data, and a list of FILEs -// also pointing into the data. -// A 'edit_buffer' coerced to a edit_string is the string of -// all the buf_chars in the buffer. - -// This implementation uses a conventional buffer gap (as in Emacs). -// The gap start is defined by de-referencing a (buf_char**). -// This is because sometimes a FILE is inserting into the buffer, -// so rather than having each putc adjust the gap, we use indirection -// to have the gap be defined as the write pointer of the FILE. -// (This assumes that putc adjusts a pointer (as in GNU's libc), not an index.) - -struct edit_buffer { - buf_char *data; /* == emacs buffer_text.p1+1 */ - buf_char *_gap_start; - edit_streambuf* _writer; // If non-NULL, currently writing stream - inline buf_char *gap_start() - { return _writer ? _writer->pptr() : _gap_start; } - buf_offset __gap_end_pos; // size of part 1 + size of gap - /* int gap; implicit: buf_size - size1 - size2 */ - int buf_size; - struct edit_streambuf *files; - struct edit_mark start_mark; - struct edit_mark end_mark; - edit_buffer(); - inline buf_offset gap_end_pos() { return __gap_end_pos; } - inline struct edit_mark *start_marker() { return &start_mark; } - inline struct edit_mark *end_marker() { return &end_mark; } -/* these should be protected, ultimately */ - buf_index tell(edit_mark*); - buf_index tell(buf_char*); - inline buf_char *gap_end() { return data + gap_end_pos(); } - inline int gap_size() { return gap_end() - gap_start(); } - inline int size1() { return gap_start() - data; } - inline int size2() { return buf_size - gap_end_pos(); } - inline struct edit_mark * mark_list() { return &start_mark; } - void make_gap (buf_offset); - void move_gap (buf_offset pos); - void move_gap (buf_char *pos) { move_gap(pos - data); } - void gap_left (int pos); - void gap_right (int pos); - void adjust_markers(mark_pointer low, mark_pointer high, - int amount, buf_char *old_data); - void delete_range(buf_index from, buf_index to); - void delete_range(struct edit_mark *start, struct edit_mark *end); -}; - -extern buf_char * bstr_copy(struct edit_string *str, int *lenp); - -// Convert a edit_mark to a (buf_char*) - -inline buf_char *edit_mark::ptr(struct edit_buffer *buf) - { return buf->data + index_in_buffer(buf); } - -inline void edit_streambuf::flush_to_buffer() -{ - edit_buffer* buffer = str->buffer; - if (buffer->_writer == this) flush_to_buffer(buffer); -} -#endif /* !_EDITBUF_H*/ - diff --git a/gnu/lib/libg++/include/floatio.h b/gnu/lib/libg++/include/floatio.h deleted file mode 100644 index 880f8074c849..000000000000 --- a/gnu/lib/libg++/include/floatio.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -/* - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * %W% (Berkeley) %G% - */ - -/* - * Floating point scanf/printf (input/output) definitions. - */ - -/* 11-bit exponent (VAX G floating point) is 308 decimal digits */ -#define MAXEXP 308 -/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */ -#define MAXFRACT 39 diff --git a/gnu/lib/libg++/include/fstream.h b/gnu/lib/libg++/include/fstream.h deleted file mode 100644 index 20dfbf2324fa..000000000000 --- a/gnu/lib/libg++/include/fstream.h +++ /dev/null @@ -1,81 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#ifndef _FSTREAM_H -#define _FSTREAM_H -#ifdef __GNUG__ -#pragma interface -#endif -#include <iostream.h> - -class fstreambase : virtual public ios { - public: - fstreambase(); - fstreambase(int fd); - fstreambase(int fd, char *p, int l); /* Deprecated */ - fstreambase(const char *name, int mode, int prot=0664); - void close(); - filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); } - void open(const char *name, int mode, int prot=0664); - int is_open() const { return rdbuf()->is_open(); } - void setbuf(char *ptr, int len) { rdbuf()->setbuf(ptr, len); } -#ifdef _STREAM_COMPAT - int filedesc() { return rdbuf()->fd(); } - fstreambase& raw() { rdbuf()->setbuf(NULL, 0); return *this; } -#endif -}; - -class ifstream : public fstreambase, public istream { - public: - ifstream() : fstreambase() { } - ifstream(int fd) : fstreambase(fd) { } - ifstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/ - ifstream(const char *name, int mode=ios::in, int prot=0664) - : fstreambase(name, mode, prot) { } - void open(const char *name, int mode=ios::in, int prot=0664) - { fstreambase::open(name, mode, prot); } -}; - -class ofstream : public fstreambase, public ostream { - public: - ofstream() : fstreambase() { } - ofstream(int fd) : fstreambase(fd) { } - ofstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/ - ofstream(const char *name, int mode=ios::out, int prot=0664) - : fstreambase(name, mode, prot) { } - void open(const char *name, int mode=ios::out, int prot=0664) - { fstreambase::open(name, mode, prot); } -}; - -class fstream : public fstreambase, public iostream { - public: - fstream() : fstreambase() { } - fstream(int fd) : fstreambase(fd) { } - fstream(const char *name, int mode, int prot=0664) - : fstreambase(name, mode, prot) { } - fstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/ - void open(const char *name, int mode, int prot=0664) - { fstreambase::open(name, mode, prot); } -}; -#endif /*!_FSTREAM_H*/ diff --git a/gnu/lib/libg++/include/indstream.h b/gnu/lib/libg++/include/indstream.h deleted file mode 100644 index 8047b8217abe..000000000000 --- a/gnu/lib/libg++/include/indstream.h +++ /dev/null @@ -1,74 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. - -Written by Per Bothner (bothner@cygnus.com). */ - -#ifndef _INDSTREAM_H -#define _INDSTREAM_H - -#ifdef __GNUG__ -#pragma interface -#endif - -#include <iostream.h> - -// An indirectbuf is one that forwards all of its I/O requests -// to another streambuf. -// All get-related requests are sent to get_stream(). -// All put-related requests are sent to put_stream(). - -// An indirectbuf can be used to implement Common Lisp -// synonym-streams and two-way-streams. -// -// class synonymbuf : public indirectbuf { -// Symbol *sym; -// synonymbuf(Symbol *s) { sym = s; } -// virtual streambuf *lookup_stream(int mode) { -// return coerce_to_streambuf(lookup_value(sym)); } -// }; - -class indirectbuf : public streambuf { - protected: - streambuf *_get_stream; // Optional cache for get_stream(). - streambuf *_put_stream; // Optional cache for put_stream(). - int _delete_flags; - public: - streambuf *get_stream() - { return _get_stream ? _get_stream : lookup_stream(ios::in); } - streambuf *put_stream() - { return _put_stream ? _put_stream : lookup_stream(ios::out); } - virtual streambuf *lookup_stream(int/*mode*/) { return NULL; } // ERROR! - indirectbuf(streambuf *get=NULL, streambuf *put=NULL, int delete_mode=0); - virtual ~indirectbuf(); - virtual int xsputn(const char* s, int n); - virtual int xsgetn(char* s, int n); - virtual int underflow(); - 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); - virtual int sync(); - virtual int pbackfail(int c); -}; - -#endif /* !_INDSTREAM_H */ diff --git a/gnu/lib/libg++/include/iolibio.h b/gnu/lib/libg++/include/iolibio.h deleted file mode 100644 index 08040fa4e10e..000000000000 --- a/gnu/lib/libg++/include/iolibio.h +++ /dev/null @@ -1,52 +0,0 @@ -#include "libio.h" - -/* These emulate stdio functionality, but with a different name - (_IO_ungetc instead of ungetc), and using _IO_FILE instead of FILE. */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int _IO_fclose __P((_IO_FILE*)); -extern _IO_FILE *_IO_fdopen __P((int, const char*)); -extern int _IO_fflush __P((_IO_FILE*)); -extern int _IO_fgetpos __P((_IO_FILE*, _IO_fpos_t*)); -extern char* _IO_fgets __P((char*, int, _IO_FILE*)); -extern _IO_FILE *_IO_fopen __P((const char*, const char*)); -extern int _IO_fprintf __P((_IO_FILE*, const char*, ...)); -extern int _IO_fputs __P((const char*, _IO_FILE*)); -extern int _IO_fsetpos __P((_IO_FILE*, const _IO_fpos_t *)); -extern long int _IO_ftell __P((_IO_FILE*)); -extern _IO_size_t _IO_fwrite __P((const void*, - _IO_size_t, _IO_size_t, _IO_FILE*)); -extern char* _IO_gets __P((char*)); -extern void _IO_perror __P((const char*)); -extern int _IO_printf __P((const char*, ...)); -extern int _IO_puts __P((const char*)); -extern int _IO_scanf __P((const char*, ...)); -extern void _IO_setbuffer __P((_IO_FILE *, char*, _IO_size_t)); -extern int _IO_setvbuf __P((_IO_FILE*, char*, int, _IO_size_t)); -extern int _IO_sscanf __P((const char*, const char*, ...)); -extern int _IO_sprintf __P((char *, const char*, ...)); -extern int _IO_ungetc __P((int, _IO_FILE*)); -extern int _IO_vsscanf __P((const char *, const char *, _IO_va_list)); -extern int _IO_vsprintf __P((char*, const char*, _IO_va_list)); -#ifndef _IO_pos_BAD -#define _IO_pos_BAD ((_IO_fpos_t)(-1)) -#endif -#define _IO_clearerr(FP) ((FP)->_flags &= ~(_IO_ERR_SEEN|_IO_EOF_SEEN)) -#define _IO_fseek(__fp, __offset, __whence) \ - (_IO_seekoff(__fp, __offset, (_IO_off_t)(__whence)) == _IO_pos_BAD ? EOF : 0) -#define _IO_rewind(FILE) (void)_IO_seekoff(FILE, 0, 0) -#define _IO_vprintf(FORMAT, ARGS) _IO_vfprintf(_IO_stdout, FORMAT, ARGS) -#define _IO_freopen(FILENAME, MODE, FP) \ - (_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE)) -#define _IO_fileno(FP) ((FP)->_fileno) -extern _IO_FILE* _IO_popen __P((const char*, const char*)); -#define _IO_pclose _IO_fclose -#define _IO_setbuf(_FP, _BUF) _IO_setbuffer(_FP, _BUF, _IO_BUFSIZ) -#define _IO_setlinebuf(_FP) _IO_setvbuf(_FP, NULL, 1, 0) - -#ifdef __cplusplus -} -#endif diff --git a/gnu/lib/libg++/include/iomanip.h b/gnu/lib/libg++/include/iomanip.h deleted file mode 100644 index a87e7bf63e5c..000000000000 --- a/gnu/lib/libg++/include/iomanip.h +++ /dev/null @@ -1,159 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#ifndef _IOMANIP_H -#ifdef __GNUG__ -#pragma interface -#endif -#define _IOMANIP_H - -#include <iostream.h> - -//----------------------------------------------------------------------------- -// Parametrized Manipulators as specified by ANSI draft -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Stream Manipulators -//----------------------------------------------------------------------------- -// -template<class TP> class smanip; // TP = Type Param - -template<class TP> class sapp { - ios& (*_f)(ios&, TP); -public: - sapp(ios& (*f)(ios&, TP)) : _f(f) {} - // - smanip<TP> operator()(TP a) - { return smanip<TP>(_f, a); } -}; - -template <class TP> class smanip { - ios& (*_f)(ios&, TP); - TP _a; -public: - smanip(ios& (*f)(ios&, TP), TP a) : _f(f), _a(a) {} - // - friend - istream& operator>>(istream& i, const smanip<TP>& m); - friend - ostream& operator<<(ostream& o, const smanip<TP>& m); -}; - -#ifdef __GNUG__ -extern template class smanip<int>; -extern template class smanip<ios::fmtflags>; -#endif - -template<class TP> -inline istream& operator>>(istream& i, const smanip<TP>& m) - { (*m._f)(i, m._a); return i; } - -template<class TP> -inline ostream& operator<<(ostream& o, const smanip<TP>& m) - { (*m._f)(o, m._a); return o;} - -#ifdef __GNUG__ -extern template istream& operator>>(istream&, const smanip<int>&); -extern template istream& operator>>(istream&, const smanip<ios::fmtflags>&); -extern template ostream& operator<<(ostream&, const smanip<int>&); -extern template ostream& operator<<(ostream&, const smanip<ios::fmtflags>&); -#endif - -//----------------------------------------------------------------------------- -// Input-Stream Manipulators -//----------------------------------------------------------------------------- -// -template<class TP> class imanip; - -template<class TP> class iapp { - istream& (*_f)(istream&, TP); -public: - iapp(istream& (*f)(istream&,TP)) : _f(f) {} - // - imanip<TP> operator()(TP a) - { return imanip<TP>(_f, a); } -}; - -template <class TP> class imanip { - istream& (*_f)(istream&, TP); - TP _a; -public: - imanip(istream& (*f)(istream&, TP), TP a) : _f(f), _a(a) {} - // - friend - istream& operator>>(istream& i, const imanip<TP>& m) - { return (*m._f)( i, m._a); } -}; - - -//----------------------------------------------------------------------------- -// Output-Stream Manipulators -//----------------------------------------------------------------------------- -// -template<class TP> class omanip; - -template<class TP> class oapp { - ostream& (*_f)(ostream&, TP); -public: - oapp(ostream& (*f)(ostream&,TP)) : _f(f) {} - // - omanip<TP> operator()(TP a) - { return omanip<TP>(_f, a); } -}; - -template <class TP> class omanip { - ostream& (*_f)(ostream&, TP); - TP _a; -public: - omanip(ostream& (*f)(ostream&, TP), TP a) : _f(f), _a(a) {} - // - friend - ostream& operator<<(ostream& o, const omanip<TP>& m) - { return (*m._f)(o, m._a); } -}; - - -//----------------------------------------------------------------------------- -// Available Manipulators -//----------------------------------------------------------------------------- - -// -// Macro to define an iomanip function, with one argument -// The underlying function is `__iomanip_<name>' -// -#define __DEFINE_IOMANIP_FN1(type,param,function) \ - extern ios& __iomanip_##function (ios&, param); \ - inline type<param> function (param n) \ - { return type<param> (__iomanip_##function, n); } - -__DEFINE_IOMANIP_FN1( smanip, int, setbase) -__DEFINE_IOMANIP_FN1( smanip, int, setfill) -__DEFINE_IOMANIP_FN1( smanip, int, setprecision) -__DEFINE_IOMANIP_FN1( smanip, int, setw) - -__DEFINE_IOMANIP_FN1( smanip, ios::fmtflags, resetiosflags) -__DEFINE_IOMANIP_FN1( smanip, ios::fmtflags, setiosflags) - -#endif /*!_IOMANIP_H*/ diff --git a/gnu/lib/libg++/include/iostream.h b/gnu/lib/libg++/include/iostream.h deleted file mode 100644 index 4802b37b0dea..000000000000 --- a/gnu/lib/libg++/include/iostream.h +++ /dev/null @@ -1,239 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#ifndef _IOSTREAM_H -#ifdef __GNUG__ -#pragma interface -#endif -#define _IOSTREAM_H - -#include <streambuf.h> - -class istream; class ostream; -typedef ios& (*__manip)(ios&); -typedef istream& (*__imanip)(istream&); -typedef ostream& (*__omanip)(ostream&); - -extern istream& ws(istream& ins); -extern ostream& flush(ostream& outs); -extern ostream& endl(ostream& outs); -extern ostream& ends(ostream& outs); - -class ostream : virtual public ios -{ - // NOTE: If fields are changed, you must fix _fake_ostream in stdstreams.C! - void do_osfx(); - public: - ostream() { } - ostream(streambuf* sb, ostream* tied=NULL); - int opfx() { - if (!good()) return 0; else { if (_tie) _tie->flush(); return 1;} } - void osfx() { if (flags() & (ios::unitbuf|ios::stdio)) - do_osfx(); } - ostream& flush(); - ostream& put(char c) { _strbuf->sputc(c); return *this; } -#ifdef _STREAM_COMPAT - /* Temporary binary compatibility. REMOVE IN NEXT RELEASE. */ - ostream& put(unsigned char c) { return put((char)c); } - ostream& put(signed char c) { return put((char)c); } -#endif - ostream& write(const char *s, int n); - ostream& write(const unsigned char *s, int n) { return write((const char*)s, n);} - ostream& write(const signed char *s, int n) { return write((const char*)s, n);} - ostream& write(const void *s, int n) { return write((const char*)s, n);} - ostream& seekp(streampos); - ostream& seekp(streamoff, _seek_dir); - streampos tellp(); - ostream& form(const char *format ...); - ostream& vform(const char *format, _IO_va_list args); - - ostream& operator<<(char c); - ostream& operator<<(unsigned char c) { return (*this) << (char)c; } - ostream& operator<<(signed char c) { return (*this) << (char)c; } - ostream& operator<<(const char *s); - ostream& operator<<(const unsigned char *s) - { return (*this) << (const char*)s; } - ostream& operator<<(const signed char *s) - { return (*this) << (const char*)s; } - ostream& operator<<(const void *p); - ostream& operator<<(int n); - ostream& operator<<(unsigned int n); - ostream& operator<<(long n); - ostream& operator<<(unsigned long n); -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) - ostream& operator<<(long long n); - ostream& operator<<(unsigned long long n); -#endif - ostream& operator<<(short n) {return operator<<((int)n);} - ostream& operator<<(unsigned short n) {return operator<<((unsigned int)n);} -#if _G_HAVE_BOOL - ostream& operator<<(bool b) { return operator<<((int)b); } -#endif - ostream& operator<<(double n); - ostream& operator<<(float n) { return operator<<((double)n); } - ostream& operator<<(long double n) { return operator<<((double)n); } - ostream& operator<<(__omanip func) { return (*func)(*this); } - ostream& operator<<(__manip func) {(*func)(*this); return *this;} - ostream& operator<<(streambuf*); -#ifdef _STREAM_COMPAT - streambuf* ostreambuf() const { return _strbuf; } -#endif -}; - -class istream : virtual public ios -{ - // NOTE: If fields are changed, you must fix _fake_istream in stdstreams.C! -protected: - _IO_size_t _gcount; - - int _skip_ws(); - public: - istream() { _gcount = 0; } - istream(streambuf* sb, ostream*tied=NULL); - istream& get(char* ptr, int len, char delim = '\n'); - istream& get(unsigned char* ptr, int len, char delim = '\n') - { return get((char*)ptr, len, delim); } - istream& get(char& c); - istream& get(unsigned char& c) { return get((char&)c); } - istream& getline(char* ptr, int len, char delim = '\n'); - istream& getline(unsigned char* ptr, int len, char delim = '\n') - { return getline((char*)ptr, len, delim); } - istream& get(signed char& c) { return get((char&)c); } - istream& get(signed char* ptr, int len, char delim = '\n') - { return get((char*)ptr, len, delim); } - istream& getline(signed char* ptr, int len, char delim = '\n') - { return getline((char*)ptr, len, delim); } - istream& read(char *ptr, int n); - istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); } - istream& read(signed char *ptr, int n) { return read((char*)ptr, n); } - istream& read(void *ptr, int n) { return read((char*)ptr, n); } - istream& get(streambuf& sb, char delim = '\n'); - istream& gets(char **s, char delim = '\n'); - int ipfx(int need) { - if (!good()) { set(ios::failbit); return 0; } - else { - if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush(); - if (!need && (flags() & ios::skipws)) return _skip_ws(); - else return 1; - } - } - int ipfx0() { // Optimized version of ipfx(0). - if (!good()) { set(ios::failbit); return 0; } - else { - if (_tie) _tie->flush(); - if (flags() & ios::skipws) return _skip_ws(); - else return 1; - } - } - int ipfx1() { // Optimized version of ipfx(1). - if (!good()) { set(ios::failbit); return 0; } - else { - if (_tie && rdbuf()->in_avail() == 0) _tie->flush(); - return 1; - } - } - void isfx() { } - int get() { if (!ipfx1()) return EOF; - else { int ch = _strbuf->sbumpc(); - if (ch == EOF) set(ios::eofbit); - return ch; - } } - int peek(); - _IO_size_t gcount() { return _gcount; } - istream& ignore(int n=1, int delim = EOF); - istream& seekg(streampos); - istream& seekg(streamoff, _seek_dir); - streampos tellg(); - istream& putback(char ch) { - if (good() && _strbuf->sputbackc(ch) == EOF) clear(ios::badbit); - return *this;} - istream& unget() { - if (good() && _strbuf->sungetc() == EOF) clear(ios::badbit); - return *this;} - istream& scan(const char *format ...); - istream& vscan(const char *format, _IO_va_list args); -#ifdef _STREAM_COMPAT - istream& unget(char ch) { return putback(ch); } - int skip(int i); - streambuf* istreambuf() const { return _strbuf; } -#endif - - istream& operator>>(char*); - istream& operator>>(unsigned char* p) { return operator>>((char*)p); } - istream& operator>>(signed char*p) { return operator>>((char*)p); } - istream& operator>>(char& c); - istream& operator>>(unsigned char& c) {return operator>>((char&)c);} - istream& operator>>(signed char& c) {return operator>>((char&)c);} - istream& operator>>(int&); - istream& operator>>(long&); -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) - istream& operator>>(long long&); - istream& operator>>(unsigned long long&); -#endif - istream& operator>>(short&); - istream& operator>>(unsigned int&); - istream& operator>>(unsigned long&); - istream& operator>>(unsigned short&); -#if _G_HAVE_BOOL - istream& operator>>(bool&); -#endif - istream& operator>>(float&); - istream& operator>>(double&); - istream& operator>>(long double&); - istream& operator>>( __manip func) {(*func)(*this); return *this;} - istream& operator>>(__imanip func) { return (*func)(*this); } - istream& operator>>(streambuf*); -}; - -class iostream : public istream, public ostream -{ - public: - iostream() { } - iostream(streambuf* sb, ostream*tied=NULL); -}; - -class _IO_istream_withassign : public istream { -public: - _IO_istream_withassign& operator=(istream&); -}; - -class _IO_ostream_withassign : public ostream { -public: - _IO_ostream_withassign& operator=(ostream&); -}; - -extern _IO_istream_withassign cin; -// clog->rdbuf() == cerr->rdbuf() -extern _IO_ostream_withassign cout, cerr, clog; - -struct Iostream_init { } ; // Compatibility hack for AT&T library. - -inline ios& dec(ios& i) -{ i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; } -inline ios& hex(ios& i) -{ i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; } -inline ios& oct(ios& i) -{ i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; } - -#endif /*!_IOSTREAM_H*/ diff --git a/gnu/lib/libg++/include/iostreamP.h b/gnu/lib/libg++/include/iostreamP.h deleted file mode 100644 index e24c93f115c7..000000000000 --- a/gnu/lib/libg++/include/iostreamP.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#include "streambuf.h" -#include "libioP.h" - -inline _IO_seekflags -convert_to_seekflags(int dir, int mode) -{ - return (_IO_seekflags)((int)dir - | (mode & ios::in ? _IO_seek_set : _IO_seek_not_in) - | (mode & ios::out ? _IO_seek_set : _IO_seek_not_out)); -} diff --git a/gnu/lib/libg++/include/libiberty.h b/gnu/lib/libg++/include/libiberty.h deleted file mode 100644 index 0a71c527862f..000000000000 --- a/gnu/lib/libg++/include/libiberty.h +++ /dev/null @@ -1,114 +0,0 @@ -/* Function declarations for libiberty. - Written by Cygnus Support, 1994. - - The libiberty library provides a number of functions which are - missing on some operating systems. We do not declare those here, - to avoid conflicts with the system header files on operating - systems that do support those functions. In this file we only - declare those functions which are specific to libiberty. */ - -#ifndef LIBIBERTY_H -#define LIBIBERTY_H - -#include "ansidecl.h" - -/* Build an argument vector from a string. Allocates memory using - malloc. Use freeargv to free the vector. */ - -extern char **buildargv PARAMS ((char *)); - -/* Free a vector returned by buildargv. */ - -extern void freeargv PARAMS ((char **)); - -/* Return the last component of a path name. */ - -extern char *basename PARAMS ((char *)); - -/* Concatenate an arbitrary number of strings, up to (char *) NULL. - Allocates memory using xmalloc. */ - -extern char *concat PARAMS ((const char *, ...)); - -/* Check whether two file descriptors refer to the same file. */ - -extern int fdmatch PARAMS ((int fd1, int fd2)); - -/* Get the amount of time the process has run, in microseconds. */ - -extern long get_run_time PARAMS ((void)); - -/* Allocate memory filled with spaces. Allocates using malloc. */ - -extern const char *spaces PARAMS ((int count)); - -/* Return the maximum error number for which strerror will return a - string. */ - -extern int errno_max PARAMS ((void)); - -/* Return the name of an errno value (e.g., strerrno (EINVAL) returns - "EINVAL"). */ - -extern const char *strerrno PARAMS ((int)); - -/* Given the name of an errno value, return the value. */ - -extern int strtoerrno PARAMS ((const char *)); - -/* Return the maximum signal number for which strsignal will return a - string. */ - -extern int signo_max PARAMS ((void)); - -/* Return a signal message string for a signal number - (e.g., strsignal (SIGHUP) returns something like "Hangup"). */ -/* This is commented out as it can conflict with one in system headers. - We still document its existence though. */ - -/*extern const char *strsignal PARAMS ((int));*/ - -/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns - "SIGHUP"). */ - -extern const char *strsigno PARAMS ((int)); - -/* Given the name of a signal, return its number. */ - -extern int strtosigno PARAMS ((const char *)); - -/* Register a function to be run by xexit. Returns 0 on success. */ - -extern int xatexit PARAMS ((void (*fn) (void))); - -/* Exit, calling all the functions registered with xatexit. */ - -#ifndef __GNUC__ -extern void xexit PARAMS ((int status)); -#else -typedef void libiberty_voidfn PARAMS ((int status)); -__volatile__ libiberty_voidfn xexit; -#endif - -/* Set the program name used by xmalloc. */ - -extern void xmalloc_set_program_name PARAMS ((const char *)); - -/* Allocate memory without fail. If malloc fails, this will print a - message to stderr (using the name set by xmalloc_set_program_name, - if any) and then call xexit. - - FIXME: We do not declare the parameter type (size_t) in order to - avoid conflicts with other declarations of xmalloc that exist in - programs which use libiberty. */ - -extern PTR xmalloc (); - -/* Reallocate memory without fail. This works like xmalloc. - - FIXME: We do not declare the parameter types for the same reason as - xmalloc. */ - -extern PTR xrealloc (); - -#endif /* ! defined (LIBIBERTY_H) */ diff --git a/gnu/lib/libg++/include/libio.h b/gnu/lib/libg++/include/libio.h deleted file mode 100644 index f00b730f5e2d..000000000000 --- a/gnu/lib/libg++/include/libio.h +++ /dev/null @@ -1,257 +0,0 @@ -/* -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -/* This is part of the iostream library. - Copyright (C) 1991, 1992 Per Bothner. */ - -#ifndef _IO_STDIO_H -#define _IO_STDIO_H - -#if 1 -#include <_G_config.h> -#define _IO_pos_t _G_fpos_t /* obsolete */ -#define _IO_fpos_t _G_fpos_t -#define _IO_size_t _G_size_t -#define _IO_ssize_t _G_ssize_t -#define _IO_off_t _G_off_t -#define _IO_pid_t _G_pid_t -#define _IO_uid_t _G_uid_t -#define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT -#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE -#define _IO_BUFSIZ _G_BUFSIZ -#define _IO_va_list _G_va_list - -#ifdef _G_NEED_STDARG_H -/* This define avoids name pollution if we're using GNU stdarg.h */ -#define __need___va_list -#include <stdarg.h> -#ifdef __GNUC_VA_LIST -#undef _IO_va_list -#define _IO_va_list __gnuc_va_list -#endif /* __GNUC_VA_LIST */ -#endif - -#else -#include <_IO_config.h> -typedef _IO_fpos_t _IO_pos_t; -#endif - -#ifndef __P -#ifdef __STDC__ -#define __P(paramlist) paramlist -#else -#define __P(paramlist) () -#endif -#endif /*!__P*/ - -/* For backward compatibility */ -#ifndef _PARAMS -#define _PARAMS(paramlist) __P(paramlist) -#endif /*!_PARAMS*/ - -#ifndef __STDC__ -#define const -#endif -#define _IO_USE_DTOA - -#if 0 -#ifdef _IO_NEED_STDARG_H -#include <stdarg.h> -#endif -#endif - -#ifndef EOF -#define EOF (-1) -#endif -#ifndef NULL -#if !defined(__cplusplus) || defined(__GNUC__) -#define NULL ((void*)0) -#else -#define NULL (0) -#endif -#endif - -#define _IOS_INPUT 1 -#define _IOS_OUTPUT 2 -#define _IOS_ATEND 4 -#define _IOS_APPEND 8 -#define _IOS_TRUNC 16 -#define _IOS_NOCREATE 32 -#define _IOS_NOREPLACE 64 -#define _IOS_BIN 128 - -/* Magic numbers and bits for the _flags field. - The magic numbers use the high-order bits of _flags; - the remaining bits are abailable for variable flags. - Note: The magic numbers must all be negative if stdio - emulation is desired. */ - -#define _IO_MAGIC 0xFBAD0000 /* Magic number */ -#define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */ -#define _IO_MAGIC_MASK 0xFFFF0000 -#define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */ -#define _IO_UNBUFFERED 2 -#define _IO_NO_READS 4 /* Reading not allowed */ -#define _IO_NO_WRITES 8 /* Writing not allowd */ -#define _IO_EOF_SEEN 0x10 -#define _IO_ERR_SEEN 0x20 -#define _IO_DELETE_DONT_CLOSE 0x40 -#define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/ -#define _IO_IN_BACKUP 0x100 -#define _IO_LINE_BUF 0x200 -#define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */ -#define _IO_CURRENTLY_PUTTING 0x800 -#define _IO_IS_APPENDING 0x1000 -#define _IO_IS_FILEBUF 0x2000 - -/* These are "formatting flags" matching the iostream fmtflags enum values. */ -#define _IO_SKIPWS 01 -#define _IO_LEFT 02 -#define _IO_RIGHT 04 -#define _IO_INTERNAL 010 -#define _IO_DEC 020 -#define _IO_OCT 040 -#define _IO_HEX 0100 -#define _IO_SHOWBASE 0200 -#define _IO_SHOWPOINT 0400 -#define _IO_UPPERCASE 01000 -#define _IO_SHOWPOS 02000 -#define _IO_SCIENTIFIC 04000 -#define _IO_FIXED 010000 -#define _IO_UNITBUF 020000 -#define _IO_STDIO 040000 -#define _IO_DONT_CLOSE 0100000 - -/* A streammarker remembers a position in a buffer. */ - -struct _IO_jump_t; struct _IO_FILE; - -struct _IO_marker { - struct _IO_marker *_next; - struct _IO_FILE *_sbuf; - /* If _pos >= 0 - it points to _buf->Gbase()+_pos. FIXME comment */ - /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */ - int _pos; -#if 0 - void set_streampos(streampos sp) { _spos = sp; } - void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); } - public: - streammarker(streambuf *sb); - ~streammarker(); - int saving() { return _spos == -2; } - int delta(streammarker&); - int delta(); -#endif -}; - -struct _IO_FILE { - int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ -#define _IO_file_flags _flags - - /* The following pointers correspond to the C++ streambuf protocol. */ - char* _IO_read_ptr; /* Current read pointer */ - char* _IO_read_end; /* End of get area. */ - char* _IO_read_base; /* Start of putback+get area. */ - char* _IO_write_base; /* Start of put area. */ - char* _IO_write_ptr; /* Current put pointer. */ - char* _IO_write_end; /* End of put area. */ - char* _IO_buf_base; /* Start of reserve area. */ - char* _IO_buf_end; /* End of reserve area. */ - /* The following fields are used to support backing up and undo. */ - char *_IO_save_base; /* Pointer to start of non-current get area. */ - char *_IO_backup_base; /* Pointer to first valid character of backup area */ - char *_IO_save_end; /* Pointer to end of non-current get area. */ - - struct _IO_marker *_markers; - - struct _IO_FILE *_chain; - - struct _IO_jump_t *_jumps; /* Jump table */ - - int _fileno; - int _blksize; - _IO_off_t _offset; - -#define __HAVE_COLUMN /* temporary */ - /* 1+column number of pbase(); 0 is unknown. */ - unsigned short _cur_column; - char _unused; - char _shortbuf[1]; - - /* char* _save_gptr; char* _save_egptr; */ -}; - -#ifndef __cplusplus -typedef struct _IO_FILE _IO_FILE; -#endif - -struct _IO_FILE_plus; -extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_; -#define _IO_stdin ((_IO_FILE*)(&_IO_stdin_)) -#define _IO_stdout ((_IO_FILE*)(&_IO_stdout_)) -#define _IO_stderr ((_IO_FILE*)(&_IO_stderr_)) - -#ifdef __cplusplus -extern "C" { -#endif - -extern int __underflow __P((_IO_FILE*)); -extern int __uflow __P((_IO_FILE*)); -extern int __overflow __P((_IO_FILE*, int)); - -extern unsigned __adjust_column __P((unsigned start, const char *line, int count)); - -#define _IO_getc(_fp) \ - ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow(_fp) \ - : *(unsigned char*)(_fp)->_IO_read_ptr++) -#define _IO_peekc(_fp) \ - ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \ - && __underflow(_fp) == EOF ? EOF \ - : *(unsigned char*)(_fp)->_IO_read_ptr) - -#define _IO_putc(_ch, _fp) \ - (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \ - ? __overflow(_fp, (unsigned char)(_ch)) \ - : (unsigned char)(*(_fp)->_IO_write_ptr++ = (_ch))) - -#define _IO_feof(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0) -#define _IO_ferror(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0) - -/* This one is for Emacs. */ -#define _IO_PENDING_OUTPUT_COUNT(_fp) \ - ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base) - -extern int _IO_vfscanf __P((_IO_FILE*, const char*, _IO_va_list, int*)); -extern int _IO_vfprintf __P((_IO_FILE*, const char*, _IO_va_list)); -extern _IO_ssize_t _IO_padn __P((_IO_FILE *, int, _IO_ssize_t)); -extern _IO_size_t _IO_sgetn __P((_IO_FILE *, void*, _IO_size_t)); - -extern void _IO_free_backup_area __P((_IO_FILE*)); - -#ifdef __cplusplus -} -#endif - -#endif /* _IO_STDIO_H */ diff --git a/gnu/lib/libg++/include/libioP.h b/gnu/lib/libg++/include/libioP.h deleted file mode 100644 index 074b9d7fa0cd..000000000000 --- a/gnu/lib/libg++/include/libioP.h +++ /dev/null @@ -1,326 +0,0 @@ -/* -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#include <errno.h> -#ifndef errno -extern int errno; -#endif - -#include "iolibio.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum _IO_seekflags_ { - _IO_seek_set = 0, - _IO_seek_cur = 1, - _IO_seek_end = 2, - - /* These bits are ignored unless the _IO_FILE has independent - read and write positions. */ - _IO_seek_not_in = 4, /* Don't move read posistion. */ - _IO_seek_not_out = 8, /* Don't move write posistion. */ - _IO_seek_pos_ignored = 16 /* Result is ignored (except EOF) */ -} _IO_seekflags; - -typedef int (*_IO_overflow_t) __P((_IO_FILE*, int)); -typedef int (*_IO_underflow_t) __P((_IO_FILE*)); -typedef _IO_size_t (*_IO_xsputn_t) __P((_IO_FILE*,const void*,_IO_size_t)); -typedef _IO_size_t (*_IO_xsgetn_t) __P((_IO_FILE*, void*, _IO_size_t)); -typedef _IO_ssize_t (*_IO_read_t) __P((_IO_FILE*, void*, _IO_ssize_t)); -typedef _IO_ssize_t (*_IO_write_t) __P((_IO_FILE*,const void*,_IO_ssize_t)); -typedef int (*_IO_stat_t) __P((_IO_FILE*, void*)); -typedef _IO_fpos_t (*_IO_seek_t) __P((_IO_FILE*, _IO_off_t, int)); -typedef int (*_IO_doallocate_t) __P((_IO_FILE*)); -typedef int (*_IO_pbackfail_t) __P((_IO_FILE*, int)); -typedef int (*_IO_setbuf_t) __P((_IO_FILE*, char *, _IO_ssize_t)); -typedef int (*_IO_sync_t) __P((_IO_FILE*)); -typedef void (*_IO_finish_t) __P((_IO_FILE*)); /* finalize */ -typedef int (*_IO_close_t) __P((_IO_FILE*)); /* finalize */ -typedef _IO_fpos_t (*_IO_seekoff_t) __P((_IO_FILE*, _IO_off_t, _IO_seekflags)); - -/* The _IO_seek_cur and _IO_seek_end options are not allowed. */ -typedef _IO_fpos_t (*_IO_seekpos_t) __P((_IO_FILE*, _IO_fpos_t, _IO_seekflags)); - -struct _IO_jump_t { - _IO_overflow_t __overflow; - _IO_underflow_t __underflow; - _IO_xsputn_t __xsputn; - _IO_xsgetn_t __xsgetn; - _IO_read_t __read; - _IO_write_t __write; - _IO_doallocate_t __doallocate; - _IO_pbackfail_t __pbackfail; - _IO_setbuf_t __setbuf; - _IO_sync_t __sync; - _IO_finish_t __finish; - _IO_close_t __close; - _IO_stat_t __stat; - _IO_seek_t __seek; - _IO_seekoff_t __seekoff; - _IO_seekpos_t __seekpos; - _IO_underflow_t __uflow; -#if 0 - get_column; - set_column; -#endif -}; - -/* We always allocate an extra word following an _IO_FILE. - This is for compatibility with C++ streambuf; the word can - be used to smash to a pointer to a virtual function table. */ - -struct _IO_FILE_plus { - _IO_FILE file; - const void *vtable; -}; - -/* Generic functions */ - -extern _IO_fpos_t _IO_seekoff __P((_IO_FILE*, _IO_off_t, _IO_seekflags)); -extern _IO_fpos_t _IO_seekpos __P((_IO_FILE*, _IO_fpos_t, _IO_seekflags)); - -extern int _IO_switch_to_get_mode __P((_IO_FILE*)); -extern void _IO_init __P((_IO_FILE*, int)); -extern int _IO_sputbackc __P((_IO_FILE*, int)); -extern int _IO_sungetc __P((_IO_FILE*)); -extern void _IO_un_link __P((_IO_FILE*)); -extern void _IO_link_in __P((_IO_FILE *)); -extern void _IO_doallocbuf __P((_IO_FILE*)); -extern void _IO_unsave_markers __P((_IO_FILE*)); -extern void _IO_setb __P((_IO_FILE*, char*, char*, int)); -extern unsigned _IO_adjust_column __P((unsigned, const char *, int)); -#define _IO_sputn(__fp, __s, __n) (__fp->_jumps->__xsputn(__fp, __s, __n)) - -/* Marker-related function. */ - -extern void _IO_init_marker __P((struct _IO_marker *, _IO_FILE *)); -extern void _IO_remove_marker __P((struct _IO_marker*)); -extern int _IO_marker_difference __P((struct _IO_marker *, struct _IO_marker *)); -extern int _IO_marker_delta __P((struct _IO_marker *)); -extern int _IO_seekmark __P((_IO_FILE *, struct _IO_marker *, int)); - -/* Default jumptable functions. */ - -extern int _IO_default_underflow __P((_IO_FILE*)); -extern int _IO_default_uflow _PARAMS((_IO_FILE*)); -extern int _IO_default_doallocate __P((_IO_FILE*)); -extern void _IO_default_finish __P((_IO_FILE *)); -extern int _IO_default_pbackfail __P((_IO_FILE*, int)); -extern int _IO_default_setbuf __P((_IO_FILE *, char*, _IO_ssize_t)); -extern _IO_size_t _IO_default_xsputn __P((_IO_FILE *, const void*, _IO_size_t)); -extern _IO_size_t _IO_default_xsgetn __P((_IO_FILE *, void*, _IO_size_t)); -extern _IO_fpos_t _IO_default_seekoff __P((_IO_FILE*, _IO_off_t, _IO_seekflags)); -extern _IO_fpos_t _IO_default_seekpos __P((_IO_FILE*, _IO_fpos_t, _IO_seekflags)); -extern _IO_ssize_t _IO_default_write __P((_IO_FILE*,const void*,_IO_ssize_t)); -extern _IO_ssize_t _IO_default_read __P((_IO_FILE*, void*, _IO_ssize_t)); -extern int _IO_default_stat __P((_IO_FILE*, void*)); -extern _IO_fpos_t _IO_default_seek __P((_IO_FILE*, _IO_off_t, int)); -extern int _IO_default_sync __P((_IO_FILE*)); -#define _IO_default_close ((_IO_close_t)_IO_default_sync) - -extern struct _IO_jump_t _IO_file_jumps; -extern struct _IO_jump_t _IO_streambuf_jumps; -extern struct _IO_jump_t _IO_proc_jumps; -extern struct _IO_jump_t _IO_str_jumps; -extern int _IO_do_write __P((_IO_FILE*, const char*, _IO_size_t)); -extern int _IO_flush_all __P((void)); -extern void _IO_cleanup __P((void)); -extern void _IO_flush_all_linebuffered __P((void)); - -#define _IO_do_flush(_f) \ - _IO_do_write(_f, (_f)->_IO_write_base, \ - (_f)->_IO_write_ptr-(_f)->_IO_write_base) -#define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING) -#define _IO_mask_flags(fp, f, mask) \ - ((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask))) -#define _IO_setg(fp, eb, g, eg) ((fp)->_IO_read_base = (eb),\ - (fp)->_IO_read_ptr = (g), (fp)->_IO_read_end = (eg)) -#define _IO_setp(__fp, __p, __ep) \ - ((__fp)->_IO_write_base = (__fp)->_IO_write_ptr = __p, (__fp)->_IO_write_end = (__ep)) -#define _IO_have_backup(fp) ((fp)->_IO_save_base != NULL) -#define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP) -#define _IO_have_markers(fp) ((fp)->_markers != NULL) -#define _IO_blen(p) ((fp)->_IO_buf_end - (fp)->_IO_buf_base) - -/* Jumptable functions for files. */ - -extern int _IO_file_doallocate __P((_IO_FILE*)); -extern int _IO_file_setbuf __P((_IO_FILE *, char*, _IO_ssize_t)); -extern _IO_fpos_t _IO_file_seekoff __P((_IO_FILE*, _IO_off_t, _IO_seekflags)); -extern _IO_size_t _IO_file_xsputn __P((_IO_FILE*,const void*,_IO_size_t)); -extern int _IO_file_stat __P((_IO_FILE*, void*)); -extern int _IO_file_close __P((_IO_FILE*)); -extern int _IO_file_underflow __P((_IO_FILE *)); -extern int _IO_file_overflow __P((_IO_FILE *, int)); -#define _IO_file_is_open(__fp) ((__fp)->_fileno >= 0) -extern void _IO_file_init __P((_IO_FILE*)); -extern _IO_FILE* _IO_file_attach __P((_IO_FILE*, int)); -extern _IO_FILE* _IO_file_fopen __P((_IO_FILE*, const char*, const char*)); -extern _IO_ssize_t _IO_file_write __P((_IO_FILE*,const void*,_IO_ssize_t)); -extern _IO_ssize_t _IO_file_read __P((_IO_FILE*, void*, _IO_ssize_t)); -extern int _IO_file_sync __P((_IO_FILE*)); -extern int _IO_file_close_it __P((_IO_FILE*)); -extern _IO_fpos_t _IO_file_seek __P((_IO_FILE *, _IO_off_t, int)); -extern void _IO_file_finish __P((_IO_FILE*)); - -/* Other file functions. */ -extern _IO_FILE* _IO_file_attach __P((_IO_FILE *, int)); - -/* Jumptable functions for proc_files. */ -extern _IO_FILE* _IO_proc_open __P((_IO_FILE*, const char*, const char *)); -extern int _IO_proc_close __P((_IO_FILE*)); - -/* Jumptable functions for strfiles. */ -extern int _IO_str_underflow __P((_IO_FILE*)); -extern int _IO_str_overflow __P((_IO_FILE *, int)); -extern int _IO_str_pbackfail __P((_IO_FILE*, int)); -extern _IO_fpos_t _IO_str_seekoff __P((_IO_FILE*,_IO_off_t,_IO_seekflags)); - -/* Other strfile functions */ -extern void _IO_str_init_static __P((_IO_FILE *, char*, int, char*)); -extern void _IO_str_init_readonly __P((_IO_FILE *, const char*, int)); -extern _IO_ssize_t _IO_str_count __P ((_IO_FILE*)); - -extern _IO_size_t _IO_getline __P((_IO_FILE*,char*,_IO_size_t,int,int)); -extern _IO_ssize_t _IO_getdelim __P((char**, _IO_size_t*, int, _IO_FILE*)); -extern double _IO_strtod __P((const char *, char **)); -extern char * _IO_dtoa __P((double __d, int __mode, int __ndigits, - int *__decpt, int *__sign, char **__rve)); -extern int _IO_outfloat __P((double __value, _IO_FILE *__sb, int __type, - int __width, int __precision, int __flags, - int __sign_mode, int __fill)); - -extern _IO_FILE *_IO_list_all; -extern void (*_IO_cleanup_registration_needed) __P ((void)); - -#ifndef EOF -#define EOF (-1) -#endif -#ifndef NULL -#if !defined(__cplusplus) || defined(__GNUC__) -#define NULL ((void*)0) -#else -#define NULL (0) -#endif -#endif - -#define FREE_BUF(_B) free(_B) -#define ALLOC_BUF(_S) (char*)malloc(_S) - -#ifndef OS_FSTAT -#define OS_FSTAT fstat -#endif -struct stat; -extern _IO_ssize_t _IO_read __P((int, void*, _IO_size_t)); -extern _IO_ssize_t _IO_write __P((int, const void*, _IO_size_t)); -extern _IO_off_t _IO_lseek __P((int, _IO_off_t, int)); -extern int _IO_close __P((int)); -extern int _IO_fstat __P((int, struct stat *)); - -/* Operations on _IO_fpos_t. - Normally, these are trivial, but we provide hooks for configurations - where an _IO_fpos_t is a struct. - Note that _IO_off_t must be an integral type. */ - -/* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */ -#ifndef _IO_pos_BAD -#define _IO_pos_BAD ((_IO_fpos_t)(-1)) -#endif -/* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */ -#ifndef _IO_pos_as_off -#define _IO_pos_as_off(__pos) ((_IO_off_t)(__pos)) -#endif -/* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */ -#ifndef _IO_pos_adjust -#define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta)) -#endif -/* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */ -#ifndef _IO_pos_0 -#define _IO_pos_0 ((_IO_fpos_t)0) -#endif - -#ifdef __cplusplus -} -#endif - -/* check following! */ -#define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \ - { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, &_IO_file_jumps, FD} - -/* Define builtinbuf_vtable as a name for the virtual function table - of the builtinbuf class. */ -#if !defined(builtinbuf_vtable) && defined(__cplusplus) -#ifdef __GNUC__ -extern char builtinbuf_vtable[] - asm (_G_VTABLE_LABEL_PREFIX -#if _G_VTABLE_LABEL_HAS_LENGTH - "10" -#endif - "builtinbuf"); -#else /* !__GNUC__ */ -#if _G_VTABLE_LABEL_HAS_LENGTH -#define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf -#else -#define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf -#endif -extern char builtinbuf_vtable[]; -#endif /* !__GNUC__ */ -#endif /* !defined(builtinbuf_vtable) && defined(__cplusplus) */ - -#if defined(__STDC__) || defined(__cplusplus) -#define _IO_va_start(args, last) va_start(args, last) -#else -#define _IO_va_start(args, last) va_start(args) -#endif - -extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf; - -#if 1 -#define COERCE_FILE(FILE) /* Nothing */ -#else -/* This is part of the kludge for binary compatibility with old stdio. */ -#define COERCE_FILE(FILE) \ - (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \ - && (FILE) = *(FILE**)&((int*)fp)[1]) -#endif - -#ifdef EINVAL -#define MAYBE_SET_EINVAL errno = EINVAL -#else -#define MAYBE_SET_EINVAL /* nothing */ -#endif - -#ifdef DEBUG -#define CHECK_FILE(FILE,RET) \ - if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \ - else { COERCE_FILE(FILE); \ - if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \ - { errno = EINVAL; return RET; }} -#else -#define CHECK_FILE(FILE,RET) \ - COERCE_FILE(FILE) -#endif diff --git a/gnu/lib/libg++/include/new.h b/gnu/lib/libg++/include/new.h deleted file mode 100644 index 61bbba5cc99e..000000000000 --- a/gnu/lib/libg++/include/new.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _new_h -#ifdef __GNUG__ -#pragma interface -#endif -#define _new_h 1 - -#include <defines.h> - -#ifndef NO_LIBGXX_MALLOC -#define MALLOC_ALIGN_MASK 7 /* ptrs aligned at 8 byte boundaries */ -#define MALLOC_MIN_OVERHEAD 8 /* 8 bytes of overhead per pointer */ -#endif - -extern "C" fvoid_t *set_new_handler(fvoid_t *); - -#ifdef __GNUG__ -extern fvoid_t *__new_handler; -extern "C" void __default_new_handler(); - -#define NEW(where) new ( where ) -#endif - -// default placement version of operator new -inline void *operator new(size_t, void *place) { return place; } -inline void *operator new[](size_t, void *place) { return place; } - -#endif diff --git a/gnu/lib/libg++/include/osfcn.h b/gnu/lib/libg++/include/osfcn.h deleted file mode 100644 index 023b5c5b65d6..000000000000 --- a/gnu/lib/libg++/include/osfcn.h +++ /dev/null @@ -1,17 +0,0 @@ - -#ifndef OSFCN_H -#define OSFCN_H 1 - -#include <std.h> -#include <time.h> -#include <sys/types.h> -#if _G_HAVE_SYS_SOCKET -#include <sys/socket.h> -#endif -#if _G_HAVE_SYS_RESOURCE -#include <sys/time.h> -#include <sys/resource.h> -#endif - - -#endif diff --git a/gnu/lib/libg++/include/parsestream.h b/gnu/lib/libg++/include/parsestream.h deleted file mode 100644 index c0dfce2c51fb..000000000000 --- a/gnu/lib/libg++/include/parsestream.h +++ /dev/null @@ -1,154 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. - -Written by Per Bothner (bothner@cygnus.com). */ - -#ifndef PARSESTREAM_H -#define PARSESTREAM_H -#ifdef __GNUG__ -#pragma interface -#endif -#include "streambuf.h" - -// A parsebuf is a streambuf optimized for scanning text files. -// It keeps track of line and column numbers. -// It is guaranteed to remember the entire current line, -// as well the '\n'-s on either side of it (if they exist). -// You can arbitrarily seek (or unget) within this extended line. -// Other backward seeks are not supported. -// Normal read semantics are supported (and hence istream operators like >>). - -class parsebuf : public streambuf { - protected: - _IO_fpos_t pos_at_line_start; - long _line_length; - unsigned long __line_number; - char *buf_start; - char *buf_end; - - public: - parsebuf *chain; - - // Return column number (raw - don't handle tabs etc). - // Retult can be -1, meaning: at '\n' before current line. - virtual int tell_in_line(); - - // seek to (raw) column I in current line. - // Result is new (raw) column position - differs from I if unable to seek. - // Seek to -1 tries to seek to before previous LF. - virtual int seek_in_line(int i); - - // Note: there is no "current line" initially, until something is read. - - // Current line number, starting with 0. - // If tell_in_line()==-1, then line number of next line. - int line_number() { return __line_number; } - - // Length of current line, not counting either '\n'. - int line_length() { return _line_length; } - // Current line - not a copy, so file ops may trash it. - virtual char* current_line(); - virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); - virtual streambuf* setbuf(char* p, int len); - protected: - parsebuf() { chain= NULL; - __line_number = 0; pos_at_line_start = 0; _line_length = -1; } - virtual int pbackfail(int c); -}; - -// A string_parsebuf is a parsebuf whose source is a fixed string. - -class string_parsebuf : public parsebuf { - public: - int do_delete; - string_parsebuf(char *str, int len, int delete_at_close=0); - virtual int underflow(); - virtual char* current_line(); - virtual int seek_in_line(int i); - virtual int tell_in_line(); - char *left() const { return base(); } - char *right() const { return ebuf(); } -// streampos seekoff(streamoff, _seek_dir, int); -}; - -// A func_parsebuf calls a given function to get new input. -// Each call returns an entire NUL-terminated line (without the '\n'). -// That line has been allocated with malloc(), not new. -// The interface is tailored to the GNU readline library. -// Example: -// char* DoReadLine(void* arg) -// { -// char *line = readline((char*)arg); /* 'arg' is used as prompt. */ -// if line == NULL) { putc('\n', stderr); return NULL; } -// if (line[0] != '\0') add_history(line); -// return line; -// } -// char PromptBuffer[100] = "> "; -// func_parsebuf my_stream(DoReadLine, PromptBuffer); - -typedef char *(*CharReader)(void *arg); -class istream; - -class func_parsebuf : public parsebuf { - public: - void *arg; - CharReader read_func; - int backed_up_to_newline; - func_parsebuf(CharReader func, void *argm = NULL); - int underflow(); - virtual int tell_in_line(); - virtual int seek_in_line(int i); - virtual char* current_line(); -}; - -// A general_parsebuf is a parsebuf which gets its input from some -// other streambuf. It explicitly buffers up an entire line. - -class general_parsebuf : public parsebuf { - public: - streambuf *sbuf; - int delete_buf; // Delete sbuf when destroying this. - general_parsebuf(streambuf *buf, int delete_arg_buf = 0); - int underflow(); - virtual int tell_in_line(); - virtual int seek_in_line(int i); - ~general_parsebuf(); - virtual char* current_line(); -}; - -#if 0 -class parsestream : public istream { - streammarker marks[2]; - short _first; // of the two marks; either 0 or 1 - int _lineno; - int first() { return _first; } - int second() { return 1-_first; } - int line_length() { marks[second].delta(marks[first]); } - int line_length() { marks[second].delta(marks[first]); } - int seek_in_line(int i); - int tell_in_line(); - int line_number(); -}; -#endif -#endif /*!defined(PARSESTREAM_H)*/ diff --git a/gnu/lib/libg++/include/pfstream.h b/gnu/lib/libg++/include/pfstream.h deleted file mode 100644 index 687faf6c6546..000000000000 --- a/gnu/lib/libg++/include/pfstream.h +++ /dev/null @@ -1,57 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -/* Written by Per Bothner (bothner@cygnus.com). */ - -#ifndef _PFSTREAM_H -#define _PFSTREAM_H -#ifdef __GNUG__ -#pragma interface -#endif -#include <fstream.h> - -// ipfstream foo("NAME") is like: ifstream foo("NAME"). However, -// if NAME starts *or ends* with a '|', the remainder of NAME is -// evaluated as a shell command (using a procbuf), and all input -// read from foo is whatever that shell writes to its standard output. -// E.g. ipfstream foo("|zcat foo.Z") or ipfstream foo("zcat foo.Z|") -// (These two forms are equivalent.) - -class ipfstream : public ifstream { - public: - ipfstream(const char *name, int mode=ios::in, int prot=0664); -}; - -// opfstream foo("NAME") is like: ofstream foo("NAME"). -// However, if NAME starts with a '|', the remainder of NAME is -// evaluated as a shell command (using a procbuf), and all output -// written to foo is piped to the standard input of that shell. -// E.g. opfstream foo("|more"); - -class opfstream : public ofstream { - public: - opfstream(const char *name, int mode=ios::out, int prot=0664); -}; -#endif /*!_PFSTREAM_H*/ - diff --git a/gnu/lib/libg++/include/procbuf.h b/gnu/lib/libg++/include/procbuf.h deleted file mode 100644 index 092d9cf9bff9..000000000000 --- a/gnu/lib/libg++/include/procbuf.h +++ /dev/null @@ -1,39 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -/* Written by Per Bothner (bothner@cygnus.com). */ - -#include <streambuf.h> - -class procbuf : public filebuf { - /* Following fields must match those in struct _IO_proc_file */ - _IO_pid_t _pid; - public: - procbuf() : filebuf() { } - procbuf(const char *command, int mode); - procbuf* open(const char *command, int mode); - procbuf *close() { return (procbuf*)filebuf::close(); } - virtual int sys_close(); - ~procbuf(); -}; diff --git a/gnu/lib/libg++/include/rx.h b/gnu/lib/libg++/include/rx.h deleted file mode 100644 index edb26b4a8c00..000000000000 --- a/gnu/lib/libg++/include/rx.h +++ /dev/null @@ -1,3261 +0,0 @@ -#if !defined(RXH) || defined(RX_WANT_SE_DEFS) -#define RXH - -/* Copyright (C) 1992, 1993 Free Software Foundation, Inc. - -This file is part of the librx library. - -Librx is free software; you can redistribute it and/or modify it under -the terms of the GNU Library General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -Librx is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU Library General Public -License along with this software; see the file COPYING.LIB. If not, -write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA -02139, USA. */ -/* t. lord Wed Sep 23 18:20:57 1992 */ - - - - - - - - -#ifndef RX_WANT_SE_DEFS - -/* This page: Bitsets */ - -#ifndef RX_subset -typedef unsigned int RX_subset; -#define RX_subset_bits (32) -#define RX_subset_mask (RX_subset_bits - 1) -#endif - -typedef RX_subset * rx_Bitset; - -#ifdef __STDC__ -typedef void (*rx_bitset_iterator) (void *, int member_index); -#else -typedef void (*rx_bitset_iterator) (); -#endif - -#define rx_bitset_subset(N) ((N) / RX_subset_bits) -#define rx_bitset_subset_val(B,N) ((B)[rx_bitset_subset(N)]) -#define RX_bitset_access(B,N,OP) \ - ((B)[rx_bitset_subset(N)] OP rx_subset_singletons[(N) & RX_subset_mask]) -#define RX_bitset_member(B,N) RX_bitset_access(B, N, &) -#define RX_bitset_enjoin(B,N) RX_bitset_access(B, N, |=) -#define RX_bitset_remove(B,N) RX_bitset_access(B, N, &= ~) -#define RX_bitset_toggle(B,N) RX_bitset_access(B, N, ^= ) -#define rx_bitset_numb_subsets(N) (((N) + RX_subset_bits - 1) / RX_subset_bits) -#define rx_sizeof_bitset(N) (rx_bitset_numb_subsets(N) * sizeof(RX_subset)) - - - -/* This page: Splay trees. */ - -#ifdef __STDC__ -typedef int (*rx_sp_comparer) (void * a, void * b); -#else -typedef int (*rx_sp_comparer) (); -#endif - -struct rx_sp_node -{ - void * key; - void * data; - struct rx_sp_node * kids[2]; -}; - -#ifdef __STDC__ -typedef void (*rx_sp_key_data_freer) (struct rx_sp_node *); -#else -typedef void (*rx_sp_key_data_freer) (); -#endif - - -/* giant inflatable hash trees */ - -struct rx_hash_item -{ - struct rx_hash_item * next_same_hash; - struct rx_hash * table; - unsigned long hash; - void * data; - void * binding; -}; - -struct rx_hash -{ - struct rx_hash * parent; - int refs; - struct rx_hash * children[13]; - struct rx_hash_item * buckets [13]; - int bucket_size [13]; -}; - -struct rx_hash_rules; - -#ifdef __STDC__ -/* should return like == */ -typedef int (*rx_hash_eq)(void *, void *); -typedef struct rx_hash * (*rx_alloc_hash)(struct rx_hash_rules *); -typedef void (*rx_free_hash)(struct rx_hash *, - struct rx_hash_rules *); -typedef struct rx_hash_item * (*rx_alloc_hash_item)(struct rx_hash_rules *, - void *); -typedef void (*rx_free_hash_item)(struct rx_hash_item *, - struct rx_hash_rules *); -#else -typedef int (*rx_hash_eq)(); -typedef struct rx_hash * (*rx_alloc_hash)(); -typedef void (*rx_free_hash)(); -typedef struct rx_hash_item * (*rx_alloc_hash_item)(); -typedef void (*rx_free_hash_item)(); -#endif - -struct rx_hash_rules -{ - rx_hash_eq eq; - rx_alloc_hash hash_alloc; - rx_free_hash free_hash; - rx_alloc_hash_item hash_item_alloc; - rx_free_hash_item free_hash_item; -}; - - - -/* Matchers decide what to do by examining a series of these. - * Instruction types are described below. - */ -struct rx_inx -{ - void * inx; - void * data; - void * data_2; - void * fnord; -}; - -/* Struct RX holds a compiled regular expression - that is, an nfa ready to be - * converted on demand to a more efficient nfa. This is for the low level interface. - * The high-level interface incloses this in a `struct re_pattern_buffer'. - */ -struct rx_cache; -#ifdef __STDC__ -struct rx_se_list; -struct rx; -typedef int (*rx_se_list_order) (struct rx *, - struct rx_se_list *, struct rx_se_list *); -#else -typedef int (*rx_se_list_order) (); -#endif - -struct rx_superset; - -struct rx -{ - int rx_id; /* Every edition numbered and signed by eclose_nfa. */ - - struct rx_cache * cache; /* Where superstates come from */ - - /* Every regex defines the size of its own character set. */ - int local_cset_size; - - void * buffer; /* Malloced memory for the nfa. */ - unsigned long allocated; /* Size of that memory. */ - - /* How much buffer space to save for external uses. After compilation, - * this space will be available at (buffer + allocated - reserved) - */ - unsigned long reserved; - - /* --------- The remaining fields are for internal use only. --------- */ - /* --------- But! they should be initialized to 0. --------- */ - /* NODEC is the number of nodes in the NFA with non-epsilon - * orx transitions. - */ - int nodec; - - /* EPSNODEC is the number of nodes with only epsilon (orx) transitions. */ - int epsnodec; - - /* The sum of NODEC & EPSNODEC is the total number of states in the - * compiled NFA. - */ - - /* side_effect_progs temporarily holds a tree of side effect lists. */ - struct rx_hash se_list_memo; - - /* A memo for sets of states in the possible_future lists of an nfa: */ - struct rx_hash set_list_memo; - - /* The instruction table is indexed by the enum of instructions defined in - * rxrun.h. The values in the table are used to fill in the `inx' - * slot of instruction frames (see rxrun.h). - */ - void ** instruction_table; - struct rx_nfa_state *nfa_states; - struct rx_nfa_state *start; - - /* This orders the search through super-nfa paths. */ - rx_se_list_order se_list_cmp; - - struct rx_superset * start_set; -}; - -/* An RX NFA may contain epsilon edges labeled with side effects. - * These side effects represent match actions that can not normally be - * defined in a `pure' NFA; for example, recording the location at - * which a paren is crossed in a register structure. - * - * A matcher is supposed to find a particular path - * through the NFA (such as leftmost-longest), and then to execute the - * side effects along that path. Operationally, the space of paths is - * searched and side effects are carried out incrementally, and with - * backtracking. - * - * As the NFA is manipulated during matching sets of side effects. - * Simple lists are used to hold side effect lists. - */ - -typedef void * rx_side_effect; - -struct rx_se_list -{ - rx_side_effect car; - struct rx_se_list * cdr; -}; - - - -/* Struct rexp_node holds an expression tree that represents a regexp. - * In this expression tree, every node has a type, and some parameters - * appropriate to that type. - */ - -enum rexp_node_type -{ - r_cset, /* Match from a character set. `a' or `[a-z]'*/ - r_concat, /* Concat two regexps. `ab' */ - r_alternate, /* Choose one of two regexps. `a\|b' */ - r_opt, /* Optional regexp. `a?' */ - r_star, /* Repeated regexp. `a*' */ - r_2phase_star, /* hard to explain */ - r_side_effect, /* Matches the empty string, but - * implies that a side effect must - * take place. These nodes are used - * by the parser to implement parens, - * backreferences etc. - */ - - r_data /* R_DATA is soley for the convenience - * of parsers or other rexp - * transformers that want to - * (temporarily) introduce new node - * types in rexp structures. These - * must be eliminated - * by the time build_nfa is called. - */ -}; - -struct rexp_node -{ - enum rexp_node_type type; - union - { - rx_Bitset cset; - rx_side_effect side_effect; - struct - { - struct rexp_node *left; - struct rexp_node *right; - } pair; - void * data; - } params; -}; - - - -/* This defines the structure of the NFA into which rexps are compiled. */ - -struct rx_nfa_state -{ - int id; - struct rx_nfa_edge *edges; - struct rx_possible_future *futures; - unsigned int is_final:1; - unsigned int is_start:1; - unsigned int eclosure_needed:1; - struct rx_nfa_state *next; - unsigned int mark:1; -}; - -enum rx_nfa_etype -{ - ne_cset, - ne_epsilon, - ne_side_effect /* A special kind of epsilon. */ -}; - -struct rx_nfa_edge -{ - struct rx_nfa_edge *next; - enum rx_nfa_etype type; - struct rx_nfa_state *dest; - union - { - rx_Bitset cset; - rx_side_effect side_effect; - } params; -}; - -struct rx_nfa_state_set -{ - struct rx_nfa_state * car; - struct rx_nfa_state_set * cdr; -}; - -struct rx_possible_future -{ - struct rx_possible_future *next; - struct rx_se_list * effects; - struct rx_nfa_state_set * destset; -}; - - - -enum rx_opcode -{ - /* - * BACKTRACK_POINT is invoked when a transition results in more - * than one possible future. - * - * There is one occurence of this instruction per transition_class - * structure; that occurence is only ever executed if the - * transition_class contains a list of more than 1 edge. - */ - rx_backtrack_point = 0, /* data is (struct transition_class *) */ - - /* - * RX_DO_SIDE_EFFECTS evaluates the side effects of an epsilon path. - * There is one occurence of this instruction per rx_distinct_future. - * This instruction is skipped if a rx_distinct_future has no side effects. - */ - rx_do_side_effects = rx_backtrack_point + 1, - /* data is (struct rx_distinct_future *) */ - - /* - * RX_CACHE_MISS instructions are stored in rx_distinct_futures whose - * destination superstate has been reclaimed (or was never built). - * It recomputes the destination superstate. - * RX_CACHE_MISS is also stored in a superstate transition table before - * any of its edges have been built. - */ - rx_cache_miss = rx_do_side_effects + 1, - /* data is (struct rx_distinct_future *) */ - - /* - * RX_NEXT_CHAR is called to consume the next character and take the - * corresponding transition. This is the only instruction that uses - * the DATA field of the instruction frame instead of DATA_2. - * (see EXPLORE_FUTURE in regex.c). - */ - rx_next_char = rx_cache_miss + 1, /* data is (struct superstate *) */ - - /* RX_BACKTRACK indicates that a transition fails. - */ - rx_backtrack = rx_next_char + 1, /* no data */ - - /* - * RX_ERROR_INX is stored only in places that should never be executed. - */ - rx_error_inx = rx_backtrack + 1, /* Not supposed to occur. */ - - rx_num_instructions = rx_error_inx + 1 -}; - -/* An id_instruction_table holds the values stored in instruction - * frames. The table is indexed by the enums declared above. - */ -extern void * rx_id_instruction_table[rx_num_instructions]; - -#if 0 /* Already declared way above. */ -/* If the instruction is `rx_next_char' then data is valid. Otherwise it's 0 - * and data_2 is valid. - */ -struct rx_inx -{ - void * inx; - void * data; - void * data_2; -}; -#endif - - -#ifndef RX_TAIL_ARRAY -#define RX_TAIL_ARRAY 1 -#endif - -/* A superstate corresponds to a set of nfa states. Those sets are - * represented by STRUCT RX_SUPERSET. The constructors - * guarantee that only one (shared) structure is created for a given set. - */ -struct rx_superset -{ - int refs; - struct rx_nfa_state * car; /* May or may not be a valid addr. */ - int id; /* == car->id for the initial value of *car */ - struct rx_superset * cdr; /* May be NULL or a live or semifreed super*/ - - /* If the corresponding superstate exists: */ - struct rx_superstate * superstate; - - /* If this is a starting state (as built by re_search_2) - * this points to the `struct rx'. The memory for these objects - * is typed -- so even after they are freed it is safe to look - * at this field (to check, in fact, if this was freed.) - */ - struct rx * starts_for; - - struct rx_hash_item hash_item; -}; - -#define rx_protect_superset(RX,CON) (++(CON)->refs) - -/* Every character occurs in at most one super edge per super-state. - * But, that edge might have more than one option, indicating a point - * of non-determinism. - */ -struct rx_super_edge -{ - struct rx_super_edge *next; - struct rx_inx rx_backtrack_frame; - int cset_size; - rx_Bitset cset; - struct rx_distinct_future *options; -}; - -/* A superstate is a set of nfa states (RX_SUPERSET) along - * with a transition table. Superstates are built on demand and reclaimed - * without warning. To protect a superstate, use LOCK_SUPERSTATE. - * - * Joe Keane thought of calling these superstates and several people - * have commented on what a good name it is for what they do. - */ -struct rx_superstate -{ - int rx_id; - int locks; - struct rx_superstate * next_recyclable; - struct rx_superstate * prev_recyclable; - struct rx_distinct_future * transition_refs; - struct rx_superset * contents; - struct rx_super_edge * edges; - int is_semifree; - int trans_size; - struct rx_inx transitions[RX_TAIL_ARRAY]; /* cset sized */ -}; - -struct rx_distinct_future -{ - struct rx_distinct_future * next_same_super_edge[2]; - struct rx_distinct_future * next_same_dest; - struct rx_distinct_future * prev_same_dest; - struct rx_superstate * present; /* source state */ - struct rx_superstate * future; /* destination state */ - struct rx_super_edge * edge; - struct rx_inx future_frame; - struct rx_inx side_effects_frame; - struct rx_se_list * effects; -}; - -#define rx_lock_superstate(R,S) ((S)->locks++) -#define rx_unlock_superstate(R,S) (--(S)->locks) - - -/* This page destined for rx.h */ - -struct rx_blocklist -{ - struct rx_blocklist * next; - int bytes; -}; - -struct rx_freelist -{ - struct rx_freelist * next; -}; - -struct rx_cache; - -#ifdef __STDC__ -typedef void (*rx_morecore_fn)(struct rx_cache *); -#else -typedef void (*rx_morecore_fn)(); -#endif - -/* You use this to control the allocation of superstate data - * during matching. Most of it should be initialized to 0. - * - * A MORECORE function is necessary. It should allocate - * a new block of memory or return 0. - * A default that uses malloc is called `rx_morecore'. - * - * The number of SUPERSTATES_ALLOWED indirectly limits how much memory - * the system will try to allocate. The default is 128. Batch style - * applications that are very regexp intensive should use as high a number - * as possible without thrashing. - * - * The LOCAL_CSET_SIZE is the number of characters in a character set. - * It is therefore the number of entries in a superstate transition table. - * Generally, it should be 256. If your character set has 16 bits, - * it is better to translate your regexps into equivalent 8 bit patterns. - */ - -struct rx_cache -{ - struct rx_hash_rules superset_hash_rules; - - /* Objects are allocated by incrementing a pointer that - * scans across rx_blocklists. - */ - struct rx_blocklist * memory; - struct rx_blocklist * memory_pos; - int bytes_left; - char * memory_addr; - rx_morecore_fn morecore; - - /* Freelists. */ - struct rx_freelist * free_superstates; - struct rx_freelist * free_transition_classes; - struct rx_freelist * free_discernable_futures; - struct rx_freelist * free_supersets; - struct rx_freelist * free_hash; - - /* Two sets of superstates -- those that are semifreed, and those - * that are being used. - */ - struct rx_superstate * lru_superstate; - struct rx_superstate * semifree_superstate; - - struct rx_superset * empty_superset; - - int superstates; - int semifree_superstates; - int hits; - int misses; - int superstates_allowed; - - int local_cset_size; - void ** instruction_table; - - struct rx_hash superset_table; -}; - - - -/* The lowest-level search function supports arbitrarily fragmented - * strings and (optionally) suspendable/resumable searches. - * - * Callers have to provide a few hooks. - */ - -#ifndef __GNUC__ -#ifdef __STDC__ -#define __const__ const -#else -#define __const__ -#endif -#endif - -/* This holds a matcher position */ -struct rx_string_position -{ - __const__ unsigned char * pos; /* The current pos. */ - __const__ unsigned char * string; /* The current string burst. */ - __const__ unsigned char * end; /* First invalid position >= POS. */ - int offset; /* Integer address of the current burst. */ - int size; /* Current string's size. */ - int search_direction; /* 1 or -1 */ - int search_end; /* First position to not try. */ -}; - - -enum rx_get_burst_return -{ - rx_get_burst_continuation, - rx_get_burst_error, - rx_get_burst_ok, - rx_get_burst_no_more -}; - - -/* A call to get burst should make POS valid. It might be invalid - * if the STRING field doesn't point to a burst that actually - * contains POS. - * - * GET_BURST should take a clue from SEARCH_DIRECTION (1 or -1) as to - * whether or not to pad to the left. Padding to the right is always - * appropriate, but need not go past the point indicated by STOP. - * - * If a continuation is returned, then the reentering call to - * a search function will retry the get_burst. - */ - -#ifdef __STDC__ -typedef enum rx_get_burst_return - (*rx_get_burst_fn) (struct rx_string_position * pos, - void * app_closure, - int stop); - -#else -typedef enum rx_get_burst_return (*rx_get_burst_fn) (); -#endif - - -enum rx_back_check_return -{ - rx_back_check_continuation, - rx_back_check_error, - rx_back_check_pass, - rx_back_check_fail -}; - -/* Back_check should advance the position it is passed - * over rparen - lparen characters and return pass iff - * the characters starting at POS match those indexed - * by [LPAREN..RPAREN]. - * - * If a continuation is returned, then the reentering call to - * a search function will retry the back_check. - */ - -#ifdef __STDC__ -typedef enum rx_back_check_return - (*rx_back_check_fn) (struct rx_string_position * pos, - int lparen, - int rparen, - unsigned char * translate, - void * app_closure, - int stop); - -#else -typedef enum rx_back_check_return (*rx_back_check_fn) (); -#endif - - - - -/* A call to fetch_char should return the character at POS or POS + 1. - * Returning continuations here isn't supported. OFFSET is either 0 or 1 - * and indicates which characters is desired. - */ - -#ifdef __STDC__ -typedef int (*rx_fetch_char_fn) (struct rx_string_position * pos, - int offset, - void * app_closure, - int stop); -#else -typedef int (*rx_fetch_char_fn) (); -#endif - - -enum rx_search_return -{ - rx_search_continuation = -4, - rx_search_error = -3, - rx_search_soft_fail = -2, /* failed by running out of string */ - rx_search_fail = -1 /* failed only by reaching failure states */ - /* return values >= 0 indicate the position of a successful match */ -}; - - - - - - -/* regex.h - * - * The remaining declarations replace regex.h. - */ - -/* This is an array of error messages corresponding to the error codes. - */ -extern __const__ char *re_error_msg[]; - -#if !defined(BSD) || (BSD < 199306) || defined(_RX_C_) -/* If any error codes are removed, changed, or added, update the - `re_error_msg' table in regex.c. */ -typedef enum -{ - REG_NOERROR = 0, /* Success. */ - REG_NOMATCH, /* Didn't find a match (for regexec). */ - - /* POSIX regcomp return error codes. (In the order listed in the - standard.) */ - REG_BADPAT, /* Invalid pattern. */ - REG_ECOLLATE, /* Not implemented. */ - REG_ECTYPE, /* Invalid character class name. */ - REG_EESCAPE, /* Trailing backslash. */ - REG_ESUBREG, /* Invalid back reference. */ - REG_EBRACK, /* Unmatched left bracket. */ - REG_EPAREN, /* Parenthesis imbalance. */ - REG_EBRACE, /* Unmatched \{. */ - REG_BADBR, /* Invalid contents of \{\}. */ - REG_ERANGE, /* Invalid range end. */ - REG_ESPACE, /* Ran out of memory. */ - REG_BADRPT, /* No preceding re for repetition op. */ - - /* Error codes we've added. */ - REG_EEND, /* Premature end. */ - REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ - REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ -} reg_errcode_t; -#endif - -/* The regex.c support, as a client of rx, defines a set of possible - * side effects that can be added to the edge lables of nfa edges. - * Here is the list of sidef effects in use. - */ - -enum re_side_effects -{ -#define RX_WANT_SE_DEFS 1 -#undef RX_DEF_SE -#undef RX_DEF_CPLX_SE -#define RX_DEF_SE(IDEM, NAME, VALUE) NAME VALUE, -#define RX_DEF_CPLX_SE(IDEM, NAME, VALUE) NAME VALUE, -#include "rx.h" -#undef RX_DEF_SE -#undef RX_DEF_CPLX_SE -#undef RX_WANT_SE_DEFS - re_floogle_flap = 65533 -}; - -/* These hold paramaters for the kinds of side effects that are possible - * in the supported pattern languages. These include things like the - * numeric bounds of {} operators and the index of paren registers for - * subexpression measurement or backreferencing. - */ -struct re_se_params -{ - enum re_side_effects se; - int op1; - int op2; -}; - -typedef unsigned reg_syntax_t; - -struct re_pattern_buffer -{ - struct rx rx; - reg_syntax_t syntax; /* See below for syntax bit definitions. */ - - unsigned int no_sub:1; /* If set, don't return register offsets. */ - unsigned int not_bol:1; /* If set, the anchors ('^' and '$') don't */ - unsigned int not_eol:1; /* match at the ends of the string. */ - unsigned int newline_anchor:1;/* If true, an anchor at a newline matches.*/ - unsigned int least_subs:1; /* If set, and returning registers, return - * as few values as possible. Only - * backreferenced groups and group 0 (the whole - * match) will be returned. - */ - - /* If true, this says that the matcher should keep registers on its - * backtracking stack. For many patterns, we can easily determine that - * this isn't necessary. - */ - unsigned int match_regs_on_stack:1; - unsigned int search_regs_on_stack:1; - - /* is_anchored and begbuf_only are filled in by rx_compile. */ - unsigned int is_anchored:1; /* Anchorded by ^? */ - unsigned int begbuf_only:1; /* Anchored to char position 0? */ - - - /* If REGS_UNALLOCATED, allocate space in the `regs' structure - * for `max (RE_NREGS, re_nsub + 1)' groups. - * If REGS_REALLOCATE, reallocate space if necessary. - * If REGS_FIXED, use what's there. - */ -#define REGS_UNALLOCATED 0 -#define REGS_REALLOCATE 1 -#define REGS_FIXED 2 - unsigned int regs_allocated:2; - - - /* Either a translate table to apply to all characters before - * comparing them, or zero for no translation. The translation - * is applied to a pattern when it is compiled and to a string - * when it is matched. - */ - unsigned char * translate; - - /* If this is a valid pointer, it tells rx not to store the extents of - * certain subexpressions (those corresponding to non-zero entries). - * Passing 0x1 is the same as passing an array of all ones. Passing 0x0 - * is the same as passing an array of all zeros. - * The array should contain as many entries as their are subexps in the - * regexp. - */ - char * syntax_parens; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - void * buffer; /* Malloced memory for the nfa. */ - unsigned long allocated; /* Size of that memory. */ - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses - * the fastmap, if there is one, to skip over impossible - * starting points for matches. */ - char *fastmap; - - unsigned int fastmap_accurate:1; /* These three are internal. */ - unsigned int can_match_empty:1; - struct rx_nfa_state * start; /* The nfa starting state. */ - - /* This is the list of iterator bounds for {lo,hi} constructs. - * The memory pointed to is part of the rx->buffer. - */ - struct re_se_params *se_params; - - /* This is a bitset representation of the fastmap. - * This is a true fastmap that already takes the translate - * table into account. - */ - rx_Bitset fastset; -}; - -/* This is the structure we store register match data in. See - regex.texinfo for a full description of what registers match. */ -struct re_registers -{ - unsigned num_regs; - int *start; - int *end; -}; - -#if !defined(BSD) || (BSD < 199306) || defined(_RX_C_) -/* Type for byte offsets within the string. POSIX mandates this. */ -typedef int regoff_t; - -typedef struct re_pattern_buffer regex_t; - -/* POSIX specification for registers. Aside from the different names than - `re_registers', POSIX uses an array of structures, instead of a - structure of arrays. */ -typedef struct -{ - regoff_t rm_so; /* Byte offset from string's start to substring's start. */ - regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ -} regmatch_t; -#endif - -/* The following bits are used to determine the regexp syntax we - recognize. The set/not-set meanings are chosen so that Emacs syntax - remains the value 0. The bits are given in alphabetical order, and - the definitions shifted by one from the previous bit; thus, when we - add or remove a bit, only one other definition need change. */ - -/* If this bit is not set, then \ inside a bracket expression is literal. - If set, then such a \ quotes the following character. */ -#define RE_BACKSLASH_ESCAPE_IN_LISTS (1) - -/* If this bit is not set, then + and ? are operators, and \+ and \? are - literals. - If set, then \+ and \? are operators and + and ? are literals. */ -#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) - -/* If this bit is set, then character classes are supported. They are: - [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], - [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. - If not set, then character classes are not supported. */ -#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) - -/* If this bit is set, then ^ and $ are always anchors (outside bracket - expressions, of course). - If this bit is not set, then it depends: - ^ is an anchor if it is at the beginning of a regular - expression or after an open-group or an alternation operator; - $ is an anchor if it is at the end of a regular expression, or - before a close-group or an alternation operator. - - This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because - POSIX draft 11.2 says that * etc. in leading positions is undefined. - We already implemented a previous draft which made those constructs - invalid, though, so we haven't changed the code back. */ -#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) - -/* If this bit is set, then special characters are always special - regardless of where they are in the pattern. - If this bit is not set, then special characters are special only in - some contexts; otherwise they are ordinary. Specifically, - * + ? and intervals are only special when not after the beginning, - open-group, or alternation operator. */ -#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) - -/* If this bit is set, then *, +, ?, and { cannot be first in an re or - immediately after an alternation or begin-group operator. */ -#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) - -/* If this bit is set, then . matches newline. - If not set, then it doesn't. */ -#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) - -/* If this bit is set, then . doesn't match NUL. - If not set, then it does. */ -#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) - -/* If this bit is set, nonmatching lists [^...] do not match newline. - If not set, they do. */ -#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) - -/* If this bit is set, either \{...\} or {...} defines an - interval, depending on RE_NO_BK_BRACES. - If not set, \{, \}, {, and } are literals. */ -#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) - -/* If this bit is set, +, ? and | aren't recognized as operators. - If not set, they are. */ -#define RE_LIMITED_OPS (RE_INTERVALS << 1) - -/* If this bit is set, newline is an alternation operator. - If not set, newline is literal. */ -#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) - -/* If this bit is set, then `{...}' defines an interval, and \{ and \} - are literals. - If not set, then `\{...\}' defines an interval. */ -#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) - -/* If this bit is set, (...) defines a group, and \( and \) are literals. - If not set, \(...\) defines a group, and ( and ) are literals. */ -#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) - -/* If this bit is set, then \<digit> matches <digit>. - If not set, then \<digit> is a back-reference. */ -#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) - -/* If this bit is set, then | is an alternation operator, and \| is literal. - If not set, then \| is an alternation operator, and | is literal. */ -#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) - -/* If this bit is set, then an ending range point collating higher - than the starting range point, as in [z-a], is invalid. - If not set, then when ending range point collates higher than the - starting range point, the range is ignored. */ -#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) - -/* If this bit is set, then an unmatched ) is ordinary. - If not set, then an unmatched ) is invalid. */ -#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) - -/* This global variable defines the particular regexp syntax to use (for - some interfaces). When a regexp is compiled, the syntax used is - stored in the pattern buffer, so changing this does not affect - already-compiled regexps. */ -extern reg_syntax_t re_syntax_options; - -/* Define combinations of the above bits for the standard possibilities. - (The [[[ comments delimit what gets put into the Texinfo file, so - don't delete them!) */ -/* [[[begin syntaxes]]] */ -#define RE_SYNTAX_EMACS 0 - -#define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VAR | RE_NO_EMPTY_RANGES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -#define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) - -#define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - -#define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - -#define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) - -#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - -/* Syntax bits common to both basic and extended POSIX regex syntax. */ -#define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - -#define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) - -/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ -#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - -#define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) - -/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS - replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ -#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) -/* [[[end syntaxes]]] */ - -/* Maximum number of duplicates an interval can allow. Some systems - (erroneously) define this in other header files, but we want our - value, so remove any previous define. */ -#ifdef RE_DUP_MAX -#undef RE_DUP_MAX -#endif -#define RE_DUP_MAX ((1 << 15) - 1) - - -#if !defined(BSD) || (BSD < 199306) -/* POSIX `cflags' bits (i.e., information for `regcomp'). */ - -/* If this bit is set, then use extended regular expression syntax. - If not set, then use basic regular expression syntax. */ -#define REG_EXTENDED 1 - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -#define REG_ICASE (REG_EXTENDED << 1) - -/* If this bit is set, then anchors do not match at newline - characters in the string. - If not set, then anchors do match at newlines. */ -#define REG_NEWLINE (REG_ICASE << 1) - -/* If this bit is set, then report only success or fail in regexec. - If not set, then returns differ between not matching and errors. */ -#define REG_NOSUB (REG_NEWLINE << 1) - - -/* POSIX `eflags' bits (i.e., information for regexec). */ - -/* If this bit is set, then the beginning-of-line operator doesn't match - the beginning of the string (presumably because it's not the - beginning of a line). - If not set, then the beginning-of-line operator does match the - beginning of the string. */ -#define REG_NOTBOL 1 - -/* Like REG_NOTBOL, except for the end-of-line. */ -#define REG_NOTEOL (1 << 1) -#endif - -/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, - * `re_match_2' returns information about at least this many registers - * the first time a `regs' structure is passed. - * - * Also, this is the greatest number of backreferenced subexpressions - * allowed in a pattern being matched without caller-supplied registers. - */ -#ifndef RE_NREGS -#define RE_NREGS 30 -#endif - -extern int rx_cache_bound; -extern char rx_version_string[]; - - - -#ifdef RX_WANT_RX_DEFS - -/* This is decls to the interesting subsystems and lower layers - * of rx. Everything which doesn't have a public counterpart in - * regex.c is declared here. - */ - - -#ifdef __STDC__ -typedef void (*rx_hash_freefn) (struct rx_hash_item * it); -#else /* ndef __STDC__ */ -typedef void (*rx_hash_freefn) (); -#endif /* ndef __STDC__ */ - - - - -#ifdef __STDC__ -RX_DECL int rx_bitset_is_equal (int size, rx_Bitset a, rx_Bitset b); -RX_DECL int rx_bitset_is_subset (int size, rx_Bitset a, rx_Bitset b); -RX_DECL int rx_bitset_empty (int size, rx_Bitset set); -RX_DECL void rx_bitset_null (int size, rx_Bitset b); -RX_DECL void rx_bitset_universe (int size, rx_Bitset b); -RX_DECL void rx_bitset_complement (int size, rx_Bitset b); -RX_DECL void rx_bitset_assign (int size, rx_Bitset a, rx_Bitset b); -RX_DECL void rx_bitset_union (int size, rx_Bitset a, rx_Bitset b); -RX_DECL void rx_bitset_intersection (int size, - rx_Bitset a, rx_Bitset b); -RX_DECL void rx_bitset_difference (int size, rx_Bitset a, rx_Bitset b); -RX_DECL void rx_bitset_revdifference (int size, - rx_Bitset a, rx_Bitset b); -RX_DECL void rx_bitset_xor (int size, rx_Bitset a, rx_Bitset b); -RX_DECL unsigned long rx_bitset_hash (int size, rx_Bitset b); -RX_DECL struct rx_hash_item * rx_hash_find (struct rx_hash * table, - unsigned long hash, - void * value, - struct rx_hash_rules * rules); -RX_DECL struct rx_hash_item * rx_hash_store (struct rx_hash * table, - unsigned long hash, - void * value, - struct rx_hash_rules * rules); -RX_DECL void rx_hash_free (struct rx_hash_item * it, struct rx_hash_rules * rules); -RX_DECL void rx_free_hash_table (struct rx_hash * tab, rx_hash_freefn freefn, - struct rx_hash_rules * rules); -RX_DECL rx_Bitset rx_cset (struct rx *rx); -RX_DECL rx_Bitset rx_copy_cset (struct rx *rx, rx_Bitset a); -RX_DECL void rx_free_cset (struct rx * rx, rx_Bitset c); -RX_DECL struct rexp_node * rexp_node (struct rx *rx, - enum rexp_node_type type); -RX_DECL struct rexp_node * rx_mk_r_cset (struct rx * rx, - rx_Bitset b); -RX_DECL struct rexp_node * rx_mk_r_concat (struct rx * rx, - struct rexp_node * a, - struct rexp_node * b); -RX_DECL struct rexp_node * rx_mk_r_alternate (struct rx * rx, - struct rexp_node * a, - struct rexp_node * b); -RX_DECL struct rexp_node * rx_mk_r_opt (struct rx * rx, - struct rexp_node * a); -RX_DECL struct rexp_node * rx_mk_r_star (struct rx * rx, - struct rexp_node * a); -RX_DECL struct rexp_node * rx_mk_r_2phase_star (struct rx * rx, - struct rexp_node * a, - struct rexp_node * b); -RX_DECL struct rexp_node * rx_mk_r_side_effect (struct rx * rx, - rx_side_effect a); -RX_DECL struct rexp_node * rx_mk_r_data (struct rx * rx, - void * a); -RX_DECL void rx_free_rexp (struct rx * rx, struct rexp_node * node); -RX_DECL struct rexp_node * rx_copy_rexp (struct rx *rx, - struct rexp_node *node); -RX_DECL struct rx_nfa_state * rx_nfa_state (struct rx *rx); -RX_DECL void rx_free_nfa_state (struct rx_nfa_state * n); -RX_DECL struct rx_nfa_state * rx_id_to_nfa_state (struct rx * rx, - int id); -RX_DECL struct rx_nfa_edge * rx_nfa_edge (struct rx *rx, - enum rx_nfa_etype type, - struct rx_nfa_state *start, - struct rx_nfa_state *dest); -RX_DECL void rx_free_nfa_edge (struct rx_nfa_edge * e); -RX_DECL void rx_free_nfa (struct rx *rx); -RX_DECL int rx_build_nfa (struct rx *rx, - struct rexp_node *rexp, - struct rx_nfa_state **start, - struct rx_nfa_state **end); -RX_DECL void rx_name_nfa_states (struct rx *rx); -RX_DECL int rx_eclose_nfa (struct rx *rx); -RX_DECL void rx_delete_epsilon_transitions (struct rx *rx); -RX_DECL int rx_compactify_nfa (struct rx *rx, - void **mem, unsigned long *size); -RX_DECL void rx_release_superset (struct rx *rx, - struct rx_superset *set); -RX_DECL struct rx_superset * rx_superset_cons (struct rx * rx, - struct rx_nfa_state *car, struct rx_superset *cdr); -RX_DECL struct rx_superset * rx_superstate_eclosure_union - (struct rx * rx, struct rx_superset *set, struct rx_nfa_state_set *ecl); -RX_DECL struct rx_superstate * rx_superstate (struct rx *rx, - struct rx_superset *set); -RX_DECL struct rx_inx * rx_handle_cache_miss - (struct rx *rx, struct rx_superstate *super, unsigned char chr, void *data); -RX_DECL reg_errcode_t rx_compile (__const__ char *pattern, int size, - reg_syntax_t syntax, - struct re_pattern_buffer * rxb); -RX_DECL void rx_blow_up_fastmap (struct re_pattern_buffer * rxb); -#else /* STDC */ -RX_DECL int rx_bitset_is_equal (); -RX_DECL int rx_bitset_is_subset (); -RX_DECL int rx_bitset_empty (); -RX_DECL void rx_bitset_null (); -RX_DECL void rx_bitset_universe (); -RX_DECL void rx_bitset_complement (); -RX_DECL void rx_bitset_assign (); -RX_DECL void rx_bitset_union (); -RX_DECL void rx_bitset_intersection (); -RX_DECL void rx_bitset_difference (); -RX_DECL void rx_bitset_revdifference (); -RX_DECL void rx_bitset_xor (); -RX_DECL unsigned long rx_bitset_hash (); -RX_DECL struct rx_hash_item * rx_hash_find (); -RX_DECL struct rx_hash_item * rx_hash_store (); -RX_DECL void rx_hash_free (); -RX_DECL void rx_free_hash_table (); -RX_DECL rx_Bitset rx_cset (); -RX_DECL rx_Bitset rx_copy_cset (); -RX_DECL void rx_free_cset (); -RX_DECL struct rexp_node * rexp_node (); -RX_DECL struct rexp_node * rx_mk_r_cset (); -RX_DECL struct rexp_node * rx_mk_r_concat (); -RX_DECL struct rexp_node * rx_mk_r_alternate (); -RX_DECL struct rexp_node * rx_mk_r_opt (); -RX_DECL struct rexp_node * rx_mk_r_star (); -RX_DECL struct rexp_node * rx_mk_r_2phase_star (); -RX_DECL struct rexp_node * rx_mk_r_side_effect (); -RX_DECL struct rexp_node * rx_mk_r_data (); -RX_DECL void rx_free_rexp (); -RX_DECL struct rexp_node * rx_copy_rexp (); -RX_DECL struct rx_nfa_state * rx_nfa_state (); -RX_DECL void rx_free_nfa_state (); -RX_DECL struct rx_nfa_state * rx_id_to_nfa_state (); -RX_DECL struct rx_nfa_edge * rx_nfa_edge (); -RX_DECL void rx_free_nfa_edge (); -RX_DECL void rx_free_nfa (); -RX_DECL int rx_build_nfa (); -RX_DECL void rx_name_nfa_states (); -RX_DECL int rx_eclose_nfa (); -RX_DECL void rx_delete_epsilon_transitions (); -RX_DECL int rx_compactify_nfa (); -RX_DECL void rx_release_superset (); -RX_DECL struct rx_superset * rx_superset_cons (); -RX_DECL struct rx_superset * rx_superstate_eclosure_union (); -RX_DECL struct rx_superstate * rx_superstate (); -RX_DECL struct rx_inx * rx_handle_cache_miss (); -RX_DECL reg_errcode_t rx_compile (); -RX_DECL void rx_blow_up_fastmap (); -#endif /* STDC */ - - -#endif /* RX_WANT_RX_DEFS */ - - - -#ifdef __STDC__ -extern int re_search_2 (struct re_pattern_buffer *rxb, - __const__ char * string1, int size1, - __const__ char * string2, int size2, - int startpos, int range, - struct re_registers *regs, - int stop); -extern int re_search (struct re_pattern_buffer * rxb, __const__ char *string, - int size, int startpos, int range, - struct re_registers *regs); -extern int re_match_2 (struct re_pattern_buffer * rxb, - __const__ char * string1, int size1, - __const__ char * string2, int size2, - int pos, struct re_registers *regs, int stop); -extern int re_match (struct re_pattern_buffer * rxb, - __const__ char * string, - int size, int pos, - struct re_registers *regs); -extern reg_syntax_t re_set_syntax (reg_syntax_t syntax); -extern void re_set_registers (struct re_pattern_buffer *bufp, - struct re_registers *regs, - unsigned num_regs, - int * starts, int * ends); -extern __const__ char * re_compile_pattern (__const__ char *pattern, - int length, - struct re_pattern_buffer * rxb); -extern int re_compile_fastmap (struct re_pattern_buffer * rxb); -#if !defined(BSD) || (BSD < 199306) -extern char * re_comp (__const__ char *s); -extern int re_exec (__const__ char *s); -extern int regcomp (regex_t * preg, __const__ char * pattern, int cflags); -extern int regexec (__const__ regex_t *preg, __const__ char *string, - size_t nmatch, regmatch_t pmatch[], - int eflags); -extern size_t regerror (int errcode, __const__ regex_t *preg, - char *errbuf, size_t errbuf_size); -extern void regfree (regex_t *preg); -#endif -#else /* STDC */ -extern int re_search_2 (); -extern int re_search (); -extern int re_match_2 (); -extern int re_match (); -extern reg_syntax_t re_set_syntax (); -extern void re_set_registers (); -extern __const__ char * re_compile_pattern (); -extern int re_compile_fastmap (); -#if !defined(BSD) || (BSD < 199306) -extern char * re_comp (); -extern int re_exec (); -extern int regcomp (); -extern int regexec (); -extern size_t regerror (); -extern void regfree (); -#endif -#endif /* STDC */ - - - -#ifdef RX_WANT_RX_DEFS - -struct rx_counter_frame -{ - int tag; - int val; - struct rx_counter_frame * inherited_from; /* If this is a copy. */ - struct rx_counter_frame * cdr; -}; - -struct rx_backtrack_frame -{ - char * counter_stack_sp; - - /* A frame is used to save the matchers state when it crosses a - * backtracking point. The `stk_' fields correspond to variables - * in re_search_2 (just strip off thes `stk_'). They are documented - * tere. - */ - struct rx_superstate * stk_super; - unsigned int stk_c; - struct rx_string_position stk_test_pos; - int stk_last_l; - int stk_last_r; - int stk_test_ret; - - /* This is the list of options left to explore at the backtrack - * point for which this frame was created. - */ - struct rx_distinct_future * df; - struct rx_distinct_future * first_df; - -#ifdef RX_DEBUG - int stk_line_no; -#endif -}; - -struct rx_stack_chunk -{ - struct rx_stack_chunk * next_chunk; - int bytes_left; - char * sp; -}; - -enum rx_outer_entry -{ - rx_outer_start, - rx_outer_fastmap, - rx_outer_test, - rx_outer_restore_pos -}; - -enum rx_fastmap_return -{ - rx_fastmap_continuation, - rx_fastmap_error, - rx_fastmap_ok, - rx_fastmap_fail -}; - -enum rx_fastmap_entry -{ - rx_fastmap_start, - rx_fastmap_string_break -}; - -enum rx_test_return -{ - rx_test_continuation, - rx_test_error, - rx_test_fail, - rx_test_ok -}; - -enum rx_test_internal_return -{ - rx_test_internal_error, - rx_test_found_first, - rx_test_line_finished -}; - -enum rx_test_match_entry -{ - rx_test_start, - rx_test_cache_hit_loop, - rx_test_backreference_check, - rx_test_backtrack_return -}; - -struct rx_search_state -{ - /* Two groups of registers are kept. The group with the register state - * of the current test match, and the group that holds the state at the end - * of the best known match, if any. - * - * For some patterns, there may also be registers saved on the stack. - */ - unsigned num_regs; /* Includes an element for register zero. */ - int * lparen; /* scratch space for register returns */ - int * rparen; - int * best_lpspace; /* in case the user doesn't want these */ - int * best_rpspace; /* values, we still need space to store - * them. Normally, this memoryis unused - * and the space pointed to by REGS is - * used instead. - */ - - int last_l; /* Highest index of a valid lparen. */ - int last_r; /* It's dual. */ - - int * best_lparen; /* This contains the best known register */ - int * best_rparen; /* assignments. - * This may point to the same mem as - * best_lpspace, or it might point to memory - * passed by the caller. - */ - int best_last_l; /* best_last_l:best_lparen::last_l:lparen */ - int best_last_r; - - - unsigned char * translate; - - struct rx_string_position outer_pos; - - struct rx_superstate * start_super; - int nfa_choice; - int first_found; /* If true, return after finding any match. */ - int ret_val; - - /* For continuations... */ - enum rx_outer_entry outer_search_resume_pt; - struct re_pattern_buffer * saved_rxb; - int saved_startpos; - int saved_range; - int saved_stop; - int saved_total_size; - rx_get_burst_fn saved_get_burst; - rx_back_check_fn saved_back_check; - struct re_registers * saved_regs; - - /** - ** state for fastmap - **/ - char * fastmap; - int fastmap_chr; - int fastmap_val; - - /* for continuations in the fastmap procedure: */ - enum rx_fastmap_entry fastmap_resume_pt; - - /** - ** state for test_match - **/ - - /* The current superNFA position of the matcher. */ - struct rx_superstate * super; - - /* The matcher interprets a series of instruction frames. - * This is the `instruction counter' for the interpretation. - */ - struct rx_inx * ifr; - - /* We insert a ghost character in the string to prime - * the nfa. test_pos.pos, test_pos.str_half, and test_pos.end_half - * keep track of the test-match position and string-half. - */ - unsigned char c; - - /* Position within the string. */ - struct rx_string_position test_pos; - - struct rx_stack_chunk * counter_stack; - struct rx_stack_chunk * backtrack_stack; - int backtrack_frame_bytes; - int chunk_bytes; - struct rx_stack_chunk * free_chunks; - - /* To return from this function, set test_ret and - * `goto test_do_return'. - * - * Possible return values are: - * 1 --- end of string while the superNFA is still going - * 0 --- internal error (out of memory) - * -1 --- search completed by reaching the superNFA fail state - * -2 --- a match was found, maybe not the longest. - * - * When the search is complete (-1), best_last_r indicates whether - * a match was found. - * - * -2 is return only if search_state.first_found is non-zero. - * - * if search_state.first_found is non-zero, a return of -1 indicates no match, - * otherwise, best_last_r has to be checked. - */ - int test_ret; - - int could_have_continued; - -#ifdef RX_DEBUG - int backtrack_depth; - /* There is a search tree with every node as set of deterministic - * transitions in the super nfa. For every branch of a - * backtrack point is an edge in the tree. - * This counts up a pre-order of nodes in that tree. - * It's saved on the search stack and printed when debugging. - */ - int line_no; - int lines_found; -#endif - - - /* For continuations within the match tester */ - enum rx_test_match_entry test_match_resume_pt; - struct rx_inx * saved_next_tr_table; - struct rx_inx * saved_this_tr_table; - int saved_reg; - struct rx_backtrack_frame * saved_bf; - -}; - - -extern char rx_slowmap[]; -extern unsigned char rx_id_translation[]; - -static __inline__ void -init_fastmap (rxb, search_state) - struct re_pattern_buffer * rxb; - struct rx_search_state * search_state; -{ - search_state->fastmap = (rxb->fastmap - ? (char *)rxb->fastmap - : (char *)rx_slowmap); - /* Update the fastmap now if not correct already. - * When the regexp was compiled, the fastmap was computed - * and stored in a bitset. This expands the bitset into a - * character array containing 1s and 0s. - */ - if ((search_state->fastmap == rxb->fastmap) && !rxb->fastmap_accurate) - rx_blow_up_fastmap (rxb); - search_state->fastmap_chr = -1; - search_state->fastmap_val = 0; - search_state->fastmap_resume_pt = rx_fastmap_start; -} - -static __inline__ void -uninit_fastmap (rxb, search_state) - struct re_pattern_buffer * rxb; - struct rx_search_state * search_state; -{ - /* Unset the fastmap sentinel */ - if (search_state->fastmap_chr >= 0) - search_state->fastmap[search_state->fastmap_chr] - = search_state->fastmap_val; -} - -static __inline__ int -fastmap_search (rxb, stop, get_burst, app_closure, search_state) - struct re_pattern_buffer * rxb; - int stop; - rx_get_burst_fn get_burst; - void * app_closure; - struct rx_search_state * search_state; -{ - enum rx_fastmap_entry pc; - - if (0) - { - return_continuation: - search_state->fastmap_resume_pt = pc; - return rx_fastmap_continuation; - } - - pc = search_state->fastmap_resume_pt; - - switch (pc) - { - case rx_fastmap_start: - init_fastmap_sentinal: - /* For the sake of fast fastmapping, set a sentinal in the fastmap. - * This sentinal will trap the fastmap loop when it reaches the last - * valid character in a string half. - * - * This must be reset when the fastmap/search loop crosses a string - * boundry, and before returning to the caller. So sometimes, - * the fastmap loop is restarted with `continue', othertimes by - * `goto init_fastmap_sentinal'. - */ - if (search_state->outer_pos.size) - { - search_state->fastmap_chr = ((search_state->outer_pos.search_direction == 1) - ? *(search_state->outer_pos.end - 1) - : *search_state->outer_pos.string); - search_state->fastmap_val - = search_state->fastmap[search_state->fastmap_chr]; - search_state->fastmap[search_state->fastmap_chr] = 1; - } - else - { - search_state->fastmap_chr = -1; - search_state->fastmap_val = 0; - } - - if (search_state->outer_pos.pos >= search_state->outer_pos.end) - goto fastmap_hit_bound; - else - { - if (search_state->outer_pos.search_direction == 1) - { - if (search_state->fastmap_val) - { - for (;;) - { - while (!search_state->fastmap[*search_state->outer_pos.pos]) - ++search_state->outer_pos.pos; - return rx_fastmap_ok; - } - } - else - { - for (;;) - { - while (!search_state->fastmap[*search_state->outer_pos.pos]) - ++search_state->outer_pos.pos; - if (*search_state->outer_pos.pos != search_state->fastmap_chr) - return rx_fastmap_ok; - else - { - ++search_state->outer_pos.pos; - if (search_state->outer_pos.pos == search_state->outer_pos.end) - goto fastmap_hit_bound; - } - } - } - } - else - { - __const__ unsigned char * bound; - bound = search_state->outer_pos.string - 1; - if (search_state->fastmap_val) - { - for (;;) - { - while (!search_state->fastmap[*search_state->outer_pos.pos]) - --search_state->outer_pos.pos; - return rx_fastmap_ok; - } - } - else - { - for (;;) - { - while (!search_state->fastmap[*search_state->outer_pos.pos]) - --search_state->outer_pos.pos; - if ((*search_state->outer_pos.pos != search_state->fastmap_chr) || search_state->fastmap_val) - return rx_fastmap_ok; - else - { - --search_state->outer_pos.pos; - if (search_state->outer_pos.pos == bound) - goto fastmap_hit_bound; - } - } - } - } - } - - case rx_fastmap_string_break: - fastmap_hit_bound: - { - /* If we hit a bound, it may be time to fetch another burst - * of string, or it may be time to return a continuation to - * the caller, or it might be time to fail. - */ - - int burst_state; - burst_state = get_burst (&search_state->outer_pos, app_closure, stop); - switch (burst_state) - { - case rx_get_burst_continuation: - { - pc = rx_fastmap_string_break; - goto return_continuation; - } - case rx_get_burst_error: - return rx_fastmap_error; - case rx_get_burst_ok: - goto init_fastmap_sentinal; - case rx_get_burst_no_more: - /* ...not a string split, simply no more string. - * - * When searching backward, running out of string - * is reason to quit. - * - * When searching forward, we allow the possibility - * of an (empty) match after the last character in the - * virtual string. So, fall through to the matcher - */ - return ( (search_state->outer_pos.search_direction == 1) - ? rx_fastmap_ok - : rx_fastmap_fail); - } - } - } - -} - - - -#ifdef emacs -/* The `emacs' switch turns on certain matching commands - * that make sense only in Emacs. - */ -#include "config.h" -#include "lisp.h" -#include "buffer.h" -#include "syntax.h" -/* Emacs uses `NULL' as a predicate. */ -#undef NULL -#else /* not emacs */ -/* Setting RX_MEMDBUG is useful if you have dbmalloc. Maybe with similar - * packages too. - */ -#ifdef RX_MEMDBUG -#include <malloc.h> -#else /* not RX_RX_MEMDBUG */ - -/* We used to test for `BSTRING' here, but only GCC and Emacs define - * `BSTRING', as far as I know, and neither of them use this code. - */ -#if HAVE_STRING_H || STDC_HEADERS -#include <string.h> - -#ifndef bcmp -#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) -#endif - -#ifndef bcopy -#define bcopy(s, d, n) memcpy ((d), (s), (n)) -#endif - -#ifndef bzero -#define bzero(s, n) memset ((s), 0, (n)) -#endif - -#else /* HAVE_STRING_H || STDC_HEADERS */ -#include <strings.h> -#endif /* not RX_MEMDBUG */ - -#ifdef STDC_HEADERS -#include <stdlib.h> -#else /* not STDC_HEADERS */ -char *malloc (); -char *realloc (); -#endif /* not STDC_HEADERS */ - -#endif /* not emacs */ - - - -/* Define the syntax basics for \<, \>, etc. - * This must be nonzero for the wordchar and notwordchar pattern - * commands in re_match_2. - */ -#ifndef Sword -#define Sword 1 -#endif - -/* How many characters in the character set. */ -#define CHAR_SET_SIZE (1 << CHARBITS) -#define SYNTAX(c) re_syntax_table[c] -RX_DECL char re_syntax_table[CHAR_SET_SIZE]; - -#endif /* not emacs */ - - -/* Test if at very beginning or at very end of the virtual concatenation - * of `string1' and `string2'. If only one string, it's `string2'. - */ - -#define AT_STRINGS_BEG() \ - ( -1 \ - == ((search_state.test_pos.pos - search_state.test_pos.string) \ - + search_state.test_pos.offset)) - -#define AT_STRINGS_END() \ - ( (total_size - 1) \ - == ((search_state.test_pos.pos - search_state.test_pos.string) \ - + search_state.test_pos.offset)) - - -/* Test if POS + 1 points to a character which is word-constituent. We have - * two special cases to check for: if past the end of string1, look at - * the first character in string2; and if before the beginning of - * string2, look at the last character in string1. - * - * Assumes `string1' exists, so use in conjunction with AT_STRINGS_BEG (). - */ -#define LETTER_P(POS,OFF) \ - ( SYNTAX (fetch_char(POS, OFF, app_closure, stop)) \ - == Sword) - -/* Test if the character at D and the one after D differ with respect - * to being word-constituent. - */ -#define AT_WORD_BOUNDARY(d) \ - (AT_STRINGS_BEG () || AT_STRINGS_END () || LETTER_P (d,0) != LETTER_P (d, 1)) - - -#ifdef RX_SUPPORT_CONTINUATIONS -#define RX_STACK_ALLOC(BYTES) malloc(BYTES) -#define RX_STACK_FREE(MEM) free(MEM) -#else -#define RX_STACK_ALLOC(BYTES) alloca(BYTES) -#define RX_STACK_FREE(MEM) \ - ((struct rx_stack_chunk *)MEM)->next_chunk = search_state.free_chunks; \ - search_state.free_chunks = ((struct rx_stack_chunk *)MEM); - -#endif - -#define PUSH(CHUNK_VAR,BYTES) \ - if (!CHUNK_VAR || (CHUNK_VAR->bytes_left < (BYTES))) \ - { \ - struct rx_stack_chunk * new_chunk; \ - if (search_state.free_chunks) \ - { \ - new_chunk = search_state.free_chunks; \ - search_state.free_chunks = search_state.free_chunks->next_chunk; \ - } \ - else \ - { \ - new_chunk = (struct rx_stack_chunk *)RX_STACK_ALLOC(search_state.chunk_bytes); \ - if (!new_chunk) \ - { \ - search_state.ret_val = 0; \ - goto test_do_return; \ - } \ - } \ - new_chunk->sp = (char *)new_chunk + sizeof (struct rx_stack_chunk); \ - new_chunk->bytes_left = (search_state.chunk_bytes \ - - (BYTES) \ - - sizeof (struct rx_stack_chunk)); \ - new_chunk->next_chunk = CHUNK_VAR; \ - CHUNK_VAR = new_chunk; \ - } \ - else \ - (CHUNK_VAR->sp += (BYTES)), (CHUNK_VAR->bytes_left -= (BYTES)) - -#define POP(CHUNK_VAR,BYTES) \ - if (CHUNK_VAR->sp == ((char *)CHUNK_VAR + sizeof(*CHUNK_VAR))) \ - { \ - struct rx_stack_chunk * new_chunk = CHUNK_VAR->next_chunk; \ - RX_STACK_FREE(CHUNK_VAR); \ - CHUNK_VAR = new_chunk; \ - } \ - else \ - (CHUNK_VAR->sp -= BYTES), (CHUNK_VAR->bytes_left += BYTES) - - - -#define SRCH_TRANSLATE(C) search_state.translate[(unsigned char) (C)] - - - - -#ifdef __STDC__ -RX_DECL __inline__ int -rx_search (struct re_pattern_buffer * rxb, - int startpos, - int range, - int stop, - int total_size, - rx_get_burst_fn get_burst, - rx_back_check_fn back_check, - rx_fetch_char_fn fetch_char, - void * app_closure, - struct re_registers * regs, - struct rx_search_state * resume_state, - struct rx_search_state * save_state) -#else -RX_DECL __inline__ int -rx_search (rxb, startpos, range, stop, total_size, - get_burst, back_check, fetch_char, - app_closure, regs, resume_state, save_state) - struct re_pattern_buffer * rxb; - int startpos; - int range; - int stop; - int total_size; - rx_get_burst_fn get_burst; - rx_back_check_fn back_check; - rx_fetch_char_fn fetch_char; - void * app_closure; - struct re_registers * regs; - struct rx_search_state * resume_state; - struct rx_search_state * save_state; -#endif -{ - int pc; - int test_state; - struct rx_search_state search_state; - - if (!resume_state) - pc = rx_outer_start; - else - { - search_state = *resume_state; - regs = search_state.saved_regs; - rxb = search_state.saved_rxb; - startpos = search_state.saved_startpos; - range = search_state.saved_range; - stop = search_state.saved_stop; - total_size = search_state.saved_total_size; - get_burst = search_state.saved_get_burst; - back_check = search_state.saved_back_check; - pc = search_state.outer_search_resume_pt; - if (0) - { - return_continuation: - if (save_state) - { - *save_state = search_state; - save_state->saved_regs = regs; - save_state->saved_rxb = rxb; - save_state->saved_startpos = startpos; - save_state->saved_range = range; - save_state->saved_stop = stop; - save_state->saved_total_size = total_size; - save_state->saved_get_burst = get_burst; - save_state->saved_back_check = back_check; - save_state->outer_search_resume_pt = pc; - } - return rx_search_continuation; - } - } - - switch (pc) - { - case rx_outer_start: - search_state.ret_val = rx_search_fail; - ( search_state.lparen - = search_state.rparen - = search_state.best_lpspace - = search_state.best_rpspace - = 0); - - /* figure the number of registers we may need for use in backreferences. - * the number here includes an element for register zero. - */ - search_state.num_regs = rxb->re_nsub + 1; - - - /* check for out-of-range startpos. */ - if ((startpos < 0) || (startpos > total_size)) - return rx_search_fail; - - /* fix up range if it might eventually take us outside the string. */ - { - int endpos; - endpos = startpos + range; - if (endpos < -1) - range = (-1 - startpos); - else if (endpos > total_size) - range = total_size - startpos; - } - - /* if the search isn't to be a backwards one, don't waste time in a - * long search for a pattern that says it is anchored. - */ - if (rxb->begbuf_only && (range > 0)) - { - if (startpos > 0) - return rx_search_fail; - else - range = 1; - } - - /* decide whether to use internal or user-provided reg buffers. */ - if (!regs || rxb->no_sub) - { - search_state.best_lpspace = - (int *)REGEX_ALLOCATE (search_state.num_regs * sizeof(int)); - search_state.best_rpspace = - (int *)REGEX_ALLOCATE (search_state.num_regs * sizeof(int)); - search_state.best_lparen = search_state.best_lpspace; - search_state.best_rparen = search_state.best_rpspace; - } - else - { - /* have the register data arrays been allocated? */ - if (rxb->regs_allocated == REGS_UNALLOCATED) - { /* no. so allocate them with malloc. we need one - extra element beyond `search_state.num_regs' for the `-1' marker - gnu code uses. */ - regs->num_regs = MAX (RE_NREGS, rxb->re_nsub + 1); - regs->start = ((int *) - malloc (regs->num_regs * sizeof ( int ))); - regs->end = ((int *) - malloc (regs->num_regs * sizeof ( int ))); - if (regs->start == 0 || regs->end == 0) - return rx_search_error; - rxb->regs_allocated = REGS_REALLOCATE; - } - else if (rxb->regs_allocated == REGS_REALLOCATE) - { /* yes. if we need more elements than were already - allocated, reallocate them. if we need fewer, just - leave it alone. */ - if (regs->num_regs < search_state.num_regs + 1) - { - regs->num_regs = search_state.num_regs + 1; - regs->start = ((int *) - realloc (regs->start, - regs->num_regs * sizeof (int ))); - regs->end = ((int *) - realloc (regs->end, - regs->num_regs * sizeof ( int ))); - if (regs->start == 0 || regs->end == 0) - return rx_search_error; - } - } - else if (rxb->regs_allocated != REGS_FIXED) - return rx_search_error; - - if (regs->num_regs < search_state.num_regs + 1) - { - search_state.best_lpspace = - ((int *) - REGEX_ALLOCATE (search_state.num_regs * sizeof(int ))); - search_state.best_rpspace = - ((int *) - REGEX_ALLOCATE (search_state.num_regs * sizeof(int ))); - search_state.best_lparen = search_state.best_lpspace; - search_state.best_rparen = search_state.best_rpspace; - } - else - { - search_state.best_lparen = regs->start; - search_state.best_rparen = regs->end; - } - } - - search_state.lparen = - (int *) REGEX_ALLOCATE (search_state.num_regs * sizeof(int )); - search_state.rparen = - (int *) REGEX_ALLOCATE (search_state.num_regs * sizeof(int )); - - if (! ( search_state.best_rparen - && search_state.best_lparen - && search_state.lparen && search_state.rparen)) - return rx_search_error; - - search_state.best_last_l = search_state.best_last_r = -1; - - search_state.translate = (rxb->translate - ? rxb->translate - : rx_id_translation); - - - - /* - * two nfa's were compiled. - * `0' is complete. - * `1' faster but gets registers wrong and ends too soon. - */ - search_state.nfa_choice = (regs && !rxb->least_subs) ? '\0' : '\1'; - - /* we have the option to look for the best match or the first - * one we can find. if the user isn't asking for register information, - * we don't need to find the best match. - */ - search_state.first_found = !regs; - - if (range >= 0) - { - search_state.outer_pos.search_end = MIN (total_size, startpos + range) + 1; - search_state.outer_pos.search_direction = 1; - } - else - { - search_state.outer_pos.search_end = MAX(-1, startpos + range); - search_state.outer_pos.search_direction = -1; - } - - /* the vacuous search always turns up nothing. */ - if ((search_state.outer_pos.search_direction == 1) - ? (startpos > search_state.outer_pos.search_end) - : (startpos < search_state.outer_pos.search_end)) - return rx_search_fail; - - /* now we build the starting state of the supernfa. */ - { - struct rx_superset * start_contents; - struct rx_nfa_state_set * start_nfa_set; - - /* we presume here that the nfa start state has only one - * possible future with no side effects. - */ - start_nfa_set = rxb->start->futures->destset; - if ( rxb->rx.start_set - && (rxb->rx.start_set->starts_for == &rxb->rx)) - start_contents = rxb->rx.start_set; - else - { - start_contents = - rx_superstate_eclosure_union (&rxb->rx, - rx_superset_cons (&rxb->rx, 0, 0), - start_nfa_set); - - if (!start_contents) - return rx_search_fail; - - start_contents->starts_for = &rxb->rx; - rxb->rx.start_set = start_contents; - } - if ( start_contents->superstate - && (start_contents->superstate->rx_id == rxb->rx.rx_id)) - { - search_state.start_super = start_contents->superstate; - rx_lock_superstate (&rxb->rx, search_state.start_super); - } - else - { - rx_protect_superset (&rxb->rx, start_contents); - - search_state.start_super = rx_superstate (&rxb->rx, start_contents); - if (!search_state.start_super) - return rx_search_fail; - rx_lock_superstate (&rxb->rx, search_state.start_super); - rx_release_superset (&rxb->rx, start_contents); - } - } - - - - ( search_state.outer_pos.string - = search_state.outer_pos.end - = 0); - - search_state.outer_pos.offset = 0; - search_state.outer_pos.size = 0; - search_state.outer_pos.pos = (unsigned char *)startpos; - init_fastmap (rxb, &search_state); - - search_state.fastmap_resume_pt = rx_fastmap_start; - case rx_outer_fastmap: - /* do { */ - pseudo_do: - { - { - int fastmap_state; - fastmap_state = fastmap_search (rxb, stop, get_burst, app_closure, - &search_state); - switch (fastmap_state) - { - case rx_fastmap_continuation: - pc = rx_outer_fastmap; - goto return_continuation; - case rx_fastmap_fail: - goto finish; - case rx_fastmap_ok: - break; - } - } - - /* now the fastmap loop has brought us to a plausible - * starting point for a match. so, it's time to run the - * nfa and see if a match occured. - */ - startpos = ( search_state.outer_pos.pos - - search_state.outer_pos.string - + search_state.outer_pos.offset); - if (startpos == search_state.outer_pos.search_end) - goto finish; - } - - search_state.test_match_resume_pt = rx_test_start; - /* do interrupted for entry point... */ - case rx_outer_test: - /* ...do continued */ - { - goto test_match; - test_returns_to_search: - switch (test_state) - { - case rx_test_continuation: - pc = rx_outer_test; - goto return_continuation; - case rx_test_error: - search_state.ret_val = rx_search_error; - goto finish; - case rx_test_fail: - break; - case rx_test_ok: - goto finish; - } - search_state.outer_pos.pos += search_state.outer_pos.search_direction; - startpos += search_state.outer_pos.search_direction; - } - /* do interrupted for entry point... */ - case rx_outer_restore_pos: - { - int x; - x = get_burst (&search_state.outer_pos, app_closure, stop); - switch (x) - { - case rx_get_burst_continuation: - pc = rx_outer_restore_pos; - goto return_continuation; - case rx_get_burst_error: - search_state.ret_val = rx_search_error; - goto finish; - case rx_get_burst_no_more: - goto finish; - case rx_get_burst_ok: - break; - } - } /* } while (...see below...) */ - if ((search_state.outer_pos.search_direction == 1) - ? (startpos < search_state.outer_pos.search_end) - : (startpos > search_state.outer_pos.search_end)) - goto pseudo_do; - - - finish: - uninit_fastmap (rxb, &search_state); - if (search_state.start_super) - rx_unlock_superstate (&rxb->rx, search_state.start_super); - -#ifdef regex_malloc - if (search_state.lparen) free (search_state.lparen); - if (search_state.rparen) free (search_state.rparen); - if (search_state.best_lpspace) free (search_state.best_lpspace); - if (search_state.best_rpspace) free (search_state.best_rpspace); -#endif - return search_state.ret_val; - } - - - test_match: - { - enum rx_test_match_entry test_pc; - int inx; - test_pc = search_state.test_match_resume_pt; - if (test_pc == rx_test_start) - { -#ifdef RX_DEBUG - search_state.backtrack_depth = 0; -#endif - search_state.last_l = search_state.last_r = 0; - search_state.lparen[0] = startpos; - search_state.super = search_state.start_super; - search_state.c = search_state.nfa_choice; - search_state.test_pos.pos = search_state.outer_pos.pos - 1; - search_state.test_pos.string = search_state.outer_pos.string; - search_state.test_pos.end = search_state.outer_pos.end; - search_state.test_pos.offset = search_state.outer_pos.offset; - search_state.test_pos.size = search_state.outer_pos.size; - search_state.test_pos.search_direction = 1; - search_state.counter_stack = 0; - search_state.backtrack_stack = 0; - search_state.backtrack_frame_bytes = - (sizeof (struct rx_backtrack_frame) - + (rxb->match_regs_on_stack - ? sizeof (int ) * (search_state.num_regs + 1) * 2 - : 0)); - search_state.chunk_bytes = search_state.backtrack_frame_bytes * 64; - search_state.free_chunks = 0; - search_state.test_ret = rx_test_line_finished; - search_state.could_have_continued = 0; - } - /* This is while (1)...except that the body of the loop is interrupted - * by some alternative entry points. - */ - pseudo_while_1: - switch (test_pc) - { - case rx_test_cache_hit_loop: - goto resume_continuation_1; - case rx_test_backreference_check: - goto resume_continuation_2; - case rx_test_backtrack_return: - goto resume_continuation_3; - case rx_test_start: -#ifdef RX_DEBUG - /* There is a search tree with every node as set of deterministic - * transitions in the super nfa. For every branch of a - * backtrack point is an edge in the tree. - * This counts up a pre-order of nodes in that tree. - * It's saved on the search stack and printed when debugging. - */ - search_state.line_no = 0; - search_state.lines_found = 0; -#endif - - top_of_cycle: - /* A superstate is basicly a transition table, indexed by - * characters from the string being tested, and containing - * RX_INX (`instruction frame') structures. - */ - search_state.ifr = &search_state.super->transitions [search_state.c]; - - recurse_test_match: - /* This is the point to which control is sent when the - * test matcher `recurses'. Before jumping here, some variables - * need to be saved on the stack and the next instruction frame - * has to be computed. - */ - - restart: - /* Some instructions don't advance the matcher, but just - * carry out some side effects and fetch a new instruction. - * To dispatch that new instruction, `goto restart'. - */ - - { - struct rx_inx * next_tr_table; - struct rx_inx * this_tr_table; - /* The fastest route through the loop is when the instruction - * is RX_NEXT_CHAR. This case is detected when SEARCH_STATE.IFR->DATA - * is non-zero. In that case, it points to the next - * superstate. - * - * This allows us to not bother fetching the bytecode. - */ - next_tr_table = (struct rx_inx *)search_state.ifr->data; - this_tr_table = search_state.super->transitions; - while (next_tr_table) - { -#ifdef RX_DEBUG - if (rx_debug_trace) - { - struct rx_superset * setp; - - fprintf (stderr, "%d %d>> re_next_char @ %d (%d)", - search_state.line_no, - search_state.backtrack_depth, - (search_state.test_pos.pos - search_state.test_pos.string - + search_state.test_pos.offset), search_state.c); - - search_state.super = - ((struct rx_superstate *) - ((char *)this_tr_table - - ((unsigned long) - ((struct rx_superstate *)0)->transitions))); - - setp = search_state.super->contents; - fprintf (stderr, " superstet (rx=%d, &=%x: ", - rxb->rx.rx_id, setp); - while (setp) - { - fprintf (stderr, "%d ", setp->id); - setp = setp->cdr; - } - fprintf (stderr, "\n"); - } -#endif - this_tr_table = next_tr_table; - ++search_state.test_pos.pos; - if (search_state.test_pos.pos == search_state.test_pos.end) - { - int burst_state; - try_burst_1: - burst_state = get_burst (&search_state.test_pos, - app_closure, stop); - switch (burst_state) - { - case rx_get_burst_continuation: - search_state.saved_this_tr_table = this_tr_table; - search_state.saved_next_tr_table = next_tr_table; - test_pc = rx_test_cache_hit_loop; - goto test_return_continuation; - - resume_continuation_1: - /* Continuation one jumps here to do its work: */ - search_state.saved_this_tr_table = this_tr_table; - search_state.saved_next_tr_table = next_tr_table; - goto try_burst_1; - - case rx_get_burst_ok: - /* get_burst succeeded...keep going */ - break; - - case rx_get_burst_no_more: - search_state.test_ret = rx_test_line_finished; - search_state.could_have_continued = 1; - goto test_do_return; - - case rx_get_burst_error: - /* An error... */ - search_state.test_ret = rx_test_internal_error; - goto test_do_return; - } - } - search_state.c = *search_state.test_pos.pos; - search_state.ifr = this_tr_table + search_state.c; - next_tr_table = (struct rx_inx *)search_state.ifr->data; - } /* Fast loop through cached transition tables */ - - /* Here when we ran out of cached next-char transitions. - * So, it will be necessary to do a more expensive - * dispatch on the current instruction. The superstate - * pointer is allowed to become invalid during next-char - * transitions -- now we must bring it up to date. - */ - search_state.super = - ((struct rx_superstate *) - ((char *)this_tr_table - - ((unsigned long) - ((struct rx_superstate *)0)->transitions))); - } - - /* We've encountered an instruction other than next-char. - * Dispatch that instruction: - */ - inx = (int)search_state.ifr->inx; -#ifdef RX_DEBUG - if (rx_debug_trace) - { - struct rx_superset * setp = search_state.super->contents; - - fprintf (stderr, "%d %d>> %s @ %d (%d)", search_state.line_no, - search_state.backtrack_depth, - inx_names[inx], - (search_state.test_pos.pos - search_state.test_pos.string - + (test_pos.half == 0 ? 0 : size1)), search_state.c); - - fprintf (stderr, " superstet (rx=%d, &=%x: ", - rxb->rx.rx_id, setp); - while (setp) - { - fprintf (stderr, "%d ", setp->id); - setp = setp->cdr; - } - fprintf (stderr, "\n"); - } -#endif - switch ((enum rx_opcode)inx) - { - case rx_do_side_effects: - - /* RX_DO_SIDE_EFFECTS occurs when we cross epsilon - * edges associated with parentheses, backreferencing, etc. - */ - { - struct rx_distinct_future * df = - (struct rx_distinct_future *)search_state.ifr->data_2; - struct rx_se_list * el = df->effects; - /* Side effects come in lists. This walks down - * a list, dispatching. - */ - while (el) - { - long effect; - effect = (long)el->car; - if (effect < 0) - { -#ifdef RX_DEBUG - if (rx_debug_trace) - { - struct rx_superset * setp = search_state.super->contents; - - fprintf (stderr, "....%d %d>> %s\n", search_state.line_no, - search_state.backtrack_depth, - efnames[-effect]); - } -#endif - switch ((enum re_side_effects) effect) - - { - case re_se_pushback: - search_state.ifr = &df->future_frame; - if (!search_state.ifr->data) - { - struct rx_superstate * sup; - sup = search_state.super; - rx_lock_superstate (rx, sup); - if (!rx_handle_cache_miss (&rxb->rx, - search_state.super, - search_state.c, - (search_state.ifr - ->data_2))) - { - rx_unlock_superstate (rx, sup); - search_state.test_ret = rx_test_internal_error; - goto test_do_return; - } - rx_unlock_superstate (rx, sup); - } - /* --search_state.test_pos.pos; */ - search_state.c = 't'; - search_state.super - = ((struct rx_superstate *) - ((char *)search_state.ifr->data - - (long)(((struct rx_superstate *)0) - ->transitions))); - goto top_of_cycle; - break; - case re_se_push0: - { - struct rx_counter_frame * old_cf - = (search_state.counter_stack - ? ((struct rx_counter_frame *) - search_state.counter_stack->sp) - : 0); - struct rx_counter_frame * cf; - PUSH (search_state.counter_stack, - sizeof (struct rx_counter_frame)); - cf = ((struct rx_counter_frame *) - search_state.counter_stack->sp); - cf->tag = re_se_iter; - cf->val = 0; - cf->inherited_from = 0; - cf->cdr = old_cf; - break; - } - case re_se_fail: - goto test_do_return; - case re_se_begbuf: - if (!AT_STRINGS_BEG ()) - goto test_do_return; - break; - case re_se_endbuf: - if (!AT_STRINGS_END ()) - goto test_do_return; - break; - case re_se_wordbeg: - if ( LETTER_P (&search_state.test_pos, 1) - && ( AT_STRINGS_BEG() - || !LETTER_P (&search_state.test_pos, 0))) - break; - else - goto test_do_return; - case re_se_wordend: - if ( !AT_STRINGS_BEG () - && LETTER_P (&search_state.test_pos, 0) - && (AT_STRINGS_END () - || !LETTER_P (&search_state.test_pos, 1))) - break; - else - goto test_do_return; - case re_se_wordbound: - if (AT_WORD_BOUNDARY (&search_state.test_pos)) - break; - else - goto test_do_return; - case re_se_notwordbound: - if (!AT_WORD_BOUNDARY (&search_state.test_pos)) - break; - else - goto test_do_return; - case re_se_hat: - if (AT_STRINGS_BEG ()) - { - if (rxb->not_bol) - goto test_do_return; - else - break; - } - else - { - char pos_c = *search_state.test_pos.pos; - if ( (SRCH_TRANSLATE (pos_c) - == SRCH_TRANSLATE('\n')) - && rxb->newline_anchor) - break; - else - goto test_do_return; - } - case re_se_dollar: - if (AT_STRINGS_END ()) - { - if (rxb->not_eol) - goto test_do_return; - else - break; - } - else - { - if ( ( SRCH_TRANSLATE (fetch_char - (&search_state.test_pos, 1, - app_closure, stop)) - == SRCH_TRANSLATE ('\n')) - && rxb->newline_anchor) - break; - else - goto test_do_return; - } - - case re_se_try: - /* This is the first side effect in every - * expression. - * - * FOR NO GOOD REASON...get rid of it... - */ - break; - - case re_se_pushpos: - { - int urhere = - ((int)(search_state.test_pos.pos - - search_state.test_pos.string) - + search_state.test_pos.offset); - struct rx_counter_frame * old_cf - = (search_state.counter_stack - ? ((struct rx_counter_frame *) - search_state.counter_stack->sp) - : 0); - struct rx_counter_frame * cf; - PUSH(search_state.counter_stack, - sizeof (struct rx_counter_frame)); - cf = ((struct rx_counter_frame *) - search_state.counter_stack->sp); - cf->tag = re_se_pushpos; - cf->val = urhere; - cf->inherited_from = 0; - cf->cdr = old_cf; - break; - } - - case re_se_chkpos: - { - int urhere = - ((int)(search_state.test_pos.pos - - search_state.test_pos.string) - + search_state.test_pos.offset); - struct rx_counter_frame * cf - = ((struct rx_counter_frame *) - search_state.counter_stack->sp); - if (cf->val == urhere) - goto test_do_return; - cf->val = urhere; - break; - } - break; - - case re_se_poppos: - POP(search_state.counter_stack, - sizeof (struct rx_counter_frame)); - break; - - - case re_se_at_dot: - case re_se_syntax: - case re_se_not_syntax: -#ifdef emacs - this release lacks emacs support; - (coming soon); -#endif - break; - case re_se_win: - case re_se_lparen: - case re_se_rparen: - case re_se_backref: - case re_se_iter: - case re_se_end_iter: - case re_se_tv: - case re_floogle_flap: - search_state.ret_val = 0; - goto test_do_return; - } - } - else - { -#ifdef RX_DEBUG - if (rx_debug_trace) - fprintf (stderr, "....%d %d>> %s %d %d\n", search_state.line_no, - search_state.backtrack_depth, - efnames2[rxb->se_params [effect].se], - rxb->se_params [effect].op1, - rxb->se_params [effect].op2); -#endif - switch (rxb->se_params [effect].se) - { - case re_se_win: - /* This side effect indicates that we've - * found a match, though not necessarily the - * best match. This is a fancy assignment to - * register 0 unless the caller didn't - * care about registers. In which case, - * this stops the match. - */ - { - int urhere = - ((int)(search_state.test_pos.pos - - search_state.test_pos.string) - + search_state.test_pos.offset); - - if ( (search_state.best_last_r < 0) - || (urhere + 1 > search_state.best_rparen[0])) - { - /* Record the best known and keep - * looking. - */ - int x; - for (x = 0; x <= search_state.last_l; ++x) - search_state.best_lparen[x] = search_state.lparen[x]; - search_state.best_last_l = search_state.last_l; - for (x = 0; x <= search_state.last_r; ++x) - search_state.best_rparen[x] = search_state.rparen[x]; - search_state.best_rparen[0] = urhere + 1; - search_state.best_last_r = search_state.last_r; - } - /* If we're not reporting the match-length - * or other register info, we need look no - * further. - */ - if (search_state.first_found) - { - search_state.test_ret = rx_test_found_first; - goto test_do_return; - } - } - break; - case re_se_lparen: - { - int urhere = - ((int)(search_state.test_pos.pos - - search_state.test_pos.string) - + search_state.test_pos.offset); - - int reg = rxb->se_params [effect].op1; -#if 0 - if (reg > search_state.last_l) -#endif - { - search_state.lparen[reg] = urhere + 1; - /* In addition to making this assignment, - * we now know that lower numbered regs - * that haven't already been assigned, - * won't be. We make sure they're - * filled with -1, so they can be - * recognized as unassigned. - */ - if (search_state.last_l < reg) - while (++search_state.last_l < reg) - search_state.lparen[search_state.last_l] = -1; - } - break; - } - - case re_se_rparen: - { - int urhere = - ((int)(search_state.test_pos.pos - - search_state.test_pos.string) - + search_state.test_pos.offset); - int reg = rxb->se_params [effect].op1; - search_state.rparen[reg] = urhere + 1; - if (search_state.last_r < reg) - { - while (++search_state.last_r < reg) - search_state.rparen[search_state.last_r] - = -1; - } - break; - } - - case re_se_backref: - { - int reg = rxb->se_params [effect].op1; - if ( reg > search_state.last_r - || search_state.rparen[reg] < 0) - goto test_do_return; - - { - int backref_status; - check_backreference: - backref_status - = back_check (&search_state.test_pos, - search_state.lparen[reg], - search_state.rparen[reg], - search_state.translate, - app_closure, - stop); - switch (backref_status) - { - case rx_back_check_continuation: - search_state.saved_reg = reg; - test_pc = rx_test_backreference_check; - goto test_return_continuation; - resume_continuation_2: - reg = search_state.saved_reg; - goto check_backreference; - case rx_back_check_fail: - /* Fail */ - goto test_do_return; - case rx_back_check_pass: - /* pass -- - * test_pos now advanced to last - * char matched by backref - */ - break; - } - } - break; - } - case re_se_iter: - { - struct rx_counter_frame * csp - = ((struct rx_counter_frame *) - search_state.counter_stack->sp); - if (csp->val == rxb->se_params[effect].op2) - goto test_do_return; - else - ++csp->val; - break; - } - case re_se_end_iter: - { - struct rx_counter_frame * csp - = ((struct rx_counter_frame *) - search_state.counter_stack->sp); - if (csp->val < rxb->se_params[effect].op1) - goto test_do_return; - else - { - struct rx_counter_frame * source = csp; - while (source->inherited_from) - source = source->inherited_from; - if (!source || !source->cdr) - { - POP(search_state.counter_stack, - sizeof(struct rx_counter_frame)); - } - else - { - source = source->cdr; - csp->val = source->val; - csp->tag = source->tag; - csp->cdr = 0; - csp->inherited_from = source; - } - } - break; - } - case re_se_tv: - /* is a noop */ - break; - case re_se_try: - case re_se_pushback: - case re_se_push0: - case re_se_pushpos: - case re_se_chkpos: - case re_se_poppos: - case re_se_at_dot: - case re_se_syntax: - case re_se_not_syntax: - case re_se_begbuf: - case re_se_hat: - case re_se_wordbeg: - case re_se_wordbound: - case re_se_notwordbound: - case re_se_wordend: - case re_se_endbuf: - case re_se_dollar: - case re_se_fail: - case re_floogle_flap: - search_state.ret_val = 0; - goto test_do_return; - } - } - el = el->cdr; - } - /* Now the side effects are done, - * so get the next instruction. - * and move on. - */ - search_state.ifr = &df->future_frame; - goto restart; - } - - case rx_backtrack_point: - { - /* A backtrack point indicates that we've reached a - * non-determinism in the superstate NFA. This is a - * loop that exhaustively searches the possibilities. - * - * A backtracking strategy is used. We keep track of what - * registers are valid so we can erase side effects. - * - * First, make sure there is some stack space to hold - * our state. - */ - - struct rx_backtrack_frame * bf; - - PUSH(search_state.backtrack_stack, - search_state.backtrack_frame_bytes); -#ifdef RX_DEBUG - ++search_state.backtrack_depth; -#endif - - bf = ((struct rx_backtrack_frame *) - search_state.backtrack_stack->sp); - { - bf->stk_super = search_state.super; - /* We prevent the current superstate from being - * deleted from the superstate cache. - */ - rx_lock_superstate (&rxb->rx, search_state.super); -#ifdef RX_DEBUG - bf->stk_search_state.line_no = search_state.line_no; -#endif - bf->stk_c = search_state.c; - bf->stk_test_pos = search_state.test_pos; - bf->stk_last_l = search_state.last_l; - bf->stk_last_r = search_state.last_r; - bf->df = ((struct rx_super_edge *) - search_state.ifr->data_2)->options; - bf->first_df = bf->df; - bf->counter_stack_sp = (search_state.counter_stack - ? search_state.counter_stack->sp - : 0); - bf->stk_test_ret = search_state.test_ret; - if (rxb->match_regs_on_stack) - { - int x; - int * stk = - (int *)((char *)bf + sizeof (*bf)); - for (x = 0; x <= search_state.last_l; ++x) - stk[x] = search_state.lparen[x]; - stk += x; - for (x = 0; x <= search_state.last_r; ++x) - stk[x] = search_state.rparen[x]; - } - } - - /* Here is a while loop whose body is mainly a function - * call and some code to handle a return from that - * function. - * - * From here on for the rest of `case backtrack_point' it - * is unsafe to assume that the search_state copies of - * variables saved on the backtracking stack are valid - * -- so read their values from the backtracking stack. - * - * This lets us use one generation fewer stack saves in - * the call-graph of a search. - */ - - while_non_det_options: -#ifdef RX_DEBUG - ++search_state.lines_found; - if (rx_debug_trace) - fprintf (stderr, "@@@ %d calls %d @@@\n", - search_state.line_no, search_state.lines_found); - - search_state.line_no = search_state.lines_found; -#endif - - if (bf->df->next_same_super_edge[0] == bf->first_df) - { - /* This is a tail-call optimization -- we don't recurse - * for the last of the possible futures. - */ - search_state.ifr = (bf->df->effects - ? &bf->df->side_effects_frame - : &bf->df->future_frame); - - rx_unlock_superstate (&rxb->rx, search_state.super); - POP(search_state.backtrack_stack, - search_state.backtrack_frame_bytes); -#ifdef RX_DEBUG - --search_state.backtrack_depth; -#endif - goto restart; - } - else - { - if (search_state.counter_stack) - { - struct rx_counter_frame * old_cf - = ((struct rx_counter_frame *)search_state.counter_stack->sp); - struct rx_counter_frame * cf; - PUSH(search_state.counter_stack, sizeof (struct rx_counter_frame)); - cf = ((struct rx_counter_frame *)search_state.counter_stack->sp); - cf->tag = old_cf->tag; - cf->val = old_cf->val; - cf->inherited_from = old_cf; - cf->cdr = 0; - } - /* `Call' this test-match block */ - search_state.ifr = (bf->df->effects - ? &bf->df->side_effects_frame - : &bf->df->future_frame); - goto recurse_test_match; - } - - /* Returns in this block are accomplished by - * goto test_do_return. There are two cases. - * If there is some search-stack left, - * then it is a return from a `recursive' call. - * If there is no search-stack left, then - * we should return to the fastmap/search loop. - */ - - test_do_return: - - if (!search_state.backtrack_stack) - { -#ifdef RX_DEBUG - if (rx_debug_trace) - fprintf (stderr, "!!! %d bails returning %d !!!\n", - search_state.line_no, search_state.test_ret); -#endif - - /* No more search-stack -- this test is done. */ - if (search_state.test_ret) - goto return_from_test_match; - else - goto error_in_testing_match; - } - - /* Returning from a recursive call to - * the test match block: - */ - - bf = ((struct rx_backtrack_frame *) - search_state.backtrack_stack->sp); -#ifdef RX_DEBUG - if (rx_debug_trace) - fprintf (stderr, "+++ %d returns %d (to %d)+++\n", - search_state.line_no, - search_state.test_ret, - bf->stk_search_state.line_no); -#endif - - while (search_state.counter_stack - && (!bf->counter_stack_sp - || (bf->counter_stack_sp - != search_state.counter_stack->sp))) - { - POP(search_state.counter_stack, - sizeof (struct rx_counter_frame)); - } - - if (search_state.test_ret == rx_test_error) - { - POP (search_state.backtrack_stack, - search_state.backtrack_frame_bytes); - goto test_do_return; - } - - /* If a non-longest match was found and that is good - * enough, return immediately. - */ - if ( (search_state.test_ret == rx_test_found_first) - && search_state.first_found) - { - rx_unlock_superstate (&rxb->rx, bf->stk_super); - POP (search_state.backtrack_stack, - search_state.backtrack_frame_bytes); - goto test_do_return; - } - - search_state.test_ret = bf->stk_test_ret; - search_state.last_l = bf->stk_last_l; - search_state.last_r = bf->stk_last_r; - bf->df = bf->df->next_same_super_edge[0]; - search_state.super = bf->stk_super; - search_state.c = bf->stk_c; -#ifdef RX_DEBUG - search_state.line_no = bf->stk_search_state.line_no; -#endif - - if (rxb->match_regs_on_stack) - { - int x; - int * stk = - (int *)((char *)bf + sizeof (*bf)); - for (x = 0; x <= search_state.last_l; ++x) - search_state.lparen[x] = stk[x]; - stk += x; - for (x = 0; x <= search_state.last_r; ++x) - search_state.rparen[x] = stk[x]; - } - - { - int x; - try_burst_2: - x = get_burst (&bf->stk_test_pos, app_closure, stop); - switch (x) - { - case rx_get_burst_continuation: - search_state.saved_bf = bf; - test_pc = rx_test_backtrack_return; - goto test_return_continuation; - resume_continuation_3: - bf = search_state.saved_bf; - goto try_burst_2; - case rx_get_burst_no_more: - /* Since we've been here before, it is some kind of - * error that we can't return. - */ - case rx_get_burst_error: - search_state.test_ret = rx_test_internal_error; - goto test_do_return; - case rx_get_burst_ok: - break; - } - } - search_state.test_pos = bf->stk_test_pos; - goto while_non_det_options; - } - - - case rx_cache_miss: - /* Because the superstate NFA is lazily constructed, - * and in fact may erode from underneath us, we sometimes - * have to construct the next instruction from the hard way. - * This invokes one step in the lazy-conversion. - */ - search_state.ifr = rx_handle_cache_miss (&rxb->rx, - search_state.super, - search_state.c, - search_state.ifr->data_2); - if (!search_state.ifr) - { - search_state.test_ret = rx_test_internal_error; - goto test_do_return; - } - goto restart; - - case rx_backtrack: - /* RX_BACKTRACK means that we've reached the empty - * superstate, indicating that match can't succeed - * from this point. - */ - goto test_do_return; - - case rx_next_char: - case rx_error_inx: - case rx_num_instructions: - search_state.ret_val = 0; - goto test_do_return; - } - goto pseudo_while_1; - } - - /* Healthy exits from the test-match loop do a - * `goto return_from_test_match' On the other hand, - * we might end up here. - */ - error_in_testing_match: - test_state = rx_test_error; - goto test_returns_to_search; - - /***** fastmap/search loop body - * considering the results testing for a match - */ - - return_from_test_match: - - if (search_state.best_last_l >= 0) - { - if (regs && (regs->start != search_state.best_lparen)) - { - bcopy (search_state.best_lparen, regs->start, - regs->num_regs * sizeof (int)); - bcopy (search_state.best_rparen, regs->end, - regs->num_regs * sizeof (int)); - } - if (regs && !rxb->no_sub) - { - int q; - int bound = (regs->num_regs > search_state.num_regs - ? regs->num_regs - : search_state.num_regs); - int * s = regs->start; - int * e = regs->end; - for (q = search_state.best_last_l + 1; q < bound; ++q) - s[q] = e[q] = -1; - } - search_state.ret_val = search_state.best_lparen[0]; - test_state = rx_test_ok; - goto test_returns_to_search; - } - else - { - test_state = rx_test_fail; - goto test_returns_to_search; - } - - test_return_continuation: - search_state.test_match_resume_pt = test_pc; - test_state = rx_test_continuation; - goto test_returns_to_search; - } -} - - - -#endif /* RX_WANT_RX_DEFS */ - - - -#else /* RX_WANT_SE_DEFS */ - /* Integers are used to represent side effects. - * - * Simple side effects are given negative integer names by these enums. - * - * Non-negative names are reserved for complex effects. - * - * Complex effects are those that take arguments. For example, - * a register assignment associated with a group is complex because - * it requires an argument to tell which group is being matched. - * - * The integer name of a complex effect is an index into rxb->se_params. - */ - - RX_DEF_SE(1, re_se_try, = -1) /* Epsilon from start state */ - - RX_DEF_SE(0, re_se_pushback, = re_se_try - 1) - RX_DEF_SE(0, re_se_push0, = re_se_pushback -1) - RX_DEF_SE(0, re_se_pushpos, = re_se_push0 - 1) - RX_DEF_SE(0, re_se_chkpos, = re_se_pushpos -1) - RX_DEF_SE(0, re_se_poppos, = re_se_chkpos - 1) - - RX_DEF_SE(1, re_se_at_dot, = re_se_poppos - 1) /* Emacs only */ - RX_DEF_SE(0, re_se_syntax, = re_se_at_dot - 1) /* Emacs only */ - RX_DEF_SE(0, re_se_not_syntax, = re_se_syntax - 1) /* Emacs only */ - - RX_DEF_SE(1, re_se_begbuf, = re_se_not_syntax - 1) /* match beginning of buffer */ - RX_DEF_SE(1, re_se_hat, = re_se_begbuf - 1) /* match beginning of line */ - - RX_DEF_SE(1, re_se_wordbeg, = re_se_hat - 1) - RX_DEF_SE(1, re_se_wordbound, = re_se_wordbeg - 1) - RX_DEF_SE(1, re_se_notwordbound, = re_se_wordbound - 1) - - RX_DEF_SE(1, re_se_wordend, = re_se_notwordbound - 1) - RX_DEF_SE(1, re_se_endbuf, = re_se_wordend - 1) - - /* This fails except at the end of a line. - * It deserves to go here since it is typicly one of the last steps - * in a match. - */ - RX_DEF_SE(1, re_se_dollar, = re_se_endbuf - 1) - - /* Simple effects: */ - RX_DEF_SE(1, re_se_fail, = re_se_dollar - 1) - - /* Complex effects. These are used in the 'se' field of - * a struct re_se_params. Indexes into the se array - * are stored as instructions on nfa edges. - */ - RX_DEF_CPLX_SE(1, re_se_win, = 0) - RX_DEF_CPLX_SE(1, re_se_lparen, = re_se_win + 1) - RX_DEF_CPLX_SE(1, re_se_rparen, = re_se_lparen + 1) - RX_DEF_CPLX_SE(0, re_se_backref, = re_se_rparen + 1) - RX_DEF_CPLX_SE(0, re_se_iter, = re_se_backref + 1) - RX_DEF_CPLX_SE(0, re_se_end_iter, = re_se_iter + 1) - RX_DEF_CPLX_SE(0, re_se_tv, = re_se_end_iter + 1) - -#endif - -#endif diff --git a/gnu/lib/libg++/include/std.h b/gnu/lib/libg++/include/std.h deleted file mode 100644 index dcafc354c045..000000000000 --- a/gnu/lib/libg++/include/std.h +++ /dev/null @@ -1,35 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _std_h -#define _std_h 1 - -#include <_G_config.h> -#include <defines.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <stdio.h> -#include <errno.h> -#include <fcntl.h> - -extern "C" { -int strcasecmp _G_ARGS((const char*, const char*)); -} - -#endif diff --git a/gnu/lib/libg++/include/stdiostream.h b/gnu/lib/libg++/include/stdiostream.h deleted file mode 100644 index 8c8215e14dcd..000000000000 --- a/gnu/lib/libg++/include/stdiostream.h +++ /dev/null @@ -1,77 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -/* Written by Per Bothner (bothner@cygnus.com). */ - -#ifndef _STDIOSTREAM_H -#define _STDIOSTREAM_H - -#ifdef __GNUG__ -#pragma interface -#endif - -#include <iostream.h> -#include <stdio.h> - -class stdiobuf : public filebuf { - protected: - FILE *_file; - public: - FILE* stdiofile() const { return _file; } - stdiobuf(FILE *); - ~stdiobuf(); - int buffered () const { return _flags & _IO_UNBUFFERED ? 0 : 1; } - void buffered (int); - virtual streamsize sys_read(char*, streamsize); - virtual streampos sys_seek(streamoff, _seek_dir); - virtual streamsize sys_write(const char*, streamsize); - virtual int sys_close(); - virtual int sync(); - virtual int overflow(int c = EOF); - streamsize xsputn(const char* s, streamsize n); -}; - -class istdiostream : public istream -{ -private: - stdiobuf _file; -public: - istdiostream (FILE* __f) : _file(__f), istream() { init(&_file); } - stdiobuf* rdbuf()/* const */ { return &_file; } - int buffered () const { return _file.buffered (); } - void buffered (int _i) { _file.buffered (_i); } -}; - -class ostdiostream : public ostream -{ -private: - stdiobuf _file; -public: - ostdiostream (FILE* __f) : _file(__f), ostream() { init(&_file); } - stdiobuf* rdbuf() /* const */ { return &_file; } - int buffered () const { return _file.buffered (); } - void buffered (int _i) { _file.buffered (_i); } -}; - -#endif /* !_STDIOSTREAM_H */ diff --git a/gnu/lib/libg++/include/stream.h b/gnu/lib/libg++/include/stream.h deleted file mode 100644 index f9569a5582d7..000000000000 --- a/gnu/lib/libg++/include/stream.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#ifndef _COMPAT_STREAM_H -#define _COMPAT_STREAM_H - -// Compatibility with old library. - -#define _STREAM_COMPAT -#include <iostream.h> - -extern char* form(const char*, ...); - -extern char* dec(long, int=0); -extern char* dec(int, int=0); -extern char* dec(unsigned long, int=0); -extern char* dec(unsigned int, int=0); - -extern char* hex(long, int=0); -extern char* hex(int, int=0); -extern char* hex(unsigned long, int=0); -extern char* hex(unsigned int, int=0); - -extern char* oct(long, int=0); -extern char* oct(int, int=0); -extern char* oct(unsigned long, int=0); -extern char* oct(unsigned int, int=0); - -char* chr(char ch, int width = 0); -char* str(const char* s, int width = 0); - -inline istream& WS(istream& str) { return ws(str); } - -#endif /* !_COMPAT_STREAM_H */ diff --git a/gnu/lib/libg++/include/streambuf.h b/gnu/lib/libg++/include/streambuf.h deleted file mode 100644 index 7a3df54fcb69..000000000000 --- a/gnu/lib/libg++/include/streambuf.h +++ /dev/null @@ -1,454 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#ifndef _STREAMBUF_H -#define _STREAMBUF_H -#ifdef __GNUG__ -#pragma interface -#endif - -/* #define _G_IO_THROW */ /* Not implemented: ios::failure */ - -extern "C" { -#include <libio.h> -} -//#include <_G_config.h> -#ifdef _IO_NEED_STDARG_H -#include <stdarg.h> -#endif -#ifndef _IO_va_list -#define _IO_va_list char * -#endif - -#ifndef EOF -#define EOF (-1) -#endif -#ifndef NULL -#ifdef __GNUC__ -#define NULL ((void*)0) -#else -#define NULL (0) -#endif -#endif - -#ifndef _IO_wchar_t -#define _IO_wchar_t short -#endif - -class istream; /* Work-around for a g++ name mangling bug. Fixed in 2.6. */ -class ostream; class streambuf; - -// In case some header files defines these as macros. -#undef open -#undef close - -extern "C" int __underflow(struct _IO_FILE*); -extern "C" int __overflow(struct _IO_FILE*, int); - -typedef _IO_off_t streamoff; -typedef _IO_fpos_t streampos; -typedef _IO_ssize_t streamsize; - -typedef unsigned long __fmtflags; -typedef unsigned char __iostate; - -struct _ios_fields -{ // The data members of an ios. - // Directly using _strbuf is dangerous, because the vtable - // pointer can be NULL. Use rdbuf() when in doubt. - streambuf *_strbuf; - ostream* _tie; - int _width; - __fmtflags _flags; - _IO_wchar_t _fill; - __iostate _state; - __iostate _exceptions; - int _precision; - - void *_arrays; /* Support for ios::iword and ios::pword. */ -}; - -#define _IOS_GOOD 0 -#define _IOS_EOF 1 -#define _IOS_FAIL 2 -#define _IOS_BAD 4 - -#define _IO_INPUT 1 -#define _IO_OUTPUT 2 -#define _IO_ATEND 4 -#define _IO_APPEND 8 -#define _IO_TRUNC 16 -#define _IO_NOCREATE 32 -#define _IO_NOREPLACE 64 -#define _IO_BIN 128 - -#ifdef _STREAM_COMPAT -enum state_value { - _good = _IOS_GOOD, - _eof = _IOS_EOF, - _fail = _IOS_FAIL, - _bad = _IOS_BAD }; -enum open_mode { - input = _IO_INPUT, - output = _IO_OUTPUT, - atend = _IO_ATEND, - append = _IO_APPEND }; -#endif - -class ios : public _ios_fields { - ios& operator=(ios&); /* Not allowed! */ - public: - typedef __fmtflags fmtflags; - typedef int iostate; - typedef int openmode; - typedef int streamsize; - enum io_state { - goodbit = _IOS_GOOD, - eofbit = _IOS_EOF, - failbit = _IOS_FAIL, - badbit = _IOS_BAD }; - enum open_mode { - in = _IO_INPUT, - out = _IO_OUTPUT, - ate = _IO_ATEND, - app = _IO_APPEND, - trunc = _IO_TRUNC, - nocreate = _IO_NOCREATE, - noreplace = _IO_NOREPLACE, - bin = _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(). - enum { skipws=_IO_SKIPWS, - left=_IO_LEFT, right=_IO_RIGHT, internal=_IO_INTERNAL, - dec=_IO_DEC, oct=_IO_OCT, hex=_IO_HEX, - showbase=_IO_SHOWBASE, showpoint=_IO_SHOWPOINT, - uppercase=_IO_UPPERCASE, showpos=_IO_SHOWPOS, - scientific=_IO_SCIENTIFIC, fixed=_IO_FIXED, - unitbuf=_IO_UNITBUF, stdio=_IO_STDIO, - dont_close=_IO_DONT_CLOSE // Don't delete streambuf on stream destruction - }; - enum { // Masks. - basefield=dec+oct+hex, - floatfield = scientific+fixed, - adjustfield = left+right+internal - }; - -#ifdef _IO_THROW - class failure : public xmsg { - ios* _stream; - public: - failure(ios* stream) { _stream = stream; } - failure(string cause, ios* stream) { _stream = stream; } - ios* rdios() const { return _stream; } - }; -#endif - - ostream* tie() const { return _tie; } - ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; } - - // Methods to change the format state. - _IO_wchar_t fill() const { return (_IO_wchar_t)_fill; } - _IO_wchar_t fill(_IO_wchar_t newf) - {_IO_wchar_t oldf = (_IO_wchar_t)_fill; _fill = (char)newf; return oldf;} - fmtflags flags() const { return _flags; } - fmtflags flags(fmtflags new_val) { - fmtflags old_val = _flags; _flags = new_val; return old_val; } - int precision() const { return _precision; } - int precision(int newp) { - unsigned short oldp = _precision; _precision = (unsigned short)newp; - return oldp; } - fmtflags setf(fmtflags val) { - fmtflags oldbits = _flags; - _flags |= val; return oldbits; } - fmtflags setf(fmtflags val, fmtflags mask) { - fmtflags oldbits = _flags; - _flags = (_flags & ~mask) | (val & mask); return oldbits; } - fmtflags unsetf(fmtflags mask) { - fmtflags oldbits = _flags; - _flags &= ~mask; return oldbits; } - int width() const { return _width; } - int width(int val) { int save = _width; _width = val; return save; } - -#ifdef _IO_THROW - void _throw_failure() const { throw new ios::failure(this); } -#else - void _throw_failure() const { } -#endif - streambuf* rdbuf() const { return _strbuf; } -#ifdef _STREAM_COMPAT - void _IO_fix_vtable(); /* TEMPORARY - for binary compatibility */ - void _IO_fix_vtable() const; /* TEMPORARY - for binary compatibility */ -#endif - streambuf* rdbuf(streambuf *_s) { - streambuf *_old = _strbuf; _strbuf = _s; clear (); return _old; } - void clear(iostate state = 0) { - _state = _strbuf ? state : state|badbit; - if (_state & _exceptions) _throw_failure(); } - void set(iostate flag) { _state |= flag; - if (_state & _exceptions) _throw_failure(); } - void setstate(iostate flag) { _state |= flag; // ANSI - if (_state & _exceptions) _throw_failure(); } - int good() const { return _state == 0; } - int eof() const { return _state & ios::eofbit; } - int fail() const { return _state & (ios::badbit|ios::failbit); } - int bad() const { return _state & ios::badbit; } - iostate rdstate() const { return _state; } - operator void*() const { return fail() ? (void*)0 : (void*)(-1); } - int operator!() const { return fail(); } - iostate exceptions() const { return _exceptions; } - void exceptions(iostate enable) { - _exceptions = enable; - if (_state & _exceptions) _throw_failure(); } - - static int sync_with_stdio(int on); - static void sync_with_stdio() { sync_with_stdio(1); } - static fmtflags bitalloc(); - static int xalloc(); - void*& pword(int); - void* pword(int) const; - long& iword(int); - long iword(int) const; - -#ifdef _STREAM_COMPAT - void unset(state_value flag) { _state &= ~flag; } - void close(); - int is_open(); - int readable(); - int writable(); -#endif - - // Used to initialize standard streams. Not needed in this implementation. - class Init { - public: - Init () { } - }; - - protected: - ios(streambuf* sb = 0, ostream* tie_to = 0) { init(sb, tie_to); } - virtual ~ios(); - void init(streambuf* sb, ostream* tie = 0); -}; - -#if __GNUG__==1 -typedef int _seek_dir; -#else -typedef ios::seek_dir _seek_dir; -#endif - -// Magic numbers and bits for the _flags field. -// The magic numbers use the high-order bits of _flags; -// the remaining bits are abailable for variable flags. -// Note: The magic numbers must all be negative if stdio -// emulation is desired. - -// A streammarker remembers a position in a buffer. -// You are guaranteed to be able to seek back to it if it is saving(). -class streammarker : private _IO_marker { - friend class streambuf; - void set_offset(int offset) { _pos = offset; } - public: - streammarker(streambuf *sb); - ~streammarker(); - int saving() { return 1; } - int delta(streammarker&); - int delta(); -}; - -extern unsigned __adjust_column(unsigned start, const char *line, int count); - -struct streambuf : public _IO_FILE { // protected?? - friend class ios; - friend class istream; - friend class ostream; - friend class streammarker; - const void *&_vtable() { return *(const void**)((_IO_FILE*)this + 1); } - protected: - static streambuf* _list_all; /* List of open streambufs. */ - _IO_FILE*& xchain() { return _chain; } - void _un_link(); - void _link_in(); - char* gptr() const - { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_base : _IO_read_ptr; } - char* pptr() const { return _IO_write_ptr; } - char* egptr() const - { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_end : _IO_read_end; } - char* epptr() const { return _IO_write_end; } - char* pbase() const { return _IO_write_base; } - char* eback() const - { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_base : _IO_read_base;} - char* base() const { return _IO_buf_base; } - char* ebuf() const { return _IO_buf_end; } - int blen() const { return _IO_buf_end - _IO_buf_base; } - void xput_char(char c) { *_IO_write_ptr++ = c; } - int xflags() { return _IO_file_flags; } - int xflags(int f) {int fl = _IO_file_flags; _IO_file_flags = f; return fl;} - void xsetflags(int f) { _IO_file_flags |= f; } - void xsetflags(int f, int mask) - { _IO_file_flags = (_IO_file_flags & ~mask) | (f & mask); } - void gbump(int n) - { _IO_file_flags & _IO_IN_BACKUP ? (_IO_save_base+=n):(_IO_read_ptr+=n);} - void pbump(int n) { _IO_write_ptr += n; } - void setb(char* b, char* eb, int a=0); - void setp(char* p, char* ep) - { _IO_write_base=_IO_write_ptr=p; _IO_write_end=ep; } - void setg(char* eb, char* g, char *eg) { - if (_IO_file_flags & _IO_IN_BACKUP) _IO_free_backup_area(this); - _IO_read_base = eb; _IO_read_ptr = g; _IO_read_end = eg; } - char *shortbuf() { return _shortbuf; } - - int in_backup() { return _flags & _IO_IN_BACKUP; } - // The start of the main get area: FIXME: wrong for write-mode filebuf? - char *Gbase() { return in_backup() ? _IO_save_base : _IO_read_base; } - // The end of the main get area: - char *eGptr() { return in_backup() ? _IO_save_end : _IO_read_end; } - // The start of the backup area: - char *Bbase() { return in_backup() ? _IO_read_base : _IO_save_base; } - char *Bptr() { return _IO_backup_base; } - // The end of the backup area: - char *eBptr() { return in_backup() ? _IO_read_end : _IO_save_end; } - char *Nbase() { return _IO_save_base; } - char *eNptr() { return _IO_save_end; } - int have_backup() { return _IO_save_base != NULL; } - int have_markers() { return _markers != NULL; } - void free_backup_area(); - void unsave_markers(); // Make all streammarkers !saving(). - int put_mode() { return _flags & _IO_CURRENTLY_PUTTING; } - int switch_to_get_mode(); - - streambuf(int flags=0); - public: - static int flush_all(); - static void flush_all_linebuffered(); // Flush all line buffered files. - virtual int underflow(); // Leave public for now - virtual int overflow(int c = EOF); // Leave public for now - virtual int doallocate(); - streampos sseekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); - streampos sseekpos(streampos pos, int mode = ios::in|ios::out); - - virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); - virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out); - int seekmark(streammarker& mark, int delta = 0); - int sputbackc(char c); - int sungetc(); - virtual ~streambuf(); - int unbuffered() { return _flags & _IO_UNBUFFERED ? 1 : 0; } - int linebuffered() { return _flags & _IO_LINE_BUF ? 1 : 0; } - void unbuffered(int i) - { if (i) _flags |= _IO_UNBUFFERED; else _flags &= ~_IO_UNBUFFERED; } - void linebuffered(int i) - { if (i) _flags |= _IO_LINE_BUF; else _flags &= ~_IO_LINE_BUF; } - int allocate() { // For AT&T compatibility - if (base() || unbuffered()) return 0; - else return doallocate(); } - // Allocate a buffer if needed; use _shortbuf if appropriate. - void allocbuf() { if (base() == NULL) doallocbuf(); } - void doallocbuf(); - virtual int sync(); - virtual int pbackfail(int c); - virtual streambuf* setbuf(char* p, int len); - int in_avail() { return _IO_read_end - _IO_read_ptr; } - int out_waiting() { return _IO_write_ptr - _IO_write_base; } - virtual streamsize xsputn(const char* s, streamsize n); - streamsize sputn(const char* s, streamsize n) { return xsputn(s, n); } - streamsize padn(char pad, streamsize n) { return _IO_padn(this, pad, n); } - virtual streamsize xsgetn(char* s, streamsize n); - streamsize sgetn(char* s, streamsize n) { return _IO_sgetn(this, s, n); } - int ignore(int); - virtual int get_column(); - virtual int set_column(int); - long sgetline(char* buf, _IO_size_t n, char delim, int putback_delim); - int sputc(int c) { return _IO_putc(c, this); } - int sbumpc() { return _IO_getc(this); } - int sgetc() { return _IO_peekc(this); } - int snextc() { - if (_IO_read_ptr >= _IO_read_end && __underflow(this) == EOF) - return EOF; - else return _IO_read_ptr++, sgetc(); } - void stossc() { if (_IO_read_ptr < _IO_read_end) _IO_read_ptr++; } - int vscan(char const *fmt0, _IO_va_list ap, ios* stream = NULL); - int scan(char const *fmt0 ...); - int vform(char const *fmt0, _IO_va_list ap); - int form(char const *fmt0 ...); -#if 0 /* Work in progress */ - int column(); // Current column number (of put pointer). -1 is unknown. - void column(int c); // Set column number of put pointer to c. -#endif - virtual streamsize sys_read(char* buf, streamsize size); - virtual streampos sys_seek(streamoff, _seek_dir); - virtual streamsize sys_write(const char*, streamsize); - virtual int sys_stat(void*); // Actually, a (struct stat*) - virtual int sys_close(); -}; - -// A backupbuf is a streambuf with full backup and savepoints on reading. -// All standard streambufs in the GNU iostream library are backupbufs. - -class filebuf : public streambuf { - protected: - void init(); - public: - static const int openprot; // Non-ANSI AT&T-ism: Default open protection. - filebuf(); - filebuf(int fd); - filebuf(int fd, char* p, int len); - static filebuf *__new(); - ~filebuf(); - filebuf* attach(int fd); - filebuf* open(const char *filename, const char *mode); - filebuf* open(const char *filename, ios::openmode mode, int prot = 0664); - virtual int underflow(); - virtual int overflow(int c = EOF); - int is_open() const { return _fileno >= 0; } - int fd() const { return is_open() ? _fileno : EOF; } - filebuf* close(); - virtual int doallocate(); - virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); - virtual streambuf* setbuf(char* p, int len); - streamsize xsputn(const char* s, streamsize n); - streamsize xsgetn(char* s, streamsize n); - virtual int sync(); - protected: // See documentation in filebuf.C. -// virtual int pbackfail(int c); - int is_reading() { return eback() != egptr(); } - char* cur_ptr() { return is_reading() ? gptr() : pptr(); } - /* System's idea of pointer */ - char* file_ptr() { return eGptr(); } - int do_write(const char *data, int to_do); - // Low-level operations (Usually invoke system calls.) - virtual streamsize sys_read(char* buf, streamsize size); - virtual streampos sys_seek(streamoff, _seek_dir); - virtual streamsize sys_write(const char*, streamsize); - virtual int sys_stat(void*); // Actually, a (struct stat*) - virtual int sys_close(); -}; - -inline void ios::init(streambuf* sb, ostream* tie_to) { - _state = sb ? ios::goodbit : ios::badbit; _exceptions=0; - _strbuf=sb; _tie = tie_to; _width=0; _fill=' '; - _flags=ios::skipws|ios::dec; _precision=6; _arrays = 0; } - -inline ios::~ios() { - if (!(_flags & (unsigned int)ios::dont_close)) delete rdbuf(); } -#endif /* _STREAMBUF_H */ diff --git a/gnu/lib/libg++/include/strfile.h b/gnu/lib/libg++/include/strfile.h deleted file mode 100644 index 950f2f56b3b5..000000000000 --- a/gnu/lib/libg++/include/strfile.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -#include <libio.h> -#ifdef TODO -Merge into libio.h ? -#endif - -typedef void *(*_IO_alloc_type) __P((_IO_size_t)); -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; -}; - -typedef struct _IO_strfile_ -{ - struct _IO_FILE _f; - const void *_vtable; - struct _IO_str_fields _s; -} _IO_strfile; diff --git a/gnu/lib/libg++/include/strstream.h b/gnu/lib/libg++/include/strstream.h deleted file mode 100644 index 3c8fd5492fd7..000000000000 --- a/gnu/lib/libg++/include/strstream.h +++ /dev/null @@ -1,109 +0,0 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -/* Written by Per Bothner (bothner@cygnus.com). */ - -#ifndef __STRSTREAM_H -#define __STRSTREAM_H -#ifdef __GNUG__ -#pragma interface -#endif -#include <iostream.h> -#include <strfile.h> - -class strstreambuf : public streambuf -{ - struct _IO_str_fields _s; - - void init_dynamic(_IO_alloc_type alloc, _IO_free_type free, - int initial_size = 128); - 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); - public: - virtual ~strstreambuf(); - strstreambuf() { init_dynamic(0, 0); } - strstreambuf(int initial_size) { init_dynamic(0, 0, initial_size); } - strstreambuf(void *(*alloc)(_IO_size_t), void (*free)(void*)) - { init_dynamic(alloc, free); } - strstreambuf(char *ptr, int size, char *pstart = NULL) - { init_static(ptr, size, pstart); } - strstreambuf(unsigned char *ptr, int size, unsigned char *pstart = NULL) - { init_static((char*)ptr, size, (char*)pstart); } - strstreambuf(const char *ptr, int size) - { init_readonly(ptr, size); } - strstreambuf(const unsigned char *ptr, int size) - { init_readonly((const char*)ptr, size); } - strstreambuf(signed char *ptr, int size, signed char *pstart = NULL) - { 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(). - int frozen() { return _flags & _IO_USER_BUF ? 1 : 0; } - void freeze(int n=1) - { if (!is_static()) - { if (n) _flags |= _IO_USER_BUF; else _flags &= ~_IO_USER_BUF; } } - _IO_ssize_t pcount(); - char *str(); - virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); -}; - -class strstreambase : virtual public ios { - public: - strstreambuf* rdbuf() { return (strstreambuf*)ios::rdbuf(); } - protected: - strstreambase() { } - strstreambase(char *cp, int n, int mode=ios::out); -}; - -class istrstream : public strstreambase, public istream { - public: - istrstream(const char*, int=0); -}; - -class ostrstream : public strstreambase, public ostream { - public: - 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(); } - void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); } - int frozen() { return ((strstreambuf*)_strbuf)->frozen(); } -}; - -class strstream : public strstreambase, public iostream { - public: - strstream() : strstreambase() { init(new strstreambuf()); } - 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(); } - void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); } - int frozen() { return ((strstreambuf*)_strbuf)->frozen(); } -}; - -#endif /*!__STRSTREAM_H*/ |
