summaryrefslogtreecommitdiffstats
path: root/gnu/lib/libg++/include
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/lib/libg++/include')
-rw-r--r--gnu/lib/libg++/include/ACG.h68
-rw-r--r--gnu/lib/libg++/include/AllocRing.h62
-rw-r--r--gnu/lib/libg++/include/Binomial.h55
-rw-r--r--gnu/lib/libg++/include/BitSet.h374
-rw-r--r--gnu/lib/libg++/include/BitString.h761
-rw-r--r--gnu/lib/libg++/include/Complex.h276
-rw-r--r--gnu/lib/libg++/include/CursesW.h590
-rw-r--r--gnu/lib/libg++/include/DLList.h126
-rw-r--r--gnu/lib/libg++/include/DiscUnif.h72
-rw-r--r--gnu/lib/libg++/include/Erlang.h68
-rw-r--r--gnu/lib/libg++/include/Fix.h513
-rw-r--r--gnu/lib/libg++/include/Fix16.h648
-rw-r--r--gnu/lib/libg++/include/Fix24.h597
-rw-r--r--gnu/lib/libg++/include/Geom.h52
-rw-r--r--gnu/lib/libg++/include/GetOpt.h129
-rw-r--r--gnu/lib/libg++/include/HypGeom.h70
-rw-r--r--gnu/lib/libg++/include/Integer.h1119
-rw-r--r--gnu/lib/libg++/include/Integer.hP30
-rw-r--r--gnu/lib/libg++/include/LogNorm.h78
-rw-r--r--gnu/lib/libg++/include/MLCG.h87
-rw-r--r--gnu/lib/libg++/include/NegExp.h55
-rw-r--r--gnu/lib/libg++/include/Normal.h66
-rw-r--r--gnu/lib/libg++/include/Obstack.h216
-rw-r--r--gnu/lib/libg++/include/Pix.h5
-rw-r--r--gnu/lib/libg++/include/PlotFile.h121
-rw-r--r--gnu/lib/libg++/include/Poisson.h51
-rw-r--r--gnu/lib/libg++/include/RNG.h58
-rw-r--r--gnu/lib/libg++/include/Random.h54
-rw-r--r--gnu/lib/libg++/include/Rational.h288
-rw-r--r--gnu/lib/libg++/include/Regex.h76
-rw-r--r--gnu/lib/libg++/include/RndInt.h175
-rw-r--r--gnu/lib/libg++/include/SFile.h53
-rw-r--r--gnu/lib/libg++/include/SLList.h115
-rw-r--r--gnu/lib/libg++/include/SmplHist.h72
-rw-r--r--gnu/lib/libg++/include/SmplStat.h66
-rw-r--r--gnu/lib/libg++/include/String.h1328
-rw-r--r--gnu/lib/libg++/include/Uniform.h71
-rw-r--r--gnu/lib/libg++/include/Weibull.h74
-rw-r--r--gnu/lib/libg++/include/_G_config.h70
-rw-r--r--gnu/lib/libg++/include/ansidecl.h141
-rw-r--r--gnu/lib/libg++/include/bitdo1.h32
-rw-r--r--gnu/lib/libg++/include/bitdo2.h184
-rw-r--r--gnu/lib/libg++/include/bitprims.h125
-rw-r--r--gnu/lib/libg++/include/builtin.h159
-rw-r--r--gnu/lib/libg++/include/builtinbuf.h63
-rw-r--r--gnu/lib/libg++/include/compare.h91
-rw-r--r--gnu/lib/libg++/include/config.h1
-rw-r--r--gnu/lib/libg++/include/defines.h33
-rw-r--r--gnu/lib/libg++/include/editbuf.h183
-rw-r--r--gnu/lib/libg++/include/floatio.h51
-rw-r--r--gnu/lib/libg++/include/fstream.h81
-rw-r--r--gnu/lib/libg++/include/indstream.h74
-rw-r--r--gnu/lib/libg++/include/iolibio.h46
-rw-r--r--gnu/lib/libg++/include/iomanip.h159
-rw-r--r--gnu/lib/libg++/include/iostream.h227
-rw-r--r--gnu/lib/libg++/include/iostreamP.h34
-rw-r--r--gnu/lib/libg++/include/libiberty.h107
-rw-r--r--gnu/lib/libg++/include/libio.h254
-rw-r--r--gnu/lib/libg++/include/libioP.h308
-rw-r--r--gnu/lib/libg++/include/new.h27
-rw-r--r--gnu/lib/libg++/include/parsestream.h154
-rw-r--r--gnu/lib/libg++/include/pfstream.h57
-rw-r--r--gnu/lib/libg++/include/procbuf.h39
-rw-r--r--gnu/lib/libg++/include/regex.h272
-rw-r--r--gnu/lib/libg++/include/std.h35
-rw-r--r--gnu/lib/libg++/include/stdiostream.h77
-rw-r--r--gnu/lib/libg++/include/stream.h55
-rw-r--r--gnu/lib/libg++/include/streambuf.h455
-rw-r--r--gnu/lib/libg++/include/strfile.h46
-rw-r--r--gnu/lib/libg++/include/strstream.h109
70 files changed, 12468 insertions, 0 deletions
diff --git a/gnu/lib/libg++/include/ACG.h b/gnu/lib/libg++/include/ACG.h
new file mode 100644
index 0000000..d7101c7
--- /dev/null
+++ b/gnu/lib/libg++/include/ACG.h
@@ -0,0 +1,68 @@
+// 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 {
+
+ unsigned long initialSeed; // used to reset generator
+ int initialTableEntry;
+
+ unsigned long *state;
+ unsigned long *auxState;
+ short stateSize;
+ short auxSize;
+ unsigned long lcgRecurr;
+ short j;
+ short k;
+
+protected:
+
+public:
+ ACG(unsigned long seed = 0, int size = 55);
+ virtual ~ACG();
+ //
+ // Return a long-words word of random bits
+ //
+ virtual unsigned long asLong();
+ virtual void reset();
+};
+
+#endif
diff --git a/gnu/lib/libg++/include/AllocRing.h b/gnu/lib/libg++/include/AllocRing.h
new file mode 100644
index 0000000..15dd161
--- /dev/null
+++ b/gnu/lib/libg++/include/AllocRing.h
@@ -0,0 +1,62 @@
+// 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
new file mode 100644
index 0000000..f88dfc3
--- /dev/null
+++ b/gnu/lib/libg++/include/Binomial.h
@@ -0,0 +1,55 @@
+// 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
new file mode 100644
index 0000000..ca1d96f
--- /dev/null
+++ b/gnu/lib/libg++/include/BitSet.h
@@ -0,0 +1,374 @@
+// 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
new file mode 100644
index 0000000..b2b92b1
--- /dev/null
+++ b/gnu/lib/libg++/include/BitString.h
@@ -0,0 +1,761 @@
+// 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
new file mode 100644
index 0000000..385ea606d7
--- /dev/null
+++ b/gnu/lib/libg++/include/Complex.h
@@ -0,0 +1,276 @@
+// 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);
+
+// other functions defined as inlines
+
+int operator == (const Complex& x, const Complex& y);
+int operator == (const Complex& x, double y);
+int operator != (const Complex& x, const Complex& y);
+int operator != (const Complex& x, double y);
+
+Complex operator - (const Complex& x);
+Complex conj(const Complex& x);
+Complex operator + (const Complex& x, const Complex& y);
+Complex operator + (const Complex& x, double y);
+Complex operator + (double x, const Complex& y);
+Complex operator - (const Complex& x, const Complex& y);
+Complex operator - (const Complex& x, double y);
+Complex operator - (double x, const Complex& y);
+Complex operator * (const Complex& x, const Complex& y);
+Complex operator * (const Complex& x, double y);
+Complex operator * (double x, const Complex& y);
+
+double real(const Complex& x);
+double imag(const Complex& x);
+double abs(const Complex& x);
+double norm(const Complex& x);
+double arg(const Complex& x);
+
+Complex polar(double r, double t = 0.0);
+
+
+// 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
new file mode 100644
index 0000000..4f367fd
--- /dev/null
+++ b/gnu/lib/libg++/include/CursesW.h
@@ -0,0 +1,590 @@
+// 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
+#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 (box)(WINDOW* win, chtype v, chtype h) {return box(win, v, h); }
+#undef box
+#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
new file mode 100644
index 0000000..0c3adc2
--- /dev/null
+++ b/gnu/lib/libg++/include/DLList.h
@@ -0,0 +1,126 @@
+// 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);
+ int owns(Pix p);
+ int OK();
+ 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;
+ }
+ 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;
+ }
+ Pix first() { return Pix(h); }
+ Pix last() { return (h == 0)? 0 : Pix(h->bk); }
+ void next(Pix& p)
+ { p = (p == 0 || p == h->bk)? 0 : Pix(((DLNode<T>*)p)->fd); }
+ void prev(Pix& p)
+ { 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
new file mode 100644
index 0000000..5f26f90
--- /dev/null
+++ b/gnu/lib/libg++/include/DiscUnif.h
@@ -0,0 +1,72 @@
+// 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
new file mode 100644
index 0000000..9809388
--- /dev/null
+++ b/gnu/lib/libg++/include/Erlang.h
@@ -0,0 +1,68 @@
+// 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
new file mode 100644
index 0000000..df76c94
--- /dev/null
+++ b/gnu/lib/libg++/include/Fix.h
@@ -0,0 +1,513 @@
+// -*- 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
new file mode 100644
index 0000000..36728b4
--- /dev/null
+++ b/gnu/lib/libg++/include/Fix16.h
@@ -0,0 +1,648 @@
+// 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)((unsigned long)(1 << 31)))
+
+#define Fix32_msb ((unsigned long)(1 << 31))
+#define Fix32_m_max ((long)((1 << 31) - 1))
+#define Fix32_m_min ((long)(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;
+
+ long m;
+
+ long round(double d);
+ long assign(double d);
+
+ Fix32(long 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 long& mantissa(Fix32& f);
+ friend const long& 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(long& i) const;
+ void range_error(long& 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)(long&);
+
+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(long&),
+ Fix32_overflow_saturate(long&),
+ Fix32_overflow_warning_saturate(long&),
+ Fix32_warning(long&),
+ Fix32_abort(long&);
+
+
+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(long 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 = long(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 = long(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( long( long(f.m) * long(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 long Fix32::round(double d)
+{
+ return long( (d >= 0)? d + 0.5 : d - 0.5);
+}
+
+inline long& mantissa(Fix32& f)
+{
+ return f.m;
+}
+
+inline const long& 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)
+{
+ long 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)
+{
+ long 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(long(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
new file mode 100644
index 0000000..56d1191
--- /dev/null
+++ b/gnu/lib/libg++/include/Fix24.h
@@ -0,0 +1,597 @@
+// 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 {
+ long u;
+ unsigned long 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 unsigned long
+ 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;
+
+ long m;
+
+ long 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 long& mantissa(Fix24& f);
+ friend const long& 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(long&) const;
+ void range_error(long&) 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)(long&);
+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(long&),
+ Fix24_overflow_saturate(long&),
+ Fix24_overflow_warning_saturate(long&),
+ Fix24_warning(long&),
+ Fix24_abort(long&);
+
+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 long& mantissa(Fix24& f)
+{
+ return f.m;
+}
+
+inline const long& 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)
+{
+ long 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)
+{
+ long 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) & (long)0xffffff00;
+}
+
+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 * ((unsigned long)(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
new file mode 100644
index 0000000..5cfa39a
--- /dev/null
+++ b/gnu/lib/libg++/include/Geom.h
@@ -0,0 +1,52 @@
+// 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
new file mode 100644
index 0000000..66ecf5c
--- /dev/null
+++ b/gnu/lib/libg++/include/GetOpt.h
@@ -0,0 +1,129 @@
+/* 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
new file mode 100644
index 0000000..e16e655
--- /dev/null
+++ b/gnu/lib/libg++/include/HypGeom.h
@@ -0,0 +1,70 @@
+// 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
new file mode 100644
index 0000000..7e67ae5
--- /dev/null
+++ b/gnu/lib/libg++/include/Integer.h
@@ -0,0 +1,1119 @@
+// 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
new file mode 100644
index 0000000..b8a8039
--- /dev/null
+++ b/gnu/lib/libg++/include/Integer.hP
@@ -0,0 +1,30 @@
+// 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
new file mode 100644
index 0000000..ac98141
--- /dev/null
+++ b/gnu/lib/libg++/include/LogNorm.h
@@ -0,0 +1,78 @@
+// 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
new file mode 100644
index 0000000..8f104a1
--- /dev/null
+++ b/gnu/lib/libg++/include/MLCG.h
@@ -0,0 +1,87 @@
+// 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 unsigned long 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
new file mode 100644
index 0000000..b96f913
--- /dev/null
+++ b/gnu/lib/libg++/include/NegExp.h
@@ -0,0 +1,55 @@
+// 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
new file mode 100644
index 0000000..8c8358e
--- /dev/null
+++ b/gnu/lib/libg++/include/Normal.h
@@ -0,0 +1,66 @@
+// 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
new file mode 100644
index 0000000..384157f
--- /dev/null
+++ b/gnu/lib/libg++/include/Obstack.h
@@ -0,0 +1,216 @@
+// 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
new file mode 100644
index 0000000..be90525
--- /dev/null
+++ b/gnu/lib/libg++/include/Pix.h
@@ -0,0 +1,5 @@
+
+#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
new file mode 100644
index 0000000..91ab6ae
--- /dev/null
+++ b/gnu/lib/libg++/include/PlotFile.h
@@ -0,0 +1,121 @@
+/* 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
new file mode 100644
index 0000000..e585145
--- /dev/null
+++ b/gnu/lib/libg++/include/Poisson.h
@@ -0,0 +1,51 @@
+// 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
new file mode 100644
index 0000000..43d95b7
--- /dev/null
+++ b/gnu/lib/libg++/include/RNG.h
@@ -0,0 +1,58 @@
+// 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 unsigned long 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
new file mode 100644
index 0000000..925698f
--- /dev/null
+++ b/gnu/lib/libg++/include/Random.h
@@ -0,0 +1,54 @@
+// 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
new file mode 100644
index 0000000..131aabc
--- /dev/null
+++ b/gnu/lib/libg++/include/Rational.h
@@ -0,0 +1,288 @@
+// 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
new file mode 100644
index 0000000..c8cf731
--- /dev/null
+++ b/gnu/lib/libg++/include/Regex.h
@@ -0,0 +1,76 @@
+// 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
new file mode 100644
index 0000000..b16c7f8
--- /dev/null
+++ b/gnu/lib/libg++/include/RndInt.h
@@ -0,0 +1,175 @@
+// 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
new file mode 100644
index 0000000..3726844
--- /dev/null
+++ b/gnu/lib/libg++/include/SFile.h
@@ -0,0 +1,53 @@
+/* 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
new file mode 100644
index 0000000..c613674
--- /dev/null
+++ b/gnu/lib/libg++/include/SLList.h
@@ -0,0 +1,115 @@
+// 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();
+ void error(const char* msg);
+ void del_after(Pix p);
+ int owns(Pix p);
+ 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; }
+ inline Pix first() { return (last == 0)? 0 : Pix(last->tl); }
+ void next(Pix& p)
+ { 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; }
+ 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
new file mode 100644
index 0000000..a9a7550
--- /dev/null
+++ b/gnu/lib/libg++/include/SmplHist.h
@@ -0,0 +1,72 @@
+// 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
new file mode 100644
index 0000000..191ec67
--- /dev/null
+++ b/gnu/lib/libg++/include/SmplStat.h
@@ -0,0 +1,66 @@
+// 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
new file mode 100644
index 0000000..9537ba6
--- /dev/null
+++ b/gnu/lib/libg++/include/String.h
@@ -0,0 +1,1328 @@
+// 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* Sresize(StrRep*, int);
+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 void cat(const String&, const String&, String&);
+ friend void cat(const String&, const SubString&, String&);
+ friend void cat(const String&, const char*, String&);
+ friend void cat(const String&, char, String&);
+
+ friend void cat(const SubString&, const String&, String&);
+ friend void cat(const SubString&, const SubString&, String&);
+ friend void cat(const SubString&, const char*, String&);
+ friend void cat(const SubString&, char, String&);
+
+ friend void cat(const char*, const String&, String&);
+ friend void cat(const char*, const SubString&, String&);
+ friend void cat(const char*, const char*, String&);
+ friend 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 void cat(const String&,const String&, const String&,String&);
+ friend void cat(const String&,const String&,const SubString&,String&);
+ friend void cat(const String&,const String&, const char*, String&);
+ friend void cat(const String&,const String&, char, String&);
+ friend void cat(const String&,const SubString&,const String&,String&);
+ friend void cat(const String&,const SubString&,const SubString&,String&);
+ friend void cat(const String&,const SubString&, const char*, String&);
+ friend void cat(const String&,const SubString&, char, String&);
+ friend void cat(const String&,const char*, const String&, String&);
+ friend void cat(const String&,const char*, const SubString&, String&);
+ friend void cat(const String&,const char*, const char*, String&);
+ friend void cat(const String&,const char*, char, String&);
+
+ friend void cat(const char*, const String&, const String&,String&);
+ friend void cat(const char*,const String&,const SubString&,String&);
+ friend void cat(const char*,const String&, const char*, String&);
+ friend void cat(const char*,const String&, char, String&);
+ friend void cat(const char*,const SubString&,const String&,String&);
+ friend void cat(const char*,const SubString&,const SubString&,String&);
+ friend void cat(const char*,const SubString&, const char*, String&);
+ friend void cat(const char*,const SubString&, char, String&);
+ friend void cat(const char*,const char*, const String&, String&);
+ friend void cat(const char*,const char*, const SubString&, String&);
+ friend void cat(const char*,const char*, const char*, String&);
+ friend 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 String reverse(const String& x);
+ friend String upcase(const String& x);
+ friend String downcase(const String& x);
+ friend String capitalize(const String& x);
+
+// in-place versions of above
+
+ void reverse();
+ void upcase();
+ void downcase();
+ void capitalize();
+
+// element extraction
+
+ char& operator [] (int i);
+ char elem(int i) const;
+ char firstchar() const;
+ char lastchar() const;
+
+// conversion
+
+ operator const char*() const;
+ const char* chars() const;
+
+
+// IO
+
+ friend 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;
+
+// other inlines
+
+String operator + (const String& x, const String& y);
+String operator + (const String& x, const SubString& y);
+String operator + (const String& x, const char* y);
+String operator + (const String& x, char y);
+String operator + (const SubString& x, const String& y);
+String operator + (const SubString& x, const SubString& y);
+String operator + (const SubString& x, const char* y);
+String operator + (const SubString& x, char y);
+String operator + (const char* x, const String& y);
+String operator + (const char* x, const SubString& y);
+
+int operator==(const String& x, const String& y);
+int operator!=(const String& x, const String& y);
+int operator> (const String& x, const String& y);
+int operator>=(const String& x, const String& y);
+int operator< (const String& x, const String& y);
+int operator<=(const String& x, const String& y);
+int operator==(const String& x, const SubString& y);
+int operator!=(const String& x, const SubString& y);
+int operator> (const String& x, const SubString& y);
+int operator>=(const String& x, const SubString& y);
+int operator< (const String& x, const SubString& y);
+int operator<=(const String& x, const SubString& y);
+int operator==(const String& x, const char* t);
+int operator!=(const String& x, const char* t);
+int operator> (const String& x, const char* t);
+int operator>=(const String& x, const char* t);
+int operator< (const String& x, const char* t);
+int operator<=(const String& x, const char* t);
+int operator==(const SubString& x, const String& y);
+int operator!=(const SubString& x, const String& y);
+int operator> (const SubString& x, const String& y);
+int operator>=(const SubString& x, const String& y);
+int operator< (const SubString& x, const String& y);
+int operator<=(const SubString& x, const String& y);
+int operator==(const SubString& x, const SubString& y);
+int operator!=(const SubString& x, const SubString& y);
+int operator> (const SubString& x, const SubString& y);
+int operator>=(const SubString& x, const SubString& y);
+int operator< (const SubString& x, const SubString& y);
+int operator<=(const SubString& x, const SubString& y);
+int operator==(const SubString& x, const char* t);
+int operator!=(const SubString& x, const char* t);
+int operator> (const SubString& x, const char* t);
+int operator>=(const SubString& x, const char* t);
+int operator< (const SubString& x, const char* t);
+int operator<=(const SubString& x, const char* t);
+
+
+// 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 void String::alloc(int newsize) { rep = Sresize(rep, newsize); }
+
+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 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
new file mode 100644
index 0000000..5933f6b
--- /dev/null
+++ b/gnu/lib/libg++/include/Uniform.h
@@ -0,0 +1,71 @@
+// 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
new file mode 100644
index 0000000..d03567a
--- /dev/null
+++ b/gnu/lib/libg++/include/Weibull.h
@@ -0,0 +1,74 @@
+// 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
new file mode 100644
index 0000000..2b73e90
--- /dev/null
+++ b/gnu/lib/libg++/include/_G_config.h
@@ -0,0 +1,70 @@
+/* AUTOMATICALLY GENERATED; DO NOT EDIT! */
+#ifndef _G_config_h
+#define _G_config_h
+#define _G_LIB_VERSION "0.65"
+#define _G_NAMES_HAVE_UNDERSCORE 1
+#define _G_VTABLE_LABEL_HAS_LENGTH 0
+#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 _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
+#define _G_HAVE_ATEXIT 1
+#define _G_HAVE_SYS_RESOURCE 0
+#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 0
+#endif /* !_G_config_h */
diff --git a/gnu/lib/libg++/include/ansidecl.h b/gnu/lib/libg++/include/ansidecl.h
new file mode 100644
index 0000000..3c0dcb3
--- /dev/null
+++ b/gnu/lib/libg++/include/ansidecl.h
@@ -0,0 +1,141 @@
+/* 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
new file mode 100644
index 0000000..c234d41
--- /dev/null
+++ b/gnu/lib/libg++/include/bitdo1.h
@@ -0,0 +1,32 @@
+#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
new file mode 100644
index 0000000..6e99523
--- /dev/null
+++ b/gnu/lib/libg++/include/bitdo2.h
@@ -0,0 +1,184 @@
+#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
new file mode 100644
index 0000000..771acd9
--- /dev/null
+++ b/gnu/lib/libg++/include/bitprims.h
@@ -0,0 +1,125 @@
+#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
new file mode 100644
index 0000000..7f8299c
--- /dev/null
+++ b/gnu/lib/libg++/include/builtin.h
@@ -0,0 +1,159 @@
+// 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);
+
+
+double abs(double arg);
+float abs(float arg);
+short abs(short arg);
+long abs(long arg);
+int sign(long arg);
+int sign(double arg);
+long sqr(long arg);
+double sqr(double arg);
+int even(long arg);
+int odd(long arg);
+long lcm(long x, long y);
+void (setbit)(long& x, long b);
+void clearbit(long& x, long b);
+int testbit(long x, long b);
+
+#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
new file mode 100644
index 0000000..fb91e6a
--- /dev/null
+++ b/gnu/lib/libg++/include/builtinbuf.h
@@ -0,0 +1,63 @@
+/*
+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
new file mode 100644
index 0000000..bd13614
--- /dev/null
+++ b/gnu/lib/libg++/include/compare.h
@@ -0,0 +1,91 @@
+// 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/config.h b/gnu/lib/libg++/include/config.h
new file mode 100644
index 0000000..b37ee84
--- /dev/null
+++ b/gnu/lib/libg++/include/config.h
@@ -0,0 +1 @@
+/* !Automatically generated from ./functions.def - DO NOT EDIT! */
diff --git a/gnu/lib/libg++/include/defines.h b/gnu/lib/libg++/include/defines.h
new file mode 100644
index 0000000..ddb76e9
--- /dev/null
+++ b/gnu/lib/libg++/include/defines.h
@@ -0,0 +1,33 @@
+// 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
+
+#endif
diff --git a/gnu/lib/libg++/include/editbuf.h b/gnu/lib/libg++/include/editbuf.h
new file mode 100644
index 0000000..8535155
--- /dev/null
+++ b/gnu/lib/libg++/include/editbuf.h
@@ -0,0 +1,183 @@
+/* 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
new file mode 100644
index 0000000..edfe297
--- /dev/null
+++ b/gnu/lib/libg++/include/floatio.h
@@ -0,0 +1,51 @@
+/*
+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
new file mode 100644
index 0000000..20dfbf2
--- /dev/null
+++ b/gnu/lib/libg++/include/fstream.h
@@ -0,0 +1,81 @@
+/* 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
new file mode 100644
index 0000000..8047b82
--- /dev/null
+++ b/gnu/lib/libg++/include/indstream.h
@@ -0,0 +1,74 @@
+/* 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
new file mode 100644
index 0000000..2a7c145
--- /dev/null
+++ b/gnu/lib/libg++/include/iolibio.h
@@ -0,0 +1,46 @@
+#include "libio.h"
+
+/* These emulate stdio functionality, but with a different name
+ (_IO_ungetc instead of ungetc), and using _IO_FILE instead of FILE. */
+
+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_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_feof(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
+#define _IO_ferror(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
+#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)
+
diff --git a/gnu/lib/libg++/include/iomanip.h b/gnu/lib/libg++/include/iomanip.h
new file mode 100644
index 0000000..cab4b97
--- /dev/null
+++ b/gnu/lib/libg++/include/iomanip.h
@@ -0,0 +1,159 @@
+/* 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, 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
new file mode 100644
index 0000000..7348ce2
--- /dev/null
+++ b/gnu/lib/libg++/include/iostream.h
@@ -0,0 +1,227 @@
+/* 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<<(__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!
+ _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>>( __manip func) {(*func)(*this); return *this;}
+ istream& operator>>(__imanip func) { return (*func)(*this); }
+ istream& operator>>(streambuf*);
+};
+
+
+class iostream : public istream, public ostream
+{
+ _IO_size_t _gcount;
+ public:
+ iostream() { _gcount = 0; }
+ iostream(streambuf* sb, ostream*tied=NULL);
+};
+
+extern istream cin;
+extern ostream cout, cerr, clog; // clog->rdbuf() == cerr->rdbuf()
+
+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
new file mode 100644
index 0000000..720deb3
--- /dev/null
+++ b/gnu/lib/libg++/include/iostreamP.h
@@ -0,0 +1,34 @@
+/*
+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
new file mode 100644
index 0000000..9854b4c
--- /dev/null
+++ b/gnu/lib/libg++/include/libiberty.h
@@ -0,0 +1,107 @@
+/* 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 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
new file mode 100644
index 0000000..a064197
--- /dev/null
+++ b/gnu/lib/libg++/include/libio.h
@@ -0,0 +1,254 @@
+/*
+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 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)))
+
+/* 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
new file mode 100644
index 0000000..11d90f5
--- /dev/null
+++ b/gnu/lib/libg++/include/libioP.h
@@ -0,0 +1,308 @@
+/*
+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(());
+extern void _IO_cleanup __P(());
+extern void _IO_flush_all_linebuffered __P(());
+
+#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 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)();
+
+#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
diff --git a/gnu/lib/libg++/include/new.h b/gnu/lib/libg++/include/new.h
new file mode 100644
index 0000000..61bbba5
--- /dev/null
+++ b/gnu/lib/libg++/include/new.h
@@ -0,0 +1,27 @@
+#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/parsestream.h b/gnu/lib/libg++/include/parsestream.h
new file mode 100644
index 0000000..b168707
--- /dev/null
+++ b/gnu/lib/libg++/include/parsestream.h
@@ -0,0 +1,154 @@
+/* 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
new file mode 100644
index 0000000..687faf6
--- /dev/null
+++ b/gnu/lib/libg++/include/pfstream.h
@@ -0,0 +1,57 @@
+/* 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
new file mode 100644
index 0000000..092d9cf
--- /dev/null
+++ b/gnu/lib/libg++/include/procbuf.h
@@ -0,0 +1,39 @@
+/* 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/regex.h b/gnu/lib/libg++/include/regex.h
new file mode 100644
index 0000000..9e404e8
--- /dev/null
+++ b/gnu/lib/libg++/include/regex.h
@@ -0,0 +1,272 @@
+/* Definitions for data structures callers pass the regex library.
+
+ Copyright (C) 1985, 1989-92 Free Software Foundation, Inc.
+
+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 __REGEXP_LIBRARY
+#define __REGEXP_LIBRARY
+
+#if defined(SHORT_NAMES) || defined(VMS)
+#define re_compile_pattern recmppat
+#define re_pattern_buffer repatbuf
+#define re_registers reregs
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Define number of parens for which we record the beginnings and ends.
+ This affects how much space the `struct re_registers' type takes up. */
+#ifndef RE_NREGS
+#define RE_NREGS 10
+#endif
+
+#define BYTEWIDTH 8
+
+
+/* Maximum number of duplicates an interval can allow. */
+#ifndef RE_DUP_MAX /* kludge for AIX, which defines it */
+#define RE_DUP_MAX ((1 << 15) - 1)
+#endif
+
+/* This defines the various regexp syntaxes. */
+extern int obscure_syntax;
+
+
+/* The following bits are used in the obscure_syntax variable to choose among
+ alternative regexp syntaxes. */
+
+/* If this bit is set, plain parentheses serve as grouping, and backslash
+ parentheses are needed for literal searching.
+ If not set, backslash-parentheses are grouping, and plain parentheses
+ are for literal searching. */
+#define RE_NO_BK_PARENS 1
+
+/* If this bit is set, plain | serves as the `or'-operator, and \| is a
+ literal.
+ If not set, \| serves as the `or'-operator, and | is a literal. */
+#define RE_NO_BK_VBAR (1 << 1)
+
+/* If this bit is not set, plain + or ? serves as an operator, and \+, \? are
+ literals.
+ If set, \+, \? are operators and plain +, ? are literals. */
+#define RE_BK_PLUS_QM (1 << 2)
+
+/* If this bit is set, | binds tighter than ^ or $.
+ If not set, the contrary. */
+#define RE_TIGHT_VBAR (1 << 3)
+
+/* If this bit is set, then treat newline as an OR operator.
+ If not set, treat it as a normal character. */
+#define RE_NEWLINE_OR (1 << 4)
+
+/* If this bit is set, then special characters may act as normal
+ characters in some contexts. Specifically, this applies to:
+ ^ -- only special at the beginning, or after ( or |;
+ $ -- only special at the end, or before ) or |;
+ *, +, ? -- only special when not after the beginning, (, or |.
+ If this bit is not set, special characters (such as *, ^, and $)
+ always have their special meaning regardless of the surrounding
+ context. */
+#define RE_CONTEXT_INDEP_OPS (1 << 5)
+
+/* If this bit is not set, then \ before anything inside [ and ] is taken as
+ a real \.
+ If set, then such a \ escapes the following character. This is a
+ special case for awk. */
+#define RE_AWK_CLASS_HACK (1 << 6)
+
+/* If this bit is set, then \{ and \} or { and } serve as interval operators.
+ If not set, then \{ and \} and { and } are treated as literals. */
+#define RE_INTERVALS (1 << 7)
+
+/* If this bit is not set, then \{ and \} serve as interval operators and
+ { and } are literals.
+ If set, then { and } serve as interval operators and \{ and \} are
+ literals. */
+#define RE_NO_BK_CURLY_BRACES (1 << 8)
+
+/* 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 (1 << 9)
+
+/* If this bit is set, then the dot re doesn't match a null byte.
+ If not set, it does. */
+#define RE_DOT_NOT_NULL (1 << 10)
+
+/* If this bit is set, then [^...] doesn't match a newline.
+ If not set, it does. */
+#define RE_HAT_NOT_NEWLINE (1 << 11)
+
+/* If this bit is set, back references are recognized.
+ If not set, they aren't. */
+#define RE_NO_BK_REFS (1 << 12)
+
+/* If this bit is set, back references must refer to a preceding
+ subexpression. If not set, a back reference to a nonexistent
+ subexpression is treated as literal characters. */
+#define RE_NO_EMPTY_BK_REF (1 << 13)
+
+/* If this bit is set, bracket expressions can't be empty.
+ If it is set, they can be empty. */
+#define RE_NO_EMPTY_BRACKETS (1 << 14)
+
+/* If this bit is set, then *, +, ? and { cannot be first in an re or
+ immediately after a |, or a (. Furthermore, a | cannot be first or
+ last in an re, or immediately follow another | or a (. Also, a ^
+ cannot appear in a nonleading position and a $ cannot appear in a
+ nontrailing position (outside of bracket expressions, that is). */
+#define RE_CONTEXTUAL_INVALID_OPS (1 << 15)
+
+/* If this bit is set, then +, ? and | aren't recognized as operators.
+ If it's not, they are. */
+#define RE_LIMITED_OPS (1 << 16)
+
+/* If this bit is set, then an ending range point has to collate higher
+ or equal to the starting range point.
+ If it's not set, then when the ending range point collates higher
+ than the starting range point, the range is just considered empty. */
+#define RE_NO_EMPTY_RANGES (1 << 17)
+
+/* If this bit is set, then a hyphen (-) can't be an ending range point.
+ If it isn't, then it can. */
+#define RE_NO_HYPHEN_RANGE_END (1 << 18)
+
+
+/* Define combinations of bits for the standard possibilities. */
+#define RE_SYNTAX_POSIX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
+ | RE_CONTEXT_INDEP_OPS)
+#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
+ | RE_CONTEXT_INDEP_OPS | RE_AWK_CLASS_HACK)
+#define RE_SYNTAX_EGREP (RE_NO_BK_PARENS | RE_NO_BK_VBAR \
+ | RE_CONTEXT_INDEP_OPS | RE_NEWLINE_OR)
+#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
+#define RE_SYNTAX_EMACS 0
+#define RE_SYNTAX_POSIX_BASIC (RE_INTERVALS | RE_BK_PLUS_QM \
+ | RE_CHAR_CLASSES | RE_DOT_NOT_NULL \
+ | RE_HAT_NOT_NEWLINE | RE_NO_EMPTY_BK_REF \
+ | RE_NO_EMPTY_BRACKETS | RE_LIMITED_OPS \
+ | RE_NO_EMPTY_RANGES | RE_NO_HYPHEN_RANGE_END)
+
+#define RE_SYNTAX_POSIX_EXTENDED (RE_INTERVALS | RE_NO_BK_CURLY_BRACES \
+ | RE_NO_BK_VBAR | RE_NO_BK_PARENS \
+ | RE_HAT_NOT_NEWLINE | RE_CHAR_CLASSES \
+ | RE_NO_EMPTY_BRACKETS | RE_CONTEXTUAL_INVALID_OPS \
+ | RE_NO_BK_REFS | RE_NO_EMPTY_RANGES \
+ | RE_NO_HYPHEN_RANGE_END)
+
+
+/* This data structure is used to represent a compiled pattern. */
+
+struct re_pattern_buffer
+ {
+ char *buffer; /* Space holding the compiled pattern commands. */
+ long allocated; /* Size of space that `buffer' points to. */
+ long used; /* Length of portion of buffer actually occupied */
+ char *fastmap; /* Pointer to fastmap, if any, or zero if none. */
+ /* re_search uses the fastmap, if there is one,
+ to skip over totally implausible characters. */
+ char *translate; /* Translate table to apply to all characters before
+ comparing, or zero for no translation.
+ The translation is applied to a pattern when it is
+ compiled and to data when it is matched. */
+ char fastmap_accurate;
+ /* Set to zero when a new pattern is stored,
+ set to one when the fastmap is updated from it. */
+ char can_be_null; /* Set to one by compiling fastmap
+ if this pattern might match the null string.
+ It does not necessarily match the null string
+ in that case, but if this is zero, it cannot.
+ 2 as value means can match null string
+ but at end of range or before a character
+ listed in the fastmap. */
+ };
+
+
+/* search.c (search_buffer) needs this one value. It is defined both in
+ regex.c and here. */
+#define RE_EXACTN_VALUE 1
+
+
+/* Structure to store register contents data in.
+
+ Pass the address of such a structure as an argument to re_match, etc.,
+ if you want this information back.
+
+ For i from 1 to RE_NREGS - 1, start[i] records the starting index in
+ the string of where the ith subexpression matched, and end[i] records
+ one after the ending index. start[0] and end[0] are analogous, for
+ the entire pattern. */
+
+struct re_registers
+ {
+ int start[RE_NREGS];
+ int end[RE_NREGS];
+ };
+
+
+
+#if defined(__STDC__) || defined(__cplusplus)
+
+extern char *re_compile_pattern (const char *, int, struct re_pattern_buffer *);
+/* Is this really advertised? */
+extern void re_compile_fastmap (struct re_pattern_buffer *);
+extern int re_search (struct re_pattern_buffer *, char*, int, int, int,
+ struct re_registers *);
+extern int re_search_2 (struct re_pattern_buffer *, char *, int,
+ char *, int, int, int,
+ struct re_registers *, int);
+extern int re_match (struct re_pattern_buffer *, char *, int, int,
+ struct re_registers *);
+extern int re_match_2 (struct re_pattern_buffer *, char *, int,
+ char *, int, int, struct re_registers *, int);
+
+#if 0
+/* 4.2 bsd compatibility. */
+extern char *re_comp (char *);
+extern int re_exec (char *);
+#endif
+
+#else /* !__STDC__ */
+
+#define const /* nothing */
+extern char *re_compile_pattern ();
+/* Is this really advertised? */
+extern void re_compile_fastmap ();
+extern int re_search (), re_search_2 ();
+extern int re_match (), re_match_2 ();
+
+#if 0
+/* 4.2 bsd compatibility. */
+extern char *re_comp ();
+extern int re_exec ();
+#endif
+
+#endif /* __STDC__ */
+
+
+#ifdef SYNTAX_TABLE
+extern char *re_syntax_table;
+#endif
+
+#ifdef __cplusplus
+extern int re_max_failures;
+}
+#endif
+
+#endif /* !__REGEXP_LIBRARY */
diff --git a/gnu/lib/libg++/include/std.h b/gnu/lib/libg++/include/std.h
new file mode 100644
index 0000000..069b522
--- /dev/null
+++ b/gnu/lib/libg++/include/std.h
@@ -0,0 +1,35 @@
+// 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
new file mode 100644
index 0000000..8c8215e
--- /dev/null
+++ b/gnu/lib/libg++/include/stdiostream.h
@@ -0,0 +1,77 @@
+/* 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
new file mode 100644
index 0000000..488f367
--- /dev/null
+++ b/gnu/lib/libg++/include/stream.h
@@ -0,0 +1,55 @@
+/*
+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
new file mode 100644
index 0000000..60181a4
--- /dev/null
+++ b/gnu/lib/libg++/include/streambuf.h
@@ -0,0 +1,455 @@
+/* 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 {
+ 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
+#if 0
+ streambuf* rdbuf(streambuf *_s) {
+ streambuf *_old = _strbuf; _strbuf = _s; return _old; }
+#endif
+ 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
new file mode 100644
index 0000000..bff25b1
--- /dev/null
+++ b/gnu/lib/libg++/include/strfile.h
@@ -0,0 +1,46 @@
+/*
+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
new file mode 100644
index 0000000..3c8fd54
--- /dev/null
+++ b/gnu/lib/libg++/include/strstream.h
@@ -0,0 +1,109 @@
+/* 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*/
OpenPOWER on IntegriCloud