summaryrefslogtreecommitdiffstats
path: root/gnu/lib
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-10-04 09:02:59 +0000
committerpeter <peter@FreeBSD.org>1996-10-04 09:02:59 +0000
commit5ba3a9a5edf0e69cc0647bf9348c92f5298e5201 (patch)
tree6b8b3d6626bb0d56419525b007cdd80d975cc0c1 /gnu/lib
parent18630e633994b417e83c5e34356051336647d43f (diff)
downloadFreeBSD-src-5ba3a9a5edf0e69cc0647bf9348c92f5298e5201.zip
FreeBSD-src-5ba3a9a5edf0e69cc0647bf9348c92f5298e5201.tar.gz
To the Attic we go..
Diffstat (limited to 'gnu/lib')
-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.h249
-rw-r--r--gnu/lib/libg++/include/CursesW.h595
-rw-r--r--gnu/lib/libg++/include/DLList.h137
-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.h124
-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.h1282
-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.h74
-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.h144
-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/complex.h6
-rw-r--r--gnu/lib/libg++/include/config.h1
-rw-r--r--gnu/lib/libg++/include/defines.h35
-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.h52
-rw-r--r--gnu/lib/libg++/include/iomanip.h159
-rw-r--r--gnu/lib/libg++/include/iostream.h239
-rw-r--r--gnu/lib/libg++/include/iostreamP.h34
-rw-r--r--gnu/lib/libg++/include/libiberty.h114
-rw-r--r--gnu/lib/libg++/include/libio.h257
-rw-r--r--gnu/lib/libg++/include/libioP.h326
-rw-r--r--gnu/lib/libg++/include/new.h27
-rw-r--r--gnu/lib/libg++/include/osfcn.h17
-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/rx.h3261
-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.h454
-rw-r--r--gnu/lib/libg++/include/strfile.h46
-rw-r--r--gnu/lib/libg++/include/strstream.h109
-rw-r--r--gnu/lib/libg++/libg++/ACG.cc292
-rw-r--r--gnu/lib/libg++/libg++/AllocRing.cc110
-rw-r--r--gnu/lib/libg++/libg++/Binomial.cc34
-rw-r--r--gnu/lib/libg++/libg++/BitSet.cc1006
-rw-r--r--gnu/lib/libg++/libg++/BitString.cc1606
-rw-r--r--gnu/lib/libg++/libg++/Complex.cc256
-rw-r--r--gnu/lib/libg++/libg++/CursesW.cc253
-rw-r--r--gnu/lib/libg++/libg++/DLList.cc327
-rw-r--r--gnu/lib/libg++/libg++/DiscUnif.cc29
-rw-r--r--gnu/lib/libg++/libg++/Erlang.cc32
-rw-r--r--gnu/lib/libg++/libg++/Fix.cc663
-rw-r--r--gnu/lib/libg++/libg++/Fix16.cc238
-rw-r--r--gnu/lib/libg++/libg++/Fix24.cc329
-rw-r--r--gnu/lib/libg++/libg++/Geom.cc30
-rw-r--r--gnu/lib/libg++/libg++/GetOpt.cc253
-rw-r--r--gnu/lib/libg++/libg++/HypGeom.cc30
-rw-r--r--gnu/lib/libg++/libg++/Intdouble.cc142
-rw-r--r--gnu/lib/libg++/libg++/Integer.cc2280
-rw-r--r--gnu/lib/libg++/libg++/LogNorm.cc36
-rw-r--r--gnu/lib/libg++/libg++/MLCG.cc103
-rw-r--r--gnu/lib/libg++/libg++/NegExp.cc28
-rw-r--r--gnu/lib/libg++/libg++/Normal.cc60
-rw-r--r--gnu/lib/libg++/libg++/Obstack.cc125
-rw-r--r--gnu/lib/libg++/libg++/Poisson.cc36
-rw-r--r--gnu/lib/libg++/libg++/RNG.cc131
-rw-r--r--gnu/lib/libg++/libg++/Random.cc4
-rw-r--r--gnu/lib/libg++/libg++/Rational.cc414
-rw-r--r--gnu/lib/libg++/libg++/Regex.cc143
-rw-r--r--gnu/lib/libg++/libg++/RndInt.cc4
-rw-r--r--gnu/lib/libg++/libg++/SLList.cc247
-rw-r--r--gnu/lib/libg++/libg++/SmplHist.cc112
-rw-r--r--gnu/lib/libg++/libg++/SmplStat.cc160
-rw-r--r--gnu/lib/libg++/libg++/String.cc1300
-rw-r--r--gnu/lib/libg++/libg++/Uniform.cc27
-rw-r--r--gnu/lib/libg++/libg++/Weibull.cc33
-rw-r--r--gnu/lib/libg++/libg++/bitand.c41
-rw-r--r--gnu/lib/libg++/libg++/bitany.c38
-rw-r--r--gnu/lib/libg++/libg++/bitblt.c97
-rw-r--r--gnu/lib/libg++/libg++/bitclear.c37
-rw-r--r--gnu/lib/libg++/libg++/bitcopy.c41
-rw-r--r--gnu/lib/libg++/libg++/bitcount.c64
-rw-r--r--gnu/lib/libg++/libg++/bitinvert.c37
-rw-r--r--gnu/lib/libg++/libg++/bitlcomp.c92
-rw-r--r--gnu/lib/libg++/libg++/bitset1.c37
-rw-r--r--gnu/lib/libg++/libg++/bitxor.c41
-rw-r--r--gnu/lib/libg++/libg++/builtin.cc4
-rw-r--r--gnu/lib/libg++/libg++/chr.cc37
-rw-r--r--gnu/lib/libg++/libg++/compare.cc4
-rw-r--r--gnu/lib/libg++/libg++/error.cc58
-rw-r--r--gnu/lib/libg++/libg++/except.c79
-rw-r--r--gnu/lib/libg++/libg++/fmtq.cc29
-rw-r--r--gnu/lib/libg++/libg++/gcd.cc52
-rw-r--r--gnu/lib/libg++/libg++/hash.cc56
-rw-r--r--gnu/lib/libg++/libg++/ioob.cc32
-rw-r--r--gnu/lib/libg++/libg++/lg.cc32
-rw-r--r--gnu/lib/libg++/libg++/math.cc4
-rw-r--r--gnu/lib/libg++/libg++/new.cc31
-rw-r--r--gnu/lib/libg++/libg++/pow.cc70
-rw-r--r--gnu/lib/libg++/libg++/sqrt.cc43
-rw-r--r--gnu/lib/libg++/libg++/str.cc38
-rw-r--r--gnu/lib/libg++/libg++/timer.c136
-rw-r--r--gnu/lib/libg++/libiberty/strerror.c823
-rw-r--r--gnu/lib/libg++/libiberty/strsignal.c643
-rw-r--r--gnu/lib/libg++/libio/PlotFile.cc157
-rw-r--r--gnu/lib/libg++/libio/SFile.cc82
-rw-r--r--gnu/lib/libg++/libio/builtinbuf.cc96
-rw-r--r--gnu/lib/libg++/libio/cleanup.c14
-rw-r--r--gnu/lib/libg++/libio/editbuf.cc717
-rw-r--r--gnu/lib/libg++/libio/filebuf.cc199
-rw-r--r--gnu/lib/libg++/libio/filedoalloc.c104
-rw-r--r--gnu/lib/libg++/libio/fileops.c743
-rw-r--r--gnu/lib/libg++/libio/floatconv.c2357
-rw-r--r--gnu/lib/libg++/libio/fstream.cc84
-rw-r--r--gnu/lib/libg++/libio/genops.c867
-rw-r--r--gnu/lib/libg++/libio/indstream.cc116
-rw-r--r--gnu/lib/libg++/libio/ioassign.cc55
-rw-r--r--gnu/lib/libg++/libio/ioextend.cc129
-rw-r--r--gnu/lib/libg++/libio/iofclose.c45
-rw-r--r--gnu/lib/libg++/libio/iofgetpos.c47
-rw-r--r--gnu/lib/libg++/libio/iofread.c41
-rw-r--r--gnu/lib/libg++/libio/iofscanf.c48
-rw-r--r--gnu/lib/libg++/libio/iofsetpos.c44
-rw-r--r--gnu/lib/libg++/libio/iogetdelim.c102
-rw-r--r--gnu/lib/libg++/libio/iogetline.c77
-rw-r--r--gnu/lib/libg++/libio/ioignore.c47
-rw-r--r--gnu/lib/libg++/libio/iomanip.cc90
-rw-r--r--gnu/lib/libg++/libio/iopadn.c67
-rw-r--r--gnu/lib/libg++/libio/iopopen.c221
-rw-r--r--gnu/lib/libg++/libio/ioprims.c81
-rw-r--r--gnu/lib/libg++/libio/ioprintf.c47
-rw-r--r--gnu/lib/libg++/libio/ioseekoff.c47
-rw-r--r--gnu/lib/libg++/libio/ioseekpos.c41
-rw-r--r--gnu/lib/libg++/libio/iostream.cc824
-rw-r--r--gnu/lib/libg++/libio/iostrerror.c11
-rw-r--r--gnu/lib/libg++/libio/ioungetc.c36
-rw-r--r--gnu/lib/libg++/libio/iovfprintf.c885
-rw-r--r--gnu/lib/libg++/libio/iovfscanf.c784
-rw-r--r--gnu/lib/libg++/libio/isgetline.cc140
-rw-r--r--gnu/lib/libg++/libio/isgetsb.cc59
-rw-r--r--gnu/lib/libg++/libio/isscan.cc45
-rw-r--r--gnu/lib/libg++/libio/osform.cc54
-rw-r--r--gnu/lib/libg++/libio/outfloat.c209
-rw-r--r--gnu/lib/libg++/libio/parsestream.cc317
-rw-r--r--gnu/lib/libg++/libio/pfstream.cc92
-rw-r--r--gnu/lib/libg++/libio/procbuf.cc51
-rw-r--r--gnu/lib/libg++/libio/sbform.cc40
-rw-r--r--gnu/lib/libg++/libio/sbgetline.cc31
-rw-r--r--gnu/lib/libg++/libio/sbscan.cc45
-rw-r--r--gnu/lib/libg++/libio/stdiostream.cc159
-rw-r--r--gnu/lib/libg++/libio/stdstrbufs.cc89
-rw-r--r--gnu/lib/libg++/libio/stdstreams.cc143
-rw-r--r--gnu/lib/libg++/libio/stream.cc144
-rw-r--r--gnu/lib/libg++/libio/streambuf.cc341
-rw-r--r--gnu/lib/libg++/libio/strops.c292
-rw-r--r--gnu/lib/libg++/libio/strstream.cc133
-rw-r--r--gnu/lib/libg++/librx/rx.c7163
188 files changed, 0 insertions, 47889 deletions
diff --git a/gnu/lib/libg++/include/ACG.h b/gnu/lib/libg++/include/ACG.h
deleted file mode 100644
index fc16e2a..0000000
--- a/gnu/lib/libg++/include/ACG.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _ACG_h
-#define _ACG_h 1
-
-#include <RNG.h>
-#include <math.h>
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-//
-// Additive number generator. This method is presented in Volume II
-// of The Art of Computer Programming by Knuth. I've coded the algorithm
-// and have added the extensions by Andres Nowatzyk of CMU to randomize
-// the result of algorithm M a bit by using an LCG & a spatial
-// permutation table.
-//
-// The version presented uses the same constants for the LCG that Andres
-// uses (chosen by trial & error). The spatial permutation table is
-// the same size (it's based on word size). This is for 32-bit words.
-//
-// The ``auxillary table'' used by the LCG table varies in size, and
-// is chosen to be the the smallest power of two which is larger than
-// twice the size of the state table.
-//
-
-class ACG : public RNG {
-
- _G_uint32_t initialSeed; // used to reset generator
- int initialTableEntry;
-
- _G_uint32_t *state;
- _G_uint32_t *auxState;
- short stateSize;
- short auxSize;
- _G_uint32_t lcgRecurr;
- short j;
- short k;
-
-protected:
-
-public:
- ACG(_G_uint32_t seed = 0, int size = 55);
- virtual ~ACG();
- //
- // Return a long-words word of random bits
- //
- virtual _G_uint32_t asLong();
- virtual void reset();
-};
-
-#endif
diff --git a/gnu/lib/libg++/include/AllocRing.h b/gnu/lib/libg++/include/AllocRing.h
deleted file mode 100644
index f2f5db5..0000000
--- a/gnu/lib/libg++/include/AllocRing.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1989 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-#ifndef _AllocRing_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _AllocRing_h 1
-
-
-/*
- An AllocRing holds the last n malloc'ed strings, reallocating/reusing
- one only when the queue wraps around. It thus guarantees that the
- last n allocations are intact. It is useful for things like I/O
- formatting where reasonable restrictions may be made about the
- number of allowable live allocations before auto-deletion.
-*/
-
-class AllocRing
-{
-
- struct AllocQNode
- {
- void* ptr;
- int sz;
- };
-
- AllocQNode* nodes;
- int n;
- int current;
-
- int find(void* p);
-
-public:
-
- AllocRing(int max);
- ~AllocRing();
-
- void* alloc(int size);
- int contains(void* ptr);
- void clear();
- void free(void* p);
-};
-
-
-#endif
diff --git a/gnu/lib/libg++/include/Binomial.h b/gnu/lib/libg++/include/Binomial.h
deleted file mode 100644
index f02730b..0000000
--- a/gnu/lib/libg++/include/Binomial.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _Binomial_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Binomial_h 1
-
-#include <Random.h>
-
-class Binomial: public Random {
-protected:
- int pN;
- double pU;
-public:
- Binomial(int n, double u, RNG *gen);
-
- int n();
- int n(int xn);
-
- double u();
- double u(int xu);
-
- virtual double operator()();
-
-};
-
-
-inline Binomial::Binomial(int n, double u, RNG *gen)
-: Random(gen){
- pN = n; pU = u;
-}
-
-inline int Binomial::n() { return pN; }
-inline int Binomial::n(int xn) { int tmp = pN; pN = xn; return tmp; }
-
-inline double Binomial::u() { return pU; }
-inline double Binomial::u(int xu) { double tmp = pU; pU = xu; return tmp; }
-
-#endif
diff --git a/gnu/lib/libg++/include/BitSet.h b/gnu/lib/libg++/include/BitSet.h
deleted file mode 100644
index c80e327..0000000
--- a/gnu/lib/libg++/include/BitSet.h
+++ /dev/null
@@ -1,374 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _BitSet_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#define _BitSet_h 1
-
-#include <iostream.h>
-#include <limits.h>
-
-#define BITSETBITS (sizeof(short) * CHAR_BIT)
-
-struct BitSetRep
-{
- unsigned short len; // number of shorts in s
- unsigned short sz; // allocated slots
- unsigned short virt; // virtual 0 or 1
- unsigned short s[1]; // bits start here
-};
-
-extern BitSetRep* BitSetalloc(BitSetRep*, const unsigned short*,
- int, int, int);
-extern BitSetRep* BitSetcopy(BitSetRep*, const BitSetRep*);
-extern BitSetRep* BitSetresize(BitSetRep*, int);
-extern BitSetRep* BitSetop(const BitSetRep*, const BitSetRep*,
- BitSetRep*, char);
-extern BitSetRep* BitSetcmpl(const BitSetRep*, BitSetRep*);
-
-
-extern BitSetRep _nilBitSetRep;
-
-class BitSet;
-
-class BitSetBit
-{
-protected:
- BitSet* src;
- unsigned long pos;
-
- public:
- BitSetBit(BitSet* v, int p);
- BitSetBit(const BitSetBit& b);
- ~BitSetBit();
- operator int() const;
- int operator = (int b);
- int operator = (const BitSetBit& b);
-};
-
-class BitSet
-{
-protected:
- BitSetRep* rep;
-
-
-public:
-
-// constructors
- BitSet();
- BitSet(const BitSet&);
-
- ~BitSet();
-
- BitSet& operator = (const BitSet& y);
-
-// equality & subset tests
-
- friend int operator == (const BitSet& x, const BitSet& y);
- friend int operator != (const BitSet& x, const BitSet& y);
- friend int operator < (const BitSet& x, const BitSet& y);
- friend int operator <= (const BitSet& x, const BitSet& y);
- friend int operator > (const BitSet& x, const BitSet& y);
- friend int operator >= (const BitSet& x, const BitSet& y);
-
-
-// operations on self
-
- BitSet& operator |= (const BitSet& y);
- BitSet& operator &= (const BitSet& y);
- BitSet& operator -= (const BitSet& y);
- BitSet& operator ^= (const BitSet& y);
-
- void complement();
-
-// individual bit manipulation
-
- void set(int pos);
- void set(int from, int to);
- void set(); // set all
-
- void clear(int pos);
- void clear(int from, int to);
- void clear(); // clear all
-
- void invert(int pos);
- void invert(int from, int to);
-
- int test(int pos) const;
- int test(int from, int to) const;
-
- BitSetBit operator [] (int i);
-
-// iterators
-
- int first(int b = 1) const;
- int last(int b = 1) const;
-
- int next(int pos, int b = 1) const;
- int prev(int pos, int b = 1) const;
- int previous(int pos, int b = 1) const /* Obsolete synonym */
- { return prev(pos, b); }
-
-// status
-
- int empty() const;
- int virtual_bit() const;
- int count(int b = 1) const;
-
-// convertors & IO
-
- friend BitSet atoBitSet(const char* s,
- char f='0', char t='1', char star='*');
- // BitSettoa is deprecated; do not use in new programs.
- friend const char* BitSettoa(const BitSet& x,
- char f='0', char t='1', char star='*');
-
- friend BitSet shorttoBitSet(unsigned short w);
- friend BitSet longtoBitSet(unsigned long w);
-
- friend ostream& operator << (ostream& s, const BitSet& x);
- void printon(ostream& s,
- char f='0', char t='1', char star='*') const;
-
-// procedural versions of operators
-
- friend void and(const BitSet& x, const BitSet& y, BitSet& r);
- friend void or(const BitSet& x, const BitSet& y, BitSet& r);
- friend void xor(const BitSet& x, const BitSet& y, BitSet& r);
- friend void diff(const BitSet& x, const BitSet& y, BitSet& r);
- friend void complement(const BitSet& x, BitSet& r);
-
-// misc
-
- void error(const char* msg) const;
- int OK() const;
-};
-
-
-typedef BitSet BitSetTmp;
-
-
- BitSet operator | (const BitSet& x, const BitSet& y);
- BitSet operator & (const BitSet& x, const BitSet& y);
- BitSet operator - (const BitSet& x, const BitSet& y);
- BitSet operator ^ (const BitSet& x, const BitSet& y);
-
- BitSet operator ~ (const BitSet& x);
-
-// These are inlined regardless of optimization
-
-inline int BitSet_index(int l)
-{
- return (unsigned)(l) / BITSETBITS;
-}
-
-inline int BitSet_pos(int l)
-{
- return l & (BITSETBITS - 1);
-}
-
-
-inline BitSet::BitSet() : rep(&_nilBitSetRep) {}
-
-inline BitSet::BitSet(const BitSet& x) :rep(BitSetcopy(0, x.rep)) {}
-
-inline BitSet::~BitSet() { if (rep != &_nilBitSetRep) delete rep; }
-
-inline BitSet& BitSet::operator = (const BitSet& y)
-{
- rep = BitSetcopy(rep, y.rep);
- return *this;
-}
-
-inline int operator != (const BitSet& x, const BitSet& y) { return !(x == y); }
-
-inline int operator > (const BitSet& x, const BitSet& y) { return y < x; }
-
-inline int operator >= (const BitSet& x, const BitSet& y) { return y <= x; }
-
-inline void and(const BitSet& x, const BitSet& y, BitSet& r)
-{
- r.rep = BitSetop(x.rep, y.rep, r.rep, '&');
-}
-
-inline void or(const BitSet& x, const BitSet& y, BitSet& r)
-{
- r.rep = BitSetop(x.rep, y.rep, r.rep, '|');
-}
-
-inline void xor(const BitSet& x, const BitSet& y, BitSet& r)
-{
- r.rep = BitSetop(x.rep, y.rep, r.rep, '^');
-}
-
-inline void diff(const BitSet& x, const BitSet& y, BitSet& r)
-{
- r.rep = BitSetop(x.rep, y.rep, r.rep, '-');
-}
-
-inline void complement(const BitSet& x, BitSet& r)
-{
- r.rep = BitSetcmpl(x.rep, r.rep);
-}
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-
-inline BitSet operator & (const BitSet& x, const BitSet& y) return r
-{
- and(x, y, r);
-}
-
-inline BitSet operator | (const BitSet& x, const BitSet& y) return r
-{
- or(x, y, r);
-}
-
-inline BitSet operator ^ (const BitSet& x, const BitSet& y) return r
-{
- xor(x, y, r);
-}
-
-inline BitSet operator - (const BitSet& x, const BitSet& y) return r
-{
- diff(x, y, r);
-}
-
-inline BitSet operator ~ (const BitSet& x) return r
-{
- ::complement(x, r);
-}
-
-#else /* NO_NRV */
-
-inline BitSet operator & (const BitSet& x, const BitSet& y)
-{
- BitSet r; and(x, y, r); return r;
-}
-
-inline BitSet operator | (const BitSet& x, const BitSet& y)
-{
- BitSet r; or(x, y, r); return r;
-}
-
-inline BitSet operator ^ (const BitSet& x, const BitSet& y)
-{
- BitSet r; xor(x, y, r); return r;
-}
-
-inline BitSet operator - (const BitSet& x, const BitSet& y)
-{
- BitSet r; diff(x, y, r); return r;
-}
-
-inline BitSet operator ~ (const BitSet& x)
-{
- BitSet r; ::complement(x, r); return r;
-}
-
-#endif
-
-inline BitSet& BitSet::operator &= (const BitSet& y)
-{
- and(*this, y, *this);
- return *this;
-}
-
-inline BitSet& BitSet::operator |= (const BitSet& y)
-{
- or(*this, y, *this);
- return *this;
-}
-
-inline BitSet& BitSet::operator ^= (const BitSet& y)
-{
- xor(*this, y, *this);
- return *this;
-}
-
-inline BitSet& BitSet::operator -= (const BitSet& y)
-{
- diff(*this, y, *this);
- return *this;
-}
-
-
-inline void BitSet::complement()
-{
- ::complement(*this, *this);
-}
-
-inline int BitSet::virtual_bit() const
-{
- return rep->virt;
-}
-
-inline int BitSet::first(int b) const
-{
- return next(-1, b);
-}
-
-inline int BitSet::test(int p) const
-{
- if (p < 0) error("Illegal bit index");
- int index = BitSet_index(p);
- return (index >= rep->len)? rep->virt :
- ((rep->s[index] & (1 << BitSet_pos(p))) != 0);
-}
-
-
-inline void BitSet::set()
-{
- rep = BitSetalloc(rep, 0, 0, 1, 0);
-}
-
-inline BitSetBit::BitSetBit(const BitSetBit& b) :src(b.src), pos(b.pos) {}
-
-inline BitSetBit::BitSetBit(BitSet* v, int p)
-{
- src = v; pos = p;
-}
-
-inline BitSetBit::~BitSetBit() {}
-
-inline BitSetBit::operator int() const
-{
- return src->test(pos);
-}
-
-inline int BitSetBit::operator = (int b)
-{
- if (b) src->set(pos); else src->clear(pos); return b;
-}
-
-inline int BitSetBit::operator = (const BitSetBit& b)
-{
- int i = (int)b;
- *this = i;
- return i;
-}
-
-inline BitSetBit BitSet::operator [] (int i)
-{
- if (i < 0) error("illegal bit index");
- return BitSetBit(this, i);
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/BitString.h b/gnu/lib/libg++/include/BitString.h
deleted file mode 100644
index f30b440..0000000
--- a/gnu/lib/libg++/include/BitString.h
+++ /dev/null
@@ -1,761 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _BitString_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#define _BitString_h 1
-
-#include <stream.h>
-#include <limits.h>
-
-#include <bitprims.h>
-#define BITSTRBITS _BS_BITS_PER_WORD
-
-struct BitStrRep
-{
- unsigned int len; // length in bits
- unsigned short sz; // allocated slots
- _BS_word s[1]; // bits start here
-};
-
-extern BitStrRep* BStr_alloc(BitStrRep*, const _BS_word*, int, int,int);
-extern BitStrRep* BStr_resize(BitStrRep*, int);
-extern BitStrRep* BStr_copy(BitStrRep*, const BitStrRep*);
-extern BitStrRep* cmpl(const BitStrRep*, BitStrRep*);
-extern BitStrRep* and(const BitStrRep*, const BitStrRep*, BitStrRep*);
-extern BitStrRep* or(const BitStrRep*, const BitStrRep*, BitStrRep*);
-extern BitStrRep* xor(const BitStrRep*, const BitStrRep*, BitStrRep*);
-extern BitStrRep* diff(const BitStrRep*, const BitStrRep*, BitStrRep*);
-extern BitStrRep* cat(const BitStrRep*, const BitStrRep*, BitStrRep*);
-extern BitStrRep* cat(const BitStrRep*, unsigned int, BitStrRep*);
-extern BitStrRep* lshift(const BitStrRep*, int, BitStrRep*);
-
-
-class BitString;
-class BitPattern;
-
-class BitStrBit
-{
-protected:
- BitString& src;
- unsigned int pos;
-
- public:
- BitStrBit(BitString& v, int p);
- BitStrBit(const BitStrBit& b);
- ~BitStrBit();
- operator unsigned int() const;
- int operator = (unsigned int b);
-};
-
-class BitSubString
-{
- friend class BitString;
- friend class BitPattern;
-
-protected:
-
- BitString& S;
- unsigned int pos;
- unsigned int len;
-
- BitSubString(BitString& x, int p, int l);
- BitSubString(const BitSubString& x);
-public:
- ~BitSubString();
-
- BitSubString& operator = (const BitString&);
- BitSubString& operator = (const BitSubString&);
-
- int length() const;
- int empty() const;
-
- int OK() const;
-};
-
-class BitString
-{
- friend class BitSubString;
- friend class BitPattern;
-protected:
- BitStrRep* rep;
-
- int search(int, int, const _BS_word*, int, int) const;
- int match(int, int, int, const _BS_word*,int,int) const;
- BitSubString _substr(int first, int l);
-
-public:
-
-// constructors
- BitString();
- BitString(const BitString&);
- BitString(const BitSubString& y);
-
- ~BitString();
-
- BitString& operator = (unsigned int bit);
- BitString& operator = (const BitString& y);
- BitString& operator = (const BitSubString& y);
-
-// equality & subset tests
-
- friend int operator == (const BitString&, const BitString&);
- friend int operator != (const BitString&, const BitString&);
- friend int operator < (const BitString&, const BitString&);
- friend int operator <= (const BitString&, const BitString&);
- friend int operator > (const BitString&, const BitString&);
- friend int operator >= (const BitString&, const BitString&);
-
-// procedural versions of operators
-
-
- friend void and(const BitString&, const BitString&, BitString&);
- friend void or(const BitString&, const BitString&, BitString&);
- friend void xor(const BitString&, const BitString&, BitString&);
- friend void diff(const BitString&, const BitString&, BitString&);
- friend void cat(const BitString&, const BitString&, BitString&);
- friend void cat(const BitString&, unsigned int, BitString&);
- friend void lshift(const BitString&, int, BitString&);
- friend void rshift(const BitString&, int, BitString&);
-
- friend void complement(const BitString&, BitString&);
-
- friend int lcompare(const BitString&, const BitString&);
-
-// assignment-based operators
-// (constuctive versions decalred inline below
-
- BitString& operator |= (const BitString&);
- BitString& operator &= (const BitString&);
- BitString& operator -= (const BitString&);
- BitString& operator ^= (const BitString&);
- BitString& operator += (const BitString&);
- BitString& operator += (unsigned int b);
- BitString& operator <<=(int s);
- BitString& operator >>=(int s);
-
- void complement();
-
-// individual bit manipulation
-
- void set(int pos);
- void set(int from, int to);
- void set();
-
- void clear(int pos);
- void clear(int from, int to);
- void clear();
-
- void invert(int pos);
- void invert(int from, int to);
-
- int test(int pos) const;
- int test(int from, int to) const;
-
- void assign(int p, unsigned int bit);
-
-// indexing
-
- BitStrBit operator [] (int pos);
-
-// iterators
-
- int first(unsigned int bit = 1) const;
- int last(unsigned int b = 1) const;
-
- int next(int pos, unsigned int b = 1) const;
- int prev(int pos, unsigned int b = 1) const;
- int previous(int pos, unsigned int b = 1) const
- { return prev(pos, b); } /* Obsolete synonym */
-
-// searching & matching
-
- int index(unsigned int bit, int startpos = 0) const ;
- int index(const BitString&, int startpos = 0) const;
- int index(const BitSubString&, int startpos = 0) const;
- int index(const BitPattern&, int startpos = 0) const;
-
- int contains(const BitString&) const;
- int contains(const BitSubString&) const;
- int contains(const BitPattern&) const;
-
- int contains(const BitString&, int pos) const;
- int contains(const BitSubString&, int pos) const;
- int contains(const BitPattern&, int pos) const;
-
- int matches(const BitString&, int pos = 0) const;
- int matches(const BitSubString&, int pos = 0) const;
- int matches(const BitPattern&, int pos = 0) const;
-
-// BitSubString extraction
-
- BitSubString at(int pos, int len);
- BitSubString at(const BitString&, int startpos = 0);
- BitSubString at(const BitSubString&, int startpos = 0);
- BitSubString at(const BitPattern&, int startpos = 0);
-
- BitSubString before(int pos);
- BitSubString before(const BitString&, int startpos = 0);
- BitSubString before(const BitSubString&, int startpos = 0);
- BitSubString before(const BitPattern&, int startpos = 0);
-
- BitSubString after(int pos);
- BitSubString after(const BitString&, int startpos = 0);
- BitSubString after(const BitSubString&, int startpos = 0);
- BitSubString after(const BitPattern&, int startpos = 0);
-
-// other friends & utilities
-
- friend BitString common_prefix(const BitString&, const BitString&,
- int pos = 0);
- friend BitString common_suffix(const BitString&, const BitString&,
- int pos = -1);
- friend BitString reverse(const BitString&);
-
- void right_trim(unsigned int bit);
- void left_trim(unsigned int bit);
-
-// status
-
- int empty() const ;
- int count(unsigned int bit = 1) const;
- int length() const;
-
-// convertors & IO
-
- friend BitString atoBitString(const char* s, char f='0', char t='1');
- // BitStringtoa is deprecated; do not use in new programs!
- friend const char* BitStringtoa(const BitString&, char f='0', char t='1');
- void printon(ostream&, char f='0', char t='1') const;
-
- friend BitString shorttoBitString(unsigned short);
- friend BitString longtoBitString(unsigned long);
-
- friend ostream& operator << (ostream& s, const BitString&);
-
-// misc
-
- void error(const char* msg) const;
-
-// indirect friends
-
- friend BitPattern atoBitPattern(const char* s,
- char f='0',char t='1',char x='X');
- friend const char* BitPatterntoa(const BitPattern& p,
- char f='0',char t='1',char x='X');
- int OK() const;
-};
-
-
-class BitPattern
-{
-public:
- BitString pattern;
- BitString mask;
-
- BitPattern();
- BitPattern(const BitPattern&);
- BitPattern(const BitString& p, const BitString& m);
-
- ~BitPattern();
-
- friend const char* BitPatterntoa(const BitPattern& p,
- char f/*='0'*/,char t/*='1'*/,char x/*='X'*/);
- void printon(ostream&, char f='0',char t='1',char x='X') const;
- friend BitPattern atoBitPattern(const char* s, char f,char t, char x);
- friend ostream& operator << (ostream& s, const BitPattern&);
-
- int search(const _BS_word*, int, int) const;
- int match(const _BS_word* xs, int, int, int) const;
-
- int OK() const;
-};
-
-BitString operator & (const BitString& x, const BitString& y);
-BitString operator | (const BitString& x, const BitString& y);
-BitString operator ^ (const BitString& x, const BitString& y);
-BitString operator << (const BitString& x, int y);
-BitString operator >> (const BitString& x, int y);
-BitString operator - (const BitString& x, const BitString& y);
-BitString operator + (const BitString& x, const BitString& y);
-BitString operator + (const BitString& x, unsigned int y);
-BitString operator ~ (const BitString& x);
-int operator != (const BitString& x, const BitString& y);
-int operator>(const BitString& x, const BitString& y);
-int operator>=(const BitString& x, const BitString& y);
-
-extern BitStrRep _nilBitStrRep;
-extern BitString _nil_BitString;
-
-// primitive bit extraction
-
-// These must be inlined regardless of optimization.
-
-inline int BitStr_index(int l) { return (unsigned)(l) / BITSTRBITS; }
-
-inline int BitStr_pos(int l) { return l & (BITSTRBITS - 1); }
-
-
-// constructors & assignment
-
-inline BitString::BitString() :rep(&_nilBitStrRep) {}
-
-inline BitString::BitString(const BitString& x) :rep(BStr_copy(0, x.rep)) {}
-
-inline BitString::BitString(const BitSubString& y)
- :rep (BStr_alloc(0, y.S.rep->s, y.pos, y.pos+y.len, y.len)) {}
-
-inline BitString::~BitString()
-{
- if (rep != &_nilBitStrRep) delete rep;
-}
-
-inline BitString shorttoBitString(unsigned short w)
-{
- BitString r;
- _BS_word ww = w;
-#if _BS_BIGENDIAN
- abort();
-#endif
- r.rep = BStr_alloc(0, &ww, 0, 8 * sizeof(short), 8 * sizeof(short));
- return r;
-}
-
-inline BitString longtoBitString(unsigned long w)
-{
- BitString r;
-#if 1
- _BS_word u = w;
- r.rep = BStr_alloc(0, &u, 0, BITSTRBITS, BITSTRBITS);
-#else
- unsigned short u[2];
- u[0] = w & ((unsigned short)(~(0)));
- u[1] = w >> BITSTRBITS;
- r.rep = BStr_alloc(0, &u[0], 0, 2*BITSTRBITS, 2*BITSTRBITS);
-#endif
- return r;
-}
-
-inline BitString& BitString::operator = (const BitString& y)
-{
- rep = BStr_copy(rep, y.rep);
- return *this;
-}
-
-inline BitString& BitString::operator = (unsigned int b)
-{
- _BS_word bit = b;
- rep = BStr_alloc(rep, &bit, 0, 1, 1);
- return *this;
-}
-
-inline BitString& BitString::operator=(const BitSubString& y)
-{
- rep = BStr_alloc(rep, y.S.rep->s, y.pos, y.pos+y.len, y.len);
- return *this;
-}
-
-inline BitSubString::BitSubString(const BitSubString& x)
- :S(x.S), pos(x.pos), len(x.len) {}
-
-inline BitSubString::BitSubString(BitString& x, int p, int l)
- : S(x), pos(p), len(l) {}
-
-inline BitSubString::~BitSubString() {}
-
-inline BitPattern::BitPattern(const BitString& p, const BitString& m)
- :pattern(p), mask(m) {}
-
-inline BitPattern::BitPattern(const BitPattern& b)
- :pattern(b.pattern), mask(b.mask) {}
-
-inline BitPattern::BitPattern() {}
-inline BitPattern::~BitPattern() {}
-
-
-// procedural versions of operators
-
-inline void and(const BitString& x, const BitString& y, BitString& r)
-{
- r.rep = and(x.rep, y.rep, r.rep);
-}
-
-inline void or(const BitString& x, const BitString& y, BitString& r)
-{
- r.rep = or(x.rep, y.rep, r.rep);
-}
-
-inline void xor(const BitString& x, const BitString& y, BitString& r)
-{
- r.rep = xor(x.rep, y.rep, r.rep);
-}
-
-inline void diff(const BitString& x, const BitString& y, BitString& r)
-{
- r.rep = diff(x.rep, y.rep, r.rep);
-}
-
-inline void cat(const BitString& x, const BitString& y, BitString& r)
-{
- r.rep = cat(x.rep, y.rep, r.rep);
-}
-
-inline void cat(const BitString& x, unsigned int y, BitString& r)
-{
- r.rep = cat(x.rep, y, r.rep);
-}
-
-inline void rshift(const BitString& x, int y, BitString& r)
-{
- r.rep = lshift(x.rep, -y, r.rep);
-}
-
-inline void lshift(const BitString& x, int y, BitString& r)
-{
- r.rep = lshift(x.rep, y, r.rep);
-}
-
-inline void complement(const BitString& x, BitString& r)
-{
- r.rep = cmpl(x.rep, r.rep);
-}
-
-// operators
-
-
-inline BitString& BitString::operator &= (const BitString& y)
-{
- and(*this, y, *this);
- return *this;
-}
-
-
-inline BitString& BitString::operator |= (const BitString& y)
-{
- or(*this, y, *this);
- return *this;
-}
-
-inline BitString& BitString::operator ^= (const BitString& y)
-{
- xor(*this, y, *this);
- return *this;
-}
-
-inline BitString& BitString::operator <<= (int y)
-{
- lshift(*this, y, *this);
- return *this;
-}
-
-inline BitString& BitString::operator >>= (int y)
-{
- rshift(*this, y, *this);
- return *this;
-}
-
-inline BitString& BitString::operator -= (const BitString& y)
-{
- diff(*this, y, *this);
- return *this;
-}
-
-inline BitString& BitString::operator += (const BitString& y)
-{
- cat(*this, y, *this);
- return *this;
-}
-
-inline BitString& BitString::operator += (unsigned int y)
-{
- cat(*this, y, *this);
- return *this;
-}
-
-inline void BitString::complement()
-{
- ::complement(*this, *this);
-}
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-
-inline BitString operator & (const BitString& x, const BitString& y) return r
-{
- and(x, y, r);
-}
-
-inline BitString operator | (const BitString& x, const BitString& y) return r
-{
- or(x, y, r);
-}
-
-inline BitString operator ^ (const BitString& x, const BitString& y) return r
-{
- xor(x, y, r);
-}
-
-inline BitString operator << (const BitString& x, int y) return r
-{
- lshift(x, y, r);
-}
-
-inline BitString operator >> (const BitString& x, int y) return r
-{
- rshift(x, y, r);
-}
-
-inline BitString operator - (const BitString& x, const BitString& y) return r
-{
- diff(x, y, r);
-}
-
-inline BitString operator + (const BitString& x, const BitString& y) return r
-{
- cat(x, y, r);
-}
-
-inline BitString operator + (const BitString& x, unsigned int y) return r
-{
- cat(x, y, r);
-}
-
-inline BitString operator ~ (const BitString& x) return r
-{
- complement(x, r);
-}
-
-#else /* NO_NRV */
-
-inline BitString operator & (const BitString& x, const BitString& y)
-{
- BitString r; and(x, y, r); return r;
-}
-
-inline BitString operator | (const BitString& x, const BitString& y)
-{
- BitString r; or(x, y, r); return r;
-}
-
-inline BitString operator ^ (const BitString& x, const BitString& y)
-{
- BitString r; xor(x, y, r); return r;
-}
-
-inline BitString operator << (const BitString& x, int y)
-{
- BitString r; lshift(x, y, r); return r;
-}
-
-inline BitString operator >> (const BitString& x, int y)
-{
- BitString r; rshift(x, y, r); return r;
-}
-
-inline BitString operator - (const BitString& x, const BitString& y)
-{
- BitString r; diff(x, y, r); return r;
-}
-
-inline BitString operator + (const BitString& x, const BitString& y)
-{
- BitString r; cat(x, y, r); return r;
-}
-
-inline BitString operator + (const BitString& x, unsigned int y)
-{
- BitString r; cat(x, y, r); return r;
-}
-
-inline BitString operator ~ (const BitString& x)
-{
- BitString r; complement(x, r); return r;
-}
-
-#endif
-
-// status, matching
-
-inline int BitString::length() const
-{
- return rep->len;
-}
-
-inline int BitString::empty() const
-{
- return rep->len == 0;
-}
-
-inline int BitString::index(const BitString& y, int startpos) const
-{
- return search(startpos, rep->len, y.rep->s, 0, y.rep->len);
-}
-
-inline int BitString::index(const BitSubString& y, int startpos) const
-{
- return search(startpos, rep->len, y.S.rep->s, y.pos, y.pos+y.len);
-}
-
-inline int BitString::contains(const BitString& y) const
-{
- return search(0, rep->len, y.rep->s, 0, y.rep->len) >= 0;
-}
-
-inline int BitString::contains(const BitSubString& y) const
-{
- return search(0, rep->len, y.S.rep->s, y.pos, y.pos+y.len) >= 0;
-}
-
-inline int BitString::contains(const BitString& y, int p) const
-{
- return match(p, rep->len, 0, y.rep->s, 0, y.rep->len);
-}
-
-inline int BitString::matches(const BitString& y, int p) const
-{
- return match(p, rep->len, 1, y.rep->s, 0, y.rep->len);
-}
-
-inline int BitString::contains(const BitSubString& y, int p) const
-{
- return match(p, rep->len, 0, y.S.rep->s, y.pos, y.pos+y.len);
-}
-
-inline int BitString::matches(const BitSubString& y, int p) const
-{
- return match(p, rep->len, 1, y.S.rep->s, y.pos, y.pos+y.len);
-}
-
-inline int BitString::contains(const BitPattern& r) const
-{
- return r.search(rep->s, 0, rep->len) >= 0;
-}
-
-inline int BitString::contains(const BitPattern& r, int p) const
-{
- return r.match(rep->s, p, rep->len, 0);
-}
-
-inline int BitString::matches(const BitPattern& r, int p) const
-{
- return r.match(rep->s, p, rep->len, 1);
-}
-
-inline int BitString::index(const BitPattern& r, int startpos) const
-{
- return r.search(rep->s, startpos, rep->len);
-}
-
-inline int BitSubString::length() const
-{
- return len;
-}
-
-inline int BitSubString::empty() const
-{
- return len == 0;
-}
-
-inline int operator != (const BitString& x, const BitString& y)
-{
- return !(x == y);
-}
-
-inline int operator>(const BitString& x, const BitString& y)
-{
- return y < x;
-}
-
-inline int operator>=(const BitString& x, const BitString& y)
-{
- return y <= x;
-}
-
-inline int BitString::first(unsigned int b) const
-{
- return next(-1, b);
-}
-
-inline int BitString::last(unsigned int b) const
-{
- return prev(rep->len, b);
-}
-
-inline int BitString::index(unsigned int bit, int startpos) const
-{
- if (startpos >= 0)
- return next(startpos - 1, bit);
- else
- return prev(rep->len + startpos + 1, bit);
-}
-
-inline void BitString::right_trim(unsigned int b)
-{
- int nb = (b == 0)? 1 : 0;
- rep = BStr_resize(rep, prev(rep->len, nb) + 1);
-}
-
-inline void BitString::left_trim(unsigned int b)
-{
- int nb = (b == 0)? 1 : 0;
- int p = next(-1, nb);
- rep = BStr_alloc(rep, rep->s, p, rep->len, rep->len - p);
-}
-
-inline int BitString::test(int i) const
-{
- return ((unsigned)(i) >= rep->len)? 0 :
- ((rep->s[BitStr_index(i)] & (1 << (BitStr_pos(i)))) != 0);
-}
-
-
-// subscripting
-
-inline BitStrBit::BitStrBit(const BitStrBit& b) :src(b.src), pos(b.pos) {}
-
-inline BitStrBit::BitStrBit(BitString& v, int p) :src(v), pos(p) {}
-
-inline BitStrBit::~BitStrBit() {}
-
-inline BitStrBit::operator unsigned int() const
-{
- return src.test(pos);
-}
-
-inline int BitStrBit::operator = (unsigned int b)
-{
- src.assign(pos, b); return b;
-}
-
-inline BitStrBit BitString::operator [] (int i)
-{
- if ((unsigned)(i) >= rep->len) error("illegal bit index");
- return BitStrBit(*this, i);
-}
-
-inline BitSubString BitString::_substr(int first, int l)
-{
- if (first < 0 || l <= 0 || (unsigned)(first + l) > rep->len)
- return BitSubString(_nil_BitString, 0, 0) ;
- else
- return BitSubString(*this, first, l);
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Complex.h b/gnu/lib/libg++/include/Complex.h
deleted file mode 100644
index 128227bc..0000000
--- a/gnu/lib/libg++/include/Complex.h
+++ /dev/null
@@ -1,249 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _Complex_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Complex_h 1
-
-
-#include <iostream.h>
-#include <math.h>
-
-class Complex
-{
-#ifdef __ATT_complex__
-public:
-#else
-protected:
-#endif
-
- double re;
- double im;
-
-public:
-
- double real() const;
- double imag() const;
-
- Complex();
- Complex(const Complex& y);
- Complex(double r, double i=0);
-
- ~Complex();
-
- Complex& operator = (const Complex& y);
-
- Complex& operator += (const Complex& y);
- Complex& operator += (double y);
- Complex& operator -= (const Complex& y);
- Complex& operator -= (double y);
- Complex& operator *= (const Complex& y);
- Complex& operator *= (double y);
-
- Complex& operator /= (const Complex& y);
- Complex& operator /= (double y);
-
- void error(const char* msg) const;
-};
-
-
-// non-inline functions
-
-Complex operator / (const Complex& x, const Complex& y);
-Complex operator / (const Complex& x, double y);
-Complex operator / (double x, const Complex& y);
-
-Complex cos(const Complex& x);
-Complex sin(const Complex& x);
-
-Complex cosh(const Complex& x);
-Complex sinh(const Complex& x);
-
-Complex exp(const Complex& x);
-Complex log(const Complex& x);
-
-Complex pow(const Complex& x, int p);
-Complex pow(const Complex& x, const Complex& p);
-Complex pow(const Complex& x, double y);
-Complex sqrt(const Complex& x);
-
-istream& operator >> (istream& s, Complex& x);
-ostream& operator << (ostream& s, const Complex& x);
-
-
-// inline members
-
-inline double Complex::real() const { return re; }
-inline double Complex::imag() const { return im; }
-
-inline Complex::Complex() {}
-inline Complex::Complex(const Complex& y) :re(y.real()), im(y.imag()) {}
-inline Complex::Complex(double r, double i) :re(r), im(i) {}
-
-inline Complex::~Complex() {}
-
-inline Complex& Complex::operator = (const Complex& y)
-{
- re = y.real(); im = y.imag(); return *this;
-}
-
-inline Complex& Complex::operator += (const Complex& y)
-{
- re += y.real(); im += y.imag(); return *this;
-}
-
-inline Complex& Complex::operator += (double y)
-{
- re += y; return *this;
-}
-
-inline Complex& Complex::operator -= (const Complex& y)
-{
- re -= y.real(); im -= y.imag(); return *this;
-}
-
-inline Complex& Complex::operator -= (double y)
-{
- re -= y; return *this;
-}
-
-inline Complex& Complex::operator *= (const Complex& y)
-{
- double r = re * y.real() - im * y.imag();
- im = re * y.imag() + im * y.real();
- re = r;
- return *this;
-}
-
-inline Complex& Complex::operator *= (double y)
-{
- re *= y; im *= y; return *this;
-}
-
-
-// functions
-
-inline int operator == (const Complex& x, const Complex& y)
-{
- return x.real() == y.real() && x.imag() == y.imag();
-}
-
-inline int operator == (const Complex& x, double y)
-{
- return x.imag() == 0.0 && x.real() == y;
-}
-
-inline int operator != (const Complex& x, const Complex& y)
-{
- return x.real() != y.real() || x.imag() != y.imag();
-}
-
-inline int operator != (const Complex& x, double y)
-{
- return x.imag() != 0.0 || x.real() != y;
-}
-
-inline Complex operator - (const Complex& x)
-{
- return Complex(-x.real(), -x.imag());
-}
-
-inline Complex conj(const Complex& x)
-{
- return Complex(x.real(), -x.imag());
-}
-
-inline Complex operator + (const Complex& x, const Complex& y)
-{
- return Complex(x.real() + y.real(), x.imag() + y.imag());
-}
-
-inline Complex operator + (const Complex& x, double y)
-{
- return Complex(x.real() + y, x.imag());
-}
-
-inline Complex operator + (double x, const Complex& y)
-{
- return Complex(x + y.real(), y.imag());
-}
-
-inline Complex operator - (const Complex& x, const Complex& y)
-{
- return Complex(x.real() - y.real(), x.imag() - y.imag());
-}
-
-inline Complex operator - (const Complex& x, double y)
-{
- return Complex(x.real() - y, x.imag());
-}
-
-inline Complex operator - (double x, const Complex& y)
-{
- return Complex(x - y.real(), -y.imag());
-}
-
-inline Complex operator * (const Complex& x, const Complex& y)
-{
- return Complex(x.real() * y.real() - x.imag() * y.imag(),
- x.real() * y.imag() + x.imag() * y.real());
-}
-
-inline Complex operator * (const Complex& x, double y)
-{
- return Complex(x.real() * y, x.imag() * y);
-}
-
-inline Complex operator * (double x, const Complex& y)
-{
- return Complex(x * y.real(), x * y.imag());
-}
-
-inline double real(const Complex& x)
-{
- return x.real();
-}
-
-inline double imag(const Complex& x)
-{
- return x.imag();
-}
-
-inline double abs(const Complex& x)
-{
- return hypot(x.real(), x.imag());
-}
-
-inline double norm(const Complex& x)
-{
- return (x.real() * x.real() + x.imag() * x.imag());
-}
-
-inline double arg(const Complex& x)
-{
- return atan2(x.imag(), x.real());
-}
-
-inline Complex polar(double r, double t)
-{
- return Complex(r * cos(t), r * sin(t));
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/CursesW.h b/gnu/lib/libg++/include/CursesW.h
deleted file mode 100644
index 8ac6f3c..0000000
--- a/gnu/lib/libg++/include/CursesW.h
+++ /dev/null
@@ -1,595 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-
-/*
-Copyright (C) 1989 Free Software Foundation
- written by Eric Newton (newton@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _CursesWindow_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _CursesWindow_h
-
-#include <_G_config.h>
-#if _G_HAVE_CURSES
-// Even many system which mostly have C++-ready header files,
-// do not have C++-ready curses.h.
-extern "C" {
-#include <curses.h>
-}
-
-/* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
- Undefine it here, because CursesWindow uses lines as a method. */
-#undef lines
-
-// "Convert" macros to inlines, if needed.
-#ifdef addch
-inline int (addch)(char ch) { return addch(ch); }
-#undef addch
-#endif
-#ifdef addstr
-/* The (char*) cast is to hack around missing const's */
-inline int (addstr)(const char * str) { return addstr((char*)str); }
-#undef addstr
-#endif
-#ifdef clear
-inline int (clear)() { return clear(); }
-#undef clear
-#endif
-#ifdef clearok
-inline int (clearok)(WINDOW* win, int bf) { return clearok(win, bf); }
-#undef clearok
-#else
-extern "C" int clearok(WINDOW*, int);
-#endif
-#ifdef clrtobot
-inline int (clrtobot)() { return clrtobot(); }
-#undef clrtobot
-#endif
-#ifdef clrtoeol
-inline int (clrtoeol)() { return clrtoeol(); }
-#undef clrtoeol
-#endif
-#ifdef delch
-inline int (delch)() { return delch(); }
-#undef delch
-#endif
-#ifdef deleteln
-inline int (deleteln)() { return deleteln(); }
-#undef deleteln
-#endif
-#ifdef erase
-inline int (erase)() { return erase(); }
-#undef erase
-#endif
-#ifdef flushok
-inline int (flushok)(WINDOW* _win, int _bf) { return flushok(_win, _bf); }
-#undef flushok
-#else
-#define _no_flushok
-#endif
-#ifdef getch
-inline int (getch)() { return getch(); }
-#undef getch
-#endif
-#ifdef getstr
-inline int (getstr)(char *_str) { return getstr(_str); }
-#undef getstr
-#endif
-#ifdef getyx
-inline void (getyx)(WINDOW* win, int& y, int& x) { getyx(win, y, x); }
-#undef getyx
-#endif
-#ifdef inch
-inline int (inch)() { return inch(); }
-#undef inch
-#endif
-#ifdef insch
-inline int (insch)(char c) { return insch(c); }
-#undef insch
-#endif
-#ifdef insertln
-inline int (insertln)() { return insertln(); }
-#undef insertln
-#endif
-#ifdef leaveok
-inline int (leaveok)(WINDOW* win, int bf) { return leaveok(win, bf); }
-#undef leaveok
-#else
-extern "C" int leaveok(WINDOW* win, int bf);
-#endif
-#ifdef move
-inline int (move)(int x, int y) { return move(x, y); }
-#undef move
-#endif
-#ifdef refresh
-inline int (rfresh)() { return refresh(); }
-#undef refresh
-#endif
-#ifdef scrollok
-inline int (scrollok)(WINDOW* win, int bf) { return scrollok(win, bf); }
-#undef scrollok
-#else
-#ifndef hpux
-extern "C" int scrollok(WINDOW*, int);
-#else
-extern "C" int scrollok(WINDOW*, char);
-#endif
-#endif
-#ifdef standend
-inline int (standend)() { return standend(); }
-#undef standend
-#endif
-#ifdef standout
-inline int (standout)() { return standout(); }
-#undef standout
-#endif
-#ifdef wstandend
-inline int (wstandend)(WINDOW *win) { return wstandend(win); }
-#undef wstandend
-#endif
-#ifdef wstandout
-inline int (wstandout)(WINDOW *win) { return wstandout(win); }
-#undef wstandout
-#endif
-#ifdef winch
-inline int (winch)(WINDOW* win) { return winch(win); }
-#undef winch
-#endif
-
-/* deal with conflicting macros in ncurses.h which is SYSV based*/
-#ifdef box
-inline _G_box(WINDOW* win, chtype v, chtype h) {return box(win, v, h); }
-#undef box
-inline box(WINDOW* win, chtype v, chtype h) {return _G_box(win, v, h); }
-#endif
-#ifdef scroll
-inline (scroll)(WINDOW* win) { return scroll(win); }
-#undef scroll
-#endif
-#ifdef touchwin
-inline (touchwin)(WINDOW* win) { return touchwin(win); }
-#undef touchwin
-#endif
-
-#ifdef mvwaddch
-inline int (mvwaddch)(WINDOW *win, int y, int x, char ch)
-{ return mvwaddch(win, y, x, ch); }
-#undef mvwaddch
-#endif
-#ifdef mvwaddstr
-inline int (mvwaddstr)(WINDOW *win, int y, int x, const char * str)
-{ return mvwaddstr(win, y, x, (char*)str); }
-#undef mvwaddstr
-#endif
-#ifdef mvwdelch
-inline int (mvwdelch)(WINDOW *win, int y, int x) { return mvwdelch(win, y, x);}
-#undef mvwdelch
-#endif
-#ifdef mvwgetch
-inline int (mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);}
-#undef mvwgetch
-#endif
-#ifdef mvwgetstr
-inline int (mvwgetstr)(WINDOW *win, int y, int x, char *str)
-{return mvwgetstr(win,y,x, str);}
-#undef mvwgetstr
-#endif
-#ifdef mvwinch
-inline int (mvwinch)(WINDOW *win, int y, int x) { return mvwinch(win, y, x);}
-#undef mvwinch
-#endif
-#ifdef mvwinsch
-inline int (mvwinsch)(WINDOW *win, int y, int x, char c)
-{ return mvwinsch(win, y, x, c); }
-#undef mvwinsch
-#endif
-
-#ifdef mvaddch
-inline int (mvaddch)(int y, int x, char ch)
-{ return mvaddch(y, x, ch); }
-#undef mvaddch
-#endif
-#ifdef mvaddstr
-inline int (mvaddstr)(int y, int x, const char * str)
-{ return mvaddstr(y, x, (char*)str); }
-#undef mvaddstr
-#endif
-#ifdef mvdelch
-inline int (mvdelch)(int y, int x) { return mvdelch(y, x);}
-#undef mvdelch
-#endif
-#ifdef mvgetch
-inline int (mvgetch)(int y, int x) { return mvgetch(y, x);}
-#undef mvgetch
-#endif
-#ifdef mvgetstr
-inline int (mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);}
-#undef mvgetstr
-#endif
-#ifdef mvinch
-inline int (mvinch)(int y, int x) { return mvinch(y, x);}
-#undef mvinch
-#endif
-#ifdef mvinsch
-inline int (mvinsch)(int y, int x, char c)
-{ return mvinsch(y, x, c); }
-#undef mvinsch
-#endif
-
-/*
- *
- * C++ class for windows.
- *
- *
- */
-
-class CursesWindow
-{
-protected:
- static int count; // count of all active windows:
- // We rely on the c++ promise that
- // all otherwise uninitialized
- // static class vars are set to 0
-
- WINDOW * w; // the curses WINDOW
-
- int alloced; // true if we own the WINDOW
-
- CursesWindow* par; // parent, if subwindow
- CursesWindow* subwins; // head of subwindows list
- CursesWindow* sib; // next subwindow of parent
-
- void kill_subwindows(); // disable all subwindows
-
-public:
- CursesWindow(WINDOW* &window); // useful only for stdscr
-
- CursesWindow(int lines, // number of lines
- int cols, // number of columns
- int begin_y, // line origin
- int begin_x); // col origin
-
- CursesWindow(CursesWindow& par, // parent window
- int lines, // number of lines
- int cols, // number of columns
- int by, // absolute or relative
- int bx, // origins:
- char absrel = 'a'); // if `a', by & bx are
- // absolute screen pos,
- // else if `r', they are
- // relative to par origin
- ~CursesWindow();
-
-// terminal status
- int lines(); // number of lines on terminal, *not* window
- int cols(); // number of cols on terminal, *not* window
-
-// window status
- int height(); // number of lines in this window
- int width(); // number of cols in this window
- int begx(); // smallest x coord in window
- int begy(); // smallest y coord in window
- int maxx(); // largest x coord in window
- int maxy(); // largest x coord in window
-
-// window positioning
- int move(int y, int x);
-
-// coordinate positioning
- void getyx(int& y, int& x);
- int mvcur(int sy, int ey, int sx, int ex);
-
-// input
- int getch();
- int getstr(char * str);
- int scanw(const char *, ...);
-
-// input + positioning
- int mvgetch(int y, int x);
- int mvgetstr(int y, int x, char * str);
- int mvscanw(int, int, const char*, ...);
-
-// output
- int addch(const char ch);
- int addstr(const char * str);
- int printw(const char * fmt, ...);
- int inch();
- int insch(char c);
- int insertln();
-
-// output + positioning
- int mvaddch(int y, int x, char ch);
- int mvaddstr(int y, int x, const char * str);
- int mvprintw(int y, int x, const char * fmt, ...);
- int mvinch(int y, int x);
- int mvinsch(int y, int x, char ch);
-
-// borders
- int box(char vert, char hor);
-
-// erasure
- int erase();
- int clear();
- int clearok(int bf);
- int clrtobot();
- int clrtoeol();
- int delch();
- int mvdelch(int y, int x);
- int deleteln();
-
-// screen control
- int scroll();
- int scrollok(int bf);
- int touchwin();
- int refresh();
- int leaveok(int bf);
-#ifndef _no_flushok
- int flushok(int bf);
-#endif
- int standout();
- int standend();
-
-// multiple window control
- int overlay(CursesWindow &win);
- int overwrite(CursesWindow &win);
-
-
-// traversal support
- CursesWindow* child();
- CursesWindow* sibling();
- CursesWindow* parent();
-};
-
-
-inline int CursesWindow::begx()
-{
- return w->_begx;
-}
-
-inline int CursesWindow::begy()
-{
- return w->_begy;
-}
-
-inline int CursesWindow::maxx()
-{
- return w->_maxx;
-}
-
-inline int CursesWindow::maxy()
-{
- return w->_maxy;
-}
-
-inline int CursesWindow::height()
-{
- return maxy() - begy() + 1;
-}
-
-inline int CursesWindow::width()
-{
- return maxx() - begx() + 1;
-}
-
-inline int CursesWindow::box(char vert, char hor)
-{
- return ::box(w, vert, hor);
-}
-
-inline int CursesWindow::overlay(CursesWindow &win)
-{
- return ::overlay(w, win.w);
-}
-
-inline int CursesWindow::overwrite(CursesWindow &win)
-{
- return ::overwrite(w, win.w);
-}
-
-inline int CursesWindow::scroll()
-{
- return ::scroll(w);
-}
-
-
-inline int CursesWindow::touchwin()
-{
- return ::touchwin(w);
-}
-
-inline int CursesWindow::addch(const char ch)
-{
- return ::waddch(w, ch);
-}
-
-inline int CursesWindow::addstr(const char * str)
-{
- // The (char*) cast is to hack around prototypes in curses.h that
- // have const missing in the parameter lists. [E.g. SVR4]
- return ::waddstr(w, (char*)str);
-}
-
-inline int CursesWindow::clear()
-{
- return ::wclear(w);
-}
-
-inline int CursesWindow::clrtobot()
-{
- return ::wclrtobot(w);
-}
-
-inline int CursesWindow::clrtoeol()
-{
- return ::wclrtoeol(w);
-}
-
-inline int CursesWindow::delch()
-{
- return ::wdelch(w);
-}
-
-inline int CursesWindow::deleteln()
-{
- return ::wdeleteln(w);
-}
-
-inline int CursesWindow::erase()
-{
- return ::werase(w);
-}
-
-inline int CursesWindow::getch()
-{
- return ::wgetch(w);
-}
-
-inline int CursesWindow::getstr(char * str)
-{
- return ::wgetstr(w, str);
-}
-
-inline int CursesWindow::inch()
-{
- return winch(w);
-}
-
-inline int CursesWindow::insch(char c)
-{
- return ::winsch(w, c);
-}
-
-inline int CursesWindow::insertln()
-{
- return ::winsertln(w);
-}
-
-inline int CursesWindow::move(int y, int x)
-{
- return ::wmove(w, y, x);
-}
-
-
-inline int CursesWindow::mvcur(int sy, int ey, int sx, int ex)
-{
- return ::mvcur(sy, ey, sx,ex);
-}
-
-inline int CursesWindow::mvaddch(int y, int x, char ch)
-{
- return (::wmove(w, y, x)==ERR) ? ERR : ::waddch(w, ch);
-}
-
-inline int CursesWindow::mvgetch(int y, int x)
-{
- return (::wmove(w, y, x)==ERR) ? ERR : ::wgetch(w);
-}
-
-inline int CursesWindow::mvaddstr(int y, int x, const char * str)
-{
- return (::wmove(w, y, x)==ERR) ? ERR : ::waddstr(w, (char*)str);
-}
-
-inline int CursesWindow::mvgetstr(int y, int x, char * str)
-{
- return (::wmove(w, y, x)==ERR) ? ERR : ::wgetstr(w, str);
-}
-
-inline int CursesWindow::mvinch(int y, int x)
-{
- return (::wmove(w, y, x)==ERR) ? ERR : ::winch(w);
-}
-
-inline int CursesWindow::mvdelch(int y, int x)
-{
- return (::wmove(w, y, x)==ERR) ? ERR : ::wdelch(w);
-}
-
-inline int CursesWindow::mvinsch(int y, int x, char ch)
-{
- return (::wmove(w, y, x)==ERR) ? ERR : ::winsch(w, ch);
-}
-
-inline int CursesWindow::refresh()
-{
- return ::wrefresh(w);
-}
-
-inline int CursesWindow::clearok(int bf)
-{
- return ::clearok(w,bf);
-}
-
-inline int CursesWindow::leaveok(int bf)
-{
- return ::leaveok(w,bf);
-}
-
-inline int CursesWindow::scrollok(int bf)
-{
- return ::scrollok(w,bf);
-}
-
-#ifndef _no_flushok
-inline int CursesWindow::flushok(int bf)
-{
- return ::flushok(w, bf);
-}
-#endif
-
-inline void CursesWindow::getyx(int& y, int& x)
-{
- ::getyx(w, y, x);
-}
-
-inline int CursesWindow::standout()
-{
- return ::wstandout(w);
-}
-
-inline int CursesWindow::standend()
-{
- return ::wstandend(w);
-}
-
-inline int CursesWindow::lines()
-{
- return LINES;
-}
-
-inline int CursesWindow::cols()
-{
- return COLS;
-}
-
-inline CursesWindow* CursesWindow::child()
-{
- return subwins;
-}
-
-inline CursesWindow* CursesWindow::parent()
-{
- return par;
-}
-
-inline CursesWindow* CursesWindow::sibling()
-{
- return sib;
-}
-
-#endif /* _G_HAVE_CURSES */
-#endif
diff --git a/gnu/lib/libg++/include/DLList.h b/gnu/lib/libg++/include/DLList.h
deleted file mode 100644
index ba7ee86..0000000
--- a/gnu/lib/libg++/include/DLList.h
+++ /dev/null
@@ -1,137 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-#ifndef _DLList_h
-#ifdef __GNUG__
-//#pragma interface
-#endif
-#define _DLList_h 1
-
-#include <Pix.h>
-
-struct BaseDLNode {
- BaseDLNode *bk;
- BaseDLNode *fd;
- void *item() {return (void*)(this+1);} //Return ((DLNode<T>*)this)->hd
-};
-
-template<class T>
-class DLNode : public BaseDLNode
-{
- public:
- T hd;
- DLNode() { }
- DLNode(const T& h, DLNode* p = 0, DLNode* n = 0)
- : hd(h) { bk = p; fd = n; }
- ~DLNode() { }
-};
-
-class BaseDLList {
- protected:
- BaseDLNode *h;
-
- BaseDLList() { h = 0; }
- void copy(const BaseDLList&);
- BaseDLList& operator= (const BaseDLList& a);
- virtual void delete_node(BaseDLNode*node) = 0;
- virtual BaseDLNode* copy_node(const void* datum) = 0;
- virtual void copy_item(void *dst, void *src) = 0;
- virtual ~BaseDLList() { }
-
- Pix prepend(const void*);
- Pix append(const void*);
- Pix ins_after(Pix p, const void *datum);
- Pix ins_before(Pix p, const void *datum);
- void remove_front(void *dst);
- void remove_rear(void *dst);
- void join(BaseDLList&);
-
- public:
- int empty() const { return h == 0; }
- int length() const;
- void clear();
- void error(const char* msg) const;
- int owns(Pix p) const;
- int OK() const;
- void del(Pix& p, int dir = 1);
- void del_after(Pix& p);
- void del_front();
- void del_rear();
-};
-
-template <class T>
-class DLList : public BaseDLList {
- //friend class <T>DLListTrav;
-
- virtual void delete_node(BaseDLNode *node) { delete (DLNode<T>*)node; }
- virtual BaseDLNode* copy_node(const void *datum)
- { return new DLNode<T>(*(const T*)datum); }
- virtual void copy_item(void *dst, void *src) { *(T*)dst = *(T*)src; }
-
- public:
- DLList() : BaseDLList() { }
- DLList(const DLList<T>& a) : BaseDLList() { copy(a); }
-
- DLList<T>& operator = (const DLList<T>& a)
- { BaseDLList::operator=((const BaseDLList&) a); return *this; }
- virtual ~DLList() { clear(); }
-
- Pix prepend(const T& item) {return BaseDLList::prepend(&item);}
- Pix append(const T& item) {return BaseDLList::append(&item);}
-
- void join(DLList<T>& a) { BaseDLList::join(a); }
-
- T& front() {
- if (h == 0) error("front: empty list");
- return ((DLNode<T>*)h)->hd; }
- T& rear() {
- if (h == 0) error("rear: empty list");
- return ((DLNode<T>*)h->bk)->hd;
- }
- const T& front() const {
- if (h == 0) error("front: empty list");
- return ((DLNode<T>*)h)->hd; }
- const T& rear() const {
- if (h == 0) error("rear: empty list");
- return ((DLNode<T>*)h->bk)->hd;
- }
- T remove_front() { T dst; BaseDLList::remove_front(&dst); return dst; }
- T remove_rear() { T dst; BaseDLList::remove_rear(&dst); return dst; }
-
- T& operator () (Pix p) {
- if (p == 0) error("null Pix");
- return ((DLNode<T>*)p)->hd;
- }
- const T& operator () (Pix p) const {
- if (p == 0) error("null Pix");
- return ((DLNode<T>*)p)->hd;
- }
- Pix first() const { return Pix(h); }
- Pix last() const { return (h == 0) ? 0 : Pix(h->bk); }
- void next(Pix& p) const
- { p = (p == 0 || p == h->bk)? 0 : Pix(((DLNode<T>*)p)->fd); }
- void prev(Pix& p) const
- { p = (p == 0 || p == h)? 0 : Pix(((DLNode<T>*)p)->bk); }
- Pix ins_after(Pix p, const T& item)
- {return BaseDLList::ins_after(p, &item); }
- Pix ins_before(Pix p, const T& item)
- {return BaseDLList::ins_before(p, &item);}
-};
-
-#endif
diff --git a/gnu/lib/libg++/include/DiscUnif.h b/gnu/lib/libg++/include/DiscUnif.h
deleted file mode 100644
index 0cd6a0f..0000000
--- a/gnu/lib/libg++/include/DiscUnif.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _DiscreteUniform_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _DiscreteUniform_h 1
-
-#include <Random.h>
-
-//
-// The interval [lo..hi)
-//
-
-class DiscreteUniform: public Random {
- long pLow;
- long pHigh;
- double delta;
-public:
- DiscreteUniform(long low, long high, RNG *gen);
-
- long low();
- long low(long x);
- long high();
- long high(long x);
-
- virtual double operator()();
-};
-
-
-inline DiscreteUniform::DiscreteUniform(long low, long high, RNG *gen)
-: Random(gen)
-{
- pLow = (low < high) ? low : high;
- pHigh = (low < high) ? high : low;
- delta = (pHigh - pLow) + 1;
-}
-
-inline long DiscreteUniform::low() { return pLow; }
-
-inline long DiscreteUniform::low(long x) {
- long tmp = pLow;
- pLow = x;
- delta = (pHigh - pLow) + 1;
- return tmp;
-}
-
-inline long DiscreteUniform::high() { return pHigh; }
-
-inline long DiscreteUniform::high(long x) {
- long tmp = pHigh;
- pHigh = x;
- delta = (pHigh - pLow) + 1;
- return tmp;
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Erlang.h b/gnu/lib/libg++/include/Erlang.h
deleted file mode 100644
index 18838fc..0000000
--- a/gnu/lib/libg++/include/Erlang.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _Erlang_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Erlang_h 1
-
-#include <Random.h>
-
-class Erlang: public Random {
-protected:
- double pMean;
- double pVariance;
- int k;
- double a;
- void setState();
-public:
- Erlang(double mean, double variance, RNG *gen);
-
- double mean();
- double mean(double x);
- double variance();
- double variance(double x);
-
- virtual double operator()();
-
-};
-
-
-inline void Erlang::setState() {
- k = int( (pMean * pMean ) / pVariance + 0.5 );
- k = (k > 0) ? k : 1;
- a = k / pMean;
-}
-
-inline Erlang::Erlang(double mean, double variance, RNG *gen) : Random(gen)
-{
- pMean = mean; pVariance = variance;
- setState();
-}
-
-inline double Erlang::mean() { return pMean; }
-inline double Erlang::mean(double x) {
- double tmp = pMean; pMean = x; setState(); return tmp;
-};
-
-inline double Erlang::variance() { return pVariance; }
-inline double Erlang::variance(double x) {
- double tmp = pVariance; pVariance = x; setState(); return tmp;
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Fix.h b/gnu/lib/libg++/include/Fix.h
deleted file mode 100644
index fab91b8..0000000
--- a/gnu/lib/libg++/include/Fix.h
+++ /dev/null
@@ -1,513 +0,0 @@
-// -*- C++ -*-
-// Fix.h : variable length fixed point data type
-//
-
-#ifndef _Fix_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Fix_h 1
-
-#include <stream.h>
-#include <std.h>
-#include <stddef.h>
-#include <Integer.h>
-#include <builtin.h>
-
-class Fix
-{
- struct Rep // internal Fix representation
- {
- _G_uint16_t len; // length in bits
- _G_uint16_t siz; // allocated storage
- _G_int16_t ref; // reference count
- _G_uint16_t s[1]; // start of ushort array represention
- };
-
-public:
-
- typedef void (*PEH)(Rep*);
-
-private:
-
- Rep* rep;
-
- Fix(Rep*);
- Fix(int, const Rep*);
-
- void unique();
-
- static const _G_uint16_t min_length = 1;
- static const _G_uint16_t max_length = 65535;
- static const double min_value = -1.0;
- static const double max_value = 1.0;
-
- static _G_uint16_t default_length;
- static int default_print_width;
- static Rep Rep_0;
- static Rep Rep_m1;
- static Rep Rep_quotient_bump;
-
- // internal class functions
- static void mask(Rep*);
- static int compare(const Rep*, const Rep* = &Rep_0);
-
- static Rep* new_Fix(_G_uint16_t);
- static Rep* new_Fix(_G_uint16_t, const Rep*);
- static Rep* new_Fix(_G_uint16_t, double);
-
- static Rep* copy(const Rep*, Rep*);
- static Rep* negate(const Rep*, Rep* = NULL);
- static Rep* add(const Rep*, const Rep*, Rep* = NULL);
- static Rep* subtract(const Rep*, const Rep*, Rep* = NULL);
- static Rep* multiply(const Rep*, const Rep*, Rep* = NULL);
- static Rep* multiply(const Rep*, int, Rep* = NULL);
- static Rep* divide(const Rep*, const Rep*, Rep* = NULL,
- Rep* = NULL);
- static Rep* shift(const Rep*, int, Rep* = NULL);
-
- static one_arg_error_handler_t error_handler;
- static one_arg_error_handler_t range_error_handler;
-
- static PEH overflow_handler;
-
-public:
- Fix();
- Fix(const Fix&);
- Fix(double);
- Fix(int);
- Fix(int, const Fix&);
- Fix(int, double);
-
- ~Fix();
-
- Fix operator = (const Fix&);
- Fix operator = (double);
-
- friend int operator == (const Fix&, const Fix&);
- friend int operator != (const Fix&, const Fix&);
-
- friend int operator < (const Fix&, const Fix&);
- friend int operator <= (const Fix&, const Fix&);
- friend int operator > (const Fix&, const Fix&);
- friend int operator >= (const Fix&, const Fix&);
-
- Fix& operator + ();
- Fix operator - ();
-
- friend Fix operator + (const Fix&, const Fix&);
- friend Fix operator - (const Fix&, const Fix&);
- friend Fix operator * (const Fix&, const Fix&);
- friend Fix operator / (const Fix&, const Fix&);
-
- friend Fix operator * (const Fix&, int);
- friend Fix operator * (int, const Fix&);
- friend Fix operator % (const Fix&, int);
- friend Fix operator << (const Fix&, int);
- friend Fix operator >> (const Fix&, int);
-
-#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
- friend Fix operator <? (const Fix&, const Fix&); // min
- friend Fix operator >? (const Fix&, const Fix&); // max
-#endif
-
- Fix operator += (const Fix&);
- Fix operator -= (const Fix&);
- Fix operator *= (const Fix&);
- Fix operator /= (const Fix&);
-
- Fix operator *= (int);
- Fix operator %= (int);
- Fix operator <<=(int);
- Fix operator >>=(int);
-
- friend char* Ftoa(const Fix&, int width = default_print_width);
- void printon(ostream&, int width = default_print_width) const;
- friend Fix atoF(const char*, int len = default_length);
-
- friend istream& operator >> (istream&, Fix&);
- friend ostream& operator << (ostream&, const Fix&);
-
- // built-in functions
- friend Fix abs(Fix); // absolute value
- friend int sgn(const Fix&); // -1, 0, +1
- friend Integer mantissa(const Fix&); // integer representation
- friend double value(const Fix&); // double value
- friend int length(const Fix&); // field length
- friend void show(const Fix&); // show contents
-
- // error handlers
- static void error(const char* msg); // error handler
- static void range_error(const char* msg); // range error handler
-
- static one_arg_error_handler_t set_error_handler(one_arg_error_handler_t f);
- static one_arg_error_handler_t
- set_range_error_handler(one_arg_error_handler_t f);
-
- static void default_error_handler (const char *);
- static void default_range_error_handler (const char *);
-
- // non-operator versions for user
- friend void negate(const Fix& x, Fix& r);
- friend void add(const Fix& x, const Fix& y, Fix& r);
- friend void subtract(const Fix& x, const Fix& y, Fix& r);
- friend void multiply(const Fix& x, const Fix& y, Fix& r);
- friend void divide(const Fix& x, const Fix& y, Fix& q, Fix& r);
- friend void shift(const Fix& x, int y, Fix& r);
-
- // overflow handlers
- static void overflow_saturate(Fix::Rep*);
- static void overflow_wrap(Fix::Rep*);
- static void overflow_warning_saturate(Fix::Rep*);
- static void overflow_warning(Fix::Rep*);
- static void overflow_error(Fix::Rep*);
-
- static PEH set_overflow_handler(PEH);
-
- static int set_default_length(int);
-};
-
-// function definitions
-
-inline void
-Fix::unique()
-{
- if ( rep->ref > 1 )
- {
- rep->ref--;
- rep = new_Fix(rep->len,rep);
- }
-}
-
-inline void
-Fix::mask (Fix::Rep* x)
-{
- int n = x->len & 0x0f;
- if ( n )
- x->s[x->siz - 1] &= 0xffff0000 >> n;
-}
-
-inline Fix::Rep*
-Fix::copy(const Fix::Rep* from, Fix::Rep* to)
-{
- _G_uint16_t *ts = to->s;
- const _G_uint16_t *fs = from->s;
- int ilim = to->siz < from->siz ? to->siz : from->siz;
- for ( int i=0; i < ilim; i++ )
- *ts++ = *fs++;
- for ( ; i < to->siz; i++ )
- *ts++ = 0;
- mask(to);
- return to;
-}
-
-inline
-Fix::Fix(Rep* f)
-{
- rep = f;
-}
-
-inline
-Fix::Fix()
-{
- rep = new_Fix(default_length);
-}
-
-inline
-Fix::Fix(int len)
-{
- if ( len < min_length || len > max_length )
- error("illegal length in declaration");
- rep = new_Fix((_G_uint16_t) len);
-}
-
-inline
-Fix::Fix(double d)
-{
- rep = new_Fix(default_length,d);
-}
-
-inline
-Fix::Fix(const Fix& y)
-{
- rep = y.rep; rep->ref++;
-}
-
-inline
-Fix::Fix(int len, const Fix& y)
-{
- if ( len < Fix::min_length || len > Fix::max_length )
- error("illegal length in declaration");
- rep = new_Fix((_G_uint16_t) len,y.rep);
-}
-
-inline
-Fix::Fix(int len, const Rep* fr)
-{
- if ( len < Fix::min_length || len > Fix::max_length )
- error("illegal length in declaration");
- rep = new_Fix((_G_uint16_t) len,fr);
-}
-
-inline
-Fix::Fix(int len, double d)
-{
- if ( len < Fix::min_length || len > Fix::max_length )
- error("illegal length in declaration");
- rep = new_Fix((_G_uint16_t) len,d);
-}
-
-inline
-Fix::~Fix()
-{
- if ( --rep->ref <= 0 ) delete rep;
-}
-
-inline Fix
-Fix::operator = (const Fix& y)
-{
- if ( rep->len == y.rep->len ) {
- ++y.rep->ref;
- if ( --rep->ref <= 0 ) delete rep;
- rep = y.rep;
- }
- else {
- unique();
- copy(y.rep,rep);
- }
- return *this;
-}
-
-inline Fix
-Fix::operator = (double d)
-{
- int oldlen = rep->len;
- if ( --rep->ref <= 0 ) delete rep;
- rep = new_Fix(oldlen,d);
- return *this;
-}
-
-inline int
-operator == (const Fix& x, const Fix& y)
-{
- return Fix::compare(x.rep, y.rep) == 0;
-}
-
-inline int
-operator != (const Fix& x, const Fix& y)
-{
- return Fix::compare(x.rep, y.rep) != 0;
-}
-
-inline int
-operator < (const Fix& x, const Fix& y)
-{
- return Fix::compare(x.rep, y.rep) < 0;
-}
-
-inline int
-operator <= (const Fix& x, const Fix& y)
-{
- return Fix::compare(x.rep, y.rep) <= 0;
-}
-
-inline int
-operator > (const Fix& x, const Fix& y)
-{
- return Fix::compare(x.rep, y.rep) > 0;
-}
-
-inline int
-operator >= (const Fix& x, const Fix& y)
-{
- return Fix::compare(x.rep, y.rep) >= 0;
-}
-
-inline Fix&
-Fix::operator + ()
-{
- return *this;
-}
-
-inline Fix
-Fix::operator - ()
-{
- Rep* r = negate(rep); return r;
-}
-
-inline Fix
-operator + (const Fix& x, const Fix& y)
-{
- Fix::Rep* r = Fix::add(x.rep, y.rep); return r;
-}
-
-inline Fix
-operator - (const Fix& x, const Fix& y)
-{
- Fix::Rep* r = Fix::subtract(x.rep, y.rep); return r;
-}
-
-inline Fix
-operator * (const Fix& x, const Fix& y)
-{
- Fix::Rep* r = Fix::multiply(x.rep, y.rep); return r;
-}
-
-inline Fix
-operator * (const Fix& x, int y)
-{
- Fix::Rep* r = Fix::multiply(x.rep, y); return r;
-}
-
-inline Fix
-operator * (int y, const Fix& x)
-{
- Fix::Rep* r = Fix::multiply(x.rep, y); return r;
-}
-
-inline Fix
-operator / (const Fix& x, const Fix& y)
-{
- Fix::Rep* r = Fix::divide(x.rep, y.rep); return r;
-}
-
-inline Fix
-Fix::operator += (const Fix& y)
-{
- unique(); Fix::add(rep, y.rep, rep); return *this;
-}
-
-inline Fix
-Fix::operator -= (const Fix& y)
-{
- unique(); Fix::subtract(rep, y.rep, rep); return *this;
-}
-
-inline Fix
-Fix::operator *= (const Fix& y)
-{
- unique(); Fix::multiply(rep, y.rep, rep); return *this;
-}
-
-inline Fix
-Fix::operator *= (int y)
-{
- unique(); Fix::multiply(rep, y, rep); return *this;
-}
-
-inline Fix
-Fix::operator /= (const Fix& y)
-{
- unique(); Fix::divide(rep, y.rep, rep); return *this;
-}
-
-inline Fix
-operator % (const Fix& x, int y)
-{
- Fix r((int) x.rep->len + y, x); return r;
-}
-
-inline Fix
-operator << (const Fix& x, int y)
-{
- Fix::Rep* rep = Fix::shift(x.rep, y); return rep;
-}
-
-inline Fix
-operator >> (const Fix& x, int y)
-{
- Fix::Rep* rep = Fix::shift(x.rep, -y); return rep;
-}
-
-inline Fix
-Fix::operator <<= (int y)
-{
- unique(); Fix::shift(rep, y, rep); return *this;
-}
-
-inline Fix
-Fix::operator >>= (int y)
-{
- unique(); Fix::shift(rep, -y, rep); return *this;
-}
-
-#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
-inline Fix
-operator <? (const Fix& x, const Fix& y)
-{
- if ( Fix::compare(x.rep, y.rep) <= 0 ) return x; else return y;
-}
-
-inline Fix
-operator >? (const Fix& x, const Fix& y)
-{
- if ( Fix::compare(x.rep, y.rep) >= 0 ) return x; else return y;
-}
-#endif
-
-inline Fix
-abs(Fix x)
-{
- Fix::Rep* r = (Fix::compare(x.rep) >= 0 ? Fix::new_Fix(x.rep->len,x.rep) :
- Fix::negate(x.rep));
- return r;
-}
-
-inline int
-sgn(const Fix& x)
-{
- int a = Fix::compare(x.rep);
- return a == 0 ? 0 : (a > 0 ? 1 : -1);
-}
-
-inline int
-length(const Fix& x)
-{
- return x.rep->len;
-}
-
-inline ostream&
-operator << (ostream& s, const Fix& y)
-{
- if (s.opfx())
- y.printon(s);
- return s;
-}
-
-inline void
-negate (const Fix& x, Fix& r)
-{
- Fix::negate(x.rep, r.rep);
-}
-
-inline void
-add (const Fix& x, const Fix& y, Fix& r)
-{
- Fix::add(x.rep, y.rep, r.rep);
-}
-
-inline void
-subtract (const Fix& x, const Fix& y, Fix& r)
-{
- Fix::subtract(x.rep, y.rep, r.rep);
-}
-
-inline void
-multiply (const Fix& x, const Fix& y, Fix& r)
-{
- Fix::multiply(x.rep, y.rep, r.rep);
-}
-
-inline void
-divide (const Fix& x, const Fix& y, Fix& q, Fix& r)
-{
- Fix::divide(x.rep, y.rep, q.rep, r.rep);
-}
-
-inline void
-shift (const Fix& x, int y, Fix& r)
-{
- Fix::shift(x.rep, y, r.rep);
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Fix16.h b/gnu/lib/libg++/include/Fix16.h
deleted file mode 100644
index 2ab2209..0000000
--- a/gnu/lib/libg++/include/Fix16.h
+++ /dev/null
@@ -1,648 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu)
- adapted for libg++ by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _Fix16_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Fix16_h 1
-
-#include <stream.h>
-#include <std.h>
-
-// constant definitions
-
-#define Fix16_fs ((double)((unsigned)(1 << 15)))
-
-#define Fix16_msb (1 << 15)
-#define Fix16_m_max ((1 << 15) - 1)
-#define Fix16_m_min ((short)(1 << 15))
-
-#define Fix16_mult Fix16_fs
-#define Fix16_div (1./Fix16_fs)
-#define Fix16_max (1. - .5/Fix16_fs)
-#define Fix16_min (-1.)
-
-
-#define Fix32_fs ((double)((_G_uint32_t)(1 << 31)))
-
-#define Fix32_msb ((_G_uint32_t)(1 << 31))
-#define Fix32_m_max ((_G_int32_t)((1 << 31) - 1))
-#define Fix32_m_min ((_G_int32_t)(1 << 31))
-
-#define Fix32_mult Fix32_fs
-#define Fix32_div (1./Fix32_fs)
-#define Fix32_max (1. - .5/Fix32_fs)
-#define Fix32_min (-1.)
-
-
-//
-// Fix16 class: 16-bit Fixed point data type
-//
-// consists of a 16-bit mantissa (sign bit & 15 data bits).
-//
-
-class Fix16
-{
- friend class Fix32;
-
- short m;
-
- short round(double d);
- short assign(double d);
- Fix16(short i);
- Fix16(int i);
-
- operator double() const;
-
-
-public:
- Fix16();
- Fix16(const Fix16& f);
- Fix16(double d);
- Fix16(const Fix32& f);
-
- ~Fix16();
-
- Fix16& operator=(const Fix16& f);
- Fix16& operator=(double d);
- Fix16& operator=(const Fix32& f);
-
- friend short& mantissa(Fix16& f);
- friend const short& mantissa(const Fix16& f);
- friend double value(const Fix16& f);
-
- Fix16 operator + () const;
- Fix16 operator - () const;
-
- friend Fix16 operator + (const Fix16& f, const Fix16& g);
- friend Fix16 operator - (const Fix16& f, const Fix16& g);
- friend Fix32 operator * (const Fix16& f, const Fix16& g);
- friend Fix16 operator / (const Fix16& f, const Fix16& g);
- friend Fix16 operator << (const Fix16& f, int b);
- friend Fix16 operator >> (const Fix16& f, int b);
-
- Fix16& operator += (const Fix16& f);
- Fix16& operator -= (const Fix16& f);
- Fix16& operator *= (const Fix16& );
- Fix16& operator /= (const Fix16& f);
-
- Fix16& operator <<=(int b);
- Fix16& operator >>=(int b);
-
- friend int operator == (const Fix16& f, const Fix16& g);
- friend int operator != (const Fix16& f, const Fix16& g);
- friend int operator >= (const Fix16& f, const Fix16& g);
- friend int operator <= (const Fix16& f, const Fix16& g);
- friend int operator > (const Fix16& f, const Fix16& g);
- friend int operator < (const Fix16& f, const Fix16& g);
-
- friend istream& operator >> (istream& s, Fix16& f);
- friend ostream& operator << (ostream& s, const Fix16& f);
-
- void overflow(short&) const;
- void range_error(short&) const;
-
- friend Fix16 operator * (const Fix16& f, int g);
- friend Fix16 operator * (int g, const Fix16& f);
- Fix16& operator *= (int g);
-};
-
-
-//
-// Fix32 class: 32-bit Fixed point data type
-//
-// consists of a 32-bit mantissa (sign bit & 31 data bits).
-//
-
-class Fix32
-{
- friend class Fix16;
-
- _G_int32_t m;
-
- _G_int32_t round(double d);
- _G_int32_t assign(double d);
-
- Fix32(_G_int32_t i);
- operator double() const;
-
-
-public:
- Fix32();
- Fix32(const Fix32& f);
- Fix32(const Fix16& f);
- Fix32(double d);
- ~Fix32();
-
- Fix32& operator = (const Fix32& f);
- Fix32& operator = (const Fix16& f);
- Fix32& operator = (double d);
-
- friend _G_int32_t& mantissa(Fix32& f);
- friend const _G_int32_t& mantissa(const Fix32& f);
- friend double value(const Fix32& f);
-
- Fix32 operator + () const;
- Fix32 operator - () const;
-
- friend Fix32 operator + (const Fix32& f, const Fix32& g);
- friend Fix32 operator - (const Fix32& f, const Fix32& g);
- friend Fix32 operator * (const Fix32& f, const Fix32& g);
- friend Fix32 operator / (const Fix32& f, const Fix32& g);
- friend Fix32 operator << (const Fix32& f, int b);
- friend Fix32 operator >> (const Fix32& f, int b);
-
- friend Fix32 operator * (const Fix16& f, const Fix16& g);
-
- Fix32& operator += (const Fix32& f);
- Fix32& operator -= (const Fix32& f);
- Fix32& operator *= (const Fix32& f);
- Fix32& operator /= (const Fix32& f);
- Fix32& operator <<=(int b);
- Fix32& operator >>=(int b);
-
- friend int operator == (const Fix32& f, const Fix32& g);
- friend int operator != (const Fix32& f, const Fix32& g);
- friend int operator >= (const Fix32& f, const Fix32& g);
- friend int operator <= (const Fix32& f, const Fix32& g);
- friend int operator > (const Fix32& f, const Fix32& g);
- friend int operator < (const Fix32& f, const Fix32& g);
-
- friend istream& operator >> (istream& s, Fix32& f);
- friend ostream& operator << (ostream& s, const Fix32& f);
-
- void overflow(_G_int32_t& i) const;
- void range_error(_G_int32_t& i) const;
-
- friend Fix32 operator * (const Fix32& f, int g);
- friend Fix32 operator * (int g, const Fix32& f);
- Fix32& operator *= (int g);
-};
-
-// active error handler declarations
-
-typedef void (*Fix16_peh)(short&);
-typedef void (*Fix32_peh)(_G_int32_t&);
-
-extern Fix16_peh Fix16_overflow_handler;
-extern Fix32_peh Fix32_overflow_handler;
-
-extern Fix16_peh Fix16_range_error_handler;
-extern Fix32_peh Fix32_range_error_handler;
-
-#if defined(SHORT_NAMES) || defined(VMS)
-#define set_overflow_handler sohndl
-#define set_range_error_handler srnghdl
-#endif
-
-
-// error handler declarations
-
-extern Fix16_peh set_Fix16_overflow_handler(Fix16_peh);
-extern Fix32_peh set_Fix32_overflow_handler(Fix32_peh);
-extern void set_overflow_handler(Fix16_peh, Fix32_peh);
-
-extern Fix16_peh set_Fix16_range_error_handler(Fix16_peh);
-extern Fix32_peh set_Fix32_range_error_handler(Fix32_peh);
-extern void set_range_error_handler(Fix16_peh, Fix32_peh);
-
-extern void
- Fix16_ignore(short&),
- Fix16_overflow_saturate(short&),
- Fix16_overflow_warning_saturate(short&),
- Fix16_warning(short&),
- Fix16_abort(short&);
-
-extern void
- Fix32_ignore(_G_int32_t&),
- Fix32_overflow_saturate(_G_int32_t&),
- Fix32_overflow_warning_saturate(_G_int32_t&),
- Fix32_warning(_G_int32_t&),
- Fix32_abort(_G_int32_t&);
-
-
-inline Fix16::~Fix16() {}
-
-inline short Fix16::round(double d)
-{
- return short( (d >= 0)? d + 0.5 : d - 0.5);
-}
-
-inline Fix16::Fix16(short i)
-{
- m = i;
-}
-
-inline Fix16::Fix16(int i)
-{
- m = i;
-}
-
-inline Fix16::operator double() const
-{
- return Fix16_div * m;
-}
-
-inline Fix16::Fix16()
-{
- m = 0;
-}
-
-inline Fix16::Fix16(const Fix16& f)
-{
- m = f.m;
-}
-
-inline Fix16::Fix16(double d)
-{
- m = assign(d);
-}
-
-
-inline Fix16& Fix16::operator=(const Fix16& f)
-{
- m = f.m;
- return *this;
-}
-
-inline Fix16& Fix16::operator=(double d)
-{
- m = assign(d);
- return *this;
-}
-
-
-inline Fix32::Fix32()
-{
- m = 0;
-}
-
-inline Fix32::Fix32(_G_int32_t i)
-{
- m = i;
-}
-
-inline Fix32:: operator double() const
-{
- return Fix32_div * m;
-}
-
-
-inline Fix32::Fix32(const Fix32& f)
-{
- m = f.m;
-}
-
-inline Fix32::Fix32(const Fix16& f)
-{
- m = _G_int32_t(f.m) << 16;
-}
-
-inline Fix32::Fix32(double d)
-{
- m = assign(d);
-}
-
-inline Fix16::Fix16(const Fix32& f)
-{
- m = f.m >> 16;
-}
-
-
-inline Fix16& Fix16::operator=(const Fix32& f)
-{
- m = f.m >> 16;
- return *this;
-}
-
-inline Fix32& Fix32::operator=(const Fix32& f)
-{
- m = f.m;
- return *this;
-}
-
-inline Fix32& Fix32::operator=(const Fix16& f)
-{
- m = _G_int32_t(f.m) << 16;
- return *this;
-}
-
-inline Fix32& Fix32::operator=(double d)
-{
- m = assign(d);
- return *this;
-}
-
-inline short& mantissa(Fix16& f)
-{
- return f.m;
-}
-
-inline const short& mantissa(const Fix16& f)
-{
- return f.m;
-}
-
-inline double value(const Fix16& f)
-{
- return double(f);
-}
-
-inline Fix16 Fix16::operator+() const
-{
- return m;
-}
-
-inline Fix16 Fix16::operator-() const
-{
- return -m;
-}
-
-inline Fix16 operator+(const Fix16& f, const Fix16& g)
-{
- short sum = f.m + g.m;
- if ( (f.m ^ sum) & (g.m ^ sum) & Fix16_msb )
- f.overflow(sum);
- return sum;
-}
-
-inline Fix16 operator-(const Fix16& f, const Fix16& g)
-{
- short sum = f.m - g.m;
- if ( (f.m ^ sum) & (-g.m ^ sum) & Fix16_msb )
- f.overflow(sum);
- return sum;
-}
-
-inline Fix32 operator*(const Fix16& f, const Fix16& g)
-{
- return Fix32( _G_int32_t( _G_int32_t(f.m) * _G_int32_t(g.m) << 1));
-}
-
-inline Fix16 operator<<(const Fix16& a, int b)
-{
- return a.m << b;
-}
-
-inline Fix16 operator>>(const Fix16& a, int b)
-{
- return a.m >> b;
-}
-
-inline Fix16& Fix16:: operator+=(const Fix16& f)
-{
- return *this = *this + f;
-}
-
-inline Fix16& Fix16:: operator-=(const Fix16& f)
-{
- return *this = *this - f;
-}
-
-inline Fix16& Fix16::operator*=(const Fix16& f)
-{
- return *this = *this * f;
-}
-
-inline Fix16& Fix16:: operator/=(const Fix16& f)
-{
- return *this = *this / f;
-}
-
-inline Fix16& Fix16:: operator<<=(int b)
-{
- return *this = *this << b;
-}
-
-inline Fix16& Fix16:: operator>>=(int b)
-{
- return *this = *this >> b;
-}
-
-inline int operator==(const Fix16& f, const Fix16& g)
-{
- return f.m == g.m;
-}
-
-inline int operator!=(const Fix16& f, const Fix16& g)
-{
- return f.m != g.m;
-}
-
-inline int operator>=(const Fix16& f, const Fix16& g)
-{
- return f.m >= g.m;
-}
-
-inline int operator<=(const Fix16& f, const Fix16& g)
-{
- return f.m <= g.m;
-}
-
-inline int operator>(const Fix16& f, const Fix16& g)
-{
- return f.m > g.m;
-}
-
-inline int operator<(const Fix16& f, const Fix16& g)
-{
- return f.m < g.m;
-}
-
-inline istream& operator>>(istream& s, Fix16& f)
-{
- double d;
- s >> d;
- f = d;
- return s;
-}
-
-inline ostream& operator<<(ostream& s, const Fix16& f)
-{
- return s << double(f);
-}
-
-
-inline Fix16 operator*(const Fix16& f, int g)
-{
- return Fix16(short(f.m * g));
-}
-
-inline Fix16 operator*(int g, const Fix16& f)
-{
- return f * g;
-}
-
-
-inline Fix16& Fix16::operator*=(int g)
-{
- return *this = *this * g;
-}
-
-inline Fix32::~Fix32() {}
-
-inline _G_int32_t Fix32::round(double d)
-{
- return _G_int32_t( (d >= 0)? d + 0.5 : d - 0.5);
-}
-
-inline _G_int32_t& mantissa(Fix32& f)
-{
- return f.m;
-}
-
-inline const _G_int32_t& mantissa(const Fix32& f)
-{
- return f.m;
-}
-
-inline double value(const Fix32& f)
-{
- return double(f);
-}
-
-inline Fix32 Fix32::operator+() const
-{
- return m;
-}
-
-inline Fix32 Fix32::operator-() const
-{
- return -m;
-}
-
-inline Fix32 operator+(const Fix32& f, const Fix32& g)
-{
- _G_int32_t sum = f.m + g.m;
- if ( (f.m ^ sum) & (g.m ^ sum) & Fix32_msb )
- f.overflow(sum);
- return sum;
-}
-
-inline Fix32 operator-(const Fix32& f, const Fix32& g)
-{
- _G_int32_t sum = f.m - g.m;
- if ( (f.m ^ sum) & (-g.m ^ sum) & Fix32_msb )
- f.overflow(sum);
- return sum;
-}
-
-inline Fix32 operator<<(const Fix32& a, int b)
-{
- return a.m << b;
-}
-
-inline Fix32 operator>>(const Fix32& a, int b)
-{
- return a.m >> b;
-}
-
-inline Fix32& Fix32::operator+=(const Fix32& f)
-{
- return *this = *this + f;
-}
-
-inline Fix32& Fix32::operator-=(const Fix32& f)
-{
- return *this = *this - f;
-}
-
-inline Fix32& Fix32::operator*=(const Fix32& f)
-{
- return *this = *this * f;
-}
-
-inline Fix32& Fix32::operator/=(const Fix32& f)
-{
- return *this = *this / f;
-}
-
-
-inline Fix32& Fix32::operator<<=(int b)
-{
- return *this = *this << b;
-}
-
-inline Fix32& Fix32::operator>>=(int b)
-{
- return *this = *this >> b;
-}
-
-inline int operator==(const Fix32& f, const Fix32& g)
-{
- return f.m == g.m;
-}
-
-inline int operator!=(const Fix32& f, const Fix32& g)
-{
- return f.m != g.m;
-}
-
-inline int operator>=(const Fix32& f, const Fix32& g)
-{
- return f.m >= g.m;
-}
-
-inline int operator<=(const Fix32& f, const Fix32& g)
-{
- return f.m <= g.m;
-}
-
-inline int operator>(const Fix32& f, const Fix32& g)
-{
- return f.m > g.m;
-}
-
-inline int operator<(const Fix32& f, const Fix32& g)
-{
- return f.m < g.m;
-}
-
-inline istream& operator>>(istream& s, Fix32& f)
-{
- double d;
- s >> d;
- f = d;
- return s;
-}
-
-inline ostream& operator<<(ostream& s, const Fix32& f)
-{
- return s << double(f);
-}
-
-inline Fix32 operator*(const Fix32& f, int g)
-{
- return Fix32(_G_int32_t(f.m * g));
-}
-
-inline Fix32 operator*(int g, const Fix32& f)
-{
- return f * g;
-}
-
-
-
-inline Fix32& Fix32::operator*=(int g)
-{
- return *this = *this * g;
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Fix24.h b/gnu/lib/libg++/include/Fix24.h
deleted file mode 100644
index 0f4daea..0000000
--- a/gnu/lib/libg++/include/Fix24.h
+++ /dev/null
@@ -1,597 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu)
- adapted for libg++ by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _Fix24_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Fix24_h 1
-
-#include <stream.h>
-#include <std.h>
-
-// extra type definitions
-
-typedef struct {
- _G_int32_t u;
- _G_uint32_t l;
-} twolongs;
-
-// constant definitions
-
-static const int
- Fix24_shift = 31;
-
-static const double
- Fix24_fs = 2147483648., // 2^Fix24_shift
- Fix24_mult = Fix24_fs,
- Fix24_div = 1./Fix24_fs,
- Fix24_max = 1. - .5/Fix24_fs,
- Fix24_min = -1.;
-
-static const _G_uint32_t
- Fix24_msb = 0x80000000L,
- Fix24_lsb = 0x00000100L,
- Fix24_m_max = 0x7fffff00L,
- Fix24_m_min = 0x80000000L;
-
-static const double
- Fix48_fs = 36028797018963968., // 2^(24+Fix24_shift)
- Fix48_max = 1. - .5/Fix48_fs,
- Fix48_min = -1.,
- Fix48_div_u = 1./Fix24_fs,
- Fix48_div_l = 1./Fix48_fs;
-
-static const twolongs
- Fix48_msb = { 0x80000000L, 0L },
- Fix48_lsb = { 0L, 0x00000100L },
- Fix48_m_max = { 0x7fffff00L, 0xffffff00L },
- Fix48_m_min = { 0x80000000L, 0L };
-
-//
-// Fix24 class: 24-bit Fixed point data type
-//
-// consists of a 24-bit mantissa (sign bit & 23 data bits).
-//
-
-class Fix24
-{
- friend class Fix48;
-
- _G_int32_t m;
-
- _G_int32_t assign(double d);
- operator double() const;
- Fix24(long i);
- Fix24(int i);
-
-
-public:
- Fix24();
- Fix24(const Fix24& f);
- Fix24(double d);
- Fix24(const Fix48& f);
-
- ~Fix24();
-
- Fix24& operator=(const Fix24& f);
- Fix24& operator=(double d);
- Fix24& operator=(const Fix48& f);
-
- friend _G_int32_t& mantissa(Fix24& f);
- friend const _G_int32_t& mantissa(const Fix24& f);
- friend double value(const Fix24& f);
-
- Fix24 operator + () const;
- Fix24 operator - () const;
-
- friend Fix24 operator + (const Fix24& f, const Fix24& g);
- friend Fix24 operator - (const Fix24& f, const Fix24& g);
- friend Fix48 operator * (const Fix24& f, const Fix24& g);
- friend Fix24 operator * (const Fix24& f, int g);
- friend Fix24 operator * (int g, const Fix24& f);
- friend Fix24 operator / (const Fix24& f, const Fix24& g);
- friend Fix24 operator << (const Fix24& f, int b);
- friend Fix24 operator >> (const Fix24& f, int b);
-
- Fix24& operator += (const Fix24& f);
- Fix24& operator -= (const Fix24& f);
- Fix24& operator *= (const Fix24& f);
- Fix24& operator *= (int b);
- Fix24& operator /= (const Fix24& f);
-
- Fix24& operator <<=(int b);
- Fix24& operator >>=(int b);
-
- friend int operator == (const Fix24& f, const Fix24& g);
- friend int operator != (const Fix24& f, const Fix24& g);
- friend int operator >= (const Fix24& f, const Fix24& g);
- friend int operator <= (const Fix24& f, const Fix24& g);
- friend int operator > (const Fix24& f, const Fix24& g);
- friend int operator < (const Fix24& f, const Fix24& g);
-
- friend istream& operator >> (istream& s, Fix24& f);
- friend ostream& operator << (ostream& s, const Fix24& f);
-
- void overflow(_G_int32_t&) const;
- void range_error(_G_int32_t&) const;
-};
-
-
-//
-// Fix48 class: 48-bit Fixed point data type
-//
-// consists of a 48-bit mantissa (sign bit & 47 data bits).
-//
-
-class Fix48
-{
- friend class Fix24;
-
- twolongs m;
-
- twolongs assign(double d);
- operator double() const;
- Fix48(twolongs i);
-
-public:
- Fix48();
- Fix48(const Fix48& f);
- Fix48(const Fix24& f);
- Fix48(double d);
- ~Fix48();
-
- Fix48& operator = (const Fix48& f);
- Fix48& operator = (const Fix24& f);
- Fix48& operator = (double d);
-
- friend twolongs& mantissa(Fix48& f);
- friend const twolongs& mantissa(const Fix48& f);
- friend double value(const Fix48& f);
-
- Fix48 operator + () const;
- Fix48 operator - () const;
-
- friend Fix48 operator + (const Fix48& f, const Fix48& g);
- friend Fix48 operator - (const Fix48& f, const Fix48& g);
- friend Fix48 operator * (const Fix48& f, int g);
- friend Fix48 operator * (int g, const Fix48& f);
- friend Fix48 operator << (const Fix48& f, int b);
- friend Fix48 operator >> (const Fix48& f, int b);
-
- friend Fix48 operator * (const Fix24& f, const Fix24& g);
-
- Fix48& operator += (const Fix48& f);
- Fix48& operator -= (const Fix48& f);
- Fix48& operator *= (int b);
- Fix48& operator <<=(int b);
- Fix48& operator >>=(int b);
-
- friend int operator == (const Fix48& f, const Fix48& g);
- friend int operator != (const Fix48& f, const Fix48& g);
- friend int operator >= (const Fix48& f, const Fix48& g);
- friend int operator <= (const Fix48& f, const Fix48& g);
- friend int operator > (const Fix48& f, const Fix48& g);
- friend int operator < (const Fix48& f, const Fix48& g);
-
- friend istream& operator >> (istream& s, Fix48& f);
- friend ostream& operator << (ostream& s, const Fix48& f);
-
- void overflow(twolongs& i) const;
- void range_error(twolongs& i) const;
-};
-
-
-// active error handler declarations
-
-typedef void (*Fix24_peh)(_G_int32_t&);
-typedef void (*Fix48_peh)(twolongs&);
-
-extern Fix24_peh Fix24_overflow_handler;
-extern Fix48_peh Fix48_overflow_handler;
-
-extern Fix24_peh Fix24_range_error_handler;
-extern Fix48_peh Fix48_range_error_handler;
-
-
-// error handler declarations
-
-#if defined(SHORT_NAMES) || defined(VMS)
-#define set_overflow_handler sohndl
-#define set_range_error_handler srnghdl
-#endif
-
-extern Fix24_peh set_Fix24_overflow_handler(Fix24_peh);
-extern Fix48_peh set_Fix48_overflow_handler(Fix48_peh);
-extern void set_overflow_handler(Fix24_peh, Fix48_peh);
-
-extern Fix24_peh set_Fix24_range_error_handler(Fix24_peh);
-extern Fix48_peh set_Fix48_range_error_handler(Fix48_peh);
-extern void set_range_error_handler(Fix24_peh, Fix48_peh);
-
-extern void
- Fix24_ignore(_G_int32_t&),
- Fix24_overflow_saturate(_G_int32_t&),
- Fix24_overflow_warning_saturate(_G_int32_t&),
- Fix24_warning(_G_int32_t&),
- Fix24_abort(_G_int32_t&);
-
-extern void
- Fix48_ignore(twolongs&),
- Fix48_overflow_saturate(twolongs&),
- Fix48_overflow_warning_saturate(twolongs&),
- Fix48_warning(twolongs&),
- Fix48_abort(twolongs&);
-
-
-inline Fix24::~Fix24() {}
-
-inline Fix24::Fix24(long i)
-{
- m = i;
-}
-
-inline Fix24::Fix24(int i)
-{
- m = i;
-}
-
-inline Fix24::operator double() const
-{
- return Fix24_div * m;
-}
-
-inline Fix24::Fix24()
-{
- m = 0;
-}
-
-inline Fix24::Fix24(const Fix24& f)
-{
- m = f.m;
-}
-
-inline Fix24::Fix24(double d)
-{
- m = assign(d);
-}
-
-inline Fix24::Fix24(const Fix48& f)
-{
- m = f.m.u;
-}
-
-inline Fix24& Fix24::operator=(const Fix24& f)
-{
- m = f.m;
- return *this;
-}
-
-inline Fix24& Fix24::operator=(double d)
-{
- m = assign(d);
- return *this;
-}
-
-inline Fix24& Fix24::operator=(const Fix48& f)
-{
- m = f.m.u;
- return *this;
-}
-
-inline _G_int32_t& mantissa(Fix24& f)
-{
- return f.m;
-}
-
-inline const _G_int32_t& mantissa(const Fix24& f)
-{
- return f.m;
-}
-
-inline double value(const Fix24& f)
-{
- return double(f);
-}
-
-inline Fix24 Fix24::operator+() const
-{
- return m;
-}
-
-inline Fix24 Fix24::operator-() const
-{
- return -m;
-}
-
-inline Fix24 operator+(const Fix24& f, const Fix24& g)
-{
- _G_int32_t sum = f.m + g.m;
- if ( (f.m ^ sum) & (g.m ^ sum) & Fix24_msb )
- f.overflow(sum);
- return sum;
-}
-
-inline Fix24 operator-(const Fix24& f, const Fix24& g)
-{
- _G_int32_t sum = f.m - g.m;
- if ( (f.m ^ sum) & (-g.m ^ sum) & Fix24_msb )
- f.overflow(sum);
- return sum;
-}
-
-inline Fix24 operator*(const Fix24& a, int b)
-{
- return a.m * b;
-}
-
-inline Fix24 operator*(int b, const Fix24& a)
-{
- return a * b;
-}
-
-inline Fix24 operator<<(const Fix24& a, int b)
-{
- return a.m << b;
-}
-
-inline Fix24 operator>>(const Fix24& a, int b)
-{
- return (a.m >> b) & ~0xff;
-}
-
-inline Fix24& Fix24:: operator+=(const Fix24& f)
-{
- return *this = *this + f;
-}
-
-inline Fix24& Fix24:: operator-=(const Fix24& f)
-{
- return *this = *this - f;
-}
-
-inline Fix24& Fix24::operator*=(const Fix24& f)
-{
- return *this = *this * f;
-}
-
-inline Fix24& Fix24:: operator/=(const Fix24& f)
-{
- return *this = *this / f;
-}
-
-inline Fix24& Fix24:: operator<<=(int b)
-{
- return *this = *this << b;
-}
-
-inline Fix24& Fix24:: operator>>=(int b)
-{
- return *this = *this >> b;
-}
-
-inline Fix24& Fix24::operator*=(int b)
-{
- return *this = *this * b;
-}
-
-inline int operator==(const Fix24& f, const Fix24& g)
-{
- return f.m == g.m;
-}
-
-inline int operator!=(const Fix24& f, const Fix24& g)
-{
- return f.m != g.m;
-}
-
-inline int operator>=(const Fix24& f, const Fix24& g)
-{
- return f.m >= g.m;
-}
-
-inline int operator<=(const Fix24& f, const Fix24& g)
-{
- return f.m <= g.m;
-}
-
-inline int operator>(const Fix24& f, const Fix24& g)
-{
- return f.m > g.m;
-}
-
-inline int operator<(const Fix24& f, const Fix24& g)
-{
- return f.m < g.m;
-}
-
-inline istream& operator>>(istream& s, Fix24& f)
-{
- double d;
- s >> d;
- f = d;
- return s;
-}
-
-inline ostream& operator<<(ostream& s, const Fix24& f)
-{
- return s << double(f);
-}
-
-inline Fix48::~Fix48() {}
-
-inline Fix48::Fix48(twolongs i)
-{
- m = i;
-}
-
-inline Fix48:: operator double() const
-{
-/*
- * Note: can't simply do Fix48_div_u * m.u + Fix48_div_l * m.l, because
- * m.u is signed and m.l is unsigned.
- */
- return (m.u >= 0)? Fix48_div_u * m.u + Fix48_div_l * m.l :
- (Fix48_div_u * ((_G_uint32_t)(m.u & 0xffffff00))
- + Fix48_div_l * m.l) - 2;
-}
-
-inline Fix48::Fix48()
-{
- m.u = 0;
- m.l = 0;
-}
-
-inline Fix48::Fix48(const Fix48& f)
-{
- m = f.m;
-}
-
-inline Fix48::Fix48(const Fix24& f)
-{
- m.u = f.m;
- m.l = 0;
-}
-
-inline Fix48::Fix48(double d)
-{
- m = assign(d);
-}
-
-inline Fix48& Fix48::operator=(const Fix48& f)
-{
- m = f.m;
- return *this;
-}
-
-inline Fix48& Fix48::operator=(const Fix24& f)
-{
- m.u = f.m;
- m.l = 0;
- return *this;
-}
-
-inline Fix48& Fix48::operator=(double d)
-{
- m = assign(d);
- return *this;
-}
-
-inline twolongs& mantissa(Fix48& f)
-{
- return f.m;
-}
-
-inline const twolongs& mantissa(const Fix48& f)
-{
- return f.m;
-}
-
-inline double value(const Fix48& f)
-{
- return double(f);
-}
-
-inline Fix48 Fix48::operator+() const
-{
- return m;
-}
-
-inline Fix48 Fix48::operator-() const
-{
- twolongs n;
- n.l = -m.l;
- n.u = ~m.u + ((n.l ^ m.l) & Fix24_msb ? 0 : Fix24_lsb);
- return Fix48(n);
-}
-
-inline Fix48 operator*(int b, const Fix48& a)
-{
- return a * b;
-}
-
-inline Fix48& Fix48::operator+=(const Fix48& f)
-{
- return *this = *this + f;
-}
-
-inline Fix48& Fix48::operator-=(const Fix48& f)
-{
- return *this = *this - f;
-}
-
-inline Fix48& Fix48::operator*=(int b)
-{
- return *this = *this * b;
-}
-
-inline Fix48& Fix48::operator<<=(int b)
-{
- return *this = *this << b;
-}
-
-inline Fix48& Fix48::operator>>=(int b)
-{
- return *this = *this >> b;
-}
-
-inline int operator==(const Fix48& f, const Fix48& g)
-{
- return f.m.u == g.m.u && f.m.l == g.m.l;
-}
-
-inline int operator!=(const Fix48& f, const Fix48& g)
-{
- return f.m.u != g.m.u || f.m.l != g.m.l;
-}
-
-inline int operator>=(const Fix48& f, const Fix48& g)
-{
- return f.m.u >= g.m.u || (f.m.u == g.m.u && f.m.l >= g.m.l);
-}
-
-inline int operator<=(const Fix48& f, const Fix48& g)
-{
- return f.m.u <= g.m.u || (f.m.u == g.m.u && f.m.l <= g.m.l);
-}
-
-inline int operator>(const Fix48& f, const Fix48& g)
-{
- return f.m.u > g.m.u || (f.m.u == g.m.u && f.m.l > g.m.l);
-}
-
-inline int operator<(const Fix48& f, const Fix48& g)
-{
- return f.m.u < g.m.u || (f.m.u == g.m.u && f.m.l < g.m.l);
-}
-
-inline istream& operator>>(istream& s, Fix48& f)
-{
- double d;
- s >> d;
- f = d;
- return s;
-}
-
-inline ostream& operator<<(ostream& s, const Fix48& f)
-{
- return s << double(f);
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Geom.h b/gnu/lib/libg++/include/Geom.h
deleted file mode 100644
index 7d05b83..0000000
--- a/gnu/lib/libg++/include/Geom.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _Geometric_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Geometric_h
-
-#include <Random.h>
-
-class Geometric: public Random {
-protected:
- double pMean;
-public:
- Geometric(double mean, RNG *gen);
-
- double mean();
- double mean(double x);
-
- virtual double operator()();
-
-};
-
-
-inline Geometric::Geometric(double mean, RNG *gen) : Random(gen)
-{
- pMean = mean;
-}
-
-
-inline double Geometric::mean() { return pMean; }
-inline double Geometric::mean(double x) {
- double tmp = pMean; pMean = x; return tmp;
-}
-
-
-#endif
diff --git a/gnu/lib/libg++/include/GetOpt.h b/gnu/lib/libg++/include/GetOpt.h
deleted file mode 100644
index 9dfc3c6..0000000
--- a/gnu/lib/libg++/include/GetOpt.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Getopt for GNU.
- Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
- (Modified by Douglas C. Schmidt for use with GNU G++.)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- to intersperse the options with the other arguments.
-
- As `getopt' works, it permutes the elements of `argv' so that,
- when it is done, all the options precede everything else. Thus
- all application programs are extended to handle flexible argument order.
-
- Setting the environment variable _POSIX_OPTION_ORDER disables permutation.
- Then the behavior is completely standard.
-
- GNU application programs can use a third alternative mode in which
- they can distinguish the relative order of options and other arguments. */
-
-#ifndef GetOpt_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define GetOpt_h 1
-
-#include <std.h>
-#include <stdio.h>
-
-class GetOpt
-{
-private:
- /* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
- static char *nextchar;
-
-
- /* Describe how to deal with options that follow non-option ARGV-elements.
-
- UNSPECIFIED means the caller did not specify anything;
- the default is then REQUIRE_ORDER if the environment variable
- _OPTIONS_FIRST is defined, PERMUTE otherwise.
-
- REQUIRE_ORDER means don't recognize them as options.
- Stop option processing when the first non-option is seen.
- This is what Unix does.
-
- PERMUTE is the default. We permute the contents of `argv' as we scan,
- so that eventually all the options are at the end. This allows options
- to be given in any order, even with programs that were not written to
- expect this.
-
- RETURN_IN_ORDER is an option available to programs that were written
- to expect options and other ARGV-elements in any order and that care about
- the ordering of the two. We describe each non-option ARGV-element
- as if it were the argument of an option with character code zero.
- Using `-' as the first character of the list of option characters
- requests this mode of operation.
-
- The special argument `--' forces an end of option-scanning regardless
- of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return EOF with `optind' != ARGC. */
-
- enum OrderingEnum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER };
- OrderingEnum ordering;
-
- /* Handle permutation of arguments. */
-
- /* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
- static int first_nonopt;
- static int last_nonopt;
-
- void exchange (char **argv);
-public:
- /* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
- char *optarg;
-
- /* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns EOF, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
- int optind;
-
- /* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
- int opterr;
-
- int nargc;
- char **nargv;
- const char *noptstring;
-
- GetOpt (int argc, char **argv, const char *optstring);
- int operator () (void);
-};
-
-#endif
diff --git a/gnu/lib/libg++/include/HypGeom.h b/gnu/lib/libg++/include/HypGeom.h
deleted file mode 100644
index 1864e91..0000000
--- a/gnu/lib/libg++/include/HypGeom.h
+++ /dev/null
@@ -1,70 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _HyperGeometric_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _HyperGeometric_h
-
-#include <Random.h>
-
-class HyperGeometric: public Random {
-protected:
- double pMean;
- double pVariance;
- double pP;
- void setState();
-
-public:
- HyperGeometric(double mean, double variance, RNG *gen);
-
- double mean();
- double mean(double x);
- double variance();
- double variance(double x);
-
- virtual double operator()();
-};
-
-
-inline void HyperGeometric::setState() {
- double z = pVariance / (pMean * pMean);
- pP = 0.5 * (1.0 - sqrt((z - 1.0) / ( z + 1.0 )));
-}
-
-inline HyperGeometric::HyperGeometric(double mean, double variance, RNG *gen)
-: Random(gen) {
- pMean = mean; pVariance = variance;
- setState();
-}
-
-inline double HyperGeometric::mean() { return pMean; };
-
-inline double HyperGeometric::mean(double x) {
- double t = pMean; pMean = x;
- setState(); return t;
-}
-
-inline double HyperGeometric::variance() { return pVariance; }
-
-inline double HyperGeometric::variance(double x) {
- double t = pVariance; pVariance = x;
- setState(); return t;
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Integer.h b/gnu/lib/libg++/include/Integer.h
deleted file mode 100644
index b5c1768..0000000
--- a/gnu/lib/libg++/include/Integer.h
+++ /dev/null
@@ -1,1119 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _Integer_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Integer_h 1
-
-#include <iostream.h>
-
-struct IntRep // internal Integer representations
-{
- unsigned short len; // current length
- unsigned short sz; // allocated space (0 means static).
- short sgn; // 1 means >= 0; 0 means < 0
- unsigned short s[1]; // represented as ushort array starting here
-};
-
-// True if REP is staticly (or manually) allocated,
-// and should not be deleted by an Integer destructor.
-#define STATIC_IntRep(rep) ((rep)->sz==0)
-
-extern IntRep* Ialloc(IntRep*, const unsigned short *, int, int, int);
-extern IntRep* Icalloc(IntRep*, int);
-extern IntRep* Icopy_ulong(IntRep*, unsigned long);
-extern IntRep* Icopy_long(IntRep*, long);
-extern IntRep* Icopy(IntRep*, const IntRep*);
-extern IntRep* Iresize(IntRep*, int);
-extern IntRep* add(const IntRep*, int, const IntRep*, int, IntRep*);
-extern IntRep* add(const IntRep*, int, long, IntRep*);
-extern IntRep* multiply(const IntRep*, const IntRep*, IntRep*);
-extern IntRep* multiply(const IntRep*, long, IntRep*);
-extern IntRep* lshift(const IntRep*, long, IntRep*);
-extern IntRep* lshift(const IntRep*, const IntRep*, int, IntRep*);
-extern IntRep* bitop(const IntRep*, const IntRep*, IntRep*, char);
-extern IntRep* bitop(const IntRep*, long, IntRep*, char);
-extern IntRep* power(const IntRep*, long, IntRep*);
-extern IntRep* div(const IntRep*, const IntRep*, IntRep*);
-extern IntRep* mod(const IntRep*, const IntRep*, IntRep*);
-extern IntRep* div(const IntRep*, long, IntRep*);
-extern IntRep* mod(const IntRep*, long, IntRep*);
-extern IntRep* compl(const IntRep*, IntRep*);
-extern IntRep* abs(const IntRep*, IntRep*);
-extern IntRep* negate(const IntRep*, IntRep*);
-extern IntRep* pow(const IntRep*, long);
-extern IntRep* gcd(const IntRep*, const IntRep* y);
-extern int compare(const IntRep*, const IntRep*);
-extern int compare(const IntRep*, long);
-extern int ucompare(const IntRep*, const IntRep*);
-extern int ucompare(const IntRep*, long);
-extern char* Itoa(const IntRep* x, int base = 10, int width = 0);
-extern char* cvtItoa(const IntRep* x, char* fmt, int& fmtlen, int base,
- int showbase, int width, int align_right,
- char fillchar, char Xcase, int showpos);
-extern IntRep* atoIntRep(const char* s, int base = 10);
-extern long Itolong(const IntRep*);
-extern int Iislong(const IntRep*);
-extern long lg(const IntRep*);
-
-extern IntRep _ZeroRep, _OneRep, _MinusOneRep;
-
-class Integer
-{
-protected:
- IntRep* rep;
-public:
- Integer();
- Integer(int);
- Integer(long);
- Integer(unsigned long);
- Integer(IntRep*);
- Integer(const Integer&);
-
- ~Integer();
- Integer& operator = (const Integer&);
- Integer& operator = (long);
-
-// unary operations to self
-
- Integer& operator ++ ();
- Integer& operator -- ();
- void negate(); // negate in-place
- void abs(); // absolute-value in-place
- void complement(); // bitwise complement in-place
-
-// assignment-based operations
-
- Integer& operator += (const Integer&);
- Integer& operator -= (const Integer&);
- Integer& operator *= (const Integer&);
- Integer& operator /= (const Integer&);
- Integer& operator %= (const Integer&);
- Integer& operator <<=(const Integer&);
- Integer& operator >>=(const Integer&);
- Integer& operator &= (const Integer&);
- Integer& operator |= (const Integer&);
- Integer& operator ^= (const Integer&);
-
- Integer& operator += (long);
- Integer& operator -= (long);
- Integer& operator *= (long);
- Integer& operator /= (long);
- Integer& operator %= (long);
- Integer& operator <<=(long);
- Integer& operator >>=(long);
- Integer& operator &= (long);
- Integer& operator |= (long);
- Integer& operator ^= (long);
-
-// (constructive binary operations are inlined below)
-
-#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
- friend Integer operator <? (const Integer& x, const Integer& y); // min
- friend Integer operator >? (const Integer& x, const Integer& y); // max
-#endif
-
-// builtin Integer functions that must be friends
-
- friend long lg (const Integer&); // floor log base 2 of abs(x)
- friend double ratio(const Integer& x, const Integer& y);
- // return x/y as a double
-
- friend Integer gcd(const Integer&, const Integer&);
- friend int even(const Integer&); // true if even
- friend int odd(const Integer&); // true if odd
- friend int sign(const Integer&); // returns -1, 0, +1
-
- friend void (setbit)(Integer& x, long b); // set b'th bit of x
- friend void clearbit(Integer& x, long b); // clear b'th bit
- friend int testbit(const Integer& x, long b); // return b'th bit
-
-// procedural versions of operators
-
- friend void abs(const Integer& x, Integer& dest);
- friend void negate(const Integer& x, Integer& dest);
- friend void complement(const Integer& x, Integer& dest);
-
- friend int compare(const Integer&, const Integer&);
- friend int ucompare(const Integer&, const Integer&);
- friend void add(const Integer& x, const Integer& y, Integer& dest);
- friend void sub(const Integer& x, const Integer& y, Integer& dest);
- friend void mul(const Integer& x, const Integer& y, Integer& dest);
- friend void div(const Integer& x, const Integer& y, Integer& dest);
- friend void mod(const Integer& x, const Integer& y, Integer& dest);
- friend void divide(const Integer& x, const Integer& y,
- Integer& q, Integer& r);
- friend void and(const Integer& x, const Integer& y, Integer& dest);
- friend void or(const Integer& x, const Integer& y, Integer& dest);
- friend void xor(const Integer& x, const Integer& y, Integer& dest);
- friend void lshift(const Integer& x, const Integer& y, Integer& dest);
- friend void rshift(const Integer& x, const Integer& y, Integer& dest);
- friend void pow(const Integer& x, const Integer& y, Integer& dest);
-
- friend int compare(const Integer&, long);
- friend int ucompare(const Integer&, long);
- friend void add(const Integer& x, long y, Integer& dest);
- friend void sub(const Integer& x, long y, Integer& dest);
- friend void mul(const Integer& x, long y, Integer& dest);
- friend void div(const Integer& x, long y, Integer& dest);
- friend void mod(const Integer& x, long y, Integer& dest);
- friend void divide(const Integer& x, long y, Integer& q, long& r);
- friend void and(const Integer& x, long y, Integer& dest);
- friend void or(const Integer& x, long y, Integer& dest);
- friend void xor(const Integer& x, long y, Integer& dest);
- friend void lshift(const Integer& x, long y, Integer& dest);
- friend void rshift(const Integer& x, long y, Integer& dest);
- friend void pow(const Integer& x, long y, Integer& dest);
-
- friend int compare(long, const Integer&);
- friend int ucompare(long, const Integer&);
- friend void add(long x, const Integer& y, Integer& dest);
- friend void sub(long x, const Integer& y, Integer& dest);
- friend void mul(long x, const Integer& y, Integer& dest);
- friend void and(long x, const Integer& y, Integer& dest);
- friend void or(long x, const Integer& y, Integer& dest);
- friend void xor(long x, const Integer& y, Integer& dest);
-
-// coercion & conversion
-
- int fits_in_long() const { return Iislong(rep); }
- int fits_in_double() const;
-
- long as_long() const { return Itolong(rep); }
- double as_double() const;
-
- friend char* Itoa(const Integer& x, int base = 10, int width = 0);
- friend Integer atoI(const char* s, int base = 10);
- void printon(ostream& s, int base = 10, int width = 0) const;
-
- friend istream& operator >> (istream& s, Integer& y);
- friend ostream& operator << (ostream& s, const Integer& y);
-
-// error detection
-
- int initialized() const;
- void error(const char* msg) const;
- int OK() const;
-};
-
-
-// (These are declared inline)
-
- int operator == (const Integer&, const Integer&);
- int operator == (const Integer&, long);
- int operator != (const Integer&, const Integer&);
- int operator != (const Integer&, long);
- int operator < (const Integer&, const Integer&);
- int operator < (const Integer&, long);
- int operator <= (const Integer&, const Integer&);
- int operator <= (const Integer&, long);
- int operator > (const Integer&, const Integer&);
- int operator > (const Integer&, long);
- int operator >= (const Integer&, const Integer&);
- int operator >= (const Integer&, long);
- Integer operator - (const Integer&);
- Integer operator ~ (const Integer&);
- Integer operator + (const Integer&, const Integer&);
- Integer operator + (const Integer&, long);
- Integer operator + (long, const Integer&);
- Integer operator - (const Integer&, const Integer&);
- Integer operator - (const Integer&, long);
- Integer operator - (long, const Integer&);
- Integer operator * (const Integer&, const Integer&);
- Integer operator * (const Integer&, long);
- Integer operator * (long, const Integer&);
- Integer operator / (const Integer&, const Integer&);
- Integer operator / (const Integer&, long);
- Integer operator % (const Integer&, const Integer&);
- Integer operator % (const Integer&, long);
- Integer operator << (const Integer&, const Integer&);
- Integer operator << (const Integer&, long);
- Integer operator >> (const Integer&, const Integer&);
- Integer operator >> (const Integer&, long);
- Integer operator & (const Integer&, const Integer&);
- Integer operator & (const Integer&, long);
- Integer operator & (long, const Integer&);
- Integer operator | (const Integer&, const Integer&);
- Integer operator | (const Integer&, long);
- Integer operator | (long, const Integer&);
- Integer operator ^ (const Integer&, const Integer&);
- Integer operator ^ (const Integer&, long);
- Integer operator ^ (long, const Integer&);
-
- Integer abs(const Integer&); // absolute value
- Integer sqr(const Integer&); // square
-
- Integer pow(const Integer& x, const Integer& y);
- Integer pow(const Integer& x, long y);
- Integer Ipow(long x, long y); // x to the y as Integer
-
-
-extern char* dec(const Integer& x, int width = 0);
-extern char* oct(const Integer& x, int width = 0);
-extern char* hex(const Integer& x, int width = 0);
-extern Integer sqrt(const Integer&); // floor of square root
-extern Integer lcm(const Integer& x, const Integer& y); // least common mult
-
-
-typedef Integer IntTmp; // for backward compatibility
-
-inline Integer::Integer() :rep(&_ZeroRep) {}
-
-inline Integer::Integer(IntRep* r) :rep(r) {}
-
-inline Integer::Integer(int y) :rep(Icopy_long(0, (long)y)) {}
-
-inline Integer::Integer(long y) :rep(Icopy_long(0, y)) {}
-
-inline Integer::Integer(unsigned long y) :rep(Icopy_ulong(0, y)) {}
-
-inline Integer::Integer(const Integer& y) :rep(Icopy(0, y.rep)) {}
-
-inline Integer::~Integer() { if (rep && !STATIC_IntRep(rep)) delete rep; }
-
-inline Integer& Integer::operator = (const Integer& y)
-{
- rep = Icopy(rep, y.rep);
- return *this;
-}
-
-inline Integer& Integer::operator = (long y)
-{
- rep = Icopy_long(rep, y);
- return *this;
-}
-
-inline int Integer::initialized() const
-{
- return rep != 0;
-}
-
-// procedural versions
-
-inline int compare(const Integer& x, const Integer& y)
-{
- return compare(x.rep, y.rep);
-}
-
-inline int ucompare(const Integer& x, const Integer& y)
-{
- return ucompare(x.rep, y.rep);
-}
-
-inline int compare(const Integer& x, long y)
-{
- return compare(x.rep, y);
-}
-
-inline int ucompare(const Integer& x, long y)
-{
- return ucompare(x.rep, y);
-}
-
-inline int compare(long x, const Integer& y)
-{
- return -compare(y.rep, x);
-}
-
-inline int ucompare(long x, const Integer& y)
-{
- return -ucompare(y.rep, x);
-}
-
-inline void add(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = add(x.rep, 0, y.rep, 0, dest.rep);
-}
-
-inline void sub(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = add(x.rep, 0, y.rep, 1, dest.rep);
-}
-
-inline void mul(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = multiply(x.rep, y.rep, dest.rep);
-}
-
-inline void div(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = div(x.rep, y.rep, dest.rep);
-}
-
-inline void mod(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = mod(x.rep, y.rep, dest.rep);
-}
-
-inline void and(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = bitop(x.rep, y.rep, dest.rep, '&');
-}
-
-inline void or(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = bitop(x.rep, y.rep, dest.rep, '|');
-}
-
-inline void xor(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = bitop(x.rep, y.rep, dest.rep, '^');
-}
-
-inline void lshift(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = lshift(x.rep, y.rep, 0, dest.rep);
-}
-
-inline void rshift(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = lshift(x.rep, y.rep, 1, dest.rep);
-}
-
-inline void pow(const Integer& x, const Integer& y, Integer& dest)
-{
- dest.rep = power(x.rep, Itolong(y.rep), dest.rep); // not incorrect
-}
-
-inline void add(const Integer& x, long y, Integer& dest)
-{
- dest.rep = add(x.rep, 0, y, dest.rep);
-}
-
-inline void sub(const Integer& x, long y, Integer& dest)
-{
- dest.rep = add(x.rep, 0, -y, dest.rep);
-}
-
-inline void mul(const Integer& x, long y, Integer& dest)
-{
- dest.rep = multiply(x.rep, y, dest.rep);
-}
-
-inline void div(const Integer& x, long y, Integer& dest)
-{
- dest.rep = div(x.rep, y, dest.rep);
-}
-
-inline void mod(const Integer& x, long y, Integer& dest)
-{
- dest.rep = mod(x.rep, y, dest.rep);
-}
-
-inline void and(const Integer& x, long y, Integer& dest)
-{
- dest.rep = bitop(x.rep, y, dest.rep, '&');
-}
-
-inline void or(const Integer& x, long y, Integer& dest)
-{
- dest.rep = bitop(x.rep, y, dest.rep, '|');
-}
-
-inline void xor(const Integer& x, long y, Integer& dest)
-{
- dest.rep = bitop(x.rep, y, dest.rep, '^');
-}
-
-inline void lshift(const Integer& x, long y, Integer& dest)
-{
- dest.rep = lshift(x.rep, y, dest.rep);
-}
-
-inline void rshift(const Integer& x, long y, Integer& dest)
-{
- dest.rep = lshift(x.rep, -y, dest.rep);
-}
-
-inline void pow(const Integer& x, long y, Integer& dest)
-{
- dest.rep = power(x.rep, y, dest.rep);
-}
-
-inline void abs(const Integer& x, Integer& dest)
-{
- dest.rep = abs(x.rep, dest.rep);
-}
-
-inline void negate(const Integer& x, Integer& dest)
-{
- dest.rep = negate(x.rep, dest.rep);
-}
-
-inline void complement(const Integer& x, Integer& dest)
-{
- dest.rep = compl(x.rep, dest.rep);
-}
-
-inline void add(long x, const Integer& y, Integer& dest)
-{
- dest.rep = add(y.rep, 0, x, dest.rep);
-}
-
-inline void sub(long x, const Integer& y, Integer& dest)
-{
- dest.rep = add(y.rep, 1, x, dest.rep);
-}
-
-inline void mul(long x, const Integer& y, Integer& dest)
-{
- dest.rep = multiply(y.rep, x, dest.rep);
-}
-
-inline void and(long x, const Integer& y, Integer& dest)
-{
- dest.rep = bitop(y.rep, x, dest.rep, '&');
-}
-
-inline void or(long x, const Integer& y, Integer& dest)
-{
- dest.rep = bitop(y.rep, x, dest.rep, '|');
-}
-
-inline void xor(long x, const Integer& y, Integer& dest)
-{
- dest.rep = bitop(y.rep, x, dest.rep, '^');
-}
-
-
-// operator versions
-
-inline int operator == (const Integer& x, const Integer& y)
-{
- return compare(x, y) == 0;
-}
-
-inline int operator == (const Integer& x, long y)
-{
- return compare(x, y) == 0;
-}
-
-inline int operator != (const Integer& x, const Integer& y)
-{
- return compare(x, y) != 0;
-}
-
-inline int operator != (const Integer& x, long y)
-{
- return compare(x, y) != 0;
-}
-
-inline int operator < (const Integer& x, const Integer& y)
-{
- return compare(x, y) < 0;
-}
-
-inline int operator < (const Integer& x, long y)
-{
- return compare(x, y) < 0;
-}
-
-inline int operator <= (const Integer& x, const Integer& y)
-{
- return compare(x, y) <= 0;
-}
-
-inline int operator <= (const Integer& x, long y)
-{
- return compare(x, y) <= 0;
-}
-
-inline int operator > (const Integer& x, const Integer& y)
-{
- return compare(x, y) > 0;
-}
-
-inline int operator > (const Integer& x, long y)
-{
- return compare(x, y) > 0;
-}
-
-inline int operator >= (const Integer& x, const Integer& y)
-{
- return compare(x, y) >= 0;
-}
-
-inline int operator >= (const Integer& x, long y)
-{
- return compare(x, y) >= 0;
-}
-
-
-inline Integer& Integer::operator += (const Integer& y)
-{
- add(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator += (long y)
-{
- add(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator ++ ()
-{
- add(*this, 1, *this);
- return *this;
-}
-
-
-inline Integer& Integer::operator -= (const Integer& y)
-{
- sub(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator -= (long y)
-{
- sub(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator -- ()
-{
- add(*this, -1, *this);
- return *this;
-}
-
-
-
-inline Integer& Integer::operator *= (const Integer& y)
-{
- mul(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator *= (long y)
-{
- mul(*this, y, *this);
- return *this;
-}
-
-
-inline Integer& Integer::operator &= (const Integer& y)
-{
- and(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator &= (long y)
-{
- and(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator |= (const Integer& y)
-{
- or(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator |= (long y)
-{
- or(*this, y, *this);
- return *this;
-}
-
-
-inline Integer& Integer::operator ^= (const Integer& y)
-{
- xor(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator ^= (long y)
-{
- xor(*this, y, *this);
- return *this;
-}
-
-
-
-inline Integer& Integer::operator /= (const Integer& y)
-{
- div(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator /= (long y)
-{
- div(*this, y, *this);
- return *this;
-}
-
-
-inline Integer& Integer::operator <<= (const Integer& y)
-{
- lshift(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator <<= (long y)
-{
- lshift(*this, y, *this);
- return *this;
-}
-
-
-inline Integer& Integer::operator >>= (const Integer& y)
-{
- rshift(*this, y, *this);
- return *this;
-}
-
-inline Integer& Integer::operator >>= (long y)
-{
- rshift(*this, y, *this);
- return *this;
-}
-
-#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
-inline Integer operator <? (const Integer& x, const Integer& y)
-{
- return (compare(x.rep, y.rep) <= 0) ? x : y;
-}
-
-inline Integer operator >? (const Integer& x, const Integer& y)
-{
- return (compare(x.rep, y.rep) >= 0)? x : y;
-}
-#endif
-
-
-inline void Integer::abs()
-{
- ::abs(*this, *this);
-}
-
-inline void Integer::negate()
-{
- ::negate(*this, *this);
-}
-
-
-inline void Integer::complement()
-{
- ::complement(*this, *this);
-}
-
-
-inline int sign(const Integer& x)
-{
- return (x.rep->len == 0) ? 0 : ( (x.rep->sgn == 1) ? 1 : -1 );
-}
-
-inline int even(const Integer& y)
-{
- return y.rep->len == 0 || !(y.rep->s[0] & 1);
-}
-
-inline int odd(const Integer& y)
-{
- return y.rep->len > 0 && (y.rep->s[0] & 1);
-}
-
-inline char* Itoa(const Integer& y, int base, int width)
-{
- return Itoa(y.rep, base, width);
-}
-
-
-
-inline long lg(const Integer& x)
-{
- return lg(x.rep);
-}
-
-// constructive operations
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-
-inline Integer operator + (const Integer& x, const Integer& y) return r
-{
- add(x, y, r);
-}
-
-inline Integer operator + (const Integer& x, long y) return r
-{
- add(x, y, r);
-}
-
-inline Integer operator + (long x, const Integer& y) return r
-{
- add(x, y, r);
-}
-
-inline Integer operator - (const Integer& x, const Integer& y) return r
-{
- sub(x, y, r);
-}
-
-inline Integer operator - (const Integer& x, long y) return r
-{
- sub(x, y, r);
-}
-
-inline Integer operator - (long x, const Integer& y) return r
-{
- sub(x, y, r);
-}
-
-inline Integer operator * (const Integer& x, const Integer& y) return r
-{
- mul(x, y, r);
-}
-
-inline Integer operator * (const Integer& x, long y) return r
-{
- mul(x, y, r);
-}
-
-inline Integer operator * (long x, const Integer& y) return r
-{
- mul(x, y, r);
-}
-
-inline Integer sqr(const Integer& x) return r
-{
- mul(x, x, r);
-}
-
-inline Integer operator & (const Integer& x, const Integer& y) return r
-{
- and(x, y, r);
-}
-
-inline Integer operator & (const Integer& x, long y) return r
-{
- and(x, y, r);
-}
-
-inline Integer operator & (long x, const Integer& y) return r
-{
- and(x, y, r);
-}
-
-inline Integer operator | (const Integer& x, const Integer& y) return r
-{
- or(x, y, r);
-}
-
-inline Integer operator | (const Integer& x, long y) return r
-{
- or(x, y, r);
-}
-
-inline Integer operator | (long x, const Integer& y) return r
-{
- or(x, y, r);
-}
-
-inline Integer operator ^ (const Integer& x, const Integer& y) return r
-{
- xor(x, y, r);
-}
-
-inline Integer operator ^ (const Integer& x, long y) return r
-{
- xor(x, y, r);
-}
-
-inline Integer operator ^ (long x, const Integer& y) return r
-{
- xor(x, y, r);
-}
-
-inline Integer operator / (const Integer& x, const Integer& y) return r
-{
- div(x, y, r);
-}
-
-inline Integer operator / (const Integer& x, long y) return r
-{
- div(x, y, r);
-}
-
-inline Integer operator % (const Integer& x, const Integer& y) return r
-{
- mod(x, y, r);
-}
-
-inline Integer operator % (const Integer& x, long y) return r
-{
- mod(x, y, r);
-}
-
-inline Integer operator << (const Integer& x, const Integer& y) return r
-{
- lshift(x, y, r);
-}
-
-inline Integer operator << (const Integer& x, long y) return r
-{
- lshift(x, y, r);
-}
-
-inline Integer operator >> (const Integer& x, const Integer& y) return r;
-{
- rshift(x, y, r);
-}
-
-inline Integer operator >> (const Integer& x, long y) return r
-{
- rshift(x, y, r);
-}
-
-inline Integer pow(const Integer& x, long y) return r
-{
- pow(x, y, r);
-}
-
-inline Integer Ipow(long x, long y) return r(x)
-{
- pow(r, y, r);
-}
-
-inline Integer pow(const Integer& x, const Integer& y) return r
-{
- pow(x, y, r);
-}
-
-
-
-inline Integer abs(const Integer& x) return r
-{
- abs(x, r);
-}
-
-inline Integer operator - (const Integer& x) return r
-{
- negate(x, r);
-}
-
-inline Integer operator ~ (const Integer& x) return r
-{
- complement(x, r);
-}
-
-inline Integer atoI(const char* s, int base) return r
-{
- r.rep = atoIntRep(s, base);
-}
-
-inline Integer gcd(const Integer& x, const Integer& y) return r
-{
- r.rep = gcd(x.rep, y.rep);
-}
-
-#else /* NO_NRV */
-
-inline Integer operator + (const Integer& x, const Integer& y)
-{
- Integer r; add(x, y, r); return r;
-}
-
-inline Integer operator + (const Integer& x, long y)
-{
- Integer r; add(x, y, r); return r;
-}
-
-inline Integer operator + (long x, const Integer& y)
-{
- Integer r; add(x, y, r); return r;
-}
-
-inline Integer operator - (const Integer& x, const Integer& y)
-{
- Integer r; sub(x, y, r); return r;
-}
-
-inline Integer operator - (const Integer& x, long y)
-{
- Integer r; sub(x, y, r); return r;
-}
-
-inline Integer operator - (long x, const Integer& y)
-{
- Integer r; sub(x, y, r); return r;
-}
-
-inline Integer operator * (const Integer& x, const Integer& y)
-{
- Integer r; mul(x, y, r); return r;
-}
-
-inline Integer operator * (const Integer& x, long y)
-{
- Integer r; mul(x, y, r); return r;
-}
-
-inline Integer operator * (long x, const Integer& y)
-{
- Integer r; mul(x, y, r); return r;
-}
-
-inline Integer sqr(const Integer& x)
-{
- Integer r; mul(x, x, r); return r;
-}
-
-inline Integer operator & (const Integer& x, const Integer& y)
-{
- Integer r; and(x, y, r); return r;
-}
-
-inline Integer operator & (const Integer& x, long y)
-{
- Integer r; and(x, y, r); return r;
-}
-
-inline Integer operator & (long x, const Integer& y)
-{
- Integer r; and(x, y, r); return r;
-}
-
-inline Integer operator | (const Integer& x, const Integer& y)
-{
- Integer r; or(x, y, r); return r;
-}
-
-inline Integer operator | (const Integer& x, long y)
-{
- Integer r; or(x, y, r); return r;
-}
-
-inline Integer operator | (long x, const Integer& y)
-{
- Integer r; or(x, y, r); return r;
-}
-
-inline Integer operator ^ (const Integer& x, const Integer& y)
-{
- Integer r; xor(x, y, r); return r;
-}
-
-inline Integer operator ^ (const Integer& x, long y)
-{
- Integer r; xor(x, y, r); return r;
-}
-
-inline Integer operator ^ (long x, const Integer& y)
-{
- Integer r; xor(x, y, r); return r;
-}
-
-inline Integer operator / (const Integer& x, const Integer& y)
-{
- Integer r; div(x, y, r); return r;
-}
-
-inline Integer operator / (const Integer& x, long y)
-{
- Integer r; div(x, y, r); return r;
-}
-
-inline Integer operator % (const Integer& x, const Integer& y)
-{
- Integer r; mod(x, y, r); return r;
-}
-
-inline Integer operator % (const Integer& x, long y)
-{
- Integer r; mod(x, y, r); return r;
-}
-
-inline Integer operator << (const Integer& x, const Integer& y)
-{
- Integer r; lshift(x, y, r); return r;
-}
-
-inline Integer operator << (const Integer& x, long y)
-{
- Integer r; lshift(x, y, r); return r;
-}
-
-inline Integer operator >> (const Integer& x, const Integer& y)
-{
- Integer r; rshift(x, y, r); return r;
-}
-
-inline Integer operator >> (const Integer& x, long y)
-{
- Integer r; rshift(x, y, r); return r;
-}
-
-inline Integer pow(const Integer& x, long y)
-{
- Integer r; pow(x, y, r); return r;
-}
-
-inline Integer Ipow(long x, long y)
-{
- Integer r(x); pow(r, y, r); return r;
-}
-
-inline Integer pow(const Integer& x, const Integer& y)
-{
- Integer r; pow(x, y, r); return r;
-}
-
-
-
-inline Integer abs(const Integer& x)
-{
- Integer r; abs(x, r); return r;
-}
-
-inline Integer operator - (const Integer& x)
-{
- Integer r; negate(x, r); return r;
-}
-
-inline Integer operator ~ (const Integer& x)
-{
- Integer r; complement(x, r); return r;
-}
-
-inline Integer atoI(const char* s, int base)
-{
- Integer r; r.rep = atoIntRep(s, base); return r;
-}
-
-inline Integer gcd(const Integer& x, const Integer& y)
-{
- Integer r; r.rep = gcd(x.rep, y.rep); return r;
-}
-
-#endif /* NO_NRV */
-
-inline Integer& Integer::operator %= (const Integer& y)
-{
- *this = *this % y; // mod(*this, y, *this) doesn't work.
- return *this;
-}
-
-inline Integer& Integer::operator %= (long y)
-{
- *this = *this % y; // mod(*this, y, *this) doesn't work.
- return *this;
-}
-#endif /* !_Integer_h */
diff --git a/gnu/lib/libg++/include/Integer.hP b/gnu/lib/libg++/include/Integer.hP
deleted file mode 100644
index b8a8039..0000000
--- a/gnu/lib/libg++/include/Integer.hP
+++ /dev/null
@@ -1,30 +0,0 @@
-// Stuff used to implement the Integer class.
-// WARNING: Its internals WILL change!
-
-/*
- Sizes of shifts for multiple-precision arithmetic.
- These should not be changed unless Integer representation
- as unsigned shorts is changed in the implementation files.
-*/
-
-#define I_SHIFT (sizeof(short) * CHAR_BIT)
-#define I_RADIX ((unsigned long)(1L << I_SHIFT))
-#define I_MAXNUM ((unsigned long)((I_RADIX - 1)))
-#define I_MINNUM ((unsigned long)(I_RADIX >> 1))
-#define I_POSITIVE 1
-#define I_NEGATIVE 0
-
-/* All routines assume SHORT_PER_LONG > 1 */
-#define SHORT_PER_LONG ((unsigned)(((sizeof(long) + sizeof(short) - 1) / sizeof(short))))
-#define CHAR_PER_LONG ((unsigned)sizeof(long))
-
-/*
- minimum and maximum sizes for an IntRep
-*/
-
-#define MINIntRep_SIZE 16
-#define MAXIntRep_SIZE I_MAXNUM
-
-#ifndef MALLOC_MIN_OVERHEAD
-#define MALLOC_MIN_OVERHEAD 4
-#endif
diff --git a/gnu/lib/libg++/include/LogNorm.h b/gnu/lib/libg++/include/LogNorm.h
deleted file mode 100644
index b5c4b46..0000000
--- a/gnu/lib/libg++/include/LogNorm.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _LogNormal_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _LogNormal_h
-
-#include <Normal.h>
-
-class LogNormal: public Normal {
-protected:
- double logMean;
- double logVariance;
- void setState();
-public:
- LogNormal(double mean, double variance, RNG *gen);
- double mean();
- double mean(double x);
- double variance();
- double variance(double x);
- virtual double operator()();
-};
-
-
-inline void LogNormal::setState()
-{
- double m2 = logMean * logMean;
- pMean = log(m2 / sqrt(logVariance + m2) );
-// from ch@heike.informatik.uni-dortmund.de:
-// (was pVariance = log((sqrt(logVariance + m2)/m2 )); )
- pStdDev = sqrt(log((logVariance + m2)/m2 ));
-}
-
-inline LogNormal::LogNormal(double mean, double variance, RNG *gen)
- : Normal(mean, variance, gen)
-{
- logMean = mean;
- logVariance = variance;
- setState();
-}
-
-inline double LogNormal::mean() {
- return logMean;
-}
-
-inline double LogNormal::mean(double x)
-{
- double t=logMean; logMean = x; setState();
- return t;
-}
-
-inline double LogNormal::variance() {
- return logVariance;
-}
-
-inline double LogNormal::variance(double x)
-{
- double t=logVariance; logVariance = x; setState();
- return t;
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/MLCG.h b/gnu/lib/libg++/include/MLCG.h
deleted file mode 100644
index 9b288a7..0000000
--- a/gnu/lib/libg++/include/MLCG.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _MLCG_h
-#define _MLCG_h 1
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include <RNG.h>
-#include <math.h>
-
-//
-// Multiplicative Linear Conguential Generator
-//
-
-class MLCG : public RNG {
- _G_int32_t initialSeedOne;
- _G_int32_t initialSeedTwo;
- _G_int32_t seedOne;
- _G_int32_t seedTwo;
-
-protected:
-
-public:
- MLCG(_G_int32_t seed1 = 0, _G_int32_t seed2 = 1);
- //
- // Return a long-words word of random bits
- //
- virtual _G_uint32_t asLong();
- virtual void reset();
- _G_int32_t seed1();
- void seed1(_G_int32_t);
- _G_int32_t seed2();
- void seed2(_G_int32_t);
- void reseed(_G_int32_t, _G_int32_t);
-};
-
-inline _G_int32_t
-MLCG::seed1()
-{
- return(seedOne);
-}
-
-inline void
-MLCG::seed1(_G_int32_t s)
-{
- initialSeedOne = s;
- reset();
-}
-
-inline _G_int32_t
-MLCG::seed2()
-{
- return(seedTwo);
-}
-
-inline void
-MLCG::seed2(_G_int32_t s)
-{
- initialSeedTwo = s;
- reset();
-}
-
-inline void
-MLCG::reseed(_G_int32_t s1, _G_int32_t s2)
-{
- initialSeedOne = s1;
- initialSeedTwo = s2;
- reset();
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/NegExp.h b/gnu/lib/libg++/include/NegExp.h
deleted file mode 100644
index 041e083..0000000
--- a/gnu/lib/libg++/include/NegExp.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _NegativeExpntl_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _NegativeExpntl_h 1
-
-
-//
-// Negative Exponential Random Numbers
-//
-//
-
-#include <Random.h>
-
-class NegativeExpntl: public Random {
-protected:
- double pMean;
-public:
- NegativeExpntl(double xmean, RNG *gen);
- double mean();
- double mean(double x);
-
- virtual double operator()();
-};
-
-
-inline NegativeExpntl::NegativeExpntl(double xmean, RNG *gen)
-: Random(gen) {
- pMean = xmean;
-}
-
-inline double NegativeExpntl::mean() { return pMean; }
-inline double NegativeExpntl::mean(double x) {
- double t = pMean; pMean = x;
- return t;
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Normal.h b/gnu/lib/libg++/include/Normal.h
deleted file mode 100644
index ab80f2a..0000000
--- a/gnu/lib/libg++/include/Normal.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _Normal_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Normal_h
-
-#include <Random.h>
-
-class Normal: public Random {
- char haveCachedNormal;
- double cachedNormal;
-
-protected:
- double pMean;
- double pVariance;
- double pStdDev;
-
-public:
- Normal(double xmean, double xvariance, RNG *gen);
- double mean();
- double mean(double x);
- double variance();
- double variance(double x);
- virtual double operator()();
-};
-
-
-inline Normal::Normal(double xmean, double xvariance, RNG *gen)
-: Random(gen) {
- pMean = xmean;
- pVariance = xvariance;
- pStdDev = sqrt(pVariance);
- haveCachedNormal = 0;
-}
-
-inline double Normal::mean() { return pMean; };
-inline double Normal::mean(double x) {
- double t=pMean; pMean = x;
- return t;
-}
-
-inline double Normal::variance() { return pVariance; }
-inline double Normal::variance(double x) {
- double t=pVariance; pVariance = x;
- pStdDev = sqrt(pVariance);
- return t;
-};
-
-#endif
diff --git a/gnu/lib/libg++/include/Obstack.h b/gnu/lib/libg++/include/Obstack.h
deleted file mode 100644
index 6e353fb..0000000
--- a/gnu/lib/libg++/include/Obstack.h
+++ /dev/null
@@ -1,216 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-#ifndef _Obstack_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Obstack_h 1
-
-#include <std.h>
-
-class Obstack
-{
- struct _obstack_chunk
- {
- char* limit;
- _obstack_chunk* prev;
- char contents[4];
- };
-
-protected:
- long chunksize;
- _obstack_chunk* chunk;
- char* objectbase;
- char* nextfree;
- char* chunklimit;
- int alignmentmask;
-
- void _free(void* obj);
- void newchunk(int size);
-
-public:
- Obstack(int size = 4080, int alignment = 4); // 4080=4096-mallocslop
-
- ~Obstack();
-
- void* base();
- void* next_free();
- int alignment_mask();
- int chunk_size();
- int size();
- int room();
- int contains(void* p); // does Obstack hold pointer p?
-
- void grow(const void* data, int size);
- void grow(const void* data, int size, char terminator);
- void grow(const char* s);
- void grow(char c);
- void grow_fast(char c);
- void blank(int size);
- void blank_fast(int size);
-
- void* finish();
- void* finish(char terminator);
-
- void* copy(const void* data, int size);
- void* copy(const void* data, int size, char terminator);
- void* copy(const char* s);
- void* copy(char c);
- void* alloc(int size);
-
- void free(void* obj);
- void shrink(int size = 1); // suggested by ken@cs.rochester.edu
-
- int OK(); // rep invariant
-};
-
-
-inline Obstack::~Obstack()
-{
- _free(0);
-}
-
-inline void* Obstack::base()
-{
- return objectbase;
-}
-
-inline void* Obstack::next_free()
-{
- return nextfree;
-}
-
-inline int Obstack::alignment_mask()
-{
- return alignmentmask;
-}
-
-inline int Obstack::chunk_size()
-{
- return chunksize;
-}
-
-inline int Obstack::size()
-{
- return nextfree - objectbase;
-}
-
-inline int Obstack::room()
-{
- return chunklimit - nextfree;
-}
-
-inline void Obstack:: grow(const void* data, int size)
-{
- if (nextfree+size > chunklimit)
- newchunk(size);
- memcpy(nextfree, data, size);
- nextfree += size;
-}
-
-inline void Obstack:: grow(const void* data, int size, char terminator)
-{
- if (nextfree+size+1 > chunklimit)
- newchunk(size+1);
- memcpy(nextfree, data, size);
- nextfree += size;
- *(nextfree)++ = terminator;
-}
-
-inline void Obstack:: grow(const char* s)
-{
- grow((const void*)s, strlen(s), 0);
-}
-
-inline void Obstack:: grow(char c)
-{
- if (nextfree+1 > chunklimit)
- newchunk(1);
- *(nextfree)++ = c;
-}
-
-inline void Obstack:: blank(int size)
-{
- if (nextfree+size > chunklimit)
- newchunk(size);
- nextfree += size;
-}
-
-inline void* Obstack::finish(char terminator)
-{
- grow(terminator);
- return finish();
-}
-
-inline void* Obstack::copy(const void* data, int size)
-{
- grow (data, size);
- return finish();
-}
-
-inline void* Obstack::copy(const void* data, int size, char terminator)
-{
- grow(data, size, terminator);
- return finish();
-}
-
-inline void* Obstack::copy(const char* s)
-{
- grow((const void*)s, strlen(s), 0);
- return finish();
-}
-
-inline void* Obstack::copy(char c)
-{
- grow(c);
- return finish();
-}
-
-inline void* Obstack::alloc(int size)
-{
- blank(size);
- return finish();
-}
-
-inline void Obstack:: free(void* obj)
-{
- if (obj >= (void*)chunk && obj<(void*)chunklimit)
- nextfree = objectbase = (char *) obj;
- else
- _free(obj);
-}
-
-inline void Obstack:: grow_fast(char c)
-{
- *(nextfree)++ = c;
-}
-
-inline void Obstack:: blank_fast(int size)
-{
- nextfree += size;
-}
-
-inline void Obstack:: shrink(int size) // from ken@cs.rochester.edu
-{
- if (nextfree >= objectbase + size)
- nextfree -= size;
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Pix.h b/gnu/lib/libg++/include/Pix.h
deleted file mode 100644
index be90525..0000000
--- a/gnu/lib/libg++/include/Pix.h
+++ /dev/null
@@ -1,5 +0,0 @@
-
-#ifndef _Pix_h
-#define _Pix_h 1
-typedef void* Pix;
-#endif
diff --git a/gnu/lib/libg++/include/PlotFile.h b/gnu/lib/libg++/include/PlotFile.h
deleted file mode 100644
index 1a401cd..0000000
--- a/gnu/lib/libg++/include/PlotFile.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/*
- a very simple implementation of a class to output unix "plot"
- format plotter files. See corresponding unix man pages for
- more details.
-
- written by Doug Lea (dl@rocky.oswego.edu)
- converted to use iostream library by Per Bothner (bothner@cygnus.com)
-*/
-
-#ifndef _PlotFile_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _PlotFile_h
-
-#include <fstream.h>
-
-/*
- Some plot libraries have the `box' command to draw boxes. Some don't.
- `box' is included here via moves & lines to allow both possiblilties.
-*/
-
-
-class PlotFile : public ofstream
-{
-protected:
- PlotFile& cmd(char c);
- PlotFile& operator << (const int x);
- PlotFile& operator << (const char *s);
-
-public:
-
- PlotFile() : ofstream() { }
- PlotFile(int fd) : ofstream(fd) { }
- PlotFile(const char *name, int mode=ios::out, int prot=0664)
- : ofstream(name, mode, prot) { }
-
-// PlotFile& remove() { ofstream::remove(); return *this; }
-
-// int filedesc() { return ofstream::filedesc(); }
-// const char* name() { return File::name(); }
-// void setname(const char* newname) { File::setname(newname); }
-// int iocount() { return File::iocount(); }
-
- PlotFile& arc(const int xi, const int yi,
- const int x0, const int y0,
- const int x1, const int y1);
- PlotFile& box(const int x0, const int y0,
- const int x1, const int y1);
- PlotFile& circle(const int x, const int y, const int r);
- PlotFile& cont(const int xi, const int yi);
- PlotFile& dot(const int xi, const int yi, const int dx,
- int n, const int* pat);
- PlotFile& erase();
- PlotFile& label(const char* s);
- PlotFile& line(const int x0, const int y0,
- const int x1, const int y1);
- PlotFile& linemod(const char* s);
- PlotFile& move(const int xi, const int yi);
- PlotFile& point(const int xi, const int yi);
- PlotFile& space(const int x0, const int y0,
- const int x1, const int y1);
-};
-#endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/gnu/lib/libg++/include/Poisson.h b/gnu/lib/libg++/include/Poisson.h
deleted file mode 100644
index 895b072..0000000
--- a/gnu/lib/libg++/include/Poisson.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _Poisson_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Poisson_h
-
-#include <Random.h>
-
-class Poisson: public Random {
-protected:
- double pMean;
-public:
- Poisson(double mean, RNG *gen);
-
- double mean();
- double mean(double x);
-
- virtual double operator()();
-};
-
-
-inline Poisson::Poisson(double mean, RNG *gen)
-: Random(gen) {
- pMean = mean;
-}
-
-inline double Poisson::mean() { return pMean; }
-inline double Poisson::mean(double x) {
- double t = pMean;
- pMean = x;
- return t;
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/RNG.h b/gnu/lib/libg++/include/RNG.h
deleted file mode 100644
index 81b5e16..0000000
--- a/gnu/lib/libg++/include/RNG.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _RNG_h
-#define _RNG_h 1
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include <assert.h>
-#include <math.h>
-#include <_G_config.h>
-
-union PrivateRNGSingleType { // used to access floats as unsigneds
- float s;
- _G_uint32_t u;
-};
-
-union PrivateRNGDoubleType { // used to access doubles as unsigneds
- double d;
- _G_uint32_t u[2];
-};
-
-//
-// Base class for Random Number Generators. See ACG and MLCG for instances.
-//
-class RNG {
- static PrivateRNGSingleType singleMantissa; // mantissa bit vector
- static PrivateRNGDoubleType doubleMantissa; // mantissa bit vector
-public:
- RNG();
- //
- // Return a long-words word of random bits
- //
- virtual _G_uint32_t asLong() = 0;
- virtual void reset() = 0;
- //
- // Return random bits converted to either a float or a double
- //
- float asFloat();
- double asDouble();
-};
-
-#endif
diff --git a/gnu/lib/libg++/include/Random.h b/gnu/lib/libg++/include/Random.h
deleted file mode 100644
index e3e624a..0000000
--- a/gnu/lib/libg++/include/Random.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _Random_h
-#define _Random_h 1
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include <math.h>
-#include <RNG.h>
-
-class Random {
-protected:
- RNG *pGenerator;
-public:
- Random(RNG *generator);
- virtual double operator()() = 0;
-
- RNG *generator();
- void generator(RNG *p);
-};
-
-
-inline Random::Random(RNG *gen)
-{
- pGenerator = gen;
-}
-
-inline RNG *Random::generator()
-{
- return(pGenerator);
-}
-
-inline void Random::generator(RNG *p)
-{
- pGenerator = p;
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Rational.h b/gnu/lib/libg++/include/Rational.h
deleted file mode 100644
index 1f8b76b..0000000
--- a/gnu/lib/libg++/include/Rational.h
+++ /dev/null
@@ -1,288 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _Rational_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Rational_h 1
-
-#include <Integer.h>
-#include <math.h>
-
-class Rational
-{
-protected:
- Integer num;
- Integer den;
-
- void normalize();
-
-public:
- Rational();
- Rational(double);
- Rational(int n);
- Rational(long n);
- Rational(int n, int d);
- Rational(long n, long d);
- Rational(long n, unsigned long d);
- Rational(unsigned long n, long d);
- Rational(unsigned long n, unsigned long d);
- Rational(const Integer& n);
- Rational(const Integer& n, const Integer& d);
- Rational(const Rational&);
-
- ~Rational();
-
- Rational& operator = (const Rational& y);
-
- friend int operator == (const Rational& x, const Rational& y);
- friend int operator != (const Rational& x, const Rational& y);
- friend int operator < (const Rational& x, const Rational& y);
- friend int operator <= (const Rational& x, const Rational& y);
- friend int operator > (const Rational& x, const Rational& y);
- friend int operator >= (const Rational& x, const Rational& y);
-
- friend Rational operator + (const Rational& x, const Rational& y);
- friend Rational operator - (const Rational& x, const Rational& y);
- friend Rational operator * (const Rational& x, const Rational& y);
- friend Rational operator / (const Rational& x, const Rational& y);
-
- Rational& operator += (const Rational& y);
- Rational& operator -= (const Rational& y);
- Rational& operator *= (const Rational& y);
- Rational& operator /= (const Rational& y);
-
-#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
- friend Rational operator <? (const Rational& x, const Rational& y); // min
- friend Rational operator >? (const Rational& x, const Rational& y); // max
-#endif
-
- friend Rational operator - (const Rational& x);
-
-
-// builtin Rational functions
-
-
- void negate(); // x = -x
- void invert(); // x = 1/x
-
- friend int sign(const Rational& x); // -1, 0, or +1
- friend Rational abs(const Rational& x); // absolute value
- friend Rational sqr(const Rational& x); // square
- friend Rational pow(const Rational& x, long y);
- friend Rational pow(const Rational& x, const Integer& y);
- const Integer& numerator() const;
- const Integer& denominator() const;
-
-// coercion & conversion
-
- operator double() const;
- friend Integer floor(const Rational& x);
- friend Integer ceil(const Rational& x);
- friend Integer trunc(const Rational& x);
- friend Integer round(const Rational& x);
-
- friend istream& operator >> (istream& s, Rational& y);
- friend ostream& operator << (ostream& s, const Rational& y);
-
- int fits_in_float() const;
- int fits_in_double() const;
-
-// procedural versions of operators
-
- friend int compare(const Rational& x, const Rational& y);
- friend void add(const Rational& x, const Rational& y, Rational& dest);
- friend void sub(const Rational& x, const Rational& y, Rational& dest);
- friend void mul(const Rational& x, const Rational& y, Rational& dest);
- friend void div(const Rational& x, const Rational& y, Rational& dest);
-
-// error detection
-
- void error(const char* msg) const;
- int OK() const;
-
-};
-
-typedef Rational RatTmp; // backwards compatibility
-
-inline Rational::Rational() : num(&_ZeroRep), den(&_OneRep) {}
-inline Rational::~Rational() {}
-
-inline Rational::Rational(const Rational& y) :num(y.num), den(y.den) {}
-
-inline Rational::Rational(const Integer& n) :num(n), den(&_OneRep) {}
-
-inline Rational::Rational(const Integer& n, const Integer& d) :num(n),den(d)
-{
- normalize();
-}
-
-inline Rational::Rational(long n) :num(n), den(&_OneRep) { }
-
-inline Rational::Rational(int n) :num(n), den(&_OneRep) { }
-
-inline Rational::Rational(long n, long d) :num(n), den(d) { normalize(); }
-inline Rational::Rational(int n, int d) :num(n), den(d) { normalize(); }
-inline Rational::Rational(long n, unsigned long d) :num(n), den(d)
-{
- normalize();
-}
-inline Rational::Rational(unsigned long n, long d) :num(n), den(d)
-{
- normalize();
-}
-inline Rational::Rational(unsigned long n, unsigned long d) :num(n), den(d)
-{
- normalize();
-}
-
-inline Rational& Rational::operator = (const Rational& y)
-{
- num = y.num; den = y.den;
- return *this;
-}
-
-inline int operator == (const Rational& x, const Rational& y)
-{
- return compare(x.num, y.num) == 0 && compare(x.den, y.den) == 0;
-}
-
-inline int operator != (const Rational& x, const Rational& y)
-{
- return compare(x.num, y.num) != 0 || compare(x.den, y.den) != 0;
-}
-
-inline int operator < (const Rational& x, const Rational& y)
-{
- return compare(x, y) < 0;
-}
-
-inline int operator <= (const Rational& x, const Rational& y)
-{
- return compare(x, y) <= 0;
-}
-
-inline int operator > (const Rational& x, const Rational& y)
-{
- return compare(x, y) > 0;
-}
-
-inline int operator >= (const Rational& x, const Rational& y)
-{
- return compare(x, y) >= 0;
-}
-
-inline int sign(const Rational& x)
-{
- return sign(x.num);
-}
-
-inline void Rational::negate()
-{
- num.negate();
-}
-
-
-inline Rational& Rational::operator += (const Rational& y)
-{
- add(*this, y, *this);
- return *this;
-}
-
-inline Rational& Rational::operator -= (const Rational& y)
-{
- sub(*this, y, *this);
- return *this;
-}
-
-inline Rational& Rational::operator *= (const Rational& y)
-{
- mul(*this, y, *this);
- return *this;
-}
-
-inline Rational& Rational::operator /= (const Rational& y)
-{
- div(*this, y, *this);
- return *this;
-}
-
-inline const Integer& Rational::numerator() const { return num; }
-inline const Integer& Rational::denominator() const { return den; }
-inline Rational::operator double() const { return ratio(num, den); }
-
-#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
-inline Rational operator <? (const Rational& x, const Rational& y)
-{
- if (compare(x, y) <= 0) return x; else return y;
-}
-
-inline Rational operator >? (const Rational& x, const Rational& y)
-{
- if (compare(x, y) >= 0) return x; else return y;
-}
-#endif
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-
-inline Rational operator + (const Rational& x, const Rational& y) return r
-{
- add(x, y, r);
-}
-
-inline Rational operator - (const Rational& x, const Rational& y) return r
-{
- sub(x, y, r);
-}
-
-inline Rational operator * (const Rational& x, const Rational& y) return r
-{
- mul(x, y, r);
-}
-
-inline Rational operator / (const Rational& x, const Rational& y) return r
-{
- div(x, y, r);
-}
-
-#else /* NO_NRV */
-
-inline Rational operator + (const Rational& x, const Rational& y)
-{
- Rational r; add(x, y, r); return r;
-}
-
-inline Rational operator - (const Rational& x, const Rational& y)
-{
- Rational r; sub(x, y, r); return r;
-}
-
-inline Rational operator * (const Rational& x, const Rational& y)
-{
- Rational r; mul(x, y, r); return r;
-}
-
-inline Rational operator / (const Rational& x, const Rational& y)
-{
- Rational r; div(x, y, r); return r;
-}
-#endif
-
-#endif
diff --git a/gnu/lib/libg++/include/Regex.h b/gnu/lib/libg++/include/Regex.h
deleted file mode 100644
index adc1cea..0000000
--- a/gnu/lib/libg++/include/Regex.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-#ifndef _Regex_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Regex_h 1
-
-#if defined(SHORT_NAMES) || defined(VMS)
-#define re_compile_pattern recmppat
-#define re_pattern_buffer repatbuf
-#define re_registers reregs
-#endif
-
-struct re_pattern_buffer; // defined elsewhere
-struct re_registers;
-
-class Regex
-{
-private:
-
- Regex(const Regex&) {} // no X(X&)
- void operator = (const Regex&) {} // no assignment
-
-protected:
- re_pattern_buffer* buf;
- re_registers* reg;
-
-public:
- Regex(const char* t,
- int fast = 0,
- int bufsize = 40,
- const char* transtable = 0);
-
- ~Regex();
-
- int match(const char* s, int len, int pos = 0) const;
- int search(const char* s, int len,
- int& matchlen, int startpos = 0) const;
- int match_info(int& start, int& length, int nth = 0) const;
-
- int OK() const; // representation invariant
-};
-
-// some built in regular expressions
-
-extern const Regex RXwhite; // = "[ \n\t\r\v\f]+"
-extern const Regex RXint; // = "-?[0-9]+"
-extern const Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\|
- // \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)
- // \\([eE][---+]?[0-9]+\\)?"
-extern const Regex RXalpha; // = "[A-Za-z]+"
-extern const Regex RXlowercase; // = "[a-z]+"
-extern const Regex RXuppercase; // = "[A-Z]+"
-extern const Regex RXalphanum; // = "[0-9A-Za-z]+"
-extern const Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*"
-
-
-#endif
diff --git a/gnu/lib/libg++/include/RndInt.h b/gnu/lib/libg++/include/RndInt.h
deleted file mode 100644
index bf0f955..0000000
--- a/gnu/lib/libg++/include/RndInt.h
+++ /dev/null
@@ -1,175 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1990 Free Software Foundation
- adapted from a submission from John Reidl <riedl@cs.purdue.edu>
-
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY. No author or distributor
-accepts responsibility to anyone for the consequences of using it
-or for whether it serves any particular purpose or works at all,
-unless he says so in writing. Refer to the GNU CC General Public
-License for full details.
-
-Everyone is granted permission to copy, modify and redistribute
-GNU CC, but only under the conditions described in the
-GNU CC General Public License. A copy of this license is
-supposed to have been given to you along with GNU CC so you
-can know your rights and responsibilities. It should be in a
-file named COPYING. Among other things, the copyright notice
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _RandomInteger_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _RandomInteger_h 1
-
-// RandomInteger uses a random number generator to generate an integer
-// in a specified range. By default the range is 0..1. Since in my
-// experience random numbers are often needed for a wide variety of
-// ranges in the same program, this generator accepts a new low or high value
-// as an argument to the asLong and operator() methods to temporarily
-// override stored values
-
-#include <math.h>
-#include <RNG.h>
-
-class RandomInteger
-{
- protected:
- RNG *pGenerator;
- long pLow;
- long pHigh;
-
- long _asLong(long, long);
-
- public:
-
- RandomInteger(long low, long high, RNG *gen);
- RandomInteger(long high, RNG *gen);
- RandomInteger(RNG *gen);
-
-// read params
-
- long low() const;
- long high() const;
- RNG* generator() const;
-
-// change params
-
- long low(long x);
- long high(long x);
- RNG* generator(RNG *gen);
-
-// get a random number
-
- long asLong();
- long operator()(); // synonym for asLong
- int asInt(); // (possibly) truncate as int
-
-// override params for one shot
-
- long asLong(long high);
- long asLong(long low, long high);
-
- long operator () (long high); // synonyms
- long operator () (long low, long high);
-
-};
-
-
-inline RandomInteger::RandomInteger(long low, long high, RNG *gen)
- : pLow((low < high) ? low : high),
- pHigh((low < high) ? high : low),
- pGenerator(gen)
-{}
-
-inline RandomInteger::RandomInteger(long high, RNG *gen)
- : pLow((0 < high) ? 0 : high),
- pHigh((0 < high) ? high : 0),
- pGenerator(gen)
-{}
-
-
-inline RandomInteger::RandomInteger(RNG *gen)
- : pLow(0),
- pHigh(1),
- pGenerator(gen)
-{}
-
-inline RNG* RandomInteger::generator() const { return pGenerator;}
-inline long RandomInteger::low() const { return pLow; }
-inline long RandomInteger::high() const { return pHigh; }
-
-inline RNG* RandomInteger::generator(RNG *gen)
-{
- RNG *tmp = pGenerator; pGenerator = gen; return tmp;
-}
-
-inline long RandomInteger::low(long x)
-{
- long tmp = pLow; pLow = x; return tmp;
-}
-
-inline long RandomInteger:: high(long x)
-{
- long tmp = pHigh; pHigh = x; return tmp;
-}
-
-inline long RandomInteger:: _asLong(long low, long high)
-{
- return (pGenerator->asLong() % (high-low+1)) + low;
-}
-
-
-inline long RandomInteger:: asLong()
-{
- return _asLong(pLow, pHigh);
-}
-
-inline long RandomInteger:: asLong(long high)
-{
- return _asLong(pLow, high);
-}
-
-inline long RandomInteger:: asLong(long low, long high)
-{
- return _asLong(low, high);
-}
-
-inline long RandomInteger:: operator () ()
-{
- return _asLong(pLow, pHigh);
-}
-
-inline long RandomInteger:: operator () (long high)
-{
- return _asLong(pLow, high);
-}
-
-inline long RandomInteger:: operator () (long low, long high)
-{
- return _asLong(low, high);
-}
-
-
-
-
-inline int RandomInteger:: asInt()
-{
- return int(asLong());
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/SFile.h b/gnu/lib/libg++/include/SFile.h
deleted file mode 100644
index d4b4c71..0000000
--- a/gnu/lib/libg++/include/SFile.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1988, 1992, 1993 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#ifndef _SFile_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _SFile_h 1
-
-#include <fstream.h>
-
-class SFile: public fstream
-{
- protected:
- int sz; // unit size for structured binary IO
-
-public:
- SFile() : fstream() { }
- SFile(int fd, int size);
- SFile(const char *name, int size, int mode, int prot=0664);
- void open(const char *name, int size, int mode, int prot=0664);
-
- int size() { return sz; }
- int setsize(int s) { int old = sz; sz = s; return old; }
-
- SFile& get(void* x);
- SFile& put(void* x);
- SFile& operator[](long i);
-};
-
-#endif
diff --git a/gnu/lib/libg++/include/SLList.h b/gnu/lib/libg++/include/SLList.h
deleted file mode 100644
index 4be457f..0000000
--- a/gnu/lib/libg++/include/SLList.h
+++ /dev/null
@@ -1,124 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988, 1992 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _SLList_h
-#ifdef __GNUG__
-//#pragma interface
-#endif
-#define _SLList_h 1
-
-#include <Pix.h>
-
-struct BaseSLNode
-{
- BaseSLNode *tl;
- void *item() {return (void*)(this+1);} // Return ((SLNode<T>*)this)->hd
-};
-
-template<class T>
-class SLNode : public BaseSLNode
-{
- public:
- T hd; // Data part of node
- SLNode() { }
- SLNode(const T& h, SLNode* t = 0)
- : hd(h) { tl = t; }
- ~SLNode() { }
-};
-
-extern int __SLListLength(BaseSLNode *ptr);
-
-class BaseSLList {
- protected:
- BaseSLNode *last;
- virtual void delete_node(BaseSLNode*node) = 0;
- virtual BaseSLNode* copy_node(const void* datum) = 0;
- virtual void copy_item(void *dst, void *src) = 0;
- virtual ~BaseSLList() { }
- BaseSLList() { last = 0; }
- void copy(const BaseSLList&);
- BaseSLList& operator = (const BaseSLList& a);
- Pix ins_after(Pix p, const void *datum);
- Pix prepend(const void *datum);
- Pix append(const void *datum);
- int remove_front(void *dst, int signal_error = 0);
- void join(BaseSLList&);
- public:
- int length() const;
- int empty() const { return last == 0; }
- void clear();
- Pix prepend(BaseSLNode*);
- Pix append(BaseSLNode*);
- int OK() const;
- void error(const char* msg) const;
- void del_after(Pix p);
- int owns(Pix p) const;
- void del_front();
-};
-
-template <class T>
-class SLList : public BaseSLList
-{
- private:
- virtual void delete_node(BaseSLNode *node) { delete (SLNode<T>*)node; }
- virtual BaseSLNode* copy_node(const void *datum)
- { return new SLNode<T>(*(const T*)datum); }
- virtual void copy_item(void *dst, void *src) { *(T*)dst = *(T*)src; }
-
-public:
- SLList() : BaseSLList() { }
- SLList(const SLList<T>& a) : BaseSLList() { copy(a); }
- SLList<T>& operator = (const SLList<T>& a)
- { BaseSLList::operator=((const BaseSLList&) a); return *this; }
- virtual ~SLList() { clear(); }
-
- Pix prepend(const T& item) {return BaseSLList::prepend(&item);}
- Pix append(const T& item) {return BaseSLList::append(&item);}
- Pix prepend(SLNode<T>* node) {return BaseSLList::prepend(node);}
- Pix append(SLNode<T>* node) {return BaseSLList::append(node);}
-
- T& operator () (Pix p) {
- if (p == 0) error("null Pix");
- return ((SLNode<T>*)(p))->hd; }
- const T& operator () (Pix p) const {
- if (p == 0) error("null Pix");
- return ((SLNode<T>*)(p))->hd; }
- inline Pix first() const { return (last == 0) ? 0 : Pix(last->tl); }
- void next(Pix& p) const
- { p = (p == 0 || p == last) ? 0 : Pix(((SLNode<T>*)(p))->tl); }
- Pix ins_after(Pix p, const T& item)
- { return BaseSLList::ins_after(p, &item); }
- void join(SLList<T>& a) { BaseSLList::join(a); }
-
- T& front() {
- if (last == 0) error("front: empty list");
- return ((SLNode<T>*)last->tl)->hd; }
- T& rear() {
- if (last == 0) error("rear: empty list");
- return ((SLNode<T>*)last)->hd; }
- const T& front() const {
- if (last == 0) error("front: empty list");
- return ((SLNode<T>*)last->tl)->hd; }
- const T& rear() const {
- if (last == 0) error("rear: empty list");
- return ((SLNode<T>*)last)->hd; }
- int remove_front(T& x) { return BaseSLList::remove_front(&x); }
- T remove_front() { T dst; BaseSLList::remove_front(&dst, 1); return dst; }
-};
-
-#endif
diff --git a/gnu/lib/libg++/include/SmplHist.h b/gnu/lib/libg++/include/SmplHist.h
deleted file mode 100644
index 54614b9..0000000
--- a/gnu/lib/libg++/include/SmplHist.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef SampleHistogram_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define SampleHistogram_h 1
-
-#include <iostream.h>
-#include <SmplStat.h>
-
-extern const int SampleHistogramMinimum;
-extern const int SampleHistogramMaximum;
-
-class SampleHistogram : public SampleStatistic
-{
-protected:
- short howManyBuckets;
- int *bucketCount;
- double *bucketLimit;
-
-public:
-
- SampleHistogram(double low, double hi, double bucketWidth = -1.0);
-
- ~SampleHistogram();
-
- virtual void reset();
- virtual void operator+=(double);
-
- int similarSamples(double);
-
- int buckets();
-
- double bucketThreshold(int i);
- int inBucket(int i);
- void printBuckets(ostream&);
-
-};
-
-
-inline int SampleHistogram:: buckets() { return(howManyBuckets); };
-
-inline double SampleHistogram:: bucketThreshold(int i) {
- if (i < 0 || i >= howManyBuckets)
- error("invalid bucket access");
- return(bucketLimit[i]);
-}
-
-inline int SampleHistogram:: inBucket(int i) {
- if (i < 0 || i >= howManyBuckets)
- error("invalid bucket access");
- return(bucketCount[i]);
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/SmplStat.h b/gnu/lib/libg++/include/SmplStat.h
deleted file mode 100644
index 2ed5ab9..0000000
--- a/gnu/lib/libg++/include/SmplStat.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef SampleStatistic_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define SampleStatistic_h 1
-
-#include <builtin.h>
-
-class SampleStatistic {
-protected:
- int n;
- double x;
- double x2;
- double minValue, maxValue;
-
- public :
-
- SampleStatistic();
- virtual ~SampleStatistic();
- virtual void reset();
-
- virtual void operator+=(double);
- int samples();
- double mean();
- double stdDev();
- double var();
- double min();
- double max();
- double confidence(int p_percentage);
- double confidence(double p_value);
-
- void error(const char* msg);
-};
-
-// error handlers
-
-extern void default_SampleStatistic_error_handler(const char*);
-extern one_arg_error_handler_t SampleStatistic_error_handler;
-
-extern one_arg_error_handler_t
- set_SampleStatistic_error_handler(one_arg_error_handler_t f);
-
-inline SampleStatistic:: SampleStatistic(){ reset();}
-inline int SampleStatistic:: samples() {return(n);}
-inline double SampleStatistic:: min() {return(minValue);}
-inline double SampleStatistic:: max() {return(maxValue);}
-inline SampleStatistic::~SampleStatistic() {}
-
-#endif
diff --git a/gnu/lib/libg++/include/String.h b/gnu/lib/libg++/include/String.h
deleted file mode 100644
index 7a3d82b..0000000
--- a/gnu/lib/libg++/include/String.h
+++ /dev/null
@@ -1,1282 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-#ifndef _String_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _String_h 1
-
-#include <iostream.h>
-#include <Regex.h>
-
-struct StrRep // internal String representations
-{
- unsigned short len; // string length
- unsigned short sz; // allocated space
- char s[1]; // the string starts here
- // (at least 1 char for trailing null)
- // allocated & expanded via non-public fcts
-};
-
-// primitive ops on StrReps -- nearly all String fns go through these.
-
-StrRep* Salloc(StrRep*, const char*, int, int);
-StrRep* Scopy(StrRep*, const StrRep*);
-StrRep* Scat(StrRep*, const char*, int, const char*, int);
-StrRep* Scat(StrRep*, const char*, int,const char*,int, const char*,int);
-StrRep* Sprepend(StrRep*, const char*, int);
-StrRep* Sreverse(const StrRep*, StrRep*);
-StrRep* Supcase(const StrRep*, StrRep*);
-StrRep* Sdowncase(const StrRep*, StrRep*);
-StrRep* Scapitalize(const StrRep*, StrRep*);
-
-// These classes need to be defined in the order given
-
-class String;
-class SubString;
-
-class SubString
-{
- friend class String;
-protected:
-
- String& S; // The String I'm a substring of
- unsigned short pos; // starting position in S's rep
- unsigned short len; // length of substring
-
- void assign(const StrRep*, const char*, int = -1);
- SubString(String& x, int p, int l);
- SubString(const SubString& x);
-
-public:
-
-// Note there are no public constructors. SubStrings are always
-// created via String operations
-
- ~SubString();
-
- SubString& operator = (const String& y);
- SubString& operator = (const SubString& y);
- SubString& operator = (const char* t);
- SubString& operator = (char c);
-
-// return 1 if target appears anywhere in SubString; else 0
-
- int contains(char c) const;
- int contains(const String& y) const;
- int contains(const SubString& y) const;
- int contains(const char* t) const;
- int contains(const Regex& r) const;
-
-// return 1 if target matches entire SubString
-
- int matches(const Regex& r) const;
-
-// IO
-
- friend ostream& operator<<(ostream& s, const SubString& x);
-
-// status
-
- unsigned int length() const;
- int empty() const;
- const char* chars() const;
-
- int OK() const;
-
-};
-
-
-class String
-{
- friend class SubString;
-
-protected:
- StrRep* rep; // Strings are pointers to their representations
-
-// some helper functions
-
- int search(int, int, const char*, int = -1) const;
- int search(int, int, char) const;
- int match(int, int, int, const char*, int = -1) const;
- int _gsub(const char*, int, const char* ,int);
- int _gsub(const Regex&, const char*, int);
- SubString _substr(int, int);
-
-public:
-
-// constructors & assignment
-
- String();
- String(const String& x);
- String(const SubString& x);
- String(const char* t);
- String(const char* t, int len);
- String(char c);
-
- ~String();
-
- String& operator = (const String& y);
- String& operator = (const char* y);
- String& operator = (char c);
- String& operator = (const SubString& y);
-
-// concatenation
-
- String& operator += (const String& y);
- String& operator += (const SubString& y);
- String& operator += (const char* t);
- String& operator += (char c);
-
- void prepend(const String& y);
- void prepend(const SubString& y);
- void prepend(const char* t);
- void prepend(char c);
-
-
-// procedural versions:
-// concatenate first 2 args, store result in last arg
-
- friend inline void cat(const String&, const String&, String&);
- friend inline void cat(const String&, const SubString&, String&);
- friend inline void cat(const String&, const char*, String&);
- friend inline void cat(const String&, char, String&);
-
- friend inline void cat(const SubString&, const String&, String&);
- friend inline void cat(const SubString&, const SubString&, String&);
- friend inline void cat(const SubString&, const char*, String&);
- friend inline void cat(const SubString&, char, String&);
-
- friend inline void cat(const char*, const String&, String&);
- friend inline void cat(const char*, const SubString&, String&);
- friend inline void cat(const char*, const char*, String&);
- friend inline void cat(const char*, char, String&);
-
-// double concatenation, by request. (yes, there are too many versions,
-// but if one is supported, then the others should be too...)
-// Concatenate first 3 args, store in last arg
-
- friend inline void cat(const String&,const String&, const String&,String&);
- friend inline void cat(const String&,const String&,const SubString&,String&);
- friend inline void cat(const String&,const String&, const char*, String&);
- friend inline void cat(const String&,const String&, char, String&);
- friend inline void cat(const String&,const SubString&,const String&,String&);
- inline friend void cat(const String&,const SubString&,const SubString&,String&);
- friend inline void cat(const String&,const SubString&, const char*, String&);
- friend inline void cat(const String&,const SubString&, char, String&);
- friend inline void cat(const String&,const char*, const String&, String&);
- friend inline void cat(const String&,const char*, const SubString&, String&);
- friend inline void cat(const String&,const char*, const char*, String&);
- friend inline void cat(const String&,const char*, char, String&);
-
- friend inline void cat(const char*, const String&, const String&,String&);
- friend inline void cat(const char*,const String&,const SubString&,String&);
- friend inline void cat(const char*,const String&, const char*, String&);
- friend inline void cat(const char*,const String&, char, String&);
- friend inline void cat(const char*,const SubString&,const String&,String&);
- friend inline void cat(const char*,const SubString&,const SubString&,String&);
- friend inline void cat(const char*,const SubString&, const char*, String&);
- friend inline void cat(const char*,const SubString&, char, String&);
- friend inline void cat(const char*,const char*, const String&, String&);
- friend inline void cat(const char*,const char*, const SubString&, String&);
- friend inline void cat(const char*,const char*, const char*, String&);
- friend inline void cat(const char*,const char*, char, String&);
-
-
-// searching & matching
-
-// return position of target in string or -1 for failure
-
- int index(char c, int startpos = 0) const;
- int index(const String& y, int startpos = 0) const;
- int index(const SubString& y, int startpos = 0) const;
- int index(const char* t, int startpos = 0) const;
- int index(const Regex& r, int startpos = 0) const;
-
-// return 1 if target appears anyhere in String; else 0
-
- int contains(char c) const;
- int contains(const String& y) const;
- int contains(const SubString& y) const;
- int contains(const char* t) const;
- int contains(const Regex& r) const;
-
-// return 1 if target appears anywhere after position pos
-// (or before, if pos is negative) in String; else 0
-
- int contains(char c, int pos) const;
- int contains(const String& y, int pos) const;
- int contains(const SubString& y, int pos) const;
- int contains(const char* t, int pos) const;
- int contains(const Regex& r, int pos) const;
-
-// return 1 if target appears at position pos in String; else 0
-
- int matches(char c, int pos = 0) const;
- int matches(const String& y, int pos = 0) const;
- int matches(const SubString& y, int pos = 0) const;
- int matches(const char* t, int pos = 0) const;
- int matches(const Regex& r, int pos = 0) const;
-
-// return number of occurences of target in String
-
- int freq(char c) const;
- int freq(const String& y) const;
- int freq(const SubString& y) const;
- int freq(const char* t) const;
-
-// SubString extraction
-
-// Note that you can't take a substring of a const String, since
-// this leaves open the possiblility of indirectly modifying the
-// String through the SubString
-
- SubString at(int pos, int len);
- SubString operator () (int pos, int len); // synonym for at
-
- SubString at(const String& x, int startpos = 0);
- SubString at(const SubString& x, int startpos = 0);
- SubString at(const char* t, int startpos = 0);
- SubString at(char c, int startpos = 0);
- SubString at(const Regex& r, int startpos = 0);
-
- SubString before(int pos);
- SubString before(const String& x, int startpos = 0);
- SubString before(const SubString& x, int startpos = 0);
- SubString before(const char* t, int startpos = 0);
- SubString before(char c, int startpos = 0);
- SubString before(const Regex& r, int startpos = 0);
-
- SubString through(int pos);
- SubString through(const String& x, int startpos = 0);
- SubString through(const SubString& x, int startpos = 0);
- SubString through(const char* t, int startpos = 0);
- SubString through(char c, int startpos = 0);
- SubString through(const Regex& r, int startpos = 0);
-
- SubString from(int pos);
- SubString from(const String& x, int startpos = 0);
- SubString from(const SubString& x, int startpos = 0);
- SubString from(const char* t, int startpos = 0);
- SubString from(char c, int startpos = 0);
- SubString from(const Regex& r, int startpos = 0);
-
- SubString after(int pos);
- SubString after(const String& x, int startpos = 0);
- SubString after(const SubString& x, int startpos = 0);
- SubString after(const char* t, int startpos = 0);
- SubString after(char c, int startpos = 0);
- SubString after(const Regex& r, int startpos = 0);
-
-
-// deletion
-
-// delete len chars starting at pos
- void del(int pos, int len);
-
-// delete the first occurrence of target after startpos
-
- void del(const String& y, int startpos = 0);
- void del(const SubString& y, int startpos = 0);
- void del(const char* t, int startpos = 0);
- void del(char c, int startpos = 0);
- void del(const Regex& r, int startpos = 0);
-
-// global substitution: substitute all occurrences of pat with repl
-
- int gsub(const String& pat, const String& repl);
- int gsub(const SubString& pat, const String& repl);
- int gsub(const char* pat, const String& repl);
- int gsub(const char* pat, const char* repl);
- int gsub(const Regex& pat, const String& repl);
-
-// friends & utilities
-
-// split string into array res at separators; return number of elements
-
- friend int split(const String& x, String res[], int maxn,
- const String& sep);
- friend int split(const String& x, String res[], int maxn,
- const Regex& sep);
-
- friend String common_prefix(const String& x, const String& y,
- int startpos = 0);
- friend String common_suffix(const String& x, const String& y,
- int startpos = -1);
- friend String replicate(char c, int n);
- friend String replicate(const String& y, int n);
- friend String join(String src[], int n, const String& sep);
-
-// simple builtin transformations
-
- friend inline String reverse(const String& x);
- friend inline String upcase(const String& x);
- friend inline String downcase(const String& x);
- friend inline String capitalize(const String& x);
-
-// in-place versions of above
-
- void reverse();
- void upcase();
- void downcase();
- void capitalize();
-
-// element extraction
-
- char& operator [] (int i);
- const char& operator [] (int i) const;
- char elem(int i) const;
- char firstchar() const;
- char lastchar() const;
-
-// conversion
-
- operator const char*() const;
- const char* chars() const;
-
-
-// IO
-
- friend inline ostream& operator<<(ostream& s, const String& x);
- friend ostream& operator<<(ostream& s, const SubString& x);
- friend istream& operator>>(istream& s, String& x);
-
- friend int readline(istream& s, String& x,
- char terminator = '\n',
- int discard_terminator = 1);
-
-// status
-
- unsigned int length() const;
- int empty() const;
-
-// preallocate some space for String
- void alloc(int newsize);
-
-// report current allocation (not length!)
-
- int allocation() const;
-
-
- void error(const char* msg) const;
-
- int OK() const;
-};
-
-typedef String StrTmp; // for backward compatibility
-
-// other externs
-
-int compare(const String& x, const String& y);
-int compare(const String& x, const SubString& y);
-int compare(const String& x, const char* y);
-int compare(const SubString& x, const String& y);
-int compare(const SubString& x, const SubString& y);
-int compare(const SubString& x, const char* y);
-int fcompare(const String& x, const String& y); // ignore case
-
-extern StrRep _nilStrRep;
-extern String _nilString;
-
-// status reports, needed before defining other things
-
-inline unsigned int String::length() const { return rep->len; }
-inline int String::empty() const { return rep->len == 0; }
-inline const char* String::chars() const { return &(rep->s[0]); }
-inline int String::allocation() const { return rep->sz; }
-
-inline unsigned int SubString::length() const { return len; }
-inline int SubString::empty() const { return len == 0; }
-inline const char* SubString::chars() const { return &(S.rep->s[pos]); }
-
-
-// constructors
-
-inline String::String()
- : rep(&_nilStrRep) {}
-inline String::String(const String& x)
- : rep(Scopy(0, x.rep)) {}
-inline String::String(const char* t)
- : rep(Salloc(0, t, -1, -1)) {}
-inline String::String(const char* t, int tlen)
- : rep(Salloc(0, t, tlen, tlen)) {}
-inline String::String(const SubString& y)
- : rep(Salloc(0, y.chars(), y.length(), y.length())) {}
-inline String::String(char c)
- : rep(Salloc(0, &c, 1, 1)) {}
-
-inline String::~String() { if (rep != &_nilStrRep) delete rep; }
-
-inline SubString::SubString(const SubString& x)
- :S(x.S), pos(x.pos), len(x.len) {}
-inline SubString::SubString(String& x, int first, int l)
- :S(x), pos(first), len(l) {}
-
-inline SubString::~SubString() {}
-
-// assignment
-
-inline String& String::operator = (const String& y)
-{
- rep = Scopy(rep, y.rep);
- return *this;
-}
-
-inline String& String::operator=(const char* t)
-{
- rep = Salloc(rep, t, -1, -1);
- return *this;
-}
-
-inline String& String::operator=(const SubString& y)
-{
- rep = Salloc(rep, y.chars(), y.length(), y.length());
- return *this;
-}
-
-inline String& String::operator=(char c)
-{
- rep = Salloc(rep, &c, 1, 1);
- return *this;
-}
-
-
-inline SubString& SubString::operator = (const char* ys)
-{
- assign(0, ys);
- return *this;
-}
-
-inline SubString& SubString::operator = (char ch)
-{
- assign(0, &ch, 1);
- return *this;
-}
-
-inline SubString& SubString::operator = (const String& y)
-{
- assign(y.rep, y.chars(), y.length());
- return *this;
-}
-
-inline SubString& SubString::operator = (const SubString& y)
-{
- assign(y.S.rep, y.chars(), y.length());
- return *this;
-}
-
-// Zillions of cats...
-
-inline void cat(const String& x, const String& y, String& r)
-{
- r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const String& x, const SubString& y, String& r)
-{
- r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const String& x, const char* y, String& r)
-{
- r.rep = Scat(r.rep, x.chars(), x.length(), y, -1);
-}
-
-inline void cat(const String& x, char y, String& r)
-{
- r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1);
-}
-
-inline void cat(const SubString& x, const String& y, String& r)
-{
- r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const SubString& x, const SubString& y, String& r)
-{
- r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const SubString& x, const char* y, String& r)
-{
- r.rep = Scat(r.rep, x.chars(), x.length(), y, -1);
-}
-
-inline void cat(const SubString& x, char y, String& r)
-{
- r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1);
-}
-
-inline void cat(const char* x, const String& y, String& r)
-{
- r.rep = Scat(r.rep, x, -1, y.chars(), y.length());
-}
-
-inline void cat(const char* x, const SubString& y, String& r)
-{
- r.rep = Scat(r.rep, x, -1, y.chars(), y.length());
-}
-
-inline void cat(const char* x, const char* y, String& r)
-{
- r.rep = Scat(r.rep, x, -1, y, -1);
-}
-
-inline void cat(const char* x, char y, String& r)
-{
- r.rep = Scat(r.rep, x, -1, &y, 1);
-}
-
-inline void cat(const String& a, const String& x, const String& y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const String& a, const String& x, const SubString& y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const String& a, const String& x, const char* y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1);
-}
-
-inline void cat(const String& a, const String& x, char y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1);
-}
-
-inline void cat(const String& a, const SubString& x, const String& y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const String& a, const SubString& x, const SubString& y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const String& a, const SubString& x, const char* y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1);
-}
-
-inline void cat(const String& a, const SubString& x, char y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1);
-}
-
-inline void cat(const String& a, const char* x, const String& y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length());
-}
-
-inline void cat(const String& a, const char* x, const SubString& y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length());
-}
-
-inline void cat(const String& a, const char* x, const char* y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1);
-}
-
-inline void cat(const String& a, const char* x, char y, String& r)
-{
- r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1);
-}
-
-
-inline void cat(const char* a, const String& x, const String& y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const char* a, const String& x, const SubString& y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const char* a, const String& x, const char* y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1);
-}
-
-inline void cat(const char* a, const String& x, char y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1);
-}
-
-inline void cat(const char* a, const SubString& x, const String& y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const char* a, const SubString& x, const SubString& y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
-}
-
-inline void cat(const char* a, const SubString& x, const char* y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1);
-}
-
-inline void cat(const char* a, const SubString& x, char y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1);
-}
-
-inline void cat(const char* a, const char* x, const String& y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length());
-}
-
-inline void cat(const char* a, const char* x, const SubString& y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length());
-}
-
-inline void cat(const char* a, const char* x, const char* y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x, -1, y, -1);
-}
-
-inline void cat(const char* a, const char* x, char y, String& r)
-{
- r.rep = Scat(r.rep, a, -1, x, -1, &y, 1);
-}
-
-
-// operator versions
-
-inline String& String::operator +=(const String& y)
-{
- cat(*this, y, *this);
- return *this;
-}
-
-inline String& String::operator +=(const SubString& y)
-{
- cat(*this, y, *this);
- return *this;
-}
-
-inline String& String::operator += (const char* y)
-{
- cat(*this, y, *this);
- return *this;
-}
-
-inline String& String:: operator +=(char y)
-{
- cat(*this, y, *this);
- return *this;
-}
-
-// constructive concatenation
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-
-inline String operator + (const String& x, const String& y) return r;
-{
- cat(x, y, r);
-}
-
-inline String operator + (const String& x, const SubString& y) return r;
-{
- cat(x, y, r);
-}
-
-inline String operator + (const String& x, const char* y) return r;
-{
- cat(x, y, r);
-}
-
-inline String operator + (const String& x, char y) return r;
-{
- cat(x, y, r);
-}
-
-inline String operator + (const SubString& x, const String& y) return r;
-{
- cat(x, y, r);
-}
-
-inline String operator + (const SubString& x, const SubString& y) return r;
-{
- cat(x, y, r);
-}
-
-inline String operator + (const SubString& x, const char* y) return r;
-{
- cat(x, y, r);
-}
-
-inline String operator + (const SubString& x, char y) return r;
-{
- cat(x, y, r);
-}
-
-inline String operator + (const char* x, const String& y) return r;
-{
- cat(x, y, r);
-}
-
-inline String operator + (const char* x, const SubString& y) return r;
-{
- cat(x, y, r);
-}
-
-inline String reverse(const String& x) return r;
-{
- r.rep = Sreverse(x.rep, r.rep);
-}
-
-inline String upcase(const String& x) return r;
-{
- r.rep = Supcase(x.rep, r.rep);
-}
-
-inline String downcase(const String& x) return r;
-{
- r.rep = Sdowncase(x.rep, r.rep);
-}
-
-inline String capitalize(const String& x) return r;
-{
- r.rep = Scapitalize(x.rep, r.rep);
-}
-
-#else /* NO_NRV */
-
-inline String operator + (const String& x, const String& y)
-{
- String r; cat(x, y, r); return r;
-}
-
-inline String operator + (const String& x, const SubString& y)
-{
- String r; cat(x, y, r); return r;
-}
-
-inline String operator + (const String& x, const char* y)
-{
- String r; cat(x, y, r); return r;
-}
-
-inline String operator + (const String& x, char y)
-{
- String r; cat(x, y, r); return r;
-}
-
-inline String operator + (const SubString& x, const String& y)
-{
- String r; cat(x, y, r); return r;
-}
-
-inline String operator + (const SubString& x, const SubString& y)
-{
- String r; cat(x, y, r); return r;
-}
-
-inline String operator + (const SubString& x, const char* y)
-{
- String r; cat(x, y, r); return r;
-}
-
-inline String operator + (const SubString& x, char y)
-{
- String r; cat(x, y, r); return r;
-}
-
-inline String operator + (const char* x, const String& y)
-{
- String r; cat(x, y, r); return r;
-}
-
-inline String operator + (const char* x, const SubString& y)
-{
- String r; cat(x, y, r); return r;
-}
-
-inline String reverse(const String& x)
-{
- String r; r.rep = Sreverse(x.rep, r.rep); return r;
-}
-
-inline String upcase(const String& x)
-{
- String r; r.rep = Supcase(x.rep, r.rep); return r;
-}
-
-inline String downcase(const String& x)
-{
- String r; r.rep = Sdowncase(x.rep, r.rep); return r;
-}
-
-inline String capitalize(const String& x)
-{
- String r; r.rep = Scapitalize(x.rep, r.rep); return r;
-}
-
-#endif
-
-// prepend
-
-inline void String::prepend(const String& y)
-{
- rep = Sprepend(rep, y.chars(), y.length());
-}
-
-inline void String::prepend(const char* y)
-{
- rep = Sprepend(rep, y, -1);
-}
-
-inline void String::prepend(char y)
-{
- rep = Sprepend(rep, &y, 1);
-}
-
-inline void String::prepend(const SubString& y)
-{
- rep = Sprepend(rep, y.chars(), y.length());
-}
-
-// misc transformations
-
-
-inline void String::reverse()
-{
- rep = Sreverse(rep, rep);
-}
-
-
-inline void String::upcase()
-{
- rep = Supcase(rep, rep);
-}
-
-
-inline void String::downcase()
-{
- rep = Sdowncase(rep, rep);
-}
-
-
-inline void String::capitalize()
-{
- rep = Scapitalize(rep, rep);
-}
-
-// element extraction
-
-inline char& String::operator [] (int i)
-{
- if (((unsigned)i) >= length()) error("invalid index");
- return rep->s[i];
-}
-
-inline const char& String::operator [] (int i) const
-{
- if (((unsigned)i) >= length()) error("invalid index");
- return rep->s[i];
-}
-
-inline char String::elem (int i) const
-{
- if (((unsigned)i) >= length()) error("invalid index");
- return rep->s[i];
-}
-
-inline char String::firstchar() const
-{
- return elem(0);
-}
-
-inline char String::lastchar() const
-{
- return elem(length() - 1);
-}
-
-// searching
-
-inline int String::index(char c, int startpos) const
-{
- return search(startpos, length(), c);
-}
-
-inline int String::index(const char* t, int startpos) const
-{
- return search(startpos, length(), t);
-}
-
-inline int String::index(const String& y, int startpos) const
-{
- return search(startpos, length(), y.chars(), y.length());
-}
-
-inline int String::index(const SubString& y, int startpos) const
-{
- return search(startpos, length(), y.chars(), y.length());
-}
-
-inline int String::index(const Regex& r, int startpos) const
-{
- int unused; return r.search(chars(), length(), unused, startpos);
-}
-
-inline int String::contains(char c) const
-{
- return search(0, length(), c) >= 0;
-}
-
-inline int String::contains(const char* t) const
-{
- return search(0, length(), t) >= 0;
-}
-
-inline int String::contains(const String& y) const
-{
- return search(0, length(), y.chars(), y.length()) >= 0;
-}
-
-inline int String::contains(const SubString& y) const
-{
- return search(0, length(), y.chars(), y.length()) >= 0;
-}
-
-inline int String::contains(char c, int p) const
-{
- return match(p, length(), 0, &c, 1) >= 0;
-}
-
-inline int String::contains(const char* t, int p) const
-{
- return match(p, length(), 0, t) >= 0;
-}
-
-inline int String::contains(const String& y, int p) const
-{
- return match(p, length(), 0, y.chars(), y.length()) >= 0;
-}
-
-inline int String::contains(const SubString& y, int p) const
-{
- return match(p, length(), 0, y.chars(), y.length()) >= 0;
-}
-
-inline int String::contains(const Regex& r) const
-{
- int unused; return r.search(chars(), length(), unused, 0) >= 0;
-}
-
-inline int String::contains(const Regex& r, int p) const
-{
- return r.match(chars(), length(), p) >= 0;
-}
-
-
-inline int String::matches(const SubString& y, int p) const
-{
- return match(p, length(), 1, y.chars(), y.length()) >= 0;
-}
-
-inline int String::matches(const String& y, int p) const
-{
- return match(p, length(), 1, y.chars(), y.length()) >= 0;
-}
-
-inline int String::matches(const char* t, int p) const
-{
- return match(p, length(), 1, t) >= 0;
-}
-
-inline int String::matches(char c, int p) const
-{
- return match(p, length(), 1, &c, 1) >= 0;
-}
-
-inline int String::matches(const Regex& r, int p) const
-{
- int l = (p < 0)? -p : length() - p;
- return r.match(chars(), length(), p) == l;
-}
-
-
-inline int SubString::contains(const char* t) const
-{
- return S.search(pos, pos+len, t) >= 0;
-}
-
-inline int SubString::contains(const String& y) const
-{
- return S.search(pos, pos+len, y.chars(), y.length()) >= 0;
-}
-
-inline int SubString::contains(const SubString& y) const
-{
- return S.search(pos, pos+len, y.chars(), y.length()) >= 0;
-}
-
-inline int SubString::contains(char c) const
-{
- return S.search(pos, pos+len, c) >= 0;
-}
-
-inline int SubString::contains(const Regex& r) const
-{
- int unused; return r.search(chars(), len, unused, 0) >= 0;
-}
-
-inline int SubString::matches(const Regex& r) const
-{
- return r.match(chars(), len, 0) == len;
-}
-
-
-inline int String::gsub(const String& pat, const String& r)
-{
- return _gsub(pat.chars(), pat.length(), r.chars(), r.length());
-}
-
-inline int String::gsub(const SubString& pat, const String& r)
-{
- return _gsub(pat.chars(), pat.length(), r.chars(), r.length());
-}
-
-inline int String::gsub(const Regex& pat, const String& r)
-{
- return _gsub(pat, r.chars(), r.length());
-}
-
-inline int String::gsub(const char* pat, const String& r)
-{
- return _gsub(pat, -1, r.chars(), r.length());
-}
-
-inline int String::gsub(const char* pat, const char* r)
-{
- return _gsub(pat, -1, r, -1);
-}
-
-
-
-inline ostream& operator<<(ostream& s, const String& x)
-{
- s << x.chars(); return s;
-}
-
-// a zillion comparison operators
-
-inline int operator==(const String& x, const String& y)
-{
- return compare(x, y) == 0;
-}
-
-inline int operator!=(const String& x, const String& y)
-{
- return compare(x, y) != 0;
-}
-
-inline int operator>(const String& x, const String& y)
-{
- return compare(x, y) > 0;
-}
-
-inline int operator>=(const String& x, const String& y)
-{
- return compare(x, y) >= 0;
-}
-
-inline int operator<(const String& x, const String& y)
-{
- return compare(x, y) < 0;
-}
-
-inline int operator<=(const String& x, const String& y)
-{
- return compare(x, y) <= 0;
-}
-
-inline int operator==(const String& x, const SubString& y)
-{
- return compare(x, y) == 0;
-}
-
-inline int operator!=(const String& x, const SubString& y)
-{
- return compare(x, y) != 0;
-}
-
-inline int operator>(const String& x, const SubString& y)
-{
- return compare(x, y) > 0;
-}
-
-inline int operator>=(const String& x, const SubString& y)
-{
- return compare(x, y) >= 0;
-}
-
-inline int operator<(const String& x, const SubString& y)
-{
- return compare(x, y) < 0;
-}
-
-inline int operator<=(const String& x, const SubString& y)
-{
- return compare(x, y) <= 0;
-}
-
-inline int operator==(const String& x, const char* t)
-{
- return compare(x, t) == 0;
-}
-
-inline int operator!=(const String& x, const char* t)
-{
- return compare(x, t) != 0;
-}
-
-inline int operator>(const String& x, const char* t)
-{
- return compare(x, t) > 0;
-}
-
-inline int operator>=(const String& x, const char* t)
-{
- return compare(x, t) >= 0;
-}
-
-inline int operator<(const String& x, const char* t)
-{
- return compare(x, t) < 0;
-}
-
-inline int operator<=(const String& x, const char* t)
-{
- return compare(x, t) <= 0;
-}
-
-inline int operator==(const SubString& x, const String& y)
-{
- return compare(y, x) == 0;
-}
-
-inline int operator!=(const SubString& x, const String& y)
-{
- return compare(y, x) != 0;
-}
-
-inline int operator>(const SubString& x, const String& y)
-{
- return compare(y, x) < 0;
-}
-
-inline int operator>=(const SubString& x, const String& y)
-{
- return compare(y, x) <= 0;
-}
-
-inline int operator<(const SubString& x, const String& y)
-{
- return compare(y, x) > 0;
-}
-
-inline int operator<=(const SubString& x, const String& y)
-{
- return compare(y, x) >= 0;
-}
-
-inline int operator==(const SubString& x, const SubString& y)
-{
- return compare(x, y) == 0;
-}
-
-inline int operator!=(const SubString& x, const SubString& y)
-{
- return compare(x, y) != 0;
-}
-
-inline int operator>(const SubString& x, const SubString& y)
-{
- return compare(x, y) > 0;
-}
-
-inline int operator>=(const SubString& x, const SubString& y)
-{
- return compare(x, y) >= 0;
-}
-
-inline int operator<(const SubString& x, const SubString& y)
-{
- return compare(x, y) < 0;
-}
-
-inline int operator<=(const SubString& x, const SubString& y)
-{
- return compare(x, y) <= 0;
-}
-
-inline int operator==(const SubString& x, const char* t)
-{
- return compare(x, t) == 0;
-}
-
-inline int operator!=(const SubString& x, const char* t)
-{
- return compare(x, t) != 0;
-}
-
-inline int operator>(const SubString& x, const char* t)
-{
- return compare(x, t) > 0;
-}
-
-inline int operator>=(const SubString& x, const char* t)
-{
- return compare(x, t) >= 0;
-}
-
-inline int operator<(const SubString& x, const char* t)
-{
- return compare(x, t) < 0;
-}
-
-inline int operator<=(const SubString& x, const char* t)
-{
- return compare(x, t) <= 0;
-}
-
-
-// a helper needed by at, before, etc.
-
-inline SubString String::_substr(int first, int l)
-{
- if (first < 0 || (unsigned)(first + l) > length() )
- return SubString(_nilString, 0, 0) ;
- else
- return SubString(*this, first, l);
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Uniform.h b/gnu/lib/libg++/include/Uniform.h
deleted file mode 100644
index 91536eb..0000000
--- a/gnu/lib/libg++/include/Uniform.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _Uniform_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Uniform_h 1
-
-#include <Random.h>
-
-//
-// The interval [lo..hi]
-//
-
-class Uniform: public Random {
- double pLow;
- double pHigh;
- double delta;
-public:
- Uniform(double low, double high, RNG *gen);
-
- double low();
- double low(double x);
- double high();
- double high(double x);
-
- virtual double operator()();
-};
-
-
-inline Uniform::Uniform(double low, double high, RNG *gen) : Random(gen)
-{
- pLow = (low < high) ? low : high;
- pHigh = (low < high) ? high : low;
- delta = pHigh - pLow;
-}
-
-inline double Uniform::low() { return pLow; }
-
-inline double Uniform::low(double x) {
- double tmp = pLow;
- pLow = x;
- delta = pHigh - pLow;
- return tmp;
-}
-
-inline double Uniform::high() { return pHigh; }
-
-inline double Uniform::high(double x) {
- double tmp = pHigh;
- pHigh = x;
- delta = pHigh - pLow;
- return tmp;
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/Weibull.h b/gnu/lib/libg++/include/Weibull.h
deleted file mode 100644
index c0360dc..0000000
--- a/gnu/lib/libg++/include/Weibull.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifndef _Weibull_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _Weibull_h
-
-#include <Random.h>
-
-class Weibull: public Random {
-protected:
- double pAlpha;
- double pInvAlpha;
- double pBeta;
-
- void setState();
-
-public:
- Weibull(double alpha, double beta, RNG *gen);
-
- double alpha();
- double alpha(double x);
-
- double beta();
- double beta(double x);
-
- virtual double operator()();
-};
-
-
-inline void Weibull::setState() {
- pInvAlpha = 1.0 / pAlpha;
-}
-
-inline Weibull::Weibull(double alpha, double beta, RNG *gen) : Random(gen)
-{
- pAlpha = alpha;
- pBeta = beta;
- setState();
-}
-
-inline double Weibull::alpha() { return pAlpha; }
-
-inline double Weibull::alpha(double x) {
- double tmp = pAlpha;
- pAlpha = x;
- setState();
- return tmp;
-}
-
-inline double Weibull::beta() { return pBeta; };
-inline double Weibull::beta(double x) {
- double tmp = pBeta;
- pBeta = x;
- return tmp;
-};
-
-#endif
diff --git a/gnu/lib/libg++/include/_G_config.h b/gnu/lib/libg++/include/_G_config.h
deleted file mode 100644
index cbd1acf..0000000
--- a/gnu/lib/libg++/include/_G_config.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* AUTOMATICALLY GENERATED; DO NOT EDIT! */
-#include <sys/types.h>
-#ifndef _G_config_h
-#define _G_config_h
-#define _G_LIB_VERSION "0.66"
-#define _G_NAMES_HAVE_UNDERSCORE 1
-#define _G_VTABLE_LABEL_HAS_LENGTH 1
-#define _G_VTABLE_LABEL_PREFIX "__vt$"
-#define _G_HAVE_ST_BLKSIZE 1
-typedef unsigned long _G_clock_t;
-typedef unsigned long _G_dev_t;
-typedef quad_t _G_fpos_t;
-typedef unsigned long _G_gid_t;
-typedef unsigned long _G_ino_t;
-typedef unsigned short _G_mode_t;
-typedef unsigned short _G_nlink_t;
-typedef long long _G_off_t;
-typedef long _G_pid_t;
-#ifndef __PTRDIFF_TYPE__
-#define __PTRDIFF_TYPE__ int
-#endif
-typedef __PTRDIFF_TYPE__ _G_ptrdiff_t;
-typedef unsigned int _G_sigset_t;
-#ifndef __SIZE_TYPE__
-#define __SIZE_TYPE__ unsigned int
-#endif
-typedef __SIZE_TYPE__ _G_size_t;
-typedef long _G_time_t;
-typedef unsigned long _G_uid_t;
-#ifndef __WCHAR_TYPE__
-#define __WCHAR_TYPE__ int
-#endif
-typedef __WCHAR_TYPE__ _G_wchar_t;
-typedef int _G_ssize_t;
-typedef int /* default */ _G_wint_t;
-typedef char* /* default */ _G_va_list;
-#define _G_signal_return_type void
-#define _G_sprintf_return_type int
-#ifdef __STDC__
-typedef signed char _G_int8_t;
-#endif
-typedef unsigned char _G_uint8_t;
-typedef short _G_int16_t;
-typedef unsigned short _G_uint16_t;
-typedef int _G_int32_t;
-typedef unsigned long _G_uint32_t;
-#define HAVE_INT64
-typedef long long _G_int64_t;
-typedef unsigned _G_uint64_t;
-#define _G_BUFSIZ 1024
-#define _G_FOPEN_MAX 20
-#define _G_FILENAME_MAX 1024
-#define _G_NULL 0 /* default */
-#if defined (__cplusplus) || defined (__STDC__)
-#define _G_ARGS(ARGLIST) ARGLIST
-#else
-#define _G_ARGS(ARGLIST) ()
-#endif
-#if !defined (__GNUG__) || defined (__STRICT_ANSI__)
-#define _G_NO_NRV
-#endif
-#if !defined (__GNUG__)
-#define _G_NO_EXTERN_TEMPLATES
-#endif
-#define _G_HAVE_ATEXIT 1
-#define _G_HAVE_SYS_RESOURCE 1
-#define _G_HAVE_SYS_SOCKET 1
-#define _G_HAVE_SYS_WAIT 1
-#define _G_HAVE_UNISTD 1
-#define _G_HAVE_DIRENT 1
-#define _G_HAVE_CURSES 1
-#define _G_MATH_H_INLINES 0
-#define _G_HAVE_BOOL 1
-#endif /* !_G_config_h */
diff --git a/gnu/lib/libg++/include/ansidecl.h b/gnu/lib/libg++/include/ansidecl.h
deleted file mode 100644
index 3c0dcb3..0000000
--- a/gnu/lib/libg++/include/ansidecl.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* ANSI and traditional C compatability macros
- Copyright 1991, 1992 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* ANSI and traditional C compatibility macros
-
- ANSI C is assumed if __STDC__ is #defined.
-
- Macro ANSI C definition Traditional C definition
- ----- ---- - ---------- ----------- - ----------
- PTR `void *' `char *'
- LONG_DOUBLE `long double' `double'
- VOLATILE `volatile' `'
- SIGNED `signed' `'
- PTRCONST `void *const' `char *'
- ANSI_PROTOTYPES 1 not defined
-
- CONST is also defined, but is obsolete. Just use const.
-
- DEFUN (name, arglist, args)
-
- Defines function NAME.
-
- ARGLIST lists the arguments, separated by commas and enclosed in
- parentheses. ARGLIST becomes the argument list in traditional C.
-
- ARGS list the arguments with their types. It becomes a prototype in
- ANSI C, and the type declarations in traditional C. Arguments should
- be separated with `AND'. For functions with a variable number of
- arguments, the last thing listed should be `DOTS'.
-
- DEFUN_VOID (name)
-
- Defines a function NAME, which takes no arguments.
-
- obsolete -- EXFUN (name, (prototype)) -- obsolete.
-
- Replaced by PARAMS. Do not use; will disappear someday soon.
- Was used in external function declarations.
- In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
- parentheses). In traditional C it is `NAME()'.
- For a function that takes no arguments, PROTOTYPE should be `(void)'.
-
- PARAMS ((args))
-
- We could use the EXFUN macro to handle prototype declarations, but
- the name is misleading and the result is ugly. So we just define a
- simple macro to handle the parameter lists, as in:
-
- static int foo PARAMS ((int, char));
-
- This produces: `static int foo();' or `static int foo (int, char);'
-
- EXFUN would have done it like this:
-
- static int EXFUN (foo, (int, char));
-
- but the function is not external...and it's hard to visually parse
- the function name out of the mess. EXFUN should be considered
- obsolete; new code should be written to use PARAMS.
-
- For example:
- extern int printf PARAMS ((CONST char *format DOTS));
- int DEFUN(fprintf, (stream, format),
- FILE *stream AND CONST char *format DOTS) { ... }
- void DEFUN_VOID(abort) { ... }
-*/
-
-#ifndef _ANSIDECL_H
-
-#define _ANSIDECL_H 1
-
-
-/* Every source file includes this file,
- so they will all get the switch for lint. */
-/* LINTLIBRARY */
-
-
-#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4))
-/* All known AIX compilers implement these things (but don't always
- define __STDC__). The RISC/OS MIPS compiler defines these things
- in SVR4 mode, but does not define __STDC__. */
-
-#define PTR void *
-#define PTRCONST void *CONST
-#define LONG_DOUBLE long double
-
-#define AND ,
-#define NOARGS void
-#define CONST const
-#define VOLATILE volatile
-#define SIGNED signed
-#define DOTS , ...
-
-#define EXFUN(name, proto) name proto
-#define DEFUN(name, arglist, args) name(args)
-#define DEFUN_VOID(name) name(void)
-
-#define PROTO(type, name, arglist) type name arglist
-#define PARAMS(paramlist) paramlist
-#define ANSI_PROTOTYPES 1
-
-#else /* Not ANSI C. */
-
-#define PTR char *
-#define PTRCONST PTR
-#define LONG_DOUBLE double
-
-#define AND ;
-#define NOARGS
-#define CONST
-#ifndef const /* some systems define it in header files for non-ansi mode */
-#define const
-#endif
-#define VOLATILE
-#define SIGNED
-#define DOTS
-
-#define EXFUN(name, proto) name()
-#define DEFUN(name, arglist, args) name arglist args;
-#define DEFUN_VOID(name) name()
-#define PROTO(type, name, arglist) type name ()
-#define PARAMS(paramlist) ()
-
-#endif /* ANSI C. */
-
-#endif /* ansidecl.h */
diff --git a/gnu/lib/libg++/include/bitdo1.h b/gnu/lib/libg++/include/bitdo1.h
deleted file mode 100644
index c234d41..0000000
--- a/gnu/lib/libg++/include/bitdo1.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef ONES
-#define ONES ((_BS_word)(~0L))
-#endif
- register int nwords;
- register _BS_word mask;
- if (offset == 0)
- ;
- else if (offset + length >= _BS_BITS_PER_WORD)
- {
- mask = ONES _BS_RIGHT offset;
- DOIT(*ptr++, mask);
- length -= _BS_BITS_PER_WORD - offset;
- }
- else
- {
- mask = (ONES _BS_RIGHT (_BS_BITS_PER_WORD - length))
- _BS_LEFT (_BS_BITS_PER_WORD - length - offset);
- DOIT(*ptr, mask);
- goto done;
- }
- nwords = _BS_INDEX(length);
- while (--nwords >= 0)
- {
- DOIT(*ptr++, ONES);
- }
- length = _BS_POS (length);
- if (length)
- {
- mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - length);
- DOIT(*ptr, mask);
- }
- done: ;
diff --git a/gnu/lib/libg++/include/bitdo2.h b/gnu/lib/libg++/include/bitdo2.h
deleted file mode 100644
index 6e99523..0000000
--- a/gnu/lib/libg++/include/bitdo2.h
+++ /dev/null
@@ -1,184 +0,0 @@
-#ifndef ONES
-#define ONES ((_BS_word)(~0L))
-#endif
-
-#ifndef DOIT_SOLID
-#ifdef DOIT
-#define DOIT_SOLID(dst, src) DOIT(dst, src, (_BS_word)(~0))
-#else
-#define DOIT_SOLID(dst, src) (dst) = (COMBINE(dst, src))
-#endif
-#endif
-
-#ifndef DOIT
-#define DOIT(dst, src, mask) \
- (dst) = ((COMBINE(dst, src)) & (mask)) | ((dst) & ~(mask))
-#endif
-
- _BS_word word0, mask;
- int shift0, shift1;
-
- if (length == 0)
- goto done;
-
- shift0 = srcbit - dstbit;
-
- /* First handle the case that only one destination word is touched. */
- if (length + dstbit <= _BS_BITS_PER_WORD)
- {
- _BS_word mask
- = (ONES _BS_LEFT (_BS_BITS_PER_WORD - length)) _BS_RIGHT dstbit;
- _BS_word word0 = *psrc++;
- if (shift0 <= 0) /* dstbit >= srcbit */
- {
- word0 = word0 _BS_RIGHT (-shift0);
- }
- else
- {
- word0 = word0 _BS_LEFT shift0;
- if (length + srcbit > _BS_BITS_PER_WORD)
- word0 = word0 | (*psrc _BS_RIGHT (_BS_BITS_PER_WORD - shift0));
- }
- DOIT(*pdst, word0, mask);
- goto done;
- }
-
- /* Next optimize the case that the source and destination are aligned. */
- if (shift0 == 0)
- {
- _BS_word mask;
- if (psrc > pdst)
- {
- if (srcbit)
- {
- mask = ONES _BS_RIGHT srcbit;
- DOIT(*pdst, *psrc, mask);
- pdst++; psrc++;
- length -= _BS_BITS_PER_WORD - srcbit;
- }
- for (; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD)
- {
- DOIT_SOLID(*pdst, *psrc);
- pdst++; psrc++;
- }
- if (length)
- {
- mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - length);
- DOIT(*pdst, *psrc, mask);
- }
- }
- else if (psrc < pdst)
- {
- _BS_size_t span = srcbit + length;
- pdst += span / (_BS_size_t)_BS_BITS_PER_WORD;
- psrc += span / (_BS_size_t)_BS_BITS_PER_WORD;
- span %= (_BS_size_t)_BS_BITS_PER_WORD;
- if (span)
- {
- mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - span);
- DOIT(*pdst, *psrc, mask);
- length -= span;
- }
- pdst--; psrc--;
- for (; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD)
- {
- DOIT_SOLID(*pdst, *psrc);
- pdst--; psrc--;
- }
- if (srcbit)
- {
- mask = ONES _BS_RIGHT srcbit;
- DOIT(*pdst, *psrc, mask);
- }
- }
- /* else if (psrc == pdst) --nothing to do--; */
- goto done;
- }
-
- /* Now we assume shift!=0, and more than on destination word is changed. */
- if (psrc >= pdst) /* Do the updates in forward direction. */
- {
- _BS_word word0 = *psrc++;
- _BS_word mask = ONES _BS_RIGHT dstbit;
- if (shift0 > 0)
- {
- _BS_word word1 = *psrc++;
- shift1 = _BS_BITS_PER_WORD - shift0;
- DOIT(*pdst, (word0 _BS_LEFT shift0) | (word1 _BS_RIGHT shift1), mask);
- word0 = word1;
- }
- else /* dstbit > srcbit */
- {
- shift1 = -shift0;
- shift0 += _BS_BITS_PER_WORD;
- DOIT(*pdst, word0 _BS_RIGHT shift1, mask);
- }
- pdst++;
- length -= _BS_BITS_PER_WORD - dstbit;
-
- for ( ; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD)
- {
- register _BS_word word1 = *psrc++;
- DOIT_SOLID(*pdst,
- (word0 _BS_LEFT shift0) | (word1 _BS_RIGHT shift1));
- pdst++;
- word0 = word1;
- }
- if (length > 0)
- {
- _BS_size_t mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - length);
- word0 = word0 _BS_LEFT shift0;
- if (length > shift1)
- word0 = word0 | (*psrc _BS_RIGHT shift1) ;
- DOIT (*pdst, word0, mask);
- }
- }
- else /* Do the updates in backward direction. */
- {
- _BS_word word0;
-
- /* Make (psrc, srcbit) and (pdst, dstbit) point to *last* bit. */
- psrc += (srcbit + length - 1) / _BS_BITS_PER_WORD;
- srcbit = (srcbit + length - 1) % _BS_BITS_PER_WORD;
- pdst += (dstbit + length - 1) / _BS_BITS_PER_WORD;
- dstbit = (dstbit + length - 1) % _BS_BITS_PER_WORD;
-
- shift0 = srcbit - dstbit;
-
- word0 = *psrc--;
- mask = ONES _BS_LEFT (_BS_BITS_PER_WORD - 1 - dstbit);
- if (shift0 < 0)
- {
- _BS_word word1 = *psrc--;
- shift1 = -shift0;
- shift0 += _BS_BITS_PER_WORD;
- DOIT (*pdst, (word0 _BS_RIGHT shift1) | (word1 _BS_LEFT shift0),
- mask);
- word0 = word1;
- }
- else
- {
- shift1 = _BS_BITS_PER_WORD - shift0;
- DOIT(*pdst, word0 _BS_LEFT shift0, mask);
- }
- pdst--;
- length -= dstbit + 1;
-
- for ( ; length >= _BS_BITS_PER_WORD; length -= _BS_BITS_PER_WORD)
- {
- register _BS_word word1 = *psrc--;
- DOIT_SOLID(*pdst,
- (word0 _BS_RIGHT shift1) | (word1 _BS_LEFT shift0));
- pdst--;
- word0 = word1;
- }
- if (length > 0)
- {
- _BS_size_t mask = ONES _BS_RIGHT (_BS_BITS_PER_WORD - length);
- word0 = word0 _BS_RIGHT shift1;
- if (length > shift0)
- word0 = word0 | (*psrc _BS_LEFT shift0) ;
- DOIT (*pdst, word0, mask);
- }
- }
- done: ;
diff --git a/gnu/lib/libg++/include/bitprims.h b/gnu/lib/libg++/include/bitprims.h
deleted file mode 100644
index 24b3051..0000000
--- a/gnu/lib/libg++/include/bitprims.h
+++ /dev/null
@@ -1,125 +0,0 @@
-#ifndef _BS_PRIMS
-#define _BS_PRIMS
-
-/* For now, use unsigned short for compatibility with old libg++ code.
- Later, change to unsigned long as the default. */
-typedef unsigned long _BS_word;
-
-#define _BS_CHAR_BIT 8
-#define _BS_BITS_PER_WORD (_BS_CHAR_BIT*sizeof(_BS_word))
-#define _BS_WORDS_NEEDED(NBITS) ((NBITS+_BS_BITS_PER_WORD-1)/_BS_BITS_PER_WORD)
-
-/* For now, we number the bits in a _BS_word in little-endian order.
- Later, might use machine order. */
-#ifdef CHILL_LIB
-#ifndef BITS_BIG_ENDIAN
-#include "config.h"
-#endif
-#define _BS_BIGENDIAN BITS_BIG_ENDIAN
-#else
-#define _BS_BIGENDIAN 0
-#endif
-
-/* By "left" we mean where bit number 0 is.
- Hence, so left shift is << if we're numbering the bits in big-endian oder,
- and >> if we're numbering the bits in little-endian order.
- Currently, we always use little-endian order.
- Later, we might use machine-endian order. */
-#if _BS_BIGENDIAN
-#define _BS_LEFT <<
-#define _BS_RIGHT >>
-#else
-#define _BS_LEFT >>
-#define _BS_RIGHT <<
-#endif
-
-#if _BS_BIGENDIAN
-#define _BS_BITMASK(BITNO) (1 << (_BS_BITS_PER_WORD - 1 - (BITNO)))
-#else
-#define _BS_BITMASK(BITNO) (1 << (BITNO))
-#endif
-
-/* Given a PTR which may not be aligned on a _BS_word boundary,
- set NEW_PTR to point to (the beginning of) the corresponding _BS_word.
- Adjust the bit-offset OFFSET to compensate for the difference. */
-#define _BS_ADJUST_ALIGNED(NEW_PTR, PTR, OFFSET) \
- ( (NEW_PTR) = (_BS_word*)(((char*)(PTR)-(char*)0) & ~(sizeof(_BS_word)-1)), \
- (OFFSET) += (char*)(PTR) - (char*)(NEW_PTR) )
-
-/* Given a bit point (PTR, OFFSET) normalize it so that
- OFFSET < _BS_BITS_PER_WORD. */
-#define _BS_NORMALIZE(PTR, OFFSET) \
-{ _BS_size_t __tmp_ind = _BS_INDEX (OFFSET); \
- (PTR) += __tmp_ind; \
- (OFFSET) -= __tmp_ind * _BS_BITS_PER_WORD; }
-
-#define _BS_INDEX(I) ((unsigned)(I) / _BS_BITS_PER_WORD)
-#define _BS_POS(I) ((I) & (_BS_BITS_PER_WORD -1 ))
-
-#ifndef _BS_size_t
-#ifdef __GNUC__
-#define _BS_size_t __SIZE_TYPE__
-#else
-#define _BS_size_t unsigned long
-#endif
-#endif
-
-#ifndef __P
-#ifdef __STDC__
-#define __P(paramlist) paramlist
-#else
-#define __P(paramlist) ()
-#endif
-#endif /*!__P*/
-#if !defined(__STDC__) && !defined(const)
-#define const
-#endif
-#if !defined(__STDC__) && !defined(void)
-#define void int
-#endif
-
-/* The 16 2-operand raster-ops:
- These match the correspodning GX codes in X11. */
-enum _BS_alu {
- _BS_alu_clear = 0 /* 0 */,
- _BS_alu_and = 1 /* src & dst */,
- _BS_alu_andReverse = 2 /* src & ~dst */,
- _BS_alu_copy = 3 /* src */,
- _BS_alu_andInverted = 4 /* ~src & dst */,
- _BS_alu_noop = 5 /* dst */,
- _BS_alu_xor = 6 /* src ^ dst */,
- _BS_alu_or = 7 /* src | dst */,
- _BS_alu_nor = 8 /* ~src & ~dst */,
- _BS_alu_equiv = 9 /* ~(src ^ dst) */,
- _BS_alu_invert = 10 /* ~dst */,
- _BS_alu_orReverse = 11 /* src | ~dst */,
- _BS_alu_copyInverted = 12 /* ~src */,
- _BS_alu_orInverted = 13 /* ~src | dst */,
- _BS_alu_nand = 14 /* ~src | d~st */,
- _BS_alu_set = 15 /* ~src | dst */
-};
-#define _BS
-#define _BS
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void _BS_and __P((_BS_word*,int, const _BS_word*, int, _BS_size_t));
-extern void _BS_blt __P((enum _BS_alu,
- _BS_word*,int, const _BS_word*,int, _BS_size_t));
-extern void _BS_copy __P((_BS_word*,int, const _BS_word*,int, _BS_size_t));
-#define _BS_copy_0(DS, SS, LENGTH) _BS_copy(DS, 0, SS, 0, LENGTH)
-extern int _BS_count __P((const _BS_word*, int, _BS_size_t));
-extern int _BS_any __P((const _BS_word*, int, _BS_size_t));
-extern void _BS_clear __P((_BS_word*, int, _BS_size_t));
-extern void _BS_set __P((_BS_word*, int, _BS_size_t));
-extern void _BS_invert __P((_BS_word*, int, _BS_size_t));
-int _BS_lcompare_0 __P((_BS_word*, _BS_size_t, _BS_word*, _BS_size_t));
-extern void _BS_xor __P((_BS_word*,int, const _BS_word*,int, _BS_size_t));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !_BS_PRIMS */
diff --git a/gnu/lib/libg++/include/builtin.h b/gnu/lib/libg++/include/builtin.h
deleted file mode 100644
index e2d7bce..0000000
--- a/gnu/lib/libg++/include/builtin.h
+++ /dev/null
@@ -1,144 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-
-/*
-Copyright (C) 1988, 1992 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-/*
- arithmetic, etc. functions on built in types
-*/
-
-
-#ifndef _builtin_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _builtin_h 1
-
-#include <stddef.h>
-#include <std.h>
-#include <math.h>
-
-#ifdef __GNUG__
-#define _VOLATILE_VOID volatile void
-#else
-#define _VOLATILE_VOID void
-#endif
-
-typedef void (*one_arg_error_handler_t)(const char*);
-typedef void (*two_arg_error_handler_t)(const char*, const char*);
-
-long gcd(long, long);
-long lg(unsigned long);
-double pow(double, long);
-long pow(long, long);
-
-extern "C" double start_timer();
-extern "C" double return_elapsed_time(double last_time = 0.0);
-
-char* dtoa(double x, char cvt = 'g', int width = 0, int prec = 6);
-
-unsigned int hashpjw(const char*);
-unsigned int multiplicativehash(int);
-unsigned int foldhash(double);
-
-extern _VOLATILE_VOID default_one_arg_error_handler(const char*);
-extern _VOLATILE_VOID default_two_arg_error_handler(const char*, const char*);
-
-extern two_arg_error_handler_t lib_error_handler;
-
-extern two_arg_error_handler_t
- set_lib_error_handler(two_arg_error_handler_t f);
-
-
-#if !defined(IV)
-
-#if ! _G_MATH_H_INLINES /* hpux and SCO define this in math.h */
-inline double abs(double arg)
-{
- return (arg < 0.0)? -arg : arg;
-}
-#endif
-
-inline float abs(float arg)
-{
- return (arg < 0.0)? -arg : arg;
-}
-
-inline short abs(short arg)
-{
- return (arg < 0)? -arg : arg;
-}
-
-inline long abs(long arg)
-{
- return (arg < 0)? -arg : arg;
-}
-
-inline int sign(long arg)
-{
- return (arg == 0) ? 0 : ( (arg > 0) ? 1 : -1 );
-}
-
-inline int sign(double arg)
-{
- return (arg == 0.0) ? 0 : ( (arg > 0.0) ? 1 : -1 );
-}
-
-inline long sqr(long arg)
-{
- return arg * arg;
-}
-
-#if ! _G_MATH_H_INLINES /* hpux and SCO define this in math.h */
-inline double sqr(double arg)
-{
- return arg * arg;
-}
-#endif
-
-inline int even(long arg)
-{
- return !(arg & 1);
-}
-
-inline int odd(long arg)
-{
- return (arg & 1);
-}
-
-inline long lcm(long x, long y)
-{
- return x / gcd(x, y) * y;
-}
-
-inline void (setbit)(long& x, long b)
-{
- x |= (1 << b);
-}
-
-inline void clearbit(long& x, long b)
-{
- x &= ~(1 << b);
-}
-
-inline int testbit(long x, long b)
-{
- return ((x & (1 << b)) != 0);
-}
-
-#endif
-#endif
diff --git a/gnu/lib/libg++/include/builtinbuf.h b/gnu/lib/libg++/include/builtinbuf.h
deleted file mode 100644
index d67629a..0000000
--- a/gnu/lib/libg++/include/builtinbuf.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#ifndef _BUILTINBUF_H
-#define _BUILTINBUF_H
-
-#ifdef __GNUC__
-#pragma interface
-#endif
-
-#include <streambuf.h>
-
-// A builtinbuf a a streambuf where all the virtual operations
-// call the _IO_jump_t table.
-
-class builtinbuf : public streambuf {
- friend ios;
- virtual int overflow(int);
- virtual int underflow();
- virtual streamsize xsgetn(char *, streamsize);
- virtual streamsize xsputn(const char *, streamsize);
- virtual streambuf* setbuf(char*, int);
- virtual int doallocate();
- virtual ~builtinbuf();
- virtual int sync();
-
- virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
- virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
- virtual int pbackfail(int c);
- virtual streamsize sys_read(char* buf, streamsize size);
- virtual streampos sys_seek(streamoff, _seek_dir);
- virtual streamsize sys_write(const char*, streamsize);
- virtual int sys_stat(void*); // Actually, a (struct stat*)
- virtual int sys_close();
-#if 0
- virtual int get_column();
- virtual int set_column(int);
-#endif
- private:
- builtinbuf() { }
-};
-#endif /* _BUILTINBUF_H */
diff --git a/gnu/lib/libg++/include/compare.h b/gnu/lib/libg++/include/compare.h
deleted file mode 100644
index aec3c30..0000000
--- a/gnu/lib/libg++/include/compare.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _compare_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _compare_h 1
-
-#include <builtin.h>
-
-int compare(int a, int b);
-int compare(short a, short b);
-int compare(unsigned long a, unsigned long b);
-int compare(unsigned int a, unsigned int b);
-int compare(unsigned short a, unsigned short b);
-int compare(unsigned char a, unsigned char b);
-int compare(signed char a, signed char b);
-int compare(float a, float b);
-int compare(double a, double b);
-int compare(const char* a, const char* b);
-
-
-inline int compare(int a, int b)
-{
- return a - b;
-}
-
-inline int compare(short a, short b)
-{
- return a - b;
-}
-
-
-inline int compare(signed char a, signed char b)
-{
- return a - b;
-}
-
-inline int compare(unsigned long a, unsigned long b)
-{
- return (a < b)? -1 : (a > b)? 1 : 0;
-}
-
-inline int compare(unsigned int a, unsigned int b)
-{
- return (a < b)? -1 : (a > b)? 1 : 0;
-}
-
-inline int compare(unsigned short a, unsigned short b)
-{
- return (a < b)? -1 : (a > b)? 1 : 0;
-}
-
-inline int compare(unsigned char a, unsigned char b)
-{
- return (a < b)? -1 : (a > b)? 1 : 0;
-}
-
-inline int compare(float a, float b)
-{
- return (a < b)? -1 : (a > b)? 1 : 0;
-}
-
-inline int compare(double a, double b)
-{
- return (a < b)? -1 : (a > b)? 1 : 0;
-}
-
-inline int compare(const char* a, const char* b)
-{
- return strcmp(a,b);
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/complex.h b/gnu/lib/libg++/include/complex.h
deleted file mode 100644
index afe2c8b..0000000
--- a/gnu/lib/libg++/include/complex.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _complex_h
-#define _complex_h
-#define __ATT_complex__
-#include <Complex.h>
-typedef class Complex complex;
-#endif
diff --git a/gnu/lib/libg++/include/config.h b/gnu/lib/libg++/include/config.h
deleted file mode 100644
index b37ee84..0000000
--- a/gnu/lib/libg++/include/config.h
+++ /dev/null
@@ -1 +0,0 @@
-/* !Automatically generated from ./functions.def - DO NOT EDIT! */
diff --git a/gnu/lib/libg++/include/defines.h b/gnu/lib/libg++/include/defines.h
deleted file mode 100644
index f5056b6..0000000
--- a/gnu/lib/libg++/include/defines.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1994 Free Software Foundation
- written by Jason Merrill (jason@cygnus.com)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _defines_h
-#define _defines_h
-
-#include <_G_config.h>
-#include <stddef.h>
-
-const size_t NPOS = (size_t)(-1);
-typedef void fvoid_t();
-
-#ifndef _WINT_T
-#define _WINT_T
-typedef _G_wint_t wint_t;
-#endif
-
-enum capacity { default_size, reserve };
-
-#endif
diff --git a/gnu/lib/libg++/include/editbuf.h b/gnu/lib/libg++/include/editbuf.h
deleted file mode 100644
index 2cac3bb..0000000
--- a/gnu/lib/libg++/include/editbuf.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License.
-
-Written by Per Bothner (bothner@cygnus.com). */
-
-#ifndef _EDITBUF_H
-#define _EDITBUF_H
-#ifdef __GNUG__
-#pragma interface
-#endif
-#include <stdio.h>
-#include <fstream.h>
-
-typedef unsigned long mark_pointer;
-// At some point, it might be nice to parameterize this code
-// in terms of buf_char.
-typedef /*unsigned*/ char buf_char;
-
-// Logical pos from start of buffer (does not count gap).
-typedef long buf_index;
-
-// Pos from start of buffer, possibly including gap_size.
-typedef long buf_offset;
-
-#if 0
-struct buf_cookie {
- FILE *file;
- struct edit_string *str;
- struct buf_cookie *next;
- buf_index tell();
-};
-#endif
-
-struct edit_buffer;
-struct edit_mark;
-
-// A edit_string is defined as the region between the 'start' and 'end' marks.
-// Normally (always?) 'start->insert_before()' should be false,
-// and 'end->insert_before()' should be true.
-
-struct edit_string {
- struct edit_buffer *buffer; // buffer that 'start' and 'end' belong to
- struct edit_mark *start, *end;
- int length() const; // count of buf_chars currently in string
- edit_string(struct edit_buffer *b,
- struct edit_mark *ms, struct edit_mark *me)
- { buffer = b; start = ms; end = me; }
-/* Make a fresh, contiguous copy of the data in STR.
- Assign length of STR to *LENP.
- (Output has extra NUL at out[*LENP].) */
- buf_char *copy_bytes(int *lenp) const;
-// FILE *open_file(char *mode);
- void assign(struct edit_string *src); // copy bytes from src to this
-};
-
-struct edit_streambuf : public streambuf {
- friend edit_buffer;
- edit_string *str;
- edit_streambuf* next; // Chain of edit_streambuf's for a edit_buffer.
- short _mode;
- edit_streambuf(edit_string* bstr, int mode);
- ~edit_streambuf();
- virtual int underflow();
- virtual int overflow(int c = EOF);
- virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
- void flush_to_buffer();
- void flush_to_buffer(edit_buffer* buffer);
- int _inserting;
- int inserting() { return _inserting; }
- void inserting(int i) { _inserting = i; }
-// int delete_chars(int count, char* cut_buf); Not implemented.
- int truncate();
- int is_reading() { return gptr() != NULL; }
- buf_char* current() { return is_reading() ? gptr() : pptr(); }
- void set_current(char *p, int is_reading);
- protected:
- void disconnect_gap_from_file(edit_buffer* buffer);
-};
-
-// A 'edit_mark' indicates a position in a buffer.
-// It is "attached" the text (rather than the offset).
-// There are two kinds of mark, which have different behavior
-// when text is inserted at the mark:
-// If 'insert_before()' is true the mark will be adjusted to be
-// *after* the new text.
-
-struct edit_mark {
- struct edit_mark *chain;
- mark_pointer _pos;
- inline int insert_before() { return _pos & 1; }
- inline unsigned long index_in_buffer(struct edit_buffer *buffer)
- { return _pos >> 1; }
- inline buf_char *ptr(struct edit_buffer *buf);
- buf_index tell();
- edit_mark() { }
- edit_mark(struct edit_string *str, long delta);
- edit_buffer *buffer();
- ~edit_mark();
-};
-
-// A 'edit_buffer' consists of a sequence of buf_chars (the data),
-// a list of edit_marks pointing into the data, and a list of FILEs
-// also pointing into the data.
-// A 'edit_buffer' coerced to a edit_string is the string of
-// all the buf_chars in the buffer.
-
-// This implementation uses a conventional buffer gap (as in Emacs).
-// The gap start is defined by de-referencing a (buf_char**).
-// This is because sometimes a FILE is inserting into the buffer,
-// so rather than having each putc adjust the gap, we use indirection
-// to have the gap be defined as the write pointer of the FILE.
-// (This assumes that putc adjusts a pointer (as in GNU's libc), not an index.)
-
-struct edit_buffer {
- buf_char *data; /* == emacs buffer_text.p1+1 */
- buf_char *_gap_start;
- edit_streambuf* _writer; // If non-NULL, currently writing stream
- inline buf_char *gap_start()
- { return _writer ? _writer->pptr() : _gap_start; }
- buf_offset __gap_end_pos; // size of part 1 + size of gap
- /* int gap; implicit: buf_size - size1 - size2 */
- int buf_size;
- struct edit_streambuf *files;
- struct edit_mark start_mark;
- struct edit_mark end_mark;
- edit_buffer();
- inline buf_offset gap_end_pos() { return __gap_end_pos; }
- inline struct edit_mark *start_marker() { return &start_mark; }
- inline struct edit_mark *end_marker() { return &end_mark; }
-/* these should be protected, ultimately */
- buf_index tell(edit_mark*);
- buf_index tell(buf_char*);
- inline buf_char *gap_end() { return data + gap_end_pos(); }
- inline int gap_size() { return gap_end() - gap_start(); }
- inline int size1() { return gap_start() - data; }
- inline int size2() { return buf_size - gap_end_pos(); }
- inline struct edit_mark * mark_list() { return &start_mark; }
- void make_gap (buf_offset);
- void move_gap (buf_offset pos);
- void move_gap (buf_char *pos) { move_gap(pos - data); }
- void gap_left (int pos);
- void gap_right (int pos);
- void adjust_markers(mark_pointer low, mark_pointer high,
- int amount, buf_char *old_data);
- void delete_range(buf_index from, buf_index to);
- void delete_range(struct edit_mark *start, struct edit_mark *end);
-};
-
-extern buf_char * bstr_copy(struct edit_string *str, int *lenp);
-
-// Convert a edit_mark to a (buf_char*)
-
-inline buf_char *edit_mark::ptr(struct edit_buffer *buf)
- { return buf->data + index_in_buffer(buf); }
-
-inline void edit_streambuf::flush_to_buffer()
-{
- edit_buffer* buffer = str->buffer;
- if (buffer->_writer == this) flush_to_buffer(buffer);
-}
-#endif /* !_EDITBUF_H*/
-
diff --git a/gnu/lib/libg++/include/floatio.h b/gnu/lib/libg++/include/floatio.h
deleted file mode 100644
index 880f807..0000000
--- a/gnu/lib/libg++/include/floatio.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * %W% (Berkeley) %G%
- */
-
-/*
- * Floating point scanf/printf (input/output) definitions.
- */
-
-/* 11-bit exponent (VAX G floating point) is 308 decimal digits */
-#define MAXEXP 308
-/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
-#define MAXFRACT 39
diff --git a/gnu/lib/libg++/include/fstream.h b/gnu/lib/libg++/include/fstream.h
deleted file mode 100644
index 20dfbf2..0000000
--- a/gnu/lib/libg++/include/fstream.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#ifndef _FSTREAM_H
-#define _FSTREAM_H
-#ifdef __GNUG__
-#pragma interface
-#endif
-#include <iostream.h>
-
-class fstreambase : virtual public ios {
- public:
- fstreambase();
- fstreambase(int fd);
- fstreambase(int fd, char *p, int l); /* Deprecated */
- fstreambase(const char *name, int mode, int prot=0664);
- void close();
- filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); }
- void open(const char *name, int mode, int prot=0664);
- int is_open() const { return rdbuf()->is_open(); }
- void setbuf(char *ptr, int len) { rdbuf()->setbuf(ptr, len); }
-#ifdef _STREAM_COMPAT
- int filedesc() { return rdbuf()->fd(); }
- fstreambase& raw() { rdbuf()->setbuf(NULL, 0); return *this; }
-#endif
-};
-
-class ifstream : public fstreambase, public istream {
- public:
- ifstream() : fstreambase() { }
- ifstream(int fd) : fstreambase(fd) { }
- ifstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/
- ifstream(const char *name, int mode=ios::in, int prot=0664)
- : fstreambase(name, mode, prot) { }
- void open(const char *name, int mode=ios::in, int prot=0664)
- { fstreambase::open(name, mode, prot); }
-};
-
-class ofstream : public fstreambase, public ostream {
- public:
- ofstream() : fstreambase() { }
- ofstream(int fd) : fstreambase(fd) { }
- ofstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/
- ofstream(const char *name, int mode=ios::out, int prot=0664)
- : fstreambase(name, mode, prot) { }
- void open(const char *name, int mode=ios::out, int prot=0664)
- { fstreambase::open(name, mode, prot); }
-};
-
-class fstream : public fstreambase, public iostream {
- public:
- fstream() : fstreambase() { }
- fstream(int fd) : fstreambase(fd) { }
- fstream(const char *name, int mode, int prot=0664)
- : fstreambase(name, mode, prot) { }
- fstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/
- void open(const char *name, int mode, int prot=0664)
- { fstreambase::open(name, mode, prot); }
-};
-#endif /*!_FSTREAM_H*/
diff --git a/gnu/lib/libg++/include/indstream.h b/gnu/lib/libg++/include/indstream.h
deleted file mode 100644
index 8047b82..0000000
--- a/gnu/lib/libg++/include/indstream.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License.
-
-Written by Per Bothner (bothner@cygnus.com). */
-
-#ifndef _INDSTREAM_H
-#define _INDSTREAM_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include <iostream.h>
-
-// An indirectbuf is one that forwards all of its I/O requests
-// to another streambuf.
-// All get-related requests are sent to get_stream().
-// All put-related requests are sent to put_stream().
-
-// An indirectbuf can be used to implement Common Lisp
-// synonym-streams and two-way-streams.
-//
-// class synonymbuf : public indirectbuf {
-// Symbol *sym;
-// synonymbuf(Symbol *s) { sym = s; }
-// virtual streambuf *lookup_stream(int mode) {
-// return coerce_to_streambuf(lookup_value(sym)); }
-// };
-
-class indirectbuf : public streambuf {
- protected:
- streambuf *_get_stream; // Optional cache for get_stream().
- streambuf *_put_stream; // Optional cache for put_stream().
- int _delete_flags;
- public:
- streambuf *get_stream()
- { return _get_stream ? _get_stream : lookup_stream(ios::in); }
- streambuf *put_stream()
- { return _put_stream ? _put_stream : lookup_stream(ios::out); }
- virtual streambuf *lookup_stream(int/*mode*/) { return NULL; } // ERROR!
- indirectbuf(streambuf *get=NULL, streambuf *put=NULL, int delete_mode=0);
- virtual ~indirectbuf();
- virtual int xsputn(const char* s, int n);
- virtual int xsgetn(char* s, int n);
- virtual int underflow();
- virtual int overflow(int c = EOF);
- virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
- virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
- virtual int sync();
- virtual int pbackfail(int c);
-};
-
-#endif /* !_INDSTREAM_H */
diff --git a/gnu/lib/libg++/include/iolibio.h b/gnu/lib/libg++/include/iolibio.h
deleted file mode 100644
index 08040fa..0000000
--- a/gnu/lib/libg++/include/iolibio.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "libio.h"
-
-/* These emulate stdio functionality, but with a different name
- (_IO_ungetc instead of ungetc), and using _IO_FILE instead of FILE. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int _IO_fclose __P((_IO_FILE*));
-extern _IO_FILE *_IO_fdopen __P((int, const char*));
-extern int _IO_fflush __P((_IO_FILE*));
-extern int _IO_fgetpos __P((_IO_FILE*, _IO_fpos_t*));
-extern char* _IO_fgets __P((char*, int, _IO_FILE*));
-extern _IO_FILE *_IO_fopen __P((const char*, const char*));
-extern int _IO_fprintf __P((_IO_FILE*, const char*, ...));
-extern int _IO_fputs __P((const char*, _IO_FILE*));
-extern int _IO_fsetpos __P((_IO_FILE*, const _IO_fpos_t *));
-extern long int _IO_ftell __P((_IO_FILE*));
-extern _IO_size_t _IO_fwrite __P((const void*,
- _IO_size_t, _IO_size_t, _IO_FILE*));
-extern char* _IO_gets __P((char*));
-extern void _IO_perror __P((const char*));
-extern int _IO_printf __P((const char*, ...));
-extern int _IO_puts __P((const char*));
-extern int _IO_scanf __P((const char*, ...));
-extern void _IO_setbuffer __P((_IO_FILE *, char*, _IO_size_t));
-extern int _IO_setvbuf __P((_IO_FILE*, char*, int, _IO_size_t));
-extern int _IO_sscanf __P((const char*, const char*, ...));
-extern int _IO_sprintf __P((char *, const char*, ...));
-extern int _IO_ungetc __P((int, _IO_FILE*));
-extern int _IO_vsscanf __P((const char *, const char *, _IO_va_list));
-extern int _IO_vsprintf __P((char*, const char*, _IO_va_list));
-#ifndef _IO_pos_BAD
-#define _IO_pos_BAD ((_IO_fpos_t)(-1))
-#endif
-#define _IO_clearerr(FP) ((FP)->_flags &= ~(_IO_ERR_SEEN|_IO_EOF_SEEN))
-#define _IO_fseek(__fp, __offset, __whence) \
- (_IO_seekoff(__fp, __offset, (_IO_off_t)(__whence)) == _IO_pos_BAD ? EOF : 0)
-#define _IO_rewind(FILE) (void)_IO_seekoff(FILE, 0, 0)
-#define _IO_vprintf(FORMAT, ARGS) _IO_vfprintf(_IO_stdout, FORMAT, ARGS)
-#define _IO_freopen(FILENAME, MODE, FP) \
- (_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE))
-#define _IO_fileno(FP) ((FP)->_fileno)
-extern _IO_FILE* _IO_popen __P((const char*, const char*));
-#define _IO_pclose _IO_fclose
-#define _IO_setbuf(_FP, _BUF) _IO_setbuffer(_FP, _BUF, _IO_BUFSIZ)
-#define _IO_setlinebuf(_FP) _IO_setvbuf(_FP, NULL, 1, 0)
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/gnu/lib/libg++/include/iomanip.h b/gnu/lib/libg++/include/iomanip.h
deleted file mode 100644
index a87e7bf..0000000
--- a/gnu/lib/libg++/include/iomanip.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#ifndef _IOMANIP_H
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _IOMANIP_H
-
-#include <iostream.h>
-
-//-----------------------------------------------------------------------------
-// Parametrized Manipulators as specified by ANSI draft
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// Stream Manipulators
-//-----------------------------------------------------------------------------
-//
-template<class TP> class smanip; // TP = Type Param
-
-template<class TP> class sapp {
- ios& (*_f)(ios&, TP);
-public:
- sapp(ios& (*f)(ios&, TP)) : _f(f) {}
- //
- smanip<TP> operator()(TP a)
- { return smanip<TP>(_f, a); }
-};
-
-template <class TP> class smanip {
- ios& (*_f)(ios&, TP);
- TP _a;
-public:
- smanip(ios& (*f)(ios&, TP), TP a) : _f(f), _a(a) {}
- //
- friend
- istream& operator>>(istream& i, const smanip<TP>& m);
- friend
- ostream& operator<<(ostream& o, const smanip<TP>& m);
-};
-
-#ifdef __GNUG__
-extern template class smanip<int>;
-extern template class smanip<ios::fmtflags>;
-#endif
-
-template<class TP>
-inline istream& operator>>(istream& i, const smanip<TP>& m)
- { (*m._f)(i, m._a); return i; }
-
-template<class TP>
-inline ostream& operator<<(ostream& o, const smanip<TP>& m)
- { (*m._f)(o, m._a); return o;}
-
-#ifdef __GNUG__
-extern template istream& operator>>(istream&, const smanip<int>&);
-extern template istream& operator>>(istream&, const smanip<ios::fmtflags>&);
-extern template ostream& operator<<(ostream&, const smanip<int>&);
-extern template ostream& operator<<(ostream&, const smanip<ios::fmtflags>&);
-#endif
-
-//-----------------------------------------------------------------------------
-// Input-Stream Manipulators
-//-----------------------------------------------------------------------------
-//
-template<class TP> class imanip;
-
-template<class TP> class iapp {
- istream& (*_f)(istream&, TP);
-public:
- iapp(istream& (*f)(istream&,TP)) : _f(f) {}
- //
- imanip<TP> operator()(TP a)
- { return imanip<TP>(_f, a); }
-};
-
-template <class TP> class imanip {
- istream& (*_f)(istream&, TP);
- TP _a;
-public:
- imanip(istream& (*f)(istream&, TP), TP a) : _f(f), _a(a) {}
- //
- friend
- istream& operator>>(istream& i, const imanip<TP>& m)
- { return (*m._f)( i, m._a); }
-};
-
-
-//-----------------------------------------------------------------------------
-// Output-Stream Manipulators
-//-----------------------------------------------------------------------------
-//
-template<class TP> class omanip;
-
-template<class TP> class oapp {
- ostream& (*_f)(ostream&, TP);
-public:
- oapp(ostream& (*f)(ostream&,TP)) : _f(f) {}
- //
- omanip<TP> operator()(TP a)
- { return omanip<TP>(_f, a); }
-};
-
-template <class TP> class omanip {
- ostream& (*_f)(ostream&, TP);
- TP _a;
-public:
- omanip(ostream& (*f)(ostream&, TP), TP a) : _f(f), _a(a) {}
- //
- friend
- ostream& operator<<(ostream& o, const omanip<TP>& m)
- { return (*m._f)(o, m._a); }
-};
-
-
-//-----------------------------------------------------------------------------
-// Available Manipulators
-//-----------------------------------------------------------------------------
-
-//
-// Macro to define an iomanip function, with one argument
-// The underlying function is `__iomanip_<name>'
-//
-#define __DEFINE_IOMANIP_FN1(type,param,function) \
- extern ios& __iomanip_##function (ios&, param); \
- inline type<param> function (param n) \
- { return type<param> (__iomanip_##function, n); }
-
-__DEFINE_IOMANIP_FN1( smanip, int, setbase)
-__DEFINE_IOMANIP_FN1( smanip, int, setfill)
-__DEFINE_IOMANIP_FN1( smanip, int, setprecision)
-__DEFINE_IOMANIP_FN1( smanip, int, setw)
-
-__DEFINE_IOMANIP_FN1( smanip, ios::fmtflags, resetiosflags)
-__DEFINE_IOMANIP_FN1( smanip, ios::fmtflags, setiosflags)
-
-#endif /*!_IOMANIP_H*/
diff --git a/gnu/lib/libg++/include/iostream.h b/gnu/lib/libg++/include/iostream.h
deleted file mode 100644
index 4802b37..0000000
--- a/gnu/lib/libg++/include/iostream.h
+++ /dev/null
@@ -1,239 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#ifndef _IOSTREAM_H
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _IOSTREAM_H
-
-#include <streambuf.h>
-
-class istream; class ostream;
-typedef ios& (*__manip)(ios&);
-typedef istream& (*__imanip)(istream&);
-typedef ostream& (*__omanip)(ostream&);
-
-extern istream& ws(istream& ins);
-extern ostream& flush(ostream& outs);
-extern ostream& endl(ostream& outs);
-extern ostream& ends(ostream& outs);
-
-class ostream : virtual public ios
-{
- // NOTE: If fields are changed, you must fix _fake_ostream in stdstreams.C!
- void do_osfx();
- public:
- ostream() { }
- ostream(streambuf* sb, ostream* tied=NULL);
- int opfx() {
- if (!good()) return 0; else { if (_tie) _tie->flush(); return 1;} }
- void osfx() { if (flags() & (ios::unitbuf|ios::stdio))
- do_osfx(); }
- ostream& flush();
- ostream& put(char c) { _strbuf->sputc(c); return *this; }
-#ifdef _STREAM_COMPAT
- /* Temporary binary compatibility. REMOVE IN NEXT RELEASE. */
- ostream& put(unsigned char c) { return put((char)c); }
- ostream& put(signed char c) { return put((char)c); }
-#endif
- ostream& write(const char *s, int n);
- ostream& write(const unsigned char *s, int n) { return write((const char*)s, n);}
- ostream& write(const signed char *s, int n) { return write((const char*)s, n);}
- ostream& write(const void *s, int n) { return write((const char*)s, n);}
- ostream& seekp(streampos);
- ostream& seekp(streamoff, _seek_dir);
- streampos tellp();
- ostream& form(const char *format ...);
- ostream& vform(const char *format, _IO_va_list args);
-
- ostream& operator<<(char c);
- ostream& operator<<(unsigned char c) { return (*this) << (char)c; }
- ostream& operator<<(signed char c) { return (*this) << (char)c; }
- ostream& operator<<(const char *s);
- ostream& operator<<(const unsigned char *s)
- { return (*this) << (const char*)s; }
- ostream& operator<<(const signed char *s)
- { return (*this) << (const char*)s; }
- ostream& operator<<(const void *p);
- ostream& operator<<(int n);
- ostream& operator<<(unsigned int n);
- ostream& operator<<(long n);
- ostream& operator<<(unsigned long n);
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
- ostream& operator<<(long long n);
- ostream& operator<<(unsigned long long n);
-#endif
- ostream& operator<<(short n) {return operator<<((int)n);}
- ostream& operator<<(unsigned short n) {return operator<<((unsigned int)n);}
-#if _G_HAVE_BOOL
- ostream& operator<<(bool b) { return operator<<((int)b); }
-#endif
- ostream& operator<<(double n);
- ostream& operator<<(float n) { return operator<<((double)n); }
- ostream& operator<<(long double n) { return operator<<((double)n); }
- ostream& operator<<(__omanip func) { return (*func)(*this); }
- ostream& operator<<(__manip func) {(*func)(*this); return *this;}
- ostream& operator<<(streambuf*);
-#ifdef _STREAM_COMPAT
- streambuf* ostreambuf() const { return _strbuf; }
-#endif
-};
-
-class istream : virtual public ios
-{
- // NOTE: If fields are changed, you must fix _fake_istream in stdstreams.C!
-protected:
- _IO_size_t _gcount;
-
- int _skip_ws();
- public:
- istream() { _gcount = 0; }
- istream(streambuf* sb, ostream*tied=NULL);
- istream& get(char* ptr, int len, char delim = '\n');
- istream& get(unsigned char* ptr, int len, char delim = '\n')
- { return get((char*)ptr, len, delim); }
- istream& get(char& c);
- istream& get(unsigned char& c) { return get((char&)c); }
- istream& getline(char* ptr, int len, char delim = '\n');
- istream& getline(unsigned char* ptr, int len, char delim = '\n')
- { return getline((char*)ptr, len, delim); }
- istream& get(signed char& c) { return get((char&)c); }
- istream& get(signed char* ptr, int len, char delim = '\n')
- { return get((char*)ptr, len, delim); }
- istream& getline(signed char* ptr, int len, char delim = '\n')
- { return getline((char*)ptr, len, delim); }
- istream& read(char *ptr, int n);
- istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); }
- istream& read(signed char *ptr, int n) { return read((char*)ptr, n); }
- istream& read(void *ptr, int n) { return read((char*)ptr, n); }
- istream& get(streambuf& sb, char delim = '\n');
- istream& gets(char **s, char delim = '\n');
- int ipfx(int need) {
- if (!good()) { set(ios::failbit); return 0; }
- else {
- if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
- if (!need && (flags() & ios::skipws)) return _skip_ws();
- else return 1;
- }
- }
- int ipfx0() { // Optimized version of ipfx(0).
- if (!good()) { set(ios::failbit); return 0; }
- else {
- if (_tie) _tie->flush();
- if (flags() & ios::skipws) return _skip_ws();
- else return 1;
- }
- }
- int ipfx1() { // Optimized version of ipfx(1).
- if (!good()) { set(ios::failbit); return 0; }
- else {
- if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
- return 1;
- }
- }
- void isfx() { }
- int get() { if (!ipfx1()) return EOF;
- else { int ch = _strbuf->sbumpc();
- if (ch == EOF) set(ios::eofbit);
- return ch;
- } }
- int peek();
- _IO_size_t gcount() { return _gcount; }
- istream& ignore(int n=1, int delim = EOF);
- istream& seekg(streampos);
- istream& seekg(streamoff, _seek_dir);
- streampos tellg();
- istream& putback(char ch) {
- if (good() && _strbuf->sputbackc(ch) == EOF) clear(ios::badbit);
- return *this;}
- istream& unget() {
- if (good() && _strbuf->sungetc() == EOF) clear(ios::badbit);
- return *this;}
- istream& scan(const char *format ...);
- istream& vscan(const char *format, _IO_va_list args);
-#ifdef _STREAM_COMPAT
- istream& unget(char ch) { return putback(ch); }
- int skip(int i);
- streambuf* istreambuf() const { return _strbuf; }
-#endif
-
- istream& operator>>(char*);
- istream& operator>>(unsigned char* p) { return operator>>((char*)p); }
- istream& operator>>(signed char*p) { return operator>>((char*)p); }
- istream& operator>>(char& c);
- istream& operator>>(unsigned char& c) {return operator>>((char&)c);}
- istream& operator>>(signed char& c) {return operator>>((char&)c);}
- istream& operator>>(int&);
- istream& operator>>(long&);
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
- istream& operator>>(long long&);
- istream& operator>>(unsigned long long&);
-#endif
- istream& operator>>(short&);
- istream& operator>>(unsigned int&);
- istream& operator>>(unsigned long&);
- istream& operator>>(unsigned short&);
-#if _G_HAVE_BOOL
- istream& operator>>(bool&);
-#endif
- istream& operator>>(float&);
- istream& operator>>(double&);
- istream& operator>>(long double&);
- istream& operator>>( __manip func) {(*func)(*this); return *this;}
- istream& operator>>(__imanip func) { return (*func)(*this); }
- istream& operator>>(streambuf*);
-};
-
-class iostream : public istream, public ostream
-{
- public:
- iostream() { }
- iostream(streambuf* sb, ostream*tied=NULL);
-};
-
-class _IO_istream_withassign : public istream {
-public:
- _IO_istream_withassign& operator=(istream&);
-};
-
-class _IO_ostream_withassign : public ostream {
-public:
- _IO_ostream_withassign& operator=(ostream&);
-};
-
-extern _IO_istream_withassign cin;
-// clog->rdbuf() == cerr->rdbuf()
-extern _IO_ostream_withassign cout, cerr, clog;
-
-struct Iostream_init { } ; // Compatibility hack for AT&T library.
-
-inline ios& dec(ios& i)
-{ i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; }
-inline ios& hex(ios& i)
-{ i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; }
-inline ios& oct(ios& i)
-{ i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }
-
-#endif /*!_IOSTREAM_H*/
diff --git a/gnu/lib/libg++/include/iostreamP.h b/gnu/lib/libg++/include/iostreamP.h
deleted file mode 100644
index e24c93f..0000000
--- a/gnu/lib/libg++/include/iostreamP.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "streambuf.h"
-#include "libioP.h"
-
-inline _IO_seekflags
-convert_to_seekflags(int dir, int mode)
-{
- return (_IO_seekflags)((int)dir
- | (mode & ios::in ? _IO_seek_set : _IO_seek_not_in)
- | (mode & ios::out ? _IO_seek_set : _IO_seek_not_out));
-}
diff --git a/gnu/lib/libg++/include/libiberty.h b/gnu/lib/libg++/include/libiberty.h
deleted file mode 100644
index 0a71c52..0000000
--- a/gnu/lib/libg++/include/libiberty.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* Function declarations for libiberty.
- Written by Cygnus Support, 1994.
-
- The libiberty library provides a number of functions which are
- missing on some operating systems. We do not declare those here,
- to avoid conflicts with the system header files on operating
- systems that do support those functions. In this file we only
- declare those functions which are specific to libiberty. */
-
-#ifndef LIBIBERTY_H
-#define LIBIBERTY_H
-
-#include "ansidecl.h"
-
-/* Build an argument vector from a string. Allocates memory using
- malloc. Use freeargv to free the vector. */
-
-extern char **buildargv PARAMS ((char *));
-
-/* Free a vector returned by buildargv. */
-
-extern void freeargv PARAMS ((char **));
-
-/* Return the last component of a path name. */
-
-extern char *basename PARAMS ((char *));
-
-/* Concatenate an arbitrary number of strings, up to (char *) NULL.
- Allocates memory using xmalloc. */
-
-extern char *concat PARAMS ((const char *, ...));
-
-/* Check whether two file descriptors refer to the same file. */
-
-extern int fdmatch PARAMS ((int fd1, int fd2));
-
-/* Get the amount of time the process has run, in microseconds. */
-
-extern long get_run_time PARAMS ((void));
-
-/* Allocate memory filled with spaces. Allocates using malloc. */
-
-extern const char *spaces PARAMS ((int count));
-
-/* Return the maximum error number for which strerror will return a
- string. */
-
-extern int errno_max PARAMS ((void));
-
-/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
- "EINVAL"). */
-
-extern const char *strerrno PARAMS ((int));
-
-/* Given the name of an errno value, return the value. */
-
-extern int strtoerrno PARAMS ((const char *));
-
-/* Return the maximum signal number for which strsignal will return a
- string. */
-
-extern int signo_max PARAMS ((void));
-
-/* Return a signal message string for a signal number
- (e.g., strsignal (SIGHUP) returns something like "Hangup"). */
-/* This is commented out as it can conflict with one in system headers.
- We still document its existence though. */
-
-/*extern const char *strsignal PARAMS ((int));*/
-
-/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
- "SIGHUP"). */
-
-extern const char *strsigno PARAMS ((int));
-
-/* Given the name of a signal, return its number. */
-
-extern int strtosigno PARAMS ((const char *));
-
-/* Register a function to be run by xexit. Returns 0 on success. */
-
-extern int xatexit PARAMS ((void (*fn) (void)));
-
-/* Exit, calling all the functions registered with xatexit. */
-
-#ifndef __GNUC__
-extern void xexit PARAMS ((int status));
-#else
-typedef void libiberty_voidfn PARAMS ((int status));
-__volatile__ libiberty_voidfn xexit;
-#endif
-
-/* Set the program name used by xmalloc. */
-
-extern void xmalloc_set_program_name PARAMS ((const char *));
-
-/* Allocate memory without fail. If malloc fails, this will print a
- message to stderr (using the name set by xmalloc_set_program_name,
- if any) and then call xexit.
-
- FIXME: We do not declare the parameter type (size_t) in order to
- avoid conflicts with other declarations of xmalloc that exist in
- programs which use libiberty. */
-
-extern PTR xmalloc ();
-
-/* Reallocate memory without fail. This works like xmalloc.
-
- FIXME: We do not declare the parameter types for the same reason as
- xmalloc. */
-
-extern PTR xrealloc ();
-
-#endif /* ! defined (LIBIBERTY_H) */
diff --git a/gnu/lib/libg++/include/libio.h b/gnu/lib/libg++/include/libio.h
deleted file mode 100644
index f00b730..0000000
--- a/gnu/lib/libg++/include/libio.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* This is part of the iostream library.
- Copyright (C) 1991, 1992 Per Bothner. */
-
-#ifndef _IO_STDIO_H
-#define _IO_STDIO_H
-
-#if 1
-#include <_G_config.h>
-#define _IO_pos_t _G_fpos_t /* obsolete */
-#define _IO_fpos_t _G_fpos_t
-#define _IO_size_t _G_size_t
-#define _IO_ssize_t _G_ssize_t
-#define _IO_off_t _G_off_t
-#define _IO_pid_t _G_pid_t
-#define _IO_uid_t _G_uid_t
-#define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT
-#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
-#define _IO_BUFSIZ _G_BUFSIZ
-#define _IO_va_list _G_va_list
-
-#ifdef _G_NEED_STDARG_H
-/* This define avoids name pollution if we're using GNU stdarg.h */
-#define __need___va_list
-#include <stdarg.h>
-#ifdef __GNUC_VA_LIST
-#undef _IO_va_list
-#define _IO_va_list __gnuc_va_list
-#endif /* __GNUC_VA_LIST */
-#endif
-
-#else
-#include <_IO_config.h>
-typedef _IO_fpos_t _IO_pos_t;
-#endif
-
-#ifndef __P
-#ifdef __STDC__
-#define __P(paramlist) paramlist
-#else
-#define __P(paramlist) ()
-#endif
-#endif /*!__P*/
-
-/* For backward compatibility */
-#ifndef _PARAMS
-#define _PARAMS(paramlist) __P(paramlist)
-#endif /*!_PARAMS*/
-
-#ifndef __STDC__
-#define const
-#endif
-#define _IO_USE_DTOA
-
-#if 0
-#ifdef _IO_NEED_STDARG_H
-#include <stdarg.h>
-#endif
-#endif
-
-#ifndef EOF
-#define EOF (-1)
-#endif
-#ifndef NULL
-#if !defined(__cplusplus) || defined(__GNUC__)
-#define NULL ((void*)0)
-#else
-#define NULL (0)
-#endif
-#endif
-
-#define _IOS_INPUT 1
-#define _IOS_OUTPUT 2
-#define _IOS_ATEND 4
-#define _IOS_APPEND 8
-#define _IOS_TRUNC 16
-#define _IOS_NOCREATE 32
-#define _IOS_NOREPLACE 64
-#define _IOS_BIN 128
-
-/* Magic numbers and bits for the _flags field.
- The magic numbers use the high-order bits of _flags;
- the remaining bits are abailable for variable flags.
- Note: The magic numbers must all be negative if stdio
- emulation is desired. */
-
-#define _IO_MAGIC 0xFBAD0000 /* Magic number */
-#define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */
-#define _IO_MAGIC_MASK 0xFFFF0000
-#define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */
-#define _IO_UNBUFFERED 2
-#define _IO_NO_READS 4 /* Reading not allowed */
-#define _IO_NO_WRITES 8 /* Writing not allowd */
-#define _IO_EOF_SEEN 0x10
-#define _IO_ERR_SEEN 0x20
-#define _IO_DELETE_DONT_CLOSE 0x40
-#define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/
-#define _IO_IN_BACKUP 0x100
-#define _IO_LINE_BUF 0x200
-#define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */
-#define _IO_CURRENTLY_PUTTING 0x800
-#define _IO_IS_APPENDING 0x1000
-#define _IO_IS_FILEBUF 0x2000
-
-/* These are "formatting flags" matching the iostream fmtflags enum values. */
-#define _IO_SKIPWS 01
-#define _IO_LEFT 02
-#define _IO_RIGHT 04
-#define _IO_INTERNAL 010
-#define _IO_DEC 020
-#define _IO_OCT 040
-#define _IO_HEX 0100
-#define _IO_SHOWBASE 0200
-#define _IO_SHOWPOINT 0400
-#define _IO_UPPERCASE 01000
-#define _IO_SHOWPOS 02000
-#define _IO_SCIENTIFIC 04000
-#define _IO_FIXED 010000
-#define _IO_UNITBUF 020000
-#define _IO_STDIO 040000
-#define _IO_DONT_CLOSE 0100000
-
-/* A streammarker remembers a position in a buffer. */
-
-struct _IO_jump_t; struct _IO_FILE;
-
-struct _IO_marker {
- struct _IO_marker *_next;
- struct _IO_FILE *_sbuf;
- /* If _pos >= 0
- it points to _buf->Gbase()+_pos. FIXME comment */
- /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */
- int _pos;
-#if 0
- void set_streampos(streampos sp) { _spos = sp; }
- void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }
- public:
- streammarker(streambuf *sb);
- ~streammarker();
- int saving() { return _spos == -2; }
- int delta(streammarker&);
- int delta();
-#endif
-};
-
-struct _IO_FILE {
- int _flags; /* High-order word is _IO_MAGIC; rest is flags. */
-#define _IO_file_flags _flags
-
- /* The following pointers correspond to the C++ streambuf protocol. */
- char* _IO_read_ptr; /* Current read pointer */
- char* _IO_read_end; /* End of get area. */
- char* _IO_read_base; /* Start of putback+get area. */
- char* _IO_write_base; /* Start of put area. */
- char* _IO_write_ptr; /* Current put pointer. */
- char* _IO_write_end; /* End of put area. */
- char* _IO_buf_base; /* Start of reserve area. */
- char* _IO_buf_end; /* End of reserve area. */
- /* The following fields are used to support backing up and undo. */
- char *_IO_save_base; /* Pointer to start of non-current get area. */
- char *_IO_backup_base; /* Pointer to first valid character of backup area */
- char *_IO_save_end; /* Pointer to end of non-current get area. */
-
- struct _IO_marker *_markers;
-
- struct _IO_FILE *_chain;
-
- struct _IO_jump_t *_jumps; /* Jump table */
-
- int _fileno;
- int _blksize;
- _IO_off_t _offset;
-
-#define __HAVE_COLUMN /* temporary */
- /* 1+column number of pbase(); 0 is unknown. */
- unsigned short _cur_column;
- char _unused;
- char _shortbuf[1];
-
- /* char* _save_gptr; char* _save_egptr; */
-};
-
-#ifndef __cplusplus
-typedef struct _IO_FILE _IO_FILE;
-#endif
-
-struct _IO_FILE_plus;
-extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_;
-#define _IO_stdin ((_IO_FILE*)(&_IO_stdin_))
-#define _IO_stdout ((_IO_FILE*)(&_IO_stdout_))
-#define _IO_stderr ((_IO_FILE*)(&_IO_stderr_))
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int __underflow __P((_IO_FILE*));
-extern int __uflow __P((_IO_FILE*));
-extern int __overflow __P((_IO_FILE*, int));
-
-extern unsigned __adjust_column __P((unsigned start, const char *line, int count));
-
-#define _IO_getc(_fp) \
- ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow(_fp) \
- : *(unsigned char*)(_fp)->_IO_read_ptr++)
-#define _IO_peekc(_fp) \
- ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \
- && __underflow(_fp) == EOF ? EOF \
- : *(unsigned char*)(_fp)->_IO_read_ptr)
-
-#define _IO_putc(_ch, _fp) \
- (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
- ? __overflow(_fp, (unsigned char)(_ch)) \
- : (unsigned char)(*(_fp)->_IO_write_ptr++ = (_ch)))
-
-#define _IO_feof(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
-#define _IO_ferror(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
-
-/* This one is for Emacs. */
-#define _IO_PENDING_OUTPUT_COUNT(_fp) \
- ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)
-
-extern int _IO_vfscanf __P((_IO_FILE*, const char*, _IO_va_list, int*));
-extern int _IO_vfprintf __P((_IO_FILE*, const char*, _IO_va_list));
-extern _IO_ssize_t _IO_padn __P((_IO_FILE *, int, _IO_ssize_t));
-extern _IO_size_t _IO_sgetn __P((_IO_FILE *, void*, _IO_size_t));
-
-extern void _IO_free_backup_area __P((_IO_FILE*));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _IO_STDIO_H */
diff --git a/gnu/lib/libg++/include/libioP.h b/gnu/lib/libg++/include/libioP.h
deleted file mode 100644
index 074b9d7..0000000
--- a/gnu/lib/libg++/include/libioP.h
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
-#include "iolibio.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum _IO_seekflags_ {
- _IO_seek_set = 0,
- _IO_seek_cur = 1,
- _IO_seek_end = 2,
-
- /* These bits are ignored unless the _IO_FILE has independent
- read and write positions. */
- _IO_seek_not_in = 4, /* Don't move read posistion. */
- _IO_seek_not_out = 8, /* Don't move write posistion. */
- _IO_seek_pos_ignored = 16 /* Result is ignored (except EOF) */
-} _IO_seekflags;
-
-typedef int (*_IO_overflow_t) __P((_IO_FILE*, int));
-typedef int (*_IO_underflow_t) __P((_IO_FILE*));
-typedef _IO_size_t (*_IO_xsputn_t) __P((_IO_FILE*,const void*,_IO_size_t));
-typedef _IO_size_t (*_IO_xsgetn_t) __P((_IO_FILE*, void*, _IO_size_t));
-typedef _IO_ssize_t (*_IO_read_t) __P((_IO_FILE*, void*, _IO_ssize_t));
-typedef _IO_ssize_t (*_IO_write_t) __P((_IO_FILE*,const void*,_IO_ssize_t));
-typedef int (*_IO_stat_t) __P((_IO_FILE*, void*));
-typedef _IO_fpos_t (*_IO_seek_t) __P((_IO_FILE*, _IO_off_t, int));
-typedef int (*_IO_doallocate_t) __P((_IO_FILE*));
-typedef int (*_IO_pbackfail_t) __P((_IO_FILE*, int));
-typedef int (*_IO_setbuf_t) __P((_IO_FILE*, char *, _IO_ssize_t));
-typedef int (*_IO_sync_t) __P((_IO_FILE*));
-typedef void (*_IO_finish_t) __P((_IO_FILE*)); /* finalize */
-typedef int (*_IO_close_t) __P((_IO_FILE*)); /* finalize */
-typedef _IO_fpos_t (*_IO_seekoff_t) __P((_IO_FILE*, _IO_off_t, _IO_seekflags));
-
-/* The _IO_seek_cur and _IO_seek_end options are not allowed. */
-typedef _IO_fpos_t (*_IO_seekpos_t) __P((_IO_FILE*, _IO_fpos_t, _IO_seekflags));
-
-struct _IO_jump_t {
- _IO_overflow_t __overflow;
- _IO_underflow_t __underflow;
- _IO_xsputn_t __xsputn;
- _IO_xsgetn_t __xsgetn;
- _IO_read_t __read;
- _IO_write_t __write;
- _IO_doallocate_t __doallocate;
- _IO_pbackfail_t __pbackfail;
- _IO_setbuf_t __setbuf;
- _IO_sync_t __sync;
- _IO_finish_t __finish;
- _IO_close_t __close;
- _IO_stat_t __stat;
- _IO_seek_t __seek;
- _IO_seekoff_t __seekoff;
- _IO_seekpos_t __seekpos;
- _IO_underflow_t __uflow;
-#if 0
- get_column;
- set_column;
-#endif
-};
-
-/* We always allocate an extra word following an _IO_FILE.
- This is for compatibility with C++ streambuf; the word can
- be used to smash to a pointer to a virtual function table. */
-
-struct _IO_FILE_plus {
- _IO_FILE file;
- const void *vtable;
-};
-
-/* Generic functions */
-
-extern _IO_fpos_t _IO_seekoff __P((_IO_FILE*, _IO_off_t, _IO_seekflags));
-extern _IO_fpos_t _IO_seekpos __P((_IO_FILE*, _IO_fpos_t, _IO_seekflags));
-
-extern int _IO_switch_to_get_mode __P((_IO_FILE*));
-extern void _IO_init __P((_IO_FILE*, int));
-extern int _IO_sputbackc __P((_IO_FILE*, int));
-extern int _IO_sungetc __P((_IO_FILE*));
-extern void _IO_un_link __P((_IO_FILE*));
-extern void _IO_link_in __P((_IO_FILE *));
-extern void _IO_doallocbuf __P((_IO_FILE*));
-extern void _IO_unsave_markers __P((_IO_FILE*));
-extern void _IO_setb __P((_IO_FILE*, char*, char*, int));
-extern unsigned _IO_adjust_column __P((unsigned, const char *, int));
-#define _IO_sputn(__fp, __s, __n) (__fp->_jumps->__xsputn(__fp, __s, __n))
-
-/* Marker-related function. */
-
-extern void _IO_init_marker __P((struct _IO_marker *, _IO_FILE *));
-extern void _IO_remove_marker __P((struct _IO_marker*));
-extern int _IO_marker_difference __P((struct _IO_marker *, struct _IO_marker *));
-extern int _IO_marker_delta __P((struct _IO_marker *));
-extern int _IO_seekmark __P((_IO_FILE *, struct _IO_marker *, int));
-
-/* Default jumptable functions. */
-
-extern int _IO_default_underflow __P((_IO_FILE*));
-extern int _IO_default_uflow _PARAMS((_IO_FILE*));
-extern int _IO_default_doallocate __P((_IO_FILE*));
-extern void _IO_default_finish __P((_IO_FILE *));
-extern int _IO_default_pbackfail __P((_IO_FILE*, int));
-extern int _IO_default_setbuf __P((_IO_FILE *, char*, _IO_ssize_t));
-extern _IO_size_t _IO_default_xsputn __P((_IO_FILE *, const void*, _IO_size_t));
-extern _IO_size_t _IO_default_xsgetn __P((_IO_FILE *, void*, _IO_size_t));
-extern _IO_fpos_t _IO_default_seekoff __P((_IO_FILE*, _IO_off_t, _IO_seekflags));
-extern _IO_fpos_t _IO_default_seekpos __P((_IO_FILE*, _IO_fpos_t, _IO_seekflags));
-extern _IO_ssize_t _IO_default_write __P((_IO_FILE*,const void*,_IO_ssize_t));
-extern _IO_ssize_t _IO_default_read __P((_IO_FILE*, void*, _IO_ssize_t));
-extern int _IO_default_stat __P((_IO_FILE*, void*));
-extern _IO_fpos_t _IO_default_seek __P((_IO_FILE*, _IO_off_t, int));
-extern int _IO_default_sync __P((_IO_FILE*));
-#define _IO_default_close ((_IO_close_t)_IO_default_sync)
-
-extern struct _IO_jump_t _IO_file_jumps;
-extern struct _IO_jump_t _IO_streambuf_jumps;
-extern struct _IO_jump_t _IO_proc_jumps;
-extern struct _IO_jump_t _IO_str_jumps;
-extern int _IO_do_write __P((_IO_FILE*, const char*, _IO_size_t));
-extern int _IO_flush_all __P((void));
-extern void _IO_cleanup __P((void));
-extern void _IO_flush_all_linebuffered __P((void));
-
-#define _IO_do_flush(_f) \
- _IO_do_write(_f, (_f)->_IO_write_base, \
- (_f)->_IO_write_ptr-(_f)->_IO_write_base)
-#define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING)
-#define _IO_mask_flags(fp, f, mask) \
- ((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask)))
-#define _IO_setg(fp, eb, g, eg) ((fp)->_IO_read_base = (eb),\
- (fp)->_IO_read_ptr = (g), (fp)->_IO_read_end = (eg))
-#define _IO_setp(__fp, __p, __ep) \
- ((__fp)->_IO_write_base = (__fp)->_IO_write_ptr = __p, (__fp)->_IO_write_end = (__ep))
-#define _IO_have_backup(fp) ((fp)->_IO_save_base != NULL)
-#define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP)
-#define _IO_have_markers(fp) ((fp)->_markers != NULL)
-#define _IO_blen(p) ((fp)->_IO_buf_end - (fp)->_IO_buf_base)
-
-/* Jumptable functions for files. */
-
-extern int _IO_file_doallocate __P((_IO_FILE*));
-extern int _IO_file_setbuf __P((_IO_FILE *, char*, _IO_ssize_t));
-extern _IO_fpos_t _IO_file_seekoff __P((_IO_FILE*, _IO_off_t, _IO_seekflags));
-extern _IO_size_t _IO_file_xsputn __P((_IO_FILE*,const void*,_IO_size_t));
-extern int _IO_file_stat __P((_IO_FILE*, void*));
-extern int _IO_file_close __P((_IO_FILE*));
-extern int _IO_file_underflow __P((_IO_FILE *));
-extern int _IO_file_overflow __P((_IO_FILE *, int));
-#define _IO_file_is_open(__fp) ((__fp)->_fileno >= 0)
-extern void _IO_file_init __P((_IO_FILE*));
-extern _IO_FILE* _IO_file_attach __P((_IO_FILE*, int));
-extern _IO_FILE* _IO_file_fopen __P((_IO_FILE*, const char*, const char*));
-extern _IO_ssize_t _IO_file_write __P((_IO_FILE*,const void*,_IO_ssize_t));
-extern _IO_ssize_t _IO_file_read __P((_IO_FILE*, void*, _IO_ssize_t));
-extern int _IO_file_sync __P((_IO_FILE*));
-extern int _IO_file_close_it __P((_IO_FILE*));
-extern _IO_fpos_t _IO_file_seek __P((_IO_FILE *, _IO_off_t, int));
-extern void _IO_file_finish __P((_IO_FILE*));
-
-/* Other file functions. */
-extern _IO_FILE* _IO_file_attach __P((_IO_FILE *, int));
-
-/* Jumptable functions for proc_files. */
-extern _IO_FILE* _IO_proc_open __P((_IO_FILE*, const char*, const char *));
-extern int _IO_proc_close __P((_IO_FILE*));
-
-/* Jumptable functions for strfiles. */
-extern int _IO_str_underflow __P((_IO_FILE*));
-extern int _IO_str_overflow __P((_IO_FILE *, int));
-extern int _IO_str_pbackfail __P((_IO_FILE*, int));
-extern _IO_fpos_t _IO_str_seekoff __P((_IO_FILE*,_IO_off_t,_IO_seekflags));
-
-/* Other strfile functions */
-extern void _IO_str_init_static __P((_IO_FILE *, char*, int, char*));
-extern void _IO_str_init_readonly __P((_IO_FILE *, const char*, int));
-extern _IO_ssize_t _IO_str_count __P ((_IO_FILE*));
-
-extern _IO_size_t _IO_getline __P((_IO_FILE*,char*,_IO_size_t,int,int));
-extern _IO_ssize_t _IO_getdelim __P((char**, _IO_size_t*, int, _IO_FILE*));
-extern double _IO_strtod __P((const char *, char **));
-extern char * _IO_dtoa __P((double __d, int __mode, int __ndigits,
- int *__decpt, int *__sign, char **__rve));
-extern int _IO_outfloat __P((double __value, _IO_FILE *__sb, int __type,
- int __width, int __precision, int __flags,
- int __sign_mode, int __fill));
-
-extern _IO_FILE *_IO_list_all;
-extern void (*_IO_cleanup_registration_needed) __P ((void));
-
-#ifndef EOF
-#define EOF (-1)
-#endif
-#ifndef NULL
-#if !defined(__cplusplus) || defined(__GNUC__)
-#define NULL ((void*)0)
-#else
-#define NULL (0)
-#endif
-#endif
-
-#define FREE_BUF(_B) free(_B)
-#define ALLOC_BUF(_S) (char*)malloc(_S)
-
-#ifndef OS_FSTAT
-#define OS_FSTAT fstat
-#endif
-struct stat;
-extern _IO_ssize_t _IO_read __P((int, void*, _IO_size_t));
-extern _IO_ssize_t _IO_write __P((int, const void*, _IO_size_t));
-extern _IO_off_t _IO_lseek __P((int, _IO_off_t, int));
-extern int _IO_close __P((int));
-extern int _IO_fstat __P((int, struct stat *));
-
-/* Operations on _IO_fpos_t.
- Normally, these are trivial, but we provide hooks for configurations
- where an _IO_fpos_t is a struct.
- Note that _IO_off_t must be an integral type. */
-
-/* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */
-#ifndef _IO_pos_BAD
-#define _IO_pos_BAD ((_IO_fpos_t)(-1))
-#endif
-/* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */
-#ifndef _IO_pos_as_off
-#define _IO_pos_as_off(__pos) ((_IO_off_t)(__pos))
-#endif
-/* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */
-#ifndef _IO_pos_adjust
-#define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta))
-#endif
-/* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */
-#ifndef _IO_pos_0
-#define _IO_pos_0 ((_IO_fpos_t)0)
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-/* check following! */
-#define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \
- { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, &_IO_file_jumps, FD}
-
-/* Define builtinbuf_vtable as a name for the virtual function table
- of the builtinbuf class. */
-#if !defined(builtinbuf_vtable) && defined(__cplusplus)
-#ifdef __GNUC__
-extern char builtinbuf_vtable[]
- asm (_G_VTABLE_LABEL_PREFIX
-#if _G_VTABLE_LABEL_HAS_LENGTH
- "10"
-#endif
- "builtinbuf");
-#else /* !__GNUC__ */
-#if _G_VTABLE_LABEL_HAS_LENGTH
-#define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf
-#else
-#define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf
-#endif
-extern char builtinbuf_vtable[];
-#endif /* !__GNUC__ */
-#endif /* !defined(builtinbuf_vtable) && defined(__cplusplus) */
-
-#if defined(__STDC__) || defined(__cplusplus)
-#define _IO_va_start(args, last) va_start(args, last)
-#else
-#define _IO_va_start(args, last) va_start(args)
-#endif
-
-extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf;
-
-#if 1
-#define COERCE_FILE(FILE) /* Nothing */
-#else
-/* This is part of the kludge for binary compatibility with old stdio. */
-#define COERCE_FILE(FILE) \
- (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \
- && (FILE) = *(FILE**)&((int*)fp)[1])
-#endif
-
-#ifdef EINVAL
-#define MAYBE_SET_EINVAL errno = EINVAL
-#else
-#define MAYBE_SET_EINVAL /* nothing */
-#endif
-
-#ifdef DEBUG
-#define CHECK_FILE(FILE,RET) \
- if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \
- else { COERCE_FILE(FILE); \
- if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \
- { errno = EINVAL; return RET; }}
-#else
-#define CHECK_FILE(FILE,RET) \
- COERCE_FILE(FILE)
-#endif
diff --git a/gnu/lib/libg++/include/new.h b/gnu/lib/libg++/include/new.h
deleted file mode 100644
index 61bbba5..0000000
--- a/gnu/lib/libg++/include/new.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef _new_h
-#ifdef __GNUG__
-#pragma interface
-#endif
-#define _new_h 1
-
-#include <defines.h>
-
-#ifndef NO_LIBGXX_MALLOC
-#define MALLOC_ALIGN_MASK 7 /* ptrs aligned at 8 byte boundaries */
-#define MALLOC_MIN_OVERHEAD 8 /* 8 bytes of overhead per pointer */
-#endif
-
-extern "C" fvoid_t *set_new_handler(fvoid_t *);
-
-#ifdef __GNUG__
-extern fvoid_t *__new_handler;
-extern "C" void __default_new_handler();
-
-#define NEW(where) new ( where )
-#endif
-
-// default placement version of operator new
-inline void *operator new(size_t, void *place) { return place; }
-inline void *operator new[](size_t, void *place) { return place; }
-
-#endif
diff --git a/gnu/lib/libg++/include/osfcn.h b/gnu/lib/libg++/include/osfcn.h
deleted file mode 100644
index 023b5c5..0000000
--- a/gnu/lib/libg++/include/osfcn.h
+++ /dev/null
@@ -1,17 +0,0 @@
-
-#ifndef OSFCN_H
-#define OSFCN_H 1
-
-#include <std.h>
-#include <time.h>
-#include <sys/types.h>
-#if _G_HAVE_SYS_SOCKET
-#include <sys/socket.h>
-#endif
-#if _G_HAVE_SYS_RESOURCE
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif
-
-
-#endif
diff --git a/gnu/lib/libg++/include/parsestream.h b/gnu/lib/libg++/include/parsestream.h
deleted file mode 100644
index c0dfce2..0000000
--- a/gnu/lib/libg++/include/parsestream.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License.
-
-Written by Per Bothner (bothner@cygnus.com). */
-
-#ifndef PARSESTREAM_H
-#define PARSESTREAM_H
-#ifdef __GNUG__
-#pragma interface
-#endif
-#include "streambuf.h"
-
-// A parsebuf is a streambuf optimized for scanning text files.
-// It keeps track of line and column numbers.
-// It is guaranteed to remember the entire current line,
-// as well the '\n'-s on either side of it (if they exist).
-// You can arbitrarily seek (or unget) within this extended line.
-// Other backward seeks are not supported.
-// Normal read semantics are supported (and hence istream operators like >>).
-
-class parsebuf : public streambuf {
- protected:
- _IO_fpos_t pos_at_line_start;
- long _line_length;
- unsigned long __line_number;
- char *buf_start;
- char *buf_end;
-
- public:
- parsebuf *chain;
-
- // Return column number (raw - don't handle tabs etc).
- // Retult can be -1, meaning: at '\n' before current line.
- virtual int tell_in_line();
-
- // seek to (raw) column I in current line.
- // Result is new (raw) column position - differs from I if unable to seek.
- // Seek to -1 tries to seek to before previous LF.
- virtual int seek_in_line(int i);
-
- // Note: there is no "current line" initially, until something is read.
-
- // Current line number, starting with 0.
- // If tell_in_line()==-1, then line number of next line.
- int line_number() { return __line_number; }
-
- // Length of current line, not counting either '\n'.
- int line_length() { return _line_length; }
- // Current line - not a copy, so file ops may trash it.
- virtual char* current_line();
- virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
- virtual streambuf* setbuf(char* p, int len);
- protected:
- parsebuf() { chain= NULL;
- __line_number = 0; pos_at_line_start = 0; _line_length = -1; }
- virtual int pbackfail(int c);
-};
-
-// A string_parsebuf is a parsebuf whose source is a fixed string.
-
-class string_parsebuf : public parsebuf {
- public:
- int do_delete;
- string_parsebuf(char *str, int len, int delete_at_close=0);
- virtual int underflow();
- virtual char* current_line();
- virtual int seek_in_line(int i);
- virtual int tell_in_line();
- char *left() const { return base(); }
- char *right() const { return ebuf(); }
-// streampos seekoff(streamoff, _seek_dir, int);
-};
-
-// A func_parsebuf calls a given function to get new input.
-// Each call returns an entire NUL-terminated line (without the '\n').
-// That line has been allocated with malloc(), not new.
-// The interface is tailored to the GNU readline library.
-// Example:
-// char* DoReadLine(void* arg)
-// {
-// char *line = readline((char*)arg); /* 'arg' is used as prompt. */
-// if line == NULL) { putc('\n', stderr); return NULL; }
-// if (line[0] != '\0') add_history(line);
-// return line;
-// }
-// char PromptBuffer[100] = "> ";
-// func_parsebuf my_stream(DoReadLine, PromptBuffer);
-
-typedef char *(*CharReader)(void *arg);
-class istream;
-
-class func_parsebuf : public parsebuf {
- public:
- void *arg;
- CharReader read_func;
- int backed_up_to_newline;
- func_parsebuf(CharReader func, void *argm = NULL);
- int underflow();
- virtual int tell_in_line();
- virtual int seek_in_line(int i);
- virtual char* current_line();
-};
-
-// A general_parsebuf is a parsebuf which gets its input from some
-// other streambuf. It explicitly buffers up an entire line.
-
-class general_parsebuf : public parsebuf {
- public:
- streambuf *sbuf;
- int delete_buf; // Delete sbuf when destroying this.
- general_parsebuf(streambuf *buf, int delete_arg_buf = 0);
- int underflow();
- virtual int tell_in_line();
- virtual int seek_in_line(int i);
- ~general_parsebuf();
- virtual char* current_line();
-};
-
-#if 0
-class parsestream : public istream {
- streammarker marks[2];
- short _first; // of the two marks; either 0 or 1
- int _lineno;
- int first() { return _first; }
- int second() { return 1-_first; }
- int line_length() { marks[second].delta(marks[first]); }
- int line_length() { marks[second].delta(marks[first]); }
- int seek_in_line(int i);
- int tell_in_line();
- int line_number();
-};
-#endif
-#endif /*!defined(PARSESTREAM_H)*/
diff --git a/gnu/lib/libg++/include/pfstream.h b/gnu/lib/libg++/include/pfstream.h
deleted file mode 100644
index 687faf6..0000000
--- a/gnu/lib/libg++/include/pfstream.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Written by Per Bothner (bothner@cygnus.com). */
-
-#ifndef _PFSTREAM_H
-#define _PFSTREAM_H
-#ifdef __GNUG__
-#pragma interface
-#endif
-#include <fstream.h>
-
-// ipfstream foo("NAME") is like: ifstream foo("NAME"). However,
-// if NAME starts *or ends* with a '|', the remainder of NAME is
-// evaluated as a shell command (using a procbuf), and all input
-// read from foo is whatever that shell writes to its standard output.
-// E.g. ipfstream foo("|zcat foo.Z") or ipfstream foo("zcat foo.Z|")
-// (These two forms are equivalent.)
-
-class ipfstream : public ifstream {
- public:
- ipfstream(const char *name, int mode=ios::in, int prot=0664);
-};
-
-// opfstream foo("NAME") is like: ofstream foo("NAME").
-// However, if NAME starts with a '|', the remainder of NAME is
-// evaluated as a shell command (using a procbuf), and all output
-// written to foo is piped to the standard input of that shell.
-// E.g. opfstream foo("|more");
-
-class opfstream : public ofstream {
- public:
- opfstream(const char *name, int mode=ios::out, int prot=0664);
-};
-#endif /*!_PFSTREAM_H*/
-
diff --git a/gnu/lib/libg++/include/procbuf.h b/gnu/lib/libg++/include/procbuf.h
deleted file mode 100644
index 092d9cf..0000000
--- a/gnu/lib/libg++/include/procbuf.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Written by Per Bothner (bothner@cygnus.com). */
-
-#include <streambuf.h>
-
-class procbuf : public filebuf {
- /* Following fields must match those in struct _IO_proc_file */
- _IO_pid_t _pid;
- public:
- procbuf() : filebuf() { }
- procbuf(const char *command, int mode);
- procbuf* open(const char *command, int mode);
- procbuf *close() { return (procbuf*)filebuf::close(); }
- virtual int sys_close();
- ~procbuf();
-};
diff --git a/gnu/lib/libg++/include/rx.h b/gnu/lib/libg++/include/rx.h
deleted file mode 100644
index edb26b4..0000000
--- a/gnu/lib/libg++/include/rx.h
+++ /dev/null
@@ -1,3261 +0,0 @@
-#if !defined(RXH) || defined(RX_WANT_SE_DEFS)
-#define RXH
-
-/* Copyright (C) 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of the librx library.
-
-Librx is free software; you can redistribute it and/or modify it under
-the terms of the GNU Library General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-Librx is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this software; see the file COPYING.LIB. If not,
-write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA
-02139, USA. */
-/* t. lord Wed Sep 23 18:20:57 1992 */
-
-
-
-
-
-
-
-
-#ifndef RX_WANT_SE_DEFS
-
-/* This page: Bitsets */
-
-#ifndef RX_subset
-typedef unsigned int RX_subset;
-#define RX_subset_bits (32)
-#define RX_subset_mask (RX_subset_bits - 1)
-#endif
-
-typedef RX_subset * rx_Bitset;
-
-#ifdef __STDC__
-typedef void (*rx_bitset_iterator) (void *, int member_index);
-#else
-typedef void (*rx_bitset_iterator) ();
-#endif
-
-#define rx_bitset_subset(N) ((N) / RX_subset_bits)
-#define rx_bitset_subset_val(B,N) ((B)[rx_bitset_subset(N)])
-#define RX_bitset_access(B,N,OP) \
- ((B)[rx_bitset_subset(N)] OP rx_subset_singletons[(N) & RX_subset_mask])
-#define RX_bitset_member(B,N) RX_bitset_access(B, N, &)
-#define RX_bitset_enjoin(B,N) RX_bitset_access(B, N, |=)
-#define RX_bitset_remove(B,N) RX_bitset_access(B, N, &= ~)
-#define RX_bitset_toggle(B,N) RX_bitset_access(B, N, ^= )
-#define rx_bitset_numb_subsets(N) (((N) + RX_subset_bits - 1) / RX_subset_bits)
-#define rx_sizeof_bitset(N) (rx_bitset_numb_subsets(N) * sizeof(RX_subset))
-
-
-
-/* This page: Splay trees. */
-
-#ifdef __STDC__
-typedef int (*rx_sp_comparer) (void * a, void * b);
-#else
-typedef int (*rx_sp_comparer) ();
-#endif
-
-struct rx_sp_node
-{
- void * key;
- void * data;
- struct rx_sp_node * kids[2];
-};
-
-#ifdef __STDC__
-typedef void (*rx_sp_key_data_freer) (struct rx_sp_node *);
-#else
-typedef void (*rx_sp_key_data_freer) ();
-#endif
-
-
-/* giant inflatable hash trees */
-
-struct rx_hash_item
-{
- struct rx_hash_item * next_same_hash;
- struct rx_hash * table;
- unsigned long hash;
- void * data;
- void * binding;
-};
-
-struct rx_hash
-{
- struct rx_hash * parent;
- int refs;
- struct rx_hash * children[13];
- struct rx_hash_item * buckets [13];
- int bucket_size [13];
-};
-
-struct rx_hash_rules;
-
-#ifdef __STDC__
-/* should return like == */
-typedef int (*rx_hash_eq)(void *, void *);
-typedef struct rx_hash * (*rx_alloc_hash)(struct rx_hash_rules *);
-typedef void (*rx_free_hash)(struct rx_hash *,
- struct rx_hash_rules *);
-typedef struct rx_hash_item * (*rx_alloc_hash_item)(struct rx_hash_rules *,
- void *);
-typedef void (*rx_free_hash_item)(struct rx_hash_item *,
- struct rx_hash_rules *);
-#else
-typedef int (*rx_hash_eq)();
-typedef struct rx_hash * (*rx_alloc_hash)();
-typedef void (*rx_free_hash)();
-typedef struct rx_hash_item * (*rx_alloc_hash_item)();
-typedef void (*rx_free_hash_item)();
-#endif
-
-struct rx_hash_rules
-{
- rx_hash_eq eq;
- rx_alloc_hash hash_alloc;
- rx_free_hash free_hash;
- rx_alloc_hash_item hash_item_alloc;
- rx_free_hash_item free_hash_item;
-};
-
-
-
-/* Matchers decide what to do by examining a series of these.
- * Instruction types are described below.
- */
-struct rx_inx
-{
- void * inx;
- void * data;
- void * data_2;
- void * fnord;
-};
-
-/* Struct RX holds a compiled regular expression - that is, an nfa ready to be
- * converted on demand to a more efficient nfa. This is for the low level interface.
- * The high-level interface incloses this in a `struct re_pattern_buffer'.
- */
-struct rx_cache;
-#ifdef __STDC__
-struct rx_se_list;
-struct rx;
-typedef int (*rx_se_list_order) (struct rx *,
- struct rx_se_list *, struct rx_se_list *);
-#else
-typedef int (*rx_se_list_order) ();
-#endif
-
-struct rx_superset;
-
-struct rx
-{
- int rx_id; /* Every edition numbered and signed by eclose_nfa. */
-
- struct rx_cache * cache; /* Where superstates come from */
-
- /* Every regex defines the size of its own character set. */
- int local_cset_size;
-
- void * buffer; /* Malloced memory for the nfa. */
- unsigned long allocated; /* Size of that memory. */
-
- /* How much buffer space to save for external uses. After compilation,
- * this space will be available at (buffer + allocated - reserved)
- */
- unsigned long reserved;
-
- /* --------- The remaining fields are for internal use only. --------- */
- /* --------- But! they should be initialized to 0. --------- */
- /* NODEC is the number of nodes in the NFA with non-epsilon
- * orx transitions.
- */
- int nodec;
-
- /* EPSNODEC is the number of nodes with only epsilon (orx) transitions. */
- int epsnodec;
-
- /* The sum of NODEC & EPSNODEC is the total number of states in the
- * compiled NFA.
- */
-
- /* side_effect_progs temporarily holds a tree of side effect lists. */
- struct rx_hash se_list_memo;
-
- /* A memo for sets of states in the possible_future lists of an nfa: */
- struct rx_hash set_list_memo;
-
- /* The instruction table is indexed by the enum of instructions defined in
- * rxrun.h. The values in the table are used to fill in the `inx'
- * slot of instruction frames (see rxrun.h).
- */
- void ** instruction_table;
- struct rx_nfa_state *nfa_states;
- struct rx_nfa_state *start;
-
- /* This orders the search through super-nfa paths. */
- rx_se_list_order se_list_cmp;
-
- struct rx_superset * start_set;
-};
-
-/* An RX NFA may contain epsilon edges labeled with side effects.
- * These side effects represent match actions that can not normally be
- * defined in a `pure' NFA; for example, recording the location at
- * which a paren is crossed in a register structure.
- *
- * A matcher is supposed to find a particular path
- * through the NFA (such as leftmost-longest), and then to execute the
- * side effects along that path. Operationally, the space of paths is
- * searched and side effects are carried out incrementally, and with
- * backtracking.
- *
- * As the NFA is manipulated during matching sets of side effects.
- * Simple lists are used to hold side effect lists.
- */
-
-typedef void * rx_side_effect;
-
-struct rx_se_list
-{
- rx_side_effect car;
- struct rx_se_list * cdr;
-};
-
-
-
-/* Struct rexp_node holds an expression tree that represents a regexp.
- * In this expression tree, every node has a type, and some parameters
- * appropriate to that type.
- */
-
-enum rexp_node_type
-{
- r_cset, /* Match from a character set. `a' or `[a-z]'*/
- r_concat, /* Concat two regexps. `ab' */
- r_alternate, /* Choose one of two regexps. `a\|b' */
- r_opt, /* Optional regexp. `a?' */
- r_star, /* Repeated regexp. `a*' */
- r_2phase_star, /* hard to explain */
- r_side_effect, /* Matches the empty string, but
- * implies that a side effect must
- * take place. These nodes are used
- * by the parser to implement parens,
- * backreferences etc.
- */
-
- r_data /* R_DATA is soley for the convenience
- * of parsers or other rexp
- * transformers that want to
- * (temporarily) introduce new node
- * types in rexp structures. These
- * must be eliminated
- * by the time build_nfa is called.
- */
-};
-
-struct rexp_node
-{
- enum rexp_node_type type;
- union
- {
- rx_Bitset cset;
- rx_side_effect side_effect;
- struct
- {
- struct rexp_node *left;
- struct rexp_node *right;
- } pair;
- void * data;
- } params;
-};
-
-
-
-/* This defines the structure of the NFA into which rexps are compiled. */
-
-struct rx_nfa_state
-{
- int id;
- struct rx_nfa_edge *edges;
- struct rx_possible_future *futures;
- unsigned int is_final:1;
- unsigned int is_start:1;
- unsigned int eclosure_needed:1;
- struct rx_nfa_state *next;
- unsigned int mark:1;
-};
-
-enum rx_nfa_etype
-{
- ne_cset,
- ne_epsilon,
- ne_side_effect /* A special kind of epsilon. */
-};
-
-struct rx_nfa_edge
-{
- struct rx_nfa_edge *next;
- enum rx_nfa_etype type;
- struct rx_nfa_state *dest;
- union
- {
- rx_Bitset cset;
- rx_side_effect side_effect;
- } params;
-};
-
-struct rx_nfa_state_set
-{
- struct rx_nfa_state * car;
- struct rx_nfa_state_set * cdr;
-};
-
-struct rx_possible_future
-{
- struct rx_possible_future *next;
- struct rx_se_list * effects;
- struct rx_nfa_state_set * destset;
-};
-
-
-
-enum rx_opcode
-{
- /*
- * BACKTRACK_POINT is invoked when a transition results in more
- * than one possible future.
- *
- * There is one occurence of this instruction per transition_class
- * structure; that occurence is only ever executed if the
- * transition_class contains a list of more than 1 edge.
- */
- rx_backtrack_point = 0, /* data is (struct transition_class *) */
-
- /*
- * RX_DO_SIDE_EFFECTS evaluates the side effects of an epsilon path.
- * There is one occurence of this instruction per rx_distinct_future.
- * This instruction is skipped if a rx_distinct_future has no side effects.
- */
- rx_do_side_effects = rx_backtrack_point + 1,
- /* data is (struct rx_distinct_future *) */
-
- /*
- * RX_CACHE_MISS instructions are stored in rx_distinct_futures whose
- * destination superstate has been reclaimed (or was never built).
- * It recomputes the destination superstate.
- * RX_CACHE_MISS is also stored in a superstate transition table before
- * any of its edges have been built.
- */
- rx_cache_miss = rx_do_side_effects + 1,
- /* data is (struct rx_distinct_future *) */
-
- /*
- * RX_NEXT_CHAR is called to consume the next character and take the
- * corresponding transition. This is the only instruction that uses
- * the DATA field of the instruction frame instead of DATA_2.
- * (see EXPLORE_FUTURE in regex.c).
- */
- rx_next_char = rx_cache_miss + 1, /* data is (struct superstate *) */
-
- /* RX_BACKTRACK indicates that a transition fails.
- */
- rx_backtrack = rx_next_char + 1, /* no data */
-
- /*
- * RX_ERROR_INX is stored only in places that should never be executed.
- */
- rx_error_inx = rx_backtrack + 1, /* Not supposed to occur. */
-
- rx_num_instructions = rx_error_inx + 1
-};
-
-/* An id_instruction_table holds the values stored in instruction
- * frames. The table is indexed by the enums declared above.
- */
-extern void * rx_id_instruction_table[rx_num_instructions];
-
-#if 0 /* Already declared way above. */
-/* If the instruction is `rx_next_char' then data is valid. Otherwise it's 0
- * and data_2 is valid.
- */
-struct rx_inx
-{
- void * inx;
- void * data;
- void * data_2;
-};
-#endif
-
-
-#ifndef RX_TAIL_ARRAY
-#define RX_TAIL_ARRAY 1
-#endif
-
-/* A superstate corresponds to a set of nfa states. Those sets are
- * represented by STRUCT RX_SUPERSET. The constructors
- * guarantee that only one (shared) structure is created for a given set.
- */
-struct rx_superset
-{
- int refs;
- struct rx_nfa_state * car; /* May or may not be a valid addr. */
- int id; /* == car->id for the initial value of *car */
- struct rx_superset * cdr; /* May be NULL or a live or semifreed super*/
-
- /* If the corresponding superstate exists: */
- struct rx_superstate * superstate;
-
- /* If this is a starting state (as built by re_search_2)
- * this points to the `struct rx'. The memory for these objects
- * is typed -- so even after they are freed it is safe to look
- * at this field (to check, in fact, if this was freed.)
- */
- struct rx * starts_for;
-
- struct rx_hash_item hash_item;
-};
-
-#define rx_protect_superset(RX,CON) (++(CON)->refs)
-
-/* Every character occurs in at most one super edge per super-state.
- * But, that edge might have more than one option, indicating a point
- * of non-determinism.
- */
-struct rx_super_edge
-{
- struct rx_super_edge *next;
- struct rx_inx rx_backtrack_frame;
- int cset_size;
- rx_Bitset cset;
- struct rx_distinct_future *options;
-};
-
-/* A superstate is a set of nfa states (RX_SUPERSET) along
- * with a transition table. Superstates are built on demand and reclaimed
- * without warning. To protect a superstate, use LOCK_SUPERSTATE.
- *
- * Joe Keane thought of calling these superstates and several people
- * have commented on what a good name it is for what they do.
- */
-struct rx_superstate
-{
- int rx_id;
- int locks;
- struct rx_superstate * next_recyclable;
- struct rx_superstate * prev_recyclable;
- struct rx_distinct_future * transition_refs;
- struct rx_superset * contents;
- struct rx_super_edge * edges;
- int is_semifree;
- int trans_size;
- struct rx_inx transitions[RX_TAIL_ARRAY]; /* cset sized */
-};
-
-struct rx_distinct_future
-{
- struct rx_distinct_future * next_same_super_edge[2];
- struct rx_distinct_future * next_same_dest;
- struct rx_distinct_future * prev_same_dest;
- struct rx_superstate * present; /* source state */
- struct rx_superstate * future; /* destination state */
- struct rx_super_edge * edge;
- struct rx_inx future_frame;
- struct rx_inx side_effects_frame;
- struct rx_se_list * effects;
-};
-
-#define rx_lock_superstate(R,S) ((S)->locks++)
-#define rx_unlock_superstate(R,S) (--(S)->locks)
-
-
-/* This page destined for rx.h */
-
-struct rx_blocklist
-{
- struct rx_blocklist * next;
- int bytes;
-};
-
-struct rx_freelist
-{
- struct rx_freelist * next;
-};
-
-struct rx_cache;
-
-#ifdef __STDC__
-typedef void (*rx_morecore_fn)(struct rx_cache *);
-#else
-typedef void (*rx_morecore_fn)();
-#endif
-
-/* You use this to control the allocation of superstate data
- * during matching. Most of it should be initialized to 0.
- *
- * A MORECORE function is necessary. It should allocate
- * a new block of memory or return 0.
- * A default that uses malloc is called `rx_morecore'.
- *
- * The number of SUPERSTATES_ALLOWED indirectly limits how much memory
- * the system will try to allocate. The default is 128. Batch style
- * applications that are very regexp intensive should use as high a number
- * as possible without thrashing.
- *
- * The LOCAL_CSET_SIZE is the number of characters in a character set.
- * It is therefore the number of entries in a superstate transition table.
- * Generally, it should be 256. If your character set has 16 bits,
- * it is better to translate your regexps into equivalent 8 bit patterns.
- */
-
-struct rx_cache
-{
- struct rx_hash_rules superset_hash_rules;
-
- /* Objects are allocated by incrementing a pointer that
- * scans across rx_blocklists.
- */
- struct rx_blocklist * memory;
- struct rx_blocklist * memory_pos;
- int bytes_left;
- char * memory_addr;
- rx_morecore_fn morecore;
-
- /* Freelists. */
- struct rx_freelist * free_superstates;
- struct rx_freelist * free_transition_classes;
- struct rx_freelist * free_discernable_futures;
- struct rx_freelist * free_supersets;
- struct rx_freelist * free_hash;
-
- /* Two sets of superstates -- those that are semifreed, and those
- * that are being used.
- */
- struct rx_superstate * lru_superstate;
- struct rx_superstate * semifree_superstate;
-
- struct rx_superset * empty_superset;
-
- int superstates;
- int semifree_superstates;
- int hits;
- int misses;
- int superstates_allowed;
-
- int local_cset_size;
- void ** instruction_table;
-
- struct rx_hash superset_table;
-};
-
-
-
-/* The lowest-level search function supports arbitrarily fragmented
- * strings and (optionally) suspendable/resumable searches.
- *
- * Callers have to provide a few hooks.
- */
-
-#ifndef __GNUC__
-#ifdef __STDC__
-#define __const__ const
-#else
-#define __const__
-#endif
-#endif
-
-/* This holds a matcher position */
-struct rx_string_position
-{
- __const__ unsigned char * pos; /* The current pos. */
- __const__ unsigned char * string; /* The current string burst. */
- __const__ unsigned char * end; /* First invalid position >= POS. */
- int offset; /* Integer address of the current burst. */
- int size; /* Current string's size. */
- int search_direction; /* 1 or -1 */
- int search_end; /* First position to not try. */
-};
-
-
-enum rx_get_burst_return
-{
- rx_get_burst_continuation,
- rx_get_burst_error,
- rx_get_burst_ok,
- rx_get_burst_no_more
-};
-
-
-/* A call to get burst should make POS valid. It might be invalid
- * if the STRING field doesn't point to a burst that actually
- * contains POS.
- *
- * GET_BURST should take a clue from SEARCH_DIRECTION (1 or -1) as to
- * whether or not to pad to the left. Padding to the right is always
- * appropriate, but need not go past the point indicated by STOP.
- *
- * If a continuation is returned, then the reentering call to
- * a search function will retry the get_burst.
- */
-
-#ifdef __STDC__
-typedef enum rx_get_burst_return
- (*rx_get_burst_fn) (struct rx_string_position * pos,
- void * app_closure,
- int stop);
-
-#else
-typedef enum rx_get_burst_return (*rx_get_burst_fn) ();
-#endif
-
-
-enum rx_back_check_return
-{
- rx_back_check_continuation,
- rx_back_check_error,
- rx_back_check_pass,
- rx_back_check_fail
-};
-
-/* Back_check should advance the position it is passed
- * over rparen - lparen characters and return pass iff
- * the characters starting at POS match those indexed
- * by [LPAREN..RPAREN].
- *
- * If a continuation is returned, then the reentering call to
- * a search function will retry the back_check.
- */
-
-#ifdef __STDC__
-typedef enum rx_back_check_return
- (*rx_back_check_fn) (struct rx_string_position * pos,
- int lparen,
- int rparen,
- unsigned char * translate,
- void * app_closure,
- int stop);
-
-#else
-typedef enum rx_back_check_return (*rx_back_check_fn) ();
-#endif
-
-
-
-
-/* A call to fetch_char should return the character at POS or POS + 1.
- * Returning continuations here isn't supported. OFFSET is either 0 or 1
- * and indicates which characters is desired.
- */
-
-#ifdef __STDC__
-typedef int (*rx_fetch_char_fn) (struct rx_string_position * pos,
- int offset,
- void * app_closure,
- int stop);
-#else
-typedef int (*rx_fetch_char_fn) ();
-#endif
-
-
-enum rx_search_return
-{
- rx_search_continuation = -4,
- rx_search_error = -3,
- rx_search_soft_fail = -2, /* failed by running out of string */
- rx_search_fail = -1 /* failed only by reaching failure states */
- /* return values >= 0 indicate the position of a successful match */
-};
-
-
-
-
-
-
-/* regex.h
- *
- * The remaining declarations replace regex.h.
- */
-
-/* This is an array of error messages corresponding to the error codes.
- */
-extern __const__ char *re_error_msg[];
-
-#if !defined(BSD) || (BSD < 199306) || defined(_RX_C_)
-/* If any error codes are removed, changed, or added, update the
- `re_error_msg' table in regex.c. */
-typedef enum
-{
- REG_NOERROR = 0, /* Success. */
- REG_NOMATCH, /* Didn't find a match (for regexec). */
-
- /* POSIX regcomp return error codes. (In the order listed in the
- standard.) */
- REG_BADPAT, /* Invalid pattern. */
- REG_ECOLLATE, /* Not implemented. */
- REG_ECTYPE, /* Invalid character class name. */
- REG_EESCAPE, /* Trailing backslash. */
- REG_ESUBREG, /* Invalid back reference. */
- REG_EBRACK, /* Unmatched left bracket. */
- REG_EPAREN, /* Parenthesis imbalance. */
- REG_EBRACE, /* Unmatched \{. */
- REG_BADBR, /* Invalid contents of \{\}. */
- REG_ERANGE, /* Invalid range end. */
- REG_ESPACE, /* Ran out of memory. */
- REG_BADRPT, /* No preceding re for repetition op. */
-
- /* Error codes we've added. */
- REG_EEND, /* Premature end. */
- REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
- REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
-} reg_errcode_t;
-#endif
-
-/* The regex.c support, as a client of rx, defines a set of possible
- * side effects that can be added to the edge lables of nfa edges.
- * Here is the list of sidef effects in use.
- */
-
-enum re_side_effects
-{
-#define RX_WANT_SE_DEFS 1
-#undef RX_DEF_SE
-#undef RX_DEF_CPLX_SE
-#define RX_DEF_SE(IDEM, NAME, VALUE) NAME VALUE,
-#define RX_DEF_CPLX_SE(IDEM, NAME, VALUE) NAME VALUE,
-#include "rx.h"
-#undef RX_DEF_SE
-#undef RX_DEF_CPLX_SE
-#undef RX_WANT_SE_DEFS
- re_floogle_flap = 65533
-};
-
-/* These hold paramaters for the kinds of side effects that are possible
- * in the supported pattern languages. These include things like the
- * numeric bounds of {} operators and the index of paren registers for
- * subexpression measurement or backreferencing.
- */
-struct re_se_params
-{
- enum re_side_effects se;
- int op1;
- int op2;
-};
-
-typedef unsigned reg_syntax_t;
-
-struct re_pattern_buffer
-{
- struct rx rx;
- reg_syntax_t syntax; /* See below for syntax bit definitions. */
-
- unsigned int no_sub:1; /* If set, don't return register offsets. */
- unsigned int not_bol:1; /* If set, the anchors ('^' and '$') don't */
- unsigned int not_eol:1; /* match at the ends of the string. */
- unsigned int newline_anchor:1;/* If true, an anchor at a newline matches.*/
- unsigned int least_subs:1; /* If set, and returning registers, return
- * as few values as possible. Only
- * backreferenced groups and group 0 (the whole
- * match) will be returned.
- */
-
- /* If true, this says that the matcher should keep registers on its
- * backtracking stack. For many patterns, we can easily determine that
- * this isn't necessary.
- */
- unsigned int match_regs_on_stack:1;
- unsigned int search_regs_on_stack:1;
-
- /* is_anchored and begbuf_only are filled in by rx_compile. */
- unsigned int is_anchored:1; /* Anchorded by ^? */
- unsigned int begbuf_only:1; /* Anchored to char position 0? */
-
-
- /* If REGS_UNALLOCATED, allocate space in the `regs' structure
- * for `max (RE_NREGS, re_nsub + 1)' groups.
- * If REGS_REALLOCATE, reallocate space if necessary.
- * If REGS_FIXED, use what's there.
- */
-#define REGS_UNALLOCATED 0
-#define REGS_REALLOCATE 1
-#define REGS_FIXED 2
- unsigned int regs_allocated:2;
-
-
- /* Either a translate table to apply to all characters before
- * comparing them, or zero for no translation. The translation
- * is applied to a pattern when it is compiled and to a string
- * when it is matched.
- */
- unsigned char * translate;
-
- /* If this is a valid pointer, it tells rx not to store the extents of
- * certain subexpressions (those corresponding to non-zero entries).
- * Passing 0x1 is the same as passing an array of all ones. Passing 0x0
- * is the same as passing an array of all zeros.
- * The array should contain as many entries as their are subexps in the
- * regexp.
- */
- char * syntax_parens;
-
- /* Number of subexpressions found by the compiler. */
- size_t re_nsub;
-
- void * buffer; /* Malloced memory for the nfa. */
- unsigned long allocated; /* Size of that memory. */
-
- /* Pointer to a fastmap, if any, otherwise zero. re_search uses
- * the fastmap, if there is one, to skip over impossible
- * starting points for matches. */
- char *fastmap;
-
- unsigned int fastmap_accurate:1; /* These three are internal. */
- unsigned int can_match_empty:1;
- struct rx_nfa_state * start; /* The nfa starting state. */
-
- /* This is the list of iterator bounds for {lo,hi} constructs.
- * The memory pointed to is part of the rx->buffer.
- */
- struct re_se_params *se_params;
-
- /* This is a bitset representation of the fastmap.
- * This is a true fastmap that already takes the translate
- * table into account.
- */
- rx_Bitset fastset;
-};
-
-/* This is the structure we store register match data in. See
- regex.texinfo for a full description of what registers match. */
-struct re_registers
-{
- unsigned num_regs;
- int *start;
- int *end;
-};
-
-#if !defined(BSD) || (BSD < 199306) || defined(_RX_C_)
-/* Type for byte offsets within the string. POSIX mandates this. */
-typedef int regoff_t;
-
-typedef struct re_pattern_buffer regex_t;
-
-/* POSIX specification for registers. Aside from the different names than
- `re_registers', POSIX uses an array of structures, instead of a
- structure of arrays. */
-typedef struct
-{
- regoff_t rm_so; /* Byte offset from string's start to substring's start. */
- regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
-} regmatch_t;
-#endif
-
-/* The following bits are used to determine the regexp syntax we
- recognize. The set/not-set meanings are chosen so that Emacs syntax
- remains the value 0. The bits are given in alphabetical order, and
- the definitions shifted by one from the previous bit; thus, when we
- add or remove a bit, only one other definition need change. */
-
-/* If this bit is not set, then \ inside a bracket expression is literal.
- If set, then such a \ quotes the following character. */
-#define RE_BACKSLASH_ESCAPE_IN_LISTS (1)
-
-/* If this bit is not set, then + and ? are operators, and \+ and \? are
- literals.
- If set, then \+ and \? are operators and + and ? are literals. */
-#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
-
-/* If this bit is set, then character classes are supported. They are:
- [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
- [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
- If not set, then character classes are not supported. */
-#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
-
-/* If this bit is set, then ^ and $ are always anchors (outside bracket
- expressions, of course).
- If this bit is not set, then it depends:
- ^ is an anchor if it is at the beginning of a regular
- expression or after an open-group or an alternation operator;
- $ is an anchor if it is at the end of a regular expression, or
- before a close-group or an alternation operator.
-
- This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
- POSIX draft 11.2 says that * etc. in leading positions is undefined.
- We already implemented a previous draft which made those constructs
- invalid, though, so we haven't changed the code back. */
-#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
-
-/* If this bit is set, then special characters are always special
- regardless of where they are in the pattern.
- If this bit is not set, then special characters are special only in
- some contexts; otherwise they are ordinary. Specifically,
- * + ? and intervals are only special when not after the beginning,
- open-group, or alternation operator. */
-#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
-
-/* If this bit is set, then *, +, ?, and { cannot be first in an re or
- immediately after an alternation or begin-group operator. */
-#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
-
-/* If this bit is set, then . matches newline.
- If not set, then it doesn't. */
-#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
-
-/* If this bit is set, then . doesn't match NUL.
- If not set, then it does. */
-#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
-
-/* If this bit is set, nonmatching lists [^...] do not match newline.
- If not set, they do. */
-#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
-
-/* If this bit is set, either \{...\} or {...} defines an
- interval, depending on RE_NO_BK_BRACES.
- If not set, \{, \}, {, and } are literals. */
-#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
-
-/* If this bit is set, +, ? and | aren't recognized as operators.
- If not set, they are. */
-#define RE_LIMITED_OPS (RE_INTERVALS << 1)
-
-/* If this bit is set, newline is an alternation operator.
- If not set, newline is literal. */
-#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
-
-/* If this bit is set, then `{...}' defines an interval, and \{ and \}
- are literals.
- If not set, then `\{...\}' defines an interval. */
-#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
-
-/* If this bit is set, (...) defines a group, and \( and \) are literals.
- If not set, \(...\) defines a group, and ( and ) are literals. */
-#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
-
-/* If this bit is set, then \<digit> matches <digit>.
- If not set, then \<digit> is a back-reference. */
-#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
-
-/* If this bit is set, then | is an alternation operator, and \| is literal.
- If not set, then \| is an alternation operator, and | is literal. */
-#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
-
-/* If this bit is set, then an ending range point collating higher
- than the starting range point, as in [z-a], is invalid.
- If not set, then when ending range point collates higher than the
- starting range point, the range is ignored. */
-#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
-
-/* If this bit is set, then an unmatched ) is ordinary.
- If not set, then an unmatched ) is invalid. */
-#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
-
-/* This global variable defines the particular regexp syntax to use (for
- some interfaces). When a regexp is compiled, the syntax used is
- stored in the pattern buffer, so changing this does not affect
- already-compiled regexps. */
-extern reg_syntax_t re_syntax_options;
-
-/* Define combinations of the above bits for the standard possibilities.
- (The [[[ comments delimit what gets put into the Texinfo file, so
- don't delete them!) */
-/* [[[begin syntaxes]]] */
-#define RE_SYNTAX_EMACS 0
-
-#define RE_SYNTAX_AWK \
- (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VAR | RE_NO_EMPTY_RANGES \
- | RE_UNMATCHED_RIGHT_PAREN_ORD)
-
-#define RE_SYNTAX_POSIX_AWK \
- (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS)
-
-#define RE_SYNTAX_GREP \
- (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
- | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
- | RE_NEWLINE_ALT)
-
-#define RE_SYNTAX_EGREP \
- (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
- | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
- | RE_NO_BK_VBAR)
-
-#define RE_SYNTAX_POSIX_EGREP \
- (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
-
-#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
-
-/* Syntax bits common to both basic and extended POSIX regex syntax. */
-#define _RE_SYNTAX_POSIX_COMMON \
- (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
- | RE_INTERVALS | RE_NO_EMPTY_RANGES)
-
-#define RE_SYNTAX_POSIX_BASIC \
- (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
-
-/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
- RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
- isn't minimal, since other operators, such as \`, aren't disabled. */
-#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
- (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
-
-#define RE_SYNTAX_POSIX_EXTENDED \
- (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
- | RE_UNMATCHED_RIGHT_PAREN_ORD)
-
-/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS
- replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */
-#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
- (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
- | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
- | RE_NO_BK_PARENS | RE_NO_BK_REFS \
- | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
-/* [[[end syntaxes]]] */
-
-/* Maximum number of duplicates an interval can allow. Some systems
- (erroneously) define this in other header files, but we want our
- value, so remove any previous define. */
-#ifdef RE_DUP_MAX
-#undef RE_DUP_MAX
-#endif
-#define RE_DUP_MAX ((1 << 15) - 1)
-
-
-#if !defined(BSD) || (BSD < 199306)
-/* POSIX `cflags' bits (i.e., information for `regcomp'). */
-
-/* If this bit is set, then use extended regular expression syntax.
- If not set, then use basic regular expression syntax. */
-#define REG_EXTENDED 1
-
-/* If this bit is set, then ignore case when matching.
- If not set, then case is significant. */
-#define REG_ICASE (REG_EXTENDED << 1)
-
-/* If this bit is set, then anchors do not match at newline
- characters in the string.
- If not set, then anchors do match at newlines. */
-#define REG_NEWLINE (REG_ICASE << 1)
-
-/* If this bit is set, then report only success or fail in regexec.
- If not set, then returns differ between not matching and errors. */
-#define REG_NOSUB (REG_NEWLINE << 1)
-
-
-/* POSIX `eflags' bits (i.e., information for regexec). */
-
-/* If this bit is set, then the beginning-of-line operator doesn't match
- the beginning of the string (presumably because it's not the
- beginning of a line).
- If not set, then the beginning-of-line operator does match the
- beginning of the string. */
-#define REG_NOTBOL 1
-
-/* Like REG_NOTBOL, except for the end-of-line. */
-#define REG_NOTEOL (1 << 1)
-#endif
-
-/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
- * `re_match_2' returns information about at least this many registers
- * the first time a `regs' structure is passed.
- *
- * Also, this is the greatest number of backreferenced subexpressions
- * allowed in a pattern being matched without caller-supplied registers.
- */
-#ifndef RE_NREGS
-#define RE_NREGS 30
-#endif
-
-extern int rx_cache_bound;
-extern char rx_version_string[];
-
-
-
-#ifdef RX_WANT_RX_DEFS
-
-/* This is decls to the interesting subsystems and lower layers
- * of rx. Everything which doesn't have a public counterpart in
- * regex.c is declared here.
- */
-
-
-#ifdef __STDC__
-typedef void (*rx_hash_freefn) (struct rx_hash_item * it);
-#else /* ndef __STDC__ */
-typedef void (*rx_hash_freefn) ();
-#endif /* ndef __STDC__ */
-
-
-
-
-#ifdef __STDC__
-RX_DECL int rx_bitset_is_equal (int size, rx_Bitset a, rx_Bitset b);
-RX_DECL int rx_bitset_is_subset (int size, rx_Bitset a, rx_Bitset b);
-RX_DECL int rx_bitset_empty (int size, rx_Bitset set);
-RX_DECL void rx_bitset_null (int size, rx_Bitset b);
-RX_DECL void rx_bitset_universe (int size, rx_Bitset b);
-RX_DECL void rx_bitset_complement (int size, rx_Bitset b);
-RX_DECL void rx_bitset_assign (int size, rx_Bitset a, rx_Bitset b);
-RX_DECL void rx_bitset_union (int size, rx_Bitset a, rx_Bitset b);
-RX_DECL void rx_bitset_intersection (int size,
- rx_Bitset a, rx_Bitset b);
-RX_DECL void rx_bitset_difference (int size, rx_Bitset a, rx_Bitset b);
-RX_DECL void rx_bitset_revdifference (int size,
- rx_Bitset a, rx_Bitset b);
-RX_DECL void rx_bitset_xor (int size, rx_Bitset a, rx_Bitset b);
-RX_DECL unsigned long rx_bitset_hash (int size, rx_Bitset b);
-RX_DECL struct rx_hash_item * rx_hash_find (struct rx_hash * table,
- unsigned long hash,
- void * value,
- struct rx_hash_rules * rules);
-RX_DECL struct rx_hash_item * rx_hash_store (struct rx_hash * table,
- unsigned long hash,
- void * value,
- struct rx_hash_rules * rules);
-RX_DECL void rx_hash_free (struct rx_hash_item * it, struct rx_hash_rules * rules);
-RX_DECL void rx_free_hash_table (struct rx_hash * tab, rx_hash_freefn freefn,
- struct rx_hash_rules * rules);
-RX_DECL rx_Bitset rx_cset (struct rx *rx);
-RX_DECL rx_Bitset rx_copy_cset (struct rx *rx, rx_Bitset a);
-RX_DECL void rx_free_cset (struct rx * rx, rx_Bitset c);
-RX_DECL struct rexp_node * rexp_node (struct rx *rx,
- enum rexp_node_type type);
-RX_DECL struct rexp_node * rx_mk_r_cset (struct rx * rx,
- rx_Bitset b);
-RX_DECL struct rexp_node * rx_mk_r_concat (struct rx * rx,
- struct rexp_node * a,
- struct rexp_node * b);
-RX_DECL struct rexp_node * rx_mk_r_alternate (struct rx * rx,
- struct rexp_node * a,
- struct rexp_node * b);
-RX_DECL struct rexp_node * rx_mk_r_opt (struct rx * rx,
- struct rexp_node * a);
-RX_DECL struct rexp_node * rx_mk_r_star (struct rx * rx,
- struct rexp_node * a);
-RX_DECL struct rexp_node * rx_mk_r_2phase_star (struct rx * rx,
- struct rexp_node * a,
- struct rexp_node * b);
-RX_DECL struct rexp_node * rx_mk_r_side_effect (struct rx * rx,
- rx_side_effect a);
-RX_DECL struct rexp_node * rx_mk_r_data (struct rx * rx,
- void * a);
-RX_DECL void rx_free_rexp (struct rx * rx, struct rexp_node * node);
-RX_DECL struct rexp_node * rx_copy_rexp (struct rx *rx,
- struct rexp_node *node);
-RX_DECL struct rx_nfa_state * rx_nfa_state (struct rx *rx);
-RX_DECL void rx_free_nfa_state (struct rx_nfa_state * n);
-RX_DECL struct rx_nfa_state * rx_id_to_nfa_state (struct rx * rx,
- int id);
-RX_DECL struct rx_nfa_edge * rx_nfa_edge (struct rx *rx,
- enum rx_nfa_etype type,
- struct rx_nfa_state *start,
- struct rx_nfa_state *dest);
-RX_DECL void rx_free_nfa_edge (struct rx_nfa_edge * e);
-RX_DECL void rx_free_nfa (struct rx *rx);
-RX_DECL int rx_build_nfa (struct rx *rx,
- struct rexp_node *rexp,
- struct rx_nfa_state **start,
- struct rx_nfa_state **end);
-RX_DECL void rx_name_nfa_states (struct rx *rx);
-RX_DECL int rx_eclose_nfa (struct rx *rx);
-RX_DECL void rx_delete_epsilon_transitions (struct rx *rx);
-RX_DECL int rx_compactify_nfa (struct rx *rx,
- void **mem, unsigned long *size);
-RX_DECL void rx_release_superset (struct rx *rx,
- struct rx_superset *set);
-RX_DECL struct rx_superset * rx_superset_cons (struct rx * rx,
- struct rx_nfa_state *car, struct rx_superset *cdr);
-RX_DECL struct rx_superset * rx_superstate_eclosure_union
- (struct rx * rx, struct rx_superset *set, struct rx_nfa_state_set *ecl);
-RX_DECL struct rx_superstate * rx_superstate (struct rx *rx,
- struct rx_superset *set);
-RX_DECL struct rx_inx * rx_handle_cache_miss
- (struct rx *rx, struct rx_superstate *super, unsigned char chr, void *data);
-RX_DECL reg_errcode_t rx_compile (__const__ char *pattern, int size,
- reg_syntax_t syntax,
- struct re_pattern_buffer * rxb);
-RX_DECL void rx_blow_up_fastmap (struct re_pattern_buffer * rxb);
-#else /* STDC */
-RX_DECL int rx_bitset_is_equal ();
-RX_DECL int rx_bitset_is_subset ();
-RX_DECL int rx_bitset_empty ();
-RX_DECL void rx_bitset_null ();
-RX_DECL void rx_bitset_universe ();
-RX_DECL void rx_bitset_complement ();
-RX_DECL void rx_bitset_assign ();
-RX_DECL void rx_bitset_union ();
-RX_DECL void rx_bitset_intersection ();
-RX_DECL void rx_bitset_difference ();
-RX_DECL void rx_bitset_revdifference ();
-RX_DECL void rx_bitset_xor ();
-RX_DECL unsigned long rx_bitset_hash ();
-RX_DECL struct rx_hash_item * rx_hash_find ();
-RX_DECL struct rx_hash_item * rx_hash_store ();
-RX_DECL void rx_hash_free ();
-RX_DECL void rx_free_hash_table ();
-RX_DECL rx_Bitset rx_cset ();
-RX_DECL rx_Bitset rx_copy_cset ();
-RX_DECL void rx_free_cset ();
-RX_DECL struct rexp_node * rexp_node ();
-RX_DECL struct rexp_node * rx_mk_r_cset ();
-RX_DECL struct rexp_node * rx_mk_r_concat ();
-RX_DECL struct rexp_node * rx_mk_r_alternate ();
-RX_DECL struct rexp_node * rx_mk_r_opt ();
-RX_DECL struct rexp_node * rx_mk_r_star ();
-RX_DECL struct rexp_node * rx_mk_r_2phase_star ();
-RX_DECL struct rexp_node * rx_mk_r_side_effect ();
-RX_DECL struct rexp_node * rx_mk_r_data ();
-RX_DECL void rx_free_rexp ();
-RX_DECL struct rexp_node * rx_copy_rexp ();
-RX_DECL struct rx_nfa_state * rx_nfa_state ();
-RX_DECL void rx_free_nfa_state ();
-RX_DECL struct rx_nfa_state * rx_id_to_nfa_state ();
-RX_DECL struct rx_nfa_edge * rx_nfa_edge ();
-RX_DECL void rx_free_nfa_edge ();
-RX_DECL void rx_free_nfa ();
-RX_DECL int rx_build_nfa ();
-RX_DECL void rx_name_nfa_states ();
-RX_DECL int rx_eclose_nfa ();
-RX_DECL void rx_delete_epsilon_transitions ();
-RX_DECL int rx_compactify_nfa ();
-RX_DECL void rx_release_superset ();
-RX_DECL struct rx_superset * rx_superset_cons ();
-RX_DECL struct rx_superset * rx_superstate_eclosure_union ();
-RX_DECL struct rx_superstate * rx_superstate ();
-RX_DECL struct rx_inx * rx_handle_cache_miss ();
-RX_DECL reg_errcode_t rx_compile ();
-RX_DECL void rx_blow_up_fastmap ();
-#endif /* STDC */
-
-
-#endif /* RX_WANT_RX_DEFS */
-
-
-
-#ifdef __STDC__
-extern int re_search_2 (struct re_pattern_buffer *rxb,
- __const__ char * string1, int size1,
- __const__ char * string2, int size2,
- int startpos, int range,
- struct re_registers *regs,
- int stop);
-extern int re_search (struct re_pattern_buffer * rxb, __const__ char *string,
- int size, int startpos, int range,
- struct re_registers *regs);
-extern int re_match_2 (struct re_pattern_buffer * rxb,
- __const__ char * string1, int size1,
- __const__ char * string2, int size2,
- int pos, struct re_registers *regs, int stop);
-extern int re_match (struct re_pattern_buffer * rxb,
- __const__ char * string,
- int size, int pos,
- struct re_registers *regs);
-extern reg_syntax_t re_set_syntax (reg_syntax_t syntax);
-extern void re_set_registers (struct re_pattern_buffer *bufp,
- struct re_registers *regs,
- unsigned num_regs,
- int * starts, int * ends);
-extern __const__ char * re_compile_pattern (__const__ char *pattern,
- int length,
- struct re_pattern_buffer * rxb);
-extern int re_compile_fastmap (struct re_pattern_buffer * rxb);
-#if !defined(BSD) || (BSD < 199306)
-extern char * re_comp (__const__ char *s);
-extern int re_exec (__const__ char *s);
-extern int regcomp (regex_t * preg, __const__ char * pattern, int cflags);
-extern int regexec (__const__ regex_t *preg, __const__ char *string,
- size_t nmatch, regmatch_t pmatch[],
- int eflags);
-extern size_t regerror (int errcode, __const__ regex_t *preg,
- char *errbuf, size_t errbuf_size);
-extern void regfree (regex_t *preg);
-#endif
-#else /* STDC */
-extern int re_search_2 ();
-extern int re_search ();
-extern int re_match_2 ();
-extern int re_match ();
-extern reg_syntax_t re_set_syntax ();
-extern void re_set_registers ();
-extern __const__ char * re_compile_pattern ();
-extern int re_compile_fastmap ();
-#if !defined(BSD) || (BSD < 199306)
-extern char * re_comp ();
-extern int re_exec ();
-extern int regcomp ();
-extern int regexec ();
-extern size_t regerror ();
-extern void regfree ();
-#endif
-#endif /* STDC */
-
-
-
-#ifdef RX_WANT_RX_DEFS
-
-struct rx_counter_frame
-{
- int tag;
- int val;
- struct rx_counter_frame * inherited_from; /* If this is a copy. */
- struct rx_counter_frame * cdr;
-};
-
-struct rx_backtrack_frame
-{
- char * counter_stack_sp;
-
- /* A frame is used to save the matchers state when it crosses a
- * backtracking point. The `stk_' fields correspond to variables
- * in re_search_2 (just strip off thes `stk_'). They are documented
- * tere.
- */
- struct rx_superstate * stk_super;
- unsigned int stk_c;
- struct rx_string_position stk_test_pos;
- int stk_last_l;
- int stk_last_r;
- int stk_test_ret;
-
- /* This is the list of options left to explore at the backtrack
- * point for which this frame was created.
- */
- struct rx_distinct_future * df;
- struct rx_distinct_future * first_df;
-
-#ifdef RX_DEBUG
- int stk_line_no;
-#endif
-};
-
-struct rx_stack_chunk
-{
- struct rx_stack_chunk * next_chunk;
- int bytes_left;
- char * sp;
-};
-
-enum rx_outer_entry
-{
- rx_outer_start,
- rx_outer_fastmap,
- rx_outer_test,
- rx_outer_restore_pos
-};
-
-enum rx_fastmap_return
-{
- rx_fastmap_continuation,
- rx_fastmap_error,
- rx_fastmap_ok,
- rx_fastmap_fail
-};
-
-enum rx_fastmap_entry
-{
- rx_fastmap_start,
- rx_fastmap_string_break
-};
-
-enum rx_test_return
-{
- rx_test_continuation,
- rx_test_error,
- rx_test_fail,
- rx_test_ok
-};
-
-enum rx_test_internal_return
-{
- rx_test_internal_error,
- rx_test_found_first,
- rx_test_line_finished
-};
-
-enum rx_test_match_entry
-{
- rx_test_start,
- rx_test_cache_hit_loop,
- rx_test_backreference_check,
- rx_test_backtrack_return
-};
-
-struct rx_search_state
-{
- /* Two groups of registers are kept. The group with the register state
- * of the current test match, and the group that holds the state at the end
- * of the best known match, if any.
- *
- * For some patterns, there may also be registers saved on the stack.
- */
- unsigned num_regs; /* Includes an element for register zero. */
- int * lparen; /* scratch space for register returns */
- int * rparen;
- int * best_lpspace; /* in case the user doesn't want these */
- int * best_rpspace; /* values, we still need space to store
- * them. Normally, this memoryis unused
- * and the space pointed to by REGS is
- * used instead.
- */
-
- int last_l; /* Highest index of a valid lparen. */
- int last_r; /* It's dual. */
-
- int * best_lparen; /* This contains the best known register */
- int * best_rparen; /* assignments.
- * This may point to the same mem as
- * best_lpspace, or it might point to memory
- * passed by the caller.
- */
- int best_last_l; /* best_last_l:best_lparen::last_l:lparen */
- int best_last_r;
-
-
- unsigned char * translate;
-
- struct rx_string_position outer_pos;
-
- struct rx_superstate * start_super;
- int nfa_choice;
- int first_found; /* If true, return after finding any match. */
- int ret_val;
-
- /* For continuations... */
- enum rx_outer_entry outer_search_resume_pt;
- struct re_pattern_buffer * saved_rxb;
- int saved_startpos;
- int saved_range;
- int saved_stop;
- int saved_total_size;
- rx_get_burst_fn saved_get_burst;
- rx_back_check_fn saved_back_check;
- struct re_registers * saved_regs;
-
- /**
- ** state for fastmap
- **/
- char * fastmap;
- int fastmap_chr;
- int fastmap_val;
-
- /* for continuations in the fastmap procedure: */
- enum rx_fastmap_entry fastmap_resume_pt;
-
- /**
- ** state for test_match
- **/
-
- /* The current superNFA position of the matcher. */
- struct rx_superstate * super;
-
- /* The matcher interprets a series of instruction frames.
- * This is the `instruction counter' for the interpretation.
- */
- struct rx_inx * ifr;
-
- /* We insert a ghost character in the string to prime
- * the nfa. test_pos.pos, test_pos.str_half, and test_pos.end_half
- * keep track of the test-match position and string-half.
- */
- unsigned char c;
-
- /* Position within the string. */
- struct rx_string_position test_pos;
-
- struct rx_stack_chunk * counter_stack;
- struct rx_stack_chunk * backtrack_stack;
- int backtrack_frame_bytes;
- int chunk_bytes;
- struct rx_stack_chunk * free_chunks;
-
- /* To return from this function, set test_ret and
- * `goto test_do_return'.
- *
- * Possible return values are:
- * 1 --- end of string while the superNFA is still going
- * 0 --- internal error (out of memory)
- * -1 --- search completed by reaching the superNFA fail state
- * -2 --- a match was found, maybe not the longest.
- *
- * When the search is complete (-1), best_last_r indicates whether
- * a match was found.
- *
- * -2 is return only if search_state.first_found is non-zero.
- *
- * if search_state.first_found is non-zero, a return of -1 indicates no match,
- * otherwise, best_last_r has to be checked.
- */
- int test_ret;
-
- int could_have_continued;
-
-#ifdef RX_DEBUG
- int backtrack_depth;
- /* There is a search tree with every node as set of deterministic
- * transitions in the super nfa. For every branch of a
- * backtrack point is an edge in the tree.
- * This counts up a pre-order of nodes in that tree.
- * It's saved on the search stack and printed when debugging.
- */
- int line_no;
- int lines_found;
-#endif
-
-
- /* For continuations within the match tester */
- enum rx_test_match_entry test_match_resume_pt;
- struct rx_inx * saved_next_tr_table;
- struct rx_inx * saved_this_tr_table;
- int saved_reg;
- struct rx_backtrack_frame * saved_bf;
-
-};
-
-
-extern char rx_slowmap[];
-extern unsigned char rx_id_translation[];
-
-static __inline__ void
-init_fastmap (rxb, search_state)
- struct re_pattern_buffer * rxb;
- struct rx_search_state * search_state;
-{
- search_state->fastmap = (rxb->fastmap
- ? (char *)rxb->fastmap
- : (char *)rx_slowmap);
- /* Update the fastmap now if not correct already.
- * When the regexp was compiled, the fastmap was computed
- * and stored in a bitset. This expands the bitset into a
- * character array containing 1s and 0s.
- */
- if ((search_state->fastmap == rxb->fastmap) && !rxb->fastmap_accurate)
- rx_blow_up_fastmap (rxb);
- search_state->fastmap_chr = -1;
- search_state->fastmap_val = 0;
- search_state->fastmap_resume_pt = rx_fastmap_start;
-}
-
-static __inline__ void
-uninit_fastmap (rxb, search_state)
- struct re_pattern_buffer * rxb;
- struct rx_search_state * search_state;
-{
- /* Unset the fastmap sentinel */
- if (search_state->fastmap_chr >= 0)
- search_state->fastmap[search_state->fastmap_chr]
- = search_state->fastmap_val;
-}
-
-static __inline__ int
-fastmap_search (rxb, stop, get_burst, app_closure, search_state)
- struct re_pattern_buffer * rxb;
- int stop;
- rx_get_burst_fn get_burst;
- void * app_closure;
- struct rx_search_state * search_state;
-{
- enum rx_fastmap_entry pc;
-
- if (0)
- {
- return_continuation:
- search_state->fastmap_resume_pt = pc;
- return rx_fastmap_continuation;
- }
-
- pc = search_state->fastmap_resume_pt;
-
- switch (pc)
- {
- case rx_fastmap_start:
- init_fastmap_sentinal:
- /* For the sake of fast fastmapping, set a sentinal in the fastmap.
- * This sentinal will trap the fastmap loop when it reaches the last
- * valid character in a string half.
- *
- * This must be reset when the fastmap/search loop crosses a string
- * boundry, and before returning to the caller. So sometimes,
- * the fastmap loop is restarted with `continue', othertimes by
- * `goto init_fastmap_sentinal'.
- */
- if (search_state->outer_pos.size)
- {
- search_state->fastmap_chr = ((search_state->outer_pos.search_direction == 1)
- ? *(search_state->outer_pos.end - 1)
- : *search_state->outer_pos.string);
- search_state->fastmap_val
- = search_state->fastmap[search_state->fastmap_chr];
- search_state->fastmap[search_state->fastmap_chr] = 1;
- }
- else
- {
- search_state->fastmap_chr = -1;
- search_state->fastmap_val = 0;
- }
-
- if (search_state->outer_pos.pos >= search_state->outer_pos.end)
- goto fastmap_hit_bound;
- else
- {
- if (search_state->outer_pos.search_direction == 1)
- {
- if (search_state->fastmap_val)
- {
- for (;;)
- {
- while (!search_state->fastmap[*search_state->outer_pos.pos])
- ++search_state->outer_pos.pos;
- return rx_fastmap_ok;
- }
- }
- else
- {
- for (;;)
- {
- while (!search_state->fastmap[*search_state->outer_pos.pos])
- ++search_state->outer_pos.pos;
- if (*search_state->outer_pos.pos != search_state->fastmap_chr)
- return rx_fastmap_ok;
- else
- {
- ++search_state->outer_pos.pos;
- if (search_state->outer_pos.pos == search_state->outer_pos.end)
- goto fastmap_hit_bound;
- }
- }
- }
- }
- else
- {
- __const__ unsigned char * bound;
- bound = search_state->outer_pos.string - 1;
- if (search_state->fastmap_val)
- {
- for (;;)
- {
- while (!search_state->fastmap[*search_state->outer_pos.pos])
- --search_state->outer_pos.pos;
- return rx_fastmap_ok;
- }
- }
- else
- {
- for (;;)
- {
- while (!search_state->fastmap[*search_state->outer_pos.pos])
- --search_state->outer_pos.pos;
- if ((*search_state->outer_pos.pos != search_state->fastmap_chr) || search_state->fastmap_val)
- return rx_fastmap_ok;
- else
- {
- --search_state->outer_pos.pos;
- if (search_state->outer_pos.pos == bound)
- goto fastmap_hit_bound;
- }
- }
- }
- }
- }
-
- case rx_fastmap_string_break:
- fastmap_hit_bound:
- {
- /* If we hit a bound, it may be time to fetch another burst
- * of string, or it may be time to return a continuation to
- * the caller, or it might be time to fail.
- */
-
- int burst_state;
- burst_state = get_burst (&search_state->outer_pos, app_closure, stop);
- switch (burst_state)
- {
- case rx_get_burst_continuation:
- {
- pc = rx_fastmap_string_break;
- goto return_continuation;
- }
- case rx_get_burst_error:
- return rx_fastmap_error;
- case rx_get_burst_ok:
- goto init_fastmap_sentinal;
- case rx_get_burst_no_more:
- /* ...not a string split, simply no more string.
- *
- * When searching backward, running out of string
- * is reason to quit.
- *
- * When searching forward, we allow the possibility
- * of an (empty) match after the last character in the
- * virtual string. So, fall through to the matcher
- */
- return ( (search_state->outer_pos.search_direction == 1)
- ? rx_fastmap_ok
- : rx_fastmap_fail);
- }
- }
- }
-
-}
-
-
-
-#ifdef emacs
-/* The `emacs' switch turns on certain matching commands
- * that make sense only in Emacs.
- */
-#include "config.h"
-#include "lisp.h"
-#include "buffer.h"
-#include "syntax.h"
-/* Emacs uses `NULL' as a predicate. */
-#undef NULL
-#else /* not emacs */
-/* Setting RX_MEMDBUG is useful if you have dbmalloc. Maybe with similar
- * packages too.
- */
-#ifdef RX_MEMDBUG
-#include <malloc.h>
-#else /* not RX_RX_MEMDBUG */
-
-/* We used to test for `BSTRING' here, but only GCC and Emacs define
- * `BSTRING', as far as I know, and neither of them use this code.
- */
-#if HAVE_STRING_H || STDC_HEADERS
-#include <string.h>
-
-#ifndef bcmp
-#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
-#endif
-
-#ifndef bcopy
-#define bcopy(s, d, n) memcpy ((d), (s), (n))
-#endif
-
-#ifndef bzero
-#define bzero(s, n) memset ((s), 0, (n))
-#endif
-
-#else /* HAVE_STRING_H || STDC_HEADERS */
-#include <strings.h>
-#endif /* not RX_MEMDBUG */
-
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#else /* not STDC_HEADERS */
-char *malloc ();
-char *realloc ();
-#endif /* not STDC_HEADERS */
-
-#endif /* not emacs */
-
-
-
-/* Define the syntax basics for \<, \>, etc.
- * This must be nonzero for the wordchar and notwordchar pattern
- * commands in re_match_2.
- */
-#ifndef Sword
-#define Sword 1
-#endif
-
-/* How many characters in the character set. */
-#define CHAR_SET_SIZE (1 << CHARBITS)
-#define SYNTAX(c) re_syntax_table[c]
-RX_DECL char re_syntax_table[CHAR_SET_SIZE];
-
-#endif /* not emacs */
-
-
-/* Test if at very beginning or at very end of the virtual concatenation
- * of `string1' and `string2'. If only one string, it's `string2'.
- */
-
-#define AT_STRINGS_BEG() \
- ( -1 \
- == ((search_state.test_pos.pos - search_state.test_pos.string) \
- + search_state.test_pos.offset))
-
-#define AT_STRINGS_END() \
- ( (total_size - 1) \
- == ((search_state.test_pos.pos - search_state.test_pos.string) \
- + search_state.test_pos.offset))
-
-
-/* Test if POS + 1 points to a character which is word-constituent. We have
- * two special cases to check for: if past the end of string1, look at
- * the first character in string2; and if before the beginning of
- * string2, look at the last character in string1.
- *
- * Assumes `string1' exists, so use in conjunction with AT_STRINGS_BEG ().
- */
-#define LETTER_P(POS,OFF) \
- ( SYNTAX (fetch_char(POS, OFF, app_closure, stop)) \
- == Sword)
-
-/* Test if the character at D and the one after D differ with respect
- * to being word-constituent.
- */
-#define AT_WORD_BOUNDARY(d) \
- (AT_STRINGS_BEG () || AT_STRINGS_END () || LETTER_P (d,0) != LETTER_P (d, 1))
-
-
-#ifdef RX_SUPPORT_CONTINUATIONS
-#define RX_STACK_ALLOC(BYTES) malloc(BYTES)
-#define RX_STACK_FREE(MEM) free(MEM)
-#else
-#define RX_STACK_ALLOC(BYTES) alloca(BYTES)
-#define RX_STACK_FREE(MEM) \
- ((struct rx_stack_chunk *)MEM)->next_chunk = search_state.free_chunks; \
- search_state.free_chunks = ((struct rx_stack_chunk *)MEM);
-
-#endif
-
-#define PUSH(CHUNK_VAR,BYTES) \
- if (!CHUNK_VAR || (CHUNK_VAR->bytes_left < (BYTES))) \
- { \
- struct rx_stack_chunk * new_chunk; \
- if (search_state.free_chunks) \
- { \
- new_chunk = search_state.free_chunks; \
- search_state.free_chunks = search_state.free_chunks->next_chunk; \
- } \
- else \
- { \
- new_chunk = (struct rx_stack_chunk *)RX_STACK_ALLOC(search_state.chunk_bytes); \
- if (!new_chunk) \
- { \
- search_state.ret_val = 0; \
- goto test_do_return; \
- } \
- } \
- new_chunk->sp = (char *)new_chunk + sizeof (struct rx_stack_chunk); \
- new_chunk->bytes_left = (search_state.chunk_bytes \
- - (BYTES) \
- - sizeof (struct rx_stack_chunk)); \
- new_chunk->next_chunk = CHUNK_VAR; \
- CHUNK_VAR = new_chunk; \
- } \
- else \
- (CHUNK_VAR->sp += (BYTES)), (CHUNK_VAR->bytes_left -= (BYTES))
-
-#define POP(CHUNK_VAR,BYTES) \
- if (CHUNK_VAR->sp == ((char *)CHUNK_VAR + sizeof(*CHUNK_VAR))) \
- { \
- struct rx_stack_chunk * new_chunk = CHUNK_VAR->next_chunk; \
- RX_STACK_FREE(CHUNK_VAR); \
- CHUNK_VAR = new_chunk; \
- } \
- else \
- (CHUNK_VAR->sp -= BYTES), (CHUNK_VAR->bytes_left += BYTES)
-
-
-
-#define SRCH_TRANSLATE(C) search_state.translate[(unsigned char) (C)]
-
-
-
-
-#ifdef __STDC__
-RX_DECL __inline__ int
-rx_search (struct re_pattern_buffer * rxb,
- int startpos,
- int range,
- int stop,
- int total_size,
- rx_get_burst_fn get_burst,
- rx_back_check_fn back_check,
- rx_fetch_char_fn fetch_char,
- void * app_closure,
- struct re_registers * regs,
- struct rx_search_state * resume_state,
- struct rx_search_state * save_state)
-#else
-RX_DECL __inline__ int
-rx_search (rxb, startpos, range, stop, total_size,
- get_burst, back_check, fetch_char,
- app_closure, regs, resume_state, save_state)
- struct re_pattern_buffer * rxb;
- int startpos;
- int range;
- int stop;
- int total_size;
- rx_get_burst_fn get_burst;
- rx_back_check_fn back_check;
- rx_fetch_char_fn fetch_char;
- void * app_closure;
- struct re_registers * regs;
- struct rx_search_state * resume_state;
- struct rx_search_state * save_state;
-#endif
-{
- int pc;
- int test_state;
- struct rx_search_state search_state;
-
- if (!resume_state)
- pc = rx_outer_start;
- else
- {
- search_state = *resume_state;
- regs = search_state.saved_regs;
- rxb = search_state.saved_rxb;
- startpos = search_state.saved_startpos;
- range = search_state.saved_range;
- stop = search_state.saved_stop;
- total_size = search_state.saved_total_size;
- get_burst = search_state.saved_get_burst;
- back_check = search_state.saved_back_check;
- pc = search_state.outer_search_resume_pt;
- if (0)
- {
- return_continuation:
- if (save_state)
- {
- *save_state = search_state;
- save_state->saved_regs = regs;
- save_state->saved_rxb = rxb;
- save_state->saved_startpos = startpos;
- save_state->saved_range = range;
- save_state->saved_stop = stop;
- save_state->saved_total_size = total_size;
- save_state->saved_get_burst = get_burst;
- save_state->saved_back_check = back_check;
- save_state->outer_search_resume_pt = pc;
- }
- return rx_search_continuation;
- }
- }
-
- switch (pc)
- {
- case rx_outer_start:
- search_state.ret_val = rx_search_fail;
- ( search_state.lparen
- = search_state.rparen
- = search_state.best_lpspace
- = search_state.best_rpspace
- = 0);
-
- /* figure the number of registers we may need for use in backreferences.
- * the number here includes an element for register zero.
- */
- search_state.num_regs = rxb->re_nsub + 1;
-
-
- /* check for out-of-range startpos. */
- if ((startpos < 0) || (startpos > total_size))
- return rx_search_fail;
-
- /* fix up range if it might eventually take us outside the string. */
- {
- int endpos;
- endpos = startpos + range;
- if (endpos < -1)
- range = (-1 - startpos);
- else if (endpos > total_size)
- range = total_size - startpos;
- }
-
- /* if the search isn't to be a backwards one, don't waste time in a
- * long search for a pattern that says it is anchored.
- */
- if (rxb->begbuf_only && (range > 0))
- {
- if (startpos > 0)
- return rx_search_fail;
- else
- range = 1;
- }
-
- /* decide whether to use internal or user-provided reg buffers. */
- if (!regs || rxb->no_sub)
- {
- search_state.best_lpspace =
- (int *)REGEX_ALLOCATE (search_state.num_regs * sizeof(int));
- search_state.best_rpspace =
- (int *)REGEX_ALLOCATE (search_state.num_regs * sizeof(int));
- search_state.best_lparen = search_state.best_lpspace;
- search_state.best_rparen = search_state.best_rpspace;
- }
- else
- {
- /* have the register data arrays been allocated? */
- if (rxb->regs_allocated == REGS_UNALLOCATED)
- { /* no. so allocate them with malloc. we need one
- extra element beyond `search_state.num_regs' for the `-1' marker
- gnu code uses. */
- regs->num_regs = MAX (RE_NREGS, rxb->re_nsub + 1);
- regs->start = ((int *)
- malloc (regs->num_regs * sizeof ( int )));
- regs->end = ((int *)
- malloc (regs->num_regs * sizeof ( int )));
- if (regs->start == 0 || regs->end == 0)
- return rx_search_error;
- rxb->regs_allocated = REGS_REALLOCATE;
- }
- else if (rxb->regs_allocated == REGS_REALLOCATE)
- { /* yes. if we need more elements than were already
- allocated, reallocate them. if we need fewer, just
- leave it alone. */
- if (regs->num_regs < search_state.num_regs + 1)
- {
- regs->num_regs = search_state.num_regs + 1;
- regs->start = ((int *)
- realloc (regs->start,
- regs->num_regs * sizeof (int )));
- regs->end = ((int *)
- realloc (regs->end,
- regs->num_regs * sizeof ( int )));
- if (regs->start == 0 || regs->end == 0)
- return rx_search_error;
- }
- }
- else if (rxb->regs_allocated != REGS_FIXED)
- return rx_search_error;
-
- if (regs->num_regs < search_state.num_regs + 1)
- {
- search_state.best_lpspace =
- ((int *)
- REGEX_ALLOCATE (search_state.num_regs * sizeof(int )));
- search_state.best_rpspace =
- ((int *)
- REGEX_ALLOCATE (search_state.num_regs * sizeof(int )));
- search_state.best_lparen = search_state.best_lpspace;
- search_state.best_rparen = search_state.best_rpspace;
- }
- else
- {
- search_state.best_lparen = regs->start;
- search_state.best_rparen = regs->end;
- }
- }
-
- search_state.lparen =
- (int *) REGEX_ALLOCATE (search_state.num_regs * sizeof(int ));
- search_state.rparen =
- (int *) REGEX_ALLOCATE (search_state.num_regs * sizeof(int ));
-
- if (! ( search_state.best_rparen
- && search_state.best_lparen
- && search_state.lparen && search_state.rparen))
- return rx_search_error;
-
- search_state.best_last_l = search_state.best_last_r = -1;
-
- search_state.translate = (rxb->translate
- ? rxb->translate
- : rx_id_translation);
-
-
-
- /*
- * two nfa's were compiled.
- * `0' is complete.
- * `1' faster but gets registers wrong and ends too soon.
- */
- search_state.nfa_choice = (regs && !rxb->least_subs) ? '\0' : '\1';
-
- /* we have the option to look for the best match or the first
- * one we can find. if the user isn't asking for register information,
- * we don't need to find the best match.
- */
- search_state.first_found = !regs;
-
- if (range >= 0)
- {
- search_state.outer_pos.search_end = MIN (total_size, startpos + range) + 1;
- search_state.outer_pos.search_direction = 1;
- }
- else
- {
- search_state.outer_pos.search_end = MAX(-1, startpos + range);
- search_state.outer_pos.search_direction = -1;
- }
-
- /* the vacuous search always turns up nothing. */
- if ((search_state.outer_pos.search_direction == 1)
- ? (startpos > search_state.outer_pos.search_end)
- : (startpos < search_state.outer_pos.search_end))
- return rx_search_fail;
-
- /* now we build the starting state of the supernfa. */
- {
- struct rx_superset * start_contents;
- struct rx_nfa_state_set * start_nfa_set;
-
- /* we presume here that the nfa start state has only one
- * possible future with no side effects.
- */
- start_nfa_set = rxb->start->futures->destset;
- if ( rxb->rx.start_set
- && (rxb->rx.start_set->starts_for == &rxb->rx))
- start_contents = rxb->rx.start_set;
- else
- {
- start_contents =
- rx_superstate_eclosure_union (&rxb->rx,
- rx_superset_cons (&rxb->rx, 0, 0),
- start_nfa_set);
-
- if (!start_contents)
- return rx_search_fail;
-
- start_contents->starts_for = &rxb->rx;
- rxb->rx.start_set = start_contents;
- }
- if ( start_contents->superstate
- && (start_contents->superstate->rx_id == rxb->rx.rx_id))
- {
- search_state.start_super = start_contents->superstate;
- rx_lock_superstate (&rxb->rx, search_state.start_super);
- }
- else
- {
- rx_protect_superset (&rxb->rx, start_contents);
-
- search_state.start_super = rx_superstate (&rxb->rx, start_contents);
- if (!search_state.start_super)
- return rx_search_fail;
- rx_lock_superstate (&rxb->rx, search_state.start_super);
- rx_release_superset (&rxb->rx, start_contents);
- }
- }
-
-
-
- ( search_state.outer_pos.string
- = search_state.outer_pos.end
- = 0);
-
- search_state.outer_pos.offset = 0;
- search_state.outer_pos.size = 0;
- search_state.outer_pos.pos = (unsigned char *)startpos;
- init_fastmap (rxb, &search_state);
-
- search_state.fastmap_resume_pt = rx_fastmap_start;
- case rx_outer_fastmap:
- /* do { */
- pseudo_do:
- {
- {
- int fastmap_state;
- fastmap_state = fastmap_search (rxb, stop, get_burst, app_closure,
- &search_state);
- switch (fastmap_state)
- {
- case rx_fastmap_continuation:
- pc = rx_outer_fastmap;
- goto return_continuation;
- case rx_fastmap_fail:
- goto finish;
- case rx_fastmap_ok:
- break;
- }
- }
-
- /* now the fastmap loop has brought us to a plausible
- * starting point for a match. so, it's time to run the
- * nfa and see if a match occured.
- */
- startpos = ( search_state.outer_pos.pos
- - search_state.outer_pos.string
- + search_state.outer_pos.offset);
- if (startpos == search_state.outer_pos.search_end)
- goto finish;
- }
-
- search_state.test_match_resume_pt = rx_test_start;
- /* do interrupted for entry point... */
- case rx_outer_test:
- /* ...do continued */
- {
- goto test_match;
- test_returns_to_search:
- switch (test_state)
- {
- case rx_test_continuation:
- pc = rx_outer_test;
- goto return_continuation;
- case rx_test_error:
- search_state.ret_val = rx_search_error;
- goto finish;
- case rx_test_fail:
- break;
- case rx_test_ok:
- goto finish;
- }
- search_state.outer_pos.pos += search_state.outer_pos.search_direction;
- startpos += search_state.outer_pos.search_direction;
- }
- /* do interrupted for entry point... */
- case rx_outer_restore_pos:
- {
- int x;
- x = get_burst (&search_state.outer_pos, app_closure, stop);
- switch (x)
- {
- case rx_get_burst_continuation:
- pc = rx_outer_restore_pos;
- goto return_continuation;
- case rx_get_burst_error:
- search_state.ret_val = rx_search_error;
- goto finish;
- case rx_get_burst_no_more:
- goto finish;
- case rx_get_burst_ok:
- break;
- }
- } /* } while (...see below...) */
- if ((search_state.outer_pos.search_direction == 1)
- ? (startpos < search_state.outer_pos.search_end)
- : (startpos > search_state.outer_pos.search_end))
- goto pseudo_do;
-
-
- finish:
- uninit_fastmap (rxb, &search_state);
- if (search_state.start_super)
- rx_unlock_superstate (&rxb->rx, search_state.start_super);
-
-#ifdef regex_malloc
- if (search_state.lparen) free (search_state.lparen);
- if (search_state.rparen) free (search_state.rparen);
- if (search_state.best_lpspace) free (search_state.best_lpspace);
- if (search_state.best_rpspace) free (search_state.best_rpspace);
-#endif
- return search_state.ret_val;
- }
-
-
- test_match:
- {
- enum rx_test_match_entry test_pc;
- int inx;
- test_pc = search_state.test_match_resume_pt;
- if (test_pc == rx_test_start)
- {
-#ifdef RX_DEBUG
- search_state.backtrack_depth = 0;
-#endif
- search_state.last_l = search_state.last_r = 0;
- search_state.lparen[0] = startpos;
- search_state.super = search_state.start_super;
- search_state.c = search_state.nfa_choice;
- search_state.test_pos.pos = search_state.outer_pos.pos - 1;
- search_state.test_pos.string = search_state.outer_pos.string;
- search_state.test_pos.end = search_state.outer_pos.end;
- search_state.test_pos.offset = search_state.outer_pos.offset;
- search_state.test_pos.size = search_state.outer_pos.size;
- search_state.test_pos.search_direction = 1;
- search_state.counter_stack = 0;
- search_state.backtrack_stack = 0;
- search_state.backtrack_frame_bytes =
- (sizeof (struct rx_backtrack_frame)
- + (rxb->match_regs_on_stack
- ? sizeof (int ) * (search_state.num_regs + 1) * 2
- : 0));
- search_state.chunk_bytes = search_state.backtrack_frame_bytes * 64;
- search_state.free_chunks = 0;
- search_state.test_ret = rx_test_line_finished;
- search_state.could_have_continued = 0;
- }
- /* This is while (1)...except that the body of the loop is interrupted
- * by some alternative entry points.
- */
- pseudo_while_1:
- switch (test_pc)
- {
- case rx_test_cache_hit_loop:
- goto resume_continuation_1;
- case rx_test_backreference_check:
- goto resume_continuation_2;
- case rx_test_backtrack_return:
- goto resume_continuation_3;
- case rx_test_start:
-#ifdef RX_DEBUG
- /* There is a search tree with every node as set of deterministic
- * transitions in the super nfa. For every branch of a
- * backtrack point is an edge in the tree.
- * This counts up a pre-order of nodes in that tree.
- * It's saved on the search stack and printed when debugging.
- */
- search_state.line_no = 0;
- search_state.lines_found = 0;
-#endif
-
- top_of_cycle:
- /* A superstate is basicly a transition table, indexed by
- * characters from the string being tested, and containing
- * RX_INX (`instruction frame') structures.
- */
- search_state.ifr = &search_state.super->transitions [search_state.c];
-
- recurse_test_match:
- /* This is the point to which control is sent when the
- * test matcher `recurses'. Before jumping here, some variables
- * need to be saved on the stack and the next instruction frame
- * has to be computed.
- */
-
- restart:
- /* Some instructions don't advance the matcher, but just
- * carry out some side effects and fetch a new instruction.
- * To dispatch that new instruction, `goto restart'.
- */
-
- {
- struct rx_inx * next_tr_table;
- struct rx_inx * this_tr_table;
- /* The fastest route through the loop is when the instruction
- * is RX_NEXT_CHAR. This case is detected when SEARCH_STATE.IFR->DATA
- * is non-zero. In that case, it points to the next
- * superstate.
- *
- * This allows us to not bother fetching the bytecode.
- */
- next_tr_table = (struct rx_inx *)search_state.ifr->data;
- this_tr_table = search_state.super->transitions;
- while (next_tr_table)
- {
-#ifdef RX_DEBUG
- if (rx_debug_trace)
- {
- struct rx_superset * setp;
-
- fprintf (stderr, "%d %d>> re_next_char @ %d (%d)",
- search_state.line_no,
- search_state.backtrack_depth,
- (search_state.test_pos.pos - search_state.test_pos.string
- + search_state.test_pos.offset), search_state.c);
-
- search_state.super =
- ((struct rx_superstate *)
- ((char *)this_tr_table
- - ((unsigned long)
- ((struct rx_superstate *)0)->transitions)));
-
- setp = search_state.super->contents;
- fprintf (stderr, " superstet (rx=%d, &=%x: ",
- rxb->rx.rx_id, setp);
- while (setp)
- {
- fprintf (stderr, "%d ", setp->id);
- setp = setp->cdr;
- }
- fprintf (stderr, "\n");
- }
-#endif
- this_tr_table = next_tr_table;
- ++search_state.test_pos.pos;
- if (search_state.test_pos.pos == search_state.test_pos.end)
- {
- int burst_state;
- try_burst_1:
- burst_state = get_burst (&search_state.test_pos,
- app_closure, stop);
- switch (burst_state)
- {
- case rx_get_burst_continuation:
- search_state.saved_this_tr_table = this_tr_table;
- search_state.saved_next_tr_table = next_tr_table;
- test_pc = rx_test_cache_hit_loop;
- goto test_return_continuation;
-
- resume_continuation_1:
- /* Continuation one jumps here to do its work: */
- search_state.saved_this_tr_table = this_tr_table;
- search_state.saved_next_tr_table = next_tr_table;
- goto try_burst_1;
-
- case rx_get_burst_ok:
- /* get_burst succeeded...keep going */
- break;
-
- case rx_get_burst_no_more:
- search_state.test_ret = rx_test_line_finished;
- search_state.could_have_continued = 1;
- goto test_do_return;
-
- case rx_get_burst_error:
- /* An error... */
- search_state.test_ret = rx_test_internal_error;
- goto test_do_return;
- }
- }
- search_state.c = *search_state.test_pos.pos;
- search_state.ifr = this_tr_table + search_state.c;
- next_tr_table = (struct rx_inx *)search_state.ifr->data;
- } /* Fast loop through cached transition tables */
-
- /* Here when we ran out of cached next-char transitions.
- * So, it will be necessary to do a more expensive
- * dispatch on the current instruction. The superstate
- * pointer is allowed to become invalid during next-char
- * transitions -- now we must bring it up to date.
- */
- search_state.super =
- ((struct rx_superstate *)
- ((char *)this_tr_table
- - ((unsigned long)
- ((struct rx_superstate *)0)->transitions)));
- }
-
- /* We've encountered an instruction other than next-char.
- * Dispatch that instruction:
- */
- inx = (int)search_state.ifr->inx;
-#ifdef RX_DEBUG
- if (rx_debug_trace)
- {
- struct rx_superset * setp = search_state.super->contents;
-
- fprintf (stderr, "%d %d>> %s @ %d (%d)", search_state.line_no,
- search_state.backtrack_depth,
- inx_names[inx],
- (search_state.test_pos.pos - search_state.test_pos.string
- + (test_pos.half == 0 ? 0 : size1)), search_state.c);
-
- fprintf (stderr, " superstet (rx=%d, &=%x: ",
- rxb->rx.rx_id, setp);
- while (setp)
- {
- fprintf (stderr, "%d ", setp->id);
- setp = setp->cdr;
- }
- fprintf (stderr, "\n");
- }
-#endif
- switch ((enum rx_opcode)inx)
- {
- case rx_do_side_effects:
-
- /* RX_DO_SIDE_EFFECTS occurs when we cross epsilon
- * edges associated with parentheses, backreferencing, etc.
- */
- {
- struct rx_distinct_future * df =
- (struct rx_distinct_future *)search_state.ifr->data_2;
- struct rx_se_list * el = df->effects;
- /* Side effects come in lists. This walks down
- * a list, dispatching.
- */
- while (el)
- {
- long effect;
- effect = (long)el->car;
- if (effect < 0)
- {
-#ifdef RX_DEBUG
- if (rx_debug_trace)
- {
- struct rx_superset * setp = search_state.super->contents;
-
- fprintf (stderr, "....%d %d>> %s\n", search_state.line_no,
- search_state.backtrack_depth,
- efnames[-effect]);
- }
-#endif
- switch ((enum re_side_effects) effect)
-
- {
- case re_se_pushback:
- search_state.ifr = &df->future_frame;
- if (!search_state.ifr->data)
- {
- struct rx_superstate * sup;
- sup = search_state.super;
- rx_lock_superstate (rx, sup);
- if (!rx_handle_cache_miss (&rxb->rx,
- search_state.super,
- search_state.c,
- (search_state.ifr
- ->data_2)))
- {
- rx_unlock_superstate (rx, sup);
- search_state.test_ret = rx_test_internal_error;
- goto test_do_return;
- }
- rx_unlock_superstate (rx, sup);
- }
- /* --search_state.test_pos.pos; */
- search_state.c = 't';
- search_state.super
- = ((struct rx_superstate *)
- ((char *)search_state.ifr->data
- - (long)(((struct rx_superstate *)0)
- ->transitions)));
- goto top_of_cycle;
- break;
- case re_se_push0:
- {
- struct rx_counter_frame * old_cf
- = (search_state.counter_stack
- ? ((struct rx_counter_frame *)
- search_state.counter_stack->sp)
- : 0);
- struct rx_counter_frame * cf;
- PUSH (search_state.counter_stack,
- sizeof (struct rx_counter_frame));
- cf = ((struct rx_counter_frame *)
- search_state.counter_stack->sp);
- cf->tag = re_se_iter;
- cf->val = 0;
- cf->inherited_from = 0;
- cf->cdr = old_cf;
- break;
- }
- case re_se_fail:
- goto test_do_return;
- case re_se_begbuf:
- if (!AT_STRINGS_BEG ())
- goto test_do_return;
- break;
- case re_se_endbuf:
- if (!AT_STRINGS_END ())
- goto test_do_return;
- break;
- case re_se_wordbeg:
- if ( LETTER_P (&search_state.test_pos, 1)
- && ( AT_STRINGS_BEG()
- || !LETTER_P (&search_state.test_pos, 0)))
- break;
- else
- goto test_do_return;
- case re_se_wordend:
- if ( !AT_STRINGS_BEG ()
- && LETTER_P (&search_state.test_pos, 0)
- && (AT_STRINGS_END ()
- || !LETTER_P (&search_state.test_pos, 1)))
- break;
- else
- goto test_do_return;
- case re_se_wordbound:
- if (AT_WORD_BOUNDARY (&search_state.test_pos))
- break;
- else
- goto test_do_return;
- case re_se_notwordbound:
- if (!AT_WORD_BOUNDARY (&search_state.test_pos))
- break;
- else
- goto test_do_return;
- case re_se_hat:
- if (AT_STRINGS_BEG ())
- {
- if (rxb->not_bol)
- goto test_do_return;
- else
- break;
- }
- else
- {
- char pos_c = *search_state.test_pos.pos;
- if ( (SRCH_TRANSLATE (pos_c)
- == SRCH_TRANSLATE('\n'))
- && rxb->newline_anchor)
- break;
- else
- goto test_do_return;
- }
- case re_se_dollar:
- if (AT_STRINGS_END ())
- {
- if (rxb->not_eol)
- goto test_do_return;
- else
- break;
- }
- else
- {
- if ( ( SRCH_TRANSLATE (fetch_char
- (&search_state.test_pos, 1,
- app_closure, stop))
- == SRCH_TRANSLATE ('\n'))
- && rxb->newline_anchor)
- break;
- else
- goto test_do_return;
- }
-
- case re_se_try:
- /* This is the first side effect in every
- * expression.
- *
- * FOR NO GOOD REASON...get rid of it...
- */
- break;
-
- case re_se_pushpos:
- {
- int urhere =
- ((int)(search_state.test_pos.pos
- - search_state.test_pos.string)
- + search_state.test_pos.offset);
- struct rx_counter_frame * old_cf
- = (search_state.counter_stack
- ? ((struct rx_counter_frame *)
- search_state.counter_stack->sp)
- : 0);
- struct rx_counter_frame * cf;
- PUSH(search_state.counter_stack,
- sizeof (struct rx_counter_frame));
- cf = ((struct rx_counter_frame *)
- search_state.counter_stack->sp);
- cf->tag = re_se_pushpos;
- cf->val = urhere;
- cf->inherited_from = 0;
- cf->cdr = old_cf;
- break;
- }
-
- case re_se_chkpos:
- {
- int urhere =
- ((int)(search_state.test_pos.pos
- - search_state.test_pos.string)
- + search_state.test_pos.offset);
- struct rx_counter_frame * cf
- = ((struct rx_counter_frame *)
- search_state.counter_stack->sp);
- if (cf->val == urhere)
- goto test_do_return;
- cf->val = urhere;
- break;
- }
- break;
-
- case re_se_poppos:
- POP(search_state.counter_stack,
- sizeof (struct rx_counter_frame));
- break;
-
-
- case re_se_at_dot:
- case re_se_syntax:
- case re_se_not_syntax:
-#ifdef emacs
- this release lacks emacs support;
- (coming soon);
-#endif
- break;
- case re_se_win:
- case re_se_lparen:
- case re_se_rparen:
- case re_se_backref:
- case re_se_iter:
- case re_se_end_iter:
- case re_se_tv:
- case re_floogle_flap:
- search_state.ret_val = 0;
- goto test_do_return;
- }
- }
- else
- {
-#ifdef RX_DEBUG
- if (rx_debug_trace)
- fprintf (stderr, "....%d %d>> %s %d %d\n", search_state.line_no,
- search_state.backtrack_depth,
- efnames2[rxb->se_params [effect].se],
- rxb->se_params [effect].op1,
- rxb->se_params [effect].op2);
-#endif
- switch (rxb->se_params [effect].se)
- {
- case re_se_win:
- /* This side effect indicates that we've
- * found a match, though not necessarily the
- * best match. This is a fancy assignment to
- * register 0 unless the caller didn't
- * care about registers. In which case,
- * this stops the match.
- */
- {
- int urhere =
- ((int)(search_state.test_pos.pos
- - search_state.test_pos.string)
- + search_state.test_pos.offset);
-
- if ( (search_state.best_last_r < 0)
- || (urhere + 1 > search_state.best_rparen[0]))
- {
- /* Record the best known and keep
- * looking.
- */
- int x;
- for (x = 0; x <= search_state.last_l; ++x)
- search_state.best_lparen[x] = search_state.lparen[x];
- search_state.best_last_l = search_state.last_l;
- for (x = 0; x <= search_state.last_r; ++x)
- search_state.best_rparen[x] = search_state.rparen[x];
- search_state.best_rparen[0] = urhere + 1;
- search_state.best_last_r = search_state.last_r;
- }
- /* If we're not reporting the match-length
- * or other register info, we need look no
- * further.
- */
- if (search_state.first_found)
- {
- search_state.test_ret = rx_test_found_first;
- goto test_do_return;
- }
- }
- break;
- case re_se_lparen:
- {
- int urhere =
- ((int)(search_state.test_pos.pos
- - search_state.test_pos.string)
- + search_state.test_pos.offset);
-
- int reg = rxb->se_params [effect].op1;
-#if 0
- if (reg > search_state.last_l)
-#endif
- {
- search_state.lparen[reg] = urhere + 1;
- /* In addition to making this assignment,
- * we now know that lower numbered regs
- * that haven't already been assigned,
- * won't be. We make sure they're
- * filled with -1, so they can be
- * recognized as unassigned.
- */
- if (search_state.last_l < reg)
- while (++search_state.last_l < reg)
- search_state.lparen[search_state.last_l] = -1;
- }
- break;
- }
-
- case re_se_rparen:
- {
- int urhere =
- ((int)(search_state.test_pos.pos
- - search_state.test_pos.string)
- + search_state.test_pos.offset);
- int reg = rxb->se_params [effect].op1;
- search_state.rparen[reg] = urhere + 1;
- if (search_state.last_r < reg)
- {
- while (++search_state.last_r < reg)
- search_state.rparen[search_state.last_r]
- = -1;
- }
- break;
- }
-
- case re_se_backref:
- {
- int reg = rxb->se_params [effect].op1;
- if ( reg > search_state.last_r
- || search_state.rparen[reg] < 0)
- goto test_do_return;
-
- {
- int backref_status;
- check_backreference:
- backref_status
- = back_check (&search_state.test_pos,
- search_state.lparen[reg],
- search_state.rparen[reg],
- search_state.translate,
- app_closure,
- stop);
- switch (backref_status)
- {
- case rx_back_check_continuation:
- search_state.saved_reg = reg;
- test_pc = rx_test_backreference_check;
- goto test_return_continuation;
- resume_continuation_2:
- reg = search_state.saved_reg;
- goto check_backreference;
- case rx_back_check_fail:
- /* Fail */
- goto test_do_return;
- case rx_back_check_pass:
- /* pass --
- * test_pos now advanced to last
- * char matched by backref
- */
- break;
- }
- }
- break;
- }
- case re_se_iter:
- {
- struct rx_counter_frame * csp
- = ((struct rx_counter_frame *)
- search_state.counter_stack->sp);
- if (csp->val == rxb->se_params[effect].op2)
- goto test_do_return;
- else
- ++csp->val;
- break;
- }
- case re_se_end_iter:
- {
- struct rx_counter_frame * csp
- = ((struct rx_counter_frame *)
- search_state.counter_stack->sp);
- if (csp->val < rxb->se_params[effect].op1)
- goto test_do_return;
- else
- {
- struct rx_counter_frame * source = csp;
- while (source->inherited_from)
- source = source->inherited_from;
- if (!source || !source->cdr)
- {
- POP(search_state.counter_stack,
- sizeof(struct rx_counter_frame));
- }
- else
- {
- source = source->cdr;
- csp->val = source->val;
- csp->tag = source->tag;
- csp->cdr = 0;
- csp->inherited_from = source;
- }
- }
- break;
- }
- case re_se_tv:
- /* is a noop */
- break;
- case re_se_try:
- case re_se_pushback:
- case re_se_push0:
- case re_se_pushpos:
- case re_se_chkpos:
- case re_se_poppos:
- case re_se_at_dot:
- case re_se_syntax:
- case re_se_not_syntax:
- case re_se_begbuf:
- case re_se_hat:
- case re_se_wordbeg:
- case re_se_wordbound:
- case re_se_notwordbound:
- case re_se_wordend:
- case re_se_endbuf:
- case re_se_dollar:
- case re_se_fail:
- case re_floogle_flap:
- search_state.ret_val = 0;
- goto test_do_return;
- }
- }
- el = el->cdr;
- }
- /* Now the side effects are done,
- * so get the next instruction.
- * and move on.
- */
- search_state.ifr = &df->future_frame;
- goto restart;
- }
-
- case rx_backtrack_point:
- {
- /* A backtrack point indicates that we've reached a
- * non-determinism in the superstate NFA. This is a
- * loop that exhaustively searches the possibilities.
- *
- * A backtracking strategy is used. We keep track of what
- * registers are valid so we can erase side effects.
- *
- * First, make sure there is some stack space to hold
- * our state.
- */
-
- struct rx_backtrack_frame * bf;
-
- PUSH(search_state.backtrack_stack,
- search_state.backtrack_frame_bytes);
-#ifdef RX_DEBUG
- ++search_state.backtrack_depth;
-#endif
-
- bf = ((struct rx_backtrack_frame *)
- search_state.backtrack_stack->sp);
- {
- bf->stk_super = search_state.super;
- /* We prevent the current superstate from being
- * deleted from the superstate cache.
- */
- rx_lock_superstate (&rxb->rx, search_state.super);
-#ifdef RX_DEBUG
- bf->stk_search_state.line_no = search_state.line_no;
-#endif
- bf->stk_c = search_state.c;
- bf->stk_test_pos = search_state.test_pos;
- bf->stk_last_l = search_state.last_l;
- bf->stk_last_r = search_state.last_r;
- bf->df = ((struct rx_super_edge *)
- search_state.ifr->data_2)->options;
- bf->first_df = bf->df;
- bf->counter_stack_sp = (search_state.counter_stack
- ? search_state.counter_stack->sp
- : 0);
- bf->stk_test_ret = search_state.test_ret;
- if (rxb->match_regs_on_stack)
- {
- int x;
- int * stk =
- (int *)((char *)bf + sizeof (*bf));
- for (x = 0; x <= search_state.last_l; ++x)
- stk[x] = search_state.lparen[x];
- stk += x;
- for (x = 0; x <= search_state.last_r; ++x)
- stk[x] = search_state.rparen[x];
- }
- }
-
- /* Here is a while loop whose body is mainly a function
- * call and some code to handle a return from that
- * function.
- *
- * From here on for the rest of `case backtrack_point' it
- * is unsafe to assume that the search_state copies of
- * variables saved on the backtracking stack are valid
- * -- so read their values from the backtracking stack.
- *
- * This lets us use one generation fewer stack saves in
- * the call-graph of a search.
- */
-
- while_non_det_options:
-#ifdef RX_DEBUG
- ++search_state.lines_found;
- if (rx_debug_trace)
- fprintf (stderr, "@@@ %d calls %d @@@\n",
- search_state.line_no, search_state.lines_found);
-
- search_state.line_no = search_state.lines_found;
-#endif
-
- if (bf->df->next_same_super_edge[0] == bf->first_df)
- {
- /* This is a tail-call optimization -- we don't recurse
- * for the last of the possible futures.
- */
- search_state.ifr = (bf->df->effects
- ? &bf->df->side_effects_frame
- : &bf->df->future_frame);
-
- rx_unlock_superstate (&rxb->rx, search_state.super);
- POP(search_state.backtrack_stack,
- search_state.backtrack_frame_bytes);
-#ifdef RX_DEBUG
- --search_state.backtrack_depth;
-#endif
- goto restart;
- }
- else
- {
- if (search_state.counter_stack)
- {
- struct rx_counter_frame * old_cf
- = ((struct rx_counter_frame *)search_state.counter_stack->sp);
- struct rx_counter_frame * cf;
- PUSH(search_state.counter_stack, sizeof (struct rx_counter_frame));
- cf = ((struct rx_counter_frame *)search_state.counter_stack->sp);
- cf->tag = old_cf->tag;
- cf->val = old_cf->val;
- cf->inherited_from = old_cf;
- cf->cdr = 0;
- }
- /* `Call' this test-match block */
- search_state.ifr = (bf->df->effects
- ? &bf->df->side_effects_frame
- : &bf->df->future_frame);
- goto recurse_test_match;
- }
-
- /* Returns in this block are accomplished by
- * goto test_do_return. There are two cases.
- * If there is some search-stack left,
- * then it is a return from a `recursive' call.
- * If there is no search-stack left, then
- * we should return to the fastmap/search loop.
- */
-
- test_do_return:
-
- if (!search_state.backtrack_stack)
- {
-#ifdef RX_DEBUG
- if (rx_debug_trace)
- fprintf (stderr, "!!! %d bails returning %d !!!\n",
- search_state.line_no, search_state.test_ret);
-#endif
-
- /* No more search-stack -- this test is done. */
- if (search_state.test_ret)
- goto return_from_test_match;
- else
- goto error_in_testing_match;
- }
-
- /* Returning from a recursive call to
- * the test match block:
- */
-
- bf = ((struct rx_backtrack_frame *)
- search_state.backtrack_stack->sp);
-#ifdef RX_DEBUG
- if (rx_debug_trace)
- fprintf (stderr, "+++ %d returns %d (to %d)+++\n",
- search_state.line_no,
- search_state.test_ret,
- bf->stk_search_state.line_no);
-#endif
-
- while (search_state.counter_stack
- && (!bf->counter_stack_sp
- || (bf->counter_stack_sp
- != search_state.counter_stack->sp)))
- {
- POP(search_state.counter_stack,
- sizeof (struct rx_counter_frame));
- }
-
- if (search_state.test_ret == rx_test_error)
- {
- POP (search_state.backtrack_stack,
- search_state.backtrack_frame_bytes);
- goto test_do_return;
- }
-
- /* If a non-longest match was found and that is good
- * enough, return immediately.
- */
- if ( (search_state.test_ret == rx_test_found_first)
- && search_state.first_found)
- {
- rx_unlock_superstate (&rxb->rx, bf->stk_super);
- POP (search_state.backtrack_stack,
- search_state.backtrack_frame_bytes);
- goto test_do_return;
- }
-
- search_state.test_ret = bf->stk_test_ret;
- search_state.last_l = bf->stk_last_l;
- search_state.last_r = bf->stk_last_r;
- bf->df = bf->df->next_same_super_edge[0];
- search_state.super = bf->stk_super;
- search_state.c = bf->stk_c;
-#ifdef RX_DEBUG
- search_state.line_no = bf->stk_search_state.line_no;
-#endif
-
- if (rxb->match_regs_on_stack)
- {
- int x;
- int * stk =
- (int *)((char *)bf + sizeof (*bf));
- for (x = 0; x <= search_state.last_l; ++x)
- search_state.lparen[x] = stk[x];
- stk += x;
- for (x = 0; x <= search_state.last_r; ++x)
- search_state.rparen[x] = stk[x];
- }
-
- {
- int x;
- try_burst_2:
- x = get_burst (&bf->stk_test_pos, app_closure, stop);
- switch (x)
- {
- case rx_get_burst_continuation:
- search_state.saved_bf = bf;
- test_pc = rx_test_backtrack_return;
- goto test_return_continuation;
- resume_continuation_3:
- bf = search_state.saved_bf;
- goto try_burst_2;
- case rx_get_burst_no_more:
- /* Since we've been here before, it is some kind of
- * error that we can't return.
- */
- case rx_get_burst_error:
- search_state.test_ret = rx_test_internal_error;
- goto test_do_return;
- case rx_get_burst_ok:
- break;
- }
- }
- search_state.test_pos = bf->stk_test_pos;
- goto while_non_det_options;
- }
-
-
- case rx_cache_miss:
- /* Because the superstate NFA is lazily constructed,
- * and in fact may erode from underneath us, we sometimes
- * have to construct the next instruction from the hard way.
- * This invokes one step in the lazy-conversion.
- */
- search_state.ifr = rx_handle_cache_miss (&rxb->rx,
- search_state.super,
- search_state.c,
- search_state.ifr->data_2);
- if (!search_state.ifr)
- {
- search_state.test_ret = rx_test_internal_error;
- goto test_do_return;
- }
- goto restart;
-
- case rx_backtrack:
- /* RX_BACKTRACK means that we've reached the empty
- * superstate, indicating that match can't succeed
- * from this point.
- */
- goto test_do_return;
-
- case rx_next_char:
- case rx_error_inx:
- case rx_num_instructions:
- search_state.ret_val = 0;
- goto test_do_return;
- }
- goto pseudo_while_1;
- }
-
- /* Healthy exits from the test-match loop do a
- * `goto return_from_test_match' On the other hand,
- * we might end up here.
- */
- error_in_testing_match:
- test_state = rx_test_error;
- goto test_returns_to_search;
-
- /***** fastmap/search loop body
- * considering the results testing for a match
- */
-
- return_from_test_match:
-
- if (search_state.best_last_l >= 0)
- {
- if (regs && (regs->start != search_state.best_lparen))
- {
- bcopy (search_state.best_lparen, regs->start,
- regs->num_regs * sizeof (int));
- bcopy (search_state.best_rparen, regs->end,
- regs->num_regs * sizeof (int));
- }
- if (regs && !rxb->no_sub)
- {
- int q;
- int bound = (regs->num_regs > search_state.num_regs
- ? regs->num_regs
- : search_state.num_regs);
- int * s = regs->start;
- int * e = regs->end;
- for (q = search_state.best_last_l + 1; q < bound; ++q)
- s[q] = e[q] = -1;
- }
- search_state.ret_val = search_state.best_lparen[0];
- test_state = rx_test_ok;
- goto test_returns_to_search;
- }
- else
- {
- test_state = rx_test_fail;
- goto test_returns_to_search;
- }
-
- test_return_continuation:
- search_state.test_match_resume_pt = test_pc;
- test_state = rx_test_continuation;
- goto test_returns_to_search;
- }
-}
-
-
-
-#endif /* RX_WANT_RX_DEFS */
-
-
-
-#else /* RX_WANT_SE_DEFS */
- /* Integers are used to represent side effects.
- *
- * Simple side effects are given negative integer names by these enums.
- *
- * Non-negative names are reserved for complex effects.
- *
- * Complex effects are those that take arguments. For example,
- * a register assignment associated with a group is complex because
- * it requires an argument to tell which group is being matched.
- *
- * The integer name of a complex effect is an index into rxb->se_params.
- */
-
- RX_DEF_SE(1, re_se_try, = -1) /* Epsilon from start state */
-
- RX_DEF_SE(0, re_se_pushback, = re_se_try - 1)
- RX_DEF_SE(0, re_se_push0, = re_se_pushback -1)
- RX_DEF_SE(0, re_se_pushpos, = re_se_push0 - 1)
- RX_DEF_SE(0, re_se_chkpos, = re_se_pushpos -1)
- RX_DEF_SE(0, re_se_poppos, = re_se_chkpos - 1)
-
- RX_DEF_SE(1, re_se_at_dot, = re_se_poppos - 1) /* Emacs only */
- RX_DEF_SE(0, re_se_syntax, = re_se_at_dot - 1) /* Emacs only */
- RX_DEF_SE(0, re_se_not_syntax, = re_se_syntax - 1) /* Emacs only */
-
- RX_DEF_SE(1, re_se_begbuf, = re_se_not_syntax - 1) /* match beginning of buffer */
- RX_DEF_SE(1, re_se_hat, = re_se_begbuf - 1) /* match beginning of line */
-
- RX_DEF_SE(1, re_se_wordbeg, = re_se_hat - 1)
- RX_DEF_SE(1, re_se_wordbound, = re_se_wordbeg - 1)
- RX_DEF_SE(1, re_se_notwordbound, = re_se_wordbound - 1)
-
- RX_DEF_SE(1, re_se_wordend, = re_se_notwordbound - 1)
- RX_DEF_SE(1, re_se_endbuf, = re_se_wordend - 1)
-
- /* This fails except at the end of a line.
- * It deserves to go here since it is typicly one of the last steps
- * in a match.
- */
- RX_DEF_SE(1, re_se_dollar, = re_se_endbuf - 1)
-
- /* Simple effects: */
- RX_DEF_SE(1, re_se_fail, = re_se_dollar - 1)
-
- /* Complex effects. These are used in the 'se' field of
- * a struct re_se_params. Indexes into the se array
- * are stored as instructions on nfa edges.
- */
- RX_DEF_CPLX_SE(1, re_se_win, = 0)
- RX_DEF_CPLX_SE(1, re_se_lparen, = re_se_win + 1)
- RX_DEF_CPLX_SE(1, re_se_rparen, = re_se_lparen + 1)
- RX_DEF_CPLX_SE(0, re_se_backref, = re_se_rparen + 1)
- RX_DEF_CPLX_SE(0, re_se_iter, = re_se_backref + 1)
- RX_DEF_CPLX_SE(0, re_se_end_iter, = re_se_iter + 1)
- RX_DEF_CPLX_SE(0, re_se_tv, = re_se_end_iter + 1)
-
-#endif
-
-#endif
diff --git a/gnu/lib/libg++/include/std.h b/gnu/lib/libg++/include/std.h
deleted file mode 100644
index dcafc35..0000000
--- a/gnu/lib/libg++/include/std.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988, 1992 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _std_h
-#define _std_h 1
-
-#include <_G_config.h>
-#include <defines.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
-
-extern "C" {
-int strcasecmp _G_ARGS((const char*, const char*));
-}
-
-#endif
diff --git a/gnu/lib/libg++/include/stdiostream.h b/gnu/lib/libg++/include/stdiostream.h
deleted file mode 100644
index 8c8215e..0000000
--- a/gnu/lib/libg++/include/stdiostream.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Written by Per Bothner (bothner@cygnus.com). */
-
-#ifndef _STDIOSTREAM_H
-#define _STDIOSTREAM_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include <iostream.h>
-#include <stdio.h>
-
-class stdiobuf : public filebuf {
- protected:
- FILE *_file;
- public:
- FILE* stdiofile() const { return _file; }
- stdiobuf(FILE *);
- ~stdiobuf();
- int buffered () const { return _flags & _IO_UNBUFFERED ? 0 : 1; }
- void buffered (int);
- virtual streamsize sys_read(char*, streamsize);
- virtual streampos sys_seek(streamoff, _seek_dir);
- virtual streamsize sys_write(const char*, streamsize);
- virtual int sys_close();
- virtual int sync();
- virtual int overflow(int c = EOF);
- streamsize xsputn(const char* s, streamsize n);
-};
-
-class istdiostream : public istream
-{
-private:
- stdiobuf _file;
-public:
- istdiostream (FILE* __f) : _file(__f), istream() { init(&_file); }
- stdiobuf* rdbuf()/* const */ { return &_file; }
- int buffered () const { return _file.buffered (); }
- void buffered (int _i) { _file.buffered (_i); }
-};
-
-class ostdiostream : public ostream
-{
-private:
- stdiobuf _file;
-public:
- ostdiostream (FILE* __f) : _file(__f), ostream() { init(&_file); }
- stdiobuf* rdbuf() /* const */ { return &_file; }
- int buffered () const { return _file.buffered (); }
- void buffered (int _i) { _file.buffered (_i); }
-};
-
-#endif /* !_STDIOSTREAM_H */
diff --git a/gnu/lib/libg++/include/stream.h b/gnu/lib/libg++/include/stream.h
deleted file mode 100644
index f9569a5..0000000
--- a/gnu/lib/libg++/include/stream.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#ifndef _COMPAT_STREAM_H
-#define _COMPAT_STREAM_H
-
-// Compatibility with old library.
-
-#define _STREAM_COMPAT
-#include <iostream.h>
-
-extern char* form(const char*, ...);
-
-extern char* dec(long, int=0);
-extern char* dec(int, int=0);
-extern char* dec(unsigned long, int=0);
-extern char* dec(unsigned int, int=0);
-
-extern char* hex(long, int=0);
-extern char* hex(int, int=0);
-extern char* hex(unsigned long, int=0);
-extern char* hex(unsigned int, int=0);
-
-extern char* oct(long, int=0);
-extern char* oct(int, int=0);
-extern char* oct(unsigned long, int=0);
-extern char* oct(unsigned int, int=0);
-
-char* chr(char ch, int width = 0);
-char* str(const char* s, int width = 0);
-
-inline istream& WS(istream& str) { return ws(str); }
-
-#endif /* !_COMPAT_STREAM_H */
diff --git a/gnu/lib/libg++/include/streambuf.h b/gnu/lib/libg++/include/streambuf.h
deleted file mode 100644
index 7a3df54..0000000
--- a/gnu/lib/libg++/include/streambuf.h
+++ /dev/null
@@ -1,454 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#ifndef _STREAMBUF_H
-#define _STREAMBUF_H
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-/* #define _G_IO_THROW */ /* Not implemented: ios::failure */
-
-extern "C" {
-#include <libio.h>
-}
-//#include <_G_config.h>
-#ifdef _IO_NEED_STDARG_H
-#include <stdarg.h>
-#endif
-#ifndef _IO_va_list
-#define _IO_va_list char *
-#endif
-
-#ifndef EOF
-#define EOF (-1)
-#endif
-#ifndef NULL
-#ifdef __GNUC__
-#define NULL ((void*)0)
-#else
-#define NULL (0)
-#endif
-#endif
-
-#ifndef _IO_wchar_t
-#define _IO_wchar_t short
-#endif
-
-class istream; /* Work-around for a g++ name mangling bug. Fixed in 2.6. */
-class ostream; class streambuf;
-
-// In case some header files defines these as macros.
-#undef open
-#undef close
-
-extern "C" int __underflow(struct _IO_FILE*);
-extern "C" int __overflow(struct _IO_FILE*, int);
-
-typedef _IO_off_t streamoff;
-typedef _IO_fpos_t streampos;
-typedef _IO_ssize_t streamsize;
-
-typedef unsigned long __fmtflags;
-typedef unsigned char __iostate;
-
-struct _ios_fields
-{ // The data members of an ios.
- // Directly using _strbuf is dangerous, because the vtable
- // pointer can be NULL. Use rdbuf() when in doubt.
- streambuf *_strbuf;
- ostream* _tie;
- int _width;
- __fmtflags _flags;
- _IO_wchar_t _fill;
- __iostate _state;
- __iostate _exceptions;
- int _precision;
-
- void *_arrays; /* Support for ios::iword and ios::pword. */
-};
-
-#define _IOS_GOOD 0
-#define _IOS_EOF 1
-#define _IOS_FAIL 2
-#define _IOS_BAD 4
-
-#define _IO_INPUT 1
-#define _IO_OUTPUT 2
-#define _IO_ATEND 4
-#define _IO_APPEND 8
-#define _IO_TRUNC 16
-#define _IO_NOCREATE 32
-#define _IO_NOREPLACE 64
-#define _IO_BIN 128
-
-#ifdef _STREAM_COMPAT
-enum state_value {
- _good = _IOS_GOOD,
- _eof = _IOS_EOF,
- _fail = _IOS_FAIL,
- _bad = _IOS_BAD };
-enum open_mode {
- input = _IO_INPUT,
- output = _IO_OUTPUT,
- atend = _IO_ATEND,
- append = _IO_APPEND };
-#endif
-
-class ios : public _ios_fields {
- ios& operator=(ios&); /* Not allowed! */
- public:
- typedef __fmtflags fmtflags;
- typedef int iostate;
- typedef int openmode;
- typedef int streamsize;
- enum io_state {
- goodbit = _IOS_GOOD,
- eofbit = _IOS_EOF,
- failbit = _IOS_FAIL,
- badbit = _IOS_BAD };
- enum open_mode {
- in = _IO_INPUT,
- out = _IO_OUTPUT,
- ate = _IO_ATEND,
- app = _IO_APPEND,
- trunc = _IO_TRUNC,
- nocreate = _IO_NOCREATE,
- noreplace = _IO_NOREPLACE,
- bin = _IOS_BIN };
- enum seek_dir { beg, cur, end};
- // ANSI: typedef enum seek_dir seekdir; etc
- // NOTE: If adding flags here, before to update ios::bitalloc().
- enum { skipws=_IO_SKIPWS,
- left=_IO_LEFT, right=_IO_RIGHT, internal=_IO_INTERNAL,
- dec=_IO_DEC, oct=_IO_OCT, hex=_IO_HEX,
- showbase=_IO_SHOWBASE, showpoint=_IO_SHOWPOINT,
- uppercase=_IO_UPPERCASE, showpos=_IO_SHOWPOS,
- scientific=_IO_SCIENTIFIC, fixed=_IO_FIXED,
- unitbuf=_IO_UNITBUF, stdio=_IO_STDIO,
- dont_close=_IO_DONT_CLOSE // Don't delete streambuf on stream destruction
- };
- enum { // Masks.
- basefield=dec+oct+hex,
- floatfield = scientific+fixed,
- adjustfield = left+right+internal
- };
-
-#ifdef _IO_THROW
- class failure : public xmsg {
- ios* _stream;
- public:
- failure(ios* stream) { _stream = stream; }
- failure(string cause, ios* stream) { _stream = stream; }
- ios* rdios() const { return _stream; }
- };
-#endif
-
- ostream* tie() const { return _tie; }
- ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }
-
- // Methods to change the format state.
- _IO_wchar_t fill() const { return (_IO_wchar_t)_fill; }
- _IO_wchar_t fill(_IO_wchar_t newf)
- {_IO_wchar_t oldf = (_IO_wchar_t)_fill; _fill = (char)newf; return oldf;}
- fmtflags flags() const { return _flags; }
- fmtflags flags(fmtflags new_val) {
- fmtflags old_val = _flags; _flags = new_val; return old_val; }
- int precision() const { return _precision; }
- int precision(int newp) {
- unsigned short oldp = _precision; _precision = (unsigned short)newp;
- return oldp; }
- fmtflags setf(fmtflags val) {
- fmtflags oldbits = _flags;
- _flags |= val; return oldbits; }
- fmtflags setf(fmtflags val, fmtflags mask) {
- fmtflags oldbits = _flags;
- _flags = (_flags & ~mask) | (val & mask); return oldbits; }
- fmtflags unsetf(fmtflags mask) {
- fmtflags oldbits = _flags;
- _flags &= ~mask; return oldbits; }
- int width() const { return _width; }
- int width(int val) { int save = _width; _width = val; return save; }
-
-#ifdef _IO_THROW
- void _throw_failure() const { throw new ios::failure(this); }
-#else
- void _throw_failure() const { }
-#endif
- streambuf* rdbuf() const { return _strbuf; }
-#ifdef _STREAM_COMPAT
- void _IO_fix_vtable(); /* TEMPORARY - for binary compatibility */
- void _IO_fix_vtable() const; /* TEMPORARY - for binary compatibility */
-#endif
- streambuf* rdbuf(streambuf *_s) {
- streambuf *_old = _strbuf; _strbuf = _s; clear (); return _old; }
- void clear(iostate state = 0) {
- _state = _strbuf ? state : state|badbit;
- if (_state & _exceptions) _throw_failure(); }
- void set(iostate flag) { _state |= flag;
- if (_state & _exceptions) _throw_failure(); }
- void setstate(iostate flag) { _state |= flag; // ANSI
- if (_state & _exceptions) _throw_failure(); }
- int good() const { return _state == 0; }
- int eof() const { return _state & ios::eofbit; }
- int fail() const { return _state & (ios::badbit|ios::failbit); }
- int bad() const { return _state & ios::badbit; }
- iostate rdstate() const { return _state; }
- operator void*() const { return fail() ? (void*)0 : (void*)(-1); }
- int operator!() const { return fail(); }
- iostate exceptions() const { return _exceptions; }
- void exceptions(iostate enable) {
- _exceptions = enable;
- if (_state & _exceptions) _throw_failure(); }
-
- static int sync_with_stdio(int on);
- static void sync_with_stdio() { sync_with_stdio(1); }
- static fmtflags bitalloc();
- static int xalloc();
- void*& pword(int);
- void* pword(int) const;
- long& iword(int);
- long iword(int) const;
-
-#ifdef _STREAM_COMPAT
- void unset(state_value flag) { _state &= ~flag; }
- void close();
- int is_open();
- int readable();
- int writable();
-#endif
-
- // Used to initialize standard streams. Not needed in this implementation.
- class Init {
- public:
- Init () { }
- };
-
- protected:
- ios(streambuf* sb = 0, ostream* tie_to = 0) { init(sb, tie_to); }
- virtual ~ios();
- void init(streambuf* sb, ostream* tie = 0);
-};
-
-#if __GNUG__==1
-typedef int _seek_dir;
-#else
-typedef ios::seek_dir _seek_dir;
-#endif
-
-// Magic numbers and bits for the _flags field.
-// The magic numbers use the high-order bits of _flags;
-// the remaining bits are abailable for variable flags.
-// Note: The magic numbers must all be negative if stdio
-// emulation is desired.
-
-// A streammarker remembers a position in a buffer.
-// You are guaranteed to be able to seek back to it if it is saving().
-class streammarker : private _IO_marker {
- friend class streambuf;
- void set_offset(int offset) { _pos = offset; }
- public:
- streammarker(streambuf *sb);
- ~streammarker();
- int saving() { return 1; }
- int delta(streammarker&);
- int delta();
-};
-
-extern unsigned __adjust_column(unsigned start, const char *line, int count);
-
-struct streambuf : public _IO_FILE { // protected??
- friend class ios;
- friend class istream;
- friend class ostream;
- friend class streammarker;
- const void *&_vtable() { return *(const void**)((_IO_FILE*)this + 1); }
- protected:
- static streambuf* _list_all; /* List of open streambufs. */
- _IO_FILE*& xchain() { return _chain; }
- void _un_link();
- void _link_in();
- char* gptr() const
- { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_base : _IO_read_ptr; }
- char* pptr() const { return _IO_write_ptr; }
- char* egptr() const
- { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_end : _IO_read_end; }
- char* epptr() const { return _IO_write_end; }
- char* pbase() const { return _IO_write_base; }
- char* eback() const
- { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_base : _IO_read_base;}
- char* base() const { return _IO_buf_base; }
- char* ebuf() const { return _IO_buf_end; }
- int blen() const { return _IO_buf_end - _IO_buf_base; }
- void xput_char(char c) { *_IO_write_ptr++ = c; }
- int xflags() { return _IO_file_flags; }
- int xflags(int f) {int fl = _IO_file_flags; _IO_file_flags = f; return fl;}
- void xsetflags(int f) { _IO_file_flags |= f; }
- void xsetflags(int f, int mask)
- { _IO_file_flags = (_IO_file_flags & ~mask) | (f & mask); }
- void gbump(int n)
- { _IO_file_flags & _IO_IN_BACKUP ? (_IO_save_base+=n):(_IO_read_ptr+=n);}
- void pbump(int n) { _IO_write_ptr += n; }
- void setb(char* b, char* eb, int a=0);
- void setp(char* p, char* ep)
- { _IO_write_base=_IO_write_ptr=p; _IO_write_end=ep; }
- void setg(char* eb, char* g, char *eg) {
- if (_IO_file_flags & _IO_IN_BACKUP) _IO_free_backup_area(this);
- _IO_read_base = eb; _IO_read_ptr = g; _IO_read_end = eg; }
- char *shortbuf() { return _shortbuf; }
-
- int in_backup() { return _flags & _IO_IN_BACKUP; }
- // The start of the main get area: FIXME: wrong for write-mode filebuf?
- char *Gbase() { return in_backup() ? _IO_save_base : _IO_read_base; }
- // The end of the main get area:
- char *eGptr() { return in_backup() ? _IO_save_end : _IO_read_end; }
- // The start of the backup area:
- char *Bbase() { return in_backup() ? _IO_read_base : _IO_save_base; }
- char *Bptr() { return _IO_backup_base; }
- // The end of the backup area:
- char *eBptr() { return in_backup() ? _IO_read_end : _IO_save_end; }
- char *Nbase() { return _IO_save_base; }
- char *eNptr() { return _IO_save_end; }
- int have_backup() { return _IO_save_base != NULL; }
- int have_markers() { return _markers != NULL; }
- void free_backup_area();
- void unsave_markers(); // Make all streammarkers !saving().
- int put_mode() { return _flags & _IO_CURRENTLY_PUTTING; }
- int switch_to_get_mode();
-
- streambuf(int flags=0);
- public:
- static int flush_all();
- static void flush_all_linebuffered(); // Flush all line buffered files.
- virtual int underflow(); // Leave public for now
- virtual int overflow(int c = EOF); // Leave public for now
- virtual int doallocate();
- streampos sseekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
- streampos sseekpos(streampos pos, int mode = ios::in|ios::out);
-
- virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
- virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
- int seekmark(streammarker& mark, int delta = 0);
- int sputbackc(char c);
- int sungetc();
- virtual ~streambuf();
- int unbuffered() { return _flags & _IO_UNBUFFERED ? 1 : 0; }
- int linebuffered() { return _flags & _IO_LINE_BUF ? 1 : 0; }
- void unbuffered(int i)
- { if (i) _flags |= _IO_UNBUFFERED; else _flags &= ~_IO_UNBUFFERED; }
- void linebuffered(int i)
- { if (i) _flags |= _IO_LINE_BUF; else _flags &= ~_IO_LINE_BUF; }
- int allocate() { // For AT&T compatibility
- if (base() || unbuffered()) return 0;
- else return doallocate(); }
- // Allocate a buffer if needed; use _shortbuf if appropriate.
- void allocbuf() { if (base() == NULL) doallocbuf(); }
- void doallocbuf();
- virtual int sync();
- virtual int pbackfail(int c);
- virtual streambuf* setbuf(char* p, int len);
- int in_avail() { return _IO_read_end - _IO_read_ptr; }
- int out_waiting() { return _IO_write_ptr - _IO_write_base; }
- virtual streamsize xsputn(const char* s, streamsize n);
- streamsize sputn(const char* s, streamsize n) { return xsputn(s, n); }
- streamsize padn(char pad, streamsize n) { return _IO_padn(this, pad, n); }
- virtual streamsize xsgetn(char* s, streamsize n);
- streamsize sgetn(char* s, streamsize n) { return _IO_sgetn(this, s, n); }
- int ignore(int);
- virtual int get_column();
- virtual int set_column(int);
- long sgetline(char* buf, _IO_size_t n, char delim, int putback_delim);
- int sputc(int c) { return _IO_putc(c, this); }
- int sbumpc() { return _IO_getc(this); }
- int sgetc() { return _IO_peekc(this); }
- int snextc() {
- if (_IO_read_ptr >= _IO_read_end && __underflow(this) == EOF)
- return EOF;
- else return _IO_read_ptr++, sgetc(); }
- void stossc() { if (_IO_read_ptr < _IO_read_end) _IO_read_ptr++; }
- int vscan(char const *fmt0, _IO_va_list ap, ios* stream = NULL);
- int scan(char const *fmt0 ...);
- int vform(char const *fmt0, _IO_va_list ap);
- int form(char const *fmt0 ...);
-#if 0 /* Work in progress */
- int column(); // Current column number (of put pointer). -1 is unknown.
- void column(int c); // Set column number of put pointer to c.
-#endif
- virtual streamsize sys_read(char* buf, streamsize size);
- virtual streampos sys_seek(streamoff, _seek_dir);
- virtual streamsize sys_write(const char*, streamsize);
- virtual int sys_stat(void*); // Actually, a (struct stat*)
- virtual int sys_close();
-};
-
-// A backupbuf is a streambuf with full backup and savepoints on reading.
-// All standard streambufs in the GNU iostream library are backupbufs.
-
-class filebuf : public streambuf {
- protected:
- void init();
- public:
- static const int openprot; // Non-ANSI AT&T-ism: Default open protection.
- filebuf();
- filebuf(int fd);
- filebuf(int fd, char* p, int len);
- static filebuf *__new();
- ~filebuf();
- filebuf* attach(int fd);
- filebuf* open(const char *filename, const char *mode);
- filebuf* open(const char *filename, ios::openmode mode, int prot = 0664);
- virtual int underflow();
- virtual int overflow(int c = EOF);
- int is_open() const { return _fileno >= 0; }
- int fd() const { return is_open() ? _fileno : EOF; }
- filebuf* close();
- virtual int doallocate();
- virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
- virtual streambuf* setbuf(char* p, int len);
- streamsize xsputn(const char* s, streamsize n);
- streamsize xsgetn(char* s, streamsize n);
- virtual int sync();
- protected: // See documentation in filebuf.C.
-// virtual int pbackfail(int c);
- int is_reading() { return eback() != egptr(); }
- char* cur_ptr() { return is_reading() ? gptr() : pptr(); }
- /* System's idea of pointer */
- char* file_ptr() { return eGptr(); }
- int do_write(const char *data, int to_do);
- // Low-level operations (Usually invoke system calls.)
- virtual streamsize sys_read(char* buf, streamsize size);
- virtual streampos sys_seek(streamoff, _seek_dir);
- virtual streamsize sys_write(const char*, streamsize);
- virtual int sys_stat(void*); // Actually, a (struct stat*)
- virtual int sys_close();
-};
-
-inline void ios::init(streambuf* sb, ostream* tie_to) {
- _state = sb ? ios::goodbit : ios::badbit; _exceptions=0;
- _strbuf=sb; _tie = tie_to; _width=0; _fill=' ';
- _flags=ios::skipws|ios::dec; _precision=6; _arrays = 0; }
-
-inline ios::~ios() {
- if (!(_flags & (unsigned int)ios::dont_close)) delete rdbuf(); }
-#endif /* _STREAMBUF_H */
diff --git a/gnu/lib/libg++/include/strfile.h b/gnu/lib/libg++/include/strfile.h
deleted file mode 100644
index 950f2f5..0000000
--- a/gnu/lib/libg++/include/strfile.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include <libio.h>
-#ifdef TODO
-Merge into libio.h ?
-#endif
-
-typedef void *(*_IO_alloc_type) __P((_IO_size_t));
-typedef void (*_IO_free_type) __P((void*));
-
-struct _IO_str_fields
-{
- /* The current length is max(_len, _IO_write_ptr-_IO_write_base). */
- _IO_size_t _len;
- _IO_alloc_type _allocate_buffer;
- _IO_free_type _free_buffer;
-};
-
-typedef struct _IO_strfile_
-{
- struct _IO_FILE _f;
- const void *_vtable;
- struct _IO_str_fields _s;
-} _IO_strfile;
diff --git a/gnu/lib/libg++/include/strstream.h b/gnu/lib/libg++/include/strstream.h
deleted file mode 100644
index 3c8fd54..0000000
--- a/gnu/lib/libg++/include/strstream.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Written by Per Bothner (bothner@cygnus.com). */
-
-#ifndef __STRSTREAM_H
-#define __STRSTREAM_H
-#ifdef __GNUG__
-#pragma interface
-#endif
-#include <iostream.h>
-#include <strfile.h>
-
-class strstreambuf : public streambuf
-{
- struct _IO_str_fields _s;
-
- void init_dynamic(_IO_alloc_type alloc, _IO_free_type free,
- int initial_size = 128);
- void init_static(char *ptr, int size, char *pstart);
- void init_readonly(const char *ptr, int size);
- protected:
- int is_static() const { return _s._allocate_buffer == (_IO_alloc_type)0; }
- virtual int overflow(int = EOF);
- virtual int underflow();
- virtual int pbackfail(int c);
- public:
- virtual ~strstreambuf();
- strstreambuf() { init_dynamic(0, 0); }
- strstreambuf(int initial_size) { init_dynamic(0, 0, initial_size); }
- strstreambuf(void *(*alloc)(_IO_size_t), void (*free)(void*))
- { init_dynamic(alloc, free); }
- strstreambuf(char *ptr, int size, char *pstart = NULL)
- { init_static(ptr, size, pstart); }
- strstreambuf(unsigned char *ptr, int size, unsigned char *pstart = NULL)
- { init_static((char*)ptr, size, (char*)pstart); }
- strstreambuf(const char *ptr, int size)
- { init_readonly(ptr, size); }
- strstreambuf(const unsigned char *ptr, int size)
- { init_readonly((const char*)ptr, size); }
- strstreambuf(signed char *ptr, int size, signed char *pstart = NULL)
- { init_static((char*)ptr, size, (char*)pstart); }
- strstreambuf(const signed char *ptr, int size)
- { init_readonly((const char*)ptr, size); }
- // Note: frozen() is always true if is_static().
- int frozen() { return _flags & _IO_USER_BUF ? 1 : 0; }
- void freeze(int n=1)
- { if (!is_static())
- { if (n) _flags |= _IO_USER_BUF; else _flags &= ~_IO_USER_BUF; } }
- _IO_ssize_t pcount();
- char *str();
- virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
-};
-
-class strstreambase : virtual public ios {
- public:
- strstreambuf* rdbuf() { return (strstreambuf*)ios::rdbuf(); }
- protected:
- strstreambase() { }
- strstreambase(char *cp, int n, int mode=ios::out);
-};
-
-class istrstream : public strstreambase, public istream {
- public:
- istrstream(const char*, int=0);
-};
-
-class ostrstream : public strstreambase, public ostream {
- public:
- ostrstream();
- ostrstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){}
- _IO_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); }
- char *str() { return ((strstreambuf*)_strbuf)->str(); }
- void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); }
- int frozen() { return ((strstreambuf*)_strbuf)->frozen(); }
-};
-
-class strstream : public strstreambase, public iostream {
- public:
- strstream() : strstreambase() { init(new strstreambuf()); }
- strstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){}
- _IO_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); }
- char *str() { return ((strstreambuf*)_strbuf)->str(); }
- void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); }
- int frozen() { return ((strstreambuf*)_strbuf)->frozen(); }
-};
-
-#endif /*!__STRSTREAM_H*/
diff --git a/gnu/lib/libg++/libg++/ACG.cc b/gnu/lib/libg++/libg++/ACG.cc
deleted file mode 100644
index 6206080..0000000
--- a/gnu/lib/libg++/libg++/ACG.cc
+++ /dev/null
@@ -1,292 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1989 Free Software Foundation
-
-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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <ACG.h>
-#include <assert.h>
-
-//
-// This is an extension of the older implementation of Algorithm M
-// which I previously supplied. The main difference between this
-// version and the old code are:
-//
-// + Andres searched high & low for good constants for
-// the LCG.
-//
-// + theres more bit chopping going on.
-//
-// The following contains his comments.
-//
-// agn@UNH.CS.CMU.EDU sez..
-//
-// The generator below is based on 2 well known
-// methods: Linear Congruential (LCGs) and Additive
-// Congruential generators (ACGs).
-//
-// The LCG produces the longest possible sequence
-// of 32 bit random numbers, each being unique in
-// that sequence (it has only 32 bits of state).
-// It suffers from 2 problems: a) Independence
-// isnt great, that is the (n+1)th number is
-// somewhat related to the preceding one, unlike
-// flipping a coin where knowing the past outcomes
-// dont help to predict the next result. b)
-// Taking parts of a LCG generated number can be
-// quite non-random: for example, looking at only
-// the least significant byte gives a permuted
-// 8-bit counter (that has a period length of only
-// 256). The advantage of an LCA is that it is
-// perfectly uniform when run for the entire period
-// length (and very uniform for smaller sequences
-// too, if the parameters are chosen carefully).
-//
-// ACGs have extremly long period lengths and
-// provide good independence. Unfortunately,
-// uniformity isnt not too great. Furthermore, I
-// didnt find any theoretically analysis of ACGs
-// that addresses uniformity.
-//
-// The RNG given below will return numbers
-// generated by an LCA that are permuted under
-// control of a ACG. 2 permutations take place: the
-// 4 bytes of one LCG generated number are
-// subjected to one of 16 permutations selected by
-// 4 bits of the ACG. The permutation a such that
-// byte of the result may come from each byte of
-// the LCG number. This effectively destroys the
-// structure within a word. Finally, the sequence
-// of such numbers is permuted within a range of
-// 256 numbers. This greatly improves independence.
-//
-//
-// Algorithm M as describes in Knuths "Art of Computer Programming",
-// Vol 2. 1969
-// is used with a linear congruential generator (to get a good uniform
-// distribution) that is permuted with a Fibonacci additive congruential
-// generator to get good independence.
-//
-// Bit, byte, and word distributions were extensively tested and pass
-// Chi-squared test near perfect scores (>7E8 numbers tested, Uniformity
-// assumption holds with probability > 0.999)
-//
-// Run-up tests for on 7E8 numbers confirm independence with
-// probability > 0.97.
-//
-// Plotting random points in 2d reveals no apparent structure.
-//
-// Autocorrelation on sequences of 5E5 numbers (A(i) = SUM X(n)*X(n-i),
-// i=1..512)
-// results in no obvious structure (A(i) ~ const).
-//
-// Except for speed and memory requirements, this generator outperforms
-// random() for all tests. (random() scored rather low on uniformity tests,
-// while independence test differences were less dramatic).
-//
-// AGN would like to..
-// thanks to M.Mauldin, H.Walker, J.Saxe and M.Molloy for inspiration & help.
-//
-// And I would (DGC) would like to thank Donald Kunth for AGN for letting me
-// use his extensions in this implementation.
-//
-
-//
-// Part of the table on page 28 of Knuth, vol II. This allows us
-// to adjust the size of the table at the expense of shorter sequences.
-//
-
-static randomStateTable[][3] = {
-{3,7,16}, {4,9, 32}, {3,10, 32}, {1,11, 32}, {1,15,64}, {3,17,128},
-{7,18,128}, {3,20,128}, {2,21, 128}, {1,22, 128}, {5,23, 128}, {3,25, 128},
-{2,29, 128}, {3,31, 128}, {13,33, 256}, {2,35, 256}, {11,36, 256},
-{14,39,256}, {3,41,256}, {9,49,256}, {3,52,256}, {24,55,256}, {7,57, 256},
-{19,58,256}, {38,89,512}, {17,95,512}, {6,97,512}, {11,98,512}, {-1,-1,-1} };
-
-//
-// spatial permutation table
-// RANDOM_PERM_SIZE must be a power of two
-//
-
-#define RANDOM_PERM_SIZE 64
-_G_uint32_t randomPermutations[RANDOM_PERM_SIZE] = {
-0xffffffff, 0x00000000, 0x00000000, 0x00000000, // 3210
-0x0000ffff, 0x00ff0000, 0x00000000, 0xff000000, // 2310
-0xff0000ff, 0x0000ff00, 0x00000000, 0x00ff0000, // 3120
-0x00ff00ff, 0x00000000, 0xff00ff00, 0x00000000, // 1230
-
-0xffff0000, 0x000000ff, 0x00000000, 0x0000ff00, // 3201
-0x00000000, 0x00ff00ff, 0x00000000, 0xff00ff00, // 2301
-0xff000000, 0x00000000, 0x000000ff, 0x00ffff00, // 3102
-0x00000000, 0x00000000, 0x00000000, 0xffffffff, // 2103
-
-0xff00ff00, 0x00000000, 0x00ff00ff, 0x00000000, // 3012
-0x0000ff00, 0x00000000, 0x00ff0000, 0xff0000ff, // 2013
-0x00000000, 0x00000000, 0xffffffff, 0x00000000, // 1032
-0x00000000, 0x0000ff00, 0xffff0000, 0x000000ff, // 1023
-
-0x00000000, 0xffffffff, 0x00000000, 0x00000000, // 0321
-0x00ffff00, 0xff000000, 0x00000000, 0x000000ff, // 0213
-0x00000000, 0xff000000, 0x0000ffff, 0x00ff0000, // 0132
-0x00000000, 0xff00ff00, 0x00000000, 0x00ff00ff // 0123
-};
-
-//
-// SEED_TABLE_SIZE must be a power of 2
-//
-#define SEED_TABLE_SIZE 32
-static _G_uint32_t seedTable[SEED_TABLE_SIZE] = {
-0xbdcc47e5, 0x54aea45d, 0xec0df859, 0xda84637b,
-0xc8c6cb4f, 0x35574b01, 0x28260b7d, 0x0d07fdbf,
-0x9faaeeb0, 0x613dd169, 0x5ce2d818, 0x85b9e706,
-0xab2469db, 0xda02b0dc, 0x45c60d6e, 0xffe49d10,
-0x7224fea3, 0xf9684fc9, 0xfc7ee074, 0x326ce92a,
-0x366d13b5, 0x17aaa731, 0xeb83a675, 0x7781cb32,
-0x4ec7c92d, 0x7f187521, 0x2cf346b4, 0xad13310f,
-0xb89cff2b, 0x12164de1, 0xa865168d, 0x32b56cdf
-};
-
-//
-// The LCG used to scramble the ACG
-//
-//
-// LC-parameter selection follows recommendations in
-// "Handbook of Mathematical Functions" by Abramowitz & Stegun 10th, edi.
-//
-// LC_A = 251^2, ~= sqrt(2^32) = 66049
-// LC_C = result of a long trial & error series = 3907864577
-//
-
-static const _G_uint32_t LC_A = 66049;
-static const _G_uint32_t LC_C = 3907864577;
-static inline _G_uint32_t LCG(_G_uint32_t x)
-{
- return( x * LC_A + LC_C );
-}
-
-
-ACG::ACG(_G_uint32_t seed, int size)
-{
-
- initialSeed = seed;
-
- //
- // Determine the size of the state table
- //
-
- for (register int l = 0;
- randomStateTable[l][0] != -1 && randomStateTable[l][1] < size;
- l++);
-
- if (randomStateTable[l][1] == -1) {
- l--;
- }
-
- initialTableEntry = l;
-
- stateSize = randomStateTable[ initialTableEntry ][ 1 ];
- auxSize = randomStateTable[ initialTableEntry ][ 2 ];
-
- //
- // Allocate the state table & the auxillary table in a single malloc
- //
-
- state = new _G_uint32_t[stateSize + auxSize];
- auxState = &state[stateSize];
-
- reset();
-}
-
-//
-// Initialize the state
-//
-void
-ACG::reset()
-{
- register _G_uint32_t u;
-
- if (initialSeed < SEED_TABLE_SIZE) {
- u = seedTable[ initialSeed ];
- } else {
- u = initialSeed ^ seedTable[ initialSeed & (SEED_TABLE_SIZE-1) ];
- }
-
-
- j = randomStateTable[ initialTableEntry ][ 0 ] - 1;
- k = randomStateTable[ initialTableEntry ][ 1 ] - 1;
-
- register int i;
- for(i = 0; i < stateSize; i++) {
- state[i] = u = LCG(u);
- }
-
- for (i = 0; i < auxSize; i++) {
- auxState[i] = u = LCG(u);
- }
-
- k = u % stateSize;
- int tailBehind = (stateSize - randomStateTable[ initialTableEntry ][ 0 ]);
- j = k - tailBehind;
- if (j < 0) {
- j += stateSize;
- }
-
- lcgRecurr = u;
-
- assert(sizeof(double) == 2 * sizeof(_G_int32_t));
-}
-
-ACG::~ACG()
-{
- if (state) delete state;
- state = 0;
- // don't delete auxState, it's really an alias for state.
-}
-
-//
-// Returns 32 bits of random information.
-//
-
-_G_uint32_t
-ACG::asLong()
-{
- _G_uint32_t result = state[k] + state[j];
- state[k] = result;
- j = (j <= 0) ? (stateSize-1) : (j-1);
- k = (k <= 0) ? (stateSize-1) : (k-1);
-
- short int auxIndex = (result >> 24) & (auxSize - 1);
- register _G_uint32_t auxACG = auxState[auxIndex];
- auxState[auxIndex] = lcgRecurr = LCG(lcgRecurr);
-
- //
- // 3c is a magic number. We are doing four masks here, so we
- // do not want to run off the end of the permutation table.
- // This insures that we have always got four entries left.
- //
- register _G_uint32_t *perm = & randomPermutations[result & 0x3c];
-
- result = *(perm++) & auxACG;
- result |= *(perm++) & ((auxACG << 24)
- | ((auxACG >> 8)& 0xffffff));
- result |= *(perm++) & ((auxACG << 16)
- | ((auxACG >> 16) & 0xffff));
- result |= *(perm++) & ((auxACG << 8)
- | ((auxACG >> 24) & 0xff));
-
- return(result);
-}
diff --git a/gnu/lib/libg++/libg++/AllocRing.cc b/gnu/lib/libg++/libg++/AllocRing.cc
deleted file mode 100644
index 5be1ff0..0000000
--- a/gnu/lib/libg++/libg++/AllocRing.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1989 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <std.h>
-#include <AllocRing.h>
-#include <new.h>
-
-AllocRing::AllocRing(int max)
- :n(max), current(0), nodes(new AllocQNode[max])
-{
- for (int i = 0; i < n; ++i)
- {
- nodes[i].ptr = 0;
- nodes[i].sz = 0;
- }
-}
-
-int AllocRing::find(void* p)
-{
- if (p == 0) return -1;
-
- for (int i = 0; i < n; ++i)
- if (nodes[i].ptr == p)
- return i;
-
- return -1;
-}
-
-
-void AllocRing::clear()
-{
- for (int i = 0; i < n; ++i)
- {
- if (nodes[i].ptr != 0)
- {
- delete(nodes[i].ptr);
- nodes[i].ptr = 0;
- }
- nodes[i].sz = 0;
- }
- current = 0;
-}
-
-
-void AllocRing::free(void* p)
-{
- int idx = find(p);
- if (idx >= 0)
- {
- delete nodes[idx].ptr;
- nodes[idx].ptr = 0;
- }
-}
-
-AllocRing::~AllocRing()
-{
- clear();
-}
-
-int AllocRing::contains(void* p)
-{
- return find(p) >= 0;
-}
-
-static inline unsigned int good_size(unsigned int s)
-{
- unsigned int req = s + 4;
- unsigned int good = 8;
- while (good < req) good <<= 1;
- return good - 4;
-}
-
-void* AllocRing::alloc(int s)
-{
- unsigned int size = good_size(s);
-
- void* p;
- if (nodes[current].ptr != 0 &&
- nodes[current].sz >= int(size) &&
- nodes[current].sz < int(4 * size))
- p = nodes[current].ptr;
- else
- {
- if (nodes[current].ptr != 0) delete nodes[current].ptr;
- p = new char[size];
- nodes[current].ptr = p;
- nodes[current].sz = size;
- }
- ++current;
- if (current >= n) current = 0;
- return p;
-}
diff --git a/gnu/lib/libg++/libg++/Binomial.cc b/gnu/lib/libg++/libg++/Binomial.cc
deleted file mode 100644
index 7166e55..0000000
--- a/gnu/lib/libg++/libg++/Binomial.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <Binomial.h>
-
-double Binomial::operator()()
-{
- int s = 0;
- for (int i = 0; i < pN; i++) {
- if (pGenerator -> asDouble() < pU) {
- s++;
- }
- }
- return(double(s));
-}
-
diff --git a/gnu/lib/libg++/libg++/BitSet.cc b/gnu/lib/libg++/libg++/BitSet.cc
deleted file mode 100644
index 397c750..0000000
--- a/gnu/lib/libg++/libg++/BitSet.cc
+++ /dev/null
@@ -1,1006 +0,0 @@
-/*
-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.
-*/
-
-/*
- BitSet class implementation
- */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <BitSet.h>
-#include <std.h>
-#include <limits.h>
-#include <Obstack.h>
-#include <AllocRing.h>
-#include <new.h>
-#include <builtin.h>
-#include <string.h>
-#include <strstream.h>
-
-void BitSet::error(const char* msg) const
-{
- (*lib_error_handler)("BitSet", msg);
-}
-
-// globals & constants
-
-BitSetRep _nilBitSetRep = { 0, 1, 0, {0} }; // nil BitSets point here
-
-#define ONES ((unsigned short)(~0L))
-#define MAXBitSetRep_SIZE ((1 << (sizeof(short)*CHAR_BIT - 1)) - 1)
-#define MINBitSetRep_SIZE 16
-
-#ifndef MALLOC_MIN_OVERHEAD
-#define MALLOC_MIN_OVERHEAD 4
-#endif
-
-// break things up into .s indices and positions
-
-
-// mask out bits from left
-
-static inline unsigned short lmask(int p)
-{
- return ONES << p;
-}
-
-// mask out high bits
-
-static inline unsigned short rmask(int p)
-{
- return ONES >> (BITSETBITS - 1 - p);
-}
-
-
-inline static BitSetRep* BSnew(int newlen)
-{
- unsigned int siz = sizeof(BitSetRep) + newlen * sizeof(short)
- + MALLOC_MIN_OVERHEAD;
- unsigned int allocsiz = MINBitSetRep_SIZE;;
- while (allocsiz < siz) allocsiz <<= 1;
- allocsiz -= MALLOC_MIN_OVERHEAD;
- if (allocsiz >= MAXBitSetRep_SIZE * sizeof(short))
- (*lib_error_handler)("BitSet", "Requested length out of range");
-
- BitSetRep* rep = (BitSetRep *) new char[allocsiz];
- memset(rep, 0, allocsiz);
- rep->sz = (allocsiz - sizeof(BitSetRep) + sizeof(short)) / sizeof(short);
- return rep;
-}
-
-BitSetRep* BitSetalloc(BitSetRep* old, const unsigned short* src, int srclen,
- int newvirt, int newlen)
-{
- if (old == &_nilBitSetRep) old = 0;
- BitSetRep* rep;
- if (old == 0 || newlen >= old->sz)
- rep = BSnew(newlen);
- else
- rep = old;
-
- rep->len = newlen;
- rep->virt = newvirt;
-
- if (srclen != 0 && src != rep->s)
- memcpy(rep->s, src, srclen * sizeof(short));
- // BUG fix: extend virtual bit! 20 Oct 1992 Kevin Karplus
- if (rep->virt)
- memset(&rep->s[srclen], ONES, (newlen - srclen) * sizeof(short));
- if (old != rep && old != 0) delete old;
- return rep;
-}
-
-BitSetRep* BitSetresize(BitSetRep* old, int newlen)
-{
- BitSetRep* rep;
- if (old == 0 || old == &_nilBitSetRep)
- {
- rep = BSnew(newlen);
- rep->virt = 0;
- }
- else if (newlen >= old->sz)
- {
- rep = BSnew(newlen);
- memcpy(rep->s, old->s, old->len * sizeof(short));
- rep->virt = old->virt;
- // BUG fix: extend virtual bit! 20 Oct 1992 Kevin Karplus
- if (rep->virt)
- memset(&rep->s[old->len], ONES, (newlen - old->len) * sizeof(short));
- delete old;
- }
- else
- {
- rep = old;
- if (rep->len < newlen)
- memset(&rep->s[rep->len],
- rep->virt ? ONES : 0,
- (newlen - rep->len) * sizeof(short));
- }
-
- rep->len = newlen;
-
- return rep;
-}
-
-// same, for straight copy
-
-BitSetRep* BitSetcopy(BitSetRep* old, const BitSetRep* src)
-{
- BitSetRep* rep;
- if (old == &_nilBitSetRep) old = 0;
- if (src == 0 || src == &_nilBitSetRep)
- {
- if (old == 0)
- rep = BSnew(0);
- else
- rep = old;
- rep->len = 0;
- rep->virt = 0;
- }
- else if (old == src)
- return old;
- else
- {
- int newlen = src->len;
- if (old == 0 || newlen > old->sz)
- {
- rep = BSnew(newlen);
- if (old != 0) delete old;
- }
- else
- rep = old;
-
- memcpy(rep->s, src->s, newlen * sizeof(short));
- rep->len = newlen;
- rep->virt = src->virt;
- }
- return rep;
-}
-
-
-// remove unneeded top bits
-
-inline static void trim(BitSetRep* rep)
-{
- int l = rep->len;
- unsigned short* s = &(rep->s[l - 1]);
-
- if (rep->virt == 0)
- while (l > 0 && *s-- == 0) --l;
- else
- while (l > 0 && *s-- == ONES) --l;
- rep->len = l;
-}
-
-int operator == (const BitSet& x, const BitSet& y)
-{
- if (x.rep->virt != y.rep->virt)
- return 0;
- int xl = x.rep->len;
- int yl = y.rep->len;
-
- unsigned short* xs = x.rep->s;
- unsigned short* ys = y.rep->s;
- if (xl<=yl)
- {
- if (memcmp((void*)xs, (void*)ys, xl * sizeof(short)))
- return 0;
- for (register int i=xl; i<yl; i++)
- if (ys[i])
- return 0;
- return 1;
- }
- else
- {
- if (memcmp((void*)xs, (void*)ys, yl * sizeof(short)))
- return 0;
- for (register int i=yl; i<xl; i++)
- if (xs[i])
- return 0;
- return 1;
- }
-}
-
-int operator <= (const BitSet& x, const BitSet& y)
-{
- if (x.rep->virt > y.rep->virt)
- return 0;
-
- int xl = x.rep->len;
- int yl = y.rep->len;
-
- unsigned short* xs = x.rep->s;
- unsigned short* ys = y.rep->s;
- unsigned short* topx = &(xs[xl]);
- unsigned short* topy = &(ys[yl]);
-
- while (xs < topx && ys < topy)
- {
- unsigned short a = *xs++;
- unsigned short b = *ys++;
- if ((a | b) != b)
- return 0;
- }
- if (xl == yl)
- return x.rep->virt <= y.rep->virt;
- else if (xl < yl)
- return !x.rep->virt;
- else
- return y.rep->virt;
-}
-
-
-int operator < (const BitSet& x, const BitSet& y)
-{
- if (x.rep->virt > y.rep->virt)
- return 0;
-
- int xl = x.rep->len;
- int yl = y.rep->len;
-
- unsigned short* xs = x.rep->s;
- unsigned short* ys = y.rep->s;
- unsigned short* topx = &(xs[xl]);
- unsigned short* topy = &(ys[yl]);
- int one_diff = 0;
- while (xs < topx && ys < topy)
- {
- unsigned short a = *xs++;
- unsigned short b = *ys++;
- unsigned short c = a | b;
- if (c != b)
- return 0;
- else if (c != a)
- one_diff = 1;
- }
- if (xl == yl)
- return x.rep->virt < y.rep->virt ||
- (one_diff && x.rep->virt == y.rep->virt);
- else if (xl < yl)
- return !x.rep->virt;
- else
- return y.rep->virt;
-}
-
-
-
-int BitSet::empty() const
-{
- if (rep->virt == 1)
- return 0;
-
- unsigned short* bots = rep->s;
- unsigned short* s = &(bots[rep->len - 1]);
- while (s >= bots) if (*s-- != 0) return 0;
- return 1;
-}
-
-
-int BitSet::count(int b) const
-{
- if (b == rep->virt)
- return -1;
- int l = 0;
- unsigned short* s = rep->s;
- unsigned short* tops = &(s[rep->len]);
- if (b == 1)
- {
- while (s < tops)
- {
- unsigned short a = *s++;
- for (int i = 0; i < BITSETBITS && a != 0; ++i)
- {
- if (a & 1)
- ++l;
- a >>= 1;
- }
- }
- }
- else
- {
- unsigned short maxbit = 1 << (BITSETBITS - 1);
- while (s < tops)
- {
- unsigned short a = *s++;
- for (int i = 0; i < BITSETBITS; ++i)
- {
- if ((a & maxbit) == 0)
- ++l;
- a <<= 1;
- }
- }
- }
- return l;
-}
-
-BitSetRep* BitSetcmpl(const BitSetRep* src, BitSetRep* r)
-{
- r = BitSetcopy(r, src);
- r->virt = !src->virt;
- unsigned short* rs = r->s;
- unsigned short* topr = &(rs[r->len]);
- if (r->len == 0)
- *rs = ONES;
- else
- {
- while (rs < topr)
- {
- unsigned short cmp = ~(*rs);
- *rs++ = cmp;
- }
- }
- trim(r);
- return r;
-}
-
-
-BitSetRep* BitSetop(const BitSetRep* x, const BitSetRep* y,
- BitSetRep* r, char op)
-{
- int xrsame = x == r;
- int yrsame = y == r;
- int xv = x->virt;
- int yv = y->virt;
- int xl = x->len;
- int yl = y->len;
- int rl = (xl >= yl)? xl : yl;
-
- r = BitSetresize(r, rl);
- unsigned short* rs = r->s;
- unsigned short* topr = &(rs[rl]);
-
- int av, bv;
- const unsigned short* as;
- const unsigned short* topa;
- const unsigned short* bs;
- const unsigned short* topb;
-
- if (xl <= yl)
- {
- as = (xrsame)? r->s : x->s;
- av = xv;
- topa = &(as[xl]);
- bs = (yrsame)? r->s : y->s;
- bv = yv;
- topb = &(bs[yl]);
- }
- else
- {
- as = (yrsame)? r->s : y->s;
- av = yv;
- topa = &(as[yl]);
- bs = (xrsame)? r->s : x->s;
- bv = xv;
- topb = &(bs[xl]);
- if (op == '-') // reverse sense of difference
- op = 'D';
- }
-
- switch (op)
- {
- case '&':
- r->virt = av & bv;
- while (as < topa) *rs++ = *as++ & *bs++;
- if (av)
- while (rs < topr) *rs++ = *bs++;
- else
- while (rs < topr) *rs++ = 0;
- break;
- case '|':
- r->virt = av | bv;
- while (as < topa) *rs++ = *as++ | *bs++;
- if (av)
- while (rs < topr) *rs++ = ONES;
- else
- while (rs < topr) *rs++ = *bs++;
- break;
- case '^':
- r->virt = av ^ bv;
- while (as < topa) *rs++ = *as++ ^ *bs++;
- if (av)
- while (rs < topr) *rs++ = ~(*bs++);
- else
- while (rs < topr) *rs++ = *bs++;
- break;
- case '-':
- r->virt = av & ~(bv);
- while (as < topa) *rs++ = *as++ & ~(*bs++);
- if (av)
- while (rs < topr) *rs++ = ~(*bs++);
- else
- while (rs < topr) *rs++ = 0;
- break;
- case 'D':
- r->virt = ~(av) & (bv);
- while (as < topa) *rs++ = ~(*as++) & (*bs++);
- if (av)
- while (rs < topr) *rs++ = 0;
- else
- while (rs < topr) *rs++ = *bs++;
- break;
- }
- trim(r);
- return r;
-}
-
-
-void BitSet::set(int p)
-{
- if (p < 0) error("Illegal bit index");
-
- int index = BitSet_index(p);
- int pos = BitSet_pos(p);
-
- if (index >= rep->len)
- {
- if (rep->virt)
- return;
- else
- rep = BitSetresize(rep, index+1);
- }
-
- rep->s[index] |= (1 << pos);
-}
-
-void BitSet::clear()
-{
- if (rep->len > 0) memset(rep->s, 0, rep->sz * sizeof(short));
- rep->len = rep->virt = 0;
-}
-
-void BitSet::clear(int p)
-{
- if (p < 0) error("Illegal bit index");
- int index = BitSet_index(p);
- if (index >= rep->len)
- {
- if (rep->virt == 0)
- return;
- else
- rep = BitSetresize(rep, index+1);
- }
- rep->s[index] &= ~(1 << BitSet_pos(p));
-}
-
-void BitSet::invert(int p)
-{
- if (p < 0) error("Illegal bit index");
- int index = BitSet_index(p);
- if (index >= rep->len) rep = BitSetresize(rep, index+1);
- rep->s[index] ^= (1 << BitSet_pos(p));
-}
-
-void BitSet::set(int from, int to)
-{
- if (from < 0 || from > to) error("Illegal bit index");
-
- int index1 = BitSet_index(from);
- int pos1 = BitSet_pos(from);
-
- if (rep->virt && index1 >= rep->len)
- return;
-
- int index2 = BitSet_index(to);
- int pos2 = BitSet_pos(to);
-
- if (index2 >= rep->len)
- rep = BitSetresize(rep, index2+1);
-
- unsigned short* s = &(rep->s[index1]);
- unsigned short m1 = lmask(pos1);
- unsigned short m2 = rmask(pos2);
- if (index2 == index1)
- *s |= m1 & m2;
- else
- {
- *s++ |= m1;
- unsigned short* top = &(rep->s[index2]);
- *top |= m2;
- while (s < top)
- *s++ = ONES;
- }
-}
-
-void BitSet::clear(int from, int to)
-{
- if (from < 0 || from > to) error("Illegal bit index");
-
- int index1 = BitSet_index(from);
- int pos1 = BitSet_pos(from);
-
- if (!rep->virt && index1 >= rep->len)
- return;
-
- int index2 = BitSet_index(to);
- int pos2 = BitSet_pos(to);
-
- if (index2 >= rep->len)
- rep = BitSetresize(rep, index2+1);
-
- unsigned short* s = &(rep->s[index1]);
- unsigned short m1 = lmask(pos1);
- unsigned short m2 = rmask(pos2);
- if (index2 == index1)
- *s &= ~(m1 & m2);
- else
- {
- *s++ &= ~m1;
- unsigned short* top = &(rep->s[index2]);
- *top &= ~m2;
- while (s < top)
- *s++ = 0;
- }
-}
-
-void BitSet::invert(int from, int to)
-{
- if (from < 0 || from > to) error("Illegal bit index");
-
- int index1 = BitSet_index(from);
- int pos1 = BitSet_pos(from);
- int index2 = BitSet_index(to);
- int pos2 = BitSet_pos(to);
-
- if (index2 >= rep->len)
- rep = BitSetresize(rep, index2+1);
-
- unsigned short* s = &(rep->s[index1]);
- unsigned short m1 = lmask(pos1);
- unsigned short m2 = rmask(pos2);
- if (index2 == index1)
- *s ^= m1 & m2;
- else
- {
- *s++ ^= m1;
- unsigned short* top = &(rep->s[index2]);
- *top ^= m2;
- while (s < top)
- {
- unsigned short cmp = ~(*s);
- *s++ = cmp;
- }
- }
-}
-
-
-int BitSet::test(int from, int to) const
-{
- if (from < 0 || from > to) return 0;
-
- int index1 = BitSet_index(from);
- int pos1 = BitSet_pos(from);
-
- if (index1 >= rep->len)
- return rep->virt;
-
- int index2 = BitSet_index(to);
- int pos2 = BitSet_pos(to);
-
- if (index2 >= rep->len)
- {
- if (rep->virt)
- return 1;
- else
- {
- index2 = rep->len - 1;
- pos2 = BITSETBITS - 1;
- }
- }
-
- unsigned short* s = &(rep->s[index1]);
- unsigned short m1 = lmask(pos1);
- unsigned short m2 = rmask(pos2);
-
- if (index2 == index1)
- return (*s & m1 & m2) != 0;
- else
- {
- if (*s++ & m1)
- return 1;
- unsigned short* top = &(rep->s[index2]);
- if (*top & m2)
- return 1;
- while (s < top)
- if (*s++ != 0)
- return 1;
- return 0;
- }
-}
-
-int BitSet::next(int p, int b) const
-{
- ++p;
- int index = BitSet_index(p);
- int pos = BitSet_pos(p);
-
- int l = rep->len;
-
- if (index >= l)
- {
- if (rep->virt == b)
- return p;
- else
- return -1;
- }
- int j = index;
- unsigned short* s = rep->s;
- unsigned short a = s[j] >> pos;
- int i = pos;
-
- if (b == 1)
- {
- for (; i < BITSETBITS && a != 0; ++i)
- {
- if (a & 1)
- return j * BITSETBITS + i;
- a >>= 1;
- }
- for (++j; j < l; ++j)
- {
- a = s[j];
- for (i = 0; i < BITSETBITS && a != 0; ++i)
- {
- if (a & 1)
- return j * BITSETBITS + i;
- a >>= 1;
- }
- }
- if (rep->virt)
- return j * BITSETBITS;
- else
- return -1;
- }
- else
- {
- for (; i < BITSETBITS; ++i)
- {
- if ((a & 1) == 0)
- return j * BITSETBITS + i;
- a >>= 1;
- }
- for (++j; j < l; ++j)
- {
- a = s[j];
- if (a != ONES)
- {
- for (i = 0; i < BITSETBITS; ++i)
- {
- if ((a & 1) == 0)
- return j * BITSETBITS + i;
- a >>= 1;
- }
- }
- }
- if (!rep->virt)
- return j * BITSETBITS;
- else
- return -1;
- }
-}
-
-int BitSet::prev(int p, int b) const
-{
- if (--p < 0)
- return -1;
-
- int index = BitSet_index(p);
- int pos = BitSet_pos(p);
-
- unsigned short* s = rep->s;
- int l = rep->len;
-
- if (index >= l)
- {
- if (rep->virt == b)
- return p;
- else
- {
- index = l - 1;
- pos = BITSETBITS - 1;
- }
- }
-
- int j = index;
- unsigned short a = s[j];
-
- int i = pos;
- unsigned short maxbit = 1 << pos;
-
- if (b == 1)
- {
- for (; i >= 0 && a != 0; --i)
- {
- if (a & maxbit)
- return j * BITSETBITS + i;
- a <<= 1;
- }
- maxbit = 1 << (BITSETBITS - 1);
- for (--j; j >= 0; --j)
- {
- a = s[j];
- for (i = BITSETBITS - 1; i >= 0 && a != 0; --i)
- {
- if (a & maxbit)
- return j * BITSETBITS + i;
- a <<= 1;
- }
- }
- return -1;
- }
- else
- {
- if (a != ONES)
- {
- for (; i >= 0; --i)
- {
- if ((a & maxbit) == 0)
- return j * BITSETBITS + i;
- a <<= 1;
- }
- }
- maxbit = 1 << (BITSETBITS - 1);
- for (--j; j >= 0; --j)
- {
- a = s[j];
- if (a != ONES)
- {
- for (i = BITSETBITS - 1; i >= 0; --i)
- {
- if ((a & maxbit) == 0)
- return j * BITSETBITS + i;
- a <<= 1;
- }
- }
- }
- return -1;
- }
-}
-
-int BitSet::last(int b) const
-{
- if (b == rep->virt)
- return -1;
- else
- return prev((rep->len) * BITSETBITS, b);
-}
-
-
-extern AllocRing _libgxx_fmtq;
-
-const char* BitSettoa(const BitSet& x, char f, char t, char star)
-{
- trim(x.rep);
- int wrksiz = (x.rep->len + 1) * BITSETBITS + 2;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- ostrstream stream(fmtbase, wrksiz);
-
- x.printon(stream, f, t, star);
- stream << ends;
- return fmtbase;
-}
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-
-BitSet shorttoBitSet(unsigned short w) return r
-{
- r.rep = BitSetalloc(0, &w, 1, 0, 2); trim(r.rep);
-}
-
-BitSet longtoBitSet(unsigned long w) return r;
-{
- unsigned short u[2];
- u[0] = w & ((unsigned short)(~(0)));
- u[1] = w >> BITSETBITS;
- r.rep = BitSetalloc(0, &u[0], 2, 0, 3);
- trim(r.rep);
-}
-
-BitSet atoBitSet(const char* s, char f, char t, char star) return r
-{
- int sl = strlen(s);
- if (sl != 0)
- {
- r.rep = BitSetresize(r.rep, sl / BITSETBITS + 1);
- unsigned short* rs = r.rep->s;
- unsigned short a = 0;
- unsigned short m = 1;
- char lastch = 0;
- unsigned int i = 0;
- unsigned int l = 1;
- for(;;)
- {
- char ch = s[i];
- if (ch == t)
- a |= m;
- else if (ch == star)
- {
- if (r.rep->virt = lastch == t)
- *rs = a | ~(m - 1);
- else
- *rs = a;
- break;
- }
- else if (ch != f)
- {
- *rs = a;
- break;
- }
- lastch = ch;
- if (++i == sl)
- {
- *rs = a;
- break;
- }
- else if (i % BITSETBITS == 0)
- {
- *rs++ = a;
- a = 0;
- m = 1;
- ++l;
- }
- else
- m <<= 1;
- }
- r.rep->len = l;
- trim(r.rep);
- }
- return;
-}
-
-#else
-
-BitSet shorttoBitSet(unsigned short w)
-{
- BitSet r;
- r.rep = BitSetalloc(0, &w, 1, 0, 2); trim(r.rep);
- return r;
-}
-
-BitSet longtoBitSet(unsigned long w)
-{
- BitSet r;
- unsigned short u[2];
- u[0] = w & ((unsigned short)(~(0)));
- u[1] = w >> BITSETBITS;
- r.rep = BitSetalloc(0, &u[0], 2, 0, 3);
- trim(r.rep);
- return r;
-}
-
-BitSet atoBitSet(const char* s, char f, char t, char star)
-{
- BitSet r;
- int sl = strlen(s);
- if (sl != 0)
- {
- r.rep = BitSetresize(r.rep, sl / BITSETBITS + 1);
- unsigned short* rs = r.rep->s;
- unsigned short a = 0;
- unsigned short m = 1;
- char lastch = 0;
- unsigned int i = 0;
- unsigned int l = 1;
- for(;;)
- {
- char ch = s[i];
- if (ch == t)
- a |= m;
- else if (ch == star)
- {
- if (r.rep->virt = lastch == t)
- *rs = a | ~(m - 1);
- else
- *rs = a;
- break;
- }
- else if (ch != f)
- {
- *rs = a;
- break;
- }
- lastch = ch;
- if (++i == sl)
- {
- *rs = a;
- break;
- }
- else if (i % BITSETBITS == 0)
- {
- *rs++ = a;
- a = 0;
- m = 1;
- ++l;
- }
- else
- m <<= 1;
- }
- r.rep->len = l;
- trim(r.rep);
- }
- return r;
-}
-
-#endif
-
-ostream& operator << (ostream& s, const BitSet& x)
-{
- if (s.opfx())
- x.printon(s);
- return s;
-}
-
-void BitSet::printon(ostream& os, char f, char t, char star) const
-// FIXME: Does not respect s.width()!
-{
- trim(rep);
- register streambuf* sb = os.rdbuf();
- const unsigned short* s = rep->s;
- const unsigned short* top = &(s[rep->len - 1]);
-
- while (s < top)
- {
- unsigned short a = *s++;
- for (int j = 0; j < BITSETBITS; ++j)
- {
- sb->sputc((a & 1)? t : f);
- a >>= 1;
- }
- }
-
- if (!rep->virt)
- {
- unsigned short a = *s;
- if (rep->len != 0)
- {
- for (int j = 0; j < BITSETBITS && a != 0; ++j)
- {
- sb->sputc((a & 1)? t : f);
- a >>= 1;
- }
- }
- sb->sputc(f);
- }
- else
- {
- unsigned short a = *s;
- unsigned short mask = ONES;
- unsigned short himask = (1 << (BITSETBITS - 1)) - 1;
- if (rep->len != 0)
- {
- for (int j = 0; j < BITSETBITS && a != mask; ++j)
- {
- sb->sputc((a & 1)? t : f);
- a = (a >> 1) & himask;
- mask = (mask >> 1) & himask;
- }
- }
- sb->sputc(t);
- }
-
- sb->sputc(star);
-}
-
-int BitSet::OK() const
-{
- int v = rep != 0; // have a rep
- v &= rep->len <= rep->sz; // within bounds
- v &= rep->virt == 0 || rep->virt == 1; // valid virtual bit
- if (!v) error("invariant failure");
- return v;
-}
-
diff --git a/gnu/lib/libg++/libg++/BitString.cc b/gnu/lib/libg++/libg++/BitString.cc
deleted file mode 100644
index 26331ae..0000000
--- a/gnu/lib/libg++/libg++/BitString.cc
+++ /dev/null
@@ -1,1606 +0,0 @@
-/*
-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.
-*/
-
-/*
- BitString class implementation
- */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <BitString.h>
-#include <std.h>
-#include <limits.h>
-#include <Obstack.h>
-#include <AllocRing.h>
-#include <new.h>
-#include <builtin.h>
-#include <strstream.h>
-
-void BitString::error(const char* msg) const
-{
- (*lib_error_handler)("BitString", msg);
-}
-
-// globals
-
-BitStrRep _nilBitStrRep = { 0, 1, {0} };
-
-BitString _nil_BitString;
-
-#define MINBitStrRep_SIZE 8
-#define MAXBitStrRep_SIZE ((1 << (sizeof(short)*CHAR_BIT - 1)) - 1)
-
-#ifndef MALLOC_MIN_OVERHEAD
-#define MALLOC_MIN_OVERHEAD 4
-#endif
-
-#define ONES ((_BS_word)(~0L))
-#define MAXBIT (((_BS_word)1) << (BITSTRBITS - 1))
-
-/*
- * bit manipulation utilities
-*/
-
-// break things up into .s indices and positions
-
-inline static int BitStr_len(int l)
-{
- return (unsigned)(l) / BITSTRBITS + 1;
-}
-
-
-// mask out low bits
-
-static inline _BS_word lmask(int p)
-{
- return ONES _BS_RIGHT p;
-}
-
-// mask out high bits
-
-static inline _BS_word rmask(int p)
-{
- int s = BITSTRBITS - 1 - p;
- if (s <= 0)
- return ONES;
- else
- return ONES _BS_LEFT s;
-}
-
-
-// mask out unused bits in last word of rep
-
-inline static void check_last(BitStrRep* r)
-{
- int bit_len_mod = r->len & (BITSTRBITS - 1);
- if (bit_len_mod)
- r->s[r->len / BITSTRBITS] &= ONES _BS_LEFT (BITSTRBITS - bit_len_mod);
-}
-
-// merge bits from next word
-
-static inline _BS_word borrow_hi(const _BS_word a[], int ind,
- int maxind, int p)
-{
- if (p == 0)
- return a[ind];
- else if (ind < maxind)
- return (a[ind] _BS_LEFT p) | (a[ind+1] _BS_RIGHT (BITSTRBITS - p));
- else
- return (a[ind] _BS_LEFT p);
-}
-
-// merge bits from prev word
-
-static inline _BS_word borrow_lo(const _BS_word a[], int ind,
- int minind, int p)
-{
- _BS_word word = a[ind] _BS_RIGHT (BITSTRBITS - 1 - p);
- if (ind > minind)
- word |= (a[ind-1] _BS_LEFT (p + 1));
- return word;
-}
-
-// same with bounds check (for masks shorter than patterns)
-
-static inline _BS_word safe_borrow_hi(const _BS_word a[], int ind,
- int maxind, int p)
-{
- if (ind > maxind)
- return 0;
- else if (p == 0)
- return a[ind];
- else if (ind == maxind)
- return a[ind] _BS_LEFT p;
- else
- return (a[ind] _BS_LEFT p) | (a[ind+1] _BS_RIGHT (BITSTRBITS - p));
-}
-
-
-// allocate a new rep; pad to near a power of two
-
-inline static BitStrRep* BSnew(int newlen)
-{
- unsigned int siz = sizeof(BitStrRep) + BitStr_len(newlen) * sizeof(_BS_word)
- + MALLOC_MIN_OVERHEAD;
- unsigned int allocsiz = MINBitStrRep_SIZE;;
- while (allocsiz < siz) allocsiz <<= 1;
- allocsiz -= MALLOC_MIN_OVERHEAD;
- if (allocsiz >= MAXBitStrRep_SIZE * sizeof(_BS_word))
- (*lib_error_handler)("BitString", "Requested length out of range");
-
- BitStrRep* rep = (BitStrRep *) new char[allocsiz];
- memset(rep, 0, allocsiz);
- rep->sz =
- (allocsiz - sizeof(BitStrRep) + sizeof(_BS_word)) / sizeof(_BS_word);
- return rep;
-}
-
-inline void
-copy_bits (_BS_word* pdst, _BS_size_t dstbit,
- const _BS_word* psrc, _BS_size_t srcbit,
- _BS_size_t length)
-{
- _BS_NORMALIZE (pdst, dstbit);
- _BS_NORMALIZE (psrc, srcbit);
- _BS_copy (pdst, dstbit, psrc, srcbit, length);
-}
-
-BitStrRep* BStr_alloc(BitStrRep* old, const _BS_word* src,
- int startpos, int endp, int newlen)
-{
- if (old == &_nilBitStrRep) old = 0;
- if (newlen < 0) newlen = 0;
- int news = BitStr_len(newlen);
- BitStrRep* rep;
- if (old == 0 || news > old->sz)
- rep = BSnew(newlen);
- else
- rep = old;
- rep->len = newlen;
-
- if (src != 0 && endp > 0 && (src != rep->s || startpos > 0))
- copy_bits (rep->s, 0, src, startpos, endp - startpos);
-
- check_last(rep);
-
- if (old != rep && old != 0) delete old;
-
- return rep;
-}
-
-BitStrRep* BStr_resize(BitStrRep* old, int newlen)
-{
- BitStrRep* rep;
- if (newlen < 0) newlen = 0;
- int news = BitStr_len(newlen);
- if (old == 0 || old == &_nilBitStrRep)
- {
- rep = BSnew(newlen);
- }
- else if (news > old->sz)
- {
- rep = BSnew(newlen);
- memcpy(rep->s, old->s, BitStr_len(old->len) * sizeof(_BS_word));
- delete old;
- }
- else
- rep = old;
-
- rep->len = newlen;
- check_last(rep);
- return rep;
-}
-
-BitStrRep* BStr_copy(BitStrRep* old, const BitStrRep* src)
-{
- BitStrRep* rep;
- if (old == src && old != &_nilBitStrRep) return old;
- if (old == &_nilBitStrRep) old = 0;
- if (src == &_nilBitStrRep) src = 0;
- if (src == 0)
- {
- if (old == 0)
- rep = BSnew(0);
- else
- rep = old;
- rep->len = 0;
- }
- else
- {
- int newlen = src->len;
- int news = BitStr_len(newlen);
- if (old == 0 || news > old->sz)
- {
- rep = BSnew(newlen);
- if (old != 0) delete old;
- }
- else
- rep = old;
-
- memcpy(rep->s, src->s, news * sizeof(_BS_word));
- rep->len = newlen;
- }
- check_last(rep);
- return rep;
-}
-
-
-int operator == (const BitString& x, const BitString& y)
-{
- return x.rep->len == y.rep->len &&
- memcmp((void*)x.rep->s, (void*)y.rep->s,
- BitStr_len(x.rep->len) * sizeof(_BS_word)) == 0;
-}
-
-int operator <= (const BitString& x, const BitString& y)
-{
- unsigned int xl = x.rep->len;
- unsigned int yl = y.rep->len;
- if (xl > yl)
- return 0;
-
- const _BS_word* xs = x.rep->s;
- const _BS_word* topx = &(xs[BitStr_len(xl)]);
- const _BS_word* ys = y.rep->s;
-
- while (xs < topx)
- {
- _BS_word a = *xs++;
- _BS_word b = *ys++;
- if ((a | b) != b)
- return 0;
- }
- return 1;
-}
-
-int operator < (const BitString& x, const BitString& y)
-{
- unsigned short xl = x.rep->len;
- unsigned short yl = y.rep->len;
- if (xl > yl)
- return 0;
-
- const _BS_word* xs = x.rep->s;
- const _BS_word* ys = y.rep->s;
- const _BS_word* topx = &(xs[BitStr_len(xl)]);
- const _BS_word* topy = &(ys[BitStr_len(yl)]);
- int one_diff = 0;
- while (xs < topx)
- {
- _BS_word a = *xs++;
- _BS_word b = *ys++;
- _BS_word c = a | b;
- if (c != b)
- return 0;
- else if (c != a)
- one_diff = 1;
- }
- if (one_diff)
- return 1;
- else
- {
- while (ys < topy)
- if (*ys++ != 0)
- return 1;
- return 0;
- }
-}
-
-int lcompare(const BitString& x, const BitString& y)
-{
- return _BS_lcompare_0 (x.rep->s, x.rep->len, y.rep->s, y.rep->len);
-}
-
-int BitString::count(unsigned int b) const
-{
- int count = _BS_count (rep->s, 0, rep->len);
- if (!b)
- count = rep->len - count;
- return count;
-}
-
-
-BitStrRep* cmpl(const BitStrRep* src, BitStrRep* r)
-{
- r = BStr_copy(r, src);
- _BS_word* rs = r->s;
- _BS_word* topr = &(rs[BitStr_len(r->len)]);
- while (rs < topr)
- {
- _BS_word cmp = ~(*rs);
- *rs++ = cmp;
- }
- check_last(r);
- return r;
-}
-
-
-BitStrRep* and(const BitStrRep* x, const BitStrRep* y, BitStrRep* r)
-{
- int xrsame = x == r;
- int yrsame = y == r;
-
- unsigned int xl = x->len;
- unsigned int yl = y->len;
- unsigned int rl = (xl <= yl)? xl : yl;
-
- r = BStr_resize(r, rl);
-
- _BS_word* rs = r->s;
- _BS_word* topr = &(rs[BitStr_len(rl)]);
- const _BS_word* xs = (xrsame)? rs : x->s;
- const _BS_word* ys = (yrsame)? rs : y->s;
-
- while (rs < topr) *rs++ = *xs++ & *ys++;
- check_last(r);
- return r;
-}
-
-BitStrRep* or(const BitStrRep* x, const BitStrRep* y, BitStrRep* r)
-{
- unsigned int xl = x->len;
- unsigned int yl = y->len;
- unsigned int rl = (xl >= yl)? xl : yl;
- int xrsame = x == r;
- int yrsame = y == r;
-
- r = BStr_resize(r, rl);
-
- _BS_word* rs = r->s;
- const _BS_word* xs = (xrsame)? rs : x->s;
- const _BS_word* topx = &(xs[BitStr_len(xl)]);
- const _BS_word* ys = (yrsame)? rs : y->s;
- const _BS_word* topy = &(ys[BitStr_len(yl)]);
-
- if (xl <= yl)
- {
- while (xs < topx) *rs++ = *xs++ | *ys++;
- if (rs != ys) while (ys < topy) *rs++ = *ys++;
- }
- else
- {
- while (ys < topy) *rs++ = *xs++ | *ys++;
- if (rs != xs) while (xs < topx) *rs++ = *xs++;
- }
- check_last(r);
- return r;
-}
-
-
-BitStrRep* xor(const BitStrRep* x, const BitStrRep* y, BitStrRep* r)
-{
- unsigned int xl = x->len;
- unsigned int yl = y->len;
- unsigned int rl = (xl >= yl)? xl : yl;
- int xrsame = x == r;
- int yrsame = y == r;
-
- r = BStr_resize(r, rl);
-
- _BS_word* rs = r->s;
- const _BS_word* xs = (xrsame)? rs : x->s;
- const _BS_word* topx = &(xs[BitStr_len(xl)]);
- const _BS_word* ys = (yrsame)? rs : y->s;
- const _BS_word* topy = &(ys[BitStr_len(yl)]);
-
- if (xl <= yl)
- {
- while (xs < topx) *rs++ = *xs++ ^ *ys++;
- if (rs != ys) while (ys < topy) *rs++ = *ys++;
- }
- else
- {
- while (ys < topy) *rs++ = *xs++ ^ *ys++;
- if (rs != xs) while (xs < topx) *rs++ = *xs++;
- }
- check_last(r);
- return r;
-}
-
-
-BitStrRep* diff(const BitStrRep* x, const BitStrRep* y, BitStrRep* r)
-{
- unsigned int xl = x->len;
- unsigned int yl = y->len;
- int xrsame = x == y;
- int yrsame = y == r;
-
- r = BStr_resize(r, xl);
-
- _BS_word* rs = r->s;
- const _BS_word* xs = (xrsame)? rs : x->s;
- const _BS_word* topx = &(xs[BitStr_len(xl)]);
- const _BS_word* ys = (yrsame)? rs : y->s;
- const _BS_word* topy = &(ys[BitStr_len(yl)]);
-
- if (xl <= yl)
- {
- while (xs < topx) *rs++ = *xs++ & ~(*ys++);
- }
- else
- {
- while (ys < topy) *rs++ = *xs++ & ~(*ys++);
- if (rs != xs) while (xs < topx) *rs++ = *xs++;
- }
- check_last(r);
- return r;
-}
-
-
-BitStrRep* cat(const BitStrRep* x, const BitStrRep* y, BitStrRep* r)
-{
- unsigned int xl = x->len;
- unsigned int yl = y->len;
- unsigned int rl = xl + yl;
- int xrsame = x == r;
- int yrsame = y == r;
-
- if (yrsame)
- {
- if (xrsame)
- {
- r = BStr_resize(r, rl);
- copy_bits (r->s, xl, r->s, 0, yl);
- }
- else
- {
- BitStrRep* tmp = BStr_copy(0, y);
- r = BStr_resize(r, rl);
- _BS_copy_0(r->s, x->s, xl);
- copy_bits (r->s, xl, tmp->s, 0, yl);
- delete tmp;
- }
- }
- else
- {
- r = BStr_resize(r, rl);
- if (!xrsame) _BS_copy_0(r->s, x->s, xl);
- copy_bits (r->s, xl, y->s, 0, yl);
- }
- check_last(r);
- return r;
-}
-
-BitStrRep* cat(const BitStrRep* x, unsigned int bit, BitStrRep* r)
-{
- unsigned int xl = x->len;
- int xrsame = x == r;
- r = BStr_resize(r, xl+1);
- if (!xrsame)
- _BS_copy_0(r->s, x->s, xl);
- if (bit)
- r->s[BitStr_index(xl)] |= _BS_BITMASK(BitStr_pos(xl));
- else
- r->s[BitStr_index(xl)] &= ~(_BS_BITMASK(BitStr_pos(xl)));
- check_last(r);
- return r;
-}
-
-BitStrRep* lshift(const BitStrRep* x, int s, BitStrRep* r)
-{
- int xrsame = x == r;
- int xl = x->len;
- int rl = xl + s;
- if (s == 0)
- r = BStr_copy(r, x);
- else if (rl <= 0)
- {
- r = BStr_resize(r, 0);
- r->len = 0;
- r->s[0] = 0;
- }
- else if (s > 0)
- {
- r = BStr_resize(r, rl);
- const _BS_word* xs = (xrsame)? r->s : x->s;
- copy_bits (r->s, s, xs, 0, xl);
- _BS_clear (r->s, 0, s);
- }
- else if (xrsame)
- {
- r = BStr_resize(r, xl);
- r->len = rl;
- copy_bits (r->s, 0, r->s, -s, xl + s);
- }
- else
- {
- r = BStr_resize(r, rl);
- copy_bits (r->s, 0, x->s, -s, xl + s);
- }
- check_last(r);
- return r;
-}
-
-
-void BitString::set(int p)
-{
- if (p < 0) error("Illegal bit index");
- if ((unsigned)(p) >= rep->len) rep = BStr_resize(rep, p + 1);
- rep->s[BitStr_index(p)] |= _BS_BITMASK(BitStr_pos(p));
-}
-
-void BitString::assign(int p, unsigned int bit)
-{
- if (p < 0) error("Illegal bit index");
- if ((unsigned)(p) >= rep->len) rep = BStr_resize(rep, p + 1);
- if (bit)
- rep->s[BitStr_index(p)] |= _BS_BITMASK(BitStr_pos(p));
- else
- rep->s[BitStr_index(p)] &= ~(_BS_BITMASK(BitStr_pos(p)));
-}
-
-void BitString::clear(int p)
-{
- if (p < 0) error("Illegal bit index");
- if ((unsigned)(p) >= rep->len) rep = BStr_resize(rep, p + 1);
- rep->s[BitStr_index(p)] &= ~(_BS_BITMASK(BitStr_pos(p)));
-}
-
-void BitString::clear()
-{
- if (rep == &_nilBitStrRep) return;
- _BS_clear (rep->s, 0, rep->len);
-}
-
-void BitString::set()
-{
- if (rep == &_nilBitStrRep) return;
- _BS_word* s = rep->s;
- _BS_word* tops = &(s[BitStr_len(rep->len)]);
- while (s < tops) *s++ = ONES;
- check_last(rep);
-}
-
-void BitString::invert(int p)
-{
- if (p < 0) error("Illegal bit index");
- if ((unsigned)(p) >= rep->len) rep = BStr_resize(rep, p + 1);
- rep->s[BitStr_index(p)] ^= _BS_BITMASK(BitStr_pos(p));
-}
-
-void BitString::set(int from, int to)
-{
- if (from < 0 || from > to) error("Illegal bit index");
- if ((unsigned)(to) >= rep->len) rep = BStr_resize(rep, to+1);
-
- _BS_size_t len = to - from + 1;
- _BS_word* xs = rep->s;
- _BS_NORMALIZE (xs, from);
- _BS_invert (xs, from, len);
-}
-
-void BitString::clear(int from, int to)
-{
- if (from < 0 || from > to) error("Illegal bit index");
- if ((unsigned)(to) >= rep->len) rep = BStr_resize(rep, to+1);
-
- _BS_size_t len = to - from + 1;
- _BS_word* xs = rep->s;
- _BS_NORMALIZE (xs, from);
- _BS_clear (xs, from, len);
-}
-
-void BitString::invert(int from, int to)
-{
- if (from < 0 || from > to) error("Illegal bit index");
- if ((unsigned)(to) >= rep->len) rep = BStr_resize(rep, to+1);
- _BS_size_t len = to - from + 1;
- _BS_word* xs = rep->s;
- _BS_NORMALIZE (xs, from);
- _BS_invert (xs, from, len);
-}
-
-
-int BitString::test(int from, int to) const
-{
- if (from < 0 || from > to || (unsigned)(from) >= rep->len) return 0;
-
- _BS_size_t len = to - from + 1;
- _BS_word* xs = rep->s;
- _BS_NORMALIZE (xs, from);
- return _BS_any (xs, from, len);
-}
-
-int BitString::next(int p, unsigned int b) const
-{
- if ((unsigned)(++p) >= rep->len)
- return -1;
-
- int ind = BitStr_index(p);
- int pos = BitStr_pos(p);
- int l = BitStr_len(rep->len);
-
- int j = ind;
- const _BS_word* s = rep->s;
- _BS_word a = s[j] >> pos;
- int i = pos;
-
- if (b != 0)
- {
- for (; i < BITSTRBITS && a != 0; ++i)
- {
- if (a & 1)
- return j * BITSTRBITS + i;
- a >>= 1;
- }
- for (++j; j < l; ++j)
- {
- a = s[j];
- for (i = 0; i < BITSTRBITS && a != 0; ++i)
- {
- if (a & 1)
- return j * BITSTRBITS + i;
- a >>= 1;
- }
- }
- return -1;
- }
- else
- {
- int last = BitStr_pos(rep->len);
- if (j == l - 1)
- {
- for (; i < last; ++i)
- {
- if ((a & 1) == 0)
- return j * BITSTRBITS + i;
- a >>= 1;
- }
- return -1;
- }
-
- for (; i < BITSTRBITS; ++i)
- {
- if ((a & 1) == 0)
- return j * BITSTRBITS + i;
- a >>= 1;
- }
- for (++j; j < l - 1; ++j)
- {
- a = s[j];
- if (a != ONES)
- {
- for (i = 0; i < BITSTRBITS; ++i)
- {
- if ((a & 1) == 0)
- return j * BITSTRBITS + i;
- a >>= 1;
- }
- }
- }
- a = s[j];
- for (i = 0; i < last; ++i)
- {
- if ((a & 1) == 0)
- return j * BITSTRBITS + i;
- a >>= 1;
- }
- return -1;
- }
-}
-
-int BitString::prev(int p, unsigned int b) const
-{
- if (--p < 0)
- return -1;
-
- int ind = BitStr_index(p);
- int pos = BitStr_pos(p);
-
- const _BS_word* s = rep->s;
-
- if ((unsigned)(p) >= rep->len)
- {
- ind = BitStr_index(rep->len - 1);
- pos = BitStr_pos(rep->len - 1);
- }
-
- int j = ind;
- _BS_word a = s[j];
-
- int i = pos;
- _BS_word maxbit = ((_BS_word)1) << pos;
-
- if (b != 0)
- {
- for (; i >= 0 && a != 0; --i)
- {
- if (a & maxbit)
- return j * BITSTRBITS + i;
- a <<= 1;
- }
- maxbit = ((_BS_word)1) << (BITSTRBITS - 1);
- for (--j; j >= 0; --j)
- {
- a = s[j];
- for (i = BITSTRBITS - 1; i >= 0 && a != 0; --i)
- {
- if (a & maxbit)
- return j * BITSTRBITS + i;
- a <<= 1;
- }
- }
- return -1;
- }
- else
- {
- if (a != ONES)
- {
- for (; i >= 0; --i)
- {
- if ((a & maxbit) == 0)
- return j * BITSTRBITS + i;
- a <<= 1;
- }
- }
- maxbit = ((_BS_word)1) << (BITSTRBITS - 1);
- for (--j; j >= 0; --j)
- {
- a = s[j];
- if (a != ONES)
- {
- for (i = BITSTRBITS - 1; i >= 0; --i)
- {
- if ((a & maxbit) == 0)
- return j * BITSTRBITS + i;
- a <<= 1;
- }
- }
- }
- return -1;
- }
-}
-
-
-int BitString::search(int startx, int lengthx,
- const _BS_word* ys, int starty, int lengthy) const
-{
- const _BS_word* xs = rep->s;
- int ylen = lengthy - starty;
- int righty = lengthy - 1;
- int rev = startx < 0;
- if (rev)
- {
- int leftx = 0;
- int rightx = lengthx + startx;
- startx = rightx - ylen + 1;
- if (ylen == 0) return startx;
- if (starty < 0 || righty < 0 || startx < 0 || startx >= lengthx) return -1;
-
- int xind = BitStr_index(startx);
- int xpos = BitStr_pos(startx);
- int yind = BitStr_index(starty);
- int ypos = BitStr_pos(starty);
-
- int rightxind = BitStr_index(rightx);
-
- _BS_word x = borrow_hi(xs, xind, rightxind, xpos);
-
- int rightyind = BitStr_index(righty);
- int rightypos = BitStr_pos(righty);
- _BS_word y = borrow_hi(ys, yind, rightyind, ypos);
- _BS_word ymask;
- if (yind == rightyind)
- ymask = rmask(rightypos);
- else if (yind+1 == rightyind)
- ymask = rmask(BITSTRBITS - ypos + rightypos + 1);
- else
- ymask = ONES;
-
- int p = startx;
- for (;;)
- {
- if ((x & ymask) == y)
- {
- int xi = xind;
- int yi = yind;
- for (;;)
- {
- if (++yi > rightyind || ++xi > rightxind)
- return p;
- _BS_word tx = borrow_hi(xs, xi, rightxind, xpos);
- _BS_word ty = borrow_hi(ys, yi, rightyind, ypos);
- if (yi == rightyind)
- tx &= rmask(rightypos);
- else if (yi+1 == rightyind)
- tx &= rmask(BITSTRBITS - ypos + rightypos + 1);
- if (tx != ty)
- break;
- }
- }
- if (--p < leftx)
- return -1;
- if (--xpos < 0)
- {
- xpos = BITSTRBITS - 1;
- --xind;
- }
- x = borrow_hi(xs, xind, rightxind, xpos);
- }
- }
- else
- {
-
- int rightx = lengthx - 1;
- if (ylen == 0) return startx;
- if (starty < 0 || righty < 0 || startx < 0 || startx >= lengthx) return -1;
-
- int xind = BitStr_index(startx);
- int xpos = BitStr_pos(startx);
- int yind = BitStr_index(starty);
- int ypos = BitStr_pos(starty);
-
- int rightxind = BitStr_index(rightx);
-
- _BS_word x = borrow_hi(xs, xind, rightxind, xpos);
- _BS_word nextx = (xind >= rightxind) ? 0 : (xs[xind+1] >> xpos);
-
- int rightyind = BitStr_index(righty);
- int rightypos = BitStr_pos(righty);
- _BS_word y = borrow_hi(ys, yind, rightyind, ypos);
- _BS_word ymask;
- if (yind == rightyind)
- ymask = rmask(rightypos);
- else if (yind+1 == rightyind)
- ymask = rmask(BITSTRBITS - ypos + rightypos + 1);
- else
- ymask = ONES;
-
- int p = startx;
- for (;;)
- {
- if ((x & ymask) == y)
- {
- int xi = xind;
- int yi = yind;
- for (;;)
- {
- if (++yi > rightyind || ++xi > rightxind)
- return p;
- _BS_word tx = borrow_hi(xs, xi, rightxind, xpos);
- _BS_word ty = borrow_hi(ys, yi, rightyind, ypos);
- if (yi == rightyind)
- tx &= rmask(rightypos);
- else if (yi+1 == rightyind)
- tx &= rmask(BITSTRBITS - ypos + rightypos + 1);
- if (tx != ty)
- break;
- }
- }
- if (++p > rightx)
- return -1;
- if (++xpos == BITSTRBITS)
- {
- xpos = 0;
- x = xs[++xind];
- nextx = (xind >= rightxind) ? 0 : xs[xind+1];
- }
- else
- {
- x >>= 1;
- if (nextx & 1)
- x |= MAXBIT;
- nextx >>= 1;
- }
- }
- }
-}
-
-
-int BitPattern::search(const _BS_word* xs, int startx, int lengthx) const
-{
- const _BS_word* ys = pattern.rep->s;
- const _BS_word* ms = mask.rep->s;
- int righty = pattern.rep->len - 1;
- int rightm = mask.rep->len - 1;
-
- int rev = startx < 0;
- if (rev)
- {
- int leftx = 0;
- int rightx = lengthx + startx;
- startx = rightx - righty;
-
- if (righty < 0) return startx;
- if (startx < 0 || startx >= lengthx) return -1;
-
- int xind = BitStr_index(startx);
- int xpos = BitStr_pos(startx);
-
- int rightxind = BitStr_index(rightx);
-
- int rightmind = BitStr_index(rightm);
- int rightyind = BitStr_index(righty);
-
- _BS_word x = safe_borrow_hi(xs, xind, rightxind, xpos);
- _BS_word m = safe_borrow_hi(ms, 0, rightmind, 0);
- _BS_word y = safe_borrow_hi(ys, 0, rightyind, 0) & m;
-
- int p = startx;
- for (;;)
- {
- if ((x & m) == y)
- {
- int xi = xind;
- int yi = 0;
- for (;;)
- {
- if (++yi > rightyind || ++xi > rightxind)
- return p;
- _BS_word tm = safe_borrow_hi(ms, yi, rightmind, 0);
- _BS_word ty = safe_borrow_hi(ys, yi, rightyind, 0);
- _BS_word tx = safe_borrow_hi(xs, xi, rightxind, xpos);
- if ((tx & tm) != (ty & tm))
- break;
- }
- }
- if (--p < leftx)
- return -1;
- if (--xpos < 0)
- {
- xpos = BITSTRBITS - 1;
- --xind;
- }
- x = safe_borrow_hi(xs, xind, rightxind, xpos);
- }
- }
- else
- {
-
- int rightx = lengthx - 1;
-
- if (righty < 0) return startx;
- if (startx < 0 || startx >= lengthx) return -1;
-
- int xind = BitStr_index(startx);
- int xpos = BitStr_pos(startx);
-
- int rightxind = BitStr_index(rightx);
-
- int rightmind = BitStr_index(rightm);
- int rightyind = BitStr_index(righty);
-
- _BS_word x = safe_borrow_hi(xs, xind, rightxind, xpos);
- _BS_word m = safe_borrow_hi(ms, 0, rightmind, 0);
- _BS_word y = safe_borrow_hi(ys, 0, rightyind, 0) & m;
-
- _BS_word nextx = (xind >= rightxind) ? 0 : (xs[xind+1] >> xpos);
-
- int p = startx;
- for (;;)
- {
- if ((x & m) == y)
- {
- int xi = xind;
- int yi = 0;
- for (;;)
- {
- if (++yi > rightyind || ++xi > rightxind)
- return p;
- _BS_word tm = safe_borrow_hi(ms, yi, rightmind, 0);
- _BS_word ty = safe_borrow_hi(ys, yi, rightyind, 0);
- _BS_word tx = safe_borrow_hi(xs, xi, rightxind, xpos);
- if ((tx & tm) != (ty & tm))
- break;
- }
- }
- if (++p > rightx)
- return -1;
- if (++xpos == BITSTRBITS)
- {
- xpos = 0;
- x = xs[++xind];
- nextx = (xind >= rightxind) ? 0 : xs[xind+1];
- }
- else
- {
- x >>= 1;
- if (nextx & 1)
- x |= MAXBIT;
- nextx >>= 1;
- }
- }
- }
-}
-
-int BitString::match(int startx, int lengthx, int exact,
- const _BS_word* ys, int starty, int yl) const
-{
- const _BS_word* xs = rep->s;
- int ylen = yl - starty;
- int righty = yl - 1;
-
- int rightx;
- int rev = startx < 0;
- if (rev)
- {
- rightx = lengthx + startx;
- startx = rightx - ylen + 1;
- if (exact && startx != 0)
- return 0;
- }
- else
- {
- rightx = lengthx - 1;
- if (exact && rightx - startx != righty)
- return 0;
- }
-
- if (ylen == 0) return 1;
- if (righty < 0 || startx < 0 || startx >= lengthx) return 0;
-
- int xi = BitStr_index(startx);
- int xpos = BitStr_pos(startx);
- int yi = BitStr_index(starty);
- int ypos = BitStr_pos(starty);
-
- int rightxind = BitStr_index(rightx);
- int rightyind = BitStr_index(righty);
- int rightypos = BitStr_pos(righty);
-
- for (;;)
- {
- _BS_word x = borrow_hi(xs, xi, rightxind, xpos);
- _BS_word y = borrow_hi(ys, yi, rightyind, ypos);
- if (yi == rightyind)
- x &= rmask(rightypos);
- else if (yi+1 == rightyind)
- x &= rmask(BITSTRBITS - ypos + rightypos + 1);
- if (x != y)
- return 0;
- else if (++yi > rightyind || ++xi > rightxind)
- return 1;
- }
-}
-
-int BitPattern::match(const _BS_word* xs, int startx,
- int lengthx, int exact) const
-{
- const _BS_word* ys = pattern.rep->s;
- int righty = pattern.rep->len - 1;
- _BS_word* ms = mask.rep->s;
- int rightm = mask.rep->len - 1;
-
- int rightx;
- int rev = startx < 0;
- if (rev)
- {
- rightx = lengthx + startx;
- startx = rightx - righty;
- if (exact && startx != 0)
- return 0;
- }
- else
- {
- rightx = lengthx - 1;
- if (exact && rightx - startx != righty)
- return 0;
- }
-
- if (righty < 0) return 1;
- if (startx < 0 || startx >= lengthx) return 0;
-
- int xind = BitStr_index(startx);
- int xpos = BitStr_pos(startx);
- int yind = 0;
-
- int rightxind = BitStr_index(rightx);
- int rightyind = BitStr_index(righty);
- int rightmind = BitStr_index(rightm);
-
- for(;;)
- {
- _BS_word m = safe_borrow_hi(ms, yind, rightmind, 0);
- _BS_word x = safe_borrow_hi(xs, xind, rightxind, xpos) & m;
- _BS_word y = safe_borrow_hi(ys, yind, rightyind, 0) & m;
- if (x != y)
- return 0;
- else if (++yind > rightyind || ++xind > rightxind)
- return 1;
- }
-}
-
-BitSubString& BitSubString::operator = (const BitString& y)
-{
- if (&S == &_nil_BitString)
- return *this;
- BitStrRep* targ = S.rep;
-
- unsigned int ylen = y.rep->len;
- int sl = targ->len - len + ylen;
-
- if (y.rep == targ || ylen > len)
- {
- BitStrRep* oldtarg = targ;
- targ = BStr_alloc(0, 0, 0, 0, sl);
- _BS_copy (targ->s, 0, oldtarg->s, 0, pos);
- copy_bits (targ->s, pos, y.rep->s, 0, ylen);
- copy_bits (targ->s, pos + ylen, oldtarg->s, pos+len, oldtarg->len-pos-len);
- delete oldtarg;
- }
- else if (len == ylen)
- copy_bits (targ->s, pos, y.rep->s, 0, len);
- else if (ylen < len)
- {
- copy_bits (targ->s, pos, y.rep->s, 0, ylen);
- copy_bits (targ->s, pos + ylen, targ->s, pos + len, targ->len - pos - len);
- targ->len = sl;
- }
- check_last(targ);
- S.rep = targ;
- return *this;
-}
-
-BitSubString& BitSubString::operator = (const BitSubString& y)
-{
- if (&S == &_nil_BitString)
- return *this;
- BitStrRep* targ = S.rep;
-
- if (len == 0 || pos >= targ->len)
- return *this;
-
- int sl = targ->len - len + y.len;
-
- if (y.S.rep == targ || y.len > len)
- {
- BitStrRep* oldtarg = targ;
- targ = BStr_alloc(0, 0, 0, 0, sl);
- _BS_copy_0(targ->s, oldtarg->s, pos);
- copy_bits (targ->s, pos, y.S.rep->s, y.pos, y.len);
- copy_bits (targ->s, pos + y.len, oldtarg->s, pos+len,
- oldtarg->len-pos-len);
- delete oldtarg;
- }
- else if (len == y.len)
- copy_bits (targ->s, pos, y.S.rep->s, y.pos, y.len);
- else if (y.len < len)
- {
- copy_bits (targ->s, pos, y.S.rep->s, y.pos, y.len);
- copy_bits (targ->s, pos + y.len, targ->s, pos + len,
- targ->len - pos - len);
- targ->len = sl;
- }
- check_last(targ);
- S.rep = targ;
- return *this;
-}
-
-BitSubString BitString::at(int first, int len)
-{
- return _substr(first, len);
-}
-
-BitSubString BitString::before(int pos)
-{
- return _substr(0, pos);
-}
-
-BitSubString BitString::after(int pos)
-{
- return _substr(pos + 1, rep->len - (pos + 1));
-}
-
-BitSubString BitString::at(const BitString& y, int startpos)
-{
- int first = search(startpos, rep->len, y.rep->s, 0, y.rep->len);
- return _substr(first, y.rep->len);
-}
-
-BitSubString BitString::before(const BitString& y, int startpos)
-{
- int last = search(startpos, rep->len, y.rep->s, 0, y.rep->len);
- return _substr(0, last);
-}
-
-BitSubString BitString::after(const BitString& y, int startpos)
-{
- int first = search(startpos, rep->len, y.rep->s, 0, y.rep->len);
- if (first >= 0) first += y.rep->len;
- return _substr(first, rep->len - first);
-}
-
-
-BitSubString BitString::at(const BitSubString& y, int startpos)
-{
- int first = search(startpos, rep->len, y.S.rep->s, y.pos, y.len);
- return _substr(first, y.len);
-}
-
-BitSubString BitString::before(const BitSubString& y, int startpos)
-{
- int last = search(startpos, rep->len, y.S.rep->s, y.pos, y.len);
- return _substr(0, last);
-}
-
-BitSubString BitString::after(const BitSubString& y, int startpos)
-{
- int first = search(startpos, rep->len, y.S.rep->s, y.pos, y.len);
- if (first >= 0) first += y.len;
- return _substr(first, rep->len - first);
-}
-
-BitSubString BitString::at(const BitPattern& r, int startpos)
-{
- int first = r.search(rep->s, startpos, rep->len);
- return _substr(first, r.pattern.rep->len);
-}
-
-
-BitSubString BitString::before(const BitPattern& r, int startpos)
-{
- int first = r.search(rep->s, startpos, rep->len);
- return _substr(0, first);
-}
-
-BitSubString BitString::after(const BitPattern& r, int startpos)
-{
- int first = r.search(rep->s, startpos, rep->len);
- if (first >= 0) first += r.pattern.rep->len;
- return _substr(first, rep->len - first);
-}
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-#define RETURN(r) return
-#define RETURNS(r) return r;
-#define RETURN_OBJECT(TYPE, NAME) /* nothing */
-#define USE_UNSIGNED 1 /* probably correct */
-#else /* _G_NO_NRV */
-#define RETURN(r) return r
-#define RETURNS(r) /* nothing */
-#define RETURN_OBJECT(TYPE, NAME) TYPE NAME;
-#define USE_UNSIGNED 0 /* probably old bug */
-#endif
-
-BitString
-common_prefix (const BitString& x, const BitString& y, int startpos)
- RETURNS(r)
-{
- RETURN_OBJECT(BitString, r);
- unsigned int xl = x.rep->len;
- unsigned int yl = y.rep->len;
-
- unsigned int startx, starty;
- if (startpos < 0)
- {
- startx = xl + startpos;
- starty = yl + startpos;
- }
- else
- startx = starty = startpos;
-
- if (startx >= xl || starty >= yl)
- RETURN(r);
-
- const _BS_word* xs = &(x.rep->s[BitStr_index(startx)]);
- _BS_word a = *xs++;
- unsigned int xp = startx;
-
- const _BS_word* ys = &(y.rep->s[BitStr_index(starty)]);
- _BS_word b = *ys++;
- unsigned int yp = starty;
-
- for(; xp < xl && yp < yl; ++xp, ++yp)
- {
- _BS_word xbit = ((_BS_word)1) << (BitStr_pos(xp));
- _BS_word ybit = ((_BS_word)1) << (BitStr_pos(yp));
- if (((a & xbit) == 0) != ((b & ybit) == 0))
- break;
- if (xbit == MAXBIT)
- a = *xs++;
- if (ybit == MAXBIT)
- b = *ys++;
- }
- r.rep = BStr_alloc(0, x.rep->s, startx, xp, xp - startx);
- RETURN(r);
-}
-
-
-BitString
-common_suffix (const BitString& x, const BitString& y, int startpos)
- RETURNS(r)
-{
- RETURN_OBJECT(BitString, r);
- unsigned int xl = x.rep->len;
- unsigned int yl = y.rep->len;
-
- unsigned int startx, starty;
- if (startpos < 0)
- {
- startx = xl + startpos;
- starty = yl + startpos;
- }
- else
- startx = starty = startpos;
-
- if (startx >= xl || starty >= yl)
- RETURN(r);
-
- const _BS_word* xs = &(x.rep->s[BitStr_index(startx)]);
- _BS_word a = *xs--;
- int xp = startx;
-
- const _BS_word* ys = &(y.rep->s[BitStr_index(starty)]);
- _BS_word b = *ys--;
- int yp = starty;
-
- for(; xp >= 0 && yp >= 0; --xp, --yp)
- {
- _BS_word xbit = ((_BS_word)1) << (BitStr_pos(xp));
- _BS_word ybit = ((_BS_word)1) << (BitStr_pos(yp));
- if (((a & xbit) == 0) != ((b & ybit) == 0))
- break;
- if (xbit == 1)
- a = *xs--;
- if (ybit == 1)
- b = *ys--;
- }
- r.rep = BStr_alloc(0, x.rep->s, xp+1, startx+1, startx - xp);
- RETURN(r);
-}
-
-BitString reverse (const BitString& x)
- RETURNS(r)
-{
- RETURN_OBJECT(BitString, r);
- unsigned int yl = x.rep->len;
- BitStrRep* y = BStr_resize(0, yl);
- if (yl > 0)
- {
- const _BS_word* ls = x.rep->s;
- _BS_word lm = 1;
- _BS_word* rs = &(y->s[BitStr_index(yl - 1)]);
- _BS_word rm = ((_BS_word)1) << (BitStr_pos(yl - 1));
- for (unsigned int l = 0; l < yl; ++l)
- {
- if (*ls & lm)
- *rs |= rm;
- if (lm == MAXBIT)
- {
- ++ls;
- lm = 1;
- }
- else
- lm <<= 1;
- if (rm == 1)
- {
- --rs;
- rm = MAXBIT;
- }
- else
- rm >>= 1;
- }
- }
- r.rep = y;
- RETURN(r);
-}
-
-BitString
-atoBitString (const char* s, char f, char t)
- RETURNS(res)
-{
- RETURN_OBJECT(BitString, res);
- int sl = strlen(s);
- BitStrRep* r = BStr_resize(0, sl);
- if (sl != 0)
- {
- unsigned int rl = 0;
- _BS_word* rs = r->s;
- _BS_word a = 0;
- _BS_word m = 1;
- unsigned int i = 0;
- for(;;)
- {
- char ch = s[i];
- if (ch != t && ch != f)
- {
- *rs = a;
- break;
- }
- ++rl;
- if (ch == t)
- a |= m;
- if (++i == sl)
- {
- *rs = a;
- break;
- }
- else if (i % BITSTRBITS == 0)
- {
- *rs++ = a;
- a = 0;
- m = 1;
- }
- else
- m <<= 1;
- }
- r = BStr_resize(r, rl);
- }
- res.rep = r;
- RETURN(res);
-}
-
-BitPattern
-atoBitPattern (const char* s, char f,char t,char x)
- RETURNS(r)
-{
- RETURN_OBJECT(BitPattern, r);
- int sl = strlen(s);
- if (sl != 0)
- {
- unsigned int rl = 0;
- r.pattern.rep = BStr_resize(r.pattern.rep, sl);
- r.mask.rep = BStr_resize(r.mask.rep, sl);
- _BS_word* rs = r.pattern.rep->s;
- _BS_word* ms = r.mask.rep->s;
- _BS_word a = 0;
- _BS_word b = 0;
- _BS_word m = 1;
- unsigned int i = 0;
- for(;;)
- {
- char ch = s[i];
- if (ch != t && ch != f && ch != x)
- {
- *rs = a;
- *ms = b;
- break;
- }
- ++rl;
- if (ch == t)
- {
- a |= m;
- b |= m;
- }
- else if (ch == f)
- {
- b |= m;
- }
- if (++i == sl)
- {
- *rs = a;
- *ms = b;
- break;
- }
- else if (i % BITSTRBITS == 0)
- {
- *rs++ = a;
- *ms++ = b;
- a = 0;
- b = 0;
- m = 1;
- }
- else
- m <<= 1;
- }
- r.pattern.rep = BStr_resize(r.pattern.rep, rl);
- r.mask.rep = BStr_resize(r.mask.rep, rl);
- }
- RETURN(r);
-}
-
-extern AllocRing _libgxx_fmtq;
-
-void BitString::printon (ostream& os, char f, char t) const
-{
- unsigned int xl = rep->len;
- const _BS_word* ptr = rep->s;
- register streambuf *sb = os.rdbuf();
- _BS_word a = 0;
-
- for (unsigned int i = 0; i < xl; ++i)
- {
- if (i % BITSTRBITS == 0)
- a = *ptr++;
- sb->sputc((a & 1)? t : f);
- a >>= 1;
- }
-}
-const char* BitStringtoa(const BitString& x, char f, char t)
-{
- int wrksiz = x.length() + 2;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- ostrstream stream(fmtbase, wrksiz);
-
- x.printon(stream, f, t);
- stream << ends;
- return fmtbase;
-}
-
-ostream& operator << (ostream& s, const BitString& x)
-{
- if (s.opfx())
- x.printon(s);
- return s;
-}
-
-const char* BitPatterntoa(const BitPattern& p, char f,char t,char x)
-{
- unsigned int pl = p.pattern.rep->len;
- unsigned int ml = p.mask.rep->len;
- unsigned int l = (pl <= ml)? pl : ml;
-
- int wrksiz = l + 2;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- ostrstream stream(fmtbase, wrksiz);
-
- p.printon(stream, f, t, x);
- stream << ends;
- return fmtbase;
-}
-
-void BitPattern::printon(ostream& s, char f,char t,char x) const
-{
- unsigned int pl = pattern.rep->len;
- unsigned int ml = mask.rep->len;
- unsigned int l = (pl <= ml)? pl : ml;
- register streambuf *sb = s.rdbuf();
-
- const _BS_word* ps = pattern.rep->s;
- const _BS_word* ms = mask.rep->s;
- _BS_word a = 0;
- _BS_word m = 0;
-
- for (unsigned int i = 0; i < l; ++i)
- {
- if (i % BITSTRBITS == 0)
- {
- a = *ps++;
- m = *ms++;
- }
- if (m & 1)
- sb->sputc((a & 1)? t : f);
- else
- sb->sputc(x);
- a >>= 1;
- m >>= 1;
- }
-}
-
-ostream& operator << (ostream& s, const BitPattern& x)
-{
- if (s.opfx())
- x.printon(s);
- return s;
-}
-
-
-int BitString::OK() const
-{
- int v = rep != 0; // have a rep;
- v &= BitStr_len(rep->len) <= rep->sz; // within allocated size
- if (!v) error("invariant failure");
- return v;
-}
-
-int BitSubString::OK() const
-{
- int v = S.OK(); // valid BitString
- v &= pos + len <= S.rep->len; // within bounds of targ
- if (!v) S.error("BitSubString invariant failure");
- return v;
-}
-
-int BitPattern::OK() const
-{
- int v = pattern.OK() && mask.OK();
- if (!v) pattern.error("BitPattern invariant failure");
- return v;
-}
-
diff --git a/gnu/lib/libg++/libg++/Complex.cc b/gnu/lib/libg++/libg++/Complex.cc
deleted file mode 100644
index 5aed909..0000000
--- a/gnu/lib/libg++/libg++/Complex.cc
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
-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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <Complex.h>
-#include <std.h>
-#include <builtin.h>
-
-// error handling
-
-void default_Complex_error_handler(const char* msg)
-{
- cerr << "Fatal Complex arithmetic error. " << msg << "\n";
- exit(1);
-}
-
-one_arg_error_handler_t Complex_error_handler = default_Complex_error_handler;
-
-one_arg_error_handler_t set_Complex_error_handler(one_arg_error_handler_t f)
-{
- one_arg_error_handler_t old = Complex_error_handler;
- Complex_error_handler = f;
- return old;
-}
-
-void Complex::error(const char* msg) const
-{
- (*Complex_error_handler)(msg);
-}
-
-/* from romine@xagsun.epm.ornl.gov */
-Complex /* const */ operator / (const Complex& x, const Complex& y)
-{
- double den = fabs(y.real()) + fabs(y.imag());
- if (den == 0.0) x.error ("Attempted division by zero.");
- double xrden = x.real() / den;
- double xiden = x.imag() / den;
- double yrden = y.real() / den;
- double yiden = y.imag() / den;
- double nrm = yrden * yrden + yiden * yiden;
- return Complex((xrden * yrden + xiden * yiden) / nrm,
- (xiden * yrden - xrden * yiden) / nrm);
-}
-
-Complex& Complex::operator /= (const Complex& y)
-{
- double den = fabs(y.real()) + fabs(y.imag());
- if (den == 0.0) error ("Attempted division by zero.");
- double xrden = re / den;
- double xiden = im / den;
- double yrden = y.real() / den;
- double yiden = y.imag() / den;
- double nrm = yrden * yrden + yiden * yiden;
- re = (xrden * yrden + xiden * yiden) / nrm;
- im = (xiden * yrden - xrden * yiden) / nrm;
- return *this;
-}
-
-Complex /* const */ operator / (double x, const Complex& y)
-{
- double den = norm(y);
- if (den == 0.0) y.error ("Attempted division by zero.");
- return Complex((x * y.real()) / den, -(x * y.imag()) / den);
-}
-
-Complex /* const */ operator / (const Complex& x, double y)
-{
- if (y == 0.0) x.error ("Attempted division by zero.");
- return Complex(x.real() / y, x.imag() / y);
-}
-
-
-Complex& Complex::operator /= (double y)
-{
- if (y == 0.0) error ("Attempted division by zero.");
- re /= y; im /= y;
- return *this;
-}
-
-
-Complex /* const */ exp(const Complex& x)
-{
- double r = exp(x.real());
- return Complex(r * cos(x.imag()),
- r * sin(x.imag()));
-}
-
-Complex /* const */ cosh(const Complex& x)
-{
- return Complex(cos(x.imag()) * cosh(x.real()),
- sin(x.imag()) * sinh(x.real()));
-}
-
-Complex /* const */ sinh(const Complex& x)
-{
- return Complex(cos(x.imag()) * sinh(x.real()),
- sin(x.imag()) * cosh(x.real()));
-}
-
-Complex /* const */ cos(const Complex& x)
-{
- return Complex(cos(x.real()) * cosh(x.imag()),
- -sin(x.real()) * sinh(x.imag()));
-}
-
-Complex /* const */ sin(const Complex& x)
-{
- return Complex(sin(x.real()) * cosh(x.imag()),
- cos(x.real()) * sinh(x.imag()));
-}
-
-Complex /* const */ log(const Complex& x)
-{
- double h = hypot(x.real(), x.imag());
- if (h <= 0.0) x.error("attempted log of zero magnitude number.");
- return Complex(log(h), atan2(x.imag(), x.real()));
-}
-
-// Corrections based on reports from: thc@cs.brown.edu & saito@sdr.slb.com
-Complex /* const */ pow(const Complex& x, const Complex& p)
-{
- double h = hypot(x.real(), x.imag());
- if (h <= 0.0) x.error("attempted power of zero magnitude number.");
-
- double a = atan2(x.imag(), x.real());
- double lr = pow(h, p.real());
- double li = p.real() * a;
- if (p.imag() != 0.0)
- {
- lr /= exp(p.imag() * a);
- li += p.imag() * log(h);
- }
- return Complex(lr * cos(li), lr * sin(li));
-}
-
-Complex /* const */ pow(const Complex& x, double p)
-{
- double h = hypot(x.real(), x.imag());
- if (h <= 0.0) x.error("attempted power of zero magnitude number.");
- double lr = pow(h, p);
- double a = atan2(x.imag(), x.real());
- double li = p * a;
- return Complex(lr * cos(li), lr * sin(li));
-}
-
-
-Complex /* const */ sqrt(const Complex& x)
-{
- if (x.real() == 0.0 && x.imag() == 0.0)
- return Complex(0.0, 0.0);
- else
- {
- double s = sqrt((fabs(x.real()) + hypot(x.real(), x.imag())) * 0.5);
- double d = (x.imag() / s) * 0.5;
- if (x.real() > 0.0)
- return Complex(s, d);
- else if (x.imag() >= 0.0)
- return Complex(d, s);
- else
- return Complex(-d, -s);
- }
-}
-
-
-Complex /* const */ pow(const Complex& x, int p)
-{
- if (p == 0)
- return Complex(1.0, 0.0);
- else if (x == 0.0)
- return Complex(0.0, 0.0);
- else
- {
- Complex res(1.0, 0.0);
- Complex b = x;
- if (p < 0)
- {
- p = -p;
- b = 1.0 / b;
- }
- for(;;)
- {
- if (p & 1)
- res *= b;
- if ((p >>= 1) == 0)
- return res;
- else
- b *= b;
- }
- }
-}
-
-ostream& operator << (ostream& s, const Complex& x)
-{
- return s << "(" << x.real() << ", " << x.imag() << ")" ;
-}
-
-istream& operator >> (istream& s, Complex& x)
-{
-#ifdef _OLD_STREAMS
- if (!s.good())
- {
- return s;
- }
-#else
- if (!s.ipfx(0))
- {
- s.clear(ios::failbit|s.rdstate()); // Redundant if using GNU iostreams.
- return s;
- }
-#endif
- double r, i;
- char ch;
- s >> ws;
- s.get(ch);
- if (ch == '(')
- {
- s >> r;
- s >> ws;
- s.get(ch);
- if (ch == ',')
- {
- s >> i;
- s >> ws;
- s .get(ch);
- }
- else
- i = 0;
- if (ch != ')')
- s.clear(ios::failbit);
- }
- else
- {
- s.putback(ch);
- s >> r;
- i = 0;
- }
- x = Complex(r, i);
- return s;
-}
-
diff --git a/gnu/lib/libg++/libg++/CursesW.cc b/gnu/lib/libg++/libg++/CursesW.cc
deleted file mode 100644
index 92bddfe..0000000
--- a/gnu/lib/libg++/libg++/CursesW.cc
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
-Copyright (C) 1989, 1992 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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <stdio.h>
-#include <stdarg.h>
-#include <builtin.h>
-#ifndef _OLD_STREAMS
-#include <strstream.h>
-#endif
-// Include CurseW.h and/or curses.h *after* iostream includes,
-// because curses.h defines a clear macro that conflicts with iostream. Sigh.
-#include <CursesW.h>
-
-#if _G_HAVE_CURSES
-
-int CursesWindow::count = 0;
-
-/*
- * C++ interface to curses library.
- *
- */
-
-#if !defined(_IO_MAGIC) && !defined(HAVE_VSCANF) &&!defined vsscanf
-extern "C" int _doscan(FILE *, const char*, va_list args);
-
-static int vsscanf(char *buf, const char * fmt, va_list args)
-{
- FILE b;
-#ifdef _IOSTRG
- b._flag = _IOREAD|_IOSTRG;
-#else
- b._flag = _IOREAD;
-#endif
- b._base = (unsigned char*)buf;
- b._ptr = (unsigned char*)buf;
- b._cnt = BUFSIZ;
- return _doscan(&b, fmt, args);
-}
-#endif
-
-/*
- * varargs functions are handled conservatively:
- * They interface directly into the underlying
- * _doscan, _doprnt and/or vfprintf routines rather than
- * assume that such things are handled compatibly in the curses library
- */
-
-int CursesWindow::scanw(const char * fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
-#ifdef VMS
- int result = wscanw(w , fmt , args);
-#else /* NOT VMS */
- char buf[BUFSIZ];
- int result = wgetstr(w, buf);
- if (result == OK) {
-
-#ifdef _IO_MAGIC /* GNU iostreams */
- strstreambuf ss(buf, BUFSIZ);
- result = ss.vscan(fmt, args);
-#else
- result = vsscanf(buf, fmt, args);
-#endif
- }
-#endif /* !VMS */
- va_end(args);
- return result;
-}
-
-int CursesWindow::mvscanw(int y, int x, const char * fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- char buf[BUFSIZ];
- int result = wmove(w, y, x);
- if (result == OK)
-#ifdef VMS
- result=wscanw(w , fmt , args);
-#else /* !VMS */
- {
- result = wgetstr(w, buf);
- if (result == OK) {
-#ifdef _IO_MAGIC /* GNU iostreams */
- strstreambuf ss(buf, BUFSIZ);
- result = ss.vscan(fmt, args);
-#else
- result = vsscanf(buf, fmt, args);
-#endif
- }
- }
-#endif /* !VMS */
- va_end(args);
- return result;
-}
-
-int CursesWindow::printw(const char * fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- char buf[BUFSIZ];
- vsprintf(buf, fmt, args);
- va_end(args);
- return waddstr(w, buf);
-}
-
-
-int CursesWindow::mvprintw(int y, int x, const char * fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- int result = wmove(w, y, x);
- if (result == OK)
- {
- char buf[BUFSIZ];
- vsprintf(buf, fmt, args);
- result = waddstr(w, buf);
- }
- va_end(args);
- return result;
-}
-
-CursesWindow::CursesWindow(int lines, int cols, int begin_y, int begin_x)
-{
- if (count==0)
- initscr();
-
- w = newwin(lines, cols, begin_y, begin_x);
- if (w == 0)
- {
- (*lib_error_handler)("CursesWindow", "Cannot construct window");
- }
-
- alloced = 1;
- subwins = par = sib = 0;
- count++;
-}
-
-CursesWindow::CursesWindow(WINDOW* &window)
-{
- if (count==0)
- initscr();
-
- w = window;
- alloced = 0;
- subwins = par = sib = 0;
- count++;
-}
-
-CursesWindow::CursesWindow(CursesWindow& win, int l, int c,
- int by, int bx, char absrel)
-{
-
- if (absrel == 'r') // relative origin
- {
- by += win.begy();
- bx += win.begx();
- }
-
- // Even though we treat subwindows as a tree, the standard curses
- // library needs the `subwin' call to link to the root in
- // order to correctly perform refreshes, etc.
-
- CursesWindow* root = &win;
- while (root->par != 0) root = root->par;
-
- w = subwin(root->w, l, c, by, bx);
- if (w == 0)
- {
- (*lib_error_handler)("CursesWindow", "Cannot construct subwindow");
- }
-
- par = &win;
- sib = win.subwins;
- win.subwins = this;
- subwins = 0;
- alloced = 1;
- count++;
-}
-
-
-void CursesWindow::kill_subwindows()
-{
- for (CursesWindow* p = subwins; p != 0; p = p->sib)
- {
- p->kill_subwindows();
- if (p->alloced)
- {
- if (p->w != 0)
- ::delwin(p->w);
- p->alloced = 0;
- }
- p->w = 0; // cause a run-time error if anyone attempts to use...
- }
-}
-
-CursesWindow::~CursesWindow()
-{
- kill_subwindows();
-
- if (par != 0) // Snip us from the parent's list of subwindows.
- {
- CursesWindow * win = par->subwins;
- CursesWindow * trail = 0;
- for (;;)
- {
- if (win == 0)
- break;
- else if (win == this)
- {
- if (trail != 0)
- trail->sib = win->sib;
- else
- par->subwins = win->sib;
- break;
- }
- else
- {
- trail = win;
- win = win->sib;
- }
- }
- }
-
- if (alloced && w != 0)
- delwin(w);
-
- --count;
- if (count == 0)
- endwin();
- else if (count < 0) // cannot happen!
- {
- (*lib_error_handler)("CursesWindow", "Too many windows destroyed");
- }
-}
-
-#endif /* _G_HAVE_CURSES */
diff --git a/gnu/lib/libg++/libg++/DLList.cc b/gnu/lib/libg++/libg++/DLList.cc
deleted file mode 100644
index ff8a81b..0000000
--- a/gnu/lib/libg++/libg++/DLList.cc
+++ /dev/null
@@ -1,327 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _G_NO_TEMPLATES
-#ifdef __GNUG__
-//#pragma implementation
-#endif
-#include <limits.h>
-#include <stream.h>
-#include <builtin.h>
-#include "DLList.h"
-
-void BaseDLList::error(const char* msg) const
-{
- (*lib_error_handler)("DLList", msg);
-}
-
-int BaseDLList::length() const
-{
- int l = 0;
- BaseDLNode* t = h;
- if (t != 0) do { ++l; t = t->fd; } while (t != h);
- return l;
-}
-
-// Note: This is an internal method. It does *not* free old contents!
-
-void BaseDLList::copy(const BaseDLList& a)
-{
- if (a.h == 0)
- h = 0;
- else
- {
- BaseDLNode* p = a.h;
- BaseDLNode* t = copy_node(p->item());
- h = t;
- p = p->fd;
- while (p != a.h)
- {
- BaseDLNode* n = copy_node(p->item());
- t->fd = n;
- n->bk = t;
- t = n;
- p = p->fd;
- }
- t->fd = h;
- h->bk = t;
- return;
- }
-}
-
-void BaseDLList::clear()
-{
- if (h == 0)
- return;
-
- BaseDLNode* p = h->fd;
- h->fd = 0;
- h = 0;
-
- while (p != 0)
- {
- BaseDLNode* nxt = p->fd;
- delete_node(p);
- p = nxt;
- }
-}
-
-BaseDLList& BaseDLList::operator = (const BaseDLList& a)
-{
- if (h != a.h)
- {
- clear();
- copy(a);
- }
- return *this;
-}
-
-
-Pix BaseDLList::prepend(const void *datum)
-{
- BaseDLNode* t = copy_node(datum);
- if (h == 0)
- t->fd = t->bk = h = t;
- else
- {
- t->fd = h;
- t->bk = h->bk;
- h->bk->fd = t;
- h->bk = t;
- h = t;
- }
- return Pix(t);
-}
-
-Pix BaseDLList::append(const void *datum)
-{
- BaseDLNode* t = copy_node(datum);
- if (h == 0)
- t->fd = t->bk = h = t;
- else
- {
- t->bk = h->bk;
- t->bk->fd = t;
- t->fd = h;
- h->bk = t;
- }
- return Pix(t);
-}
-
-Pix BaseDLList::ins_after(Pix p, const void *datum)
-{
- if (p == 0) return prepend(datum);
- BaseDLNode* u = (BaseDLNode*) p;
- BaseDLNode* t = copy_node(datum);
- t->bk = u;
- t->fd = u->fd;
- u->fd->bk = t;
- u->fd = t;
- return Pix(t);
-}
-
-Pix BaseDLList::ins_before(Pix p, const void *datum)
-{
- if (p == 0) error("null Pix");
- BaseDLNode* u = (BaseDLNode*) p;
- BaseDLNode* t = copy_node(datum);
- t->bk = u->bk;
- t->fd = u;
- u->bk->fd = t;
- u->bk = t;
- if (u == h) h = t;
- return Pix(t);
-}
-
-void BaseDLList::join(BaseDLList& b)
-{
- BaseDLNode* t = b.h;
- b.h = 0;
- if (h == 0)
- h = t;
- else if (t != 0)
- {
- BaseDLNode* l = t->bk;
- h->bk->fd = t;
- t->bk = h->bk;
- h->bk = l;
- l->fd = h;
- }
-}
-
-int BaseDLList::owns(Pix p) const
-{
- BaseDLNode* t = h;
- if (t != 0 && p != 0)
- {
- do
- {
- if (Pix(t) == p) return 1;
- t = t->fd;
- } while (t != h);
- }
- return 0;
-}
-
-void BaseDLList::del(Pix& p, int dir)
-{
- if (p == 0) error("null Pix");
- BaseDLNode* t = (BaseDLNode*) p;
- if (t->fd == t)
- {
- h = 0;
- p = 0;
- }
- else
- {
- if (dir < 0)
- {
- if (t == h)
- p = 0;
- else
- p = Pix(t->bk);
- }
- else
- {
- if (t == h->bk)
- p = 0;
- else
- p = Pix(t->fd);
- }
- t->bk->fd = t->fd;
- t->fd->bk = t->bk;
- if (t == h) h = t->fd;
- }
- delete_node(t);
-}
-
-void BaseDLList::del_after(Pix& p)
-{
- if (p == 0)
- {
- del_front();
- return;
- }
-
- BaseDLNode* b = (BaseDLNode*) p;
- BaseDLNode* t = b->fd;
-
- if (b == t)
- {
- h = 0;
- p = 0;
- }
- else
- {
- t->bk->fd = t->fd;
- t->fd->bk = t->bk;
- if (t == h) h = t->fd;
- }
- delete_node(t);
-}
-
-void BaseDLList::remove_front(void *dst)
-{
- if (h == 0)
- error("remove_front of empty list");
- else {
- BaseDLNode* t = h;
- copy_item(dst, t->item());
- if (h->fd == h)
- h = 0;
- else
- {
- h->fd->bk = h->bk;
- h->bk->fd = h->fd;
- h = h->fd;
- }
- delete_node(t);
- }
-}
-
-void BaseDLList::del_front()
-{
- if (h == 0)
- error("del_front of empty list");
- BaseDLNode* t = h;
- if (h->fd == h)
- h = 0;
- else
- {
- h->fd->bk = h->bk;
- h->bk->fd = h->fd;
- h = h->fd;
- }
- delete_node(t);
-}
-
-void BaseDLList::remove_rear(void *dst)
-{
- if (h == 0)
- error("remove_rear of empty list");
- else
- {
- BaseDLNode* t = h->bk;
- copy_item(dst, t->item());
- if (h->fd == h)
- h = 0;
- else
- {
- t->fd->bk = t->bk;
- t->bk->fd = t->fd;
- }
- delete_node(t);
- }
-}
-
-void BaseDLList::del_rear()
-{
- if (h == 0)
- error("del_rear of empty list");
- BaseDLNode* t = h->bk;
- if (h->fd == h)
- h = 0;
- else
- {
- t->fd->bk = t->bk;
- t->bk->fd = t->fd;
- }
- delete_node(t);
-}
-
-
-int BaseDLList::OK() const
-{
- int v = 1;
- if (h != 0)
- {
- BaseDLNode* t = h;
- long count = LONG_MAX; // Lots of chances to find h!
- do
- {
- count--;
- v &= t->bk->fd == t;
- v &= t->fd->bk == t;
- t = t->fd;
- } while (v && count > 0 && t != h);
- v &= count > 0;
- }
- if (!v) error("invariant failure");
- return v;
-}
-#endif
diff --git a/gnu/lib/libg++/libg++/DiscUnif.cc b/gnu/lib/libg++/libg++/DiscUnif.cc
deleted file mode 100644
index 136ad11..0000000
--- a/gnu/lib/libg++/libg++/DiscUnif.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <DiscUnif.h>
-
-double DiscreteUniform::operator()()
-{
- long tmp = long(floor(delta * pGenerator -> asDouble()));
- return( double(pLow + tmp) );
-}
-
diff --git a/gnu/lib/libg++/libg++/Erlang.cc b/gnu/lib/libg++/libg++/Erlang.cc
deleted file mode 100644
index da3e4e7..0000000
--- a/gnu/lib/libg++/libg++/Erlang.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <Erlang.h>
-
-double Erlang::operator()()
-{
- double prod = 1.0;
-
- for (int i = 0; i < k; i++) {
- prod *= pGenerator -> asDouble();
- }
- return(-log(prod)/a);
-}
diff --git a/gnu/lib/libg++/libg++/Fix.cc b/gnu/lib/libg++/libg++/Fix.cc
deleted file mode 100644
index 7e9e474..0000000
--- a/gnu/lib/libg++/libg++/Fix.cc
+++ /dev/null
@@ -1,663 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1989 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-//
-// Fix.cc : variable length fixed point data type class functions
-//
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <Fix.h>
-#include <std.h>
-#include <Obstack.h>
-#include <AllocRing.h>
-#include <strstream.h>
-
-// member constants
-
-const _G_uint16_t Fix::min_length;
-const _G_uint16_t Fix::max_length;
-const double Fix::min_value;
-const double Fix::max_value;
-
-// default parameters
-
-_G_uint16_t Fix::default_length = 16;
-int Fix::default_print_width = 8;
-
-Fix::PEH Fix::overflow_handler = Fix::overflow_saturate;
-
-Fix::Rep Fix::Rep_0 = { 16, 1, 1, { 0 } };
-Fix::Rep Fix::Rep_m1 = { 16, 1, 1, { 0x8000 } };
-Fix::Rep Fix::Rep_quotient_bump = { 16, 1, 1, { 0x4000 } };
-
-// error handling
-
-void
-Fix::default_error_handler(const char* msg)
-{
- cerr << "Fix: " << msg << "\n";
- abort();
-}
-
-void
-Fix::default_range_error_handler(const char* msg)
-{
- cerr << "Fix: range error in " << msg << "\n";
- //abort();
-}
-
-one_arg_error_handler_t
- Fix::error_handler = Fix::default_error_handler,
- Fix::range_error_handler = Fix::default_range_error_handler;
-
-one_arg_error_handler_t
-Fix::set_error_handler(one_arg_error_handler_t f)
-{
- one_arg_error_handler_t old = error_handler;
- error_handler = f;
- return old;
-}
-
-one_arg_error_handler_t
-Fix::set_range_error_handler(one_arg_error_handler_t f)
-{
- one_arg_error_handler_t old = range_error_handler;
- range_error_handler = f;
- return old;
-}
-
-void
-Fix::error(const char* msg)
-{
- error_handler(msg);
-}
-
-void
-Fix::range_error(const char* msg)
-{
- range_error_handler(msg);
-}
-
-// Fix::Rep allocation and initialization functions
-
-static inline Fix::Rep*
-_new_Fix(_G_uint16_t len)
-{
- int siz = (((_G_uint32_t) len + 15) >> 4);
- if (siz <= 0) siz = 1;
- unsigned int allocsiz = (sizeof(Fix::Rep) + (siz - 1) * sizeof(_G_uint16_t));
- Fix::Rep* z = (Fix::Rep*)(new char[allocsiz]);
- memset(z, 0, allocsiz);
- z->len = len;
- z->siz = siz;
- z->ref = 1;
- return z;
-}
-
-Fix::Rep*
-Fix::new_Fix(_G_uint16_t len)
-{
- return _new_Fix(len);
-}
-
-Fix::Rep*
-Fix::new_Fix(_G_uint16_t len, const Rep* x)
-{
- Rep* z = _new_Fix(len);
- return copy(x,z);
-}
-
-Fix::Rep*
-Fix::new_Fix(_G_uint16_t len, double d)
-{
- Rep* z = _new_Fix(len);
-
- if ( d == max_value )
- {
- z->s[0] = 0x7fff;
- for ( int i=1; i < z->siz; i++ )
- z->s[i] = 0xffff;
- }
- else if ( d < min_value || d > max_value )
- range_error("declaration");
- else
- {
- if (d < 0)
- d += 2.0;
- d *= 32768;
- for ( int i=0; i < z->siz; i++ )
- {
- z->s[i] = (_G_uint16_t )d;
- d -= z->s[i];
- d *= 65536;
- }
- if ( d >= 32768 )
- z->s[z->siz-1]++;
- }
- mask(z);
- return z;
-}
-
-// convert to a double
-
-double
-value(const Fix& x)
-{
- double d = 0.0;
- for ( int i=x.rep->siz-1; i >= 0; i-- )
- {
- d += x.rep->s[i];
- d *= 1./65536.;
- }
- d *= 2.;
- return d < 1. ? d : d - 2.;
-}
-
-// extract mantissa to Integer
-
-Integer
-mantissa(const Fix& x)
-{
- Integer a = 1, b=1;
- for ( int i=0; i < x.rep->siz; i++ )
- {
- a <<= 16;
- a += x.rep->s[i];
- b <<= 16;
- }
- return a-b;
-}
-
-// comparison functions
-
-inline static int
-docmp(const _G_uint16_t* x, const _G_uint16_t* y, int siz)
-{
- int diff = (_G_int16_t )*x - (_G_int16_t )*y;
- while ( --siz && !diff )
- diff = (_G_int32_t )(_G_uint32_t )*++x - (_G_int32_t )(_G_uint32_t )*++y;
- return diff;
-}
-
-inline static int
-docmpz(const _G_uint16_t* x, int siz)
-{
- while ( siz-- )
- if ( *x++ ) return 1;
- return 0;
-}
-
-int
-Fix::compare(const Rep* x, const Rep* y)
-{
- if ( x->siz == y->siz )
- return docmp(x->s, y->s, x->siz);
- else
- {
- int r;
- const Rep* longer, *shorter;
- if ( x->siz > y->siz )
- {
- longer = x;
- shorter = y;
- r = 1;
- }
- else
- {
- longer = y;
- shorter = x;
- r = -1;
- }
- int diff = docmp(x->s, y->s, shorter->siz);
- if ( diff )
- return diff;
- else if ( docmpz(&longer->s[shorter->siz], longer->siz-shorter->siz) )
- return r;
- else
- return 0;
- }
-}
-
-// arithmetic functions
-
-Fix::Rep*
-Fix::add(const Rep* x, const Rep* y, Rep* r)
-{
- _G_uint16_t xsign = x->s[0], ysign = y->s[0];
- const Rep* longer, *shorter;
- if ( x->len >= y->len )
- longer = x, shorter = y;
- else
- longer = y, shorter = x;
- if ( r == NULL )
- r = new_Fix(longer->len);
- for ( int i=r->siz-1; i >= longer->siz; i-- )
- r->s[i] = 0;
- for ( ; i >= shorter->siz; i-- )
- r->s[i] = longer->s[i];
- _G_uint32_t sum = 0, carry = 0;
- for ( ; i >= 0; i-- )
- {
- sum = carry + (_G_uint32_t )x->s[i] + (_G_uint32_t )y->s[i];
- carry = sum >> 16;
- r->s[i] = sum;
- }
- if ( (xsign ^ sum) & (ysign ^ sum) & 0x8000 )
- overflow_handler(r);
- return r;
-}
-
-Fix::Rep*
-Fix::subtract(const Rep* x, const Rep* y, Rep* r)
-{
- _G_uint16_t xsign = x->s[0], ysign = y->s[0];
- const Rep* longer, *shorter;
- if ( x->len >= y->len )
- longer = x, shorter = y;
- else
- longer = y, shorter = x;
- if ( r == NULL )
- r = new_Fix(longer->len);
- for ( int i=r->siz-1; i >= longer->siz; i-- )
- r->s[i] = 0;
- for ( ; i >= shorter->siz; i-- )
- r->s[i] = (longer == x ? x->s[i] : -y->s[i]);
- _G_int16_t carry = 0;
- _G_uint32_t sum = 0;
- for ( ; i >= 0; i-- )
- {
- sum = (_G_int32_t )carry + (_G_uint32_t )x->s[i] - (_G_uint32_t )y->s[i];
- carry = sum >> 16;
- r->s[i] = sum;
- }
- if ( (xsign ^ sum) & (~ysign ^ sum) & 0x8000 )
- overflow_handler(r);
- return r;
-}
-
-Fix::Rep*
-Fix::multiply(const Rep* x, const Rep* y, Rep* r)
-{
- if ( r == NULL )
- r = new_Fix(x->len + y->len);
- int xsign = x->s[0] & 0x8000,
- ysign = y->s[0] & 0x8000;
- Fix X(x->len), Y(y->len);
- if ( xsign )
- x = negate(x,X.rep);
- if ( ysign )
- y = negate(y,Y.rep);
- for ( int i=0; i < r->siz; i++ )
- r->s[i] = 0;
- for ( i=x->siz-1; i >= 0; i-- )
- {
- _G_uint32_t carry = 0;
- for ( int j=y->siz-1; j >= 0; j-- )
- {
- int k = i + j + 1;
- _G_uint32_t a = (_G_uint32_t )x->s[i] * (_G_uint32_t )y->s[j];
- _G_uint32_t b = ((a << 1) & 0xffff) + carry;
- if ( k < r->siz )
- {
- b += r->s[k];
- r->s[k] = b;
- }
- if ( k < (int)r->siz + 1 )
- carry = (a >> 15) + (b >> 16);
- }
- r->s[i] = carry;
- }
- if ( xsign != ysign )
- negate(r,r);
- return r;
-}
-
-Fix::Rep*
-Fix::multiply(const Rep* x, int y, Rep* r)
-{
- if ( y != (_G_int16_t )y )
- range_error("multiply by int -- int too large");
- if ( r == NULL )
- r = new_Fix(x->len);
- for ( int i=r->siz-1; i >= x->siz; i-- )
- r->s[i] = 0;
- _G_int32_t a, carry = 0;
- for ( ; i > 0; i-- )
- {
- a = (_G_int32_t) (_G_uint32_t )x->s[i] * y + carry;
- r->s[i] = a;
- carry = a >> 16; // assumes arithmetic right shift
- }
- a = (_G_int32_t) (_G_int16_t )x->s[0] * y + carry;
- r->s[0] = a;
- a &= 0xffff8000L;
- if ( a != (_G_int32_t)0xffff8000L && a != (_G_int32_t)0L ) {
- r->s[0] = 0x8000 ^ x->s[0] ^ y;
- overflow_handler(r);
- }
- return r;
-}
-
-Fix::Rep*
-Fix::divide(const Rep* x, const Rep* y, Rep* q, Rep* r)
-{
- int xsign = x->s[0] & 0x8000,
- ysign = y->s[0] & 0x8000;
- if ( q == NULL )
- q = new_Fix(x->len);
- copy(&Rep_0,q);
- if ( r == NULL )
- r = new_Fix(x->len + y->len - 1);
- if ( xsign )
- negate(x,r);
- else
- copy(x,r);
- Fix Y(y->len);
- Rep* y2 = ( ysign ? negate(y,Y.rep) : copy(y,Y.rep) );
- if ( !compare(y2) )
- range_error("division -- division by zero");
- else if ( compare(x,y2) >= 0 )
- if ( compare(x,y2) == 0 && (xsign ^ ysign) != 0 )
- {
- copy(&Rep_m1,q);
- copy(&Rep_0,r);
- }
- else
- range_error("division");
- else
- {
- Rep* t;
- Fix S(r->len),
- W(q->len,&Rep_quotient_bump);
- for ( int i=1; i < q->len; i++ )
- {
- shift(y2,-1,y2);
- subtract(r,y2,S.rep);
- int s_status = compare(S.rep);
- if ( s_status == 0 )
- {
- t = r, r = S.rep, S.rep = t;
- break;
- }
- else if ( s_status > 0 )
- {
- t = r, r = S.rep, S.rep = t;
- add(q,W.rep,q);
- }
- shift(W.rep,-1,W.rep);
- }
- if ( xsign ^ ysign )
- negate(q,q);
- }
- return q;
-}
-
-Fix::Rep*
-Fix::shift(const Rep* x, int y, Rep* r)
-{
- if ( r == NULL )
- r = new_Fix(x->len);
- if ( y == 0 )
- {
- copy (x, r);
- return r;
- }
-
- int ay = abs((_G_int32_t) y),
- ayh = ay >> 4,
- ayl = ay & 0x0f;
- int xl, u, ilow, ihigh;
- _G_uint16_t *rs;
- const _G_uint16_t *xsl, *xsr;
-
- if ( y > 0 )
- {
- rs = r->s;
- xsl = x->s + ayh;
- xsr = xsl + 1;
- xl = ayl;
- u = 1;
- ihigh = x->siz - ayh - 1;
- ilow = 0;
- }
- else
- {
- rs = &r->s[r->siz - 1];
- xsr = &x->s[r->siz - 1] - ayh;
- xsl = xsr - 1;
- xl = 16 - ayl;
- u = -1;
- ihigh = r->siz - ayh - 1;
- ilow = ihigh - x->siz;
- }
-
- int xr = 16 - xl;
- _G_uint16_t xrmask = 0xffffL >> xr;
- for ( int i=0; i < ilow; i++, rs+=u, xsl+=u, xsr+=u )
- *rs = 0;
- for ( ; i < ihigh; i++, rs+=u, xsl+=u, xsr+=u )
- *rs = (*xsl << xl) + ((*xsr >> xr) & xrmask);
- *rs = (y > 0 ? (*xsl << xl) : ((*xsr >> xr) & xrmask));
- rs += u;
- for ( ; ++i < r->siz; rs+=u )
- *rs = 0;
- return r;
-}
-
-Fix::Rep*
-Fix::negate(const Rep* x, Rep* r)
-{
- if ( r == NULL )
- r = new_Fix(x->len);
- _G_uint32_t carry = 1;
- for ( int i=r->siz-1; i >= x->siz; i-- )
- r->s[i] = 0;
- for ( ; i >= 0; i-- )
- {
- _G_uint32_t a = (_G_uint16_t )~x->s[i] + carry; // bug work-around
- r->s[i] = a;
- carry = a >> 16;
- }
- return r;
-}
-
-// io functions
-
-Fix
-atoF(const char* a, int len)
-{
- return Fix(len,atof(a));
-}
-
-extern AllocRing _libgxx_fmtq;
-
-void
-Fix::printon(ostream& s, int width) const
-{
- double val = value(*this);
- int old_precision = s.precision(width-3);
- _G_int32_t old_flags = s.setf(ios::fixed, ios::fixed|ios::scientific);
- if (val >= 0)
- s << ' ';
- s.width(width-2);
- s << val;
- s.precision(old_precision);
- s.flags(old_flags);
-}
-
-char*
-Ftoa(Fix& x, int width)
-{
- int wrksiz = width + 2;
- char *fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- ostrstream stream(fmtbase, wrksiz);
-
- x.printon(stream, width);
- stream << ends;
- return fmtbase;
-}
-
-extern Obstack _libgxx_io_ob;
-
-Fix
-Fix::operator %= (int y)
-{
- Fix r((int )rep->len + y, *this); return *this = r;
-}
-
-istream&
-operator >> (istream& s, Fix& y)
-{
- int got_one = 0;
- if (!s.ipfx(0))
- {
- s.clear(ios::failbit|s.rdstate()); // Redundant if using GNU iostreams.
- return s;
- }
-
- char sign = 0, point = 0;
- char ch;
- s >> ws;
- if (!s.good())
- {
- s.clear(ios::failbit|s.rdstate());
- return s;
- }
- while (s.get(ch))
- {
- if (ch == '-')
- {
- if (sign == 0)
- {
- sign = 1;
- _libgxx_io_ob.grow(ch);
- }
- else
- break;
- }
- if (ch == '.')
- {
- if (point == 0)
- {
- point = 1;
- _libgxx_io_ob.grow(ch);
- }
- else
- break;
- }
- else if (ch >= '0' && ch <= '9')
- {
- got_one = 1;
- _libgxx_io_ob.grow(ch);
- }
- else
- break;
- }
- char * p = (char*)(_libgxx_io_ob.finish(0));
- if (s.good())
- s.putback(ch);
- if (!got_one)
- s.clear(ios::failbit|s.rdstate());
- else
- y = atoF(p);
- _libgxx_io_ob.free(p);
- return s;
-}
-
-void
-show(const Fix& x)
-{
- cout << "len = " << x.rep->len << "\n";
- cout << "siz = " << x.rep->siz << "\n";
- cout << "ref = " << x.rep->ref << "\n";
- cout << "man = ";
-#ifdef _OLD_STREAMS
- cout << Itoa(mantissa(x),16,4*x.rep->siz);
-#else
- int old_flags = cout.setf(ios::hex, ios::hex|ios::dec|ios::oct);
- cout.width(4*x.rep->siz);
- cout << mantissa(x);
- cout.setf(old_flags, ios::hex|ios::dec|ios::oct);
-#endif
- cout << "\n";
- cout << "val = " << value(x) << "\n";
-}
-
-// parameter setting operations
-
-Fix::PEH Fix::set_overflow_handler(PEH new_handler)
-{
- PEH old_handler = overflow_handler;
- overflow_handler = new_handler;
- return old_handler;
-}
-
-int
-Fix::set_default_length(int newlen)
-{
- _G_uint16_t oldlen = default_length;
- if ( newlen < min_length || newlen > max_length )
- error("illegal length in Fix::set_default_length");
- default_length = newlen;
- return oldlen;
-}
-
-// overflow handlers
-
-void
-Fix::overflow_saturate(Rep* r)
-{
- if ( (_G_int16_t) r->s[0] > 0 )
- {
- r->s[0] = 0x8000;
- for ( int i=1; i < r->siz; i++ )
- r->s[i] = 0;
- }
- else
- {
- r->s[0] = 0x7fff;
- for ( int i = 1; i < (int)r->siz; i++ )
- r->s[i] = 0xffff;
- mask(r);
- }
-}
-
-void
-Fix::overflow_wrap(Rep*)
-{}
-
-void
-Fix::overflow_warning_saturate(Rep* r)
-{
- overflow_warning(r);
- overflow_saturate(r);
-}
-
-void
-Fix::overflow_warning(Rep*)
-{
- cerr << "Fix: overflow warning\n";
-}
-
-void
-Fix::overflow_error(Rep*)
-{
- cerr << "Fix: overflow error\n";
- abort();
-}
diff --git a/gnu/lib/libg++/libg++/Fix16.cc b/gnu/lib/libg++/libg++/Fix16.cc
deleted file mode 100644
index 3974fb3..0000000
--- a/gnu/lib/libg++/libg++/Fix16.cc
+++ /dev/null
@@ -1,238 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu)
- adapted for libg++ by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-//
-// Fix.cc : fixed precision class support functions
-//
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <Fix16.h>
-
-// basic operators too large to be inline
-
-short Fix16::assign(double d)
-{
- if (d == 1.0)
- return Fix16_m_max;
- else if (d > Fix16_max)
- {
- short i = Fix16_m_max;
- range_error(i);
- return i;
- }
- else if (d < Fix16_min)
- {
- short i = Fix16_m_min;
- range_error(i);
- return i;
- }
- else
- return round(Fix16_mult * d);
-}
-
-_G_int32_t Fix32::assign(double d)
-{
- if (d == 1.0)
- return Fix32_m_max;
- else if (d > Fix32_max)
- {
- _G_int32_t i = Fix32_m_max;
- range_error(i);
- return i;
- }
- else if (d < Fix32_min)
- {
- _G_int32_t i = Fix32_m_min;
- range_error(i);
- return i;
- }
- else
- return round(Fix32_mult * d);
-}
-
-
-Fix32 operator * (const Fix32& a, const Fix32& b)
-{
-// break a and b into lo and hi parts, and do a multiple-precision
-// multiply, with rounding
-
- int apos = (a.m >= 0);
- _G_uint32_t ua = (apos)? a.m : - a.m;
- ua <<= 1; // ua is biased so result will be 31 bit mantissa, not 30:
- _G_uint32_t hi_a = (ua >> 16) & ((1 << 16) - 1);
- _G_uint32_t lo_a = ua & ((1 << 16) - 1);
-
- int bpos = (b.m >= 0);
- _G_uint32_t ub = (bpos)? b.m : -b.m;
- _G_uint32_t hi_b = (ub >> 16) & ((1 << 16) - 1);
- _G_uint32_t lo_b = ub & ((1 << 16) - 1);
-
- _G_uint32_t r = lo_a * lo_b + (1 << 15);
- r = (r >> 16) + hi_a * lo_b + lo_a * hi_b + (1 << 15);
- r = (r >> 16) + hi_a * hi_b;
- _G_int32_t p = (apos != bpos)? -r : r;
- return Fix32(p);
-}
-
-Fix16 operator / (const Fix16& a, const Fix16& b)
-{
- short q;
- int apos = (a.m >= 0);
- _G_int32_t la = (apos)? a.m : -a.m;
- _G_int32_t scaled_a = la << 15;
- int bpos = (b.m >= 0);
- short sb = (bpos)? b.m: -b.m;
- if (la >= sb)
- {
- q = (apos == bpos)? Fix16_m_max: Fix16_m_min;
- a.range_error(q);
- }
- else
- {
- q = scaled_a / sb;
- if ((scaled_a % sb) >= (sb / 2)) ++q;
- if (apos != bpos) q = -q;
- }
- return Fix16(q);
-}
-
-Fix32 operator / (const Fix32& a, const Fix32& b)
-{
- _G_int32_t q;
- int apos = (a.m >= 0);
- _G_uint32_t la = (apos)? a.m : -a.m;
- int bpos = (b.m >= 0);
- _G_uint32_t lb = (bpos)? b.m: -b.m;
- if (la >= lb)
- {
- q = (apos == bpos)? Fix32_m_max: Fix32_m_min;
- a.range_error(q);
- }
- else // standard shift-based division alg
- {
- q = 0;
- _G_int32_t r = la;
-
- for (int i = 32; i > 0; i--)
- {
- if ((unsigned)(r) > lb) {
- q = (q << 1) | 1;
- r -= lb;
- }
- else
- q = (q << 1);
- r <<= 1;
- }
-
- if (apos != bpos) q = -q; // Fix sign
- }
- return Fix32(q);
-}
-
-
-// error handling
-
-void Fix16::overflow(short& i) const
-{
- (*Fix16_overflow_handler)(i);
-}
-
-void Fix32::overflow(_G_int32_t& i) const
-{
- (*Fix32_overflow_handler)(i);
-}
-
-void Fix16::range_error(short& i) const
-{
- (*Fix16_range_error_handler)(i);
-}
-
-void Fix32::range_error(_G_int32_t& i) const
-{
- (*Fix32_range_error_handler)(i);
-}
-
-// data definitions
-
-Fix16_peh Fix16_overflow_handler = Fix16_overflow_saturate;
-Fix32_peh Fix32_overflow_handler = Fix32_overflow_saturate;
-
-Fix16_peh Fix16_range_error_handler = Fix16_warning;
-Fix32_peh Fix32_range_error_handler = Fix32_warning;
-
-//function definitions
-
-Fix16_peh set_Fix16_overflow_handler(Fix16_peh new_handler) {
- Fix16_peh old_handler = Fix16_overflow_handler;
- Fix16_overflow_handler = new_handler;
- return old_handler;
-}
-
-Fix32_peh set_Fix32_overflow_handler(Fix32_peh new_handler) {
- Fix32_peh old_handler = Fix32_overflow_handler;
- Fix32_overflow_handler = new_handler;
- return old_handler;
-}
-
-void set_overflow_handler(Fix16_peh handler16, Fix32_peh handler32) {
- set_Fix16_overflow_handler(handler16);
- set_Fix32_overflow_handler(handler32);
-}
-
-Fix16_peh set_Fix16_range_error_handler(Fix16_peh new_handler) {
- Fix16_peh old_handler = Fix16_range_error_handler;
- Fix16_range_error_handler = new_handler;
- return old_handler;
-}
-
-Fix32_peh set_Fix32_range_error_handler(Fix32_peh new_handler) {
- Fix32_peh old_handler = Fix32_range_error_handler;
- Fix32_range_error_handler = new_handler;
- return old_handler;
-}
-
-void set_range_error_handler(Fix16_peh handler16, Fix32_peh handler32) {
- set_Fix16_range_error_handler(handler16);
- set_Fix32_range_error_handler(handler32);
-}
-
-void Fix16_overflow_saturate(short& i)
- { i = (i > 0 ? Fix16_m_min : Fix16_m_max); }
-void Fix16_ignore(short&) {}
-void Fix16_warning(short&)
- { cerr << "warning: Fix16 result out of range\n"; }
-void Fix16_overflow_warning_saturate(short& i)
- { cerr << "warning: Fix16 result out of range\n";
- Fix16_overflow_saturate(i); }
-void Fix16_abort(short&)
- { cerr << "error: Fix16 result out of range\n"; abort(); }
-
-void Fix32_ignore(_G_int32_t&) {}
-void Fix32_overflow_saturate(_G_int32_t& i)
- { i = (i > 0 ? Fix32_m_min : Fix32_m_max); }
-void Fix32_warning(_G_int32_t&)
- { cerr << "warning: Fix32 result out of range\n"; }
-void Fix32_overflow_warning_saturate(_G_int32_t& i)
- { cerr << "warning: Fix32 result out of range\n";
- Fix32_overflow_saturate(i); }
-void Fix32_abort(_G_int32_t&)
- { cerr << "error: Fix32 result out of range\n"; abort(); }
-
diff --git a/gnu/lib/libg++/libg++/Fix24.cc b/gnu/lib/libg++/libg++/Fix24.cc
deleted file mode 100644
index 84cb834..0000000
--- a/gnu/lib/libg++/libg++/Fix24.cc
+++ /dev/null
@@ -1,329 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu)
- adapted for libg++ by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-//
-// Fix24.cc : fixed precision class support functions
-//
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <Fix24.h>
-
-// basic operators too large to be inline
-
-_G_int32_t Fix24::assign(double d)
-{
- if (d == 1.0)
- return Fix24_m_max;
- else if (d > Fix24_max)
- {
- _G_int32_t i = Fix24_m_max;
- range_error(i);
- return i;
- }
- else if (d < Fix24_min)
- {
- _G_int32_t i = Fix24_m_min;
- range_error(i);
- return i;
- }
- else {
- // Round to 24 bits
- d = (_G_int32_t) (d * (1 << 24) + ((d >= 0)? 0.5 : -0.5));
- /* Convert to integer format */
- return ((_G_int32_t) d) << (Fix24_shift - 24);
- }
-}
-
-twolongs Fix48::assign(double d)
-{
- if (d == 1.0)
- return Fix48_m_max;
- else if (d > Fix48_max)
- {
- twolongs i = Fix48_m_max;
- range_error(i);
- return i;
- }
- else if (d < Fix48_min)
- {
- twolongs i = Fix48_m_min;
- range_error(i);
- return i;
- }
- else {
- twolongs i;
- int sign = (d < 0);
-
-/* First, convert the absolute value of d to a 48-bit integer format */
- if (d < 0) d = -d;
- i.u = ((_G_int32_t)(d *= Fix24_mult)) & 0xffffff00;
- i.l = ((_G_uint32_t)((d - i.u)* (Fix24_mult / (1 << 7)))) & 0xffffff00;
-
-/* Calculate the two's complement if d was negative */
- if (sign) {
- _G_uint32_t oldlower = i.l;
- i.l = (~i.l + 1) & 0xffffff00;
- i.u = (~i.u + (((oldlower ^ i.l) & Fix24_msb)? 0 : 1)) & ~0xffL;
- }
- return i;
- }
-}
-
-
-Fix48 operator * (const Fix24& a, const Fix24& b)
-{
-// break a and b into lo and hi parts, and do a multiple-precision
-// multiply, with rounding
-
- int apos = (a.m >= 0);
- _G_uint32_t ua = (apos)? a.m : - a.m;
- ua <<= 1; // ua is biased so result will be 47 bit mantissa, not 46:
- _G_uint32_t hi_a = (ua >> 16) & ((1 << 16) - 1);
- _G_uint32_t lo_a = ua & ((1 << 16) - 1);
-
- int bpos = (b.m >= 0);
- _G_uint32_t ub = (bpos)? b.m : -b.m;
- _G_uint32_t hi_b = (ub >> 16) & ((1 << 16) - 1);
- _G_uint32_t lo_b = ub & ((1 << 16) - 1);
-
- _G_uint32_t
- hi_r = hi_a * hi_b,
- mi_r = hi_a * lo_b + lo_a * hi_b,
- lo_r = lo_a * lo_b,
- rl = ((hi_r << 16) & 0x00ffffffL) + (mi_r & 0x00ffffffL) + (lo_r >> 16);
- twolongs r;
- r.u = (hi_r & 0xffffff00L) + ((mi_r >> 16) & 0x0000ff00L)
- + ((rl >> 16) & 0x0000ff00L);
- r.l = rl << 8;
-
- if ( apos != bpos ) {
- _G_uint32_t l = r.l;
- r.l = -r.l;
- r.u = (~r.u + ((l ^ r.l) & Fix24_msb ? 0 : Fix24_lsb)) & 0xffffff00;
- }
- return r;
-}
-
-Fix24 operator / (const Fix24& a, const Fix24& b)
-{
- _G_int32_t q;
- int apos = (a.m >= 0);
- _G_uint32_t la = (apos)? a.m : -a.m;
- int bpos = (b.m >= 0);
- _G_uint32_t lb = (bpos)? b.m: -b.m;
- if (la >= lb)
- {
- q = (apos == bpos)? Fix24_m_max: Fix24_m_min;
- a.range_error(q);
- }
- else // standard shift-based division alg
- {
- q = 0;
- _G_int32_t r = la;
-
- for (int i = 32; i > 0; i--)
- {
- if ((unsigned)(r) > lb) {
- q = (q << 1) | 1;
- r -= lb;
- }
- else
- q = (q << 1);
- r <<= 1;
- }
-
- q += 0x80; // Round result to 24 bits
- if (apos != bpos) q = -q; // Fix sign
- }
- return (q & ~0xff);
-}
-
-
-Fix48 operator + (const Fix48& f, const Fix48& g)
-{
- _G_int32_t lo_r = (f.m.l >> 8) + (g.m.l >> 8);
- twolongs r;
- r.u = f.m.u + g.m.u + (lo_r & 0x01000000L ? 0x00000100L : 0);
- r.l = lo_r << 8;
-
- if ( (f.m.u ^ r.u) & (g.m.u ^ r.u) & Fix24_msb )
- f.overflow(r);
- return r;
-}
-
-Fix48 operator - (const Fix48& f, const Fix48& g)
-{
- unsigned lo_r = (f.m.l >> 8) - (g.m.l >> 8);
- twolongs r;
- r.u = f.m.u - g.m.u - (lo_r & 0x01000000L ? 0x00000100L: 0);
- r.l = lo_r << 8;
-
- if ( ((f.m.u ^ r.u) & (-g.m.u ^ r.u) & Fix24_msb) && g.m.u )
- f.overflow(r);
- return r;
-}
-
-Fix48 operator * (const Fix48& a, int b)
-{
- twolongs r;
- int bpos = (b >= 0);
- unsigned ub = (bpos)? b : -b;
- if ( ub >= 65536L ) {
- r = (bpos)? Fix48_m_max : Fix48_m_min;
- a.range_error(r);
- }
- else {
- _G_uint32_t
- lo_r = (a.m.l & 0xffff) * ub,
- mi_r = ((a.m.l >> 16) & 0xffff) * ub,
- hi_r = a.m.u * ub;
- r.l = lo_r + (mi_r << 16);
- r.u = hi_r + ((mi_r >> 8) & 0x00ffff00L);
- if ( !bpos ) {
- _G_uint32_t l = r.l;
- r.l = -r.l & 0xffffffff;
- r.u = ~r.u + ((l ^ r.l) & Fix24_msb ? 0 : Fix24_lsb);
- }
- }
- return r;
-}
-
-Fix48 operator << (const Fix48& a, int b)
-{
- twolongs r; r.u = 0; r.l = 0;
- if ( b >= 0 )
- if ( b < 24 ) {
- r.u = (a.m.u << b) + ((a.m.l >> (24 - b)) & 0xffffff00L);
- r.l = a.m.l << b;
- }
- else if ( b < 48 ) {
- r.u = a.m.l << (b - 24);
- }
- return r;
-}
-
-Fix48 operator >> (const Fix48& a, int b)
-{
- twolongs r; r.u = 0; r.l = 0;
- if ( b >= 0 )
- if ( b < 24 ) {
- r.l = ((a.m.u << (24 - b)) & 0xffffffffL) + ((a.m.l >> b) & 0xffffff00L);
- r.u = (a.m.u >> b) & ~0xffL;
- }
- else if ( b < 48 ) {
- r.l = (a.m.u >> (b - 24)) & 0xffffff00L;
- r.u = (a.m.u >> 24) & ~0xffL;
- }
- else {
- r.l = (a.m.u >> 24) & ~0xffL;
- r.u = r.l;
- }
- return r;
-}
-
-// error handling
-
-void Fix24::overflow(_G_int32_t& i) const
-{
- (*Fix24_overflow_handler)(i);
-}
-
-void Fix48::overflow(twolongs& i) const
-{
- (*Fix48_overflow_handler)(i);
-}
-
-void Fix24::range_error(_G_int32_t& i) const
-{
- (*Fix24_range_error_handler)(i);
-}
-
-void Fix48::range_error(twolongs& i) const
-{
- (*Fix48_range_error_handler)(i);
-}
-
-// data definitions
-
-Fix24_peh Fix24_overflow_handler = Fix24_overflow_saturate;
-Fix48_peh Fix48_overflow_handler = Fix48_overflow_saturate;
-
-Fix24_peh Fix24_range_error_handler = Fix24_warning;
-Fix48_peh Fix48_range_error_handler = Fix48_warning;
-
-//function definitions
-
-Fix24_peh set_Fix24_overflow_handler(Fix24_peh new_handler) {
- Fix24_peh old_handler = Fix24_overflow_handler;
- Fix24_overflow_handler = new_handler;
- return old_handler;
-}
-
-Fix48_peh set_Fix48_overflow_handler(Fix48_peh new_handler) {
- Fix48_peh old_handler = Fix48_overflow_handler;
- Fix48_overflow_handler = new_handler;
- return old_handler;
-}
-
-void set_overflow_handler(Fix24_peh handler24, Fix48_peh handler48) {
- set_Fix24_overflow_handler(handler24);
- set_Fix48_overflow_handler(handler48);
-}
-
-Fix24_peh set_Fix24_range_error_handler(Fix24_peh new_handler) {
- Fix24_peh old_handler = Fix24_range_error_handler;
- Fix24_range_error_handler = new_handler;
- return old_handler;
-}
-
-Fix48_peh set_Fix48_range_error_handler(Fix48_peh new_handler) {
- Fix48_peh old_handler = Fix48_range_error_handler;
- Fix48_range_error_handler = new_handler;
- return old_handler;
-}
-
-void set_range_error_handler(Fix24_peh handler24, Fix48_peh handler48) {
- set_Fix24_range_error_handler(handler24);
- set_Fix48_range_error_handler(handler48);
-}
-
-void Fix24_overflow_saturate(_G_int32_t& i)
- { i = (i > 0 ? Fix24_m_min : Fix24_m_max); }
-void Fix24_ignore(_G_int32_t&) {}
-void Fix24_warning(_G_int32_t&)
- { cerr << "warning: Fix24 result out of range\n"; }
-void Fix24_overflow_warning_saturate(_G_int32_t& i)
- { cerr << "warning: Fix24 result out of range\n";
- Fix24_overflow_saturate(i); }
-void Fix24_abort(_G_int32_t&)
- { cerr << "error: Fix24 result out of range\n"; abort(); }
-
-void Fix48_ignore(twolongs&) {}
-void Fix48_overflow_saturate(twolongs& i)
- { i = (i.u > 0 ? Fix48_m_min : Fix48_m_max); }
-void Fix48_warning(twolongs&)
- { cerr << "warning: Fix48 result out of range\n"; }
-void Fix48_overflow_warning_saturate(twolongs& i)
- { cerr << "warning: Fix48 result out of range\n";
- Fix48_overflow_saturate(i); }
-void Fix48_abort(twolongs&)
- { cerr << "error: Fix48 result out of range\n"; abort(); }
-
diff --git a/gnu/lib/libg++/libg++/Geom.cc b/gnu/lib/libg++/libg++/Geom.cc
deleted file mode 100644
index 0353738..0000000
--- a/gnu/lib/libg++/libg++/Geom.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <Geom.h>
-
-double Geometric::operator()()
-{
- int samples;
- for (samples = 1; pGenerator -> asDouble() < pMean; samples++);
- return((double) samples);
-}
-
diff --git a/gnu/lib/libg++/libg++/GetOpt.cc b/gnu/lib/libg++/libg++/GetOpt.cc
deleted file mode 100644
index 16c647d..0000000
--- a/gnu/lib/libg++/libg++/GetOpt.cc
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
-Getopt for GNU.
-Copyright (C) 1987, 1989 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-/* AIX requires the alloca decl to be the first thing in the file. */
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#elif defined(sparc)
-#include <alloca.h>
-extern "C" void *__builtin_alloca(...);
-#elif defined(_AIX)
-#pragma alloca
-#else
-char *alloca ();
-#endif
-#include <GetOpt.h>
-
-char* GetOpt::nextchar = 0;
-int GetOpt::first_nonopt = 0;
-int GetOpt::last_nonopt = 0;
-
-GetOpt::GetOpt (int argc, char **argv, const char *optstring)
- :opterr (1), nargc (argc), nargv (argv), noptstring (optstring)
-{
- /* Initialize the internal data when the first call is made.
- Start processing options with ARGV-element 1 (since ARGV-element 0
- is the program name); the sequence of previously skipped
- non-option ARGV-elements is empty. */
-
- first_nonopt = last_nonopt = optind = 1;
- optarg = nextchar = 0;
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-')
- ordering = RETURN_IN_ORDER;
- else if (getenv ("_POSIX_OPTION_ORDER") != 0)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
-}
-
-void
-GetOpt::exchange (char **argv)
-{
- int nonopts_size
- = (last_nonopt - first_nonopt) * sizeof (char *);
- char **temp = (char **) alloca (nonopts_size);
-
- /* Interchange the two blocks of data in argv. */
-
- memcpy (temp, &argv[first_nonopt], nonopts_size);
- memcpy (&argv[first_nonopt], &argv[last_nonopt],
- (optind - last_nonopt) * sizeof (char *));
- memcpy (&argv[first_nonopt + optind - last_nonopt], temp,
- nonopts_size);
-
- /* Update records for the slots the non-options now occupy. */
-
- first_nonopt += (optind - last_nonopt);
- last_nonopt = optind;
-}
-
-/* Scan elements of ARGV (whose length is ARGC) for option characters
- given in OPTSTRING.
-
- If an element of ARGV starts with '-', and is not exactly "-" or "--",
- then it is an option element. The characters of this element
- (aside from the initial '-') are option characters. If `getopt'
- is called repeatedly, it returns successively each of theoption characters
- from each of the option elements.
-
- If `getopt' finds another option character, it returns that character,
- updating `optind' and `nextchar' so that the next call to `getopt' can
- resume the scan with the following option character or ARGV-element.
-
- If there are no more option characters, `getopt' returns `EOF'.
- Then `optind' is the index in ARGV of the first ARGV-element
- that is not an option. (The ARGV-elements have been permuted
- so that those that are not options now come last.)
-
- OPTSTRING is a string containing the legitimate option characters.
- A colon in OPTSTRING means that the previous character is an option
- that wants an argument. The argument is taken from the rest of the
- current ARGV-element, or from the following ARGV-element,
- and returned in `optarg'.
-
- If an option character is seen that is not listed in OPTSTRING,
- return '?' after printing an error message. If you set `opterr' to
- zero, the error message is suppressed but we still return '?'.
-
- If a char in OPTSTRING is followed by a colon, that means it wants an arg,
- so the following text in the same ARGV-element, or the text of the following
- ARGV-element, is returned in `optarg. Two colons mean an option that
- wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `optarg'.
-
- If OPTSTRING starts with `-', it requests a different method of handling the
- non-option ARGV-elements. See the comments about RETURN_IN_ORDER, above. */
-
-int
-GetOpt::operator () (void)
-{
- if (nextchar == 0 || *nextchar == 0)
- {
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange (nargv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Now skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < nargc
- && (nargv[optind][0] != '-'
- || nargv[optind][1] == 0))
- optind++;
- last_nonopt = optind;
- }
-
- /* Special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != nargc && !strcmp (nargv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange (nargv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = nargc;
-
- optind = nargc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == nargc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return EOF;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if (nargv[optind][0] != '-' || nargv[optind][1] == 0)
- {
- if (ordering == REQUIRE_ORDER)
- return EOF;
- optarg = nargv[optind++];
- return 0;
- }
-
- /* We have found another option-ARGV-element.
- Start decoding its characters. */
-
- nextchar = nargv[optind] + 1;
- }
-
- /* Look at and handle the next option-character. */
-
- {
- char c = *nextchar++;
- char *temp = (char *) strchr (noptstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == 0)
- optind++;
-
- if (temp == 0 || c == ':')
- {
- if (opterr != 0)
- {
- if (c < 040 || c >= 0177)
- fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
- nargv[0], c);
- else
- fprintf (stderr, "%s: unrecognized option `-%c'\n",
- nargv[0], c);
- }
- return '?';
- }
- if (temp[1] == ':')
- {
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != 0)
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = 0;
- nextchar = 0;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != 0)
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == nargc)
- {
- if (opterr != 0)
- fprintf (stderr, "%s: no argument for `-%c' option\n",
- nargv[0], c);
- c = '?';
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = nargv[optind++];
- nextchar = 0;
- }
- }
- return c;
- }
-}
diff --git a/gnu/lib/libg++/libg++/HypGeom.cc b/gnu/lib/libg++/libg++/HypGeom.cc
deleted file mode 100644
index 50d9586..0000000
--- a/gnu/lib/libg++/libg++/HypGeom.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <HypGeom.h>
-
-double HyperGeometric::operator()()
-{
- double d = (pGenerator -> asDouble() > pP) ? (1.0 - pP) : (pP);
- return(-pMean * log(pGenerator -> asDouble()) / (2.0 * d) );
-}
-
diff --git a/gnu/lib/libg++/libg++/Intdouble.cc b/gnu/lib/libg++/libg++/Intdouble.cc
deleted file mode 100644
index 8db9061..0000000
--- a/gnu/lib/libg++/libg++/Intdouble.cc
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
-Copyright (C) 1988, 1993 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.
-*/
-
-// Routines for converting between Integers and doubles.
-// Split up into a separate file to avoid Integer.o's need
-// for libm.a on some systems (including SunOS 4).
-
-#include <Integer.h>
-#include "Integer.hP"
-#include <float.h>
-#include <math.h>
-#include <limits.h>
-
-#ifndef HUGE_VAL
-#ifdef HUGE
-#define HUGE_VAL HUGE
-#else
-#define HUGE_VAL DBL_MAX
-#endif
-#endif
-
-// convert to a double
-
-double Itodouble(const IntRep* rep)
-{
- double d = 0.0;
- double bound = DBL_MAX / 2.0;
- for (int i = rep->len - 1; i >= 0; --i)
- {
- unsigned short a = I_RADIX >> 1;
- while (a != 0)
- {
- if (d >= bound)
- return (rep->sgn == I_NEGATIVE) ? -HUGE_VAL : HUGE_VAL;
- d *= 2.0;
- if (rep->s[i] & a)
- d += 1.0;
- a >>= 1;
- }
- }
- if (rep->sgn == I_NEGATIVE)
- return -d;
- else
- return d;
-}
-
-// see whether op double() will work-
-// have to actually try it in order to find out
-// since otherwise might trigger fp exception
-
-int Iisdouble(const IntRep* rep)
-{
- double d = 0.0;
- double bound = DBL_MAX / 2.0;
- for (int i = rep->len - 1; i >= 0; --i)
- {
- unsigned short a = I_RADIX >> 1;
- while (a != 0)
- {
- if (d > bound || (d == bound && (i > 0 || (rep->s[i] & a))))
- return 0;
- d *= 2.0;
- if (rep->s[i] & a)
- d += 1.0;
- a >>= 1;
- }
- }
- return 1;
-}
-
-// real division of num / den
-
-double ratio(const Integer& num, const Integer& den)
-{
- Integer q, r;
- divide(num, den, q, r);
- double d1 = q.as_double();
-
- if (d1 >= DBL_MAX || d1 <= -DBL_MAX || sign(r) == 0)
- return d1;
- else // use as much precision as available for fractional part
- {
- double d2 = 0.0;
- double d3 = 0.0;
- int cont = 1;
- for (int i = den.rep->len - 1; i >= 0 && cont; --i)
- {
- unsigned short a = I_RADIX >> 1;
- while (a != 0)
- {
- if (d2 + 1.0 == d2) // out of precision when we get here
- {
- cont = 0;
- break;
- }
-
- d2 *= 2.0;
- if (den.rep->s[i] & a)
- d2 += 1.0;
-
- if (i < r.rep->len)
- {
- d3 *= 2.0;
- if (r.rep->s[i] & a)
- d3 += 1.0;
- }
-
- a >>= 1;
- }
- }
-
- if (sign(r) < 0)
- d3 = -d3;
- return d1 + d3 / d2;
- }
-}
-
-double
-Integer::as_double () const
-{
- return Itodouble (rep);
-}
-
-int
-Integer::fits_in_double () const
-{
- return Iisdouble(rep);
-}
diff --git a/gnu/lib/libg++/libg++/Integer.cc b/gnu/lib/libg++/libg++/Integer.cc
deleted file mode 100644
index 5f11e6d..0000000
--- a/gnu/lib/libg++/libg++/Integer.cc
+++ /dev/null
@@ -1,2280 +0,0 @@
-/*
-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.
-*/
-
-/*
- Some of the following algorithms are very loosely based on those from
- MIT C-Scheme bignum.c, which is
- Copyright (c) 1987 Massachusetts Institute of Technology
-
- with other guidance from Knuth, vol. 2
-
- Thanks to the creators of the algorithms.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <Integer.h>
-#include <std.h>
-#include <ctype.h>
-#include <limits.h>
-#include <Obstack.h>
-#include <AllocRing.h>
-#include <new.h>
-#include <builtin.h>
-#include "Integer.hP"
-
-IntRep _ZeroRep = {1, 0, 1, {0}};
-IntRep _OneRep = {1, 0, 1, {1}};
-IntRep _MinusOneRep = {1, 0, 0, {1}};
-
-
-// utilities to extract and transfer bits
-
-// get low bits
-
-inline static unsigned short extract(unsigned long x)
-{
- return x & I_MAXNUM;
-}
-
-// transfer high bits to low
-
-inline static unsigned long down(unsigned long x)
-{
- return (x >> I_SHIFT) & I_MAXNUM;
-}
-
-// transfer low bits to high
-
-inline static unsigned long up(unsigned long x)
-{
- return x << I_SHIFT;
-}
-
-// compare two equal-length reps
-
-inline static int docmp(const unsigned short* x, const unsigned short* y, int l)
-{
- int diff = 0;
- const unsigned short* xs = &(x[l]);
- const unsigned short* ys = &(y[l]);
- while (l-- > 0 && (diff = (*--xs) - (*--ys)) == 0);
- return diff;
-}
-
-// figure out max length of result of +, -, etc.
-
-inline static int calc_len(int len1, int len2, int pad)
-{
- return (len1 >= len2)? len1 + pad : len2 + pad;
-}
-
-// ensure len & sgn are correct
-
-inline static void Icheck(IntRep* rep)
-{
- int l = rep->len;
- const unsigned short* p = &(rep->s[l]);
- while (l > 0 && *--p == 0) --l;
- if ((rep->len = l) == 0) rep->sgn = I_POSITIVE;
-}
-
-
-// zero out the end of a rep
-
-inline static void Iclear_from(IntRep* rep, int p)
-{
- unsigned short* cp = &(rep->s[p]);
- const unsigned short* cf = &(rep->s[rep->len]);
- while(cp < cf) *cp++ = 0;
-}
-
-// copy parts of a rep
-
-static inline void scpy(const unsigned short* src, unsigned short* dest,int nb)
-{
- while (--nb >= 0) *dest++ = *src++;
-}
-
-// make sure an argument is valid
-
-static inline void nonnil(const IntRep* rep)
-{
- if (rep == 0)
- (*lib_error_handler)("Integer", "operation on uninitialized Integer");
-}
-
-// allocate a new Irep. Pad to something close to a power of two.
-
-inline static IntRep* Inew(int newlen)
-{
- unsigned int siz = sizeof(IntRep) + newlen * sizeof(short) +
- MALLOC_MIN_OVERHEAD;
- unsigned int allocsiz = MINIntRep_SIZE;
- while (allocsiz < siz) allocsiz <<= 1; // find a power of 2
- allocsiz -= MALLOC_MIN_OVERHEAD;
- if (allocsiz >= MAXIntRep_SIZE * sizeof(short))
- (*lib_error_handler)("Integer", "Requested length out of range");
-
- IntRep* rep = (IntRep *) new char[allocsiz];
- rep->sz = (allocsiz - sizeof(IntRep) + sizeof(short)) / sizeof(short);
- return rep;
-}
-
-// allocate: use the bits in src if non-null, clear the rest
-
-IntRep* Ialloc(IntRep* old, const unsigned short* src, int srclen, int newsgn,
- int newlen)
-{
- IntRep* rep;
- if (old == 0 || newlen > old->sz)
- rep = Inew(newlen);
- else
- rep = old;
-
- rep->len = newlen;
- rep->sgn = newsgn;
-
- scpy(src, rep->s, srclen);
- Iclear_from(rep, srclen);
-
- if (old != rep && old != 0 && !STATIC_IntRep(old)) delete old;
- return rep;
-}
-
-// allocate and clear
-
-IntRep* Icalloc(IntRep* old, int newlen)
-{
- IntRep* rep;
- if (old == 0 || newlen > old->sz)
- {
- if (old != 0 && !STATIC_IntRep(old)) delete old;
- rep = Inew(newlen);
- }
- else
- rep = old;
-
- rep->len = newlen;
- rep->sgn = I_POSITIVE;
- Iclear_from(rep, 0);
-
- return rep;
-}
-
-// reallocate
-
-IntRep* Iresize(IntRep* old, int newlen)
-{
- IntRep* rep;
- unsigned short oldlen;
- if (old == 0)
- {
- oldlen = 0;
- rep = Inew(newlen);
- rep->sgn = I_POSITIVE;
- }
- else
- {
- oldlen = old->len;
- if (newlen > old->sz)
- {
- rep = Inew(newlen);
- scpy(old->s, rep->s, oldlen);
- rep->sgn = old->sgn;
- if (!STATIC_IntRep(old)) delete old;
- }
- else
- rep = old;
- }
-
- rep->len = newlen;
- Iclear_from(rep, oldlen);
-
- return rep;
-}
-
-
-// same, for straight copy
-
-IntRep* Icopy(IntRep* old, const IntRep* src)
-{
- if (old == src) return old;
- IntRep* rep;
- if (src == 0)
- {
- if (old == 0)
- rep = Inew(0);
- else
- {
- rep = old;
- Iclear_from(rep, 0);
- }
- rep->len = 0;
- rep->sgn = I_POSITIVE;
- }
- else
- {
- int newlen = src->len;
- if (old == 0 || newlen > old->sz)
- {
- if (old != 0 && !STATIC_IntRep(old)) delete old;
- rep = Inew(newlen);
- }
- else
- rep = old;
-
- rep->len = newlen;
- rep->sgn = src->sgn;
-
- scpy(src->s, rep->s, newlen);
- }
-
- return rep;
-}
-
-// allocate & copy space for a long
-
-IntRep* Icopy_long(IntRep* old, long x)
-{
- int newsgn = (x >= 0);
- IntRep* rep = Icopy_ulong(old, newsgn ? x : -x);
- rep->sgn = newsgn;
- return rep;
-}
-
-IntRep* Icopy_ulong(IntRep* old, unsigned long x)
-{
- unsigned short src[SHORT_PER_LONG];
-
- unsigned short srclen = 0;
- while (x != 0)
- {
- src[srclen++] = extract(x);
- x = down(x);
- }
-
- IntRep* rep;
- if (old == 0 || srclen > old->sz)
- {
- if (old != 0 && !STATIC_IntRep(old)) delete old;
- rep = Inew(srclen);
- }
- else
- rep = old;
-
- rep->len = srclen;
- rep->sgn = I_POSITIVE;
-
- scpy(src, rep->s, srclen);
-
- return rep;
-}
-
-// special case for zero -- it's worth it!
-
-IntRep* Icopy_zero(IntRep* old)
-{
- if (old == 0 || STATIC_IntRep(old))
- return &_ZeroRep;
-
- old->len = 0;
- old->sgn = I_POSITIVE;
-
- return old;
-}
-
-// special case for 1 or -1
-
-IntRep* Icopy_one(IntRep* old, int newsgn)
-{
- if (old == 0 || 1 > old->sz)
- {
- if (old != 0 && !STATIC_IntRep(old)) delete old;
- return newsgn==I_NEGATIVE ? &_MinusOneRep : &_OneRep;
- }
-
- old->sgn = newsgn;
- old->len = 1;
- old->s[0] = 1;
-
- return old;
-}
-
-// convert to a legal two's complement long if possible
-// if too big, return most negative/positive value
-
-long Itolong(const IntRep* rep)
-{
- if ((unsigned)(rep->len) > (unsigned)(SHORT_PER_LONG))
- return (rep->sgn == I_POSITIVE) ? LONG_MAX : LONG_MIN;
- else if (rep->len == 0)
- return 0;
- else if ((unsigned)(rep->len) < (unsigned)(SHORT_PER_LONG))
- {
- unsigned long a = rep->s[rep->len-1];
- if (SHORT_PER_LONG > 2) // normally optimized out
- {
- for (int i = rep->len - 2; i >= 0; --i)
- a = up(a) | rep->s[i];
- }
- return (rep->sgn == I_POSITIVE)? a : -((long)a);
- }
- else
- {
- unsigned long a = rep->s[SHORT_PER_LONG - 1];
- if (a >= I_MINNUM)
- return (rep->sgn == I_POSITIVE) ? LONG_MAX : LONG_MIN;
- else
- {
- a = up(a) | rep->s[SHORT_PER_LONG - 2];
- if (SHORT_PER_LONG > 2)
- {
- for (int i = SHORT_PER_LONG - 3; i >= 0; --i)
- a = up(a) | rep->s[i];
- }
- return (rep->sgn == I_POSITIVE)? a : -((long)a);
- }
- }
-}
-
-// test whether op long() will work.
-// careful about asymmetry between LONG_MIN & LONG_MAX
-
-int Iislong(const IntRep* rep)
-{
- unsigned int l = rep->len;
- if (l < SHORT_PER_LONG)
- return 1;
- else if (l > SHORT_PER_LONG)
- return 0;
- else if ((unsigned)(rep->s[SHORT_PER_LONG - 1]) < (unsigned)(I_MINNUM))
- return 1;
- else if (rep->sgn == I_NEGATIVE && rep->s[SHORT_PER_LONG - 1] == I_MINNUM)
- {
- for (unsigned int i = 0; i < SHORT_PER_LONG - 1; ++i)
- if (rep->s[i] != 0)
- return 0;
- return 1;
- }
- else
- return 0;
-}
-
-// comparison functions
-
-int compare(const IntRep* x, const IntRep* y)
-{
- int diff = x->sgn - y->sgn;
- if (diff == 0)
- {
- diff = x->len - y->len;
- if (diff == 0)
- diff = docmp(x->s, y->s, x->len);
- if (x->sgn == I_NEGATIVE)
- diff = -diff;
- }
- return diff;
-}
-
-int ucompare(const IntRep* x, const IntRep* y)
-{
- int diff = x->len - y->len;
- if (diff == 0)
- {
- int l = x->len;
- const unsigned short* xs = &(x->s[l]);
- const unsigned short* ys = &(y->s[l]);
- while (l-- > 0 && (diff = (*--xs) - (*--ys)) == 0);
- }
- return diff;
-}
-
-int compare(const IntRep* x, long y)
-{
- int xl = x->len;
- int xsgn = x->sgn;
- if (y == 0)
- {
- if (xl == 0)
- return 0;
- else if (xsgn == I_NEGATIVE)
- return -1;
- else
- return 1;
- }
- else
- {
- int ysgn = y >= 0;
- unsigned long uy = (ysgn)? y : -y;
- int diff = xsgn - ysgn;
- if (diff == 0)
- {
- diff = xl - SHORT_PER_LONG;
- if (diff <= 0)
- {
- unsigned short tmp[SHORT_PER_LONG];
- int yl = 0;
- while (uy != 0)
- {
- tmp[yl++] = extract(uy);
- uy = down(uy);
- }
- diff = xl - yl;
- if (diff == 0)
- diff = docmp(x->s, tmp, xl);
- }
- if (xsgn == I_NEGATIVE)
- diff = -diff;
- }
- return diff;
- }
-}
-
-int ucompare(const IntRep* x, long y)
-{
- int xl = x->len;
- if (y == 0)
- return xl;
- else
- {
- unsigned long uy = (y >= 0)? y : -y;
- int diff = xl - SHORT_PER_LONG;
- if (diff <= 0)
- {
- unsigned short tmp[SHORT_PER_LONG];
- int yl = 0;
- while (uy != 0)
- {
- tmp[yl++] = extract(uy);
- uy = down(uy);
- }
- diff = xl - yl;
- if (diff == 0)
- diff = docmp(x->s, tmp, xl);
- }
- return diff;
- }
-}
-
-
-
-// arithmetic functions
-
-IntRep* add(const IntRep* x, int negatex,
- const IntRep* y, int negatey, IntRep* r)
-{
- nonnil(x);
- nonnil(y);
-
- int xl = x->len;
- int yl = y->len;
-
- int xsgn = (negatex && xl != 0) ? !x->sgn : x->sgn;
- int ysgn = (negatey && yl != 0) ? !y->sgn : y->sgn;
-
- int xrsame = x == r;
- int yrsame = y == r;
-
- if (yl == 0)
- r = Ialloc(r, x->s, xl, xsgn, xl);
- else if (xl == 0)
- r = Ialloc(r, y->s, yl, ysgn, yl);
- else if (xsgn == ysgn)
- {
- if (xrsame || yrsame)
- r = Iresize(r, calc_len(xl, yl, 1));
- else
- r = Icalloc(r, calc_len(xl, yl, 1));
- r->sgn = xsgn;
- unsigned short* rs = r->s;
- const unsigned short* as;
- const unsigned short* bs;
- const unsigned short* topa;
- const unsigned short* topb;
- if (xl >= yl)
- {
- as = (xrsame)? r->s : x->s;
- topa = &(as[xl]);
- bs = (yrsame)? r->s : y->s;
- topb = &(bs[yl]);
- }
- else
- {
- bs = (xrsame)? r->s : x->s;
- topb = &(bs[xl]);
- as = (yrsame)? r->s : y->s;
- topa = &(as[yl]);
- }
- unsigned long sum = 0;
- while (bs < topb)
- {
- sum += (unsigned long)(*as++) + (unsigned long)(*bs++);
- *rs++ = extract(sum);
- sum = down(sum);
- }
- while (sum != 0 && as < topa)
- {
- sum += (unsigned long)(*as++);
- *rs++ = extract(sum);
- sum = down(sum);
- }
- if (sum != 0)
- *rs = extract(sum);
- else if (rs != as)
- while (as < topa)
- *rs++ = *as++;
- }
- else
- {
- int comp = ucompare(x, y);
- if (comp == 0)
- r = Icopy_zero(r);
- else
- {
- if (xrsame || yrsame)
- r = Iresize(r, calc_len(xl, yl, 0));
- else
- r = Icalloc(r, calc_len(xl, yl, 0));
- unsigned short* rs = r->s;
- const unsigned short* as;
- const unsigned short* bs;
- const unsigned short* topa;
- const unsigned short* topb;
- if (comp > 0)
- {
- as = (xrsame)? r->s : x->s;
- topa = &(as[xl]);
- bs = (yrsame)? r->s : y->s;
- topb = &(bs[yl]);
- r->sgn = xsgn;
- }
- else
- {
- bs = (xrsame)? r->s : x->s;
- topb = &(bs[xl]);
- as = (yrsame)? r->s : y->s;
- topa = &(as[yl]);
- r->sgn = ysgn;
- }
- unsigned long hi = 1;
- while (bs < topb)
- {
- hi += (unsigned long)(*as++) + I_MAXNUM - (unsigned long)(*bs++);
- *rs++ = extract(hi);
- hi = down(hi);
- }
- while (hi == 0 && as < topa)
- {
- hi = (unsigned long)(*as++) + I_MAXNUM;
- *rs++ = extract(hi);
- hi = down(hi);
- }
- if (rs != as)
- while (as < topa)
- *rs++ = *as++;
- }
- }
- Icheck(r);
- return r;
-}
-
-
-IntRep* add(const IntRep* x, int negatex, long y, IntRep* r)
-{
- nonnil(x);
- int xl = x->len;
- int xsgn = (negatex && xl != 0) ? !x->sgn : x->sgn;
- int xrsame = x == r;
-
- int ysgn = (y >= 0);
- unsigned long uy = (ysgn)? y : -y;
-
- if (y == 0)
- r = Ialloc(r, x->s, xl, xsgn, xl);
- else if (xl == 0)
- r = Icopy_long(r, y);
- else if (xsgn == ysgn)
- {
- if (xrsame)
- r = Iresize(r, calc_len(xl, SHORT_PER_LONG, 1));
- else
- r = Icalloc(r, calc_len(xl, SHORT_PER_LONG, 1));
- r->sgn = xsgn;
- unsigned short* rs = r->s;
- const unsigned short* as = (xrsame)? r->s : x->s;
- const unsigned short* topa = &(as[xl]);
- unsigned long sum = 0;
- while (as < topa && uy != 0)
- {
- unsigned long u = extract(uy);
- uy = down(uy);
- sum += (unsigned long)(*as++) + u;
- *rs++ = extract(sum);
- sum = down(sum);
- }
- while (sum != 0 && as < topa)
- {
- sum += (unsigned long)(*as++);
- *rs++ = extract(sum);
- sum = down(sum);
- }
- if (sum != 0)
- *rs = extract(sum);
- else if (rs != as)
- while (as < topa)
- *rs++ = *as++;
- }
- else
- {
- unsigned short tmp[SHORT_PER_LONG];
- int yl = 0;
- while (uy != 0)
- {
- tmp[yl++] = extract(uy);
- uy = down(uy);
- }
- int comp = xl - yl;
- if (comp == 0)
- comp = docmp(x->s, tmp, yl);
- if (comp == 0)
- r = Icopy_zero(r);
- else
- {
- if (xrsame)
- r = Iresize(r, calc_len(xl, yl, 0));
- else
- r = Icalloc(r, calc_len(xl, yl, 0));
- unsigned short* rs = r->s;
- const unsigned short* as;
- const unsigned short* bs;
- const unsigned short* topa;
- const unsigned short* topb;
- if (comp > 0)
- {
- as = (xrsame)? r->s : x->s;
- topa = &(as[xl]);
- bs = tmp;
- topb = &(bs[yl]);
- r->sgn = xsgn;
- }
- else
- {
- bs = (xrsame)? r->s : x->s;
- topb = &(bs[xl]);
- as = tmp;
- topa = &(as[yl]);
- r->sgn = ysgn;
- }
- unsigned long hi = 1;
- while (bs < topb)
- {
- hi += (unsigned long)(*as++) + I_MAXNUM - (unsigned long)(*bs++);
- *rs++ = extract(hi);
- hi = down(hi);
- }
- while (hi == 0 && as < topa)
- {
- hi = (unsigned long)(*as++) + I_MAXNUM;
- *rs++ = extract(hi);
- hi = down(hi);
- }
- if (rs != as)
- while (as < topa)
- *rs++ = *as++;
- }
- }
- Icheck(r);
- return r;
-}
-
-
-IntRep* multiply(const IntRep* x, const IntRep* y, IntRep* r)
-{
- nonnil(x);
- nonnil(y);
- int xl = x->len;
- int yl = y->len;
- int rl = xl + yl;
- int rsgn = x->sgn == y->sgn;
- int xrsame = x == r;
- int yrsame = y == r;
- int xysame = x == y;
-
- if (xl == 0 || yl == 0)
- r = Icopy_zero(r);
- else if (xl == 1 && x->s[0] == 1)
- r = Icopy(r, y);
- else if (yl == 1 && y->s[0] == 1)
- r = Icopy(r, x);
- else if (!(xysame && xrsame))
- {
- if (xrsame || yrsame)
- r = Iresize(r, rl);
- else
- r = Icalloc(r, rl);
- unsigned short* rs = r->s;
- unsigned short* topr = &(rs[rl]);
-
- // use best inner/outer loop params given constraints
- unsigned short* currentr;
- const unsigned short* bota;
- const unsigned short* as;
- const unsigned short* botb;
- const unsigned short* topb;
- if (xrsame)
- {
- currentr = &(rs[xl-1]);
- bota = rs;
- as = currentr;
- botb = y->s;
- topb = &(botb[yl]);
- }
- else if (yrsame)
- {
- currentr = &(rs[yl-1]);
- bota = rs;
- as = currentr;
- botb = x->s;
- topb = &(botb[xl]);
- }
- else if (xl <= yl)
- {
- currentr = &(rs[xl-1]);
- bota = x->s;
- as = &(bota[xl-1]);
- botb = y->s;
- topb = &(botb[yl]);
- }
- else
- {
- currentr = &(rs[yl-1]);
- bota = y->s;
- as = &(bota[yl-1]);
- botb = x->s;
- topb = &(botb[xl]);
- }
-
- while (as >= bota)
- {
- unsigned long ai = (unsigned long)(*as--);
- unsigned short* rs = currentr--;
- *rs = 0;
- if (ai != 0)
- {
- unsigned long sum = 0;
- const unsigned short* bs = botb;
- while (bs < topb)
- {
- sum += ai * (unsigned long)(*bs++) + (unsigned long)(*rs);
- *rs++ = extract(sum);
- sum = down(sum);
- }
- while (sum != 0 && rs < topr)
- {
- sum += (unsigned long)(*rs);
- *rs++ = extract(sum);
- sum = down(sum);
- }
- }
- }
- }
- else // x, y, and r same; compute over diagonals
- {
- r = Iresize(r, rl);
- unsigned short* botr = r->s;
- unsigned short* topr = &(botr[rl]);
- unsigned short* rs = &(botr[rl - 2]);
-
- const unsigned short* bota = (xrsame)? botr : x->s;
- const unsigned short* loa = &(bota[xl - 1]);
- const unsigned short* hia = loa;
-
- for (; rs >= botr; --rs)
- {
- const unsigned short* h = hia;
- const unsigned short* l = loa;
- unsigned long prod = (unsigned long)(*h) * (unsigned long)(*l);
- *rs = 0;
-
- for(;;)
- {
- unsigned short* rt = rs;
- unsigned long sum = prod + (unsigned long)(*rt);
- *rt++ = extract(sum);
- sum = down(sum);
- while (sum != 0 && rt < topr)
- {
- sum += (unsigned long)(*rt);
- *rt++ = extract(sum);
- sum = down(sum);
- }
- if (h > l)
- {
- rt = rs;
- sum = prod + (unsigned long)(*rt);
- *rt++ = extract(sum);
- sum = down(sum);
- while (sum != 0 && rt < topr)
- {
- sum += (unsigned long)(*rt);
- *rt++ = extract(sum);
- sum = down(sum);
- }
- if (--h >= ++l)
- prod = (unsigned long)(*h) * (unsigned long)(*l);
- else
- break;
- }
- else
- break;
- }
- if (loa > bota)
- --loa;
- else
- --hia;
- }
- }
- r->sgn = rsgn;
- Icheck(r);
- return r;
-}
-
-
-IntRep* multiply(const IntRep* x, long y, IntRep* r)
-{
- nonnil(x);
- int xl = x->len;
-
- if (xl == 0 || y == 0)
- r = Icopy_zero(r);
- else if (y == 1)
- r = Icopy(r, x);
- else
- {
- int ysgn = y >= 0;
- int rsgn = x->sgn == ysgn;
- unsigned long uy = (ysgn)? y : -y;
- unsigned short tmp[SHORT_PER_LONG];
- int yl = 0;
- while (uy != 0)
- {
- tmp[yl++] = extract(uy);
- uy = down(uy);
- }
-
- int rl = xl + yl;
- int xrsame = x == r;
- if (xrsame)
- r = Iresize(r, rl);
- else
- r = Icalloc(r, rl);
-
- unsigned short* rs = r->s;
- unsigned short* topr = &(rs[rl]);
- unsigned short* currentr;
- const unsigned short* bota;
- const unsigned short* as;
- const unsigned short* botb;
- const unsigned short* topb;
-
- if (xrsame)
- {
- currentr = &(rs[xl-1]);
- bota = rs;
- as = currentr;
- botb = tmp;
- topb = &(botb[yl]);
- }
- else if (xl <= yl)
- {
- currentr = &(rs[xl-1]);
- bota = x->s;
- as = &(bota[xl-1]);
- botb = tmp;
- topb = &(botb[yl]);
- }
- else
- {
- currentr = &(rs[yl-1]);
- bota = tmp;
- as = &(bota[yl-1]);
- botb = x->s;
- topb = &(botb[xl]);
- }
-
- while (as >= bota)
- {
- unsigned long ai = (unsigned long)(*as--);
- unsigned short* rs = currentr--;
- *rs = 0;
- if (ai != 0)
- {
- unsigned long sum = 0;
- const unsigned short* bs = botb;
- while (bs < topb)
- {
- sum += ai * (unsigned long)(*bs++) + (unsigned long)(*rs);
- *rs++ = extract(sum);
- sum = down(sum);
- }
- while (sum != 0 && rs < topr)
- {
- sum += (unsigned long)(*rs);
- *rs++ = extract(sum);
- sum = down(sum);
- }
- }
- }
- r->sgn = rsgn;
- }
- Icheck(r);
- return r;
-}
-
-
-// main division routine
-
-static void do_divide(unsigned short* rs,
- const unsigned short* ys, int yl,
- unsigned short* qs, int ql)
-{
- const unsigned short* topy = &(ys[yl]);
- unsigned short d1 = ys[yl - 1];
- unsigned short d2 = ys[yl - 2];
-
- int l = ql - 1;
- int i = l + yl;
-
- for (; l >= 0; --l, --i)
- {
- unsigned short qhat; // guess q
- if (d1 == rs[i])
- qhat = I_MAXNUM;
- else
- {
- unsigned long lr = up((unsigned long)rs[i]) | rs[i-1];
- qhat = lr / d1;
- }
-
- for(;;) // adjust q, use docmp to avoid overflow problems
- {
- unsigned short ts[3];
- unsigned long prod = (unsigned long)d2 * (unsigned long)qhat;
- ts[0] = extract(prod);
- prod = down(prod) + (unsigned long)d1 * (unsigned long)qhat;
- ts[1] = extract(prod);
- ts[2] = extract(down(prod));
- if (docmp(ts, &(rs[i-2]), 3) > 0)
- --qhat;
- else
- break;
- };
-
- // multiply & subtract
-
- const unsigned short* yt = ys;
- unsigned short* rt = &(rs[l]);
- unsigned long prod = 0;
- unsigned long hi = 1;
- while (yt < topy)
- {
- prod = (unsigned long)qhat * (unsigned long)(*yt++) + down(prod);
- hi += (unsigned long)(*rt) + I_MAXNUM - (unsigned long)(extract(prod));
- *rt++ = extract(hi);
- hi = down(hi);
- }
- hi += (unsigned long)(*rt) + I_MAXNUM - (unsigned long)(down(prod));
- *rt = extract(hi);
- hi = down(hi);
-
- // off-by-one, add back
-
- if (hi == 0)
- {
- --qhat;
- yt = ys;
- rt = &(rs[l]);
- hi = 0;
- while (yt < topy)
- {
- hi = (unsigned long)(*rt) + (unsigned long)(*yt++) + down(hi);
- *rt++ = extract(hi);
- }
- *rt = 0;
- }
- if (qs != 0)
- qs[l] = qhat;
- }
-}
-
-// divide by single digit, return remainder
-// if q != 0, then keep the result in q, else just compute rem
-
-static int unscale(const unsigned short* x, int xl, unsigned short y,
- unsigned short* q)
-{
- if (xl == 0 || y == 1)
- return 0;
- else if (q != 0)
- {
- unsigned short* botq = q;
- unsigned short* qs = &(botq[xl - 1]);
- const unsigned short* xs = &(x[xl - 1]);
- unsigned long rem = 0;
- while (qs >= botq)
- {
- rem = up(rem) | *xs--;
- unsigned long u = rem / y;
- *qs-- = extract(u);
- rem -= u * y;
- }
- int r = extract(rem);
- return r;
- }
- else // same loop, a bit faster if just need rem
- {
- const unsigned short* botx = x;
- const unsigned short* xs = &(botx[xl - 1]);
- unsigned long rem = 0;
- while (xs >= botx)
- {
- rem = up(rem) | *xs--;
- unsigned long u = rem / y;
- rem -= u * y;
- }
- int r = extract(rem);
- return r;
- }
-}
-
-
-IntRep* div(const IntRep* x, const IntRep* y, IntRep* q)
-{
- nonnil(x);
- nonnil(y);
- int xl = x->len;
- int yl = y->len;
- if (yl == 0) (*lib_error_handler)("Integer", "attempted division by zero");
-
- int comp = ucompare(x, y);
- int xsgn = x->sgn;
- int ysgn = y->sgn;
-
- int samesign = xsgn == ysgn;
-
- if (comp < 0)
- q = Icopy_zero(q);
- else if (comp == 0)
- q = Icopy_one(q, samesign);
- else if (yl == 1)
- {
- q = Icopy(q, x);
- unscale(q->s, q->len, y->s[0], q->s);
- }
- else
- {
- IntRep* yy = 0;
- IntRep* r = 0;
- unsigned short prescale = (I_RADIX / (1 + y->s[yl - 1]));
- if (prescale != 1 || y == q)
- {
- yy = multiply(y, ((long)prescale & I_MAXNUM), yy);
- r = multiply(x, ((long)prescale & I_MAXNUM), r);
- }
- else
- {
- yy = (IntRep*)y;
- r = Icalloc(r, xl + 1);
- scpy(x->s, r->s, xl);
- }
-
- int ql = xl - yl + 1;
-
- q = Icalloc(q, ql);
- do_divide(r->s, yy->s, yl, q->s, ql);
-
- if (yy != y && !STATIC_IntRep(yy)) delete yy;
- if (!STATIC_IntRep(r)) delete r;
- }
- q->sgn = samesign;
- Icheck(q);
- return q;
-}
-
-IntRep* div(const IntRep* x, long y, IntRep* q)
-{
- nonnil(x);
- int xl = x->len;
- if (y == 0) (*lib_error_handler)("Integer", "attempted division by zero");
-
- unsigned short ys[SHORT_PER_LONG];
- unsigned long u;
- int ysgn = y >= 0;
- if (ysgn)
- u = y;
- else
- u = -y;
- int yl = 0;
- while (u != 0)
- {
- ys[yl++] = extract(u);
- u = down(u);
- }
-
- int comp = xl - yl;
- if (comp == 0) comp = docmp(x->s, ys, xl);
-
- int xsgn = x->sgn;
- int samesign = xsgn == ysgn;
-
- if (comp < 0)
- q = Icopy_zero(q);
- else if (comp == 0)
- {
- q = Icopy_one(q, samesign);
- }
- else if (yl == 1)
- {
- q = Icopy(q, x);
- unscale(q->s, q->len, ys[0], q->s);
- }
- else
- {
- IntRep* r = 0;
- unsigned short prescale = (I_RADIX / (1 + ys[yl - 1]));
- if (prescale != 1)
- {
- unsigned long prod = (unsigned long)prescale * (unsigned long)ys[0];
- ys[0] = extract(prod);
- prod = down(prod) + (unsigned long)prescale * (unsigned long)ys[1];
- ys[1] = extract(prod);
- r = multiply(x, ((long)prescale & I_MAXNUM), r);
- }
- else
- {
- r = Icalloc(r, xl + 1);
- scpy(x->s, r->s, xl);
- }
-
- int ql = xl - yl + 1;
-
- q = Icalloc(q, ql);
- do_divide(r->s, ys, yl, q->s, ql);
-
- if (!STATIC_IntRep(r)) delete r;
- }
- q->sgn = samesign;
- Icheck(q);
- return q;
-}
-
-
-void divide(const Integer& Ix, long y, Integer& Iq, long& rem)
-{
- const IntRep* x = Ix.rep;
- nonnil(x);
- IntRep* q = Iq.rep;
- int xl = x->len;
- if (y == 0) (*lib_error_handler)("Integer", "attempted division by zero");
-
- unsigned short ys[SHORT_PER_LONG];
- unsigned long u;
- int ysgn = y >= 0;
- if (ysgn)
- u = y;
- else
- u = -y;
- int yl = 0;
- while (u != 0)
- {
- ys[yl++] = extract(u);
- u = down(u);
- }
-
- int comp = xl - yl;
- if (comp == 0) comp = docmp(x->s, ys, xl);
-
- int xsgn = x->sgn;
- int samesign = xsgn == ysgn;
-
- if (comp < 0)
- {
- rem = Itolong(x);
- q = Icopy_zero(q);
- }
- else if (comp == 0)
- {
- q = Icopy_one(q, samesign);
- rem = 0;
- }
- else if (yl == 1)
- {
- q = Icopy(q, x);
- rem = unscale(q->s, q->len, ys[0], q->s);
- }
- else
- {
- IntRep* r = 0;
- unsigned short prescale = (I_RADIX / (1 + ys[yl - 1]));
- if (prescale != 1)
- {
- unsigned long prod = (unsigned long)prescale * (unsigned long)ys[0];
- ys[0] = extract(prod);
- prod = down(prod) + (unsigned long)prescale * (unsigned long)ys[1];
- ys[1] = extract(prod);
- r = multiply(x, ((long)prescale & I_MAXNUM), r);
- }
- else
- {
- r = Icalloc(r, xl + 1);
- scpy(x->s, r->s, xl);
- }
-
- int ql = xl - yl + 1;
-
- q = Icalloc(q, ql);
-
- do_divide(r->s, ys, yl, q->s, ql);
-
- if (prescale != 1)
- {
- Icheck(r);
- unscale(r->s, r->len, prescale, r->s);
- }
- Icheck(r);
- rem = Itolong(r);
- if (!STATIC_IntRep(r)) delete r;
- }
- rem = abs(rem);
- if (xsgn == I_NEGATIVE) rem = -rem;
- q->sgn = samesign;
- Icheck(q);
- Iq.rep = q;
-}
-
-
-void divide(const Integer& Ix, const Integer& Iy, Integer& Iq, Integer& Ir)
-{
- const IntRep* x = Ix.rep;
- nonnil(x);
- const IntRep* y = Iy.rep;
- nonnil(y);
- IntRep* q = Iq.rep;
- IntRep* r = Ir.rep;
-
- int xl = x->len;
- int yl = y->len;
- if (yl == 0)
- (*lib_error_handler)("Integer", "attempted division by zero");
-
- int comp = ucompare(x, y);
- int xsgn = x->sgn;
- int ysgn = y->sgn;
-
- int samesign = xsgn == ysgn;
-
- if (comp < 0)
- {
- q = Icopy_zero(q);
- r = Icopy(r, x);
- }
- else if (comp == 0)
- {
- q = Icopy_one(q, samesign);
- r = Icopy_zero(r);
- }
- else if (yl == 1)
- {
- q = Icopy(q, x);
- int rem = unscale(q->s, q->len, y->s[0], q->s);
- r = Icopy_long(r, rem);
- if (rem != 0)
- r->sgn = xsgn;
- }
- else
- {
- IntRep* yy = 0;
- unsigned short prescale = (I_RADIX / (1 + y->s[yl - 1]));
- if (prescale != 1 || y == q || y == r)
- {
- yy = multiply(y, ((long)prescale & I_MAXNUM), yy);
- r = multiply(x, ((long)prescale & I_MAXNUM), r);
- }
- else
- {
- yy = (IntRep*)y;
- r = Icalloc(r, xl + 1);
- scpy(x->s, r->s, xl);
- }
-
- int ql = xl - yl + 1;
-
- q = Icalloc(q, ql);
- do_divide(r->s, yy->s, yl, q->s, ql);
-
- if (yy != y && !STATIC_IntRep(yy)) delete yy;
- if (prescale != 1)
- {
- Icheck(r);
- unscale(r->s, r->len, prescale, r->s);
- }
- }
- q->sgn = samesign;
- Icheck(q);
- Iq.rep = q;
- Icheck(r);
- Ir.rep = r;
-}
-
-IntRep* mod(const IntRep* x, const IntRep* y, IntRep* r)
-{
- nonnil(x);
- nonnil(y);
- int xl = x->len;
- int yl = y->len;
- if (yl == 0) (*lib_error_handler)("Integer", "attempted division by zero");
-
- int comp = ucompare(x, y);
- int xsgn = x->sgn;
-
- if (comp < 0)
- r = Icopy(r, x);
- else if (comp == 0)
- r = Icopy_zero(r);
- else if (yl == 1)
- {
- int rem = unscale(x->s, xl, y->s[0], 0);
- r = Icopy_long(r, rem);
- if (rem != 0)
- r->sgn = xsgn;
- }
- else
- {
- IntRep* yy = 0;
- unsigned short prescale = (I_RADIX / (1 + y->s[yl - 1]));
- if (prescale != 1 || y == r)
- {
- yy = multiply(y, ((long)prescale & I_MAXNUM), yy);
- r = multiply(x, ((long)prescale & I_MAXNUM), r);
- }
- else
- {
- yy = (IntRep*)y;
- r = Icalloc(r, xl + 1);
- scpy(x->s, r->s, xl);
- }
-
- do_divide(r->s, yy->s, yl, 0, xl - yl + 1);
-
- if (yy != y && !STATIC_IntRep(yy)) delete yy;
-
- if (prescale != 1)
- {
- Icheck(r);
- unscale(r->s, r->len, prescale, r->s);
- }
- }
- Icheck(r);
- return r;
-}
-
-IntRep* mod(const IntRep* x, long y, IntRep* r)
-{
- nonnil(x);
- int xl = x->len;
- if (y == 0) (*lib_error_handler)("Integer", "attempted division by zero");
-
- unsigned short ys[SHORT_PER_LONG];
- unsigned long u;
- int ysgn = y >= 0;
- if (ysgn)
- u = y;
- else
- u = -y;
- int yl = 0;
- while (u != 0)
- {
- ys[yl++] = extract(u);
- u = down(u);
- }
-
- int comp = xl - yl;
- if (comp == 0) comp = docmp(x->s, ys, xl);
-
- int xsgn = x->sgn;
-
- if (comp < 0)
- r = Icopy(r, x);
- else if (comp == 0)
- r = Icopy_zero(r);
- else if (yl == 1)
- {
- int rem = unscale(x->s, xl, ys[0], 0);
- r = Icopy_long(r, rem);
- if (rem != 0)
- r->sgn = xsgn;
- }
- else
- {
- unsigned short prescale = (I_RADIX / (1 + ys[yl - 1]));
- if (prescale != 1)
- {
- unsigned long prod = (unsigned long)prescale * (unsigned long)ys[0];
- ys[0] = extract(prod);
- prod = down(prod) + (unsigned long)prescale * (unsigned long)ys[1];
- ys[1] = extract(prod);
- r = multiply(x, ((long)prescale & I_MAXNUM), r);
- }
- else
- {
- r = Icalloc(r, xl + 1);
- scpy(x->s, r->s, xl);
- }
-
- do_divide(r->s, ys, yl, 0, xl - yl + 1);
-
- if (prescale != 1)
- {
- Icheck(r);
- unscale(r->s, r->len, prescale, r->s);
- }
- }
- Icheck(r);
- return r;
-}
-
-IntRep* lshift(const IntRep* x, long y, IntRep* r)
-{
- nonnil(x);
- int xl = x->len;
- if (xl == 0 || y == 0)
- {
- r = Icopy(r, x);
- return r;
- }
-
- int xrsame = x == r;
- int rsgn = x->sgn;
-
- long ay = (y < 0)? -y : y;
- int bw = ay / I_SHIFT;
- int sw = ay % I_SHIFT;
-
- if (y > 0)
- {
- int rl = bw + xl + 1;
- if (xrsame)
- r = Iresize(r, rl);
- else
- r = Icalloc(r, rl);
-
- unsigned short* botr = r->s;
- unsigned short* rs = &(botr[rl - 1]);
- const unsigned short* botx = (xrsame)? botr : x->s;
- const unsigned short* xs = &(botx[xl - 1]);
- unsigned long a = 0;
- while (xs >= botx)
- {
- a = up(a) | ((unsigned long)(*xs--) << sw);
- *rs-- = extract(down(a));
- }
- *rs-- = extract(a);
- while (rs >= botr)
- *rs-- = 0;
- }
- else
- {
- int rl = xl - bw;
- if (rl < 0)
- r = Icopy_zero(r);
- else
- {
- if (xrsame)
- r = Iresize(r, rl);
- else
- r = Icalloc(r, rl);
- int rw = I_SHIFT - sw;
- unsigned short* rs = r->s;
- unsigned short* topr = &(rs[rl]);
- const unsigned short* botx = (xrsame)? rs : x->s;
- const unsigned short* xs = &(botx[bw]);
- const unsigned short* topx = &(botx[xl]);
- unsigned long a = (unsigned long)(*xs++) >> sw;
- while (xs < topx)
- {
- a |= (unsigned long)(*xs++) << rw;
- *rs++ = extract(a);
- a = down(a);
- }
- *rs++ = extract(a);
- if (xrsame) topr = (unsigned short*)topx;
- while (rs < topr)
- *rs++ = 0;
- }
- }
- r->sgn = rsgn;
- Icheck(r);
- return r;
-}
-
-IntRep* lshift(const IntRep* x, const IntRep* yy, int negatey, IntRep* r)
-{
- long y = Itolong(yy);
- if (negatey)
- y = -y;
-
- return lshift(x, y, r);
-}
-
-IntRep* bitop(const IntRep* x, const IntRep* y, IntRep* r, char op)
-{
- nonnil(x);
- nonnil(y);
- int xl = x->len;
- int yl = y->len;
- int xsgn = x->sgn;
- int xrsame = x == r;
- int yrsame = y == r;
- if (xrsame || yrsame)
- r = Iresize(r, calc_len(xl, yl, 0));
- else
- r = Icalloc(r, calc_len(xl, yl, 0));
- r->sgn = xsgn;
- unsigned short* rs = r->s;
- unsigned short* topr = &(rs[r->len]);
- const unsigned short* as;
- const unsigned short* bs;
- const unsigned short* topb;
- if (xl >= yl)
- {
- as = (xrsame)? rs : x->s;
- bs = (yrsame)? rs : y->s;
- topb = &(bs[yl]);
- }
- else
- {
- bs = (xrsame)? rs : x->s;
- topb = &(bs[xl]);
- as = (yrsame)? rs : y->s;
- }
-
- switch (op)
- {
- case '&':
- while (bs < topb) *rs++ = *as++ & *bs++;
- while (rs < topr) *rs++ = 0;
- break;
- case '|':
- while (bs < topb) *rs++ = *as++ | *bs++;
- while (rs < topr) *rs++ = *as++;
- break;
- case '^':
- while (bs < topb) *rs++ = *as++ ^ *bs++;
- while (rs < topr) *rs++ = *as++;
- break;
- }
- Icheck(r);
- return r;
-}
-
-IntRep* bitop(const IntRep* x, long y, IntRep* r, char op)
-{
- nonnil(x);
- unsigned short tmp[SHORT_PER_LONG];
- unsigned long u;
- int newsgn;
- if (newsgn = (y >= 0))
- u = y;
- else
- u = -y;
-
- int l = 0;
- while (u != 0)
- {
- tmp[l++] = extract(u);
- u = down(u);
- }
-
- int xl = x->len;
- int yl = l;
- int xsgn = x->sgn;
- int xrsame = x == r;
- if (xrsame)
- r = Iresize(r, calc_len(xl, yl, 0));
- else
- r = Icalloc(r, calc_len(xl, yl, 0));
- r->sgn = xsgn;
- unsigned short* rs = r->s;
- unsigned short* topr = &(rs[r->len]);
- const unsigned short* as;
- const unsigned short* bs;
- const unsigned short* topb;
- if (xl >= yl)
- {
- as = (xrsame)? rs : x->s;
- bs = tmp;
- topb = &(bs[yl]);
- }
- else
- {
- bs = (xrsame)? rs : x->s;
- topb = &(bs[xl]);
- as = tmp;
- }
-
- switch (op)
- {
- case '&':
- while (bs < topb) *rs++ = *as++ & *bs++;
- while (rs < topr) *rs++ = 0;
- break;
- case '|':
- while (bs < topb) *rs++ = *as++ | *bs++;
- while (rs < topr) *rs++ = *as++;
- break;
- case '^':
- while (bs < topb) *rs++ = *as++ ^ *bs++;
- while (rs < topr) *rs++ = *as++;
- break;
- }
- Icheck(r);
- return r;
-}
-
-
-
-IntRep* compl(const IntRep* src, IntRep* r)
-{
- nonnil(src);
- r = Icopy(r, src);
- unsigned short* s = r->s;
- unsigned short* top = &(s[r->len - 1]);
- while (s < top)
- {
- unsigned short cmp = ~(*s);
- *s++ = cmp;
- }
- unsigned short a = *s;
- unsigned short b = 0;
- while (a != 0)
- {
- b <<= 1;
- if (!(a & 1)) b |= 1;
- a >>= 1;
- }
- *s = b;
- Icheck(r);
- return r;
-}
-
-void (setbit)(Integer& x, long b)
-{
- if (b >= 0)
- {
- int bw = (unsigned long)b / I_SHIFT;
- int sw = (unsigned long)b % I_SHIFT;
- int xl = x.rep ? x.rep->len : 0;
- if (xl <= bw)
- x.rep = Iresize(x.rep, calc_len(xl, bw+1, 0));
- x.rep->s[bw] |= (1 << sw);
- Icheck(x.rep);
- }
-}
-
-void clearbit(Integer& x, long b)
-{
- if (b >= 0)
- {
- if (x.rep == 0)
- x.rep = &_ZeroRep;
- else
- {
- int bw = (unsigned long)b / I_SHIFT;
- int sw = (unsigned long)b % I_SHIFT;
- if (x.rep->len > bw)
- x.rep->s[bw] &= ~(1 << sw);
- }
- Icheck(x.rep);
- }
-}
-
-int testbit(const Integer& x, long b)
-{
- if (x.rep != 0 && b >= 0)
- {
- int bw = (unsigned long)b / I_SHIFT;
- int sw = (unsigned long)b % I_SHIFT;
- return (bw < x.rep->len && (x.rep->s[bw] & (1 << sw)) != 0);
- }
- else
- return 0;
-}
-
-// A version of knuth's algorithm B / ex. 4.5.3.34
-// A better version that doesn't bother shifting all of `t' forthcoming
-
-IntRep* gcd(const IntRep* x, const IntRep* y)
-{
- nonnil(x);
- nonnil(y);
- int ul = x->len;
- int vl = y->len;
-
- if (vl == 0)
- return Ialloc(0, x->s, ul, I_POSITIVE, ul);
- else if (ul == 0)
- return Ialloc(0, y->s, vl, I_POSITIVE, vl);
-
- IntRep* u = Ialloc(0, x->s, ul, I_POSITIVE, ul);
- IntRep* v = Ialloc(0, y->s, vl, I_POSITIVE, vl);
-
-// find shift so that both not even
-
- long k = 0;
- int l = (ul <= vl)? ul : vl;
- int cont = 1;
- for (int i = 0; i < l && cont; ++i)
- {
- unsigned long a = (i < ul)? u->s[i] : 0;
- unsigned long b = (i < vl)? v->s[i] : 0;
- for (int j = 0; j < I_SHIFT; ++j)
- {
- if ((a | b) & 1)
- {
- cont = 0;
- break;
- }
- else
- {
- ++k;
- a >>= 1;
- b >>= 1;
- }
- }
- }
-
- if (k != 0)
- {
- u = lshift(u, -k, u);
- v = lshift(v, -k, v);
- }
-
- IntRep* t;
- if (u->s[0] & 01)
- t = Ialloc(0, v->s, v->len, !v->sgn, v->len);
- else
- t = Ialloc(0, u->s, u->len, u->sgn, u->len);
-
- while (t->len != 0)
- {
- long s = 0; // shift t until odd
- cont = 1;
- int tl = t->len;
- for (i = 0; i < tl && cont; ++i)
- {
- unsigned long a = t->s[i];
- for (int j = 0; j < I_SHIFT; ++j)
- {
- if (a & 1)
- {
- cont = 0;
- break;
- }
- else
- {
- ++s;
- a >>= 1;
- }
- }
- }
-
- if (s != 0) t = lshift(t, -s, t);
-
- if (t->sgn == I_POSITIVE)
- {
- u = Icopy(u, t);
- t = add(t, 0, v, 1, t);
- }
- else
- {
- v = Ialloc(v, t->s, t->len, !t->sgn, t->len);
- t = add(t, 0, u, 0, t);
- }
- }
- if (!STATIC_IntRep(t)) delete t;
- if (!STATIC_IntRep(v)) delete v;
- if (k != 0) u = lshift(u, k, u);
- return u;
-}
-
-
-
-long lg(const IntRep* x)
-{
- nonnil(x);
- int xl = x->len;
- if (xl == 0)
- return 0;
-
- long l = (xl - 1) * I_SHIFT - 1;
- unsigned short a = x->s[xl-1];
-
- while (a != 0)
- {
- a = a >> 1;
- ++l;
- }
- return l;
-}
-
-IntRep* power(const IntRep* x, long y, IntRep* r)
-{
- nonnil(x);
- int sgn;
- if (x->sgn == I_POSITIVE || (!(y & 1)))
- sgn = I_POSITIVE;
- else
- sgn = I_NEGATIVE;
-
- int xl = x->len;
-
- if (y == 0 || (xl == 1 && x->s[0] == 1))
- r = Icopy_one(r, sgn);
- else if (xl == 0 || y < 0)
- r = Icopy_zero(r);
- else if (y == 1 || y == -1)
- r = Icopy(r, x);
- else
- {
- int maxsize = ((lg(x) + 1) * y) / I_SHIFT + 2; // pre-allocate space
- IntRep* b = Ialloc(0, x->s, xl, I_POSITIVE, maxsize);
- b->len = xl;
- r = Icalloc(r, maxsize);
- r = Icopy_one(r, I_POSITIVE);
- for(;;)
- {
- if (y & 1)
- r = multiply(r, b, r);
- if ((y >>= 1) == 0)
- break;
- else
- b = multiply(b, b, b);
- }
- if (!STATIC_IntRep(b)) delete b;
- }
- r->sgn = sgn;
- Icheck(r);
- return r;
-}
-
-IntRep* abs(const IntRep* src, IntRep* dest)
-{
- nonnil(src);
- if (src != dest)
- dest = Icopy(dest, src);
- dest->sgn = I_POSITIVE;
- return dest;
-}
-
-IntRep* negate(const IntRep* src, IntRep* dest)
-{
- nonnil(src);
- if (src != dest)
- dest = Icopy(dest, src);
- if (dest->len != 0)
- dest->sgn = !dest->sgn;
- return dest;
-}
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-
-Integer sqrt(const Integer& x) return r(x)
-{
- int s = sign(x);
- if (s < 0) x.error("Attempted square root of negative Integer");
- if (s != 0)
- {
- r >>= (lg(x) / 2); // get close
- Integer q;
- div(x, r, q);
- while (q < r)
- {
- r += q;
- r >>= 1;
- div(x, r, q);
- }
- }
- return;
-}
-
-Integer lcm(const Integer& x, const Integer& y) return r
-{
- if (!x.initialized() || !y.initialized())
- x.error("operation on uninitialized Integer");
- Integer g;
- if (sign(x) == 0 || sign(y) == 0)
- g = 1;
- else
- g = gcd(x, y);
- div(x, g, r);
- mul(r, y, r);
-}
-
-#else
-Integer sqrt(const Integer& x)
-{
- Integer r(x);
- int s = sign(x);
- if (s < 0) x.error("Attempted square root of negative Integer");
- if (s != 0)
- {
- r >>= (lg(x) / 2); // get close
- Integer q;
- div(x, r, q);
- while (q < r)
- {
- r += q;
- r >>= 1;
- div(x, r, q);
- }
- }
- return r;
-}
-
-Integer lcm(const Integer& x, const Integer& y)
-{
- Integer r;
- if (!x.initialized() || !y.initialized())
- x.error("operation on uninitialized Integer");
- Integer g;
- if (sign(x) == 0 || sign(y) == 0)
- g = 1;
- else
- g = gcd(x, y);
- div(x, g, r);
- mul(r, y, r);
- return r;
-}
-
-#endif
-
-
-
-IntRep* atoIntRep(const char* s, int base)
-{
- int sl = strlen(s);
- IntRep* r = Icalloc(0, sl * (lg(base) + 1) / I_SHIFT + 1);
- if (s != 0)
- {
- char sgn;
- while (isspace(*s)) ++s;
- if (*s == '-')
- {
- sgn = I_NEGATIVE;
- s++;
- }
- else if (*s == '+')
- {
- sgn = I_POSITIVE;
- s++;
- }
- else
- sgn = I_POSITIVE;
- for (;;)
- {
- long digit;
- if (*s >= '0' && *s <= '9') digit = *s - '0';
- else if (*s >= 'a' && *s <= 'z') digit = *s - 'a' + 10;
- else if (*s >= 'A' && *s <= 'Z') digit = *s - 'A' + 10;
- else break;
- if (digit >= base) break;
- r = multiply(r, base, r);
- r = add(r, 0, digit, r);
- ++s;
- }
- r->sgn = sgn;
- }
- return r;
-}
-
-
-
-extern AllocRing _libgxx_fmtq;
-
-char* Itoa(const IntRep* x, int base, int width)
-{
- int fmtlen = (x->len + 1) * I_SHIFT / lg(base) + 4 + width;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(fmtlen);
- char* f = cvtItoa(x, fmtbase, fmtlen, base, 0, width, 0, ' ', 'X', 0);
- return f;
-}
-
-ostream& operator << (ostream& s, const Integer& y)
-{
-#ifdef _OLD_STREAMS
- return s << Itoa(y.rep);
-#else
- if (s.opfx())
- {
- int base = (s.flags() & ios::oct) ? 8 : (s.flags() & ios::hex) ? 16 : 10;
- int width = s.width();
- y.printon(s, base, width);
- }
- return s;
-#endif
-}
-
-void Integer::printon(ostream& s, int base /* =10 */, int width /* =0 */) const
-{
- int align_right = !(s.flags() & ios::left);
- int showpos = s.flags() & ios::showpos;
- int showbase = s.flags() & ios::showbase;
- char fillchar = s.fill();
- char Xcase = (s.flags() & ios::uppercase)? 'X' : 'x';
- const IntRep* x = rep;
- int fmtlen = (x->len + 1) * I_SHIFT / lg(base) + 4 + width;
- char* fmtbase = new char[fmtlen];
- char* f = cvtItoa(x, fmtbase, fmtlen, base, showbase, width, align_right,
- fillchar, Xcase, showpos);
- s.write(f, fmtlen);
- delete fmtbase;
-}
-
-char* cvtItoa(const IntRep* x, char* fmt, int& fmtlen, int base, int showbase,
- int width, int align_right, char fillchar, char Xcase,
- int showpos)
-{
- char* e = fmt + fmtlen - 1;
- char* s = e;
- *--s = 0;
-
- if (x->len == 0)
- *--s = '0';
- else
- {
- IntRep* z = Icopy(0, x);
-
- // split division by base into two parts:
- // first divide by biggest power of base that fits in an unsigned short,
- // then use straight signed div/mods from there.
-
- // find power
- int bpower = 1;
- unsigned short b = base;
- unsigned short maxb = I_MAXNUM / base;
- while (b < maxb)
- {
- b *= base;
- ++bpower;
- }
- for(;;)
- {
- int rem = unscale(z->s, z->len, b, z->s);
- Icheck(z);
- if (z->len == 0)
- {
- while (rem != 0)
- {
- char ch = rem % base;
- rem /= base;
- if (ch >= 10)
- ch += 'a' - 10;
- else
- ch += '0';
- *--s = ch;
- }
- if (!STATIC_IntRep(z)) delete z;
- break;
- }
- else
- {
- for (int i = 0; i < bpower; ++i)
- {
- char ch = rem % base;
- rem /= base;
- if (ch >= 10)
- ch += 'a' - 10;
- else
- ch += '0';
- *--s = ch;
- }
- }
- }
- }
-
- if (base == 8 && showbase)
- *--s = '0';
- else if (base == 16 && showbase)
- {
- *--s = Xcase;
- *--s = '0';
- }
- if (x->sgn == I_NEGATIVE) *--s = '-';
- else if (showpos) *--s = '+';
- int w = e - s - 1;
- if (!align_right || w >= width)
- {
- while (w++ < width)
- *--s = fillchar;
- fmtlen = e - s - 1;
- return s;
- }
- else
- {
- char* p = fmt;
- for (char* t = s; *t != 0; ++t, ++p) *p = *t;
- while (w++ < width) *p++ = fillchar;
- *p = 0;
- fmtlen = p - fmt;
- return fmt;
- }
-}
-
-char* dec(const Integer& x, int width)
-{
- return Itoa(x, 10, width);
-}
-
-char* oct(const Integer& x, int width)
-{
- return Itoa(x, 8, width);
-}
-
-char* hex(const Integer& x, int width)
-{
- return Itoa(x, 16, width);
-}
-
-istream& operator >> (istream& stream, Integer& val)
-{
- if (!stream.ipfx0())
- return stream;
- int sign = ' ';
- register streambuf* sb = stream.rdbuf();
- int base = 10;
- int ndigits = 0;
- register int ch = sb->sbumpc();
- while (ch != EOF && isspace(ch))
- ch = sb->sbumpc();
- if (ch == '+' || ch == '-')
- {
- sign = ch;
- ch = sb->sbumpc();
- while (ch != EOF && isspace(ch))
- ch = sb->sbumpc();
- }
- if (ch == EOF) goto eof_fail;
- if (!(stream.flags() & ios::basefield))
- {
- if (ch == '0')
- {
- ch = sb->sbumpc();
- if (ch == EOF) { }
- else if (ch == 'x' || ch == 'X')
- {
- base = 16;
- ch = sb->sbumpc();
- if (ch == EOF) goto eof_fail;
- }
- else
- {
- sb->sputbackc(ch);
- base = 8;
- ch = '0';
- }
- }
- }
- else if ((stream.flags() & ios::basefield) == ios::hex)
- base = 16;
- else if ((stream.flags() & ios::basefield) == ios::oct)
- base = 8;
-
- val.rep = Icopy_zero(val.rep);
-
- for (;;)
- {
- if (ch == EOF)
- break;
- int digit;
- if (ch >= '0' && ch <= '9')
- digit = ch - '0';
- else if (ch >= 'A' && ch <= 'F')
- digit = ch - 'A' + 10;
- else if (ch >= 'a' && ch <= 'f')
- digit = ch - 'a' + 10;
- else
- digit = 999;
- if (digit >= base)
- {
- sb->sputbackc(ch);
- if (ndigits == 0)
- goto fail;
- else
- goto done;
- }
- ndigits++;
- switch (base)
- {
- case 8:
- val <<= 3;
- break;
- case 16:
- val <<= 4;
- break;
- default:
- val *= base;
- break;
- }
- val += digit;
- ch = sb->sbumpc();
- }
- fail:
- stream.set(ios::failbit);
- done:
- if (sign == '-')
- val.negate();
- return stream;
- eof_fail:
- stream.set(ios::failbit|ios::eofbit);
- return stream;
-}
-
-int Integer::OK() const
-{
- if (rep != 0)
- {
- int l = rep->len;
- int s = rep->sgn;
- int v = l <= rep->sz || STATIC_IntRep(rep); // length within bounds
- v &= s == 0 || s == 1; // legal sign
- Icheck(rep); // and correctly adjusted
- v &= rep->len == l;
- v &= rep->sgn == s;
- if (v)
- return v;
- }
- error("invariant failure");
- return 0;
-}
-
-void Integer::error(const char* msg) const
-{
- (*lib_error_handler)("Integer", msg);
-}
-
diff --git a/gnu/lib/libg++/libg++/LogNorm.cc b/gnu/lib/libg++/libg++/LogNorm.cc
deleted file mode 100644
index ab60f87..0000000
--- a/gnu/lib/libg++/libg++/LogNorm.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <Normal.h>
-
-#include <LogNorm.h>
-
-//
-// See Simulation, Modelling & Analysis by Law & Kelton, pp260
-//
-//
-
-double LogNormal::operator()()
-{
- return exp (this->Normal::operator()() );
-}
-
-
diff --git a/gnu/lib/libg++/libg++/MLCG.cc b/gnu/lib/libg++/libg++/MLCG.cc
deleted file mode 100644
index 053325e..0000000
--- a/gnu/lib/libg++/libg++/MLCG.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1989 Free Software Foundation
-
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <MLCG.h>
-//
-// SEED_TABLE_SIZE must be a power of 2
-//
-
-
-#define SEED_TABLE_SIZE 32
-
-static _G_int32_t seedTable[SEED_TABLE_SIZE] = {
-0xbdcc47e5, 0x54aea45d, 0xec0df859, 0xda84637b,
-0xc8c6cb4f, 0x35574b01, 0x28260b7d, 0x0d07fdbf,
-0x9faaeeb0, 0x613dd169, 0x5ce2d818, 0x85b9e706,
-0xab2469db, 0xda02b0dc, 0x45c60d6e, 0xffe49d10,
-0x7224fea3, 0xf9684fc9, 0xfc7ee074, 0x326ce92a,
-0x366d13b5, 0x17aaa731, 0xeb83a675, 0x7781cb32,
-0x4ec7c92d, 0x7f187521, 0x2cf346b4, 0xad13310f,
-0xb89cff2b, 0x12164de1, 0xa865168d, 0x32b56cdf
-};
-
-MLCG::MLCG(_G_int32_t seed1, _G_int32_t seed2)
-{
- initialSeedOne = seed1;
- initialSeedTwo = seed2;
- reset();
-}
-
-void
-MLCG::reset()
-{
- _G_int32_t seed1 = initialSeedOne;
- _G_int32_t seed2 = initialSeedTwo;
-
- //
- // Most people pick stupid seed numbers that do not have enough
- // bits. In this case, if they pick a small seed number, we
- // map that to a specific seed.
- //
- if (seed1 < 0) {
- seed1 = (seed1 + 2147483561);
- seed1 = (seed1 < 0) ? -seed1 : seed1;
- }
-
- if (seed2 < 0) {
- seed2 = (seed2 + 2147483561);
- seed2 = (seed2 < 0) ? -seed2 : seed2;
- }
-
- if (seed1 > -1 && seed1 < SEED_TABLE_SIZE) {
- seedOne = seedTable[seed1];
- } else {
- seedOne = seed1 ^ seedTable[seed1 & (SEED_TABLE_SIZE-1)];
- }
-
- if (seed2 > -1 && seed2 < SEED_TABLE_SIZE) {
- seedTwo = seedTable[seed2];
- } else {
- seedTwo = seed2 ^ seedTable[ seed2 & (SEED_TABLE_SIZE-1) ];
- }
- seedOne = (seedOne % 2147483561) + 1;
- seedTwo = (seedTwo % 2147483397) + 1;
-}
-
-_G_uint32_t MLCG::asLong()
-{
- _G_int32_t k = seedOne % 53668;
-
- seedOne = 40014 * (seedOne-k * 53668) - k * 12211;
- if (seedOne < 0) {
- seedOne += 2147483563;
- }
-
- k = seedTwo % 52774;
- seedTwo = 40692 * (seedTwo - k * 52774) - k * 3791;
- if (seedTwo < 0) {
- seedTwo += 2147483399;
- }
-
- _G_int32_t z = seedOne - seedTwo;
- if (z < 1) {
- z += 2147483562;
- }
- return( (unsigned long) z);
-}
-
diff --git a/gnu/lib/libg++/libg++/NegExp.cc b/gnu/lib/libg++/libg++/NegExp.cc
deleted file mode 100644
index 8bd6d05..0000000
--- a/gnu/lib/libg++/libg++/NegExp.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <NegExp.h>
-
-double NegativeExpntl::operator()()
-{
- return(-pMean * log(pGenerator -> asDouble()));
-}
-
diff --git a/gnu/lib/libg++/libg++/Normal.cc b/gnu/lib/libg++/libg++/Normal.cc
deleted file mode 100644
index bae43e1..0000000
--- a/gnu/lib/libg++/libg++/Normal.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <Normal.h>
-//
-// See Simulation, Modelling & Analysis by Law & Kelton, pp259
-//
-// This is the ``polar'' method.
-//
-
-double Normal::operator()()
-{
-
- if (haveCachedNormal == 1) {
- haveCachedNormal = 0;
- return(cachedNormal * pStdDev + pMean );
- } else {
-
- for(;;) {
- double u1 = pGenerator -> asDouble();
- double u2 = pGenerator -> asDouble();
- double v1 = 2 * u1 - 1;
- double v2 = 2 * u2 - 1;
- double w = (v1 * v1) + (v2 * v2);
-
-//
-// We actually generate two IID normal distribution variables.
-// We cache the one & return the other.
-//
- if (w <= 1) {
- double y = sqrt( (-2 * log(w)) / w);
- double x1 = v1 * y;
- double x2 = v2 * y;
-
- haveCachedNormal = 1;
- cachedNormal = x2;
- return(x1 * pStdDev + pMean);
- }
- }
- }
-}
-
diff --git a/gnu/lib/libg++/libg++/Obstack.cc b/gnu/lib/libg++/libg++/Obstack.cc
deleted file mode 100644
index d661df0..0000000
--- a/gnu/lib/libg++/libg++/Obstack.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <limits.h>
-#include <builtin.h>
-#include <Obstack.h>
-
-/* We use subtraction of (char *)0 instead of casting to int
- because on word-addressable machines a simple cast to int
- may ignore the byte-within-word field of the pointer. */
-
-#ifndef __PTR_TO_INT
-#define __PTR_TO_INT(P) ((P) - (char *)0)
-#endif
-
-#ifndef __INT_TO_PTR
-#define __INT_TO_PTR(P) ((P) + (char *)0)
-#endif
-
-Obstack::Obstack(int size, int alignment)
-{
- alignmentmask = alignment - 1;
- chunksize = size;
- chunk = 0;
- nextfree = objectbase = 0;
- chunklimit = 0;
-}
-
-void Obstack::_free(void* obj)
-{
- _obstack_chunk* lp;
- _obstack_chunk* plp;
-
- lp = chunk;
- while (lp != 0 && ((void*)lp > obj || (void*)(lp)->limit < obj))
- {
- plp = lp -> prev;
- delete [] (char*)lp;
- lp = plp;
- }
- if (lp)
- {
- objectbase = nextfree = (char *)(obj);
- chunklimit = lp->limit;
- chunk = lp;
- }
- else if (obj != 0)
- (*lib_error_handler)("Obstack", "deletion of nonexistent obj");
-}
-
-void Obstack::newchunk(int size)
-{
- _obstack_chunk* old_chunk = chunk;
- _obstack_chunk* new_chunk;
- long new_size;
- int obj_size = nextfree - objectbase;
-
- new_size = (obj_size + size) << 1;
- if (new_size < chunksize)
- new_size = chunksize;
-
- new_chunk = chunk = (_obstack_chunk*)(new char[new_size]);
- new_chunk->prev = old_chunk;
- new_chunk->limit = chunklimit = (char *) new_chunk + new_size;
-
- memcpy((void*)new_chunk->contents, (void*)objectbase, obj_size);
- objectbase = new_chunk->contents;
- nextfree = objectbase + obj_size;
-}
-
-void* Obstack::finish()
-{
- void* value = (void*) objectbase;
- nextfree = __INT_TO_PTR (__PTR_TO_INT (nextfree + alignmentmask)
- & ~alignmentmask);
- if (nextfree - (char*)chunk > chunklimit - (char*)chunk)
- nextfree = chunklimit;
- objectbase = nextfree;
- return value;
-}
-
-int Obstack::contains(void* obj) // true if obj somewhere in Obstack
-{
- for (_obstack_chunk* ch = chunk;
- ch != 0 && (obj < (void*)ch || obj >= (void*)(ch->limit));
- ch = ch->prev);
-
- return ch != 0;
-}
-
-int Obstack::OK()
-{
- int v = chunksize > 0; // valid size
- v &= alignmentmask != 0; // and alignment
- v &= chunk != 0;
- v &= objectbase >= chunk->contents;
- v &= nextfree >= objectbase;
- v &= nextfree <= chunklimit;
- v &= chunklimit == chunk->limit;
- _obstack_chunk* p = chunk;
- // allow lots of chances to find bottom!
- long x = LONG_MAX;
- while (p != 0 && x != 0) { --x; p = p->prev; }
- v &= x > 0;
- if (!v)
- (*lib_error_handler)("Obstack", "invariant failure");
- return v;
-}
diff --git a/gnu/lib/libg++/libg++/Poisson.cc b/gnu/lib/libg++/libg++/Poisson.cc
deleted file mode 100644
index 8d70f17..0000000
--- a/gnu/lib/libg++/libg++/Poisson.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <Poisson.h>
-
-double Poisson::operator()()
-{
- double bound = exp(-1.0 * pMean);
- int count = 0;
-
- for (double product = 1.0;
- product >= bound;
- product *= pGenerator -> asDouble()) {
- count++;
- }
- return(count - 1);
-}
diff --git a/gnu/lib/libg++/libg++/RNG.cc b/gnu/lib/libg++/libg++/RNG.cc
deleted file mode 100644
index 02b7cdf..0000000
--- a/gnu/lib/libg++/libg++/RNG.cc
+++ /dev/null
@@ -1,131 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1989 Free Software Foundation
-
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <assert.h>
-#include <builtin.h>
-#include <RNG.h>
-
-// These two static fields get initialized by RNG::RNG().
-PrivateRNGSingleType RNG::singleMantissa;
-PrivateRNGDoubleType RNG::doubleMantissa;
-
-//
-// The scale constant is 2^-31. It is used to scale a 31 bit
-// long to a double.
-//
-
-//static const double randomDoubleScaleConstant = 4.656612873077392578125e-10;
-//static const float randomFloatScaleConstant = 4.656612873077392578125e-10;
-
-static char initialized = 0;
-
-RNG::RNG()
-{
- if (!initialized)
- {
-
- assert (sizeof(double) == 2 * sizeof(_G_uint32_t));
-
- //
- // The following is a hack that I attribute to
- // Andres Nowatzyk at CMU. The intent of the loop
- // is to form the smallest number 0 <= x < 1.0,
- // which is then used as a mask for two longwords.
- // this gives us a fast way way to produce double
- // precision numbers from longwords.
- //
- // I know that this works for IEEE and VAX floating
- // point representations.
- //
- // A further complication is that gnu C will blow
- // the following loop, unless compiled with -ffloat-store,
- // because it uses extended representations for some of
- // of the comparisons. Thus, we have the following hack.
- // If we could specify #pragma optimize, we wouldn't need this.
- //
-
- PrivateRNGDoubleType t;
- PrivateRNGSingleType s;
-
-#if _IEEE == 1
-
- t.d = 1.5;
- if ( t.u[1] == 0 ) { // sun word order?
- t.u[0] = 0x3fffffff;
- t.u[1] = 0xffffffff;
- }
- else {
- t.u[0] = 0xffffffff; // encore word order?
- t.u[1] = 0x3fffffff;
- }
-
- s.u = 0x3fffffff;
-#else
- volatile double x = 1.0; // volatile needed when fp hardware used,
- // and has greater precision than memory doubles
- double y = 0.5;
- do { // find largest fp-number < 2.0
- t.d = x;
- x += y;
- y *= 0.5;
- } while (x != t.d && x < 2.0);
-
- volatile float xx = 1.0; // volatile needed when fp hardware used,
- // and has greater precision than memory floats
- float yy = 0.5;
- do { // find largest fp-number < 2.0
- s.s = xx;
- xx += yy;
- yy *= 0.5;
- } while (xx != s.s && xx < 2.0);
-#endif
- // set doubleMantissa to 1 for each doubleMantissa bit
- doubleMantissa.d = 1.0;
- doubleMantissa.u[0] ^= t.u[0];
- doubleMantissa.u[1] ^= t.u[1];
-
- // set singleMantissa to 1 for each singleMantissa bit
- singleMantissa.s = 1.0;
- singleMantissa.u ^= s.u;
-
- initialized = 1;
- }
-}
-
-float RNG::asFloat()
-{
- PrivateRNGSingleType result;
- result.s = 1.0;
- result.u |= (asLong() & singleMantissa.u);
- result.s -= 1.0;
- assert( result.s < 1.0 && result.s >= 0);
- return( result.s );
-}
-
-double RNG::asDouble()
-{
- PrivateRNGDoubleType result;
- result.d = 1.0;
- result.u[0] |= (asLong() & doubleMantissa.u[0]);
- result.u[1] |= (asLong() & doubleMantissa.u[1]);
- result.d -= 1.0;
- assert( result.d < 1.0 && result.d >= 0);
- return( result.d );
-}
-
diff --git a/gnu/lib/libg++/libg++/Random.cc b/gnu/lib/libg++/libg++/Random.cc
deleted file mode 100644
index 572a602..0000000
--- a/gnu/lib/libg++/libg++/Random.cc
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <Random.h>
diff --git a/gnu/lib/libg++/libg++/Rational.cc b/gnu/lib/libg++/libg++/Rational.cc
deleted file mode 100644
index 3c00b56..0000000
--- a/gnu/lib/libg++/libg++/Rational.cc
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
-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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <Rational.h>
-#include <std.h>
-#include <math.h>
-#include <builtin.h>
-#include <float.h>
-
-void Rational::error(const char* msg) const
-{
- (*lib_error_handler)("Rational", msg);
-}
-
-static const Integer _Int_One(1);
-
-void Rational::normalize()
-{
- int s = sign(den);
- if (s == 0)
- error("Zero denominator.");
- else if (s < 0)
- {
- den.negate();
- num.negate();
- }
-
- Integer g = gcd(num, den);
- if (ucompare(g, _Int_One) != 0)
- {
- num /= g;
- den /= g;
- }
-}
-
-void add(const Rational& x, const Rational& y, Rational& r)
-{
- if (&r != &x && &r != &y)
- {
- mul(x.num, y.den, r.num);
- mul(x.den, y.num, r.den);
- add(r.num, r.den, r.num);
- mul(x.den, y.den, r.den);
- }
- else
- {
- Integer tmp;
- mul(x.den, y.num, tmp);
- mul(x.num, y.den, r.num);
- add(r.num, tmp, r.num);
- mul(x.den, y.den, r.den);
- }
- r.normalize();
-}
-
-void sub(const Rational& x, const Rational& y, Rational& r)
-{
- if (&r != &x && &r != &y)
- {
- mul(x.num, y.den, r.num);
- mul(x.den, y.num, r.den);
- sub(r.num, r.den, r.num);
- mul(x.den, y.den, r.den);
- }
- else
- {
- Integer tmp;
- mul(x.den, y.num, tmp);
- mul(x.num, y.den, r.num);
- sub(r.num, tmp, r.num);
- mul(x.den, y.den, r.den);
- }
- r.normalize();
-}
-
-void mul(const Rational& x, const Rational& y, Rational& r)
-{
- mul(x.num, y.num, r.num);
- mul(x.den, y.den, r.den);
- r.normalize();
-}
-
-void div(const Rational& x, const Rational& y, Rational& r)
-{
- if (&r != &x && &r != &y)
- {
- mul(x.num, y.den, r.num);
- mul(x.den, y.num, r.den);
- }
- else
- {
- Integer tmp;
- mul(x.num, y.den, tmp);
- mul(y.num, x.den, r.den);
- r.num = tmp;
- }
- r.normalize();
-}
-
-
-
-
-void Rational::invert()
-{
- Integer tmp = num;
- num = den;
- den = tmp;
- int s = sign(den);
- if (s == 0)
- error("Zero denominator.");
- else if (s < 0)
- {
- den.negate();
- num.negate();
- }
-}
-
-int compare(const Rational& x, const Rational& y)
-{
- int xsgn = sign(x.num);
- int ysgn = sign(y.num);
- int d = xsgn - ysgn;
- if (d == 0 && xsgn != 0) d = compare(x.num * y.den, x.den * y.num);
- return d;
-}
-
-Rational::Rational(double x)
-{
- num = 0;
- den = 1;
- if (x != 0.0)
- {
- int neg = x < 0;
- if (neg)
- x = -x;
-
- const long shift = 15; // a safe shift per step
- const double width = 32768.0; // = 2^shift
- const int maxiter = 20; // ought not be necessary, but just in case,
- // max 300 bits of precision
- int expt;
- double mantissa = frexp(x, &expt);
- long exponent = expt;
- double intpart;
- int k = 0;
- while (mantissa != 0.0 && k++ < maxiter)
- {
- mantissa *= width;
- mantissa = modf(mantissa, &intpart);
- num <<= shift;
- num += (long)intpart;
- exponent -= shift;
- }
- if (exponent > 0)
- num <<= exponent;
- else if (exponent < 0)
- den <<= -exponent;
- if (neg)
- num.negate();
- }
- normalize();
-}
-
-
-Integer trunc(const Rational& x)
-{
- return x.num / x.den ;
-}
-
-
-Rational pow(const Rational& x, const Integer& y)
-{
- long yy = y.as_long();
- return pow(x, yy);
-}
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-
-Rational operator - (const Rational& x) return r(x)
-{
- r.negate();
-}
-
-Rational abs(const Rational& x) return r(x)
-{
- if (sign(r.num) < 0) r.negate();
-}
-
-
-Rational sqr(const Rational& x) return r
-{
- mul(x.num, x.num, r.num);
- mul(x.den, x.den, r.den);
- r.normalize();
-}
-
-Integer floor(const Rational& x) return q
-{
- Integer r;
- divide(x.num, x.den, q, r);
- if (sign(x.num) < 0 && sign(r) != 0) --q;
-}
-
-Integer ceil(const Rational& x) return q
-{
- Integer r;
- divide(x.num, x.den, q, r);
- if (sign(x.num) >= 0 && sign(r) != 0) ++q;
-}
-
-Integer round(const Rational& x) return q
-{
- Integer r;
- divide(x.num, x.den, q, r);
- r <<= 1;
- if (ucompare(r, x.den) >= 0)
- {
- if (sign(x.num) >= 0)
- ++q;
- else
- --q;
- }
-}
-
-// power: no need to normalize since num & den already relatively prime
-
-Rational pow(const Rational& x, long y) return r
-{
- if (y >= 0)
- {
- pow(x.num, y, r.num);
- pow(x.den, y, r.den);
- }
- else
- {
- y = -y;
- pow(x.num, y, r.den);
- pow(x.den, y, r.num);
- if (sign(r.den) < 0)
- {
- r.num.negate();
- r.den.negate();
- }
- }
-}
-
-#else
-
-Rational operator - (const Rational& x)
-{
- Rational r(x); r.negate(); return r;
-}
-
-Rational abs(const Rational& x)
-{
- Rational r(x);
- if (sign(r.num) < 0) r.negate();
- return r;
-}
-
-
-Rational sqr(const Rational& x)
-{
- Rational r;
- mul(x.num, x.num, r.num);
- mul(x.den, x.den, r.den);
- r.normalize();
- return r;
-}
-
-Integer floor(const Rational& x)
-{
- Integer q;
- Integer r;
- divide(x.num, x.den, q, r);
- if (sign(x.num) < 0 && sign(r) != 0) --q;
- return q;
-}
-
-Integer ceil(const Rational& x)
-{
- Integer q;
- Integer r;
- divide(x.num, x.den, q, r);
- if (sign(x.num) >= 0 && sign(r) != 0) ++q;
- return q;
-}
-
-Integer round(const Rational& x)
-{
- Integer q;
- Integer r;
- divide(x.num, x.den, q, r);
- r <<= 1;
- if (ucompare(r, x.den) >= 0)
- {
- if (sign(x.num) >= 0)
- ++q;
- else
- --q;
- }
- return q;
-}
-
-Rational pow(const Rational& x, long y)
-{
- Rational r;
- if (y >= 0)
- {
- pow(x.num, y, r.num);
- pow(x.den, y, r.den);
- }
- else
- {
- y = -y;
- pow(x.num, y, r.den);
- pow(x.den, y, r.num);
- if (sign(r.den) < 0)
- {
- r.num.negate();
- r.den.negate();
- }
- }
- return r;
-}
-
-#endif
-
-ostream& operator << (ostream& s, const Rational& y)
-{
- if (y.denominator() == 1L)
- s << y.numerator();
- else
- {
- s << y.numerator();
- s << "/";
- s << y.denominator();
- }
- return s;
-}
-
-istream& operator >> (istream& s, Rational& y)
-{
-#ifdef _OLD_STREAMS
- if (!s.good())
- {
- return s;
- }
-#else
- if (!s.ipfx(0))
- {
- s.clear(ios::failbit|s.rdstate()); // Redundant if using GNU iostreams.
- return s;
- }
-#endif
- Integer n = 0;
- Integer d = 1;
- if (s >> n)
- {
- char ch = 0;
- s.get(ch);
- if (ch == '/')
- {
- s >> d;
- }
- else
- {
- s.putback(ch);
- }
- }
- y = Rational(n, d);
- return s;
-}
-
-int Rational::OK() const
-{
- int v = num.OK() && den.OK(); // have valid num and denom
- if (v)
- {
- v &= sign(den) > 0; // denominator positive;
- v &= ucompare(gcd(num, den), _Int_One) == 0; // relatively prime
- }
- if (!v) error("invariant failure");
- return v;
-}
-
-int
-Rational::fits_in_float() const
-{
- return Rational (FLT_MIN) <= *this && *this <= Rational (FLT_MAX);
-}
-
-int
-Rational::fits_in_double() const
-{
- return Rational (DBL_MIN) <= *this && *this <= Rational (DBL_MAX);
-}
diff --git a/gnu/lib/libg++/libg++/Regex.cc b/gnu/lib/libg++/libg++/Regex.cc
deleted file mode 100644
index 65f03a0..0000000
--- a/gnu/lib/libg++/libg++/Regex.cc
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-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.
-*/
-
-/*
- Regex class implementation
- */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <std.h>
-#include <ctype.h>
-#include <new.h>
-#include <builtin.h>
-
-extern "C" {
-#if 1
-#include <rx.h>
-#else
-#include <gnuregex.h>
-#endif
-}
-
-#include <Regex.h>
-
-Regex::~Regex()
-{
- if (buf) {
- if (buf->buffer) free(buf->buffer);
- if (buf->fastmap) free(buf->fastmap);
- delete(buf);
- }
- if (reg)
- delete(reg);
-}
-
-Regex::Regex(const char* t, int fast, int bufsize,
- const char* transtable)
-{
- int tlen = (t == 0)? 0 : strlen(t);
- buf = new re_pattern_buffer;
- memset (buf, 0, sizeof(re_pattern_buffer));
- reg = new re_registers;
- if (fast)
- buf->fastmap = (char*)malloc(256);
- else
- buf->fastmap = 0;
- buf->translate = (unsigned char*)transtable;
- if (tlen > bufsize)
- bufsize = tlen;
- buf->allocated = bufsize;
- buf->buffer = (char *)malloc(buf->allocated);
- const char* msg = re_compile_pattern((const char*)t, tlen, buf);
- if (msg != 0)
- (*lib_error_handler)("Regex", msg);
- else if (fast)
- re_compile_fastmap(buf);
-}
-
-int Regex::match_info(int& start, int& length, int nth) const
-{
- if ((unsigned)(nth) >= RE_NREGS)
- return 0;
- else
- {
- start = reg->start[nth];
- length = reg->end[nth] - start;
- return start >= 0 && length >= 0;
- }
-}
-
-int Regex::search(const char* s, int len, int& matchlen, int startpos) const
-{
- int matchpos, pos, range;
- if (startpos >= 0)
- {
- pos = startpos;
- range = len - startpos;
- }
- else
- {
- pos = len + startpos;
- range = -pos;
- }
- matchpos = re_search_2(buf, 0, 0, (char*)s, len, pos, range, reg, len);
- if (matchpos >= 0)
- matchlen = reg->end[0] - reg->start[0];
- else
- matchlen = 0;
- return matchpos;
-}
-
-int Regex::match(const char*s, int len, int p) const
-{
- if (p < 0)
- {
- p += len;
- if (p > len)
- return -1;
- return re_match_2(buf, 0, 0, (char*)s, p, 0, reg, p);
- }
- else if (p > len)
- return -1;
- else
- return re_match_2(buf, 0, 0, (char*)s, len, p, reg, len);
-}
-
-int Regex::OK() const
-{
-// can't verify much, since we've lost the original string
- int v = buf != 0; // have a regex buf
- v &= buf->buffer != 0; // with a pat
- if (!v) (*lib_error_handler)("Regex", "invariant failure");
- return v;
-}
-
-/*
- some built-in Regular expressions
-*/
-
-const Regex RXwhite("[ \n\t\r\v\f]+", 1);
-const Regex RXint("-?[0-9]+", 1);
-const Regex RXdouble("-?\\(\\([0-9]+\\.[0-9]*\\)\\|\\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)\\([eE][---+]?[0-9]+\\)?", 1, 200);
-const Regex RXalpha("[A-Za-z]+", 1);
-const Regex RXlowercase("[a-z]+", 1);
-const Regex RXuppercase("[A-Z]+", 1);
-const Regex RXalphanum("[0-9A-Za-z]+", 1);
-const Regex RXidentifier("[A-Za-z_][A-Za-z0-9_]*", 1);
-
diff --git a/gnu/lib/libg++/libg++/RndInt.cc b/gnu/lib/libg++/libg++/RndInt.cc
deleted file mode 100644
index c09f1e5..0000000
--- a/gnu/lib/libg++/libg++/RndInt.cc
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <RndInt.h>
diff --git a/gnu/lib/libg++/libg++/SLList.cc b/gnu/lib/libg++/libg++/SLList.cc
deleted file mode 100644
index 7c19b3c..0000000
--- a/gnu/lib/libg++/libg++/SLList.cc
+++ /dev/null
@@ -1,247 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988, 1992 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _G_NO_TEMPLATES
-#ifdef __GNUG__
-//#pragma implementation
-#endif
-#include <limits.h>
-#include <stream.h>
-#include <builtin.h>
-#include "SLList.h"
-
-void BaseSLList::error(const char* msg) const
-{
- (*lib_error_handler)("SLList", msg);
-}
-
-int BaseSLList::length() const
-{
- int l = 0;
- BaseSLNode* t = last;
- if (t != 0) do { ++l; t = t->tl; } while (t != last);
- return l;
-}
-
-void BaseSLList::clear()
-{
- if (last == 0)
- return;
-
- BaseSLNode* p = last->tl;
- last->tl = 0;
- last = 0;
-
- while (p != 0)
- {
- BaseSLNode* nxt = p->tl;
- delete_node(p);
- p = nxt;
- }
-}
-
-
-// Note: This is an internal method. It does *not* free old contents!
-
-void BaseSLList::copy(const BaseSLList& a)
-{
- if (a.last == 0)
- last = 0;
- else
- {
- BaseSLNode* p = a.last->tl;
- BaseSLNode* h = copy_node(p->item());
- last = h;
- for (;;)
- {
- if (p == a.last)
- {
- last->tl = h;
- return;
- }
- p = p->tl;
- BaseSLNode* n = copy_node(p->item());
- last->tl = n;
- last = n;
- }
- }
-}
-
-BaseSLList& BaseSLList::operator = (const BaseSLList& a)
-{
- if (last != a.last)
- {
- clear();
- copy(a);
- }
- return *this;
-}
-
-Pix BaseSLList::prepend(const void *datum)
-{
- return prepend(copy_node(datum));
-}
-
-
-Pix BaseSLList::prepend(BaseSLNode* t)
-{
- if (t == 0) return 0;
- if (last == 0)
- t->tl = last = t;
- else
- {
- t->tl = last->tl;
- last->tl = t;
- }
- return Pix(t);
-}
-
-
-Pix BaseSLList::append(const void *datum)
-{
- return append(copy_node(datum));
-}
-
-Pix BaseSLList::append(BaseSLNode* t)
-{
- if (t == 0) return 0;
- if (last == 0)
- t->tl = last = t;
- else
- {
- t->tl = last->tl;
- last->tl = t;
- last = t;
- }
- return Pix(t);
-}
-
-void BaseSLList::join(BaseSLList& b)
-{
- BaseSLNode* t = b.last;
- b.last = 0;
- if (last == 0)
- last = t;
- else if (t != 0)
- {
- BaseSLNode* f = last->tl;
- last->tl = t->tl;
- t->tl = f;
- last = t;
- }
-}
-
-Pix BaseSLList::ins_after(Pix p, const void *datum)
-{
- BaseSLNode* u = (BaseSLNode*)p;
- BaseSLNode* t = copy_node(datum);
- if (last == 0)
- t->tl = last = t;
- else if (u == 0) // ins_after 0 means prepend
- {
- t->tl = last->tl;
- last->tl = t;
- }
- else
- {
- t->tl = u->tl;
- u->tl = t;
- if (u == last)
- last = t;
- }
- return Pix(t);
-}
-
-void BaseSLList::del_after(Pix p)
-{
- BaseSLNode* u = (BaseSLNode*)p;
- if (last == 0 || u == last) error("cannot del_after last");
- if (u == 0) u = last; // del_after 0 means delete first
- BaseSLNode* t = u->tl;
- if (u == t)
- last = 0;
- else
- {
- u->tl = t->tl;
- if (last == t)
- last = u;
- }
- delete_node(t);
-}
-
-int BaseSLList::owns(Pix p) const
-{
- BaseSLNode* t = last;
- if (t != 0 && p != 0)
- {
- do
- {
- if (Pix(t) == p) return 1;
- t = t->tl;
- } while (t != last);
- }
- return 0;
-}
-
-int BaseSLList::remove_front(void *dst, int signal_error)
-{
- if (last)
- {
- BaseSLNode* t = last->tl;
- copy_item(dst, t->item());
- if (t == last)
- last = 0;
- else
- last->tl = t->tl;
- delete_node(t);
- return 1;
- }
- if (signal_error)
- error("remove_front of empty list");
- return 0;
-}
-
-void BaseSLList::del_front()
-{
- if (last == 0) error("del_front of empty list");
- BaseSLNode* t = last->tl;
- if (t == last)
- last = 0;
- else
- last->tl = t->tl;
- delete_node(t);
-}
-
-int BaseSLList::OK() const
-{
- int v = 1;
- if (last != 0)
- {
- BaseSLNode* t = last;
- long count = LONG_MAX; // Lots of chances to find last!
- do
- {
- count--;
- t = t->tl;
- } while (count > 0 && t != last);
- v &= count > 0;
- }
- if (!v) error("invariant failure");
- return v;
-}
-#endif /*!_G_NO_TEMPLATES*/
diff --git a/gnu/lib/libg++/libg++/SmplHist.cc b/gnu/lib/libg++/libg++/SmplHist.cc
deleted file mode 100644
index a1fcd15..0000000
--- a/gnu/lib/libg++/libg++/SmplHist.cc
+++ /dev/null
@@ -1,112 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <stream.h>
-#include <SmplHist.h>
-#include <math.h>
-
-#ifndef HUGE_VAL
-#ifdef HUGE
-#define HUGE_VAL HUGE
-#else
-#include <float.h>
-#define HUGE_VAL DBL_MAX
-#endif
-#endif
-
-const int SampleHistogramMinimum = -2;
-const int SampleHistogramMaximum = -1;
-
-SampleHistogram::SampleHistogram(double low, double high, double width)
-{
- if (high < low) {
- double t = high;
- high = low;
- low = t;
- }
-
- if (width == -1) {
- width = (high - low) / 10;
- }
-
- howManyBuckets = int((high - low) / width) + 2;
- bucketCount = new int[howManyBuckets];
- bucketLimit = new double[howManyBuckets];
- double lim = low;
- for (int i = 0; i < howManyBuckets; i++) {
- bucketCount[i] = 0;
- bucketLimit[i] = lim;
- lim += width;
- }
- bucketLimit[howManyBuckets-1] = HUGE_VAL; /* from math.h */
-}
-
-SampleHistogram::~SampleHistogram()
-{
- if (howManyBuckets > 0) {
- delete bucketCount;
- delete bucketLimit;
- }
-}
-
-void
-SampleHistogram::operator+=(double value)
-{
- int i;
- for (i = 0; i < howManyBuckets; i++) {
- if (value < bucketLimit[i]) break;
- }
- bucketCount[i]++;
- this->SampleStatistic::operator+=(value);
-}
-
-int
-SampleHistogram::similarSamples(double d)
-{
- int i;
- for (i = 0; i < howManyBuckets; i++) {
- if (d < bucketLimit[i]) return(bucketCount[i]);
- }
- return(0);
-}
-
-void
-SampleHistogram::printBuckets(ostream& s)
-{
- for(int i = 0; i < howManyBuckets; i++) {
- if (bucketLimit[i] >= HUGE_VAL) {
- s << "< max : " << bucketCount[i] << "\n";
- } else {
- s << "< " << bucketLimit[i] << " : " << bucketCount[i] << "\n";
- }
- }
-}
-
-void
-SampleHistogram::reset()
-{
- this->SampleStatistic::reset();
- if (howManyBuckets > 0) {
- for (register int i = 0; i < howManyBuckets; i++) {
- bucketCount[i] = 0;
- }
- }
-}
-
diff --git a/gnu/lib/libg++/libg++/SmplStat.cc b/gnu/lib/libg++/libg++/SmplStat.cc
deleted file mode 100644
index 461bea4..0000000
--- a/gnu/lib/libg++/libg++/SmplStat.cc
+++ /dev/null
@@ -1,160 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988 Free Software Foundation
- written by Dirk Grunwald (grunwald@cs.uiuc.edu)
-
-This file is part of the GNU C++ Library. This library is free
-software; you can redistribute it and/or modify it under the terms of
-the GNU Library General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your
-option) any later version. This library is distributed in the hope
-that it will be useful, but WITHOUT ANY WARRANTY; without even the
-implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-PURPOSE. See the GNU Library General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with this library; if not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <stream.h>
-#include <SmplStat.h>
-#include <math.h>
-
-#ifndef HUGE_VAL
-#ifdef HUGE
-#define HUGE_VAL HUGE
-#else
-#include <float.h>
-#define HUGE_VAL DBL_MAX
-#endif
-#endif
-
-// error handling
-
-void default_SampleStatistic_error_handler(const char* msg)
-{
- cerr << "Fatal SampleStatistic error. " << msg << "\n";
- exit(1);
-}
-
-one_arg_error_handler_t SampleStatistic_error_handler = default_SampleStatistic_error_handler;
-
-one_arg_error_handler_t set_SampleStatistic_error_handler(one_arg_error_handler_t f)
-{
- one_arg_error_handler_t old = SampleStatistic_error_handler;
- SampleStatistic_error_handler = f;
- return old;
-}
-
-void SampleStatistic::error(const char* msg)
-{
- (*SampleStatistic_error_handler)(msg);
-}
-
-// t-distribution: given p-value and degrees of freedom, return t-value
-// adapted from Peizer & Pratt JASA, vol63, p1416
-
-double tval(double p, int df)
-{
- double t;
- int positive = p >= 0.5;
- p = (positive)? 1.0 - p : p;
- if (p <= 0.0 || df <= 0)
- t = HUGE_VAL;
- else if (p == 0.5)
- t = 0.0;
- else if (df == 1)
- t = 1.0 / tan((p + p) * 1.57079633);
- else if (df == 2)
- t = sqrt(1.0 / ((p + p) * (1.0 - p)) - 2.0);
- else
- {
- double ddf = df;
- double a = sqrt(log(1.0 / (p * p)));
- double aa = a * a;
- a = a - ((2.515517 + (0.802853 * a) + (0.010328 * aa)) /
- (1.0 + (1.432788 * a) + (0.189269 * aa) +
- (0.001308 * aa * a)));
- t = ddf - 0.666666667 + 1.0 / (10.0 * ddf);
- t = sqrt(ddf * (exp(a * a * (ddf - 0.833333333) / (t * t)) - 1.0));
- }
- return (positive)? t : -t;
-}
-
-void
-SampleStatistic::reset()
-{
- n = 0; x = x2 = 0.0;
- maxValue = -HUGE_VAL;
- minValue = HUGE_VAL;
-}
-
-void
-SampleStatistic::operator+=(double value)
-{
- n += 1;
- x += value;
- x2 += (value * value);
- if ( minValue > value) minValue = value;
- if ( maxValue < value) maxValue = value;
-}
-
-double
-SampleStatistic::mean()
-{
- if ( n > 0) {
- return (x / n);
- }
- else {
- return ( 0.0 );
- }
-}
-
-double
-SampleStatistic::var()
-{
- if ( n > 1) {
- return(( x2 - ((x * x) / n)) / ( n - 1));
- }
- else {
- return ( 0.0 );
- }
-}
-
-double
-SampleStatistic::stdDev()
-{
- if ( n <= 0 || this -> var() <= 0) {
- return(0);
- } else {
- return( (double) sqrt( var() ) );
- }
-}
-
-double
-SampleStatistic::confidence(int interval)
-{
- int df = n - 1;
- if (df <= 0) return HUGE_VAL;
- double t = tval(double(100 + interval) * 0.005, df);
- if (t == HUGE_VAL)
- return t;
- else
- return (t * stdDev()) / sqrt(double(n));
-}
-
-double
-SampleStatistic::confidence(double p_value)
-{
- int df = n - 1;
- if (df <= 0) return HUGE_VAL;
- double t = tval((1.0 + p_value) * 0.5, df);
- if (t == HUGE_VAL)
- return t;
- else
- return (t * stdDev()) / sqrt(double(n));
-}
-
-
diff --git a/gnu/lib/libg++/libg++/String.cc b/gnu/lib/libg++/libg++/String.cc
deleted file mode 100644
index cb2c524..0000000
--- a/gnu/lib/libg++/libg++/String.cc
+++ /dev/null
@@ -1,1300 +0,0 @@
-/*
-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.
-*/
-
-/*
- String class implementation
- */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <String.h>
-#include <std.h>
-#include <ctype.h>
-#include <limits.h>
-#include <new.h>
-#include <builtin.h>
-
-void String::error(const char* msg) const
-{
- (*lib_error_handler)("String", msg);
-}
-
-String::operator const char*() const
-{
- return (const char*)chars();
-}
-
-// globals
-
-StrRep _nilStrRep = { 0, 1, { 0 } }; // nil strings point here
-String _nilString; // nil SubStrings point here
-
-
-
-
-/*
- the following inline fcts are specially designed to work
- in support of String classes, and are not meant as generic replacements
- for libc "str" functions.
-
- inline copy fcts - I like left-to-right from->to arguments.
- all versions assume that `to' argument is non-null
-
- These are worth doing inline, rather than through calls because,
- via procedural integration, adjacent copy calls can be smushed
- together by the optimizer.
-*/
-
-// copy n bytes
-inline static void ncopy(const char* from, char* to, int n)
-{
- if (from != to) while (--n >= 0) *to++ = *from++;
-}
-
-// copy n bytes, null-terminate
-inline static void ncopy0(const char* from, char* to, int n)
-{
- if (from != to)
- {
- while (--n >= 0) *to++ = *from++;
- *to = 0;
- }
- else
- to[n] = 0;
-}
-
-// copy until null
-inline static void scopy(const char* from, char* to)
-{
- if (from != 0) while((*to++ = *from++) != 0);
-}
-
-// copy right-to-left
-inline static void revcopy(const char* from, char* to, short n)
-{
- if (from != 0) while (--n >= 0) *to-- = *from--;
-}
-
-
-inline static int slen(const char* t) // inline strlen
-{
- if (t == 0)
- return 0;
- else
- {
- const char* a = t;
- while (*a++ != 0);
- return a - 1 - t;
- }
-}
-
-// minimum & maximum representable rep size
-
-#define MAXStrRep_SIZE ((1 << (sizeof(short) * CHAR_BIT - 1)) - 1)
-#define MINStrRep_SIZE 16
-
-#ifndef MALLOC_MIN_OVERHEAD
-#define MALLOC_MIN_OVERHEAD 4
-#endif
-
-// The basic allocation primitive:
-// Always round request to something close to a power of two.
-// This ensures a bit of padding, which often means that
-// concatenations don't have to realloc. Plus it tends to
-// be faster when lots of Strings are created and discarded,
-// since just about any version of malloc (op new()) will
-// be faster when it can reuse identically-sized chunks
-
-inline static StrRep* Snew(int newsiz)
-{
- unsigned int siz = sizeof(StrRep) + newsiz + MALLOC_MIN_OVERHEAD;
- unsigned int allocsiz = MINStrRep_SIZE;
- while (allocsiz < siz) allocsiz <<= 1;
- allocsiz -= MALLOC_MIN_OVERHEAD;
- if (allocsiz >= MAXStrRep_SIZE)
- (*lib_error_handler)("String", "Requested length out of range");
-
- StrRep* rep = (StrRep *) new char[allocsiz];
- rep->sz = allocsiz - sizeof(StrRep);
- return rep;
-}
-
-// Do-something-while-allocating routines.
-
-// We live with two ways to signify empty Sreps: either the
-// null pointer (0) or a pointer to the nilStrRep.
-
-// We always signify unknown source lengths (usually when fed a char*)
-// via len == -1, in which case it is computed.
-
-// allocate, copying src if nonull
-
-StrRep* Salloc(StrRep* old, const char* src, int srclen, int newlen)
-{
- if (old == &_nilStrRep) old = 0;
- if (srclen < 0) srclen = slen(src);
- if (newlen < srclen) newlen = srclen;
- StrRep* rep;
- if (old == 0 || newlen > old->sz)
- rep = Snew(newlen);
- else
- rep = old;
-
- rep->len = newlen;
- ncopy0(src, rep->s, srclen);
-
- if (old != rep && old != 0) delete old;
-
- return rep;
-}
-
-// reallocate: Given the initial allocation scheme, it will
-// generally be faster in the long run to get new space & copy
-// than to call realloc
-
-static StrRep*
-Sresize(StrRep* old, int newlen)
-{
- if (old == &_nilStrRep) old = 0;
- StrRep* rep;
- if (old == 0)
- rep = Snew(newlen);
- else if (newlen > old->sz)
- {
- rep = Snew(newlen);
- ncopy0(old->s, rep->s, old->len);
- delete old;
- }
- else
- rep = old;
-
- rep->len = newlen;
-
- return rep;
-}
-
-void
-String::alloc (int newsize)
-{
- unsigned short old_len = rep->len;
- rep = Sresize(rep, newsize);
- rep->len = old_len;
-}
-
-// like allocate, but we know that src is a StrRep
-
-StrRep* Scopy(StrRep* old, const StrRep* s)
-{
- if (old == &_nilStrRep) old = 0;
- if (s == &_nilStrRep) s = 0;
- if (old == s)
- return (old == 0)? &_nilStrRep : old;
- else if (s == 0)
- {
- old->s[0] = 0;
- old->len = 0;
- return old;
- }
- else
- {
- StrRep* rep;
- int newlen = s->len;
- if (old == 0 || newlen > old->sz)
- {
- if (old != 0) delete old;
- rep = Snew(newlen);
- }
- else
- rep = old;
- rep->len = newlen;
- ncopy0(s->s, rep->s, newlen);
- return rep;
- }
-}
-
-// allocate & concatenate
-
-StrRep* Scat(StrRep* old, const char* s, int srclen, const char* t, int tlen)
-{
- if (old == &_nilStrRep) old = 0;
- if (srclen < 0) srclen = slen(s);
- if (tlen < 0) tlen = slen(t);
- int newlen = srclen + tlen;
- StrRep* rep;
-
- if (old == 0 || newlen > old->sz ||
- (t >= old->s && t < &(old->s[old->len]))) // beware of aliasing
- rep = Snew(newlen);
- else
- rep = old;
-
- rep->len = newlen;
-
- ncopy(s, rep->s, srclen);
- ncopy0(t, &(rep->s[srclen]), tlen);
-
- if (old != rep && old != 0) delete old;
-
- return rep;
-}
-
-// double-concatenate
-
-StrRep* Scat(StrRep* old, const char* s, int srclen, const char* t, int tlen,
- const char* u, int ulen)
-{
- if (old == &_nilStrRep) old = 0;
- if (srclen < 0) srclen = slen(s);
- if (tlen < 0) tlen = slen(t);
- if (ulen < 0) ulen = slen(u);
- int newlen = srclen + tlen + ulen;
- StrRep* rep;
- if (old == 0 || newlen > old->sz ||
- (t >= old->s && t < &(old->s[old->len])) ||
- (u >= old->s && u < &(old->s[old->len])))
- rep = Snew(newlen);
- else
- rep = old;
-
- rep->len = newlen;
-
- ncopy(s, rep->s, srclen);
- ncopy(t, &(rep->s[srclen]), tlen);
- ncopy0(u, &(rep->s[srclen+tlen]), ulen);
-
- if (old != rep && old != 0) delete old;
-
- return rep;
-}
-
-// like cat, but we know that new stuff goes in the front of existing rep
-
-StrRep* Sprepend(StrRep* old, const char* t, int tlen)
-{
- char* s;
- int srclen;
- if (old == &_nilStrRep || old == 0)
- {
- s = 0; old = 0; srclen = 0;
- }
- else
- {
- s = old->s; srclen = old->len;
- }
- if (tlen < 0) tlen = slen(t);
- int newlen = srclen + tlen;
- StrRep* rep;
- if (old == 0 || newlen > old->sz ||
- (t >= old->s && t < &(old->s[old->len])))
- rep = Snew(newlen);
- else
- rep = old;
-
- rep->len = newlen;
-
- revcopy(&(s[srclen]), &(rep->s[newlen]), srclen+1);
- ncopy(t, rep->s, tlen);
-
- if (old != rep && old != 0) delete old;
-
- return rep;
-}
-
-
-// string compare: first argument is known to be non-null
-
-inline static int scmp(const char* a, const char* b)
-{
- if (b == 0)
- return *a != 0;
- else
- {
- signed char diff = 0;
- while ((diff = *a - *b++) == 0 && *a++ != 0);
- return diff;
- }
-}
-
-
-inline static int ncmp(const char* a, int al, const char* b, int bl)
-{
- int n = (al <= bl)? al : bl;
- signed char diff;
- while (n-- > 0) if ((diff = *a++ - *b++) != 0) return diff;
- return al - bl;
-}
-
-int fcompare(const String& x, const String& y)
-{
- const char* a = x.chars();
- const char* b = y.chars();
- int al = x.length();
- int bl = y.length();
- int n = (al <= bl)? al : bl;
- signed char diff = 0;
- while (n-- > 0)
- {
- char ac = *a++;
- char bc = *b++;
- if ((diff = ac - bc) != 0)
- {
- if (ac >= 'a' && ac <= 'z')
- ac = ac - 'a' + 'A';
- if (bc >= 'a' && bc <= 'z')
- bc = bc - 'a' + 'A';
- if ((diff = ac - bc) != 0)
- return diff;
- }
- }
- return al - bl;
-}
-
-// these are not inline, but pull in the above inlines, so are
-// pretty fast
-
-int compare(const String& x, const char* b)
-{
- return scmp(x.chars(), b);
-}
-
-int compare(const String& x, const String& y)
-{
- return scmp(x.chars(), y.chars());
-}
-
-int compare(const String& x, const SubString& y)
-{
- return ncmp(x.chars(), x.length(), y.chars(), y.length());
-}
-
-int compare(const SubString& x, const String& y)
-{
- return ncmp(x.chars(), x.length(), y.chars(), y.length());
-}
-
-int compare(const SubString& x, const SubString& y)
-{
- return ncmp(x.chars(), x.length(), y.chars(), y.length());
-}
-
-int compare(const SubString& x, const char* b)
-{
- if (b == 0)
- return x.length();
- else
- {
- const char* a = x.chars();
- int n = x.length();
- signed char diff;
- while (n-- > 0) if ((diff = *a++ - *b++) != 0) return diff;
- return (*b == 0) ? 0 : -1;
- }
-}
-
-/*
- index fcts
-*/
-
-int String::search(int start, int sl, char c) const
-{
- const char* s = chars();
- if (sl > 0)
- {
- if (start >= 0)
- {
- const char* a = &(s[start]);
- const char* lasta = &(s[sl]);
- while (a < lasta) if (*a++ == c) return --a - s;
- }
- else
- {
- const char* a = &(s[sl + start + 1]);
- while (--a >= s) if (*a == c) return a - s;
- }
- }
- return -1;
-}
-
-int String::search(int start, int sl, const char* t, int tl) const
-{
- const char* s = chars();
- if (tl < 0) tl = slen(t);
- if (sl > 0 && tl > 0)
- {
- if (start >= 0)
- {
- const char* lasts = &(s[sl - tl]);
- const char* lastt = &(t[tl]);
- const char* p = &(s[start]);
-
- while (p <= lasts)
- {
- const char* x = p++;
- const char* y = t;
- while (*x++ == *y++) if (y >= lastt) return --p - s;
- }
- }
- else
- {
- const char* firsts = &(s[tl - 1]);
- const char* lastt = &(t[tl - 1]);
- const char* p = &(s[sl + start + 1]);
-
- while (--p >= firsts)
- {
- const char* x = p;
- const char* y = lastt;
- while (*x-- == *y--) if (y < t) return ++x - s;
- }
- }
- }
- return -1;
-}
-
-int String::match(int start, int sl, int exact, const char* t, int tl) const
-{
- if (tl < 0) tl = slen(t);
-
- if (start < 0)
- {
- start = sl + start - tl + 1;
- if (start < 0 || (exact && start != 0))
- return -1;
- }
- else if (exact && sl - start != tl)
- return -1;
-
- if (sl == 0 || tl == 0 || sl - start < tl || start >= sl)
- return -1;
-
- int n = tl;
- const char* s = &(rep->s[start]);
- while (--n >= 0) if (*s++ != *t++) return -1;
- return tl;
-}
-
-void SubString::assign(const StrRep* ysrc, const char* ys, int ylen)
-{
- if (&S == &_nilString) return;
-
- if (ylen < 0) ylen = slen(ys);
- StrRep* targ = S.rep;
- int sl = targ->len - len + ylen;
-
- if (ysrc == targ || sl >= targ->sz)
- {
- StrRep* oldtarg = targ;
- targ = Sresize(0, sl);
- ncopy(oldtarg->s, targ->s, pos);
- ncopy(ys, &(targ->s[pos]), ylen);
- scopy(&(oldtarg->s[pos + len]), &(targ->s[pos + ylen]));
- delete oldtarg;
- }
- else if (len == ylen)
- ncopy(ys, &(targ->s[pos]), len);
- else if (ylen < len)
- {
- ncopy(ys, &(targ->s[pos]), ylen);
- scopy(&(targ->s[pos + len]), &(targ->s[pos + ylen]));
- }
- else
- {
- revcopy(&(targ->s[targ->len]), &(targ->s[sl]), targ->len-pos-len +1);
- ncopy(ys, &(targ->s[pos]), ylen);
- }
- targ->len = sl;
- S.rep = targ;
-}
-
-
-
-/*
- * substitution
- */
-
-
-int String::_gsub(const char* pat, int pl, const char* r, int rl)
-{
- int nmatches = 0;
- if (pl < 0) pl = slen(pat);
- if (rl < 0) rl = slen(r);
- int sl = length();
- if (sl <= 0 || pl <= 0 || sl < pl)
- return nmatches;
-
- const char* s = chars();
-
- // prepare to make new rep
- StrRep* nrep = 0;
- int nsz = 0;
- char* x = 0;
-
- int si = 0;
- int xi = 0;
- int remaining = sl;
-
- while (remaining >= pl)
- {
- int pos = search(si, sl, pat, pl);
- if (pos < 0)
- break;
- else
- {
- ++nmatches;
- int mustfit = xi + remaining + rl - pl;
- if (mustfit >= nsz)
- {
- if (nrep != 0) nrep->len = xi;
- nrep = Sresize(nrep, mustfit);
- nsz = nrep->sz;
- x = nrep->s;
- }
- pos -= si;
- ncopy(&(s[si]), &(x[xi]), pos);
- ncopy(r, &(x[xi + pos]), rl);
- si += pos + pl;
- remaining -= pos + pl;
- xi += pos + rl;
- }
- }
-
- if (nrep == 0)
- {
- if (nmatches == 0)
- return nmatches;
- else
- nrep = Sresize(nrep, xi+remaining);
- }
-
- ncopy0(&(s[si]), &(x[xi]), remaining);
- nrep->len = xi + remaining;
-
- if (nrep->len <= rep->sz) // fit back in if possible
- {
- rep->len = nrep->len;
- ncopy0(nrep->s, rep->s, rep->len);
- delete(nrep);
- }
- else
- {
- delete(rep);
- rep = nrep;
- }
- return nmatches;
-}
-
-int String::_gsub(const Regex& pat, const char* r, int rl)
-{
- int nmatches = 0;
- int sl = length();
- if (sl <= 0)
- return nmatches;
-
- if (rl < 0) rl = slen(r);
-
- const char* s = chars();
-
- StrRep* nrep = 0;
- int nsz = 0;
-
- char* x = 0;
-
- int si = 0;
- int xi = 0;
- int remaining = sl;
- int pos, pl = 0; // how long is a regular expression?
-
- while (remaining > 0)
- {
- pos = pat.search(s, sl, pl, si); // unlike string search, the pos returned here is absolute
- if (pos < 0 || pl <= 0)
- break;
- else
- {
- ++nmatches;
- int mustfit = xi + remaining + rl - pl;
- if (mustfit >= nsz)
- {
- if (nrep != 0) nrep->len = xi;
- nrep = Sresize(nrep, mustfit);
- x = nrep->s;
- nsz = nrep->sz;
- }
- pos -= si;
- ncopy(&(s[si]), &(x[xi]), pos);
- ncopy(r, &(x[xi + pos]), rl);
- si += pos + pl;
- remaining -= pos + pl;
- xi += pos + rl;
- }
- }
-
- if (nrep == 0)
- {
- if (nmatches == 0)
- return nmatches;
- else
- nrep = Sresize(nrep, xi+remaining);
- }
-
- ncopy0(&(s[si]), &(x[xi]), remaining);
- nrep->len = xi + remaining;
-
- if (nrep->len <= rep->sz) // fit back in if possible
- {
- rep->len = nrep->len;
- ncopy0(nrep->s, rep->s, rep->len);
- delete(nrep);
- }
- else
- {
- delete(rep);
- rep = nrep;
- }
- return nmatches;
-}
-
-
-/*
- * deletion
- */
-
-void String::del(int pos, int len)
-{
- if (pos < 0 || len <= 0 || (unsigned)(pos + len) > length()) return;
- int nlen = length() - len;
- int first = pos + len;
- ncopy0(&(rep->s[first]), &(rep->s[pos]), length() - first);
- rep->len = nlen;
-}
-
-void String::del(const Regex& r, int startpos)
-{
- int mlen;
- int first = r.search(chars(), length(), mlen, startpos);
- del(first, mlen);
-}
-
-void String::del(const char* t, int startpos)
-{
- int tlen = slen(t);
- int p = search(startpos, length(), t, tlen);
- del(p, tlen);
-}
-
-void String::del(const String& y, int startpos)
-{
- del(search(startpos, length(), y.chars(), y.length()), y.length());
-}
-
-void String::del(const SubString& y, int startpos)
-{
- del(search(startpos, length(), y.chars(), y.length()), y.length());
-}
-
-void String::del(char c, int startpos)
-{
- del(search(startpos, length(), c), 1);
-}
-
-/*
- * substring extraction
- */
-
-
-SubString String::at(int first, int len)
-{
- return _substr(first, len);
-}
-
-SubString String::operator() (int first, int len)
-{
- return _substr(first, len);
-}
-
-SubString String::before(int pos)
-{
- return _substr(0, pos);
-}
-
-SubString String::through(int pos)
-{
- return _substr(0, pos+1);
-}
-
-SubString String::after(int pos)
-{
- return _substr(pos + 1, length() - (pos + 1));
-}
-
-SubString String::from(int pos)
-{
- return _substr(pos, length() - pos);
-}
-
-SubString String::at(const String& y, int startpos)
-{
- int first = search(startpos, length(), y.chars(), y.length());
- return _substr(first, y.length());
-}
-
-SubString String::at(const SubString& y, int startpos)
-{
- int first = search(startpos, length(), y.chars(), y.length());
- return _substr(first, y.length());
-}
-
-SubString String::at(const Regex& r, int startpos)
-{
- int mlen;
- int first = r.search(chars(), length(), mlen, startpos);
- return _substr(first, mlen);
-}
-
-SubString String::at(const char* t, int startpos)
-{
- int tlen = slen(t);
- int first = search(startpos, length(), t, tlen);
- return _substr(first, tlen);
-}
-
-SubString String::at(char c, int startpos)
-{
- int first = search(startpos, length(), c);
- return _substr(first, 1);
-}
-
-SubString String::before(const String& y, int startpos)
-{
- int last = search(startpos, length(), y.chars(), y.length());
- return _substr(0, last);
-}
-
-SubString String::before(const SubString& y, int startpos)
-{
- int last = search(startpos, length(), y.chars(), y.length());
- return _substr(0, last);
-}
-
-SubString String::before(const Regex& r, int startpos)
-{
- int mlen;
- int first = r.search(chars(), length(), mlen, startpos);
- return _substr(0, first);
-}
-
-SubString String::before(char c, int startpos)
-{
- int last = search(startpos, length(), c);
- return _substr(0, last);
-}
-
-SubString String::before(const char* t, int startpos)
-{
- int tlen = slen(t);
- int last = search(startpos, length(), t, tlen);
- return _substr(0, last);
-}
-
-SubString String::through(const String& y, int startpos)
-{
- int last = search(startpos, length(), y.chars(), y.length());
- if (last >= 0) last += y.length();
- return _substr(0, last);
-}
-
-SubString String::through(const SubString& y, int startpos)
-{
- int last = search(startpos, length(), y.chars(), y.length());
- if (last >= 0) last += y.length();
- return _substr(0, last);
-}
-
-SubString String::through(const Regex& r, int startpos)
-{
- int mlen;
- int first = r.search(chars(), length(), mlen, startpos);
- if (first >= 0) first += mlen;
- return _substr(0, first);
-}
-
-SubString String::through(char c, int startpos)
-{
- int last = search(startpos, length(), c);
- if (last >= 0) last += 1;
- return _substr(0, last);
-}
-
-SubString String::through(const char* t, int startpos)
-{
- int tlen = slen(t);
- int last = search(startpos, length(), t, tlen);
- if (last >= 0) last += tlen;
- return _substr(0, last);
-}
-
-SubString String::after(const String& y, int startpos)
-{
- int first = search(startpos, length(), y.chars(), y.length());
- if (first >= 0) first += y.length();
- return _substr(first, length() - first);
-}
-
-SubString String::after(const SubString& y, int startpos)
-{
- int first = search(startpos, length(), y.chars(), y.length());
- if (first >= 0) first += y.length();
- return _substr(first, length() - first);
-}
-
-SubString String::after(char c, int startpos)
-{
- int first = search(startpos, length(), c);
- if (first >= 0) first += 1;
- return _substr(first, length() - first);
-}
-
-SubString String::after(const Regex& r, int startpos)
-{
- int mlen;
- int first = r.search(chars(), length(), mlen, startpos);
- if (first >= 0) first += mlen;
- return _substr(first, length() - first);
-}
-
-SubString String::after(const char* t, int startpos)
-{
- int tlen = slen(t);
- int first = search(startpos, length(), t, tlen);
- if (first >= 0) first += tlen;
- return _substr(first, length() - first);
-}
-
-SubString String::from(const String& y, int startpos)
-{
- int first = search(startpos, length(), y.chars(), y.length());
- return _substr(first, length() - first);
-}
-
-SubString String::from(const SubString& y, int startpos)
-{
- int first = search(startpos, length(), y.chars(), y.length());
- return _substr(first, length() - first);
-}
-
-SubString String::from(const Regex& r, int startpos)
-{
- int mlen;
- int first = r.search(chars(), length(), mlen, startpos);
- return _substr(first, length() - first);
-}
-
-SubString String::from(char c, int startpos)
-{
- int first = search(startpos, length(), c);
- return _substr(first, length() - first);
-}
-
-SubString String::from(const char* t, int startpos)
-{
- int tlen = slen(t);
- int first = search(startpos, length(), t, tlen);
- return _substr(first, length() - first);
-}
-
-
-
-/*
- * split/join
- */
-
-
-int split(const String& src, String results[], int n, const String& sep)
-{
- String x = src;
- const char* s = x.chars();
- int sl = x.length();
- int i = 0;
- int pos = 0;
- while (i < n && pos < sl)
- {
- int p = x.search(pos, sl, sep.chars(), sep.length());
- if (p < 0)
- p = sl;
- results[i].rep = Salloc(results[i].rep, &(s[pos]), p - pos, p - pos);
- i++;
- pos = p + sep.length();
- }
- return i;
-}
-
-int split(const String& src, String results[], int n, const Regex& r)
-{
- String x = src;
- const char* s = x.chars();
- int sl = x.length();
- int i = 0;
- int pos = 0;
- int p, matchlen;
- while (i < n && pos < sl)
- {
- p = r.search(s, sl, matchlen, pos);
- if (p < 0)
- p = sl;
- results[i].rep = Salloc(results[i].rep, &(s[pos]), p - pos, p - pos);
- i++;
- pos = p + matchlen;
- }
- return i;
-}
-
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-#define RETURN(r) return
-#define RETURNS(r) return r;
-#define RETURN_OBJECT(TYPE, NAME) /* nothing */
-#else /* _G_NO_NRV */
-#define RETURN(r) return r
-#define RETURNS(r) /* nothing */
-#define RETURN_OBJECT(TYPE, NAME) TYPE NAME;
-#endif
-
-String join(String src[], int n, const String& separator) RETURNS(x)
-{
- RETURN_OBJECT(String,x)
- String sep = separator;
- int xlen = 0;
- for (int i = 0; i < n; ++i)
- xlen += src[i].length();
- xlen += (n - 1) * sep.length();
-
- x.rep = Sresize (x.rep, xlen);
-
- int j = 0;
-
- for (i = 0; i < n - 1; ++i)
- {
- ncopy(src[i].chars(), &(x.rep->s[j]), src[i].length());
- j += src[i].length();
- ncopy(sep.chars(), &(x.rep->s[j]), sep.length());
- j += sep.length();
- }
- ncopy0(src[i].chars(), &(x.rep->s[j]), src[i].length());
- RETURN(x);
-}
-
-/*
- misc
-*/
-
-
-StrRep* Sreverse(const StrRep* src, StrRep* dest)
-{
- int n = src->len;
- if (src != dest)
- dest = Salloc(dest, src->s, n, n);
- if (n > 0)
- {
- char* a = dest->s;
- char* b = &(a[n - 1]);
- while (a < b)
- {
- char t = *a;
- *a++ = *b;
- *b-- = t;
- }
- }
- return dest;
-}
-
-
-StrRep* Supcase(const StrRep* src, StrRep* dest)
-{
- int n = src->len;
- if (src != dest) dest = Salloc(dest, src->s, n, n);
- char* p = dest->s;
- char* e = &(p[n]);
- for (; p < e; ++p) if (islower(*p)) *p = toupper(*p);
- return dest;
-}
-
-StrRep* Sdowncase(const StrRep* src, StrRep* dest)
-{
- int n = src->len;
- if (src != dest) dest = Salloc(dest, src->s, n, n);
- char* p = dest->s;
- char* e = &(p[n]);
- for (; p < e; ++p) if (isupper(*p)) *p = tolower(*p);
- return dest;
-}
-
-StrRep* Scapitalize(const StrRep* src, StrRep* dest)
-{
- int n = src->len;
- if (src != dest) dest = Salloc(dest, src->s, n, n);
-
- char* p = dest->s;
- char* e = &(p[n]);
- for (; p < e; ++p)
- {
- int at_word;
- if (at_word = islower(*p))
- *p = toupper(*p);
- else
- at_word = isupper(*p) || isdigit(*p);
-
- if (at_word)
- {
- while (++p < e)
- {
- if (isupper(*p))
- *p = tolower(*p);
- /* A '\'' does not break a word, so that "Nathan's" stays
- "Nathan's" rather than turning into "Nathan'S". */
- else if (!islower(*p) && !isdigit(*p) && (*p != '\''))
- break;
- }
- }
- }
- return dest;
-}
-
-#if defined(__GNUG__) && !defined(_G_NO_NRV)
-
-String replicate(char c, int n) return w;
-{
- w.rep = Sresize(w.rep, n);
- char* p = w.rep->s;
- while (n-- > 0) *p++ = c;
- *p = 0;
-}
-
-String replicate(const String& y, int n) return w
-{
- int len = y.length();
- w.rep = Sresize(w.rep, n * len);
- char* p = w.rep->s;
- while (n-- > 0)
- {
- ncopy(y.chars(), p, len);
- p += len;
- }
- *p = 0;
-}
-
-String common_prefix(const String& x, const String& y, int startpos) return r;
-{
- const char* xchars = x.chars();
- const char* ychars = y.chars();
- const char* xs = &(xchars[startpos]);
- const char* ss = xs;
- const char* topx = &(xchars[x.length()]);
- const char* ys = &(ychars[startpos]);
- const char* topy = &(ychars[y.length()]);
- for (int l = 0; xs < topx && ys < topy && *xs++ == *ys++; ++l);
- r.rep = Salloc(r.rep, ss, l, l);
-}
-
-String common_suffix(const String& x, const String& y, int startpos) return r;
-{
- const char* xchars = x.chars();
- const char* ychars = y.chars();
- const char* xs = &(xchars[x.length() + startpos]);
- const char* botx = xchars;
- const char* ys = &(ychars[y.length() + startpos]);
- const char* boty = ychars;
- for (int l = 0; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l);
- r.rep = Salloc(r.rep, ++xs, l, l);
-}
-
-#else
-
-String replicate(char c, int n)
-{
- String w;
- w.rep = Sresize(w.rep, n);
- char* p = w.rep->s;
- while (n-- > 0) *p++ = c;
- *p = 0;
- return w;
-}
-
-String replicate(const String& y, int n)
-{
- String w;
- int len = y.length();
- w.rep = Sresize(w.rep, n * len);
- char* p = w.rep->s;
- while (n-- > 0)
- {
- ncopy(y.chars(), p, len);
- p += len;
- }
- *p = 0;
- return w;
-}
-
-String common_prefix(const String& x, const String& y, int startpos)
-{
- String r;
- const char* xchars = x.chars();
- const char* ychars = y.chars();
- const char* xs = &(xchars[startpos]);
- const char* ss = xs;
- const char* topx = &(xchars[x.length()]);
- const char* ys = &(ychars[startpos]);
- const char* topy = &(ychars[y.length()]);
- for (int l = 0; xs < topx && ys < topy && *xs++ == *ys++; ++l);
- r.rep = Salloc(r.rep, ss, l, l);
- return r;
-}
-
-String common_suffix(const String& x, const String& y, int startpos)
-{
- String r;
- const char* xchars = x.chars();
- const char* ychars = y.chars();
- const char* xs = &(xchars[x.length() + startpos]);
- const char* botx = xchars;
- const char* ys = &(ychars[y.length() + startpos]);
- const char* boty = ychars;
- for (int l = 0; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l);
- r.rep = Salloc(r.rep, ++xs, l, l);
- return r;
-}
-
-#endif
-
-// IO
-
-istream& operator>>(istream& s, String& x)
-{
- if (!s.ipfx(0) || (!(s.flags() & ios::skipws) && !ws(s)))
- {
- s.clear(ios::failbit|s.rdstate()); // Redundant if using GNU iostreams.
- return s;
- }
- int ch;
- int i = 0;
- x.rep = Sresize(x.rep, 20);
- register streambuf *sb = s.rdbuf();
- while ((ch = sb->sbumpc()) != EOF)
- {
- if (isspace(ch))
- break;
- if (i >= x.rep->sz - 1)
- x.rep = Sresize(x.rep, i+1);
- x.rep->s[i++] = ch;
- }
- x.rep->s[i] = 0;
- x.rep->len = i;
- int new_state = s.rdstate();
- if (i == 0) new_state |= ios::failbit;
- if (ch == EOF) new_state |= ios::eofbit;
- s.clear(new_state);
- return s;
-}
-
-int readline(istream& s, String& x, char terminator, int discard)
-{
- if (!s.ipfx(0))
- return 0;
- int ch;
- int i = 0;
- x.rep = Sresize(x.rep, 80);
- register streambuf *sb = s.rdbuf();
- while ((ch = sb->sbumpc()) != EOF)
- {
- if (ch != terminator || !discard)
- {
- if (i >= x.rep->sz - 1)
- x.rep = Sresize(x.rep, i+1);
- x.rep->s[i++] = ch;
- }
- if (ch == terminator)
- break;
- }
- x.rep->s[i] = 0;
- x.rep->len = i;
- if (ch == EOF) s.clear(ios::eofbit|s.rdstate());
- return i;
-}
-
-
-ostream& operator<<(ostream& s, const SubString& x)
-{
- const char* a = x.chars();
- const char* lasta = &(a[x.length()]);
- while (a < lasta)
- s.put(*a++);
- return(s);
-}
-
-// from John.Willis@FAS.RI.CMU.EDU
-
-int String::freq(const SubString& y) const
-{
- int found = 0;
- for (unsigned int i = 0; i < length(); i++)
- if (match(i,length(),0,y.chars(), y.length())>= 0) found++;
- return(found);
-}
-
-int String::freq(const String& y) const
-{
- int found = 0;
- for (unsigned int i = 0; i < length(); i++)
- if (match(i,length(),0,y.chars(),y.length()) >= 0) found++;
- return(found);
-}
-
-int String::freq(const char* t) const
-{
- int found = 0;
- for (unsigned int i = 0; i < length(); i++)
- if (match(i,length(),0,t) >= 0) found++;
- return(found);
-}
-
-int String::freq(char c) const
-{
- int found = 0;
- for (unsigned int i = 0; i < length(); i++)
- if (match(i,length(),0,&c,1) >= 0) found++;
- return(found);
-}
-
-
-int String::OK() const
-{
- if (rep == 0 // don't have a rep
- || rep->len > rep->sz // string oustide bounds
- || rep->s[rep->len] != 0) // not null-terminated
- error("invariant failure");
- return 1;
-}
-
-int SubString::OK() const
-{
- int v = S != (const char*)0; // have a String;
- v &= S.OK(); // that is legal
- v &= pos + len >= S.rep->len;// pos and len within bounds
- if (!v) S.error("SubString invariant failure");
- return v;
-}
-
diff --git a/gnu/lib/libg++/libg++/Uniform.cc b/gnu/lib/libg++/libg++/Uniform.cc
deleted file mode 100644
index 2bf7259..0000000
--- a/gnu/lib/libg++/libg++/Uniform.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <Uniform.h>
-
-double Uniform::operator()()
-{
- return( pLow + delta * pGenerator -> asDouble() );
-}
diff --git a/gnu/lib/libg++/libg++/Weibull.cc b/gnu/lib/libg++/libg++/Weibull.cc
deleted file mode 100644
index 02670b9..0000000
--- a/gnu/lib/libg++/libg++/Weibull.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-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.
-*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <Random.h>
-#include <Weibull.h>
-
-//
-// See Simulation, Modelling & Analysis by Law & Kelton, pp259
-//
-// This is the ``polar'' method.
-//
-
-double Weibull::operator()()
-{
- return( pow(pBeta * ( - log(1 - pGenerator -> asDouble()) ), pInvAlpha) );
-}
diff --git a/gnu/lib/libg++/libg++/bitand.c b/gnu/lib/libg++/libg++/bitand.c
deleted file mode 100644
index 7809a11..0000000
--- a/gnu/lib/libg++/libg++/bitand.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright (C) 1994 Free Software Foundation
-
-This file is part of the GNU BitString 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 "bitprims.h"
-
-/* Copy LENGTH bits from (starting at SRCBIT) into pdst starting at DSTBIT.
- This will work even if psrc & pdst overlap. */
-
-void
-_BS_and (pdst, dstbit, psrc, srcbit, length)
- register _BS_word* pdst;
- int dstbit;
- register const _BS_word* psrc;
- int srcbit;
- _BS_size_t length;
-{
-#define COMBINE(dst, src) (dst) & (src)
-#include "bitdo2.h"
-}
diff --git a/gnu/lib/libg++/libg++/bitany.c b/gnu/lib/libg++/libg++/bitany.c
deleted file mode 100644
index 861382f..0000000
--- a/gnu/lib/libg++/libg++/bitany.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 1994 Free Software Foundation
-
-This file is part of the GNU BitString 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 "bitprims.h"
-
-int
-_BS_any (ptr, offset, length)
- register const _BS_word *ptr;
- int offset;
- _BS_size_t length;
-{
-#undef DOIT
-#define DOIT(WORD, MASK) if ((WORD) & (MASK)) return 1;
-#include "bitdo1.h"
- return 0;
-}
diff --git a/gnu/lib/libg++/libg++/bitblt.c b/gnu/lib/libg++/libg++/bitblt.c
deleted file mode 100644
index a1cc71b..0000000
--- a/gnu/lib/libg++/libg++/bitblt.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright (C) 1994 Free Software Foundation
-
-This file is part of the GNU BitString 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).
- Based on ideas in the X11 MFB server. */
-
-#include "bitprims.h"
-#define ONES ((_BS_word)(~0))
-
-/* Copy LENGTH bits from (starting at SRCBIT) into pdst starting at DSTBIT.
- This will work even if psrc & pdst overlap. */
-
-void
-_BS_blt (op, pdst, dstbit, psrc, srcbit, length)
- enum _BS_alu op;
- register _BS_word* pdst;
- int dstbit;
- register const _BS_word* psrc;
- int srcbit;
- _BS_size_t length;
-{
- _BS_word ca1, cx1, ca2, cx2;
- switch (op)
- {
- case _BS_alu_clear:
- _BS_clear (pdst, dstbit, length);
- return;
- case _BS_alu_and:
- _BS_and (pdst, dstbit, psrc, srcbit, length);
- return;
- case _BS_alu_andReverse:
- ca1 = ONES; cx1 = 0; ca2 = ONES; cx2 = 0;
- break;
- case _BS_alu_copy:
- _BS_copy (pdst, dstbit, psrc, srcbit, length);
- return;
- case _BS_alu_andInverted:
- ca1 = ONES; cx1 = ONES; ca2 = 0; cx2 = 0;
- break;
- case _BS_alu_noop:
- return;
- case _BS_alu_xor:
- _BS_xor (pdst, dstbit, psrc, srcbit, length);
- return;
- case _BS_alu_or:
- ca1 = ONES; cx1 = ONES; ca2 = ONES; cx2 = 0;
- break;
- case _BS_alu_nor:
- ca1 = ONES; cx1 = ONES; ca2 = ONES; cx2 = ONES;
- break;
- case _BS_alu_equiv:
- ca1 = 0; cx1 = ONES; ca2 = ONES; cx2 = ONES;
- break;
- case _BS_alu_invert:
- _BS_invert (pdst, dstbit, length);
- return;
- case _BS_alu_orReverse:
- ca1 = ONES; cx1 = ONES; ca2 = 0; cx2 = ONES;
- break;
- case _BS_alu_copyInverted:
- ca1 = 0; cx1 = 0; ca2 = ONES; cx2 = ONES;
- break;
- case _BS_alu_orInverted:
- ca1 = ONES; cx1 = 0; ca2 = ONES; cx2 = ONES;
- break;
- case _BS_alu_nand:
- ca1 = ONES; cx1 = 0; ca2 = 0; cx2 = ONES;
- break;
- case _BS_alu_set:
- _BS_set (pdst, dstbit, length);
- return;
- }
- {
-#define COMBINE(dst, src) ( ((dst) & ( ((src) & ca1) ^ cx1)) ^ ( ((src) & ca2) ^ cx2))
-#include "bitdo2.h"
- }
-}
diff --git a/gnu/lib/libg++/libg++/bitclear.c b/gnu/lib/libg++/libg++/bitclear.c
deleted file mode 100644
index 8015843..0000000
--- a/gnu/lib/libg++/libg++/bitclear.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 1994 Free Software Foundation
-
-This file is part of the GNU BitString 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 "bitprims.h"
-
-void
-_BS_clear (ptr, offset, length)
- register _BS_word *ptr;
- int offset;
- _BS_size_t length;
-{
-#undef DOIT
-#define DOIT(WORD, MASK) ((WORD) &= ~(MASK))
-#include "bitdo1.h"
-}
diff --git a/gnu/lib/libg++/libg++/bitcopy.c b/gnu/lib/libg++/libg++/bitcopy.c
deleted file mode 100644
index f0f449c..0000000
--- a/gnu/lib/libg++/libg++/bitcopy.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright (C) 1994 Free Software Foundation
-
-This file is part of the GNU BitString 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 "bitprims.h"
-
-/* Copy LENGTH bits from (starting at SRCBIT) into pdst starting at DSTBIT.
- This will work even if psrc & pdst overlap. */
-
-void
-_BS_copy (pdst, dstbit, psrc, srcbit, length)
- register _BS_word* pdst;
- int dstbit;
- register const _BS_word* psrc;
- int srcbit;
- _BS_size_t length;
-{
-#define COMBINE(dst, src) (src)
-#include "bitdo2.h"
-}
diff --git a/gnu/lib/libg++/libg++/bitcount.c b/gnu/lib/libg++/libg++/bitcount.c
deleted file mode 100644
index 9a17d17..0000000
--- a/gnu/lib/libg++/libg++/bitcount.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Copyright (C) 1994 Free Software Foundation
-
-This file is part of the GNU BitString 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 "bitprims.h"
-
-/* bit_count[I] is number of '1' bits in I. */
-static const unsigned char
-four_bit_count[16] = {
- 0, 1, 1, 2,
- 1, 2, 2, 3,
- 1, 2, 2, 3,
- 2, 3, 3, 4};
-
-#if !defined(inline) && !defined(__GNUC__) && !defined(__cplusplus)
-#define inline
-#endif
-
-static inline int
-_BS_count_word (word)
- register _BS_word word;
-{
- register int count = 0;
- while (word > 0)
- {
- count += four_bit_count[word & 15];
- word >>= 4;
- }
- return count;
-}
-
-int
-_BS_count (ptr, offset, length)
- register const _BS_word *ptr;
- int offset;
- _BS_size_t length;
-{
- register int count = 0;
-#undef DOIT
-#define DOIT(WORD, MASK) count += _BS_count_word ((WORD) & (MASK));
-#include "bitdo1.h"
- return count;
-}
diff --git a/gnu/lib/libg++/libg++/bitinvert.c b/gnu/lib/libg++/libg++/bitinvert.c
deleted file mode 100644
index 50f0369..0000000
--- a/gnu/lib/libg++/libg++/bitinvert.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 1994 Free Software Foundation
-
-This file is part of the GNU BitString 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 "bitprims.h"
-
-void
-_BS_invert (ptr, offset, length)
- register _BS_word *ptr;
- int offset;
- _BS_size_t length;
-{
-#undef DOIT
-#define DOIT(WORD, MASK) ((WORD) ^= (MASK))
-#include "bitdo1.h"
-}
diff --git a/gnu/lib/libg++/libg++/bitlcomp.c b/gnu/lib/libg++/libg++/bitlcomp.c
deleted file mode 100644
index 9f0c0e0..0000000
--- a/gnu/lib/libg++/libg++/bitlcomp.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Copyright (C) 1994 Free Software Foundation
-
-This file is part of the GNU BitString 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 <stdlib.h>
-#include "bitprims.h"
-
-/* Return -1, 0, 1 depending on whether (ptr0, len0) is
- lexicographically less than, equal, or greater than (ptr1, len1).
- Both bitstrings must be left-aligned. */
-
-int
-_BS_lcompare_0 (ptr0, len0, ptr1, len1)
- register _BS_word *ptr0;
- _BS_size_t len0;
- register _BS_word *ptr1;
- _BS_size_t len1;
-{
- _BS_size_t nwords0 = len0 / _BS_BITS_PER_WORD;
- _BS_size_t nwords1 = len1 / _BS_BITS_PER_WORD;
- register _BS_word word0, word1, mask;
- _BS_size_t nwords = nwords0 > nwords1 ? nwords1 : nwords0;
- for (; nwords != 0; nwords--)
- {
- word0 = *ptr0++;
- word1 = *ptr1++;
- if (word0 != word1)
- {
-#if _BS_BIGENDIAN
- return (word0 < word1) ? -1 : 1;
-#else
- mask = 1;
- for (;;)
- {
- int bit0 = word0 & 1;
- int bit1 = word1 & 1;
- int diff = bit0 - bit1;
- if (diff)
- return diff;
- word0 >>= 1;
- word1 >>= 1;
- }
-#endif
- }
- }
- len0 -= nwords0 * _BS_BITS_PER_WORD;
- len1 -= nwords1 * _BS_BITS_PER_WORD;
- if (len0 == 0 || len1 == 0)
- return (len0 == 0) - (len1 == 0);
- len0 &= _BS_BITS_PER_WORD - 1;
- len1 &= _BS_BITS_PER_WORD - 1;
- word0 = *ptr0++ & ~((_BS_word)(~0) _BS_RIGHT len0);
- word1 = *ptr1++ & ~((_BS_word)(~0) _BS_RIGHT len1);
- if (word0 == word1)
- return len0 == len1 ? 0 : len0 < len1 ? -1 : 1;
-#if _BS_BIGENDIAN
- return (word0 < word1) ? -1 : 1;
-#else
- for (;;)
- {
- int bit0 = word0 & 1;
- int bit1 = word1 & 1;
- int diff = bit0 - bit1;
- if (diff)
- return diff;
- word0 >>= 1;
- word1 >>= 1;
- }
-#endif
-}
-
diff --git a/gnu/lib/libg++/libg++/bitset1.c b/gnu/lib/libg++/libg++/bitset1.c
deleted file mode 100644
index 96e5ebd..0000000
--- a/gnu/lib/libg++/libg++/bitset1.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 1994 Free Software Foundation
-
-This file is part of the GNU BitString 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 "bitprims.h"
-
-void
-_BS_set (ptr, offset, length)
- register _BS_word *ptr;
- int offset;
- _BS_size_t length;
-{
-#undef DOIT
-#define DOIT(WORD, MASK) ((WORD) |= (MASK))
-#include "bitdo1.h"
-}
diff --git a/gnu/lib/libg++/libg++/bitxor.c b/gnu/lib/libg++/libg++/bitxor.c
deleted file mode 100644
index 0159bb4..0000000
--- a/gnu/lib/libg++/libg++/bitxor.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright (C) 1994 Free Software Foundation
-
-This file is part of the GNU BitString 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 "bitprims.h"
-
-/* Copy LENGTH bits from (starting at SRCBIT) into pdst starting at DSTBIT.
- This will work even if psrc & pdst overlap. */
-
-void
-_BS_xor (pdst, dstbit, psrc, srcbit, length)
- register _BS_word* pdst;
- int dstbit;
- register const _BS_word* psrc;
- int srcbit;
- _BS_size_t length;
-{
-#define COMBINE(dst, src) (dst) ^ (src)
-#include "bitdo2.h"
-}
diff --git a/gnu/lib/libg++/libg++/builtin.cc b/gnu/lib/libg++/libg++/builtin.cc
deleted file mode 100644
index 6b9abe5..0000000
--- a/gnu/lib/libg++/libg++/builtin.cc
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
diff --git a/gnu/lib/libg++/libg++/chr.cc b/gnu/lib/libg++/libg++/chr.cc
deleted file mode 100644
index d580a62..0000000
--- a/gnu/lib/libg++/libg++/chr.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-Copyright (C) 1990 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <AllocRing.h>
-
-extern AllocRing _libgxx_fmtq;
-
-char* chr(char ch, int width)
-{
- int len = 1;
- int wrksiz = len + width + 1;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- char* fmt = fmtbase;
- for (int blanks = width - len; blanks > 0; --blanks)
- *fmt++ = ' ';
- *fmt++ = ch;
- *fmt = 0;
- return fmtbase;
-}
diff --git a/gnu/lib/libg++/libg++/compare.cc b/gnu/lib/libg++/libg++/compare.cc
deleted file mode 100644
index aae8409..0000000
--- a/gnu/lib/libg++/libg++/compare.cc
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <compare.h>
diff --git a/gnu/lib/libg++/libg++/error.cc b/gnu/lib/libg++/libg++/error.cc
deleted file mode 100644
index 9283d14..0000000
--- a/gnu/lib/libg++/libg++/error.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-Copyright (C) 1990 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-
-#ifdef __GNUC__
-typedef _VOLATILE_VOID (*NoReturnFunc)(void);
-/* Cast abort to a _VOLATILE_VOID function, even if <stdlib.h> differs.
-This is to avoid a warning from g++ that a `volatile' function does return. */
-#define ABORT() ((NoReturnFunc)abort)()
-#else
-#define ABORT() abort()
-#endif
-
-_VOLATILE_VOID default_one_arg_error_handler(const char* msg)
-{
- fputs("Error: ", stderr);
- fputs(msg, stderr);
- fputs("\n", stderr);
- ABORT();
-}
-
-
-_VOLATILE_VOID default_two_arg_error_handler(const char* kind, const char* msg)
-{
- fputs(kind, stderr);
- fputs(" Error: ", stderr);
- fputs(msg, stderr);
- fputs("\n", stderr);
- ABORT();
-}
-
-two_arg_error_handler_t lib_error_handler = default_two_arg_error_handler;
-
-two_arg_error_handler_t set_lib_error_handler(two_arg_error_handler_t f)
-{
- two_arg_error_handler_t old = lib_error_handler;
- lib_error_handler = f;
- return old;
-}
-
diff --git a/gnu/lib/libg++/libg++/except.c b/gnu/lib/libg++/libg++/except.c
deleted file mode 100644
index 84adf22..0000000
--- a/gnu/lib/libg++/libg++/except.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* This is part of GNU C++ Library.
-Copyright (C) 1994 Free Software Foundation
-
-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 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. */
-
-/* terminate(), unexpected(), set_terminate(), set_unexpected() as
- well as the default terminate func and default unexpected func */
-
-#if 0
-extern int printf();
-#endif
-
-typedef void (*vfp)();
-
-void
-__default_terminate()
-{
- abort();
-}
-
-void
-__default_unexpected()
-{
- __default_terminate();
-}
-
-static vfp __terminate_func = __default_terminate;
-static vfp __unexpected_func = __default_unexpected;
-
-vfp
-set_terminate(func)
-vfp func;
-{
- vfp old = __terminate_func;
-
- __terminate_func = func;
- return old;
-}
-
-vfp
-set_unexpected(func)
-vfp func;
-{
- vfp old = __unexpected_func;
-
- __unexpected_func = func;
- return old;
-}
-
-void
-terminate()
-{
- __terminate_func();
-}
-
-void
-unexpected()
-{
- __unexpected_func();
-}
diff --git a/gnu/lib/libg++/libg++/fmtq.cc b/gnu/lib/libg++/libg++/fmtq.cc
deleted file mode 100644
index 7a9dd7b..0000000
--- a/gnu/lib/libg++/libg++/fmtq.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-Copyright (C) 1990 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <AllocRing.h>
-
-// AllocRings are used for output operations
-// We guaranteee that the last _libgxx_maxfmt formats
-// will be intact
-
-static const int _libgxx_maxfmt = 20;
-AllocRing _libgxx_fmtq(_libgxx_maxfmt);
diff --git a/gnu/lib/libg++/libg++/gcd.cc b/gnu/lib/libg++/libg++/gcd.cc
deleted file mode 100644
index 76ff0ef..0000000
--- a/gnu/lib/libg++/libg++/gcd.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-Copyright (C) 1990 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-
-
-/*
- common functions on built-in types
-*/
-
-long gcd(long x, long y) // euclid's algorithm
-{
- long a = abs(x);
- long b = abs(y);
-
- long tmp;
-
- if (b > a)
- {
- tmp = a; a = b; b = tmp;
- }
- for(;;)
- {
- if (b == 0)
- return a;
- else if (b == 1)
- return b;
- else
- {
- tmp = b;
- b = a % b;
- a = tmp;
- }
- }
-}
diff --git a/gnu/lib/libg++/libg++/hash.cc b/gnu/lib/libg++/libg++/hash.cc
deleted file mode 100644
index 4f16f97..0000000
--- a/gnu/lib/libg++/libg++/hash.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-Copyright (C) 1990 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-
-/*
- some useful hash functions
-*/
-
-unsigned int hashpjw(const char* x) // From Dragon book, p436
-{
- unsigned int h = 0;
- unsigned int g;
-
- while (*x != 0)
- {
- h = (h << 4) + *x++;
- if ((g = h & 0xf0000000) != 0)
- h = (h ^ (g >> 24)) ^ g;
- }
- return h;
-}
-
-unsigned int multiplicativehash(int x)
-{
- // uses a const close to golden ratio * pow(2,32)
- return ((unsigned)x) * 2654435767;
-}
-
-
-unsigned int foldhash(double x)
-{
- union { unsigned int i[2]; double d; } u;
- u.d = x;
- unsigned int u0 = u.i[0];
- unsigned int u1 = u.i[1];
- return u0 ^ u1;
-}
-
diff --git a/gnu/lib/libg++/libg++/ioob.cc b/gnu/lib/libg++/libg++/ioob.cc
deleted file mode 100644
index 08409a5..0000000
--- a/gnu/lib/libg++/libg++/ioob.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-Copyright (C) 1990 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
-This file is part of GNU CC.
-
-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
-and this notice must be preserved on all copies.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <Obstack.h>
-
-// Obstacks are used as an easy way to allocate enough space
-// for various builtin input operations
-
-
-Obstack _libgxx_io_ob;
diff --git a/gnu/lib/libg++/libg++/lg.cc b/gnu/lib/libg++/libg++/lg.cc
deleted file mode 100644
index b5ea5fd..0000000
--- a/gnu/lib/libg++/libg++/lg.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-Copyright (C) 1990 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-
-long lg(unsigned long x)
-{
- long l = 0;
- while (x > 1)
- {
- x = x >> 1;
- ++l;
- }
- return l;
-}
diff --git a/gnu/lib/libg++/libg++/math.cc b/gnu/lib/libg++/libg++/math.cc
deleted file mode 100644
index f1a0e52..0000000
--- a/gnu/lib/libg++/libg++/math.cc
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <math.h>
diff --git a/gnu/lib/libg++/libg++/new.cc b/gnu/lib/libg++/libg++/new.cc
deleted file mode 100644
index 7a707a6..0000000
--- a/gnu/lib/libg++/libg++/new.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-
-/*
-Copyright (C) 1989 Free Software Foundation
- written by Doug Lea (dl@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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <new.h>
-
-#if 0 /* ndef NO_LIBGXX_MALLOC */
-
-void* operator new(size_t n)
-{
- return malloc (n);
-}
-#endif
diff --git a/gnu/lib/libg++/libg++/pow.cc b/gnu/lib/libg++/libg++/pow.cc
deleted file mode 100644
index b56a8b7..0000000
--- a/gnu/lib/libg++/libg++/pow.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-Copyright (C) 1990 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <math.h>
-
-double pow(double x, long p)
-{
- if (p == 0)
- return 1.0;
- else if (x == 0.0)
- return 0.0;
- else
- {
- if (p < 0)
- {
- p = -p;
- x = 1.0 / x;
- }
-
- double r = 1.0;
- for(;;)
- {
- if (p & 1)
- r *= x;
- if ((p >>= 1) == 0)
- return r;
- else
- x *= x;
- }
- }
-}
-
-long pow(long x, long p)
-{
- if (p == 0)
- return 1;
- else if (p < 0 || x == 0)
- return 0;
- else
- {
- long r = 1;
- for(;;)
- {
- if (p & 1)
- r *= x;
- if ((p >>= 1) == 0)
- return r;
- else
- x *= x;
- }
- }
-}
diff --git a/gnu/lib/libg++/libg++/sqrt.cc b/gnu/lib/libg++/libg++/sqrt.cc
deleted file mode 100644
index 6df9af3..0000000
--- a/gnu/lib/libg++/libg++/sqrt.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-Copyright (C) 1990 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <math.h>
-
-long sqrt(long x)
-{
- if (x <= 0)
- return 0; // no int error handler, so ...
- else if (x == 1)
- return 1;
- else
- {
- long r = x >> 1;
- long q;
- for(;;)
- {
- q = x / r;
- if (q >= r)
- return r;
- else
- r = (r + q) >> 1;
- }
- }
-}
diff --git a/gnu/lib/libg++/libg++/str.cc b/gnu/lib/libg++/libg++/str.cc
deleted file mode 100644
index bf77c02..0000000
--- a/gnu/lib/libg++/libg++/str.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-Copyright (C) 1990 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <builtin.h>
-#include <AllocRing.h>
-
-extern AllocRing _libgxx_fmtq;
-
-char* str(const char* s, int width)
-{
- int len = strlen(s);
- int wrksiz = len + width + 1;
- char* fmtbase = (char *) _libgxx_fmtq.alloc(wrksiz);
- char* fmt = fmtbase;
- for (int blanks = width - len; blanks > 0; --blanks)
- *fmt++ = ' ';
- while (*s != 0)
- *fmt++ = *s++;
- *fmt = 0;
- return fmtbase;
-}
diff --git a/gnu/lib/libg++/libg++/timer.c b/gnu/lib/libg++/libg++/timer.c
deleted file mode 100644
index 579cc54..0000000
--- a/gnu/lib/libg++/libg++/timer.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
-Copyright (C) 1990, 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-/* Timing functions from Doug Schmidt... */
-
-/* no such thing as "negative time"! */
-#define TIMER_ERROR_VALUE -1.0
-
-/* If this does not work on your system, change this to #if 0, and
- report the problem. */
-
-#if 1
-
-#include <_G_config.h>
-#if _G_HAVE_SYS_RESOURCE
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif
-#if !_G_HAVE_SYS_RESOURCE || !defined(RUSAGE_SELF)
-#define USE_TIMES
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/times.h>
-#if !defined (HZ) && defined(CLK_TCK)
-#define HZ CLK_TCK
-#endif
-static struct tms Old_Time;
-static struct tms New_Time;
-#else
-static struct rusage Old_Time;
-static struct rusage New_Time;
-#endif
-static int Timer_Set = 0;
-
-double
-start_timer()
-{
- Timer_Set = 1;
-#ifdef USE_TIMES
- times(&Old_Time);
- return((double) Old_Time.tms_utime / HZ);
-#else
- getrusage(RUSAGE_SELF,&Old_Time); /* set starting process time */
- return(Old_Time.ru_utime.tv_sec + (Old_Time.ru_utime.tv_usec / 1000000.0));
-#endif
-}
-
-/* Returns process time since Last_Time.
- If parameter is 0.0, returns time since the Old_Time was set.
- Returns TIMER_ERROR_VALUE if `start_timer' is not called first. */
-
-double
-return_elapsed_time(Last_Time)
- double Last_Time;
-{
- if (!Timer_Set) {
- return(TIMER_ERROR_VALUE);
- }
- else {
- /* get process time */
-#ifdef USE_TIMES
- times(&New_Time);
-#else
- getrusage(RUSAGE_SELF,&New_Time);
-#endif
- if (Last_Time == 0.0) {
-#ifdef USE_TIMES
- return((double) (New_Time.tms_utime - Old_Time.tms_utime) / HZ);
-#else
- return((New_Time.ru_utime.tv_sec - Old_Time.ru_utime.tv_sec) +
- ((New_Time.ru_utime.tv_usec - Old_Time.ru_utime.tv_usec)
- / 1000000.0));
-#endif
- }
- else {
-#ifdef USE_TIMES
- return((double) New_Time.tms_utime / HZ - Last_Time);
-#else
- return((New_Time.ru_utime.tv_sec +
- (New_Time.ru_utime.tv_usec / 1000000.0)) - Last_Time);
-#endif
- }
- }
-}
-
-#ifdef VMS
-void sys$gettim(unsigned int*) asm("sys$gettim");
-
-getrusage(int dummy,struct rusage* time){
- double rtime;
- unsigned int systime[2];
- int i;
- sys$gettim(&systime[0]);
- rtime=systime[1];
- for(i=0;i<4;i++) rtime *= 256;
- rtime+= systime[0];
-/* we subtract an offset to make sure that the number fits in a long int*/
- rtime=rtime/1.0e+7-4.144e+9;
- time->ru_utime.tv_sec= rtime;
- rtime=(rtime-time->ru_utime.tv_sec)*1.0e6;
- time->ru_utime.tv_usec= rtime;
-}
-#endif
-#else /* dummy them out */
-
-double start_timer()
-{
- return TIMER_ERROR_VALUE;
-}
-
-double return_elapsed_time(double)
-{
- return TIMER_ERROR_VALUE;
-}
-
-#endif /* timing stuff */
-
-
diff --git a/gnu/lib/libg++/libiberty/strerror.c b/gnu/lib/libg++/libiberty/strerror.c
deleted file mode 100644
index 29a4e4a..0000000
--- a/gnu/lib/libg++/libiberty/strerror.c
+++ /dev/null
@@ -1,823 +0,0 @@
-/* Extended support for using errno values.
- Copyright (C) 1992 Free Software Foundation, Inc.
- Written by Fred Fish. fnf@cygnus.com
-
-This file is part of the libiberty library.
-Libiberty 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.
-
-Libiberty 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 libiberty; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#include "ansidecl.h"
-#include "libiberty.h"
-
-#include "config.h"
-
-#ifndef NEED_sys_errlist
-/* Note that errno.h (not sure what OS) or stdio.h (BSD 4.4, at least)
- might declare sys_errlist in a way that the compiler might consider
- incompatible with our later declaration, perhaps by using const
- attributes. So we hide the declaration in errno.h (if any) using a
- macro. */
-#define sys_errlist sys_errlist__
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-
-#ifndef NEED_sys_errlist
-#undef sys_errlist
-#endif
-
-/* Routines imported from standard C runtime libraries. */
-
-#ifdef __STDC__
-#include <stddef.h>
-extern void *malloc (size_t size); /* 4.10.3.3 */
-extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */
-#else /* !__STDC__ */
-extern char *malloc (); /* Standard memory allocater */
-extern char *memset ();
-#endif /* __STDC__ */
-
-#ifndef MAX
-# define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
-/* Translation table for errno values. See intro(2) in most UNIX systems
- Programmers Reference Manuals.
-
- Note that this table is generally only accessed when it is used at runtime
- to initialize errno name and message tables that are indexed by errno
- value.
-
- Not all of these errnos will exist on all systems. This table is the only
- thing that should have to be updated as new error numbers are introduced.
- It's sort of ugly, but at least its portable. */
-
-struct error_info
-{
- int value; /* The numeric value from <errno.h> */
- const char *name; /* The equivalent symbolic value */
-#ifdef NEED_sys_errlist
- const char *msg; /* Short message about this value */
-#endif
-};
-
-#ifdef NEED_sys_errlist
-# define ENTRY(value, name, msg) {value, name, msg}
-#else
-# define ENTRY(value, name, msg) {value, name}
-#endif
-
-static const struct error_info error_table[] =
-{
-#if defined (EPERM)
- ENTRY(EPERM, "EPERM", "Not owner"),
-#endif
-#if defined (ENOENT)
- ENTRY(ENOENT, "ENOENT", "No such file or directory"),
-#endif
-#if defined (ESRCH)
- ENTRY(ESRCH, "ESRCH", "No such process"),
-#endif
-#if defined (EINTR)
- ENTRY(EINTR, "EINTR", "Interrupted system call"),
-#endif
-#if defined (EIO)
- ENTRY(EIO, "EIO", "I/O error"),
-#endif
-#if defined (ENXIO)
- ENTRY(ENXIO, "ENXIO", "No such device or address"),
-#endif
-#if defined (E2BIG)
- ENTRY(E2BIG, "E2BIG", "Arg list too long"),
-#endif
-#if defined (ENOEXEC)
- ENTRY(ENOEXEC, "ENOEXEC", "Exec format error"),
-#endif
-#if defined (EBADF)
- ENTRY(EBADF, "EBADF", "Bad file number"),
-#endif
-#if defined (ECHILD)
- ENTRY(ECHILD, "ECHILD", "No child processes"),
-#endif
-#if defined (EWOULDBLOCK) /* Put before EAGAIN, sometimes aliased */
- ENTRY(EWOULDBLOCK, "EWOULDBLOCK", "Operation would block"),
-#endif
-#if defined (EAGAIN)
- ENTRY(EAGAIN, "EAGAIN", "No more processes"),
-#endif
-#if defined (ENOMEM)
- ENTRY(ENOMEM, "ENOMEM", "Not enough space"),
-#endif
-#if defined (EACCES)
- ENTRY(EACCES, "EACCES", "Permission denied"),
-#endif
-#if defined (EFAULT)
- ENTRY(EFAULT, "EFAULT", "Bad address"),
-#endif
-#if defined (ENOTBLK)
- ENTRY(ENOTBLK, "ENOTBLK", "Block device required"),
-#endif
-#if defined (EBUSY)
- ENTRY(EBUSY, "EBUSY", "Device busy"),
-#endif
-#if defined (EEXIST)
- ENTRY(EEXIST, "EEXIST", "File exists"),
-#endif
-#if defined (EXDEV)
- ENTRY(EXDEV, "EXDEV", "Cross-device link"),
-#endif
-#if defined (ENODEV)
- ENTRY(ENODEV, "ENODEV", "No such device"),
-#endif
-#if defined (ENOTDIR)
- ENTRY(ENOTDIR, "ENOTDIR", "Not a directory"),
-#endif
-#if defined (EISDIR)
- ENTRY(EISDIR, "EISDIR", "Is a directory"),
-#endif
-#if defined (EINVAL)
- ENTRY(EINVAL, "EINVAL", "Invalid argument"),
-#endif
-#if defined (ENFILE)
- ENTRY(ENFILE, "ENFILE", "File table overflow"),
-#endif
-#if defined (EMFILE)
- ENTRY(EMFILE, "EMFILE", "Too many open files"),
-#endif
-#if defined (ENOTTY)
- ENTRY(ENOTTY, "ENOTTY", "Not a typewriter"),
-#endif
-#if defined (ETXTBSY)
- ENTRY(ETXTBSY, "ETXTBSY", "Text file busy"),
-#endif
-#if defined (EFBIG)
- ENTRY(EFBIG, "EFBIG", "File too large"),
-#endif
-#if defined (ENOSPC)
- ENTRY(ENOSPC, "ENOSPC", "No space left on device"),
-#endif
-#if defined (ESPIPE)
- ENTRY(ESPIPE, "ESPIPE", "Illegal seek"),
-#endif
-#if defined (EROFS)
- ENTRY(EROFS, "EROFS", "Read-only file system"),
-#endif
-#if defined (EMLINK)
- ENTRY(EMLINK, "EMLINK", "Too many links"),
-#endif
-#if defined (EPIPE)
- ENTRY(EPIPE, "EPIPE", "Broken pipe"),
-#endif
-#if defined (EDOM)
- ENTRY(EDOM, "EDOM", "Math argument out of domain of func"),
-#endif
-#if defined (ERANGE)
- ENTRY(ERANGE, "ERANGE", "Math result not representable"),
-#endif
-#if defined (ENOMSG)
- ENTRY(ENOMSG, "ENOMSG", "No message of desired type"),
-#endif
-#if defined (EIDRM)
- ENTRY(EIDRM, "EIDRM", "Identifier removed"),
-#endif
-#if defined (ECHRNG)
- ENTRY(ECHRNG, "ECHRNG", "Channel number out of range"),
-#endif
-#if defined (EL2NSYNC)
- ENTRY(EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"),
-#endif
-#if defined (EL3HLT)
- ENTRY(EL3HLT, "EL3HLT", "Level 3 halted"),
-#endif
-#if defined (EL3RST)
- ENTRY(EL3RST, "EL3RST", "Level 3 reset"),
-#endif
-#if defined (ELNRNG)
- ENTRY(ELNRNG, "ELNRNG", "Link number out of range"),
-#endif
-#if defined (EUNATCH)
- ENTRY(EUNATCH, "EUNATCH", "Protocol driver not attached"),
-#endif
-#if defined (ENOCSI)
- ENTRY(ENOCSI, "ENOCSI", "No CSI structure available"),
-#endif
-#if defined (EL2HLT)
- ENTRY(EL2HLT, "EL2HLT", "Level 2 halted"),
-#endif
-#if defined (EDEADLK)
- ENTRY(EDEADLK, "EDEADLK", "Deadlock condition"),
-#endif
-#if defined (ENOLCK)
- ENTRY(ENOLCK, "ENOLCK", "No record locks available"),
-#endif
-#if defined (EBADE)
- ENTRY(EBADE, "EBADE", "Invalid exchange"),
-#endif
-#if defined (EBADR)
- ENTRY(EBADR, "EBADR", "Invalid request descriptor"),
-#endif
-#if defined (EXFULL)
- ENTRY(EXFULL, "EXFULL", "Exchange full"),
-#endif
-#if defined (ENOANO)
- ENTRY(ENOANO, "ENOANO", "No anode"),
-#endif
-#if defined (EBADRQC)
- ENTRY(EBADRQC, "EBADRQC", "Invalid request code"),
-#endif
-#if defined (EBADSLT)
- ENTRY(EBADSLT, "EBADSLT", "Invalid slot"),
-#endif
-#if defined (EDEADLOCK)
- ENTRY(EDEADLOCK, "EDEADLOCK", "File locking deadlock error"),
-#endif
-#if defined (EBFONT)
- ENTRY(EBFONT, "EBFONT", "Bad font file format"),
-#endif
-#if defined (ENOSTR)
- ENTRY(ENOSTR, "ENOSTR", "Device not a stream"),
-#endif
-#if defined (ENODATA)
- ENTRY(ENODATA, "ENODATA", "No data available"),
-#endif
-#if defined (ETIME)
- ENTRY(ETIME, "ETIME", "Timer expired"),
-#endif
-#if defined (ENOSR)
- ENTRY(ENOSR, "ENOSR", "Out of streams resources"),
-#endif
-#if defined (ENONET)
- ENTRY(ENONET, "ENONET", "Machine is not on the network"),
-#endif
-#if defined (ENOPKG)
- ENTRY(ENOPKG, "ENOPKG", "Package not installed"),
-#endif
-#if defined (EREMOTE)
- ENTRY(EREMOTE, "EREMOTE", "Object is remote"),
-#endif
-#if defined (ENOLINK)
- ENTRY(ENOLINK, "ENOLINK", "Link has been severed"),
-#endif
-#if defined (EADV)
- ENTRY(EADV, "EADV", "Advertise error"),
-#endif
-#if defined (ESRMNT)
- ENTRY(ESRMNT, "ESRMNT", "Srmount error"),
-#endif
-#if defined (ECOMM)
- ENTRY(ECOMM, "ECOMM", "Communication error on send"),
-#endif
-#if defined (EPROTO)
- ENTRY(EPROTO, "EPROTO", "Protocol error"),
-#endif
-#if defined (EMULTIHOP)
- ENTRY(EMULTIHOP, "EMULTIHOP", "Multihop attempted"),
-#endif
-#if defined (EDOTDOT)
- ENTRY(EDOTDOT, "EDOTDOT", "RFS specific error"),
-#endif
-#if defined (EBADMSG)
- ENTRY(EBADMSG, "EBADMSG", "Not a data message"),
-#endif
-#if defined (ENAMETOOLONG)
- ENTRY(ENAMETOOLONG, "ENAMETOOLONG", "File name too long"),
-#endif
-#if defined (EOVERFLOW)
- ENTRY(EOVERFLOW, "EOVERFLOW", "Value too large for defined data type"),
-#endif
-#if defined (ENOTUNIQ)
- ENTRY(ENOTUNIQ, "ENOTUNIQ", "Name not unique on network"),
-#endif
-#if defined (EBADFD)
- ENTRY(EBADFD, "EBADFD", "File descriptor in bad state"),
-#endif
-#if defined (EREMCHG)
- ENTRY(EREMCHG, "EREMCHG", "Remote address changed"),
-#endif
-#if defined (ELIBACC)
- ENTRY(ELIBACC, "ELIBACC", "Can not access a needed shared library"),
-#endif
-#if defined (ELIBBAD)
- ENTRY(ELIBBAD, "ELIBBAD", "Accessing a corrupted shared library"),
-#endif
-#if defined (ELIBSCN)
- ENTRY(ELIBSCN, "ELIBSCN", ".lib section in a.out corrupted"),
-#endif
-#if defined (ELIBMAX)
- ENTRY(ELIBMAX, "ELIBMAX", "Attempting to link in too many shared libraries"),
-#endif
-#if defined (ELIBEXEC)
- ENTRY(ELIBEXEC, "ELIBEXEC", "Cannot exec a shared library directly"),
-#endif
-#if defined (EILSEQ)
- ENTRY(EILSEQ, "EILSEQ", "Illegal byte sequence"),
-#endif
-#if defined (ENOSYS)
- ENTRY(ENOSYS, "ENOSYS", "Operation not applicable"),
-#endif
-#if defined (ELOOP)
- ENTRY(ELOOP, "ELOOP", "Too many symbolic links encountered"),
-#endif
-#if defined (ERESTART)
- ENTRY(ERESTART, "ERESTART", "Interrupted system call should be restarted"),
-#endif
-#if defined (ESTRPIPE)
- ENTRY(ESTRPIPE, "ESTRPIPE", "Streams pipe error"),
-#endif
-#if defined (ENOTEMPTY)
- ENTRY(ENOTEMPTY, "ENOTEMPTY", "Directory not empty"),
-#endif
-#if defined (EUSERS)
- ENTRY(EUSERS, "EUSERS", "Too many users"),
-#endif
-#if defined (ENOTSOCK)
- ENTRY(ENOTSOCK, "ENOTSOCK", "Socket operation on non-socket"),
-#endif
-#if defined (EDESTADDRREQ)
- ENTRY(EDESTADDRREQ, "EDESTADDRREQ", "Destination address required"),
-#endif
-#if defined (EMSGSIZE)
- ENTRY(EMSGSIZE, "EMSGSIZE", "Message too long"),
-#endif
-#if defined (EPROTOTYPE)
- ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"),
-#endif
-#if defined (ENOPROTOOPT)
- ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"),
-#endif
-#if defined (EPROTONOSUPPORT)
- ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"),
-#endif
-#if defined (ESOCKTNOSUPPORT)
- ENTRY(ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "Socket type not supported"),
-#endif
-#if defined (EOPNOTSUPP)
- ENTRY(EOPNOTSUPP, "EOPNOTSUPP", "Operation not supported on transport endpoint"),
-#endif
-#if defined (EPFNOSUPPORT)
- ENTRY(EPFNOSUPPORT, "EPFNOSUPPORT", "Protocol family not supported"),
-#endif
-#if defined (EAFNOSUPPORT)
- ENTRY(EAFNOSUPPORT, "EAFNOSUPPORT", "Address family not supported by protocol"),
-#endif
-#if defined (EADDRINUSE)
- ENTRY(EADDRINUSE, "EADDRINUSE", "Address already in use"),
-#endif
-#if defined (EADDRNOTAVAIL)
- ENTRY(EADDRNOTAVAIL, "EADDRNOTAVAIL","Cannot assign requested address"),
-#endif
-#if defined (ENETDOWN)
- ENTRY(ENETDOWN, "ENETDOWN", "Network is down"),
-#endif
-#if defined (ENETUNREACH)
- ENTRY(ENETUNREACH, "ENETUNREACH", "Network is unreachable"),
-#endif
-#if defined (ENETRESET)
- ENTRY(ENETRESET, "ENETRESET", "Network dropped connection because of reset"),
-#endif
-#if defined (ECONNABORTED)
- ENTRY(ECONNABORTED, "ECONNABORTED", "Software caused connection abort"),
-#endif
-#if defined (ECONNRESET)
- ENTRY(ECONNRESET, "ECONNRESET", "Connection reset by peer"),
-#endif
-#if defined (ENOBUFS)
- ENTRY(ENOBUFS, "ENOBUFS", "No buffer space available"),
-#endif
-#if defined (EISCONN)
- ENTRY(EISCONN, "EISCONN", "Transport endpoint is already connected"),
-#endif
-#if defined (ENOTCONN)
- ENTRY(ENOTCONN, "ENOTCONN", "Transport endpoint is not connected"),
-#endif
-#if defined (ESHUTDOWN)
- ENTRY(ESHUTDOWN, "ESHUTDOWN", "Cannot send after transport endpoint shutdown"),
-#endif
-#if defined (ETOOMANYREFS)
- ENTRY(ETOOMANYREFS, "ETOOMANYREFS", "Too many references: cannot splice"),
-#endif
-#if defined (ETIMEDOUT)
- ENTRY(ETIMEDOUT, "ETIMEDOUT", "Connection timed out"),
-#endif
-#if defined (ECONNREFUSED)
- ENTRY(ECONNREFUSED, "ECONNREFUSED", "Connection refused"),
-#endif
-#if defined (EHOSTDOWN)
- ENTRY(EHOSTDOWN, "EHOSTDOWN", "Host is down"),
-#endif
-#if defined (EHOSTUNREACH)
- ENTRY(EHOSTUNREACH, "EHOSTUNREACH", "No route to host"),
-#endif
-#if defined (EALREADY)
- ENTRY(EALREADY, "EALREADY", "Operation already in progress"),
-#endif
-#if defined (EINPROGRESS)
- ENTRY(EINPROGRESS, "EINPROGRESS", "Operation now in progress"),
-#endif
-#if defined (ESTALE)
- ENTRY(ESTALE, "ESTALE", "Stale NFS file handle"),
-#endif
-#if defined (EUCLEAN)
- ENTRY(EUCLEAN, "EUCLEAN", "Structure needs cleaning"),
-#endif
-#if defined (ENOTNAM)
- ENTRY(ENOTNAM, "ENOTNAM", "Not a XENIX named type file"),
-#endif
-#if defined (ENAVAIL)
- ENTRY(ENAVAIL, "ENAVAIL", "No XENIX semaphores available"),
-#endif
-#if defined (EISNAM)
- ENTRY(EISNAM, "EISNAM", "Is a named type file"),
-#endif
-#if defined (EREMOTEIO)
- ENTRY(EREMOTEIO, "EREMOTEIO", "Remote I/O error"),
-#endif
- ENTRY(0, NULL, NULL)
-};
-
-/* Translation table allocated and initialized at runtime. Indexed by the
- errno value to find the equivalent symbolic value. */
-
-static const char **error_names;
-static int num_error_names = 0;
-
-/* Translation table allocated and initialized at runtime, if it does not
- already exist in the host environment. Indexed by the errno value to find
- the descriptive string.
-
- We don't export it for use in other modules because even though it has the
- same name, it differs from other implementations in that it is dynamically
- initialized rather than statically initialized. */
-
-#ifdef NEED_sys_errlist
-
-static int sys_nerr;
-static const char **sys_errlist;
-
-#else
-
-extern int sys_nerr;
-extern char *sys_errlist[];
-
-#endif
-
-
-/*
-
-NAME
-
- init_error_tables -- initialize the name and message tables
-
-SYNOPSIS
-
- static void init_error_tables ();
-
-DESCRIPTION
-
- Using the error_table, which is initialized at compile time, generate
- the error_names and the sys_errlist (if needed) tables, which are
- indexed at runtime by a specific errno value.
-
-BUGS
-
- The initialization of the tables may fail under low memory conditions,
- in which case we don't do anything particularly useful, but we don't
- bomb either. Who knows, it might succeed at a later point if we free
- some memory in the meantime. In any case, the other routines know
- how to deal with lack of a table after trying to initialize it. This
- may or may not be considered to be a bug, that we don't specifically
- warn about this particular failure mode.
-
-*/
-
-static void
-init_error_tables ()
-{
- const struct error_info *eip;
- int nbytes;
-
- /* If we haven't already scanned the error_table once to find the maximum
- errno value, then go find it now. */
-
- if (num_error_names == 0)
- {
- for (eip = error_table; eip -> name != NULL; eip++)
- {
- if (eip -> value >= num_error_names)
- {
- num_error_names = eip -> value + 1;
- }
- }
- }
-
- /* Now attempt to allocate the error_names table, zero it out, and then
- initialize it from the statically initialized error_table. */
-
- if (error_names == NULL)
- {
- nbytes = num_error_names * sizeof (char *);
- if ((error_names = (const char **) malloc (nbytes)) != NULL)
- {
- memset (error_names, 0, nbytes);
- for (eip = error_table; eip -> name != NULL; eip++)
- {
- error_names[eip -> value] = eip -> name;
- }
- }
- }
-
-#ifdef NEED_sys_errlist
-
- /* Now attempt to allocate the sys_errlist table, zero it out, and then
- initialize it from the statically initialized error_table. */
-
- if (sys_errlist == NULL)
- {
- nbytes = num_error_names * sizeof (char *);
- if ((sys_errlist = (const char **) malloc (nbytes)) != NULL)
- {
- memset (sys_errlist, 0, nbytes);
- sys_nerr = num_error_names;
- for (eip = error_table; eip -> name != NULL; eip++)
- {
- sys_errlist[eip -> value] = eip -> msg;
- }
- }
- }
-
-#endif
-
-}
-
-/*
-
-NAME
-
- errno_max -- return the max errno value
-
-SYNOPSIS
-
- int errno_max ();
-
-DESCRIPTION
-
- Returns the maximum errno value for which a corresponding symbolic
- name or message is available. Note that in the case where
- we use the sys_errlist supplied by the system, it is possible for
- there to be more symbolic names than messages, or vice versa.
- In fact, the manual page for perror(3C) explicitly warns that one
- should check the size of the table (sys_nerr) before indexing it,
- since new error codes may be added to the system before they are
- added to the table. Thus sys_nerr might be smaller than value
- implied by the largest errno value defined in <errno.h>.
-
- We return the maximum value that can be used to obtain a meaningful
- symbolic name or message.
-
-*/
-
-int
-errno_max ()
-{
- int maxsize;
-
- if (error_names == NULL)
- {
- init_error_tables ();
- }
- maxsize = MAX (sys_nerr, num_error_names);
- return (maxsize - 1);
-}
-
-#ifdef NEED_strerror
-
-/*
-
-NAME
-
- strerror -- map an error number to an error message string
-
-SYNOPSIS
-
- char *strerror (int errnoval)
-
-DESCRIPTION
-
- Maps an errno number to an error message string, the contents of
- which are implementation defined. On systems which have the external
- variables sys_nerr and sys_errlist, these strings will be the same
- as the ones used by perror().
-
- If the supplied error number is within the valid range of indices
- for the sys_errlist, but no message is available for the particular
- error number, then returns the string "Error NUM", where NUM is the
- error number.
-
- If the supplied error number is not a valid index into sys_errlist,
- returns NULL.
-
- The returned string is only guaranteed to be valid only until the
- next call to strerror.
-
-*/
-
-char *
-strerror (errnoval)
- int errnoval;
-{
- char *msg;
- static char buf[32];
-
-#ifdef NEED_sys_errlist
-
- if (error_names == NULL)
- {
- init_error_tables ();
- }
-
-#endif
-
- if ((errnoval < 0) || (errnoval >= sys_nerr))
- {
- /* Out of range, just return NULL */
- msg = NULL;
- }
- else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL))
- {
- /* In range, but no sys_errlist or no entry at this index. */
- sprintf (buf, "Error %d", errnoval);
- msg = buf;
- }
- else
- {
- /* In range, and a valid message. Just return the message. */
- msg = (char *) sys_errlist[errnoval];
- }
-
- return (msg);
-}
-
-#endif /* NEED_strerror */
-
-
-/*
-
-NAME
-
- strerrno -- map an error number to a symbolic name string
-
-SYNOPSIS
-
- const char *strerrno (int errnoval)
-
-DESCRIPTION
-
- Given an error number returned from a system call (typically
- returned in errno), returns a pointer to a string containing the
- symbolic name of that error number, as found in <errno.h>.
-
- If the supplied error number is within the valid range of indices
- for symbolic names, but no name is available for the particular
- error number, then returns the string "Error NUM", where NUM is
- the error number.
-
- If the supplied error number is not within the range of valid
- indices, then returns NULL.
-
-BUGS
-
- The contents of the location pointed to are only guaranteed to be
- valid until the next call to strerrno.
-
-*/
-
-const char *
-strerrno (errnoval)
- int errnoval;
-{
- const char *name;
- static char buf[32];
-
- if (error_names == NULL)
- {
- init_error_tables ();
- }
-
- if ((errnoval < 0) || (errnoval >= num_error_names))
- {
- /* Out of range, just return NULL */
- name = NULL;
- }
- else if ((error_names == NULL) || (error_names[errnoval] == NULL))
- {
- /* In range, but no error_names or no entry at this index. */
- sprintf (buf, "Error %d", errnoval);
- name = (const char *) buf;
- }
- else
- {
- /* In range, and a valid name. Just return the name. */
- name = error_names[errnoval];
- }
-
- return (name);
-}
-
-/*
-
-NAME
-
- strtoerrno -- map a symbolic errno name to a numeric value
-
-SYNOPSIS
-
- int strtoerrno (char *name)
-
-DESCRIPTION
-
- Given the symbolic name of a error number, map it to an errno value.
- If no translation is found, returns 0.
-
-*/
-
-int
-strtoerrno (name)
- const char *name;
-{
- int errnoval = 0;
-
- if (name != NULL)
- {
- if (error_names == NULL)
- {
- init_error_tables ();
- }
- for (errnoval = 0; errnoval < num_error_names; errnoval++)
- {
- if ((error_names[errnoval] != NULL) &&
- (strcmp (name, error_names[errnoval]) == 0))
- {
- break;
- }
- }
- if (errnoval == num_error_names)
- {
- errnoval = 0;
- }
- }
- return (errnoval);
-}
-
-
-/* A simple little main that does nothing but print all the errno translations
- if MAIN is defined and this file is compiled and linked. */
-
-#ifdef MAIN
-
-#include <stdio.h>
-
-int
-main ()
-{
- int errn;
- int errnmax;
- const char *name;
- char *msg;
- char *strerror ();
-
- errnmax = errno_max ();
- printf ("%d entries in names table.\n", num_error_names);
- printf ("%d entries in messages table.\n", sys_nerr);
- printf ("%d is max useful index.\n", errnmax);
-
- /* Keep printing values until we get to the end of *both* tables, not
- *either* table. Note that knowing the maximum useful index does *not*
- relieve us of the responsibility of testing the return pointer for
- NULL. */
-
- for (errn = 0; errn <= errnmax; errn++)
- {
- name = strerrno (errn);
- name = (name == NULL) ? "<NULL>" : name;
- msg = strerror (errn);
- msg = (msg == NULL) ? "<NULL>" : msg;
- printf ("%-4d%-18s%s\n", errn, name, msg);
- }
-
- return 0;
-}
-
-#endif
diff --git a/gnu/lib/libg++/libiberty/strsignal.c b/gnu/lib/libg++/libiberty/strsignal.c
deleted file mode 100644
index 815af83..0000000
--- a/gnu/lib/libg++/libiberty/strsignal.c
+++ /dev/null
@@ -1,643 +0,0 @@
-/* Extended support for using signal values.
- Copyright (C) 1992 Free Software Foundation, Inc.
- Written by Fred Fish. fnf@cygnus.com
-
-This file is part of the libiberty library.
-Libiberty 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.
-
-Libiberty 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 libiberty; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#include "ansidecl.h"
-#include "libiberty.h"
-
-#include "config.h"
-
-#ifdef LOSING_SYS_SIGLIST
-#define sys_siglist no_such_symbol
-#endif
-
-#include <stdio.h>
-#include <signal.h>
-
-/* Routines imported from standard C runtime libraries. */
-
-#ifdef __STDC__
-#include <stddef.h>
-extern void *malloc (size_t size); /* 4.10.3.3 */
-extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */
-#else /* !__STDC__ */
-extern char *malloc (); /* Standard memory allocater */
-extern char *memset ();
-#endif /* __STDC__ */
-
-#ifdef LOSING_SYS_SIGLIST
-#undef sys_siglist
-#endif
-
-
-#ifndef NULL
-# ifdef __STDC__
-# define NULL (void *) 0
-# else
-# define NULL 0
-# endif
-#endif
-
-#ifndef MAX
-# define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
-/* Translation table for signal values.
-
- Note that this table is generally only accessed when it is used at runtime
- to initialize signal name and message tables that are indexed by signal
- value.
-
- Not all of these signals will exist on all systems. This table is the only
- thing that should have to be updated as new signal numbers are introduced.
- It's sort of ugly, but at least its portable. */
-
-struct signal_info
-{
- int value; /* The numeric value from <signal.h> */
- const char *name; /* The equivalent symbolic value */
-#ifdef NEED_sys_siglist
- const char *msg; /* Short message about this value */
-#endif
-};
-
-#ifdef NEED_sys_siglist
-# define ENTRY(value, name, msg) {value, name, msg}
-#else
-# define ENTRY(value, name, msg) {value, name}
-#endif
-
-static const struct signal_info signal_table[] =
-{
-#if defined (SIGHUP)
- ENTRY(SIGHUP, "SIGHUP", "Hangup"),
-#endif
-#if defined (SIGINT)
- ENTRY(SIGINT, "SIGINT", "Interrupt"),
-#endif
-#if defined (SIGQUIT)
- ENTRY(SIGQUIT, "SIGQUIT", "Quit"),
-#endif
-#if defined (SIGILL)
- ENTRY(SIGILL, "SIGILL", "Illegal instruction"),
-#endif
-#if defined (SIGTRAP)
- ENTRY(SIGTRAP, "SIGTRAP", "Trace/breakpoint trap"),
-#endif
-/* Put SIGIOT before SIGABRT, so that if SIGIOT==SIGABRT then SIGABRT
- overrides SIGIOT. SIGABRT is in ANSI and POSIX.1, and SIGIOT isn't. */
-#if defined (SIGIOT)
- ENTRY(SIGIOT, "SIGIOT", "IOT trap"),
-#endif
-#if defined (SIGABRT)
- ENTRY(SIGABRT, "SIGABRT", "Aborted"),
-#endif
-#if defined (SIGEMT)
- ENTRY(SIGEMT, "SIGEMT", "Emulation trap"),
-#endif
-#if defined (SIGFPE)
- ENTRY(SIGFPE, "SIGFPE", "Arithmetic exception"),
-#endif
-#if defined (SIGKILL)
- ENTRY(SIGKILL, "SIGKILL", "Killed"),
-#endif
-#if defined (SIGBUS)
- ENTRY(SIGBUS, "SIGBUS", "Bus error"),
-#endif
-#if defined (SIGSEGV)
- ENTRY(SIGSEGV, "SIGSEGV", "Segmentation fault"),
-#endif
-#if defined (SIGSYS)
- ENTRY(SIGSYS, "SIGSYS", "Bad system call"),
-#endif
-#if defined (SIGPIPE)
- ENTRY(SIGPIPE, "SIGPIPE", "Broken pipe"),
-#endif
-#if defined (SIGALRM)
- ENTRY(SIGALRM, "SIGALRM", "Alarm clock"),
-#endif
-#if defined (SIGTERM)
- ENTRY(SIGTERM, "SIGTERM", "Terminated"),
-#endif
-#if defined (SIGUSR1)
- ENTRY(SIGUSR1, "SIGUSR1", "User defined signal 1"),
-#endif
-#if defined (SIGUSR2)
- ENTRY(SIGUSR2, "SIGUSR2", "User defined signal 2"),
-#endif
-/* Put SIGCLD before SIGCHLD, so that if SIGCLD==SIGCHLD then SIGCHLD
- overrides SIGCLD. SIGCHLD is in POXIX.1 */
-#if defined (SIGCLD)
- ENTRY(SIGCLD, "SIGCLD", "Child status changed"),
-#endif
-#if defined (SIGCHLD)
- ENTRY(SIGCHLD, "SIGCHLD", "Child status changed"),
-#endif
-#if defined (SIGPWR)
- ENTRY(SIGPWR, "SIGPWR", "Power fail/restart"),
-#endif
-#if defined (SIGWINCH)
- ENTRY(SIGWINCH, "SIGWINCH", "Window size changed"),
-#endif
-#if defined (SIGURG)
- ENTRY(SIGURG, "SIGURG", "Urgent I/O condition"),
-#endif
-#if defined (SIGIO)
- /* "I/O pending" has also been suggested, but is misleading since the
- signal only happens when the process has asked for it, not everytime
- I/O is pending. */
- ENTRY(SIGIO, "SIGIO", "I/O possible"),
-#endif
-#if defined (SIGPOLL)
- ENTRY(SIGPOLL, "SIGPOLL", "Pollable event occurred"),
-#endif
-#if defined (SIGSTOP)
- ENTRY(SIGSTOP, "SIGSTOP", "Stopped (signal)"),
-#endif
-#if defined (SIGTSTP)
- ENTRY(SIGTSTP, "SIGTSTP", "Stopped (user)"),
-#endif
-#if defined (SIGCONT)
- ENTRY(SIGCONT, "SIGCONT", "Continued"),
-#endif
-#if defined (SIGTTIN)
- ENTRY(SIGTTIN, "SIGTTIN", "Stopped (tty input)"),
-#endif
-#if defined (SIGTTOU)
- ENTRY(SIGTTOU, "SIGTTOU", "Stopped (tty output)"),
-#endif
-#if defined (SIGVTALRM)
- ENTRY(SIGVTALRM, "SIGVTALRM", "Virtual timer expired"),
-#endif
-#if defined (SIGPROF)
- ENTRY(SIGPROF, "SIGPROF", "Profiling timer expired"),
-#endif
-#if defined (SIGXCPU)
- ENTRY(SIGXCPU, "SIGXCPU", "CPU time limit exceeded"),
-#endif
-#if defined (SIGXFSZ)
- ENTRY(SIGXFSZ, "SIGXFSZ", "File size limit exceeded"),
-#endif
-#if defined (SIGWIND)
- ENTRY(SIGWIND, "SIGWIND", "SIGWIND"),
-#endif
-#if defined (SIGPHONE)
- ENTRY(SIGPHONE, "SIGPHONE", "SIGPHONE"),
-#endif
-#if defined (SIGLOST)
- ENTRY(SIGLOST, "SIGLOST", "Resource lost"),
-#endif
-#if defined (SIGWAITING)
- ENTRY(SIGWAITING, "SIGWAITING", "Process's LWPs are blocked"),
-#endif
-#if defined (SIGLWP)
- ENTRY(SIGLWP, "SIGLWP", "Signal LWP"),
-#endif
-#if defined (SIGDANGER)
- ENTRY(SIGDANGER, "SIGDANGER", "Swap space dangerously low"),
-#endif
-#if defined (SIGGRANT)
- ENTRY(SIGGRANT, "SIGGRANT", "Monitor mode granted"),
-#endif
-#if defined (SIGRETRACT)
- ENTRY(SIGRETRACT, "SIGRETRACT", "Need to relinguish monitor mode"),
-#endif
-#if defined (SIGMSG)
- ENTRY(SIGMSG, "SIGMSG", "Monitor mode data available"),
-#endif
-#if defined (SIGSOUND)
- ENTRY(SIGSOUND, "SIGSOUND", "Sound completed"),
-#endif
-#if defined (SIGSAK)
- ENTRY(SIGSAK, "SIGSAK", "Secure attention"),
-#endif
- ENTRY(0, NULL, NULL)
-};
-
-/* Translation table allocated and initialized at runtime. Indexed by the
- signal value to find the equivalent symbolic value. */
-
-static const char **signal_names;
-static int num_signal_names = 0;
-
-/* Translation table allocated and initialized at runtime, if it does not
- already exist in the host environment. Indexed by the signal value to find
- the descriptive string.
-
- We don't export it for use in other modules because even though it has the
- same name, it differs from other implementations in that it is dynamically
- initialized rather than statically initialized. */
-
-#ifdef NEED_sys_siglist
-
-static int sys_nsig;
-static const char **sys_siglist;
-
-#else
-
-static int sys_nsig = NSIG;
-extern const char * const sys_siglist[];
-
-#endif
-
-
-/*
-
-NAME
-
- init_signal_tables -- initialize the name and message tables
-
-SYNOPSIS
-
- static void init_signal_tables ();
-
-DESCRIPTION
-
- Using the signal_table, which is initialized at compile time, generate
- the signal_names and the sys_siglist (if needed) tables, which are
- indexed at runtime by a specific signal value.
-
-BUGS
-
- The initialization of the tables may fail under low memory conditions,
- in which case we don't do anything particularly useful, but we don't
- bomb either. Who knows, it might succeed at a later point if we free
- some memory in the meantime. In any case, the other routines know
- how to deal with lack of a table after trying to initialize it. This
- may or may not be considered to be a bug, that we don't specifically
- warn about this particular failure mode.
-
-*/
-
-static void
-init_signal_tables ()
-{
- const struct signal_info *eip;
- int nbytes;
-
- /* If we haven't already scanned the signal_table once to find the maximum
- signal value, then go find it now. */
-
- if (num_signal_names == 0)
- {
- for (eip = signal_table; eip -> name != NULL; eip++)
- {
- if (eip -> value >= num_signal_names)
- {
- num_signal_names = eip -> value + 1;
- }
- }
- }
-
- /* Now attempt to allocate the signal_names table, zero it out, and then
- initialize it from the statically initialized signal_table. */
-
- if (signal_names == NULL)
- {
- nbytes = num_signal_names * sizeof (char *);
- if ((signal_names = (const char **) malloc (nbytes)) != NULL)
- {
- memset (signal_names, 0, nbytes);
- for (eip = signal_table; eip -> name != NULL; eip++)
- {
- signal_names[eip -> value] = eip -> name;
- }
- }
- }
-
-#ifdef NEED_sys_siglist
-
- /* Now attempt to allocate the sys_siglist table, zero it out, and then
- initialize it from the statically initialized signal_table. */
-
- if (sys_siglist == NULL)
- {
- nbytes = num_signal_names * sizeof (char *);
- if ((sys_siglist = (const char **) malloc (nbytes)) != NULL)
- {
- memset (sys_siglist, 0, nbytes);
- sys_nsig = num_signal_names;
- for (eip = signal_table; eip -> name != NULL; eip++)
- {
- sys_siglist[eip -> value] = eip -> msg;
- }
- }
- }
-
-#endif
-
-}
-
-
-/*
-
-NAME
-
- signo_max -- return the max signo value
-
-SYNOPSIS
-
- int signo_max ();
-
-DESCRIPTION
-
- Returns the maximum signo value for which a corresponding symbolic
- name or message is available. Note that in the case where
- we use the sys_siglist supplied by the system, it is possible for
- there to be more symbolic names than messages, or vice versa.
- In fact, the manual page for psignal(3b) explicitly warns that one
- should check the size of the table (NSIG) before indexing it,
- since new signal codes may be added to the system before they are
- added to the table. Thus NSIG might be smaller than value
- implied by the largest signo value defined in <signal.h>.
-
- We return the maximum value that can be used to obtain a meaningful
- symbolic name or message.
-
-*/
-
-int
-signo_max ()
-{
- int maxsize;
-
- if (signal_names == NULL)
- {
- init_signal_tables ();
- }
- maxsize = MAX (sys_nsig, num_signal_names);
- return (maxsize - 1);
-}
-
-
-/*
-
-NAME
-
- strsignal -- map a signal number to a signal message string
-
-SYNOPSIS
-
- const char *strsignal (int signo)
-
-DESCRIPTION
-
- Maps an signal number to an signal message string, the contents of
- which are implementation defined. On systems which have the external
- variable sys_siglist, these strings will be the same as the ones used
- by psignal().
-
- If the supplied signal number is within the valid range of indices
- for the sys_siglist, but no message is available for the particular
- signal number, then returns the string "Signal NUM", where NUM is the
- signal number.
-
- If the supplied signal number is not a valid index into sys_siglist,
- returns NULL.
-
- The returned string is only guaranteed to be valid only until the
- next call to strsignal.
-
-*/
-
-const char *
-strsignal (signo)
- int signo;
-{
- const char *msg;
- static char buf[32];
-
-#ifdef NEED_sys_siglist
-
- if (signal_names == NULL)
- {
- init_signal_tables ();
- }
-
-#endif
-
- if ((signo < 0) || (signo >= sys_nsig))
- {
- /* Out of range, just return NULL */
- msg = NULL;
- }
- else if ((sys_siglist == NULL) || (sys_siglist[signo] == NULL))
- {
- /* In range, but no sys_siglist or no entry at this index. */
- sprintf (buf, "Signal %d", signo);
- msg = (const char *) buf;
- }
- else
- {
- /* In range, and a valid message. Just return the message. */
- msg = (const char *) sys_siglist[signo];
- }
-
- return (msg);
-}
-
-
-/*
-
-NAME
-
- strsigno -- map an signal number to a symbolic name string
-
-SYNOPSIS
-
- const char *strsigno (int signo)
-
-DESCRIPTION
-
- Given an signal number, returns a pointer to a string containing
- the symbolic name of that signal number, as found in <signal.h>.
-
- If the supplied signal number is within the valid range of indices
- for symbolic names, but no name is available for the particular
- signal number, then returns the string "Signal NUM", where NUM is
- the signal number.
-
- If the supplied signal number is not within the range of valid
- indices, then returns NULL.
-
-BUGS
-
- The contents of the location pointed to are only guaranteed to be
- valid until the next call to strsigno.
-
-*/
-
-const char *
-strsigno (signo)
- int signo;
-{
- const char *name;
- static char buf[32];
-
- if (signal_names == NULL)
- {
- init_signal_tables ();
- }
-
- if ((signo < 0) || (signo >= num_signal_names))
- {
- /* Out of range, just return NULL */
- name = NULL;
- }
- else if ((signal_names == NULL) || (signal_names[signo] == NULL))
- {
- /* In range, but no signal_names or no entry at this index. */
- sprintf (buf, "Signal %d", signo);
- name = (const char *) buf;
- }
- else
- {
- /* In range, and a valid name. Just return the name. */
- name = signal_names[signo];
- }
-
- return (name);
-}
-
-
-/*
-
-NAME
-
- strtosigno -- map a symbolic signal name to a numeric value
-
-SYNOPSIS
-
- int strtosigno (char *name)
-
-DESCRIPTION
-
- Given the symbolic name of a signal, map it to a signal number.
- If no translation is found, returns 0.
-
-*/
-
-int
-strtosigno (name)
- const char *name;
-{
- int signo = 0;
-
- if (name != NULL)
- {
- if (signal_names == NULL)
- {
- init_signal_tables ();
- }
- for (signo = 0; signo < num_signal_names; signo++)
- {
- if ((signal_names[signo] != NULL) &&
- (strcmp (name, signal_names[signo]) == 0))
- {
- break;
- }
- }
- if (signo == num_signal_names)
- {
- signo = 0;
- }
- }
- return (signo);
-}
-
-
-/*
-
-NAME
-
- psignal -- print message about signal to stderr
-
-SYNOPSIS
-
- void psignal (unsigned signo, char *message);
-
-DESCRIPTION
-
- Print to the standard error the message, followed by a colon,
- followed by the description of the signal specified by signo,
- followed by a newline.
-*/
-
-#ifdef NEED_psignal
-
-void
-psignal (signo, message)
- unsigned signo;
- char *message;
-{
- if (signal_names == NULL)
- {
- init_signal_tables ();
- }
- if ((signo <= 0) || (signo >= sys_nsig))
- {
- fprintf (stderr, "%s: unknown signal\n", message);
- }
- else
- {
- fprintf (stderr, "%s: %s\n", message, sys_siglist[signo]);
- }
-}
-
-#endif /* NEED_psignal */
-
-
-/* A simple little main that does nothing but print all the signal translations
- if MAIN is defined and this file is compiled and linked. */
-
-#ifdef MAIN
-
-#include <stdio.h>
-
-int
-main ()
-{
- int signo;
- int maxsigno;
- const char *name;
- const char *msg;
-
- maxsigno = signo_max ();
- printf ("%d entries in names table.\n", num_signal_names);
- printf ("%d entries in messages table.\n", sys_nsig);
- printf ("%d is max useful index.\n", maxsigno);
-
- /* Keep printing values until we get to the end of *both* tables, not
- *either* table. Note that knowing the maximum useful index does *not*
- relieve us of the responsibility of testing the return pointer for
- NULL. */
-
- for (signo = 0; signo <= maxsigno; signo++)
- {
- name = strsigno (signo);
- name = (name == NULL) ? "<NULL>" : name;
- msg = strsignal (signo);
- msg = (msg == NULL) ? "<NULL>" : msg;
- printf ("%-4d%-18s%s\n", signo, name, msg);
- }
-
- return 0;
-}
-
-#endif
diff --git a/gnu/lib/libg++/libio/PlotFile.cc b/gnu/lib/libg++/libio/PlotFile.cc
deleted file mode 100644
index a5af5c1..0000000
--- a/gnu/lib/libg++/libio/PlotFile.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-// This may look like C code, but it is really -*- C++ -*-
-/*
-Copyright (C) 1988, 1992, 1993 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
- converted to use iostream library by Per Bothner (bothner@cygnus.com)
-
-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 GCC 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. */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <PlotFile.h>
-
-/*
- PlotFile implementation module
-*/
-
-
-PlotFile& PlotFile:: cmd(char c)
-{
- ofstream::put(c);
- return *this;
-}
-
-PlotFile& PlotFile:: operator<<(const int x)
-{
-#if defined(convex)
- ofstream::put((char)(x>>8));
- ofstream::put((char)(x&0377));
-#else
- ofstream::put((char)(x&0377));
- ofstream::put((char)(x>>8));
-#endif
- return *this;
-}
-
-PlotFile& PlotFile:: operator<<(const char *s)
-{
- *(ofstream*)this << s;
- return *this;
-}
-
-
-PlotFile& PlotFile:: arc(const int xi, const int yi,
- const int x0, const int y0,
- const int x1, const int y1)
-{
- return cmd('a') << xi << yi << x0 << y0 << x1 << y1;
-}
-
-
-PlotFile& PlotFile:: box(const int x0, const int y0,
- const int x1, const int y1)
-{
- line(x0, y0, x0, y1);
- line(x0, y1, x1, y1);
- line(x1, y1, x1, y0);
- return line(x1, y0, x0, y0);
-}
-
-PlotFile& PlotFile:: circle(const int x, const int y, const int r)
-{
- return cmd('c') << x << y << r;
-}
-
-PlotFile& PlotFile:: cont(const int xi, const int yi)
-{
- return cmd('n') << xi << yi;
-}
-
-PlotFile& PlotFile:: dot(const int xi, const int yi, const int dx,
- int n, const int* pat)
-{
- cmd('d') << xi << yi << dx << n;
- while (n-- > 0) *this << *pat++;
- return *this;
-}
-
-PlotFile& PlotFile:: erase()
-{
- return cmd('e');
-}
-
-PlotFile& PlotFile:: label(const char* s)
-{
- return cmd('t') << s << "\n";
-}
-
-PlotFile& PlotFile:: line(const int x0, const int y0,
- const int x1, const int y1)
-{
- return cmd('l') << x0 << y0 << x1 << y1;
-}
-
-PlotFile& PlotFile:: linemod(const char* s)
-{
- return cmd('f') << s << "\n";
-}
-
-PlotFile& PlotFile:: move(const int xi, const int yi)
-{
- return cmd('m') << xi << yi;
-}
-
-PlotFile& PlotFile:: point(const int xi, const int yi)
-{
- return cmd('p') << xi << yi;
-}
-
-PlotFile& PlotFile:: space(const int x0, const int y0,
- const int x1, const int y1)
-{
- return cmd('s') << x0 << y0 << x1 << y1;
-}
diff --git a/gnu/lib/libg++/libio/SFile.cc b/gnu/lib/libg++/libio/SFile.cc
deleted file mode 100644
index 24f668b..0000000
--- a/gnu/lib/libg++/libio/SFile.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/*
-Copyright (C) 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.
-*/
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include <SFile.h>
-
-SFile::SFile(const char *filename, int size, int mode, int prot)
-: fstream(filename, mode, prot)
-{
- sz = size;
-}
-
-SFile::SFile(int fd, int size)
-: fstream(fd)
-{
- sz = size;
-}
-
-void SFile::open(const char *name, int size, int mode, int prot)
-{
- fstream::open(name, mode, prot);
- sz = size;
-}
-
-SFile& SFile::get(void* x)
-{
- read(x, sz);
- return *this;
-}
-
-SFile& SFile::put(void* x)
-{
- write(x, sz);
- return *this;
-}
-
-SFile& SFile::operator[](long i)
-{
- if (rdbuf()->sseekoff(i * sz, ios::beg) == EOF)
- set(ios::badbit);
- return *this;
-}
diff --git a/gnu/lib/libg++/libio/builtinbuf.cc b/gnu/lib/libg++/libio/builtinbuf.cc
deleted file mode 100644
index d6b9ebb..0000000
--- a/gnu/lib/libg++/libio/builtinbuf.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#ifdef __GNUC__
-#pragma implementation
-#endif
-#define _STREAM_COMPAT
-#include "builtinbuf.h"
-#include "iostreamP.h"
-
-int builtinbuf::overflow(int ch) { return (*_jumps->__overflow)(this, ch); }
-
-int builtinbuf::underflow() { return (*_jumps->__underflow)(this); }
-
-streamsize builtinbuf::xsgetn(char* buf, streamsize n)
-{ return (*_jumps->__xsgetn)(this, buf, n); }
-
-streamsize builtinbuf::xsputn(const char* buf, streamsize n)
-{ return _jumps->__xsputn (this, buf, n); }
-
-int builtinbuf::doallocate() { return _jumps->__doallocate(this); }
-
-builtinbuf::~builtinbuf() { _jumps->__finish(this); }
-
-int builtinbuf::sync() { return _jumps->__sync(this); }
-
-streambuf* builtinbuf::setbuf(char *buf, int n)
-{ return _jumps->__setbuf (this, buf, n) == 0 ? this : NULL; }
-
-streampos builtinbuf::seekoff(streamoff off, _seek_dir dir, int mode)
-{
- return _jumps->__seekoff (this, off, convert_to_seekflags(dir, mode));
-}
-
-streampos builtinbuf::seekpos(streampos pos, int mode)
-{
- int flags = 0;
- if (!(mode & ios::in))
- flags |= _IO_seek_not_in;
- if (!(mode & ios::out))
- flags |= _IO_seek_not_out;
- return _jumps->__seekpos(this, pos, (_IO_seekflags)flags);
-}
-
-int builtinbuf::pbackfail(int c)
-{ return _jumps->__pbackfail(this, c); }
-
-streamsize builtinbuf::sys_read(char* buf, streamsize size)
-{ return _jumps->__read(this, buf, size); }
-
-streampos builtinbuf::sys_seek(streamoff off, _seek_dir dir)
-{ return _jumps->__seek(this, off, dir); }
-
-streamsize builtinbuf::sys_write(const char* buf, streamsize size)
-{ return _jumps->__write(this, buf, size); }
-
-int builtinbuf::sys_stat(void* buf) // Actually, a (struct stat*)
-{ return _jumps->__stat(this, buf); }
-
-int builtinbuf::sys_close()
-{ return _jumps->__close(this); }
-
-#ifdef _STREAM_COMPAT
-/* These methods are TEMPORARY, for binary compatibility! */
-#include <stdlib.h>
-void ios::_IO_fix_vtable() const
-{
- abort ();
-}
-
-void ios::_IO_fix_vtable()
-{
- ((const ios*) this)->_IO_fix_vtable();
-}
-#endif
diff --git a/gnu/lib/libg++/libio/cleanup.c b/gnu/lib/libg++/libio/cleanup.c
deleted file mode 100644
index 35c2ef1..0000000
--- a/gnu/lib/libg++/libio/cleanup.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "libioP.h"
-#if _G_HAVE_ATEXIT
-#include <stdlib.h>
-
-typedef void (*voidfunc) __P((void));
-
-static void _IO_register_cleanup ()
-{
- atexit ((voidfunc)_IO_cleanup);
- _IO_cleanup_registration_needed = 0;
-}
-
-void (*_IO_cleanup_registration_needed)() = _IO_register_cleanup;
-#endif /* _G_HAVE_ATEXIT */
diff --git a/gnu/lib/libg++/libio/editbuf.cc b/gnu/lib/libg++/libio/editbuf.cc
deleted file mode 100644
index 87358fa..0000000
--- a/gnu/lib/libg++/libio/editbuf.cc
+++ /dev/null
@@ -1,717 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License.
-
-Written by Per Bothner (bothner@cygnus.com). */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include "libioP.h"
-#include "editbuf.h"
-#include <stddef.h>
-#include <stdlib.h>
-
-/* NOTE: Some of the code here is taken from GNU emacs */
-/* Hence this file falls under the GNU License! */
-
-// Invariants for edit_streambuf:
-// An edit_streambuf is associated with a specific edit_string,
-// which again is a sub-string of a specific edit_buffer.
-// An edit_streambuf is always in either get mode or put mode, never both.
-// In get mode, gptr() is the current position,
-// and pbase(), pptr(), and epptr() are all NULL.
-// In put mode, pptr() is the current position,
-// and eback(), gptr(), and egptr() are all NULL.
-// Any edit_streambuf that is actively doing insertion (as opposed to
-// replacing) // must have its pptr() pointing to the start of the gap.
-// Only one edit_streambuf can be actively inserting into a specific
-// edit_buffer; the edit_buffer's _writer field points to that edit_streambuf.
-// That edit_streambuf "owns" the gap, and the actual start of the
-// gap is the pptr() of the edit_streambuf; the edit_buffer::_gap_start pointer
-// will only be updated on an edit_streambuf::overflow().
-
-int edit_streambuf::truncate()
-{
- str->buffer->delete_range(str->buffer->tell((buf_char*)pptr()),
- str->buffer->tell(str->end));
- return 0;
-}
-
-#ifdef OLD_STDIO
-inline void disconnect_gap_from_file(edit_buffer* buffer, FILE* fp)
-{
- if (buffer->gap_start_ptr != &fp->__bufp)
- return;
- buffer->gap_start_normal = fp->__bufp;
- buffer->gap_start_ptr = &buffer->gap_start_normal;
-}
-#endif
-
-void edit_streambuf::flush_to_buffer(edit_buffer* buffer)
-{
- if (pptr() > buffer->_gap_start && pptr() < buffer->gap_end())
- buffer->_gap_start = pptr();
-}
-
-void edit_streambuf::disconnect_gap_from_file(edit_buffer* buffer)
-{
- if (buffer->_writer != this) return;
- flush_to_buffer(buffer);
- setp(pptr(),pptr());
- buffer->_writer = NULL;
-}
-
-buf_index edit_buffer::tell(buf_char *ptr)
-{
- if (ptr <= gap_start())
- return ptr - data;
- else
- return ptr - gap_end() + size1();
-}
-
-#if 0
-buf_index buf_cookie::tell()
-{
- return str->buffer->tell(file->__bufp);
-}
-#endif
-
-buf_index edit_buffer::tell(edit_mark*mark)
-{
- return tell(data + mark->index_in_buffer(this));
-}
-
-// adjust the position of the gap
-
-void edit_buffer::move_gap(buf_offset pos)
-{
- if (pos < size1())
- gap_left (pos);
- else if (pos > size1())
- gap_right (pos);
-}
-
-void edit_buffer::gap_left (int pos)
-{
- register buf_char *to, *from;
- register int i;
- int new_s1;
-
- i = size1();
- from = gap_start();
- to = from + gap_size();
- new_s1 = size1();
-
- /* Now copy the characters. To move the gap down,
- copy characters up. */
-
- for (;;)
- {
- /* I gets number of characters left to copy. */
- i = new_s1 - pos;
- if (i == 0)
- break;
-#if 0
- /* If a quit is requested, stop copying now.
- Change POS to be where we have actually moved the gap to. */
- if (QUITP)
- {
- pos = new_s1;
- break;
- }
-#endif
- /* Move at most 32000 chars before checking again for a quit. */
- if (i > 32000)
- i = 32000;
- new_s1 -= i;
- while (--i >= 0)
- *--to = *--from;
- }
-
- /* Adjust markers, and buffer data structure, to put the gap at POS.
- POS is where the loop above stopped, which may be what was specified
- or may be where a quit was detected. */
- adjust_markers (pos << 1, size1() << 1, gap_size(), data);
-#ifndef OLD_STDIO
- _gap_start = data + pos;
-#else
- if (gap_start_ptr == &gap_start_normal)
- gap_start_normal = data + pos;
-#endif
- __gap_end_pos = to - data;
-/* QUIT;*/
-}
-
-void edit_buffer::gap_right (int pos)
-{
- register buf_char *to, *from;
- register int i;
- int new_s1;
-
- i = size1();
- to = gap_start();
- from = i + gap_end();
- new_s1 = i;
-
- /* Now copy the characters. To move the gap up,
- copy characters down. */
-
- while (1)
- {
- /* I gets number of characters left to copy. */
- i = pos - new_s1;
- if (i == 0)
- break;
-#if 0
- /* If a quit is requested, stop copying now.
- Change POS to be where we have actually moved the gap to. */
- if (QUITP)
- {
- pos = new_s1;
- break;
- }
-#endif
- /* Move at most 32000 chars before checking again for a quit. */
- if (i > 32000)
- i = 32000;
- new_s1 += i;
- while (--i >= 0)
- *to++ = *from++;
- }
-
- adjust_markers ((size1() + gap_size()) << 1, (pos + gap_size()) << 1,
- - gap_size(), data);
-#ifndef OLD_STDIO
- _gap_start = data+pos;
-#else
- if (gap_start_ptr == &gap_start_normal)
- gap_start_normal = data + pos;
-#endif
- __gap_end_pos = from - data;
-/* QUIT;*/
-}
-
-/* make sure that the gap in the current buffer is at least k
- characters wide */
-
-void edit_buffer::make_gap(buf_offset k)
-{
- register buf_char *p1, *p2, *lim;
- buf_char *old_data = data;
- int s1 = size1();
-
- if (gap_size() >= k)
- return;
-
- /* Get more than just enough */
- if (buf_size > 1000) k += 2000;
- else k += /*200;*/ 20; // for testing!
-
- p1 = (buf_char *) realloc (data, s1 + size2() + k);
- if (p1 == 0)
- abort(); /*memory_full ();*/
-
- k -= gap_size(); /* Amount of increase. */
-
- /* Record new location of text */
- data = p1;
-
- /* Transfer the new free space from the end to the gap
- by shifting the second segment upward */
- p2 = data + buf_size;
- p1 = p2 + k;
- lim = p2 - size2();
- while (lim < p2)
- *--p1 = *--p2;
-
- /* Finish updating text location data */
- __gap_end_pos += k;
-
-#ifndef OLD_STDIO
- _gap_start = data + s1;
-#else
- if (gap_start_ptr == &gap_start_normal)
- gap_start_normal = data + s1;
-#endif
-
- /* adjust markers */
- adjust_markers (s1 << 1, (buf_size << 1) + 1, k, old_data);
- buf_size += k;
-}
-
-/* Add `amount' to the position of every marker in the current buffer
- whose current position is between `from' (exclusive) and `to' (inclusive).
- Also, any markers past the outside of that interval, in the direction
- of adjustment, are first moved back to the near end of the interval
- and then adjusted by `amount'. */
-
-void edit_buffer::adjust_markers(register mark_pointer low,
- register mark_pointer high,
- int amount, buf_char *old_data)
-{
- register struct edit_mark *m;
- register mark_pointer mpos;
- /* convert to mark_pointer */
- amount <<= 1;
-
- if (_writer)
- _writer->disconnect_gap_from_file(this);
-
- for (m = mark_list(); m != NULL; m = m->chain)
- {
- mpos = m->_pos;
- if (amount > 0)
- {
- if (mpos > high && mpos < high + amount)
- mpos = high + amount;
- }
- else
- {
- if (mpos > low + amount && mpos <= low)
- mpos = low + amount;
- }
- if (mpos > low && mpos <= high)
- mpos += amount;
- m->_pos = mpos;
- }
-
- // Now adjust files
- edit_streambuf *file;
-
- for (file = files; file != NULL; file = file->next) {
- mpos = file->current() - old_data;
- if (amount > 0)
- {
- if (mpos > high && mpos < high + amount)
- mpos = high + amount;
- }
- else
- {
- if (mpos > low + amount && mpos <= low)
- mpos = low + amount;
- }
- if (mpos > low && mpos <= high)
- mpos += amount;
- char* new_pos = data + mpos;
- file->set_current(new_pos, file->is_reading());
- }
-}
-
-#if 0
-stdio_
- __off == index at start of buffer (need only be valid after seek ? )
- __buf ==
-
-if read/read_delete/overwrite mode:
- __endp <= min(*gap_start_ptr, edit_string->end->ptr(buffer))
-
-if inserting:
- must have *gap_start_ptr == __bufp && *gap_start_ptr+gap == __endp
- file->edit_string->end->ptr(buffer) == *gap_start_ptr+end
-if write_mode:
- if before gap
-#endif
-
-int edit_streambuf::underflow()
-{
- if (!(_mode & ios::in))
- return EOF;
- struct edit_buffer *buffer = str->buffer;
- if (!is_reading()) { // Must switch from put to get mode.
- disconnect_gap_from_file(buffer);
- set_current(pptr(), 1);
- }
- buf_char *str_end = str->end->ptr(buffer);
- retry:
- if (gptr() < egptr()) {
- return *gptr();
- }
- if ((buf_char*)gptr() == str_end)
- return EOF;
- if (str_end <= buffer->gap_start()) {
- setg(eback(), gptr(), str_end);
- goto retry;
- }
- if (gptr() < buffer->gap_start()) {
- setg(eback(), gptr(), buffer->gap_start());
- goto retry;
- }
- if (gptr() == buffer->gap_start()) {
- disconnect_gap_from_file(buffer);
-// fp->__offset += fp->__bufp - fp->__buffer;
- setg(buffer->gap_end(), buffer->gap_end(), str_end);
- }
- else
- setg(eback(), gptr(), str_end);
- goto retry;
-}
-
-int edit_streambuf::overflow(int ch)
-{
- if (_mode == ios::in)
- return EOF;
- struct edit_buffer *buffer = str->buffer;
- flush_to_buffer(buffer);
- if (ch == EOF)
- return 0;
- if (is_reading()) { // Must switch from get to put mode.
- set_current(gptr(), 0);
- }
- buf_char *str_end = str->end->ptr(buffer);
- retry:
- if (pptr() < epptr()) {
- *pptr() = ch;
- pbump(1);
- return (unsigned char)ch;
- }
- if ((buf_char*)pptr() == str_end || inserting()) {
- /* insert instead */
- if (buffer->_writer)
- buffer->_writer->flush_to_buffer(); // Redundant?
- buffer->_writer = NULL;
- if (pptr() >= buffer->gap_end())
- buffer->move_gap(pptr() - buffer->gap_size());
- else
- buffer->move_gap(pptr());
- buffer->make_gap(1);
- setp(buffer->gap_start(), buffer->gap_end());
- buffer->_writer = this;
- *pptr() = ch;
- pbump(1);
- return (unsigned char)ch;
- }
- if (str_end <= buffer->gap_start()) {
- // Entire string is left of gap.
- setp(pptr(), str_end);
- }
- else if (pptr() < buffer->gap_start()) {
- // Current pos is left of gap.
- setp(pptr(), buffer->gap_start());
- goto retry;
- }
- else if (pptr() == buffer->gap_start()) {
- // Current pos is at start of gap; move to end of gap.
-// disconnect_gap_from_file(buffer);
- setp(buffer->gap_end(), str_end);
-// __offset += __bufp - __buffer;
- }
- else {
- // Otherwise, current pos is right of gap.
- setp(pptr(), str_end);
- }
- goto retry;
-}
-
-void edit_streambuf::set_current(char *new_pos, int reading)
-{
- if (reading) {
- setg(new_pos, new_pos, new_pos);
- setp(NULL, NULL);
- }
- else {
- setg(NULL, NULL, NULL);
- setp(new_pos, new_pos);
- }
-}
-
-// Called by fseek(fp, pos, whence) if fp is bound to a edit_buffer.
-
-streampos edit_streambuf::seekoff(streamoff offset, _seek_dir dir,
- int mode /* =ios::in|ios::out*/)
-{
- struct edit_buffer *buffer = str->buffer;
- disconnect_gap_from_file(buffer);
- buf_index cur_pos = buffer->tell((buf_char*)current());;
- buf_index start_pos = buffer->tell(str->start);
- buf_index end_pos = buffer->tell(str->end);
- switch (dir) {
- case ios::beg:
- offset += start_pos;
- break;
- case ios::cur:
- offset += cur_pos;
- break;
- case ios::end:
- offset += end_pos;
- break;
- }
- if (offset < start_pos || offset > end_pos)
- return EOF;
- buf_char *new_pos = buffer->data + offset;
- buf_char* gap_start = buffer->gap_start();
- if (new_pos > gap_start) {
- buf_char* gap_end = buffer->gap_end();
- new_pos += gap_end - gap_start;
- if (new_pos >= buffer->data + buffer->buf_size) abort(); // Paranoia.
- }
- set_current(new_pos, is_reading());
- return EOF;
-}
-
-#if 0
-int buf_seek(void *arg_cookie, fpos_t * pos, int whence)
-{
- struct buf_cookie *cookie = arg_cookie;
- FILE *file = cookie->file;
- struct edit_buffer *buffer = cookie->str->buffer;
- buf_char *str_start = cookie->str->start->ptr(buffer);
- disconnect_gap_from_file(buffer, cookie->file);
- fpos_t cur_pos, new_pos;
- if (file->__bufp <= *buffer->gap_start_ptr
- || str_start >= buffer->__gap_end)
- cur_pos = str_start - file->__bufp;
- else
- cur_pos =
- (*buffer->gap_start_ptr - str_start) + (file->__bufp - __gap_end);
- end_pos = ...;
- switch (whence) {
- case SEEK_SET:
- new_pos = *pos;
- break;
- case SEEK_CUR:
- new_pos = cur_pos + *pos;
- break;
- case SEEK_END:
- new_pos = end_pos + *pos;
- break;
- }
- if (new_pos > end_pos) {
- seek to end_pos;
- insert_nulls(new_pos - end_pos);
- return;
- }
- if (str_start + new_pos <= *gap_start_ptr &* *gap_start_ptr < end) {
- __buffer = str_start;
- __off = 0;
- __bufp = str_start + new_pos;
- file->__get_limit =
- *buffer->gap_start_ptr; /* what if gap_start_ptr == &bufp ??? */
- } else if () {
-
- }
- *pos = new_pos;
-}
-#endif
-
-/* Delete characters from `from' up to (but not incl) `to' */
-
-void edit_buffer::delete_range (buf_index from, buf_index to)
-{
- register int numdel;
-
- if ((numdel = to - from) <= 0)
- return;
-
- /* Make sure the gap is somewhere in or next to what we are deleting */
- if (from > size1())
- gap_right (from);
- if (to < size1())
- gap_left (to);
-
- /* Relocate all markers pointing into the new, larger gap
- to point at the end of the text before the gap. */
- adjust_markers ((to + gap_size()) << 1, (to + gap_size()) << 1,
- - numdel - gap_size(), data);
-
- __gap_end_pos = to + gap_size();
- _gap_start = data + from;
-}
-
-void edit_buffer::delete_range(struct edit_mark *start, struct edit_mark *end)
-{
- delete_range(tell(start), tell(end));
-}
-
-void buf_delete_chars(struct edit_buffer *buf, struct edit_mark *mark, size_t count)
-{
- abort();
-}
-
-edit_streambuf::edit_streambuf(edit_string* bstr, int mode)
-{
- _mode = mode;
- str = bstr;
- edit_buffer* buffer = bstr->buffer;
- next = buffer->files;
- buffer->files = this;
- char* buf_ptr = bstr->start->ptr(buffer);
- _inserting = 0;
-// setb(buf_ptr, buf_ptr, 0);
- set_current(buf_ptr, !(mode & ios::out+ios::trunc+ios::app));
- if (_mode & ios::trunc)
- truncate();
- if (_mode & ios::ate)
- seekoff(0, ios::end);
-}
-
-// Called by fclose(fp) if fp is bound to a edit_buffer.
-
-#if 0
-static int buf_close(void *arg)
-{
- register struct buf_cookie *cookie = arg;
- struct edit_buffer *buffer = cookie->str->buffer;
- struct buf_cookie **ptr;
- for (ptr = &buffer->files; *ptr != cookie; ptr = &(*ptr)->next) ;
- *ptr = cookie->next;
- disconnect_gap_from_file(buffer, cookie->file);
- free (cookie);
- return 0;
-}
-#endif
-
-edit_streambuf::~edit_streambuf()
-{
- if (_mode == ios::out)
- truncate();
- // Unlink this from list of files associated with bstr->buffer.
- edit_streambuf **ptr = &str->buffer->files;
- for (; *ptr != this; ptr = &(*ptr)->next) { }
- *ptr = next;
-
- disconnect_gap_from_file(str->buffer);
-}
-
-edit_buffer::edit_buffer()
-{
- buf_size = /*200;*/ 15; /* for testing! */
- data = (buf_char*)malloc(buf_size);
- files = NULL;
-#ifndef OLD_STDIO
- _gap_start = data;
- _writer = NULL;
-#else
- gap_start_normal = data;
- gap_start_ptr = &gap_start_normal;
-#endif
- __gap_end_pos = buf_size;
- start_mark.chain = &end_mark;
- start_mark._pos = 0;
- end_mark.chain = NULL;
- end_mark._pos = 2 * buf_size + 1;
-}
-
-// Allocate a new mark, which is adjusted by 'delta' bytes from 'this'.
-// Restrict new mark to lie within 'str'.
-
-edit_mark::edit_mark(struct edit_string *str, long delta)
-{
- struct edit_buffer *buf = str->buffer;
- chain = buf->start_mark.chain;
- buf->start_mark.chain = this;
- mark_pointer size1 = buf->size1() << 1;
- int gap_size = buf->gap_size() << 1;
- delta <<= 1;
-
- // check if new and old marks are opposite sides of gap
- if (_pos <= size1 && _pos + delta > size1)
- delta += gap_size;
- else if (_pos >= size1 + gap_size && _pos + delta < size1 + gap_size)
- delta -= gap_size;
-
- _pos = _pos + delta;
- if (_pos < str->start->_pos & ~1)
- _pos = (str->start->_pos & ~ 1) + (_pos & 1);
- else if (_pos >= str->end->_pos)
- _pos = (str->end->_pos & ~ 1) + (_pos & 1);
-}
-
-// A (slow) way to find the buffer a mark belongs to.
-
-edit_buffer * edit_mark::buffer()
-{
- struct edit_mark *mark;
- for (mark = this; mark->chain != NULL; mark = mark->chain) ;
- // Assume that the last mark on the chain is the end_mark.
- return (edit_buffer *)((char*)mark - offsetof(edit_buffer, end_mark));
-}
-
-edit_mark::~edit_mark()
-{
- // Must unlink mark from chain of owning buffer
- struct edit_buffer *buf = buffer();
- if (this == &buf->start_mark || this == &buf->end_mark) abort();
- edit_mark **ptr;
- for (ptr = &buf->start_mark.chain; *ptr != this; ptr = &(*ptr)->chain) ;
- *ptr = this->chain;
-}
-
-int edit_string::length() const
-{
- ptrdiff_t delta = end->ptr(buffer) - start->ptr(buffer);
- if (end->ptr(buffer) <= buffer->gap_start() ||
- start->ptr(buffer) >= buffer->gap_end())
- return delta;
- return delta - buffer->gap_size();
-}
-
-buf_char * edit_string::copy_bytes(int *lenp) const
-{
- char *new_str;
- int len1, len2;
- buf_char *start1, *start2;
- start1 = start->ptr(buffer);
- if (end->ptr(buffer) <= buffer->gap_start()
- || start->ptr(buffer) >= buffer->gap_end()) {
- len1 = end->ptr(buffer) - start1;
- len2 = 0;
- start2 = NULL; // To avoid a warning from g++.
- }
- else {
- len1 = buffer->gap_start() - start1;
- start2 = buffer->gap_end();
- len2 = end->ptr(buffer) - start2;
- }
- new_str = (char*)malloc(len1 + len2 + 1);
- memcpy(new_str, start1, len1);
- if (len2 > 0) memcpy(new_str + len1, start2, len2);
- new_str[len1+len2] = '\0';
- *lenp = len1+len2;
- return new_str;
-}
-
-// Replace the buf_chars in 'this' with ones from 'src'.
-// Equivalent to deleting this, then inserting src, except tries
-// to leave marks in place: Marks whose offset from the start
-// of 'this' is less than 'src->length()' will still have the
-// same offset in 'this' when done.
-
-void edit_string::assign(struct edit_string *src)
-{
- edit_streambuf dst_file(this, ios::out);
- if (buffer == src->buffer /*&& ???*/) { /* overly conservative */
- int src_len;
- buf_char *new_str;
- new_str = src->copy_bytes(&src_len);
- dst_file.sputn(new_str, src_len);
- free (new_str);
- } else {
- edit_streambuf src_file(src, ios::in);
- for ( ; ; ) {
- int ch = src_file.sbumpc();
- if (ch == EOF) break;
- dst_file.sputc(ch);
- }
- }
-}
diff --git a/gnu/lib/libg++/libio/filebuf.cc b/gnu/lib/libg++/libio/filebuf.cc
deleted file mode 100644
index 6290636..0000000
--- a/gnu/lib/libg++/libio/filebuf.cc
+++ /dev/null
@@ -1,199 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License.
-
-Written by Per Bothner (bothner@cygnus.com). */
-
-#include "iostreamP.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "builtinbuf.h"
-
-void filebuf::init()
-{
- _IO_file_init(this);
-}
-
-filebuf::filebuf()
-{
- _IO_file_init(this);
-}
-
-/* This is like "new filebuf()", but it uses the _IO_file_jump jumptable,
- for eficiency. */
-
-filebuf* filebuf::__new()
-{
- filebuf *fb = new filebuf;
- fb->_jumps = &_IO_file_jumps;
- fb->_vtable() = builtinbuf_vtable;
- return fb;
-}
-
-filebuf::filebuf(int fd)
-{
- _IO_file_init(this);
- _IO_file_attach(this, fd);
-}
-
-filebuf::filebuf(int fd, char* p, int len)
-{
- _IO_file_init(this);
- _IO_file_attach(this, fd);
- setbuf(p, len);
-}
-
-filebuf::~filebuf()
-{
- if (!(xflags() & _IO_DELETE_DONT_CLOSE))
- close();
-
- _un_link();
-}
-
-filebuf* filebuf::open(const char *filename, ios::openmode mode, int prot)
-{
- if (_IO_file_is_open (this))
- return NULL;
- int posix_mode;
- int read_write;
- if (mode & ios::app)
- mode |= ios::out;
- if ((mode & (ios::in|ios::out)) == (ios::in|ios::out)) {
- posix_mode = O_RDWR;
- read_write = 0;
- }
- else if (mode & ios::out)
- posix_mode = O_WRONLY, read_write = _IO_NO_READS;
- else if (mode & (int)ios::in)
- posix_mode = O_RDONLY, read_write = _IO_NO_WRITES;
- else
- posix_mode = 0, read_write = _IO_NO_READS+_IO_NO_WRITES;
- if ((mode & (int)ios::trunc) || mode == (int)ios::out)
- posix_mode |= O_TRUNC;
- if (mode & ios::app)
- posix_mode |= O_APPEND, read_write |= _IO_IS_APPENDING;
- if (!(mode & (int)ios::nocreate) && mode != ios::in)
- posix_mode |= O_CREAT;
- if (mode & (int)ios::noreplace)
- posix_mode |= O_EXCL;
- int fd = ::open(filename, posix_mode, prot);
- if (fd < 0)
- return NULL;
- _fileno = fd;
- xsetflags(read_write, _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
- if (mode & (ios::ate|ios::app)) {
- if (sseekoff(0, ios::end) == EOF)
- return NULL;
- }
- _IO_link_in(this);
- return this;
-}
-
-filebuf* filebuf::open(const char *filename, const char *mode)
-{
- return (filebuf*)_IO_file_fopen(this, filename, mode);
-}
-
-filebuf* filebuf::attach(int fd)
-{
- return (filebuf*)_IO_file_attach(this, fd);
-}
-
-streambuf* filebuf::setbuf(char* p, int len)
-{
- return _IO_file_setbuf(this, p, len) == 0 ? this : NULL;
-}
-
-int filebuf::doallocate() { return _IO_file_doallocate(this); }
-
-int filebuf::overflow(int c)
-{
- return _IO_file_overflow(this, c);
-}
-
-int filebuf::underflow()
-{
- return _IO_file_underflow(this);
-}
-
-int filebuf::do_write(const char *data, int to_do)
-{
- return _IO_do_write(this, data, to_do);
-}
-
-int filebuf::sync()
-{
- return _IO_file_sync(this);
-}
-
-streampos filebuf::seekoff(streamoff offset, _seek_dir dir, int mode)
-{
- return _IO_file_seekoff (this, offset, convert_to_seekflags(dir, mode));
-}
-
-filebuf* filebuf::close()
-{
- return (_IO_file_close_it(this) ? NULL : this);
-}
-
-streamsize filebuf::sys_read(char* buf, streamsize size)
-{
- return _IO_file_read(this, buf, size);
-}
-
-streampos filebuf::sys_seek(streamoff offset, _seek_dir dir)
-{
- return _IO_file_seek(this, offset, dir);
-}
-
-streamsize filebuf::sys_write(const char *buf, streamsize n)
-{
- return _IO_file_write (this, buf, n);
-}
-
-int filebuf::sys_stat(void* st)
-{
- return _IO_file_stat (this, st);
-}
-
-int filebuf::sys_close()
-{
- return _IO_file_close (this);
-}
-
-streamsize filebuf::xsputn(const char *s, streamsize n)
-{
- return _IO_file_xsputn(this, s, n);
-}
-
-streamsize filebuf::xsgetn(char *s, streamsize n)
-{
- // FIXME: OPTIMIZE THIS (specifically, when unbuffered()).
- return streambuf::xsgetn(s, n);
-}
-
-// Non-ANSI AT&T-ism: Default open protection.
-const int filebuf::openprot = 0644;
diff --git a/gnu/lib/libg++/libio/filedoalloc.c b/gnu/lib/libg++/libio/filedoalloc.c
deleted file mode 100644
index ac96d19..0000000
--- a/gnu/lib/libg++/libio/filedoalloc.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/* Modified for GNU iostream by Per Bothner 1991, 1992. */
-
-#define _POSIX_SOURCE
-#include "libioP.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-
-/* If this function pointer is non-zero, we should call it.
- It's supposed to make sure _IO_cleanup gets called on exit.
- We call it from _IO_file_doallocate, since that is likely
- to get called by any program that does buffered I/O. */
-void (*_IO_cleanup_registration_needed)();
-
-/*
- * Allocate a file buffer, or switch to unbuffered I/O.
- * Per the ANSI C standard, ALL tty devices default to line buffered.
- *
- * As a side effect, we set __SOPT or __SNPT (en/dis-able fseek
- * optimisation) right after the _fstat() that finds the buffer size.
- */
-
-int
-_IO_file_doallocate(fp)
- register _IO_FILE *fp;
-{
- register _IO_size_t size;
- int couldbetty;
- register char *p;
- struct stat st;
-
- if (_IO_cleanup_registration_needed)
- (*_IO_cleanup_registration_needed)();
-
- if (fp->_fileno < 0 || fp->_jumps->__stat(fp, &st) < 0)
- {
- couldbetty = 0;
- size = _IO_BUFSIZ;
-#if 0
- /* do not try to optimise fseek() */
- fp->_flags |= __SNPT;
-#endif
- }
- else
- {
- couldbetty = S_ISCHR(st.st_mode);
-#if _IO_HAVE_ST_BLKSIZE
- size = st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize;
-#else
- size = _IO_BUFSIZ;
-#endif
- }
- p = ALLOC_BUF(size);
- if (p == NULL)
- return EOF;
- _IO_setb(fp, p, p+size, 1);
- if (couldbetty && isatty(fp->_fileno))
- fp->_flags |= _IO_LINE_BUF;
- return 1;
-}
diff --git a/gnu/lib/libg++/libio/fileops.c b/gnu/lib/libg++/libio/fileops.c
deleted file mode 100644
index 332a0da..0000000
--- a/gnu/lib/libg++/libio/fileops.c
+++ /dev/null
@@ -1,743 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* written by Per Bothner (bothner@cygnus.com) */
-
-#define _POSIX_SOURCE
-#include "libioP.h"
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
-/* An fstream can be in at most one of put mode, get mode, or putback mode.
- Putback mode is a variant of get mode.
-
- In a filebuf, there is only one current position, instead of two
- separate get and put pointers. In get mode, the current posistion
- is that of gptr(); in put mode that of pptr().
-
- The position in the buffer that corresponds to the position
- in external file system is file_ptr().
- This is normally _IO_read_end, except in putback mode,
- when it is _IO_save_end.
- If the field _fb._offset is >= 0, it gives the offset in
- the file as a whole corresponding to eGptr(). (???)
-
- PUT MODE:
- If a filebuf is in put mode, pbase() is non-NULL and equal to base().
- Also, epptr() == ebuf().
- Also, eback() == gptr() && gptr() == egptr().
- The un-flushed character are those between pbase() and pptr().
- GET MODE:
- If a filebuf is in get or putback mode, eback() != egptr().
- In get mode, the unread characters are between gptr() and egptr().
- The OS file position corresponds to that of egptr().
- PUTBACK MODE:
- Putback mode is used to remember "excess" characters that have
- been sputbackc'd in a separate putback buffer.
- In putback mode, the get buffer points to the special putback buffer.
- The unread characters are the characters between gptr() and egptr()
- in the putback buffer, as well as the area between save_gptr()
- and save_egptr(), which point into the original reserve buffer.
- (The pointers save_gptr() and save_egptr() are the values
- of gptr() and egptr() at the time putback mode was entered.)
- The OS position corresponds to that of save_egptr().
-
- LINE BUFFERED OUTPUT:
- During line buffered output, pbase()==base() && epptr()==base().
- However, ptr() may be anywhere between base() and ebuf().
- This forces a call to filebuf::overflow(int C) on every put.
- If there is more space in the buffer, and C is not a '\n',
- then C is inserted, and pptr() incremented.
-
- UNBUFFERED STREAMS:
- If a filebuf is unbuffered(), the _shortbuf[1] is used as the buffer.
-*/
-
-#define CLOSED_FILEBUF_FLAGS \
- (_IO_IS_FILEBUF+_IO_NO_READS+_IO_NO_WRITES+_IO_TIED_PUT_GET)
-
-
-void
-_IO_file_init(fp)
- register _IO_FILE *fp;
-{
- fp->_offset = _IO_pos_0;
- fp->_IO_file_flags |= CLOSED_FILEBUF_FLAGS;
-
- _IO_link_in(fp);
- fp->_fileno = -1;
-}
-
-int
-_IO_file_close_it(fp)
- register _IO_FILE* fp;
-{
- int status;
- if (!_IO_file_is_open(fp))
- return EOF;
-
- _IO_do_flush (fp);
-
- _IO_unsave_markers(fp);
-
- status = fp->_jumps->__close(fp);
-
- /* Free buffer. */
- _IO_setb(fp, NULL, NULL, 0);
- _IO_setg(fp, NULL, NULL, NULL);
- _IO_setp(fp, NULL, NULL);
-
- _IO_un_link(fp);
- fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
- fp->_fileno = EOF;
- fp->_offset = _IO_pos_0;
-
- return status;
-}
-
-void
-_IO_file_finish(fp)
- register _IO_FILE* fp;
-{
- if (_IO_file_is_open(fp))
- {
- _IO_do_flush (fp);
- if (!(fp->_flags & _IO_DELETE_DONT_CLOSE))
- fp->_jumps->__close(fp);
- }
- _IO_default_finish(fp);
-}
-
-_IO_FILE *
-_IO_file_fopen(fp, filename, mode)
- register _IO_FILE *fp;
- const char *filename;
- const char *mode;
-{
- int oflags = 0, omode;
- int read_write, fdesc;
- int oprot = 0666;
- if (_IO_file_is_open (fp))
- return 0;
- switch (*mode++) {
- case 'r':
- omode = O_RDONLY;
- read_write = _IO_NO_WRITES;
- break;
- case 'w':
- omode = O_WRONLY;
- oflags = O_CREAT|O_TRUNC;
- read_write = _IO_NO_READS;
- break;
- case 'a':
- omode = O_WRONLY;
- oflags = O_CREAT|O_APPEND;
- read_write = _IO_NO_READS|_IO_IS_APPENDING;
- break;
- default:
- errno = EINVAL;
- return NULL;
- }
- if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) {
- omode = O_RDWR;
- read_write &= _IO_IS_APPENDING;
- }
- fdesc = open(filename, omode|oflags, oprot);
- if (fdesc < 0)
- return NULL;
- fp->_fileno = fdesc;
- _IO_mask_flags(fp, read_write,_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
- if (read_write & _IO_IS_APPENDING)
- if (fp->_jumps->__seekoff(fp, (_IO_off_t)0, _IO_seek_end) == _IO_pos_BAD)
- return NULL;
- _IO_link_in(fp);
- return fp;
-}
-
-_IO_FILE*
-_IO_file_attach(fp, fd)
- _IO_FILE *fp;
- int fd;
-{
- if (_IO_file_is_open(fp))
- return NULL;
- fp->_fileno = fd;
- fp->_flags &= ~(_IO_NO_READS+_IO_NO_WRITES);
- fp->_flags |= _IO_DELETE_DONT_CLOSE;
- fp->_offset = _IO_pos_BAD;
- return fp;
-}
-
-int
-_IO_file_setbuf(fp, p, len)
- register _IO_FILE *fp;
- char* p;
- _IO_ssize_t len;
-{
- if (_IO_default_setbuf(fp, p, len) == EOF)
- return EOF;
-
- fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end
- = fp->_IO_buf_base;
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
-
- return 0;
-}
-
-int
-_IO_do_write(fp, data, to_do)
- register _IO_FILE *fp;
- const char* data;
- _IO_size_t to_do;
-{
- _IO_size_t count;
- if (to_do == 0)
- return 0;
- if (fp->_flags & _IO_IS_APPENDING)
- /* On a system without a proper O_APPEND implementation,
- you would need to sys_seek(0, SEEK_END) here, but is
- is not needed nor desirable for Unix- or Posix-like systems.
- Instead, just indicate that offset (before and after) is
- unpredictable. */
- fp->_offset = _IO_pos_BAD;
- else if (fp->_IO_read_end != fp->_IO_write_base)
- {
- _IO_pos_t new_pos = fp->_jumps->__seek(fp, fp->_IO_write_base - fp->_IO_read_end, 1);
- if (new_pos == _IO_pos_BAD)
- return EOF;
- fp->_offset = new_pos;
- }
- count = fp->_jumps->__write(fp, data, to_do);
- if (fp->_cur_column)
- fp->_cur_column = _IO_adjust_column(fp->_cur_column - 1, data, to_do) + 1;
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
- fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base;
- fp->_IO_write_end = (fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) ? fp->_IO_buf_base
- : fp->_IO_buf_end;
- return count != to_do ? EOF : 0;
-}
-
-int
-_IO_file_underflow(fp)
- register _IO_FILE *fp;
-{
- _IO_ssize_t count;
-#if 0
- /* SysV does not make this test; take it out for compatibility */
- if (fp->_flags & _IO_EOF_SEEN)
- return (EOF);
-#endif
-
- if (fp->_flags & _IO_NO_READS)
- return EOF;
- if (fp->_IO_read_ptr < fp->_IO_read_end)
- return *(unsigned char*)fp->_IO_read_ptr;
-
- if (fp->_IO_buf_base == NULL)
- _IO_doallocbuf(fp);
-
- /* Flush all line buffered files before reading. */
- /* FIXME This can/should be moved to genops ?? */
- if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED))
- _IO_flush_all_linebuffered();
-
- _IO_switch_to_get_mode(fp);
-
- count = fp->_jumps->__read(fp, fp->_IO_buf_base,
- fp->_IO_buf_end - fp->_IO_buf_base);
- if (count <= 0)
- {
- if (count == 0)
- fp->_flags |= _IO_EOF_SEEN;
- else
- fp->_flags |= _IO_ERR_SEEN, count = 0;
- }
- fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_buf_base;
- fp->_IO_read_end = fp->_IO_buf_base + count;
- fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end
- = fp->_IO_buf_base;
- if (count == 0)
- return EOF;
- if (fp->_offset != _IO_pos_BAD)
- _IO_pos_adjust(fp->_offset, count);
- return *(unsigned char*)fp->_IO_read_ptr;
-}
-
-int _IO_file_overflow (f, ch)
- register _IO_FILE* f;
- int ch;
-{
- if (f->_flags & _IO_NO_WRITES) /* SET ERROR */
- return EOF;
- /* If current reading or no buffer allocated. */
- if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0)
- {
- /* Allocate a buffer if needed. */
- if (f->_IO_buf_base == 0)
- {
- _IO_doallocbuf(f);
- f->_IO_read_end = f->_IO_buf_base;
- f->_IO_write_ptr = f->_IO_buf_base;
- }
- else /* Must be currently reading. */
- f->_IO_write_ptr = f->_IO_read_ptr;
- f->_IO_write_base = f->_IO_write_ptr;
- f->_IO_write_end = f->_IO_buf_end;
- f->_IO_read_base = f->_IO_read_ptr = f->_IO_read_end;
-
- if (f->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED))
- f->_IO_write_end = f->_IO_write_ptr;
- f->_flags |= _IO_CURRENTLY_PUTTING;
- }
- if (ch == EOF)
- return _IO_do_flush(f);
- if (f->_IO_write_ptr == f->_IO_buf_end ) /* Buffer is really full */
- if (_IO_do_flush(f) == EOF)
- return EOF;
- *f->_IO_write_ptr++ = ch;
- if ((f->_flags & _IO_UNBUFFERED)
- || ((f->_flags & _IO_LINE_BUF) && ch == '\n'))
- if (_IO_do_flush(f) == EOF)
- return EOF;
- return (unsigned char)ch;
-}
-
-int
-_IO_file_sync(fp)
- register _IO_FILE* fp;
-{
- _IO_size_t delta;
- /* char* ptr = cur_ptr(); */
- if (fp->_IO_write_ptr > fp->_IO_write_base)
- if (_IO_do_flush(fp)) return EOF;
- delta = fp->_IO_read_ptr - fp->_IO_read_end;
- if (delta != 0)
- {
-#ifdef TODO
- if (_IO_in_backup(fp))
- delta -= eGptr() - Gbase();
-#endif
- _IO_off_t new_pos = fp->_jumps->__seek(fp, delta, 1);
- if (new_pos == (_IO_off_t)EOF)
- return EOF;
- fp->_offset = new_pos;
- fp->_IO_read_end = fp->_IO_read_ptr;
- }
- /* FIXME: Cleanup - can this be shared? */
- /* setg(base(), ptr, ptr); */
- return 0;
-}
-
-_IO_pos_t
-_IO_file_seekoff(fp, offset, mode)
- register _IO_FILE *fp;
- _IO_off_t offset;
- _IO_seekflags mode;
-{
- _IO_pos_t result;
- _IO_off_t delta, new_offset;
- long count;
- int dir = mode & 3;
-
- if ((mode & _IO_seek_not_in) && (mode & _IO_seek_not_out))
- dir = _IO_seek_cur, offset = 0; /* Don't move any pointers. */
-
- /* Flush unwritten characters.
- (This may do an unneeded write if we seek within the buffer.
- But to be able to switch to reading, we would need to set
- egptr to ptr. That can't be done in the current design,
- which assumes file_ptr() is eGptr. Anyway, since we probably
- end up flushing when we close(), it doesn't make much difference.)
- FIXME: simulate mem-papped files. */
-
- if (fp->_IO_write_ptr > fp->_IO_write_base || _IO_in_put_mode(fp))
- if (_IO_switch_to_get_mode(fp)) return EOF;
-
- if (fp->_IO_buf_base == NULL)
- {
- _IO_doallocbuf(fp);
- _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base);
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
- }
-
- switch (dir)
- {
- case _IO_seek_cur:
- /* Adjust for read-ahead (bytes is buffer). */
- offset -= fp->_IO_read_end - fp->_IO_read_ptr;
- if (fp->_offset == _IO_pos_BAD)
- goto dumb;
- /* Make offset absolute, assuming current pointer is file_ptr(). */
- offset += _IO_pos_as_off(fp->_offset);
-
- dir = _IO_seek_set;
- break;
- case _IO_seek_set:
- break;
- case _IO_seek_end:
- {
- struct stat st;
- if (fp->_jumps->__stat(fp, &st) == 0 && S_ISREG(st.st_mode))
- {
- offset += st.st_size;
- dir = _IO_seek_set;
- }
- else
- goto dumb;
- }
- }
- /* At this point, dir==_IO_seek_set. */
-
- /* If destination is within current buffer, optimize: */
- if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
- && !_IO_in_backup (fp))
- {
- /* Offset relative to start of main get area. */
- _IO_pos_t rel_offset = offset - fp->_offset
- + (fp->_IO_read_end - fp->_IO_read_base);
- if (rel_offset >= 0)
- {
-#if 0
- if (_IO_in_backup(fp))
- _IO_switch_to_main_get_area(fp);
-#endif
- if (rel_offset <= fp->_IO_read_end - fp->_IO_read_base)
- {
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base + rel_offset,
- fp->_IO_read_end);
- _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base);
- return offset;
- }
-#ifdef TODO
- /* If we have streammarkers, seek forward by reading ahead. */
- if (_IO_have_markers(fp))
- {
- int to_skip = rel_offset
- - (fp->_IO_read_ptr - fp->_IO_read_base);
- if (ignore(to_skip) != to_skip)
- goto dumb;
- return offset;
- }
-#endif
- }
-#ifdef TODO
- if (rel_offset < 0 && rel_offset >= Bbase() - Bptr())
- {
- if (!_IO_in_backup(fp))
- _IO_switch_to_backup_area(fp);
- gbump(fp->_IO_read_end + rel_offset - fp->_IO_read_ptr);
- return offset;
- }
-#endif
- }
-
-#ifdef TODO
- _IO_unsave_markers(fp);
-#endif
-
- /* Try to seek to a block boundary, to improve kernel page management. */
- new_offset = offset & ~(fp->_IO_buf_end - fp->_IO_buf_base - 1);
- delta = offset - new_offset;
- if (delta > fp->_IO_buf_end - fp->_IO_buf_base)
- {
- new_offset = offset;
- delta = 0;
- }
- result = fp->_jumps->__seek(fp, new_offset, 0);
- if (result < 0)
- return EOF;
- if (delta == 0)
- count = 0;
- else
- {
- count = fp->_jumps->__read(fp, fp->_IO_buf_base,
- fp->_IO_buf_end - fp->_IO_buf_base);
- if (count < delta)
- {
- /* We weren't allowed to read, but try to seek the remainder. */
- offset = count == EOF ? delta : delta-count;
- dir = _IO_seek_cur;
- goto dumb;
- }
- }
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base+delta, fp->_IO_buf_base+count);
- _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base);
- fp->_offset = result + count;
- _IO_mask_flags(fp, 0, _IO_EOF_SEEN);
- return offset;
- dumb:
-
- _IO_unsave_markers(fp);
- result = fp->_jumps->__seek(fp, offset, dir);
- if (result != EOF)
- _IO_mask_flags(fp, 0, _IO_EOF_SEEN);
- fp->_offset = result;
- _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
- _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base);
- return result;
-}
-
-_IO_ssize_t
-_IO_file_read(fp, buf, size)
- register _IO_FILE* fp;
- void* buf;
- _IO_ssize_t size;
-{
- for (;;)
- {
- _IO_ssize_t count = _IO_read(fp->_fileno, buf, size);
-#ifdef EINTR
- if (count == -1 && errno == EINTR)
- continue;
-#endif
- return count;
- }
-}
-
-_IO_pos_t
-_IO_file_seek(fp, offset, dir)
- _IO_FILE *fp;
- _IO_off_t offset;
- int dir;
-{
- return _IO_lseek(fp->_fileno, offset, dir);
-}
-
-int
-_IO_file_stat(fp, st)
- _IO_FILE *fp;
- void* st;
-{
- return _IO_fstat(fp->_fileno, (struct stat*)st);
-}
-
-int
-_IO_file_close(fp)
- _IO_FILE* fp;
-{
- return _IO_close(fp->_fileno);
-}
-
-_IO_ssize_t
-_IO_file_write(f, data, n)
- register _IO_FILE* f;
- const void* data;
- _IO_ssize_t n;
-{
- _IO_ssize_t to_do = n;
- while (to_do > 0)
- {
- _IO_ssize_t count = _IO_write(f->_fileno, data, to_do);
- if (count == EOF)
- {
-#ifdef EINTR
- if (errno == EINTR)
- continue;
- else
-#endif
- {
- f->_flags |= _IO_ERR_SEEN;
- break;
- }
- }
- to_do -= count;
- data = (void*)((char*)data + count);
- }
- n -= to_do;
- if (f->_offset >= 0)
- f->_offset += n;
- return n;
-}
-
-_IO_size_t
-_IO_file_xsputn(f, data, n)
- _IO_FILE *f;
- const void *data;
- _IO_size_t n;
-{
- register const char *s = data;
- _IO_size_t to_do = n;
- int must_flush = 0;
- _IO_size_t count;
-
- if (n <= 0)
- return 0;
- /* This is an optimized implementation.
- If the amount to be written straddles a block boundary
- (or the filebuf is unbuffered), use sys_write directly. */
-
- /* First figure out how much space is available in the buffer. */
- count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */
- if ((f->_flags & _IO_LINE_BUF) && (f->_flags & _IO_CURRENTLY_PUTTING))
- {
- count = f->_IO_buf_end - f->_IO_write_ptr;
- if (count >= n)
- { register const char *p;
- for (p = s + n; p > s; )
- {
- if (*--p == '\n') {
- count = p - s + 1;
- must_flush = 1;
- break;
- }
- }
- }
- }
- /* Then fill the buffer. */
- if (count > 0)
- {
- if (count > to_do)
- count = to_do;
- if (count > 20) {
- memcpy(f->_IO_write_ptr, s, count);
- s += count;
- }
- else
- {
- register char *p = f->_IO_write_ptr;
- register int i = (int)count;
- while (--i >= 0) *p++ = *s++;
- }
- f->_IO_write_ptr += count;
- to_do -= count;
- }
- if (to_do + must_flush > 0)
- { _IO_size_t block_size, dont_write;
- /* Next flush the (full) buffer. */
- if (__overflow(f, EOF) == EOF)
- return n - to_do;
-
- /* Try to maintain alignment: write a whole number of blocks.
- dont_write is what gets left over. */
- block_size = f->_IO_buf_end - f->_IO_buf_base;
- dont_write = block_size >= 128 ? to_do % block_size : 0;
-
- count = to_do - dont_write;
- if (_IO_do_write(f, s, count) == EOF)
- return n - to_do;
- to_do = dont_write;
-
- /* Now write out the remainder. Normally, this will fit in the
- buffer, but it's somewhat messier for line-buffered files,
- so we let _IO_default_xsputn handle the general case. */
- if (dont_write)
- to_do -= _IO_default_xsputn(f, s+count, dont_write);
- }
- return n - to_do;
-}
-
-#if 0
-/* Work in progress */
-_IO_size_t
-_IO_file_xsgetn(fp, data, n)
- _IO_FILE *fp;
- void *data;
- _IO_size_t n;
-{
- register _IO_size_t more = n;
- register char *s = data;
- for (;;)
- {
- _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr; /* Data available. */
- if (count > 0)
- {
- if (count > more)
- count = more;
- if (count > 20)
- {
- memcpy(s, fp->_IO_read_ptr, count);
- s += count;
- fp->_IO_read_ptr += count;
- }
- else if (count <= 0)
- count = 0;
- else
- {
- register char *p = fp->_IO_read_ptr;
- register int i = (int)count;
- while (--i >= 0) *s++ = *p++;
- fp->_IO_read_ptr = p;
- }
- more -= count;
- }
-#if 0
- if (! _IO_in put_mode (fp)
- && ! _IO_have_markers (fp) && ! IO_have_backup (fp))
- {
- /* This is an optimization of _IO_file_underflow */
- if (fp->_flags & _IO_NO_READS)
- break;
- /* If we're reading a lot of data, don't bother allocating
- a buffer. But if we're only reading a bit, perhaps we should ??*/
- if (count <= 512 && fp->_IO_buf_base == NULL)
- _IO_doallocbuf(fp);
- if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED))
- _IO_flush_all_linebuffered();
-
- _IO_switch_to_get_mode(fp); ???;
- count = fp->_jumps->__read (fp, s, more);
- if (count <= 0)
- {
- if (count == 0)
- fp->_flags |= _IO_EOF_SEEN;
- else
- fp->_flags |= _IO_ERR_SEEN, count = 0;
- }
-
- s += count;
- more -= count;
- }
-#endif
- if (more == 0 || __underflow(fp) == EOF)
- break;
- }
- return n - more;
-}
-#endif
-
-struct _IO_jump_t _IO_file_jumps = {
- _IO_file_overflow,
- _IO_file_underflow,
- _IO_file_xsputn,
- _IO_default_xsgetn,
- _IO_file_read,
- _IO_file_write,
- _IO_file_doallocate,
- _IO_default_pbackfail,
- _IO_file_setbuf,
- _IO_file_sync,
- _IO_file_finish,
- _IO_file_close,
- _IO_file_stat,
- _IO_file_seek,
- _IO_file_seekoff,
- _IO_default_seekpos,
- _IO_default_uflow
-};
diff --git a/gnu/lib/libg++/libio/floatconv.c b/gnu/lib/libg++/libio/floatconv.c
deleted file mode 100644
index acd6998..0000000
--- a/gnu/lib/libg++/libio/floatconv.c
+++ /dev/null
@@ -1,2357 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include <libioP.h>
-#ifdef _IO_USE_DTOA
-/****************************************************************
- *
- * The author of this software is David M. Gay.
- *
- * Copyright (c) 1991 by AT&T.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose without fee is hereby granted, provided that this entire notice
- * is included in all copies of any software which is or includes a copy
- * or modification of this software and in all copies of the supporting
- * documentation for such software.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
- * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
- * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
- *
- ***************************************************************/
-
-/* Some cleaning up by Per Bothner, bothner@cygnus.com, 1992, 1993.
- Re-written to not need static variables
- (except result, result_k, HIWORD, LOWORD). */
-
-/* Please send bug reports to
- David M. Gay
- AT&T Bell Laboratories, Room 2C-463
- 600 Mountain Avenue
- Murray Hill, NJ 07974-2070
- U.S.A.
- dmg@research.att.com or research!dmg
- */
-
-/* strtod for IEEE-, VAX-, and IBM-arithmetic machines.
- *
- * This strtod returns a nearest machine number to the input decimal
- * string (or sets errno to ERANGE). With IEEE arithmetic, ties are
- * broken by the IEEE round-even rule. Otherwise ties are broken by
- * biased rounding (add half and chop).
- *
- * Inspired loosely by William D. Clinger's paper "How to Read Floating
- * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
- *
- * Modifications:
- *
- * 1. We only require IEEE, IBM, or VAX double-precision
- * arithmetic (not IEEE double-extended).
- * 2. We get by with floating-point arithmetic in a case that
- * Clinger missed -- when we're computing d * 10^n
- * for a small integer d and the integer n is not too
- * much larger than 22 (the maximum integer k for which
- * we can represent 10^k exactly), we may be able to
- * compute (d*10^k) * 10^(e-k) with just one roundoff.
- * 3. Rather than a bit-at-a-time adjustment of the binary
- * result in the hard case, we use floating-point
- * arithmetic to determine the adjustment to within
- * one bit; only in really hard cases do we need to
- * compute a second residual.
- * 4. Because of 3., we don't need a large table of powers of 10
- * for ten-to-e (just some small tables, e.g. of 10^k
- * for 0 <= k <= 22).
- */
-
-/*
- * #define IEEE_8087 for IEEE-arithmetic machines where the least
- * significant byte has the lowest address.
- * #define IEEE_MC68k for IEEE-arithmetic machines where the most
- * significant byte has the lowest address.
- * #define Sudden_Underflow for IEEE-format machines without gradual
- * underflow (i.e., that flush to zero on underflow).
- * #define IBM for IBM mainframe-style floating-point arithmetic.
- * #define VAX for VAX-style floating-point arithmetic.
- * #define Unsigned_Shifts if >> does treats its left operand as unsigned.
- * #define No_leftright to omit left-right logic in fast floating-point
- * computation of dtoa.
- * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3.
- * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
- * that use extended-precision instructions to compute rounded
- * products and quotients) with IBM.
- * #define ROUND_BIASED for IEEE-format with biased rounding.
- * #define Inaccurate_Divide for IEEE-format with correctly rounded
- * products but inaccurate quotients, e.g., for Intel i860.
- * #define KR_headers for old-style C function headers.
- */
-
-#ifdef DEBUG
-#include <stdio.h>
-#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
-#endif
-
-#ifdef __STDC__
-#include <stdlib.h>
-#include <string.h>
-#include <float.h>
-#define CONST const
-#else
-#define CONST
-#define KR_headers
-
-/* In this case, we assume IEEE floats. */
-#define FLT_ROUNDS 1
-#define FLT_RADIX 2
-#define DBL_MANT_DIG 53
-#define DBL_DIG 15
-#define DBL_MAX_10_EXP 308
-#define DBL_MAX_EXP 1024
-#endif
-
-#include <errno.h>
-#ifndef __MATH_H__
-#include <math.h>
-#endif
-
-#ifdef Unsigned_Shifts
-#define Sign_Extend(a,b) if (b < 0) a |= 0xffff0000;
-#else
-#define Sign_Extend(a,b) /*no-op*/
-#endif
-
-#if defined(__i386__) || defined(__i860__) || defined(clipper)
-#define IEEE_8087
-#endif
-#if defined(MIPSEL) || defined(__alpha__)
-#define IEEE_8087
-#endif
-#if defined(__sparc__) || defined(sparc) || defined(MIPSEB)
-#define IEEE_MC68k
-#endif
-
-#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
-
-#if FLT_RADIX==16
-#define IBM
-#else
-#if DBL_MANT_DIG==56
-#define VAX
-#else
-#if DBL_MANT_DIG==53 && DBL_MAX_10_EXP==308
-#define IEEE_Unknown
-#else
-Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
-#endif
-#endif
-#endif
-#endif
-
-typedef _G_uint32_t unsigned32;
-
-#ifdef IEEE_8087
-#define HIWORD 1
-#define LOWORD 0
-#define TEST_ENDIANNESS /* nothing */
-#else
-#if defined(IEEE_MC68k)
-#define HIWORD 0
-#define LOWORD 1
-#define TEST_ENDIANNESS /* nothing */
-#else
-static int HIWORD = -1, LOWORD;
-static void test_endianness()
-{
- union doubleword {
- double d;
- unsigned32 u[2];
- } dw;
- dw.d = 10;
- if (dw.u[0] != 0) /* big-endian */
- HIWORD=0, LOWORD=1;
- else
- HIWORD=1, LOWORD=0;
-}
-#define TEST_ENDIANNESS if (HIWORD<0) test_endianness();
-#endif
-#endif
-
-#if 0
-union {
- double d;
- unsigned32 x[2];
-} _temp;
-#endif
-#define word0(x) ((unsigned32 *)&x)[HIWORD]
-#if 0
-#define word0(X) (_temp.d = X, _temp.x[HIWORD])
-#define setword0(D,X) (_temp.d = D, _temp.x[HIWORD] = X, D = _temp.d)
-#endif
-#define word1(x) ((unsigned32 *)&x)[LOWORD]
-
-/* The following definition of Storeinc is appropriate for MIPS processors. */
-#if defined(IEEE_8087) + defined(VAX)
-#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
-((unsigned short *)a)[0] = (unsigned short)c, a++)
-#else
-#if defined(IEEE_MC68k)
-#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
-((unsigned short *)a)[1] = (unsigned short)c, a++)
-#else
-#define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
-#endif
-#endif
-
-/* #define P DBL_MANT_DIG */
-/* Ten_pmax = floor(P*log(2)/log(5)) */
-/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
-/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
-/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
-
-#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(IEEE_Unknown)
-#define Exp_shift 20
-#define Exp_shift1 20
-#define Exp_msk1 0x100000
-#define Exp_msk11 0x100000
-#define Exp_mask 0x7ff00000
-#define P 53
-#define Bias 1023
-#define IEEE_Arith
-#define Emin (-1022)
-#define Exp_1 0x3ff00000
-#define Exp_11 0x3ff00000
-#define Ebits 11
-#define Frac_mask 0xfffff
-#define Frac_mask1 0xfffff
-#define Ten_pmax 22
-#define Bletch 0x10
-#define Bndry_mask 0xfffff
-#define Bndry_mask1 0xfffff
-#define LSB 1
-#define Sign_bit 0x80000000
-#define Log2P 1
-#define Tiny0 0
-#define Tiny1 1
-#define Quick_max 14
-#define Int_max 14
-#define Infinite(x) (word0(x) == 0x7ff00000) /* sufficient test for here */
-#else
-#undef Sudden_Underflow
-#define Sudden_Underflow
-#ifdef IBM
-#define Exp_shift 24
-#define Exp_shift1 24
-#define Exp_msk1 0x1000000
-#define Exp_msk11 0x1000000
-#define Exp_mask 0x7f000000
-#define P 14
-#define Bias 65
-#define Exp_1 0x41000000
-#define Exp_11 0x41000000
-#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
-#define Frac_mask 0xffffff
-#define Frac_mask1 0xffffff
-#define Bletch 4
-#define Ten_pmax 22
-#define Bndry_mask 0xefffff
-#define Bndry_mask1 0xffffff
-#define LSB 1
-#define Sign_bit 0x80000000
-#define Log2P 4
-#define Tiny0 0x100000
-#define Tiny1 0
-#define Quick_max 14
-#define Int_max 15
-#else /* VAX */
-#define Exp_shift 23
-#define Exp_shift1 7
-#define Exp_msk1 0x80
-#define Exp_msk11 0x800000
-#define Exp_mask 0x7f80
-#define P 56
-#define Bias 129
-#define Exp_1 0x40800000
-#define Exp_11 0x4080
-#define Ebits 8
-#define Frac_mask 0x7fffff
-#define Frac_mask1 0xffff007f
-#define Ten_pmax 24
-#define Bletch 2
-#define Bndry_mask 0xffff007f
-#define Bndry_mask1 0xffff007f
-#define LSB 0x10000
-#define Sign_bit 0x8000
-#define Log2P 1
-#define Tiny0 0x80
-#define Tiny1 0
-#define Quick_max 15
-#define Int_max 15
-#endif
-#endif
-
-#ifndef IEEE_Arith
-#define ROUND_BIASED
-#endif
-
-#ifdef RND_PRODQUOT
-#define rounded_product(a,b) a = rnd_prod(a, b)
-#define rounded_quotient(a,b) a = rnd_quot(a, b)
-extern double rnd_prod(double, double), rnd_quot(double, double);
-#else
-#define rounded_product(a,b) a *= b
-#define rounded_quotient(a,b) a /= b
-#endif
-
-#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
-#define Big1 0xffffffff
-
-#define Kmax 15
-
-/* (1<<BIGINT_MINIMUM_K) is the minimum number of words to allocate
- in a Bigint. dtoa usually manages with 1<<2, and has not been
- known to need more than 1<<3. */
-
-#define BIGINT_MINIMUM_K 3
-
-struct Bigint {
- struct Bigint *next;
- int k; /* Parameter given to Balloc(k) */
- int maxwds; /* Allocated space: equals 1<<k. */
- short on_stack; /* 1 if stack-allocated. */
- short sign; /* 0 if value is positive or zero; 1 if negative. */
- int wds; /* Current length. */
- unsigned32 x[1<<BIGINT_MINIMUM_K]; /* Actually: x[maxwds] */
-};
-
-#define BIGINT_HEADER_SIZE \
- (sizeof(Bigint) - (1<<BIGINT_MINIMUM_K) * sizeof(unsigned32))
-
-typedef struct Bigint Bigint;
-
-/* Initialize a stack-allocated Bigint. */
-
-static Bigint *
-Binit
-#ifdef KR_headers
- (v) Bigint *v;
-#else
- (Bigint *v)
-#endif
-{
- v->on_stack = 1;
- v->k = BIGINT_MINIMUM_K;
- v->maxwds = 1 << BIGINT_MINIMUM_K;
- v->sign = v->wds = 0;
- return v;
-}
-
-/* Allocate a Bigint with '1<<k' big digits. */
-
-static Bigint *
-Balloc
-#ifdef KR_headers
- (k) int k;
-#else
- (int k)
-#endif
-{
- int x;
- Bigint *rv;
-
- if (k < BIGINT_MINIMUM_K)
- k = BIGINT_MINIMUM_K;
-
- x = 1 << k;
- rv = (Bigint *)
- malloc(BIGINT_HEADER_SIZE + x * sizeof(unsigned32));
- rv->k = k;
- rv->maxwds = x;
- rv->sign = rv->wds = 0;
- rv->on_stack = 0;
- return rv;
-}
-
-static void
-Bfree
-#ifdef KR_headers
- (v) Bigint *v;
-#else
- (Bigint *v)
-#endif
-{
- if (v && !v->on_stack)
- free (v);
-}
-
-static void
-Bcopy
-#ifdef KR_headers
- (x, y) Bigint *x, *y;
-#else
- (Bigint *x, Bigint *y)
-#endif
-{
- register unsigned32 *xp, *yp;
- register int i = y->wds;
- x->sign = y->sign;
- x->wds = i;
- for (xp = x->x, yp = y->x; --i >= 0; )
- *xp++ = *yp++;
-}
-
-/* Make sure b has room for at least 1<<k big digits. */
-
-static Bigint *
-Brealloc
-#ifdef KR_headers
- (b, k) Bigint *b; int k;
-#else
- (Bigint * b, int k)
-#endif
-{
- if (b == NULL)
- return Balloc(k);
- if (b->k >= k)
- return b;
- else
- {
- Bigint *rv = Balloc (k);
- Bcopy(rv, b);
- Bfree(b);
- return rv;
- }
-}
-
-/* Return b*m+a. b is modified.
- Assumption: 0xFFFF*m+a fits in 32 bits. */
-
-static Bigint *
-multadd
-#ifdef KR_headers
- (b, m, a) Bigint *b; int m, a;
-#else
- (Bigint *b, int m, int a)
-#endif
-{
- int i, wds;
- unsigned32 *x, y;
- unsigned32 xi, z;
-
- wds = b->wds;
- x = b->x;
- i = 0;
- do {
- xi = *x;
- y = (xi & 0xffff) * m + a;
- z = (xi >> 16) * m + (y >> 16);
- a = (int)(z >> 16);
- *x++ = (z << 16) + (y & 0xffff);
- }
- while(++i < wds);
- if (a) {
- if (wds >= b->maxwds)
- b = Brealloc(b, b->k+1);
- b->x[wds++] = a;
- b->wds = wds;
- }
- return b;
- }
-
-static Bigint *
-s2b
-#ifdef KR_headers
- (result, s, nd0, nd, y9)
- Bigint *result; CONST char *s; int nd0, nd; unsigned32 y9;
-#else
- (Bigint *result, CONST char *s, int nd0, int nd, unsigned32 y9)
-#endif
-{
- int i, k;
- _G_int32_t x, y;
-
- x = (nd + 8) / 9;
- for(k = 0, y = 1; x > y; y <<= 1, k++) ;
- result = Brealloc(result, k);
- result->x[0] = y9;
- result->wds = 1;
-
- i = 9;
- if (9 < nd0)
- {
- s += 9;
- do
- result = multadd(result, 10, *s++ - '0');
- while (++i < nd0);
- s++;
- }
- else
- s += 10;
- for(; i < nd; i++)
- result = multadd(result, 10, *s++ - '0');
- return result;
-}
-
-static int
-hi0bits
-#ifdef KR_headers
- (x) register unsigned32 x;
-#else
- (register unsigned32 x)
-#endif
-{
- register int k = 0;
-
- if (!(x & 0xffff0000)) {
- k = 16;
- x <<= 16;
- }
- if (!(x & 0xff000000)) {
- k += 8;
- x <<= 8;
- }
- if (!(x & 0xf0000000)) {
- k += 4;
- x <<= 4;
- }
- if (!(x & 0xc0000000)) {
- k += 2;
- x <<= 2;
- }
- if (!(x & 0x80000000)) {
- k++;
- if (!(x & 0x40000000))
- return 32;
- }
- return k;
- }
-
-static int
-lo0bits
-#ifdef KR_headers
- (y) unsigned32 *y;
-#else
- (unsigned32 *y)
-#endif
-{
- register int k;
- register unsigned32 x = *y;
-
- if (x & 7) {
- if (x & 1)
- return 0;
- if (x & 2) {
- *y = x >> 1;
- return 1;
- }
- *y = x >> 2;
- return 2;
- }
- k = 0;
- if (!(x & 0xffff)) {
- k = 16;
- x >>= 16;
- }
- if (!(x & 0xff)) {
- k += 8;
- x >>= 8;
- }
- if (!(x & 0xf)) {
- k += 4;
- x >>= 4;
- }
- if (!(x & 0x3)) {
- k += 2;
- x >>= 2;
- }
- if (!(x & 1)) {
- k++;
- x >>= 1;
- if (!x & 1)
- return 32;
- }
- *y = x;
- return k;
- }
-
-static Bigint *
-i2b
-#ifdef KR_headers
- (result, i) Bigint *result; int i;
-#else
- (Bigint* result, int i)
-#endif
-{
- result = Brealloc(result, 1);
- result->x[0] = i;
- result->wds = 1;
- return result;
-}
-
-/* Do: c = a * b. */
-
-static Bigint *
-mult
-#ifdef KR_headers
- (c, a, b) Bigint *a, *b, *c;
-#else
- (Bigint *c, Bigint *a, Bigint *b)
-#endif
-{
- int k, wa, wb, wc;
- unsigned32 carry, y, z;
- unsigned32 *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
- unsigned32 z2;
- if (a->wds < b->wds) {
- Bigint *tmp = a;
- a = b;
- b = tmp;
- }
- k = a->k;
- wa = a->wds;
- wb = b->wds;
- wc = wa + wb;
- if (wc > a->maxwds)
- k++;
- c = Brealloc(c, k);
- for(x = c->x, xa = x + wc; x < xa; x++)
- *x = 0;
- xa = a->x;
- xae = xa + wa;
- xb = b->x;
- xbe = xb + wb;
- xc0 = c->x;
- for(; xb < xbe; xb++, xc0++) {
- if ((y = *xb & 0xffff)) {
- x = xa;
- xc = xc0;
- carry = 0;
- do {
- z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
- carry = z >> 16;
- z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
- carry = z2 >> 16;
- Storeinc(xc, z2, z);
- }
- while(x < xae);
- *xc = carry;
- }
- if ((y = *xb >> 16)) {
- x = xa;
- xc = xc0;
- carry = 0;
- z2 = *xc;
- do {
- z = (*x & 0xffff) * y + (*xc >> 16) + carry;
- carry = z >> 16;
- Storeinc(xc, z, z2);
- z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
- carry = z2 >> 16;
- }
- while(x < xae);
- *xc = z2;
- }
- }
- for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ;
- c->wds = wc;
- return c;
- }
-
-/* Returns b*(5**k). b is modified. */
-/* Re-written by Per Bothner to not need a static list. */
-
-static Bigint *
-pow5mult
-#ifdef KR_headers
- (b, k) Bigint *b; int k;
-#else
- (Bigint *b, int k)
-#endif
-{
- static int p05[6] = { 5, 25, 125, 625, 3125, 15625 };
-
- for (; k > 6; k -= 6)
- b = multadd(b, 15625, 0); /* b *= 5**6 */
- if (k == 0)
- return b;
- else
- return multadd(b, p05[k-1], 0);
-}
-
-/* Re-written by Per Bothner so shift can be in place. */
-
-static Bigint *
-lshift
-#ifdef KR_headers
- (b, k) Bigint *b; int k;
-#else
- (Bigint *b, int k)
-#endif
-{
- int i;
- unsigned32 *x, *x1, *xe;
- int old_wds = b->wds;
- int n = k >> 5;
- int k1 = b->k;
- int n1 = n + old_wds + 1;
-
- if (k == 0)
- return b;
-
- for(i = b->maxwds; n1 > i; i <<= 1)
- k1++;
- b = Brealloc(b, k1);
-
- xe = b->x; /* Source limit */
- x = xe + old_wds; /* Source pointer */
- x1 = x + n; /* Destination pointer */
- if (k &= 0x1f) {
- int k1 = 32 - k;
- unsigned32 z = *--x;
- if ((*x1 = (z >> k1)) != 0) {
- ++n1;
- }
- while (x > xe) {
- unsigned32 w = *--x;
- *--x1 = (z << k) | (w >> k1);
- z = w;
- }
- *--x1 = z << k;
- }
- else
- do {
- *--x1 = *--x;
- } while(x > xe);
- while (x1 > xe)
- *--x1 = 0;
- b->wds = n1 - 1;
- return b;
-}
-
-static int
-cmp
-#ifdef KR_headers
- (a, b) Bigint *a, *b;
-#else
- (Bigint *a, Bigint *b)
-#endif
-{
- unsigned32 *xa, *xa0, *xb, *xb0;
- int i, j;
-
- i = a->wds;
- j = b->wds;
-#ifdef DEBUG
- if (i > 1 && !a->x[i-1])
- Bug("cmp called with a->x[a->wds-1] == 0");
- if (j > 1 && !b->x[j-1])
- Bug("cmp called with b->x[b->wds-1] == 0");
-#endif
- if (i -= j)
- return i;
- xa0 = a->x;
- xa = xa0 + j;
- xb0 = b->x;
- xb = xb0 + j;
- for(;;) {
- if (*--xa != *--xb)
- return *xa < *xb ? -1 : 1;
- if (xa <= xa0)
- break;
- }
- return 0;
- }
-
-/* Do: c = a-b. */
-
-static Bigint *
-diff
-#ifdef KR_headers
- (c, a, b) Bigint *c, *a, *b;
-#else
- (Bigint *c, Bigint *a, Bigint *b)
-#endif
-{
- int i, wa, wb;
- _G_int32_t borrow, y; /* We need signed shifts here. */
- unsigned32 *xa, *xae, *xb, *xbe, *xc;
- _G_int32_t z;
-
- i = cmp(a,b);
- if (!i) {
- c = Brealloc(c, 0);
- c->wds = 1;
- c->x[0] = 0;
- return c;
- }
- if (i < 0) {
- Bigint *tmp = a;
- a = b;
- b = tmp;
- i = 1;
- }
- else
- i = 0;
- c = Brealloc(c, a->k);
- c->sign = i;
- wa = a->wds;
- xa = a->x;
- xae = xa + wa;
- wb = b->wds;
- xb = b->x;
- xbe = xb + wb;
- xc = c->x;
- borrow = 0;
- do {
- y = (*xa & 0xffff) - (*xb & 0xffff) + borrow;
- borrow = y >> 16;
- Sign_Extend(borrow, y);
- z = (*xa++ >> 16) - (*xb++ >> 16) + borrow;
- borrow = z >> 16;
- Sign_Extend(borrow, z);
- Storeinc(xc, z, y);
- }
- while(xb < xbe);
- while(xa < xae) {
- y = (*xa & 0xffff) + borrow;
- borrow = y >> 16;
- Sign_Extend(borrow, y);
- z = (*xa++ >> 16) + borrow;
- borrow = z >> 16;
- Sign_Extend(borrow, z);
- Storeinc(xc, z, y);
- }
- while(!*--xc)
- wa--;
- c->wds = wa;
- return c;
- }
-
-static double
-ulp
-#ifdef KR_headers
- (x) double x;
-#else
- (double x)
-#endif
-{
- register _G_int32_t L;
- double a;
-
- L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;
-#ifndef Sudden_Underflow
- if (L > 0) {
-#endif
-#ifdef IBM
- L |= Exp_msk1 >> 4;
-#endif
- word0(a) = L;
- word1(a) = 0;
-#ifndef Sudden_Underflow
- }
- else {
- L = -L >> Exp_shift;
- if (L < Exp_shift) {
- word0(a) = 0x80000 >> L;
- word1(a) = 0;
- }
- else {
- word0(a) = 0;
- L -= Exp_shift;
- word1(a) = L >= 31 ? 1 : 1 << (31 - L);
- }
- }
-#endif
- return a;
- }
-
-static double
-b2d
-#ifdef KR_headers
- (a, e) Bigint *a; int *e;
-#else
- (Bigint *a, int *e)
-#endif
-{
- unsigned32 *xa, *xa0, w, y, z;
- int k;
- double d;
-#ifdef VAX
- unsigned32 d0, d1;
-#else
-#define d0 word0(d)
-#define d1 word1(d)
-#endif
-
- xa0 = a->x;
- xa = xa0 + a->wds;
- y = *--xa;
-#ifdef DEBUG
- if (!y) Bug("zero y in b2d");
-#endif
- k = hi0bits(y);
- *e = 32 - k;
- if (k < Ebits) {
- d0 = Exp_1 | y >> (Ebits - k);
- w = xa > xa0 ? *--xa : 0;
- d1 = y << ((32-Ebits) + k) | w >> (Ebits - k);
- goto ret_d;
- }
- z = xa > xa0 ? *--xa : 0;
- if (k -= Ebits) {
- d0 = Exp_1 | y << k | z >> (32 - k);
- y = xa > xa0 ? *--xa : 0;
- d1 = z << k | y >> (32 - k);
- }
- else {
- d0 = Exp_1 | y;
- d1 = z;
- }
- ret_d:
-#ifdef VAX
- word0(d) = d0 >> 16 | d0 << 16;
- word1(d) = d1 >> 16 | d1 << 16;
-#else
-#undef d0
-#undef d1
-#endif
- return d;
- }
-
-static Bigint *
-d2b
-#ifdef KR_headers
- (result, d, e, bits) Bigint *result; double d; int *e, *bits;
-#else
- (Bigint *result, double d, int *e, int *bits)
-#endif
-{
- int de, i, k;
- unsigned32 *x, y, z;
-#ifdef VAX
- unsigned32 d0, d1;
- d0 = word0(d) >> 16 | word0(d) << 16;
- d1 = word1(d) >> 16 | word1(d) << 16;
-#else
-#define d0 word0(d)
-#define d1 word1(d)
-#endif
-
- result = Brealloc(result, 1);
- x = result->x;
-
- z = d0 & Frac_mask;
- d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
-
- de = (int)(d0 >> Exp_shift); /* The exponent part of d. */
-
- /* Put back the suppressed high-order bit, if normalized. */
-#ifndef IBM
-#ifndef Sudden_Underflow
- if (de)
-#endif
- z |= Exp_msk11;
-#endif
-
- if ((y = d1)) {
- if ((k = lo0bits(&y))) {
- x[0] = y | z << (32 - k);
- z >>= k;
- }
- else
- x[0] = y;
- i = result->wds = (x[1] = z) ? 2 : 1;
- }
- else {
-#ifdef DEBUG
- if (!z)
- Bug("Zero passed to d2b");
-#endif
- k = lo0bits(&z);
- x[0] = z;
- i = result->wds = 1;
- k += 32;
- }
-#ifndef Sudden_Underflow
- if (de) {
-#endif
-#ifdef IBM
- *e = (de - Bias - (P-1) << 2) + k;
- *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask);
-#else
- *e = de - Bias - (P-1) + k;
- *bits = P - k;
-#endif
-#ifndef Sudden_Underflow
- }
- else {
- *e = de - Bias - (P-1) + 1 + k;
- *bits = 32*i - hi0bits(x[i-1]);
- }
-#endif
- return result;
- }
-#undef d0
-#undef d1
-
-static double
-ratio
-#ifdef KR_headers
- (a, b) Bigint *a, *b;
-#else
- (Bigint *a, Bigint *b)
-#endif
-{
- double da, db;
- int k, ka, kb;
-
- da = b2d(a, &ka);
- db = b2d(b, &kb);
- k = ka - kb + 32*(a->wds - b->wds);
-#ifdef IBM
- if (k > 0) {
- word0(da) += (k >> 2)*Exp_msk1;
- if (k &= 3)
- da *= 1 << k;
- }
- else {
- k = -k;
- word0(db) += (k >> 2)*Exp_msk1;
- if (k &= 3)
- db *= 1 << k;
- }
-#else
- if (k > 0)
- word0(da) += k*Exp_msk1;
- else {
- k = -k;
- word0(db) += k*Exp_msk1;
- }
-#endif
- return da / db;
- }
-
-static double
-tens[] = {
- 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
- 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
- 1e20, 1e21, 1e22
-#ifdef VAX
- , 1e23, 1e24
-#endif
- };
-
-static double
-#ifdef IEEE_Arith
-bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };
-static double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256 };
-#define n_bigtens 5
-#else
-#ifdef IBM
-bigtens[] = { 1e16, 1e32, 1e64 };
-static double tinytens[] = { 1e-16, 1e-32, 1e-64 };
-#define n_bigtens 3
-#else
-bigtens[] = { 1e16, 1e32 };
-static double tinytens[] = { 1e-16, 1e-32 };
-#define n_bigtens 2
-#endif
-#endif
-
- double
-_IO_strtod
-#ifdef KR_headers
- (s00, se) CONST char *s00; char **se;
-#else
- (CONST char *s00, char **se)
-#endif
-{
- int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
- e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
- CONST char *s, *s0, *s1;
- double aadj, aadj1, adj, rv, rv0;
- _G_int32_t L;
- unsigned32 y, z;
- Bigint _bb, _b_avail, _bd, _bd0, _bs, _delta;
- Bigint *bb = Binit(&_bb);
- Bigint *bd = Binit(&_bd);
- Bigint *bd0 = Binit(&_bd0);
- Bigint *bs = Binit(&_bs);
- Bigint *b_avail = Binit(&_b_avail);
- Bigint *delta = Binit(&_delta);
-
- TEST_ENDIANNESS;
- sign = nz0 = nz = 0;
- rv = 0.;
- for(s = s00;;s++) switch(*s) {
- case '-':
- sign = 1;
- /* no break */
- case '+':
- if (*++s)
- goto break2;
- /* no break */
- case 0:
- /* "+" and "-" should be reported as an error? */
- sign = 0;
- s = s00;
- goto ret;
- case '\t':
- case '\n':
- case '\v':
- case '\f':
- case '\r':
- case ' ':
- continue;
- default:
- goto break2;
- }
- break2:
- if (*s == '0') {
- nz0 = 1;
- while(*++s == '0') ;
- if (!*s)
- goto ret;
- }
- s0 = s;
- y = z = 0;
- for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
- if (nd < 9)
- y = 10*y + c - '0';
- else if (nd < 16)
- z = 10*z + c - '0';
- nd0 = nd;
- if (c == '.') {
- c = *++s;
- if (!nd) {
- for(; c == '0'; c = *++s)
- nz++;
- if (c > '0' && c <= '9') {
- s0 = s;
- nf += nz;
- nz = 0;
- goto have_dig;
- }
- goto dig_done;
- }
- for(; c >= '0' && c <= '9'; c = *++s) {
- have_dig:
- nz++;
- if (c -= '0') {
- nf += nz;
- for(i = 1; i < nz; i++)
- if (nd++ < 9)
- y *= 10;
- else if (nd <= DBL_DIG + 1)
- z *= 10;
- if (nd++ < 9)
- y = 10*y + c;
- else if (nd <= DBL_DIG + 1)
- z = 10*z + c;
- nz = 0;
- }
- }
- }
- dig_done:
- e = 0;
- if (c == 'e' || c == 'E') {
- if (!nd && !nz && !nz0) {
- s = s00;
- goto ret;
- }
- s00 = s;
- esign = 0;
- switch(c = *++s) {
- case '-':
- esign = 1;
- case '+':
- c = *++s;
- }
- if (c >= '0' && c <= '9') {
- while(c == '0')
- c = *++s;
- if (c > '0' && c <= '9') {
- e = c - '0';
- s1 = s;
- while((c = *++s) >= '0' && c <= '9')
- e = 10*e + c - '0';
- if (s - s1 > 8)
- /* Avoid confusion from exponents
- * so large that e might overflow.
- */
- e = 9999999;
- if (esign)
- e = -e;
- }
- else
- e = 0;
- }
- else
- s = s00;
- }
- if (!nd) {
- if (!nz && !nz0)
- s = s00;
- goto ret;
- }
- e1 = e -= nf;
-
- /* Now we have nd0 digits, starting at s0, followed by a
- * decimal point, followed by nd-nd0 digits. The number we're
- * after is the integer represented by those digits times
- * 10**e */
-
- if (!nd0)
- nd0 = nd;
- k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
- rv = y;
- if (k > 9)
- rv = tens[k - 9] * rv + z;
- if (nd <= DBL_DIG
-#ifndef RND_PRODQUOT
- && FLT_ROUNDS == 1
-#endif
- ) {
- if (!e)
- goto ret;
- if (e > 0) {
- if (e <= Ten_pmax) {
-#ifdef VAX
- goto vax_ovfl_check;
-#else
- /* rv = */ rounded_product(rv, tens[e]);
- goto ret;
-#endif
- }
- i = DBL_DIG - nd;
- if (e <= Ten_pmax + i) {
- /* A fancier test would sometimes let us do
- * this for larger i values.
- */
- e -= i;
- rv *= tens[i];
-#ifdef VAX
- /* VAX exponent range is so narrow we must
- * worry about overflow here...
- */
- vax_ovfl_check:
- word0(rv) -= P*Exp_msk1;
- /* rv = */ rounded_product(rv, tens[e]);
- if ((word0(rv) & Exp_mask)
- > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))
- goto ovfl;
- word0(rv) += P*Exp_msk1;
-#else
- /* rv = */ rounded_product(rv, tens[e]);
-#endif
- goto ret;
- }
- }
-#ifndef Inaccurate_Divide
- else if (e >= -Ten_pmax) {
- /* rv = */ rounded_quotient(rv, tens[-e]);
- goto ret;
- }
-#endif
- }
- e1 += nd - k;
-
- /* Get starting approximation = rv * 10**e1 */
-
- if (e1 > 0) {
- if ((i = e1 & 15))
- rv *= tens[i];
- if (e1 &= ~15) {
- if (e1 > DBL_MAX_10_EXP) {
- ovfl:
- errno = ERANGE;
-#if defined(sun) && !defined(__svr4__)
-/* SunOS defines HUGE_VAL as __infinity(), which is in libm. */
-#undef HUGE_VAL
-#endif
-#ifndef HUGE_VAL
-#define HUGE_VAL 1.7976931348623157E+308
-#endif
- rv = HUGE_VAL;
- goto ret;
- }
- if (e1 >>= 4) {
- for(j = 0; e1 > 1; j++, e1 >>= 1)
- if (e1 & 1)
- rv *= bigtens[j];
- /* The last multiplication could overflow. */
- word0(rv) -= P*Exp_msk1;
- rv *= bigtens[j];
- if ((z = word0(rv) & Exp_mask)
- > Exp_msk1*(DBL_MAX_EXP+Bias-P))
- goto ovfl;
- if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) {
- /* set to largest number */
- /* (Can't trust DBL_MAX) */
- word0(rv) = Big0;
- word1(rv) = Big1;
- }
- else
- word0(rv) += P*Exp_msk1;
- }
-
- }
- }
- else if (e1 < 0) {
- e1 = -e1;
- if ((i = e1 & 15))
- rv /= tens[i];
- if (e1 &= ~15) {
- e1 >>= 4;
- for(j = 0; e1 > 1; j++, e1 >>= 1)
- if (e1 & 1)
- rv *= tinytens[j];
- /* The last multiplication could underflow. */
- rv0 = rv;
- rv *= tinytens[j];
- if (!rv) {
- rv = 2.*rv0;
- rv *= tinytens[j];
- if (!rv) {
- undfl:
- rv = 0.;
- errno = ERANGE;
- goto ret;
- }
- word0(rv) = Tiny0;
- word1(rv) = Tiny1;
- /* The refinement below will clean
- * this approximation up.
- */
- }
- }
- }
-
- /* Now the hard part -- adjusting rv to the correct value.*/
-
- /* Put digits into bd: true value = bd * 10^e */
-
- bd0 = s2b(bd0, s0, nd0, nd, y);
- bd = Brealloc(bd, bd0->k);
-
- for(;;) {
- Bcopy(bd, bd0);
- bb = d2b(bb, rv, &bbe, &bbbits); /* rv = bb * 2^bbe */
- bs = i2b(bs, 1);
-
- if (e >= 0) {
- bb2 = bb5 = 0;
- bd2 = bd5 = e;
- }
- else {
- bb2 = bb5 = -e;
- bd2 = bd5 = 0;
- }
- if (bbe >= 0)
- bb2 += bbe;
- else
- bd2 -= bbe;
- bs2 = bb2;
-#ifdef Sudden_Underflow
-#ifdef IBM
- j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3);
-#else
- j = P + 1 - bbbits;
-#endif
-#else
- i = bbe + bbbits - 1; /* logb(rv) */
- if (i < Emin) /* denormal */
- j = bbe + (P-Emin);
- else
- j = P + 1 - bbbits;
-#endif
- bb2 += j;
- bd2 += j;
- i = bb2 < bd2 ? bb2 : bd2;
- if (i > bs2)
- i = bs2;
- if (i > 0) {
- bb2 -= i;
- bd2 -= i;
- bs2 -= i;
- }
- if (bb5 > 0) {
- Bigint *b_tmp;
- bs = pow5mult(bs, bb5);
- b_tmp = mult(b_avail, bs, bb);
- b_avail = bb;
- bb = b_tmp;
- }
- if (bb2 > 0)
- bb = lshift(bb, bb2);
- if (bd5 > 0)
- bd = pow5mult(bd, bd5);
- if (bd2 > 0)
- bd = lshift(bd, bd2);
- if (bs2 > 0)
- bs = lshift(bs, bs2);
- delta = diff(delta, bb, bd);
- dsign = delta->sign;
- delta->sign = 0;
- i = cmp(delta, bs);
- if (i < 0) {
- /* Error is less than half an ulp -- check for
- * special case of mantissa a power of two.
- */
- if (dsign || word1(rv) || word0(rv) & Bndry_mask)
- break;
- delta = lshift(delta,Log2P);
- if (cmp(delta, bs) > 0)
- goto drop_down;
- break;
- }
- if (i == 0) {
- /* exactly half-way between */
- if (dsign) {
- if ((word0(rv) & Bndry_mask1) == Bndry_mask1
- && word1(rv) == 0xffffffff) {
- /*boundary case -- increment exponent*/
- word0(rv) = (word0(rv) & Exp_mask)
- + Exp_msk1
-#ifdef IBM
- | Exp_msk1 >> 4
-#endif
- ;
- word1(rv) = 0;
- break;
- }
- }
- else if (!(word0(rv) & Bndry_mask) && !word1(rv)) {
- drop_down:
- /* boundary case -- decrement exponent */
-#ifdef Sudden_Underflow
- L = word0(rv) & Exp_mask;
-#ifdef IBM
- if (L < Exp_msk1)
-#else
- if (L <= Exp_msk1)
-#endif
- goto undfl;
- L -= Exp_msk1;
-#else
- L = (word0(rv) & Exp_mask) - Exp_msk1;
-#endif
- word0(rv) = L | Bndry_mask1;
- word1(rv) = 0xffffffff;
-#ifdef IBM
- continue;
-#else
- break;
-#endif
- }
-#ifndef ROUND_BIASED
- if (!(word1(rv) & LSB))
- break;
-#endif
- if (dsign)
- rv += ulp(rv);
-#ifndef ROUND_BIASED
- else {
- rv -= ulp(rv);
-#ifndef Sudden_Underflow
- if (!rv)
- goto undfl;
-#endif
- }
-#endif
- break;
- }
- if ((aadj = ratio(delta, bs)) <= 2.) {
- if (dsign)
- aadj = aadj1 = 1.;
- else if (word1(rv) || word0(rv) & Bndry_mask) {
-#ifndef Sudden_Underflow
- if (word1(rv) == Tiny1 && !word0(rv))
- goto undfl;
-#endif
- aadj = 1.;
- aadj1 = -1.;
- }
- else {
- /* special case -- power of FLT_RADIX to be */
- /* rounded down... */
-
- if (aadj < 2./FLT_RADIX)
- aadj = 1./FLT_RADIX;
- else
- aadj *= 0.5;
- aadj1 = -aadj;
- }
- }
- else {
- aadj *= 0.5;
- aadj1 = dsign ? aadj : -aadj;
-#ifdef Check_FLT_ROUNDS
- switch(FLT_ROUNDS) {
- case 2: /* towards +infinity */
- aadj1 -= 0.5;
- break;
- case 0: /* towards 0 */
- case 3: /* towards -infinity */
- aadj1 += 0.5;
- }
-#else
- if (FLT_ROUNDS == 0)
- aadj1 += 0.5;
-#endif
- }
- y = word0(rv) & Exp_mask;
-
- /* Check for overflow */
-
- if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
- rv0 = rv;
- word0(rv) -= P*Exp_msk1;
- adj = aadj1 * ulp(rv);
- rv += adj;
- if ((word0(rv) & Exp_mask) >=
- Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
- if (word0(rv0) == Big0 && word1(rv0) == Big1)
- goto ovfl;
- word0(rv) = Big0;
- word1(rv) = Big1;
- continue;
- }
- else
- word0(rv) += P*Exp_msk1;
- }
- else {
-#ifdef Sudden_Underflow
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
- rv0 = rv;
- word0(rv) += P*Exp_msk1;
- adj = aadj1 * ulp(rv);
- rv += adj;
-#ifdef IBM
- if ((word0(rv) & Exp_mask) < P*Exp_msk1)
-#else
- if ((word0(rv) & Exp_mask) <= P*Exp_msk1)
-#endif
- {
- if (word0(rv0) == Tiny0
- && word1(rv0) == Tiny1)
- goto undfl;
- word0(rv) = Tiny0;
- word1(rv) = Tiny1;
- continue;
- }
- else
- word0(rv) -= P*Exp_msk1;
- }
- else {
- adj = aadj1 * ulp(rv);
- rv += adj;
- }
-#else
- /* Compute adj so that the IEEE rounding rules will
- * correctly round rv + adj in some half-way cases.
- * If rv * ulp(rv) is denormalized (i.e.,
- * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid
- * trouble from bits lost to denormalization;
- * example: 1.2e-307 .
- */
- if (y <= (P-1)*Exp_msk1 && aadj >= 1.) {
- aadj1 = (double)(int)(aadj + 0.5);
- if (!dsign)
- aadj1 = -aadj1;
- }
- adj = aadj1 * ulp(rv);
- rv += adj;
-#endif
- }
- z = word0(rv) & Exp_mask;
- if (y == z) {
- /* Can we stop now? */
- L = (_G_int32_t)aadj;
- aadj -= L;
- /* The tolerances below are conservative. */
- if (dsign || word1(rv) || word0(rv) & Bndry_mask) {
- if (aadj < .4999999 || aadj > .5000001)
- break;
- }
- else if (aadj < .4999999/FLT_RADIX)
- break;
- }
- }
- Bfree(bb);
- Bfree(bd);
- Bfree(bs);
- Bfree(bd0);
- Bfree(delta);
- Bfree(b_avail);
- ret:
- if (se)
- *se = (char *)s;
- return sign ? -rv : rv;
- }
-
-static int
-quorem
-#ifdef KR_headers
- (b, S) Bigint *b, *S;
-#else
- (Bigint *b, Bigint *S)
-#endif
-{
- int n;
- _G_int32_t borrow, y;
- unsigned32 carry, q, ys;
- unsigned32 *bx, *bxe, *sx, *sxe;
- _G_int32_t z;
- unsigned32 si, zs;
-
- n = S->wds;
-#ifdef DEBUG
- /*debug*/ if (b->wds > n)
- /*debug*/ Bug("oversize b in quorem");
-#endif
- if (b->wds < n)
- return 0;
- sx = S->x;
- sxe = sx + --n;
- bx = b->x;
- bxe = bx + n;
- q = *bxe / (*sxe + 1); /* ensure q <= true quotient */
-#ifdef DEBUG
- /*debug*/ if (q > 9)
- /*debug*/ Bug("oversized quotient in quorem");
-#endif
- if (q) {
- borrow = 0;
- carry = 0;
- do {
- si = *sx++;
- ys = (si & 0xffff) * q + carry;
- zs = (si >> 16) * q + (ys >> 16);
- carry = zs >> 16;
- y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
- borrow = y >> 16;
- Sign_Extend(borrow, y);
- z = (*bx >> 16) - (zs & 0xffff) + borrow;
- borrow = z >> 16;
- Sign_Extend(borrow, z);
- Storeinc(bx, z, y);
- }
- while(sx <= sxe);
- if (!*bxe) {
- bx = b->x;
- while(--bxe > bx && !*bxe)
- --n;
- b->wds = n;
- }
- }
- if (cmp(b, S) >= 0) {
- q++;
- borrow = 0;
- carry = 0;
- bx = b->x;
- sx = S->x;
- do {
- si = *sx++;
- ys = (si & 0xffff) + carry;
- zs = (si >> 16) + (ys >> 16);
- carry = zs >> 16;
- y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
- borrow = y >> 16;
- Sign_Extend(borrow, y);
- z = (*bx >> 16) - (zs & 0xffff) + borrow;
- borrow = z >> 16;
- Sign_Extend(borrow, z);
- Storeinc(bx, z, y);
- }
- while(sx <= sxe);
- bx = b->x;
- bxe = bx + n;
- if (!*bxe) {
- while(--bxe > bx && !*bxe)
- --n;
- b->wds = n;
- }
- }
- return q;
- }
-
-/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
- *
- * Inspired by "How to Print Floating-Point Numbers Accurately" by
- * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101].
- *
- * Modifications:
- * 1. Rather than iterating, we use a simple numeric overestimate
- * to determine k = floor(log10(d)). We scale relevant
- * quantities using O(log2(k)) rather than O(k) multiplications.
- * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
- * try to generate digits strictly left to right. Instead, we
- * compute with fewer bits and propagate the carry if necessary
- * when rounding the final digit up. This is often faster.
- * 3. Under the assumption that input will be rounded nearest,
- * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
- * That is, we allow equality in stopping tests when the
- * round-nearest rule will give the same floating-point value
- * as would satisfaction of the stopping test with strict
- * inequality.
- * 4. We remove common factors of powers of 2 from relevant
- * quantities.
- * 5. When converting floating-point integers less than 1e16,
- * we use floating-point arithmetic rather than resorting
- * to multiple-precision integers.
- * 6. When asked to produce fewer than 15 digits, we first try
- * to get by with floating-point arithmetic; we resort to
- * multiple-precision integer arithmetic only if we cannot
- * guarantee that the floating-point calculation has given
- * the correctly rounded result. For k requested digits and
- * "uniformly" distributed input, the probability is
- * something like 10^(k-15) that we must resort to the long
- * calculation.
- */
-
- char *
-_IO_dtoa
-#ifdef KR_headers
- (d, mode, ndigits, decpt, sign, rve)
- double d; int mode, ndigits, *decpt, *sign; char **rve;
-#else
- (double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
-#endif
-{
- /* Arguments ndigits, decpt, sign are similar to those
- of ecvt and fcvt; trailing zeros are suppressed from
- the returned string. If not null, *rve is set to point
- to the end of the return value. If d is +-Infinity or NaN,
- then *decpt is set to 9999.
-
- mode:
- 0 ==> shortest string that yields d when read in
- and rounded to nearest.
- 1 ==> like 0, but with Steele & White stopping rule;
- e.g. with IEEE P754 arithmetic , mode 0 gives
- 1e23 whereas mode 1 gives 9.999999999999999e22.
- 2 ==> max(1,ndigits) significant digits. This gives a
- return value similar to that of ecvt, except
- that trailing zeros are suppressed.
- 3 ==> through ndigits past the decimal point. This
- gives a return value similar to that from fcvt,
- except that trailing zeros are suppressed, and
- ndigits can be negative.
- 4-9 should give the same return values as 2-3, i.e.,
- 4 <= mode <= 9 ==> same return as mode
- 2 + (mode & 1). These modes are mainly for
- debugging; often they run slower but sometimes
- faster than modes 2-3.
- 4,5,8,9 ==> left-to-right digit generation.
- 6-9 ==> don't try fast floating-point estimate
- (if applicable).
-
- Values of mode other than 0-9 are treated as mode 0.
-
- Sufficient space is allocated to the return value
- to hold the suppressed trailing zeros.
- */
-
- int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1,
- j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
- spec_case, try_quick;
- _G_int32_t L;
-#ifndef Sudden_Underflow
- int denorm;
-#endif
- Bigint _b_avail, _b, _mhi, _mlo, _S;
- Bigint *b_avail = Binit(&_b_avail);
- Bigint *b = Binit(&_b);
- Bigint *S = Binit(&_S);
- /* mhi and mlo are only set and used if leftright. */
- Bigint *mhi = NULL, *mlo = NULL;
- double d2, ds, eps;
- char *s, *s0;
- static Bigint *result = NULL;
- static int result_k;
-
- TEST_ENDIANNESS;
- if (result) {
- /* result is contains a string, so its fields (interpreted
- as a Bigint have been trashed. Restore them.
- This is a really ugly interface - result should
- not be static, since that is not thread-safe. FIXME. */
- result->k = result_k;
- result->maxwds = 1 << result_k;
- result->on_stack = 0;
- }
-
- if (word0(d) & Sign_bit) {
- /* set sign for everything, including 0's and NaNs */
- *sign = 1;
- word0(d) &= ~Sign_bit; /* clear sign bit */
- }
- else
- *sign = 0;
-
-#if defined(IEEE_Arith) + defined(VAX)
-#ifdef IEEE_Arith
- if ((word0(d) & Exp_mask) == Exp_mask)
-#else
- if (word0(d) == 0x8000)
-#endif
- {
- /* Infinity or NaN */
- *decpt = 9999;
-#ifdef IEEE_Arith
- if (!word1(d) && !(word0(d) & 0xfffff))
- {
- s = "Infinity";
- if (rve)
- *rve = s + 8;
- }
- else
-#endif
- {
- s = "NaN";
- if (rve)
- *rve = s +3;
- }
- return s;
- }
-#endif
-#ifdef IBM
- d += 0; /* normalize */
-#endif
- if (!d) {
- *decpt = 1;
- s = "0";
- if (rve)
- *rve = s + 1;
- return s;
- }
-
- b = d2b(b, d, &be, &bbits);
- i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
-#ifndef Sudden_Underflow
- if (i) {
-#endif
- d2 = d;
- word0(d2) &= Frac_mask1;
- word0(d2) |= Exp_11;
-#ifdef IBM
- if (j = 11 - hi0bits(word0(d2) & Frac_mask))
- d2 /= 1 << j;
-#endif
-
- i -= Bias;
-#ifdef IBM
- i <<= 2;
- i += j;
-#endif
-#ifndef Sudden_Underflow
- denorm = 0;
- }
- else {
- /* d is denormalized */
- unsigned32 x;
-
- i = bbits + be + (Bias + (P-1) - 1);
- x = i > 32 ? word0(d) << (64 - i) | word1(d) >> (i - 32)
- : word1(d) << (32 - i);
- d2 = x;
- word0(d2) -= 31*Exp_msk1; /* adjust exponent */
- i -= (Bias + (P-1) - 1) + 1;
- denorm = 1;
- }
-#endif
-
- /* Now i is the unbiased base-2 exponent. */
-
- /* log(x) ~=~ log(1.5) + (x-1.5)/1.5
- * log10(x) = log(x) / log(10)
- * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
- * log10(d) = i*log(2)/log(10) + log10(d2)
- *
- * This suggests computing an approximation k to log10(d) by
- *
- * k = i*0.301029995663981
- * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
- *
- * We want k to be too large rather than too small.
- * The error in the first-order Taylor series approximation
- * is in our favor, so we just round up the constant enough
- * to compensate for any error in the multiplication of
- * (i) by 0.301029995663981; since |i| <= 1077,
- * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
- * adding 1e-13 to the constant term more than suffices.
- * Hence we adjust the constant term to 0.1760912590558.
- * (We could get a more accurate k by invoking log10,
- * but this is probably not worthwhile.)
- */
-
- ds = (d2-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
- k = (int)ds;
- if (ds < 0. && ds != k)
- k--; /* want k = floor(ds) */
- k_check = 1;
- if (k >= 0 && k <= Ten_pmax) {
- if (d < tens[k])
- k--;
- k_check = 0;
- }
- j = bbits - i - 1;
- if (j >= 0) {
- b2 = 0;
- s2 = j;
- }
- else {
- b2 = -j;
- s2 = 0;
- }
- if (k >= 0) {
- b5 = 0;
- s5 = k;
- s2 += k;
- }
- else {
- b2 -= k;
- b5 = -k;
- s5 = 0;
- }
- if (mode < 0 || mode > 9)
- mode = 0;
- try_quick = 1;
- if (mode > 5) {
- mode -= 4;
- try_quick = 0;
- }
- leftright = 1;
- switch(mode) {
- case 0:
- case 1:
- ilim = ilim1 = -1;
- i = 18;
- ndigits = 0;
- break;
- case 2:
- leftright = 0;
- /* no break */
- case 4:
- if (ndigits <= 0)
- ndigits = 1;
- ilim = ilim1 = i = ndigits;
- break;
- case 3:
- leftright = 0;
- /* no break */
- case 5:
- i = ndigits + k + 1;
- ilim = i;
- ilim1 = i - 1;
- if (i <= 0)
- i = 1;
- }
- /* i is now an upper bound of the number of digits to generate. */
- j = sizeof(unsigned32) * (1<<BIGINT_MINIMUM_K);
- /* The test is <= so as to allow room for the final '\0'. */
- for(result_k = BIGINT_MINIMUM_K; BIGINT_HEADER_SIZE + j <= i;
- j <<= 1) result_k++;
- if (!result || result_k > result->k)
- {
- Bfree (result);
- result = Balloc(result_k);
- }
- s = s0 = (char *)result;
-
- if (ilim >= 0 && ilim <= Quick_max && try_quick) {
-
- /* Try to get by with floating-point arithmetic. */
-
- i = 0;
- d2 = d;
- k0 = k;
- ilim0 = ilim;
- ieps = 2; /* conservative */
- if (k > 0) {
- ds = tens[k&0xf];
- j = k >> 4;
- if (j & Bletch) {
- /* prevent overflows */
- j &= Bletch - 1;
- d /= bigtens[n_bigtens-1];
- ieps++;
- }
- for(; j; j >>= 1, i++)
- if (j & 1) {
- ieps++;
- ds *= bigtens[i];
- }
- d /= ds;
- }
- else if ((j1 = -k)) {
- d *= tens[j1 & 0xf];
- for(j = j1 >> 4; j; j >>= 1, i++)
- if (j & 1) {
- ieps++;
- d *= bigtens[i];
- }
- }
- if (k_check && d < 1. && ilim > 0) {
- if (ilim1 <= 0)
- goto fast_failed;
- ilim = ilim1;
- k--;
- d *= 10.;
- ieps++;
- }
- eps = ieps*d + 7.;
- word0(eps) -= (P-1)*Exp_msk1;
- if (ilim == 0) {
- d -= 5.;
- if (d > eps)
- goto one_digit;
- if (d < -eps)
- goto no_digits;
- goto fast_failed;
- }
-#ifndef No_leftright
- if (leftright) {
- /* Use Steele & White method of only
- * generating digits needed.
- */
- eps = 0.5/tens[ilim-1] - eps;
- for(i = 0;;) {
- L = (_G_int32_t)d;
- d -= L;
- *s++ = '0' + (int)L;
- if (d < eps)
- goto ret1;
- if (1. - d < eps)
- goto bump_up;
- if (++i >= ilim)
- break;
- eps *= 10.;
- d *= 10.;
- }
- }
- else {
-#endif
- /* Generate ilim digits, then fix them up. */
- eps *= tens[ilim-1];
- for(i = 1;; i++, d *= 10.) {
- L = (_G_int32_t)d;
- d -= L;
- *s++ = '0' + (int)L;
- if (i == ilim) {
- if (d > 0.5 + eps)
- goto bump_up;
- else if (d < 0.5 - eps) {
- while(*--s == '0');
- s++;
- goto ret1;
- }
- break;
- }
- }
-#ifndef No_leftright
- }
-#endif
- fast_failed:
- s = s0;
- d = d2;
- k = k0;
- ilim = ilim0;
- }
-
- /* Do we have a "small" integer? */
-
- if (be >= 0 && k <= Int_max) {
- /* Yes. */
- ds = tens[k];
- if (ndigits < 0 && ilim <= 0) {
- if (ilim < 0 || d <= 5*ds)
- goto no_digits;
- goto one_digit;
- }
- for(i = 1;; i++) {
- L = (_G_int32_t)(d / ds);
- d -= L*ds;
-#ifdef Check_FLT_ROUNDS
- /* If FLT_ROUNDS == 2, L will usually be high by 1 */
- if (d < 0) {
- L--;
- d += ds;
- }
-#endif
- *s++ = '0' + (int)L;
- if (i == ilim) {
- d += d;
- if (d > ds || (d == ds && L & 1)) {
- bump_up:
- while(*--s == '9')
- if (s == s0) {
- k++;
- *s = '0';
- break;
- }
- ++*s++;
- }
- break;
- }
- if (!(d *= 10.))
- break;
- }
- goto ret1;
- }
-
- m2 = b2;
- m5 = b5;
- if (leftright) {
- if (mode < 2) {
- i =
-#ifndef Sudden_Underflow
- denorm ? be + (Bias + (P-1) - 1 + 1) :
-#endif
-#ifdef IBM
- 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3);
-#else
- 1 + P - bbits;
-#endif
- }
- else {
- j = ilim - 1;
- if (m5 >= j)
- m5 -= j;
- else {
- s5 += j -= m5;
- b5 += j;
- m5 = 0;
- }
- if ((i = ilim) < 0) {
- m2 -= i;
- i = 0;
- }
- }
- b2 += i;
- s2 += i;
- mhi = i2b(Binit(&_mhi), 1);
- }
- if (m2 > 0 && s2 > 0) {
- i = m2 < s2 ? m2 : s2;
- b2 -= i;
- m2 -= i;
- s2 -= i;
- }
- if (b5 > 0) {
- if (leftright) {
- if (m5 > 0) {
- Bigint *b_tmp;
- mhi = pow5mult(mhi, m5);
- b_tmp = mult(b_avail, mhi, b);
- b_avail = b;
- b = b_tmp;
- }
- if ((j = b5 - m5))
- b = pow5mult(b, j);
- }
- else
- b = pow5mult(b, b5);
- }
- S = i2b(S, 1);
- if (s5 > 0)
- S = pow5mult(S, s5);
-
- /* Check for special case that d is a normalized power of 2. */
-
- if (mode < 2) {
- if (!word1(d) && !(word0(d) & Bndry_mask)
-#ifndef Sudden_Underflow
- && word0(d) & Exp_mask
-#endif
- ) {
- /* The special case */
- b2 += Log2P;
- s2 += Log2P;
- spec_case = 1;
- }
- else
- spec_case = 0;
- }
-
- /* Arrange for convenient computation of quotients:
- * shift left if necessary so divisor has 4 leading 0 bits.
- *
- * Perhaps we should just compute leading 28 bits of S once
- * and for all and pass them and a shift to quorem, so it
- * can do shifts and ors to compute the numerator for q.
- */
- if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f))
- i = 32 - i;
- if (i > 4) {
- i -= 4;
- b2 += i;
- m2 += i;
- s2 += i;
- }
- else if (i < 4) {
- i += 28;
- b2 += i;
- m2 += i;
- s2 += i;
- }
- if (b2 > 0)
- b = lshift(b, b2);
- if (s2 > 0)
- S = lshift(S, s2);
- if (k_check) {
- if (cmp(b,S) < 0) {
- k--;
- b = multadd(b, 10, 0); /* we botched the k estimate */
- if (leftright)
- mhi = multadd(mhi, 10, 0);
- ilim = ilim1;
- }
- }
- if (ilim <= 0 && mode > 2) {
- if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) {
- /* no digits, fcvt style */
- no_digits:
- k = -1 - ndigits;
- goto ret;
- }
- one_digit:
- *s++ = '1';
- k++;
- goto ret;
- }
- if (leftright) {
- if (m2 > 0)
- mhi = lshift(mhi, m2);
-
- /* Compute mlo -- check for special case
- * that d is a normalized power of 2.
- */
-
- if (spec_case) {
- mlo = Brealloc(Binit(&_mlo), mhi->k);
- Bcopy(mlo, mhi);
- mhi = lshift(mhi, Log2P);
- }
- else
- mlo = mhi;
-
- for(i = 1;;i++) {
- dig = quorem(b,S) + '0';
- /* Do we yet have the shortest decimal string
- * that will round to d?
- */
- j = cmp(b, mlo);
- b_avail = diff(b_avail, S, mhi); /* b_avail = S - mi */
- j1 = b_avail->sign ? 1 : cmp(b, b_avail);
-#ifndef ROUND_BIASED
- if (j1 == 0 && !mode && !(word1(d) & 1)) {
- if (dig == '9')
- goto round_9_up;
- if (j > 0)
- dig++;
- *s++ = dig;
- goto ret;
- }
-#endif
- if (j < 0 || (j == 0 && !mode
-#ifndef ROUND_BIASED
- && !(word1(d) & 1)
-#endif
- )) {
- if (j1 > 0) {
- b = lshift(b, 1);
- j1 = cmp(b, S);
- if ((j1 > 0 || (j1 == 0 && dig & 1))
- && dig++ == '9')
- goto round_9_up;
- }
- *s++ = dig;
- goto ret;
- }
- if (j1 > 0) {
- if (dig == '9') { /* possible if i == 1 */
- round_9_up:
- *s++ = '9';
- goto roundoff;
- }
- *s++ = dig + 1;
- goto ret;
- }
- *s++ = dig;
- if (i == ilim)
- break;
- b = multadd(b, 10, 0);
- if (mlo == mhi)
- mlo = mhi = multadd(mhi, 10, 0);
- else {
- mlo = multadd(mlo, 10, 0);
- mhi = multadd(mhi, 10, 0);
- }
- }
- }
- else
- for(i = 1;; i++) {
- *s++ = dig = quorem(b,S) + '0';
- if (i >= ilim)
- break;
- b = multadd(b, 10, 0);
- }
-
- /* Round off last digit */
-
- b = lshift(b, 1);
- j = cmp(b, S);
- if (j > 0 || (j == 0 && dig & 1)) {
- roundoff:
- while(*--s == '9')
- if (s == s0) {
- k++;
- *s++ = '1';
- goto ret;
- }
- ++*s++;
- }
- else {
- while(*--s == '0');
- s++;
- }
- ret:
- Bfree(b_avail);
- Bfree(S);
- if (mhi) {
- if (mlo && mlo != mhi)
- Bfree(mlo);
- Bfree(mhi);
- }
- ret1:
- Bfree(b);
- *s = 0;
- *decpt = k + 1;
- if (rve)
- *rve = s;
- return s0;
- }
-#endif /* _IO_USE_DTOA */
diff --git a/gnu/lib/libg++/libio/fstream.cc b/gnu/lib/libg++/libio/fstream.cc
deleted file mode 100644
index a9ca9f6..0000000
--- a/gnu/lib/libg++/libio/fstream.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License.
-
-Written by Per Bothner (bothner@cygnus.com). */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#define _STREAM_COMPAT
-extern "C" {
-#include "libioP.h"
-}
-#include <fstream.h>
-
-fstreambase::fstreambase()
-{
- init(filebuf::__new());
-}
-
-fstreambase::fstreambase(int fd)
-{
- init(filebuf::__new());
- _IO_file_attach(rdbuf(), fd);
-}
-
-fstreambase::fstreambase(const char *name, int mode, int prot)
-{
- init(filebuf::__new());
- if (!rdbuf()->open(name, mode, prot))
- set(ios::badbit);
-}
-
-fstreambase::fstreambase(int fd, char *p, int l)
-{
- init(filebuf::__new());
- _IO_file_attach(rdbuf(), fd);
- _IO_file_setbuf(rdbuf(), p, l);
-}
-
-void fstreambase::open(const char *name, int mode, int prot)
-{
- clear();
- if (!rdbuf()->open(name, mode, prot))
- set(ios::badbit);
-}
-
-void fstreambase::close()
-{
- if (!rdbuf()->close())
- set(ios::failbit);
-}
-
-#if 0
-static int mode_to_sys(enum open_mode mode)
-{
- return O_WRONLY;
-}
-
-static char* fopen_cmd_arg(io_mode i)
-{
- return "w";
-}
-#endif
diff --git a/gnu/lib/libg++/libio/genops.c b/gnu/lib/libg++/libio/genops.c
deleted file mode 100644
index 71989a5..0000000
--- a/gnu/lib/libg++/libio/genops.c
+++ /dev/null
@@ -1,867 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Generic or default I/O operations. */
-
-#include "libioP.h"
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#include <string.h>
-
-void _IO_un_link(fp)
- _IO_FILE *fp;
-{
- if (fp->_flags & _IO_LINKED) {
- _IO_FILE **f;
- for (f = &_IO_list_all; *f != NULL; f = &(*f)->_chain) {
- if (*f == fp) {
- *f = fp->_chain;
- break;
- }
- }
- fp->_flags &= ~_IO_LINKED;
- }
-}
-
-void _IO_link_in(fp)
- _IO_FILE *fp;
-{
- if ((fp->_flags & _IO_LINKED) == 0) {
- fp->_flags |= _IO_LINKED;
- fp->_chain = _IO_list_all;
- _IO_list_all = fp;
- }
-}
-
-/* Return minimum _pos markers
- Assumes the current get area is the main get area. */
-
-_IO_size_t
-_IO_least_marker(fp)
- register _IO_FILE *fp;
-{
- _IO_ssize_t least_so_far = fp->_IO_read_end - fp->_IO_read_base;
- register struct _IO_marker *mark;
- for (mark = fp->_markers; mark != NULL; mark = mark->_next)
- if (mark->_pos < least_so_far)
- least_so_far = mark->_pos;
- return least_so_far;
-}
-
-/* Switch current get area from backup buffer to (start of) main get area. */
-
-void
-_IO_switch_to_main_get_area(fp)
- _IO_FILE *fp;
-{
- char *tmp;
- fp->_flags &= ~_IO_IN_BACKUP;
- /* Swap _IO_read_end and _IO_save_end. */
- tmp = fp->_IO_read_end; fp->_IO_read_end= fp->_IO_save_end; fp->_IO_save_end= tmp;
- /* Swap _IO_read_base and _IO_save_base. */
- tmp = fp->_IO_read_base; fp->_IO_read_base = fp->_IO_save_base; fp->_IO_save_base = tmp;
- fp->_IO_read_ptr = fp->_IO_read_base;
-}
-
-/* Switch current get area from main get area to (end of) backup area. */
-
-void
-_IO_switch_to_backup_area(fp)
- register _IO_FILE *fp;
-{
- char *tmp;
- fp->_flags |= _IO_IN_BACKUP;
- /* Swap _IO_read_end and _IO_save_end. */
- tmp = fp->_IO_read_end; fp->_IO_read_end = fp->_IO_save_end; fp->_IO_save_end = tmp;
- /* Swap _gbase and _IO_save_base. */
- tmp = fp->_IO_read_base; fp->_IO_read_base = fp->_IO_save_base; fp->_IO_save_base = tmp;
- fp->_IO_read_ptr = fp->_IO_read_end;
-}
-
-int
-_IO_switch_to_get_mode(fp)
- register _IO_FILE *fp;
-{
- if (fp->_IO_write_ptr > fp->_IO_write_base)
- if (fp->_jumps->__overflow(fp, EOF) == EOF)
- return EOF;
- if (_IO_in_backup(fp))
- fp->_IO_read_base = fp->_IO_backup_base;
- else
- {
- fp->_IO_read_base = fp->_IO_buf_base;
- if (fp->_IO_write_ptr > fp->_IO_read_end)
- fp->_IO_read_end = fp->_IO_write_ptr;
- }
- fp->_IO_read_ptr = fp->_IO_write_ptr;
-
- fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = fp->_IO_read_ptr;
-
- fp->_flags &= ~_IO_CURRENTLY_PUTTING;
- return 0;
-}
-
-void
-_IO_free_backup_area(fp)
- register _IO_FILE *fp;
-{
- if (_IO_in_backup (fp))
- _IO_switch_to_main_get_area(fp); /* Just in case. */
- free (fp->_IO_save_base);
- fp->_IO_save_base = NULL;
- fp->_IO_save_end = NULL;
- fp->_IO_backup_base = NULL;
-}
-
-#if 0
-int
-_IO_switch_to_put_mode(fp)
- register _IO_FILE *fp;
-{
- fp->_IO_write_base = fp->_IO_read_ptr;
- fp->_IO_write_ptr = fp->_IO_read_ptr;
- /* Following is wrong if line- or un-buffered? */
- fp->_IO_write_end = fp->_flags & _IO_IN_BACKUP ? fp->_IO_read_end : fp->_IO_buf_end;
-
- fp->_IO_read_ptr = fp->_IO_read_end;
- fp->_IO_read_base = fp->_IO_read_end;
-
- fp->_flags |= _IO_CURRENTLY_PUTTING;
- return 0;
-}
-#endif
-
-int __overflow(f, ch)
- _IO_FILE *f;
- int ch;
-{
- return f->_jumps->__overflow(f, ch);
-}
-
-static int
-save_for_backup (fp)
- _IO_FILE *fp;
-{
- /* Append [_IO_read_base.._IO_read_end] to backup area. */
- int least_mark = _IO_least_marker(fp);
- /* needed_size is how much space we need in the backup area. */
- int needed_size = (fp->_IO_read_end - fp->_IO_read_base) - least_mark;
- int current_Bsize = fp->_IO_save_end - fp->_IO_save_base;
- int avail; /* Extra space available for future expansion. */
- int delta;
- struct _IO_marker *mark;
- if (needed_size > current_Bsize)
- {
- char *new_buffer;
- avail = 100;
- new_buffer = (char*)malloc(avail+needed_size);
- if (new_buffer == NULL)
- return EOF; /* FIXME */
- if (least_mark < 0)
- {
- memcpy(new_buffer + avail,
- fp->_IO_save_end + least_mark,
- -least_mark);
- memcpy(new_buffer +avail - least_mark,
- fp->_IO_read_base,
- fp->_IO_read_end - fp->_IO_read_base);
- }
- else
- memcpy(new_buffer + avail,
- fp->_IO_read_base + least_mark,
- needed_size);
- if (fp->_IO_save_base)
- free (fp->_IO_save_base);
- fp->_IO_save_base = new_buffer;
- fp->_IO_save_end = new_buffer + avail + needed_size;
- }
- else
- {
- avail = current_Bsize - needed_size;
- if (least_mark < 0)
- {
- memmove(fp->_IO_save_base + avail,
- fp->_IO_save_end + least_mark,
- -least_mark);
- memcpy(fp->_IO_save_base + avail - least_mark,
- fp->_IO_read_base,
- fp->_IO_read_end - fp->_IO_read_base);
- }
- else if (needed_size > 0)
- memcpy(fp->_IO_save_base + avail,
- fp->_IO_read_base + least_mark,
- needed_size);
- }
- /* FIXME: Dubious arithmetic if pointers are NULL */
- fp->_IO_backup_base = fp->_IO_save_base + avail;
- /* Adjust all the streammarkers. */
- delta = fp->_IO_read_end - fp->_IO_read_base;
- for (mark = fp->_markers; mark != NULL; mark = mark->_next)
- mark->_pos -= delta;
- return 0;
-}
-
-int
-__underflow(fp)
- _IO_FILE *fp;
-{
- if (_IO_in_put_mode(fp))
- if (_IO_switch_to_get_mode(fp) == EOF) return EOF;
- if (fp->_IO_read_ptr < fp->_IO_read_end)
- return *(unsigned char*)fp->_IO_read_ptr;
- if (_IO_in_backup(fp))
- {
- _IO_switch_to_main_get_area(fp);
- if (fp->_IO_read_ptr < fp->_IO_read_end)
- return *fp->_IO_read_ptr;
- }
- if (_IO_have_markers(fp))
- {
- if (save_for_backup (fp))
- return EOF;
- }
- else if (_IO_have_backup(fp))
- _IO_free_backup_area(fp);
- return fp->_jumps->__underflow(fp);
-}
-
-int
-__uflow(fp)
- _IO_FILE *fp;
-{
- if (_IO_in_put_mode(fp))
- if (_IO_switch_to_get_mode(fp) == EOF) return EOF;
- if (fp->_IO_read_ptr < fp->_IO_read_end)
- return *(unsigned char*)fp->_IO_read_ptr++;
- if (_IO_in_backup(fp))
- {
- _IO_switch_to_main_get_area(fp);
- if (fp->_IO_read_ptr < fp->_IO_read_end)
- return *fp->_IO_read_ptr++;
- }
- if (_IO_have_markers(fp))
- {
- if (save_for_backup (fp))
- return EOF;
- }
- else if (_IO_have_backup(fp))
- _IO_free_backup_area(fp);
- return fp->_jumps->__uflow(fp);
-}
-
-void
-_IO_setb(f, b, eb, a)
- _IO_FILE *f;
- char *b;
- char *eb;
- int a;
-{
- if (f->_IO_buf_base && !(f->_flags & _IO_USER_BUF))
- FREE_BUF(f->_IO_buf_base);
- f->_IO_buf_base = b;
- f->_IO_buf_end = eb;
- if (a)
- f->_flags &= ~_IO_USER_BUF;
- else
- f->_flags |= _IO_USER_BUF;
-}
-
-void
-_IO_doallocbuf(fp)
- register _IO_FILE *fp;
-{
- if (fp->_IO_buf_base)
- return;
- if (!(fp->_flags & _IO_UNBUFFERED))
- if (fp->_jumps->__doallocate(fp) != EOF)
- return;
- _IO_setb(fp, fp->_shortbuf, fp->_shortbuf+1, 0);
-}
-
-int
-_IO_default_underflow (fp)
- _IO_FILE *fp;
-{
- return EOF;
-}
-
-int
-_IO_default_uflow (fp)
- _IO_FILE *fp;
-{
- int ch = fp->_jumps->__underflow(fp);
- if (ch == EOF)
- return EOF;
- return *(unsigned char*)fp->_IO_read_ptr++;
-}
-
-_IO_size_t
-_IO_default_xsputn(f, data, n)
- register _IO_FILE *f;
- const void *data;
- _IO_size_t n;
-{
- register const char *s = data;
- register _IO_size_t more = n;
- if (more <= 0)
- return 0;
- for (;;)
- {
- _IO_ssize_t count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */
- if (count > 0)
- {
- if (count > more)
- count = more;
- if (count > 20)
- {
- memcpy(f->_IO_write_ptr, s, count);
- s += count;
- f->_IO_write_ptr += count;
- }
- else if (count <= 0)
- count = 0;
- else
- {
- register char *p = f->_IO_write_ptr;
- register _IO_ssize_t i;
- for (i = count; --i >= 0; ) *p++ = *s++;
- f->_IO_write_ptr = p;
- }
- more -= count;
- }
- if (more == 0 || __overflow(f, (unsigned char)*s++) == EOF)
- break;
- more--;
- }
- return n - more;
-}
-
-_IO_size_t
-_IO_sgetn(fp, data, n)
- _IO_FILE *fp;
- void *data;
- _IO_size_t n;
-{
- /* FIXME handle putback buffer here! */
- return fp->_jumps->__xsgetn(fp, data, n);
-}
-
-_IO_size_t
-_IO_default_xsgetn(fp, data, n)
- _IO_FILE *fp;
- void *data;
- _IO_size_t n;
-{
- register _IO_size_t more = n;
- register char *s = data;
- for (;;)
- {
- _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr; /* Data available. */
- if (count > 0)
- {
- if (count > more)
- count = more;
- if (count > 20)
- {
- memcpy(s, fp->_IO_read_ptr, count);
- s += count;
- fp->_IO_read_ptr += count;
- }
- else if (count <= 0)
- count = 0;
- else
- {
- register char *p = fp->_IO_read_ptr;
- register int i = (int)count;
- while (--i >= 0) *s++ = *p++;
- fp->_IO_read_ptr = p;
- }
- more -= count;
- }
- if (more == 0 || __underflow(fp) == EOF)
- break;
- }
- return n - more;
-}
-
-int
-_IO_sync(fp)
- register _IO_FILE *fp;
-{
- if (fp->_IO_read_ptr == fp->_IO_read_end && fp->_IO_write_ptr == fp->_IO_write_base)
- return 0;
- return EOF;
-}
-
-int
-_IO_default_setbuf(fp, p, len)
- register _IO_FILE *fp;
- char* p;
- _IO_ssize_t len;
-{
- if (fp->_jumps->__sync(fp) == EOF)
- return EOF;
- if (p == NULL || len == 0)
- {
- fp->_flags |= _IO_UNBUFFERED;
- _IO_setb(fp, fp->_shortbuf, fp->_shortbuf+1, 0);
- }
- else
- {
- fp->_flags &= ~_IO_UNBUFFERED;
- _IO_setb(fp, p, p+len, 0);
- }
- fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = 0;
- fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_read_end = 0;
- return 0;
-}
-
-_IO_pos_t
-_IO_default_seekpos(fp, pos, mode)
- _IO_FILE *fp;
- _IO_pos_t pos;
- _IO_seekflags mode;
-{
- return fp->_jumps->__seekoff(fp, _IO_pos_as_off(pos), mode);
-}
-
-int
-_IO_default_doallocate(fp)
- _IO_FILE *fp;
-{
- char *buf = ALLOC_BUF(_IO_BUFSIZ);
- if (buf == NULL)
- return EOF;
- _IO_setb(fp, buf, buf+_IO_BUFSIZ, 1);
- return 1;
-}
-
-void
-_IO_init(fp, flags)
- register _IO_FILE *fp;
- int flags;
-{
- fp->_flags = _IO_MAGIC|flags;
- fp->_IO_buf_base = NULL;
- fp->_IO_buf_end = NULL;
- fp->_IO_read_base = NULL;
- fp->_IO_read_ptr = NULL;
- fp->_IO_read_end = NULL;
- fp->_IO_write_base = NULL;
- fp->_IO_write_ptr = NULL;
- fp->_IO_write_end = NULL;
- fp->_chain = NULL; /* Not necessary. */
-
- fp->_IO_save_base = NULL;
- fp->_IO_backup_base = NULL;
- fp->_IO_save_end = NULL;
- fp->_markers = NULL;
- fp->_cur_column = 0;
-}
-
-int
-_IO_default_sync (fp)
- _IO_FILE *fp;
-{
- return 0;
-}
-
-/* The way the C++ classes are mapped into the C functions in the
- current implementation, this function can get called twice! */
-
-void _IO_default_finish (fp)
- _IO_FILE *fp;
-{
- struct _IO_marker *mark;
- if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
- {
- FREE_BUF(fp->_IO_buf_base);
- fp->_IO_buf_base = fp->_IO_buf_end = NULL;
- }
-
- for (mark = fp->_markers; mark != NULL; mark = mark->_next)
- mark->_sbuf = NULL;
-
- if (fp->_IO_save_base)
- {
- free (fp->_IO_save_base);
- fp->_IO_save_base = NULL;
- }
-
- _IO_un_link(fp);
-}
-
-_IO_pos_t
-_IO_default_seekoff(fp, offset, mode)
- register _IO_FILE *fp;
- _IO_off_t offset;
- _IO_seekflags mode;
-{
- return _IO_pos_BAD;
-}
-
-int
-_IO_sputbackc(fp, c) /* ungetc(c, fp) */
- register _IO_FILE *fp;
- int c;
-{
- if (fp->_IO_read_ptr > fp->_IO_read_base
- && (unsigned char)fp->_IO_read_ptr[-1] == (unsigned char)c)
- {
- fp->_IO_read_ptr--;
- return (unsigned char)c;
- }
- return fp->_jumps->__pbackfail(fp, c);
-}
-
-int
-_IO_sungetc(fp)
- register _IO_FILE *fp;
-{
- if (fp->_IO_read_ptr > fp->_IO_read_base)
- {
- fp->_IO_read_ptr--;
- return (unsigned char)*fp->_IO_read_ptr;
- }
- else
- return fp->_jumps->__pbackfail(fp, EOF);
-}
-
-#if 0 /* Work in progress */
-void
-_IO_set_column(fp, c)
- register _IO_FILE *fp;
- int c;
-{
- if (c == -1)
- fp->_collumn = -1;
- else
- fp->_collumn = c - (fp->_IO_write_ptr - fp->_IO_write_base);
-}
-#else
-int
-_IO_set_column(fp, i)
- register _IO_FILE *fp;
- int i;
-{
- fp->_cur_column = i+1;
- return 0;
-}
-#endif
-
-
-unsigned
-_IO_adjust_column(start, line, count)
- unsigned start;
- const char *line;
- int count;
-{
- register const char *ptr = line + count;
- while (ptr > line)
- if (*--ptr == '\n')
- return line + count - ptr - 1;
- return start + count;
-}
-
-int
-_IO_get_column(fp)
- register _IO_FILE *fp;
-{
- if (fp->_cur_column)
- return _IO_adjust_column(fp->_cur_column - 1,
- fp->_IO_write_base,
- fp->_IO_write_ptr - fp->_IO_write_base);
- return -1;
-}
-
-int
-_IO_flush_all()
-{
- int result = 0;
- _IO_FILE *fp;
- for (fp = _IO_list_all; fp != NULL; fp = fp->_chain)
- if (fp->_IO_write_ptr > fp->_IO_write_base
- && fp->_jumps->__overflow(fp, EOF) == EOF)
- result = EOF;
- return result;
-}
-
-void
-_IO_flush_all_linebuffered()
-{
- _IO_FILE *fp;
- for (fp = _IO_list_all; fp != NULL; fp = fp->_chain)
- if (fp->_flags & _IO_LINE_BUF)
- fp->_jumps->__overflow(fp, EOF);
-}
-
-void
-_IO_unbuffer_all ()
-{
- _IO_FILE *fp;
- for (fp = _IO_list_all; fp != NULL; fp = fp->_chain)
- if (! (fp->_flags & _IO_UNBUFFERED))
- fp->_jumps->__setbuf(fp, NULL, 0);
-}
-
-void
-_IO_cleanup ()
-{
- _IO_flush_all ();
-
- /* We currently don't have a reliable mechanism for making sure that
- C++ static destructors are executed in the correct order.
- So it is possible that other static destructord might want to
- write to cout - and they're supposed to be able to do so.
-
- The following will make the standard streambufs be unbuffered,
- which forces any output from late destructors to be written out. */
- _IO_unbuffer_all ();
-}
-
-void _IO_init_marker(marker, fp)
- struct _IO_marker *marker;
- _IO_FILE *fp;
-{
- marker->_sbuf = fp;
- if (_IO_in_put_mode(fp))
- _IO_switch_to_get_mode(fp);
- if (_IO_in_backup(fp))
- marker->_pos = fp->_IO_read_ptr - fp->_IO_read_end;
- else
- marker->_pos = fp->_IO_read_ptr - fp->_IO_read_base;
-
- /* Should perhaps sort the chain? */
- marker->_next = fp->_markers;
- fp->_markers = marker;
-}
-
-void
-_IO_remove_marker (marker)
- register struct _IO_marker * marker;
-{
- /* Unlink from sb's chain. */
- register struct _IO_marker **ptr = &marker->_sbuf->_markers;
- for (; ; ptr = &(*ptr)->_next)
- {
- if (*ptr == NULL)
- break;
- else if (*ptr == marker)
- {
- *ptr = marker->_next;
- return;
- }
- }
-#if 0
- if _sbuf has a backup area that is no longer needed, should we delete
- it now, or wait until the next underflow?
-#endif
-}
-
-#define BAD_DELTA EOF
-
-int
-_IO_marker_difference(mark1, mark2)
- struct _IO_marker *mark1;
- struct _IO_marker *mark2;
-{
- return mark1->_pos - mark2->_pos;
-}
-
-/* Return difference between MARK and current posistion of MARK's stream. */
-int
-_IO_marker_delta(mark)
- struct _IO_marker *mark;
-{
- int cur_pos;
- if (mark->_sbuf == NULL)
- return BAD_DELTA;
- if (_IO_in_backup(mark->_sbuf))
- cur_pos = mark->_sbuf->_IO_read_ptr - mark->_sbuf->_IO_read_end;
- else
- cur_pos = mark->_sbuf->_IO_read_ptr - mark->_sbuf->_IO_read_base;
- return mark->_pos - cur_pos;
-}
-
-int _IO_seekmark(fp, mark, delta)
- _IO_FILE *fp;
- struct _IO_marker *mark;
- int delta;
-{
- if (mark->_sbuf != fp)
- return EOF;
- if (mark->_pos >= 0)
- {
- if (_IO_in_backup(fp))
- _IO_switch_to_main_get_area(fp);
- fp->_IO_read_ptr = fp->_IO_read_base + mark->_pos;
- }
- else
- {
- if (!_IO_in_backup(fp))
- _IO_switch_to_backup_area(fp);
- fp->_IO_read_ptr = fp->_IO_read_end + mark->_pos;
- }
- return 0;
-}
-
-void _IO_unsave_markers(fp)
- register _IO_FILE *fp;
-{
- register struct _IO_marker *mark = fp->_markers;
- if (mark)
- {
-#ifdef TODO
- streampos offset = seekoff(0, ios::cur, ios::in);
- if (offset != EOF)
- {
- offset += eGptr() - Gbase();
- for ( ; mark != NULL; mark = mark->_next)
- mark->set_streampos(mark->_pos + offset);
- }
- else
- {
- for ( ; mark != NULL; mark = mark->_next)
- mark->set_streampos(EOF);
- }
-#endif
- fp->_markers = 0;
- }
-
- if (_IO_have_backup(fp))
- _IO_free_backup_area(fp);
-}
-
-int
-_IO_nobackup_pbackfail(fp, c)
- register _IO_FILE *fp;
- int c;
-{
- if (fp->_IO_read_ptr > fp->_IO_read_base)
- fp->_IO_read_ptr--;
- if (c != EOF && *fp->_IO_read_ptr != c)
- *fp->_IO_read_ptr = c;
- return (unsigned char)c;
-}
-
-int
-_IO_default_pbackfail(fp, c)
- register _IO_FILE *fp;
- int c;
-{
- if (fp->_IO_read_ptr <= fp->_IO_read_base)
- {
- /* Need to handle a filebuf in write mode (switch to read mode). FIXME!*/
- if (_IO_have_backup(fp) && !_IO_in_backup(fp))
- _IO_switch_to_backup_area(fp);
-
- if (!_IO_have_backup(fp))
- {
- /* No backup buffer: allocate one. */
- /* Use nshort buffer, if unused? (probably not) FIXME */
- int backup_size = 128;
- char *bbuf = (char*)malloc(backup_size);
- if (bbuf == NULL)
- return EOF;
- fp->_IO_save_base = bbuf;
- fp->_IO_save_end = fp->_IO_save_base + backup_size;
- fp->_IO_backup_base = fp->_IO_save_end;
- _IO_switch_to_backup_area(fp);
- }
- else if (fp->_IO_read_ptr <= fp->_IO_read_base)
- {
- /* Increase size of existing backup buffer. */
- _IO_size_t new_size;
- _IO_size_t old_size = fp->_IO_read_end - fp->_IO_read_base;
- char *new_buf;
- new_size = 2 * old_size;
- new_buf = (char*)malloc(new_size);
- if (new_buf == NULL)
- return EOF;
- memcpy(new_buf+(new_size-old_size), fp->_IO_read_base, old_size);
- free (fp->_IO_read_base);
- _IO_setg(fp,
- new_buf, new_buf+(new_size-old_size), new_buf+new_size);
- fp->_IO_backup_base = fp->_IO_read_ptr;
- }
- }
- fp->_IO_read_ptr--;
- if (c != EOF && *fp->_IO_read_ptr != c)
- *fp->_IO_read_ptr = c;
- return (unsigned char)*fp->_IO_read_ptr;
-}
-
-_IO_pos_t
-_IO_default_seek(fp, offset, dir)
- _IO_FILE *fp;
- _IO_off_t offset;
- int dir;
-{
- return _IO_pos_BAD;
-}
-
-int
-_IO_default_stat(fp, st)
- _IO_FILE *fp;
- void* st;
-{
- return EOF;
-}
-
-_IO_ssize_t
-_IO_default_read(fp, data, n)
- register _IO_FILE* fp;
- void* data;
- _IO_ssize_t n;
-{
- return -1;
-}
-
-_IO_ssize_t
-_IO_default_write(fp, data, n)
- register _IO_FILE* fp;
- const void* data;
- _IO_ssize_t n;
-{
- return 0;
-}
-
-
-#ifdef TODO
-#if defined(linux)
-#define IO_CLEANUP ;
-#endif
-
-#ifdef IO_CLEANUP
- IO_CLEANUP
-#else
-struct __io_defs {
- __io_defs() { }
- ~__io_defs() { _IO_cleanup(); }
-};
-__io_defs io_defs__;
-#endif
-
-#endif /* TODO */
diff --git a/gnu/lib/libg++/libio/indstream.cc b/gnu/lib/libg++/libio/indstream.cc
deleted file mode 100644
index 1468d45..0000000
--- a/gnu/lib/libg++/libio/indstream.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License.
-
-Written by Per Bothner (bothner@cygnus.com). */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include <indstream.h>
-
-indirectbuf::indirectbuf(streambuf *get, streambuf *put, int delete_mode)
-: streambuf()
-{
- _get_stream = get;
- _put_stream = put == NULL ? get : put;
- _delete_flags = delete_mode;
-}
-
-indirectbuf::~indirectbuf()
-{
- if (_delete_flags & ios::in) delete get_stream();
- if (_delete_flags & ios::out) delete put_stream();
-}
-
-int indirectbuf::xsputn(const char* s, int n)
-{
- return put_stream()->sputn(s, n);
-}
-
-int indirectbuf::xsgetn(char* s, int n)
-{
- return get_stream()->sgetn(s, n);
-}
-
-int indirectbuf::overflow(int c /* = EOF */)
-{
- if (c == EOF)
- return put_stream()->overflow(c);
- else
- return put_stream()->sputc(c);
-}
-
-int indirectbuf::underflow()
-{
- return get_stream()->sbumpc();
-}
-
-streampos indirectbuf::seekoff(streamoff off, _seek_dir dir, int mode)
-{
- int ret_val = 0;
- int select = mode == 0 ? (ios::in|ios::out) : mode;
- streambuf *gbuf = (select & ios::in) ? get_stream() : NULL;
- streambuf *pbuf = (select & ios::out) ? put_stream() : NULL;
- if (gbuf == pbuf)
- ret_val = gbuf->seekoff(off, dir, mode);
- else {
- if (gbuf)
- ret_val = gbuf->seekoff(off, dir, ios::in);
- if (pbuf && ret_val != EOF)
- ret_val = pbuf->seekoff(off, dir, ios::out);
- }
- return ret_val;
-}
-
-streampos indirectbuf::seekpos(streampos pos, int mode)
-{
- int ret_val = EOF;
- int select = mode == 0 ? (ios::in|ios::out) : mode;
- streambuf *gbuf = (select & ios::in) ? get_stream() : NULL;
- streambuf *pbuf = (select & ios::out) ? put_stream() : NULL;
- if (gbuf == pbuf)
- ret_val = gbuf->seekpos(pos, mode);
- else {
- if (gbuf)
- ret_val = gbuf->seekpos(pos, ios::in);
- if (pbuf && ret_val != EOF)
- ret_val = pbuf->seekpos(pos, ios::out);
- }
- return ret_val;
-}
-
-int indirectbuf::sync()
-{
- streambuf *gbuf = get_stream();
- int get_ret_val = gbuf ? gbuf->sync() : 0;
- streambuf *pbuf = put_stream();
- int put_ret_val = (pbuf && pbuf != gbuf) ? pbuf->sync() : 0;
- return get_ret_val || put_ret_val;
-}
-
-int indirectbuf::pbackfail(int c)
-{
- return get_stream()->sputbackc(c);
-}
diff --git a/gnu/lib/libg++/libio/ioassign.cc b/gnu/lib/libg++/libio/ioassign.cc
deleted file mode 100644
index 5441ae7..0000000
--- a/gnu/lib/libg++/libio/ioassign.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1994 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 <iostream.h>
-#include "libioP.h"
-
-// These method are provided for backward compatibility reasons.
-// It's generally poor style to use them.
-// They are not supported by the ANSI/ISO working paper.
-
-_IO_istream_withassign& _IO_istream_withassign::operator=(istream& rhs)
-{
- if (&rhs != (istream*)this)
- {
- if (!(_flags & (unsigned int)ios::dont_close)) delete rdbuf();
- init (rhs.rdbuf ());
- _flags |= ios::dont_close;
- _gcount = 0;
- }
- return *this;
-}
-
-_IO_ostream_withassign& _IO_ostream_withassign::operator=(ostream& rhs)
-{
- if (&rhs != (ostream*)this)
- {
- if (!(_flags & (unsigned int)ios::dont_close)) delete rdbuf();
- init (rhs.rdbuf ());
- _flags |= ios::dont_close;
- }
- return *this;
-}
diff --git a/gnu/lib/libg++/libio/ioextend.cc b/gnu/lib/libg++/libio/ioextend.cc
deleted file mode 100644
index bc6a3e1..0000000
--- a/gnu/lib/libg++/libio/ioextend.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include <iostream.h>
-
-static int __xalloc = 0;
-
-int ios::xalloc()
-{
- return __xalloc++;
-}
-
-static ios::fmtflags __used_fmt_flags
-= ios::skipws | ios::left | ios::right | ios::internal
-| ios::dec | ios::oct | ios::hex | ios::showbase | ios::showpoint
-| ios::uppercase | ios::showpos | ios::scientific | ios::fixed
-| ios::unitbuf | ios::stdio | ios::dont_close;
-
-ios::fmtflags ios::bitalloc()
-{
- fmtflags bit_to_try = (fmtflags)1;
- for (; bit_to_try; bit_to_try <<= 1)
- {
- if ((__used_fmt_flags & bit_to_try) == 0)
- {
- __used_fmt_flags |= bit_to_try;
- return bit_to_try;
- }
- }
- return 0;
-}
-
-// NOTE: This implementation of ios::iword and ios::pword assumes
-// that these methods are seldom used, so we want to minimize
-// the space and time overhead when NOT using these methods.
-//
-// ANSI specifies two conceptually-infinite arrays, one whose
-// elements are longs, and one whose elements are (void*)s.
-// We implement this as a single array, each of whose element is
-// a (struct ptr_and_long), which has space for both a long and a void*.
-// We also specify that (the i field of) the 0'th element of the array
-// contains the allocated length of the array (not counting that
-// initial element).
-
-struct ptr_and_long {
- void *p;
- long i;
-};
-
-static struct ptr_and_long&
-get_array_element(ios& io, int index)
-{
- if (index < 0)
- io._throw_failure();
- register struct ptr_and_long *array = (ptr_and_long*)io._arrays;
- int old_length = array == NULL ? 0 : array[0].i;
- if (index >= old_length)
- {
- register int i;
- int new_length = index + 10;
- register struct ptr_and_long *new_array
- = new ptr_and_long[1 + new_length];
- if (array != NULL)
- {
- for (i = 1; i <= old_length; i++)
- new_array[i] = array[i];
- delete [] array;
- }
- for (i = old_length + 1; i <= new_length; i++)
- {
- new_array[i].i = 0;
- new_array[i].p = (void*)0;
- }
- new_array[0].i = new_length;
- new_array[0].p = (void*)0;
- io._arrays = (void*)new_array;
- array = new_array;
- }
- return array[index+1];
-}
-
-long& ios::iword(int index)
-{
- return get_array_element(*this, index).i;
-}
-
-void*& ios::pword(int index)
-{
- return get_array_element(*this, index).p;
-}
-
-long ios::iword(int index) const
-{
- if (index < 0)
- _throw_failure();
- register struct ptr_and_long *pl_array = (ptr_and_long*)_arrays;
- int len = pl_array == NULL ? 0 : pl_array[0].i;
- return index >= len ? 0 : pl_array[index+1].i;
-}
-
-void* ios::pword(int index) const
-{
- if (index < 0)
- _throw_failure();
- register struct ptr_and_long *pl_array = (ptr_and_long*)_arrays;
- int len = pl_array == NULL ? 0 : pl_array[0].i;
- return index >= len ? 0 : pl_array[index+1].p;
-}
diff --git a/gnu/lib/libg++/libio/iofclose.c b/gnu/lib/libg++/libio/iofclose.c
deleted file mode 100644
index d8ad3a6..0000000
--- a/gnu/lib/libg++/libio/iofclose.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-
-int
-_IO_fclose(fp)
- register _IO_FILE *fp;
-{
- int status = 0;
- CHECK_FILE(fp, EOF);
- if (fp->_IO_file_flags & _IO_IS_FILEBUF)
- status = _IO_file_close_it(fp);
- fp->_jumps->__finish(fp);
- if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr)
- {
- fp->_IO_file_flags = 0;
- free(fp);
- }
- return status;
-}
diff --git a/gnu/lib/libg++/libio/iofgetpos.c b/gnu/lib/libg++/libio/iofgetpos.c
deleted file mode 100644
index f345463..0000000
--- a/gnu/lib/libg++/libio/iofgetpos.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#include <errno.h>
-/* ANSI explicily requires setting errno to a positive value on failure. */
-
-int
-_IO_fgetpos(fp, posp)
- _IO_FILE* fp;
- _IO_fpos_t *posp;
-{
- _IO_fpos_t pos;
- CHECK_FILE(fp, EOF);
- pos = _IO_seekoff(fp, 0, _IO_seek_cur|_IO_seek_not_in|_IO_seek_not_out);
- if (pos == _IO_pos_BAD)
- {
-#ifdef EIO
- if (errno == 0)
- errno = EIO;
-#endif
- return EOF;
- }
- *posp = pos;
- return 0;
-}
diff --git a/gnu/lib/libg++/libio/iofread.c b/gnu/lib/libg++/libio/iofread.c
deleted file mode 100644
index 9cb633e..0000000
--- a/gnu/lib/libg++/libio/iofread.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-
-_IO_size_t
-_IO_fread(buf, size, count, fp)
- void *buf;
- _IO_size_t size;
- _IO_size_t count;
- _IO_FILE* fp;
-{
- _IO_size_t bytes_requested = size*count;
- _IO_size_t bytes_read;
- CHECK_FILE(fp, 0);
- if (bytes_requested == 0)
- return 0;
- bytes_read = _IO_sgetn(fp, (char *)buf, bytes_requested);
- return bytes_requested == bytes_read ? count : bytes_read / size;
-}
diff --git a/gnu/lib/libg++/libio/iofscanf.c b/gnu/lib/libg++/libio/iofscanf.c
deleted file mode 100644
index fc43d7e..0000000
--- a/gnu/lib/libg++/libio/iofscanf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-int
-_IO_fscanf
-#ifdef __STDC__
- (_IO_FILE *fp, const char* format, ...)
-#else
-(fp, format, va_alist) _IO_FILE *fp; char *format; va_dcl
-#endif
-{
- int ret;
- va_list args;
- CHECK_FILE(fp, EOF);
- _IO_va_start(args, format);
- ret = _IO_vfscanf(fp, format, args, NULL);
- va_end(args);
- return ret;
-}
diff --git a/gnu/lib/libg++/libio/iofsetpos.c b/gnu/lib/libg++/libio/iofsetpos.c
deleted file mode 100644
index 5f2023b..0000000
--- a/gnu/lib/libg++/libio/iofsetpos.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include <libioP.h>
-#include <errno.h>
-
-int
-_IO_fsetpos(fp, posp)
- _IO_FILE* fp;
- const _IO_fpos_t *posp;
-{
- CHECK_FILE(fp, EOF);
- if (_IO_seekpos(fp, *posp, 0) == _IO_pos_BAD)
- {
- /*ANSI explicily requires setting errno to a positive value on failure.*/
-#ifdef EIO
- if (errno == 0)
- errno = EIO;
-#endif
- return EOF;
- }
- return 0;
-}
diff --git a/gnu/lib/libg++/libio/iogetdelim.c b/gnu/lib/libg++/libio/iogetdelim.c
deleted file mode 100644
index 42527ff..0000000
--- a/gnu/lib/libg++/libio/iogetdelim.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-Copyright (C) 1994 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. */
-
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#include "libioP.h"
-#include <string.h>
-#include <errno.h>
-
-/* Read up to (and including) a TERMINATOR from FP into *LINEPTR
- (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
- NULL), pointing to *N characters of space. It is realloc'ed as
- necessary. Returns the number of characters read (not including the
- null terminator), or -1 on error or EOF. */
-
-_IO_ssize_t
-_IO_getdelim (lineptr, n, delimiter, fp)
- char **lineptr;
- _IO_size_t *n;
- int delimiter;
- _IO_FILE *fp;
-{
- register _IO_ssize_t cur_len = 0;
- _IO_ssize_t len;
-
- if (lineptr == NULL || n == NULL)
- {
-#ifdef EINVAL
- errno = EINVAL;
-#endif
- return -1;
- }
- CHECK_FILE (fp, -1);
- if (_IO_ferror (fp))
- return -1;
-
- if (*lineptr == NULL || *n == 0)
- {
- *n = 120;
- *lineptr = (char *) malloc (*n);
- if (*lineptr == NULL)
- return -1;
- }
-
- len = fp->_IO_read_end - fp->_IO_read_ptr;
- if (len <= 0)
- {
- if (__underflow (fp) == EOF)
- return -1;
- len = fp->_IO_read_end - fp->_IO_read_ptr;
- }
-
- for (;;)
- {
- _IO_size_t needed;
- char *t;
- t = (char *) memchr ((void *) fp->_IO_read_ptr, delimiter, len);
- if (t != NULL)
- len = (t - fp->_IO_read_ptr) + 1;
- /* make enough space for len+1 (for final NUL) bytes. */
- needed = cur_len + len + 1;
- if (needed > *n)
- {
- if (t == NULL && needed < 2 * *n)
- needed = 2 * *n; /* Be generous. */
- *n = needed;
- *lineptr = (char *) realloc (*lineptr, needed);
- if (*lineptr == NULL)
- return -1;
- }
- memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len);
- fp->_IO_read_ptr += len;
- cur_len += len;
- if (t != NULL || __underflow (fp) == EOF)
- break;
- len = fp->_IO_read_end - fp->_IO_read_ptr;
- }
- lineptr[cur_len] = '\0';
- return cur_len;
-}
diff --git a/gnu/lib/libg++/libio/iogetline.c b/gnu/lib/libg++/libio/iogetline.c
deleted file mode 100644
index 9ca1b70..0000000
--- a/gnu/lib/libg++/libio/iogetline.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#include <string.h>
-
-/* Algorithm based on that used by Berkeley pre-4.4 fgets implementation.
-
- Read chars into buf (of size n), until delim is seen.
- Return number of chars read (at most n).
- Does not put a terminating '\0' in buf.
- If extract_delim < 0, leave delimiter unread.
- If extract_delim > 0, insert delim in output. */
-
-_IO_size_t
-_IO_getline(fp, buf, n, delim, extract_delim)
- _IO_FILE *fp;
- char* buf;
- _IO_size_t n;
- int delim;
- int extract_delim;
-{
- register char *ptr = buf;
- do
- {
- _IO_ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr;
- char *t;
- if (len <= 0)
- if (__underflow(fp) == EOF)
- break;
- else
- len = fp->_IO_read_end - fp->_IO_read_ptr;
- if (len >= n)
- len = n;
- t = (char*)memchr((void*)fp->_IO_read_ptr, delim, len);
- if (t != NULL)
- {
- _IO_size_t old_len = ptr-buf;
- len = t - fp->_IO_read_ptr;
- if (extract_delim >= 0)
- {
- t++;
- if (extract_delim > 0)
- len++;
- }
- memcpy((void*)ptr, (void*)fp->_IO_read_ptr, len);
- fp->_IO_read_ptr = t;
- return old_len + len;
- }
- memcpy((void*)ptr, (void*)fp->_IO_read_ptr, len);
- fp->_IO_read_ptr += len;
- ptr += len;
- n -= len;
- } while (n != 0);
- return ptr - buf;
-}
diff --git a/gnu/lib/libg++/libio/ioignore.c b/gnu/lib/libg++/libio/ioignore.c
deleted file mode 100644
index 70479e2..0000000
--- a/gnu/lib/libg++/libio/ioignore.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-
-int
-_IO_ignore(fp, n)
- register _IO_FILE *fp;
- _IO_size_t n;
-{
- register _IO_size_t more = n;
- for (;;)
- {
- _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr;
- if (count > 0)
- {
- if (count > more)
- count = more;
- fp->_IO_read_ptr += count;
- more -= count;
- }
- if (more == 0 || __underflow(fp) == EOF)
- break;
- }
- return n - more;
-}
diff --git a/gnu/lib/libg++/libio/iomanip.cc b/gnu/lib/libg++/libio/iomanip.cc
deleted file mode 100644
index bb15f64..0000000
--- a/gnu/lib/libg++/libio/iomanip.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "iomanip.h"
-
-
-// Those functions are called through a pointer,
-// thus it does not make sense, to inline them.
-
-ios & __iomanip_setbase (ios& i, int n)
-{
- ios::fmtflags b;
- switch (n)
- {
- case 8:
- b = ios::oct; break;
- case 10:
- b = ios::dec; break;
- case 16:
- b = ios::hex; break;
- default:
- b = 0;
- }
- i.setf(b, ios::basefield);
- return i;
-}
-
-ios & __iomanip_setfill (ios& i, int n)
-{
- //FIXME if ( i.flags() & ios::widechar )
- i.fill( (char) n);
- //FIXME else
- //FIXME i.fill( (wchar) n);
- return i;
-}
-
-ios & __iomanip_setprecision (ios& i, int n)
-{
- i.precision(n);
- return i;
-}
-ios & __iomanip_setw (ios& i, int n)
-{
- i.width(n);
- return i;
-}
-
-ios & __iomanip_setiosflags (ios& i, ios::fmtflags n)
-{
- i.setf(n,n);
- return i;
-}
-
-ios & __iomanip_resetiosflags (ios& i, ios::fmtflags n)
-{
- i.setf(0,n);
- return i;
-}
-
-template class smanip<int>;
-template class smanip<ios::fmtflags>;
-template istream& operator>>(istream&, const smanip<int>&);
-template istream& operator>>(istream&, const smanip<ios::fmtflags>&);
-template ostream& operator<<(ostream&, const smanip<int>&);
-template ostream& operator<<(ostream&, const smanip<ios::fmtflags>&);
diff --git a/gnu/lib/libg++/libio/iopadn.c b/gnu/lib/libg++/libio/iopadn.c
deleted file mode 100644
index 77b7af7..0000000
--- a/gnu/lib/libg++/libio/iopadn.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-
-#define PADSIZE 16
-static char const blanks[PADSIZE] =
-{' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
-static char const zeroes[PADSIZE] =
-{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
-
-_IO_ssize_t
-_IO_padn(fp, pad, count)
- _IO_FILE *fp;
- int pad;
- _IO_ssize_t count;
-{
- char padbuf[PADSIZE];
- const char *padptr;
- register int i;
- _IO_size_t written = 0, w;
-
- if (pad == ' ')
- padptr = blanks;
- else if (pad == '0')
- padptr = zeroes;
- else
- {
- for (i = PADSIZE; --i >= 0; ) padbuf[i] = pad;
- padptr = padbuf;
- }
- for (i = count; i >= PADSIZE; i -= PADSIZE)
- {
- w = _IO_sputn(fp, padptr, PADSIZE);
- written += w;
- if (w != PADSIZE)
- return written;
- }
-
- if (i > 0)
- {
- w = _IO_sputn(fp, padptr, i);
- written += w;
- }
- return written;
-}
diff --git a/gnu/lib/libg++/libio/iopopen.c b/gnu/lib/libg++/libio/iopopen.c
deleted file mode 100644
index 99a9145..0000000
--- a/gnu/lib/libg++/libio/iopopen.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* written by Per Bothner (bothner@cygnus.com) */
-
-#define _POSIX_SOURCE
-#include "libioP.h"
-#if _IO_HAVE_SYS_WAIT
-#include <signal.h>
-#include <unistd.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#include <sys/wait.h>
-
-#ifndef _IO_fork
-#define _IO_fork vfork /* defined in libiberty, if needed */
-_IO_pid_t _IO_fork();
-#endif
-
-#endif /* _IO_HAVE_SYS_WAIT */
-
-#ifndef _IO_pipe
-#define _IO_pipe pipe
-extern int _IO_pipe();
-#endif
-
-#ifndef _IO_dup2
-#define _IO_dup2 dup2
-extern int _IO_dup2();
-#endif
-
-#ifndef _IO_waitpid
-#define _IO_waitpid waitpid
-#endif
-
-#ifndef _IO_execl
-#define _IO_execl execl
-#endif
-#ifndef _IO__exit
-#define _IO__exit _exit
-#endif
-
-struct _IO_proc_file
-{
- struct _IO_FILE_plus file;
- /* Following fields must match those in class procbuf (procbuf.h) */
- _IO_pid_t pid;
- struct _IO_proc_file *next;
-};
-typedef struct _IO_proc_file _IO_proc_file;
-
-static struct _IO_proc_file *proc_file_chain = NULL;
-
-_IO_FILE *
-_IO_proc_open(fp, command, mode)
- _IO_FILE* fp;
- const char *command;
- const char *mode;
-{
-#if _IO_HAVE_SYS_WAIT
- int read_or_write;
- int pipe_fds[2];
- int parent_end, child_end;
- _IO_pid_t child_pid;
- if (_IO_file_is_open(fp))
- return NULL;
- if (_IO_pipe(pipe_fds) < 0)
- return NULL;
- if (mode[0] == 'r')
- {
- parent_end = pipe_fds[0];
- child_end = pipe_fds[1];
- read_or_write = _IO_NO_WRITES;
- }
- else
- {
- parent_end = pipe_fds[1];
- child_end = pipe_fds[0];
- read_or_write = _IO_NO_READS;
- }
- ((_IO_proc_file*)fp)->pid = child_pid = _IO_fork();
- if (child_pid == 0)
- {
- int child_std_end = mode[0] == 'r' ? 1 : 0;
- _IO_close(parent_end);
- if (child_end != child_std_end)
- {
- _IO_dup2(child_end, child_std_end);
- _IO_close(child_end);
- }
- /* Posix.2: "popen() shall ensure that any streams from previous
- popen() calls that remain open in the parent process are closed
- in the new child process." */
- while (proc_file_chain)
- {
- _IO_close (_IO_fileno ((_IO_FILE *) proc_file_chain));
- proc_file_chain = proc_file_chain->next;
- }
-
- _IO_execl("/bin/sh", "sh", "-c", command, NULL);
- _IO__exit(127);
- }
- _IO_close(child_end);
- if (child_pid < 0)
- {
- _IO_close(parent_end);
- return NULL;
- }
- _IO_fileno(fp) = parent_end;
-
- /* Link into proc_file_chain. */
- ((_IO_proc_file*)fp)->next = proc_file_chain;
- proc_file_chain = (_IO_proc_file*)fp;
-
- _IO_mask_flags (fp, read_or_write, _IO_NO_READS|_IO_NO_WRITES);
- return fp;
-#else /* !_IO_HAVE_SYS_WAIT */
- return NULL;
-#endif
-}
-
-_IO_FILE *
-_IO_popen(command, mode)
- const char *command;
- const char *mode;
-{
- _IO_proc_file *fpx = (_IO_proc_file*)malloc(sizeof(_IO_proc_file));
- _IO_FILE *fp = (_IO_FILE*)fpx;
- if (fp == NULL)
- return NULL;
- _IO_init(fp, 0);
- fp->_jumps = &_IO_proc_jumps;
- _IO_file_init(fp);
- ((struct _IO_FILE_plus*)fp)->vtable = NULL;
- if (_IO_proc_open (fp, command, mode) != NULL)
- return fp;
- free (fpx);
- return NULL;
-}
-
-int
-_IO_proc_close(fp)
- _IO_FILE *fp;
-{
- /* This is not name-space clean. FIXME! */
-#if _IO_HAVE_SYS_WAIT
- int wstatus;
- _IO_proc_file **ptr = &proc_file_chain;
- _IO_pid_t wait_pid;
- int status = -1;
-
- /* Unlink from proc_file_chain. */
- for ( ; *ptr != NULL; ptr = &(*ptr)->next)
- {
- if (*ptr == (_IO_proc_file*)fp)
- {
- *ptr = (*ptr)->next;
- status = 0;
- break;
- }
- }
-
- if (status < 0 || _IO_close(_IO_fileno(fp)) < 0)
- return -1;
- /* POSIX.2 Rationale: "Some historical implementations either block
- or ignore the signals SIGINT, SIGQUIT, and SIGHUP while waiting
- for the child process to terminate. Since this behavior is not
- described in POSIX.2, such implementations are not conforming." */
- do
- {
- wait_pid = _IO_waitpid (((_IO_proc_file*)fp)->pid, &wstatus, 0);
- } while (wait_pid == -1 && errno == EINTR);
- if (wait_pid == -1)
- return -1;
- return wstatus;
-#else /* !_IO_HAVE_SYS_WAIT */
- return -1;
-#endif
-}
-
-struct _IO_jump_t _IO_proc_jumps = {
- _IO_file_overflow,
- _IO_file_underflow,
- _IO_file_xsputn,
- _IO_default_xsgetn,
- _IO_file_read,
- _IO_file_write,
- _IO_file_doallocate,
- _IO_default_pbackfail,
- _IO_file_setbuf,
- _IO_file_sync,
- _IO_file_finish,
- _IO_proc_close,
- _IO_file_stat,
- _IO_file_seek,
- _IO_file_seekoff,
- _IO_default_seekpos,
- _IO_default_uflow
-};
diff --git a/gnu/lib/libg++/libio/ioprims.c b/gnu/lib/libg++/libio/ioprims.c
deleted file mode 100644
index cf9cf93..0000000
--- a/gnu/lib/libg++/libio/ioprims.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* I/O OS-level primitives.
- Needs to be replaced if not using Unix.
- Also needs to be replaced if avoiding name-space pollution
- (in which case read would be defined in terms of _IO_read,
- rather than vice versa). */
-
-#include "libioP.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/uio.h>
-#include <unistd.h>
-
-#ifdef TODO
-/* Add open, isatty */
-#endif
-
-_IO_ssize_t
-_IO_read (fildes, buf, nbyte)
- int fildes;
- void *buf;
- _IO_size_t nbyte;
-{
- return read (fildes, buf, nbyte);
-}
-
-_IO_ssize_t
-_IO_write (fildes, buf, nbyte)
- int fildes;
- const void *buf;
- _IO_size_t nbyte;
-{
- return write (fildes, buf, nbyte);
-}
-
-_IO_off_t
-_IO_lseek (fildes, offset, whence)
- int fildes;
- _IO_off_t offset;
- int whence;
-{
- return lseek (fildes, offset, whence);
-}
-
-int
-_IO_close (fildes)
- int fildes;
-{
- return close (fildes);
-}
-
-int
-_IO_fstat (fildes, buf)
- int fildes;
- struct stat *buf;
-{
- return fstat (fildes, buf);
-}
diff --git a/gnu/lib/libg++/libio/ioprintf.c b/gnu/lib/libg++/libio/ioprintf.c
deleted file mode 100644
index 69dce3e..0000000
--- a/gnu/lib/libg++/libio/ioprintf.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-int
-_IO_printf
-#ifdef __STDC__
- (const char* format, ...)
-#else
-(format, va_alist) char *format; va_dcl
-#endif
-{
- int ret;
- va_list args;
- _IO_va_start(args, format);
- ret = _IO_vfprintf(_IO_stdout, format, args);
- va_end(args);
- return ret;
-}
diff --git a/gnu/lib/libg++/libio/ioseekoff.c b/gnu/lib/libg++/libio/ioseekoff.c
deleted file mode 100644
index c409586..0000000
--- a/gnu/lib/libg++/libio/ioseekoff.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include <libioP.h>
-
-_IO_pos_t
-_IO_seekoff(fp, offset, flags)
- _IO_FILE* fp;
- _IO_off_t offset;
- _IO_seekflags flags;
-{
- int dir = flags & 3;
-
- /* If we have a backup buffer, get rid of it, since the __seekoff
- callback may not know to do the right thing about it.
- This may be over-kill, but it'll do for now. TODO */
-
- if (_IO_have_backup (fp))
- {
- if (dir == _IO_seek_cur && _IO_in_backup (fp))
- offset -= fp->_IO_read_end - fp->_IO_read_ptr;
- _IO_free_backup_area (fp);
- }
-
- return fp->_jumps->__seekoff(fp, offset, flags);
-}
diff --git a/gnu/lib/libg++/libio/ioseekpos.c b/gnu/lib/libg++/libio/ioseekpos.c
deleted file mode 100644
index 54a36b2..0000000
--- a/gnu/lib/libg++/libio/ioseekpos.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include <libioP.h>
-
-_IO_pos_t
-_IO_seekpos(fp, pos, flags)
- _IO_FILE* fp;
- _IO_pos_t pos;
- _IO_seekflags flags;
-{
- /* If we have a backup buffer, get rid of it, since the __seekoff
- callback may not know to do the right thing about it.
- This may be over-kill, but it'll do for now. TODO */
-
- if (_IO_have_backup (fp))
- _IO_free_backup_area (fp);
-
- return fp->_jumps->__seekpos(fp, pos, flags);
-}
diff --git a/gnu/lib/libg++/libio/iostream.cc b/gnu/lib/libg++/libio/iostream.cc
deleted file mode 100644
index 0c241f8..0000000
--- a/gnu/lib/libg++/libio/iostream.cc
+++ /dev/null
@@ -1,824 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Written by Per Bothner (bothner@cygnus.com). */
-
-#ifdef __GNUC__
-#pragma implementation
-#endif
-#define _STREAM_COMPAT
-#include <iostream.h>
-#include "libioP.h"
-#include <stdio.h> /* Needed for sprintf */
-#include <ctype.h>
-#include <string.h>
-#include <limits.h>
-#include "floatio.h"
-
-#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
-
-//#define isspace(ch) ((ch)==' ' || (ch)=='\t' || (ch)=='\n')
-
-istream::istream(streambuf *sb, ostream* tied)
-{
- init (sb, tied);
- _flags |= ios::dont_close;
- _gcount = 0;
-}
-
-int skip_ws(streambuf* sb)
-{
- int ch;
- for (;;) {
- ch = sb->sbumpc();
- if (ch == EOF || !isspace(ch))
- return ch;
- }
-}
-
-istream& istream::get(char& c)
-{
- if (ipfx1()) {
- int ch = _strbuf->sbumpc();
- if (ch == EOF) {
- set(ios::eofbit|ios::failbit);
- _gcount = 0;
- }
- else {
- c = (char)ch;
- _gcount = 1;
- }
- }
- else
- _gcount = 0;
- return *this;
-}
-
-int istream::peek()
-{
- if (!good())
- return EOF;
- if (_tie && rdbuf()->in_avail() == 0)
- _tie->flush();
- int ch = _strbuf->sgetc();
- if (ch == EOF)
- set(ios::eofbit);
- return ch;
-}
-
-istream& istream::ignore(int n /* = 1 */, int delim /* = EOF */)
-{
- _gcount = 0;
- if (ipfx1()) {
- register streambuf* sb = _strbuf;
- if (delim == EOF) {
- _gcount = sb->ignore(n);
- return *this;
- }
- for (;;) {
-#if 0
- if (n != MAXINT) // FIXME
-#endif
- if (--n < 0)
- break;
- int ch = sb->sbumpc();
- if (ch == EOF) {
- set(ios::eofbit|ios::failbit);
- break;
- }
- _gcount++;
- if (ch == delim)
- break;
- }
- }
- return *this;
-}
-
-istream& istream::read(char *s, int n)
-{
- if (ipfx1()) {
- _gcount = _strbuf->sgetn(s, n);
- if (_gcount != n)
- set(ios::failbit|ios::eofbit);
- }
- else
- _gcount = 0;
- return *this;
-}
-
-istream& istream::seekg(streampos pos)
-{
- pos = _strbuf->sseekpos(pos, ios::in);
- if (pos == streampos(EOF))
- set(ios::badbit);
- return *this;
-}
-
-istream& istream::seekg(streamoff off, _seek_dir dir)
-{
- streampos pos
- = _IO_seekoff (_strbuf, off,
- (_IO_seekflags)
- ((int)dir | _IO_seek_not_out | _IO_seek_pos_ignored));
- if (pos == streampos(EOF))
- set(ios::badbit);
- return *this;
-}
-
-streampos istream::tellg()
-{
-#if 0
- streampos pos = _strbuf->sseekoff(0, ios::cur, ios::in);
-#else
- streampos pos
- = _IO_seekoff (_strbuf, 0,
- (_IO_seekflags)(_IO_seek_cur | _IO_seek_not_out));
-#endif
- if (pos == streampos(EOF))
- set(ios::badbit);
- return pos;
-}
-
-istream& istream::operator>>(char& c)
-{
- if (ipfx0()) {
- int ch = _strbuf->sbumpc();
- if (ch == EOF)
- set(ios::eofbit|ios::failbit);
- else
- c = (char)ch;
- }
- return *this;
-}
-
-istream& istream::operator>>(char* ptr)
-{
- register char *p = ptr;
- int w = width(0);
- if (ipfx0()) {
- register streambuf* sb = _strbuf;
- for (;;)
- {
- int ch = sb->sbumpc();
- if (ch == EOF)
- {
- set(p == ptr ? (ios::eofbit|ios::failbit) : (ios::eofbit));
- break;
- }
- else if (isspace(ch))
- {
- sb->sputbackc(ch);
- break;
- }
- else if (w == 1)
- {
- set(ios::failbit);
- sb->sputbackc(ch);
- break;
- }
- else *p++ = ch;
- w--;
- }
- }
- *p = '\0';
- return *this;
-}
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-#define LONGEST long long
-#else
-#define LONGEST long
-#endif
-
-static int read_int(istream& stream, unsigned LONGEST& val, int& neg)
-{
- if (!stream.ipfx0())
- return 0;
- register streambuf* sb = stream.rdbuf();
- int base = 10;
- int ndigits = 0;
- register int ch = skip_ws(sb);
- if (ch == EOF)
- goto eof_fail;
- neg = 0;
- if (ch == '+') {
- ch = skip_ws(sb);
- }
- else if (ch == '-') {
- neg = 1;
- ch = skip_ws(sb);
- }
- if (ch == EOF) goto eof_fail;
- if (!(stream.flags() & ios::basefield)) {
- if (ch == '0') {
- ch = sb->sbumpc();
- if (ch == EOF) {
- val = 0;
- return 1;
- }
- if (ch == 'x' || ch == 'X') {
- base = 16;
- ch = sb->sbumpc();
- if (ch == EOF) goto eof_fail;
- }
- else {
- sb->sputbackc(ch);
- base = 8;
- ch = '0';
- }
- }
- }
- else if ((stream.flags() & ios::basefield) == ios::hex)
- base = 16;
- else if ((stream.flags() & ios::basefield) == ios::oct)
- base = 8;
- val = 0;
- for (;;) {
- if (ch == EOF)
- break;
- int digit;
- if (ch >= '0' && ch <= '9')
- digit = ch - '0';
- else if (ch >= 'A' && ch <= 'F')
- digit = ch - 'A' + 10;
- else if (ch >= 'a' && ch <= 'f')
- digit = ch - 'a' + 10;
- else
- digit = 999;
- if (digit >= base) {
- sb->sputbackc(ch);
- if (ndigits == 0)
- goto fail;
- else
- return 1;
- }
- ndigits++;
- val = base * val + digit;
- ch = sb->sbumpc();
- }
- return 1;
- fail:
- stream.set(ios::failbit);
- return 0;
- eof_fail:
- stream.set(ios::failbit|ios::eofbit);
- return 0;
-}
-
-#define READ_INT(TYPE) \
-istream& istream::operator>>(TYPE& i)\
-{\
- unsigned LONGEST val; int neg;\
- if (read_int(*this, val, neg)) {\
- if (neg) val = -val;\
- i = (TYPE)val;\
- }\
- return *this;\
-}
-
-READ_INT(short)
-READ_INT(unsigned short)
-READ_INT(int)
-READ_INT(unsigned int)
-READ_INT(long)
-READ_INT(unsigned long)
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-READ_INT(long long)
-READ_INT(unsigned long long)
-#endif
-#if _G_HAVE_BOOL
-READ_INT(bool)
-#endif
-
-istream& istream::operator>>(long double& x)
-{
- if (ipfx0())
- scan("%lg", &x);
- return *this;
-}
-
-istream& istream::operator>>(double& x)
-{
- if (ipfx0())
- scan("%lg", &x);
- return *this;
-}
-
-istream& istream::operator>>(float& x)
-{
- if (ipfx0())
- scan("%g", &x);
- return *this;
-}
-
-istream& istream::operator>>(register streambuf* sbuf)
-{
- if (ipfx0()) {
- register streambuf* inbuf = rdbuf();
- // FIXME: Should optimize!
- for (;;) {
- register int ch = inbuf->sbumpc();
- if (ch == EOF) {
- set(ios::eofbit);
- break;
- }
- if (sbuf->sputc(ch) == EOF) {
- set(ios::failbit);
- break;
- }
- }
- }
- return *this;
-}
-
-ostream& ostream::operator<<(char c)
-{
- if (opfx()) {
-#if 1
- // This is what the cfront implementation does.
- if (_strbuf->sputc(c) == EOF)
- goto failed;
-#else
- // This is what cfront documentation and current ANSI drafts say.
- int w = width(0);
- char fill_char = fill();
- register int padding = w > 0 ? w - 1 : 0;
- register streambuf *sb = _strbuf;
- if (!(flags() & ios::left) && padding) // Default adjustment.
- if (_IO_padn(sb, fill_char, padding) < padding)
- goto failed;
- if (sb->sputc(c) == EOF)
- goto failed;
- if (flags() & ios::left && padding) // Left adjustment.
- if (_IO_padn(sb, fill_char, padding) < padding)
- goto failed;
-#endif
- osfx();
- }
- return *this;
- failed:
- set(ios::badbit);
- osfx();
- return *this;
-}
-
-/* Write VAL on STREAM.
- If SIGN<0, val is the absolute value of a negative number.
- If SIGN>0, val is a signed non-negative number.
- If SIGN==0, val is unsigned. */
-
-static void write_int(ostream& stream, unsigned LONGEST val, int sign)
-{
-#define WRITE_BUF_SIZE (10 + sizeof(unsigned LONGEST) * 3)
- char buf[WRITE_BUF_SIZE];
- register char *buf_ptr = buf+WRITE_BUF_SIZE; // End of buf.
- char *show_base = "";
- int show_base_len = 0;
- int show_pos = 0; // If 1, print a '+'.
-
- // Now do the actual conversion, placing the result at the *end* of buf.
- // Note that we use separate code for decimal, octal, and hex,
- // so we can divide by optimizable constants.
- if ((stream.flags() & ios::basefield) == ios::oct) { // Octal
- do {
- *--buf_ptr = (val & 7) + '0';
- val = val >> 3;
- } while (val != 0);
- if ((stream.flags() & ios::showbase) && (*buf_ptr != '0'))
- *--buf_ptr = '0';
- }
- else if ((stream.flags() & ios::basefield) == ios::hex) { // Hex
- char *xdigs = (stream.flags() & ios::uppercase) ? "0123456789ABCDEF0X"
- : "0123456789abcdef0x";
- do {
- *--buf_ptr = xdigs[val & 15];
- val = val >> 4;
- } while (val != 0);
- if ((stream.flags() & ios::showbase)) {
- show_base = xdigs + 16; // Either "0X" or "0x".
- show_base_len = 2;
- }
- }
- else { // Decimal
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
- // Optimization: Only use long long when we need to.
- while (val > UINT_MAX) {
- *--buf_ptr = (val % 10) + '0';
- val /= 10;
- }
- // Use more efficient (int) arithmetic for the rest.
- register unsigned int ival = (unsigned int)val;
-#else
- register unsigned LONGEST ival = val;
-#endif
- do {
- *--buf_ptr = (ival % 10) + '0';
- ival /= 10;
- } while (ival != 0);
- if (sign > 0 && (stream.flags() & ios::showpos))
- show_pos=1;
- }
-
- int buf_len = buf+WRITE_BUF_SIZE - buf_ptr;
- int w = stream.width(0);
-
- // Calculate padding.
- int len = buf_len+show_pos;
- if (sign < 0) len++;
- len += show_base_len;
- int padding = len > w ? 0 : w - len;
-
- // Do actual output.
- register streambuf* sbuf = stream.rdbuf();
- ios::fmtflags pad_kind =
- stream.flags() & (ios::left|ios::right|ios::internal);
- char fill_char = stream.fill();
- if (padding > 0
- && pad_kind != (ios::fmtflags)ios::left
- && pad_kind != (ios::fmtflags)ios::internal) // Default (right) adjust.
- if (_IO_padn(sbuf, fill_char, padding) < padding)
- goto failed;
- if (sign < 0 || show_pos)
- {
- char ch = sign < 0 ? '-' : '+';
- if (sbuf->sputc(ch) < 0)
- goto failed;
- }
- if (show_base_len)
- if (_IO_sputn(sbuf, show_base, show_base_len) <= 0)
- goto failed;
- if (pad_kind == (ios::fmtflags)ios::internal && padding > 0)
- if (_IO_padn(sbuf, fill_char, padding) < padding)
- goto failed;
- if (_IO_sputn (sbuf, buf_ptr, buf_len) != buf_len)
- goto failed;
- if (pad_kind == (ios::fmtflags)ios::left && padding > 0) // Left adjustment
- if (_IO_padn(sbuf, fill_char, padding) < padding)
- goto failed;
- stream.osfx();
- return;
- failed:
- stream.set(ios::badbit);
- stream.osfx();
-}
-
-ostream& ostream::operator<<(int n)
-{
- if (opfx()) {
- int sign = 1;
- unsigned int abs_n = (unsigned)n;
- if (n < 0 && (flags() & (ios::oct|ios::hex)) == 0)
- abs_n = -((unsigned)n), sign = -1;
- write_int(*this, abs_n, sign);
- }
- return *this;
-}
-
-ostream& ostream::operator<<(unsigned int n)
-{
- if (opfx())
- write_int(*this, n, 0);
- return *this;
-}
-
-
-ostream& ostream::operator<<(long n)
-{
- if (opfx()) {
- int sign = 1;
- unsigned long abs_n = (unsigned long)n;
- if (n < 0 && (flags() & (ios::oct|ios::hex)) == 0)
- abs_n = -((unsigned long)n), sign = -1;
- write_int(*this, abs_n, sign);
- }
- return *this;
-}
-
-ostream& ostream::operator<<(unsigned long n)
-{
- if (opfx())
- write_int(*this, n, 0);
- return *this;
-}
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-ostream& ostream::operator<<(long long n)
-{
- if (opfx()) {
- int sign = 1;
- unsigned long long abs_n = (unsigned long long)n;
- if (n < 0 && (flags() & (ios::oct|ios::hex)) == 0)
- abs_n = -((unsigned long long)n), sign = -1;
- write_int(*this, abs_n, sign);
- }
- return *this;
-}
-
-
-ostream& ostream::operator<<(unsigned long long n)
-{
- if (opfx())
- write_int(*this, n, 0);
- return *this;
-}
-#endif /*__GNUC__*/
-
-ostream& ostream::operator<<(double n)
-{
- if (opfx()) {
- // Uses __cvt_double (renamed from static cvt), in Chris Torek's
- // stdio implementation. The setup code uses the same logic
- // as in __vsbprintf.C (also based on Torek's code).
- int format_char;
- if ((flags() & ios::floatfield) == ios::fixed)
- format_char = 'f';
- else if ((flags() & ios::floatfield) == ios::scientific)
- format_char = flags() & ios::uppercase ? 'E' : 'e';
- else
- format_char = flags() & ios::uppercase ? 'G' : 'g';
-
- int prec = precision();
- if (prec <= 0 && !(flags() & ios::fixed))
- prec = 6; /* default */
-
- // Do actual conversion.
-#ifdef _IO_USE_DTOA
- if (_IO_outfloat(n, rdbuf(), format_char, width(0),
- prec, flags(),
- flags() & ios::showpos ? '+' : 0,
- fill()) < 0)
- set(ios::badbit|ios::failbit); // ??
-#else
- int fpprec = 0; // 'Extra' (suppressed) floating precision.
- if (prec > MAXFRACT) {
- if (flags() & (ios::fixed|ios::scientific) & ios::showpos)
- fpprec = prec - MAXFRACT;
- prec = MAXFRACT;
- }
- int negative;
- char buf[BUF];
- int sign = '\0';
- char *cp = buf;
- *cp = 0;
- int size = __cvt_double(n, prec,
- flags() & ios::showpoint ? 0x80 : 0,
- &negative,
- format_char, cp, buf + sizeof(buf));
- if (negative) sign = '-';
- else if (flags() & ios::showpos) sign = '+';
- if (*cp == 0)
- cp++;
-
- // Calculate padding.
- int fieldsize = size + fpprec;
- if (sign) fieldsize++;
- int padding = 0;
- int w = width(0);
- if (fieldsize < w)
- padding = w - fieldsize;
-
- // Do actual output.
- register streambuf* sbuf = rdbuf();
- register i;
- char fill_char = fill();
- ios::fmtflags pad_kind =
- flags() & (ios::left|ios::right|ios::internal);
- if (pad_kind != (ios::fmtflags)ios::left // Default (right) adjust.
- && pad_kind != (ios::fmtflags)ios::internal)
- for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
- if (sign)
- sbuf->sputc(sign);
- if (pad_kind == (ios::fmtflags)ios::internal)
- for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
-
- // Emit the actual concented field, followed by extra zeros.
- _IO_sputn (sbuf, cp, size);
- for (i = fpprec; --i >= 0; ) sbuf->sputc('0');
-
- if (pad_kind == (ios::fmtflags)ios::left) // Left adjustment
- for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
-#endif
- osfx();
- }
- return *this;
-}
-
-ostream& ostream::operator<<(const char *s)
-{
- if (opfx())
- {
- if (s == NULL)
- s = "(null)";
- int len = strlen(s);
- int w = width(0);
-// FIXME: Should we: if (w && len>w) len = w;
- char fill_char = fill();
- register streambuf *sbuf = rdbuf();
- register int padding = w > len ? w - len : 0;
- if (!(flags() & ios::left) && padding > 0) // Default adjustment.
- if (_IO_padn(sbuf, fill_char, padding) != padding)
- goto failed;
- if (_IO_sputn (sbuf, s, len) != len)
- goto failed;
- if (flags() & ios::left && padding > 0) // Left adjustment.
- if (_IO_padn(sbuf, fill_char, padding) != padding)
- goto failed;
- osfx();
- }
- return *this;
- failed:
- set(ios::badbit);
- osfx();
- return *this;
-}
-
-#if 0
-ostream& ostream::operator<<(const void *p)
-{ Is in osform.cc, to avoid pulling in all of _IO_vfprintf by this file. */ }
-#endif
-
-ostream& ostream::operator<<(register streambuf* sbuf)
-{
- if (opfx())
- {
- char buffer[_IO_BUFSIZ];
- register streambuf* outbuf = _strbuf;
- for (;;)
- {
- _IO_size_t count = _IO_sgetn(sbuf, buffer, _IO_BUFSIZ);
- if (count <= 0)
- break;
- if (_IO_sputn(outbuf, buffer, count) != count)
- {
- set(ios::badbit);
- break;
- }
- }
- osfx();
- }
- return *this;
-}
-
-ostream::ostream(streambuf* sb, ostream* tied)
-{
- init (sb, tied);
- _flags |= ios::dont_close;
-}
-
-ostream& ostream::seekp(streampos pos)
-{
- pos = _strbuf->sseekpos(pos, ios::out);
- if (pos == streampos(EOF))
- set(ios::badbit);
- return *this;
-}
-
-ostream& ostream::seekp(streamoff off, _seek_dir dir)
-{
- streampos pos
- = _IO_seekoff (_strbuf, off,
- (_IO_seekflags)
- ((int)dir | _IO_seek_not_in | _IO_seek_pos_ignored));
- if (pos == streampos(EOF))
- set(ios::badbit);
- return *this;
-}
-
-streampos ostream::tellp()
-{
-#if 1
- streampos pos
- = _IO_seekoff (_strbuf, 0,
- (_IO_seekflags)(_IO_seek_cur | _IO_seek_not_in));
-#else
- streampos pos = _strbuf->sseekoff(0, ios::cur, ios::out);
-#endif
- if (pos == streampos(EOF))
- set(ios::badbit);
- return pos;
-}
-
-ostream& ostream::flush()
-{
- if (_strbuf->sync())
- set(ios::badbit);
- return *this;
-}
-
-ostream& flush(ostream& outs)
-{
- return outs.flush();
-}
-
-istream& ws(istream& ins)
-{
- if (ins.ipfx1()) {
- int ch = skip_ws(ins._strbuf);
- if (ch == EOF)
- ins.set(ios::eofbit);
- else
- ins._strbuf->sputbackc(ch);
- }
- return ins;
-}
-
-// Skip white-space. Return 0 on failure (EOF), or 1 on success.
-// Differs from ws() manipulator in that failbit is set on EOF.
-// Called by ipfx() and ipfx0() if needed.
-
-int istream::_skip_ws()
-{
- int ch = skip_ws(_strbuf);
- if (ch == EOF) {
- set(ios::eofbit|ios::failbit);
- return 0;
- }
- else {
- _strbuf->sputbackc(ch);
- return 1;
- }
-}
-
-ostream& ends(ostream& outs)
-{
- outs.put('\0');
- return outs;
-}
-
-ostream& endl(ostream& outs)
-{
- return flush(outs.put('\n'));
-}
-
-ostream& ostream::write(const char *s, int n)
-{
- if (opfx()) {
- if (_IO_sputn(_strbuf, s, n) != n)
- set(ios::failbit);
- }
- return *this;
-}
-
-void ostream::do_osfx()
-{
- if (flags() & ios::unitbuf)
- flush();
- if (flags() & ios::stdio) {
- fflush(stdout);
- fflush(stderr);
- }
-}
-
-iostream::iostream(streambuf* sb, ostream* tied)
-{
- init (sb, tied);
- _flags |= ios::dont_close;
-}
-
-// NOTE: extension for compatibility with old libg++.
-// Not really compatible with fistream::close().
-#ifdef _STREAM_COMPAT
-void ios::close()
-{
- if (!(_flags & (unsigned int)ios::dont_close))
- delete rdbuf();
- else if (_strbuf->_flags & _IO_IS_FILEBUF)
- ((struct filebuf*)rdbuf())->close();
- else if (_strbuf != NULL)
- rdbuf()->sync();
- _flags |= ios::dont_close;
- _strbuf = NULL;
- _state = badbit;
-}
-
-int istream::skip(int i)
-{
- int old = (_flags & ios::skipws) != 0;
- if (i)
- _flags |= ios::skipws;
- else
- _flags &= ~ios::skipws;
- return old;
-}
-#endif
diff --git a/gnu/lib/libg++/libio/iostrerror.c b/gnu/lib/libg++/libio/iostrerror.c
deleted file mode 100644
index 2833fc7..0000000
--- a/gnu/lib/libg++/libio/iostrerror.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/* This should be replaced by whatever namespace-clean
- version of strerror you have available. */
-
-extern char *strerror();
-
-char *
-_IO_strerror(errnum)
- int errnum;
-{
- return strerror(errnum);
-}
diff --git a/gnu/lib/libg++/libio/ioungetc.c b/gnu/lib/libg++/libio/ioungetc.c
deleted file mode 100644
index 0b13e6d..0000000
--- a/gnu/lib/libg++/libio/ioungetc.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-
-int
-_IO_ungetc(c, fp)
- int c;
- _IO_FILE *fp;
-{
- CHECK_FILE(fp, EOF);
- if (c == EOF)
- return EOF;
- return _IO_sputbackc(fp, (unsigned char)c);
-}
diff --git a/gnu/lib/libg++/libio/iovfprintf.c b/gnu/lib/libg++/libio/iovfprintf.c
deleted file mode 100644
index 4ee12e0..0000000
--- a/gnu/lib/libg++/libio/iovfprintf.c
+++ /dev/null
@@ -1,885 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/*
- * Copyright (c) 1990 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.
- */
-
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "%W% (Berkeley) %G%";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Actual printf innards.
- *
- * This code is large and complicated...
- */
-
-#include <sys/types.h>
-#include "libioP.h"
-#include <string.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-/*
- * Define FLOATING_POINT to get floating point.
- */
-#ifndef NO_FLOATING_POINT
-#define FLOATING_POINT
-#endif
-
-/* end of configuration stuff */
-
-
-/*
- * Helper "class" for `fprintf to unbuffered': creates a
- * temporary buffer. */
-
-struct helper_file
-{
- struct _IO_FILE_plus _f;
- _IO_FILE *_put_stream;
-};
-
-static int
-_IO_helper_overflow (fp, c)
- _IO_FILE *fp;
- int c;
-{
- _IO_FILE *target = ((struct helper_file*)fp)->_put_stream;
- int used = fp->_IO_write_ptr - fp->_IO_write_base;
- if (used)
- {
- _IO_sputn(target, fp->_IO_write_base, used);
- fp->_IO_write_ptr -= used;
- }
- return _IO_putc (c, fp);
-}
-
-static struct _IO_jump_t _IO_helper_jumps = {
- _IO_helper_overflow,
- _IO_default_underflow,
- _IO_default_xsputn,
- _IO_default_xsgetn,
- _IO_default_read,
- _IO_default_write,
- _IO_default_doallocate,
- _IO_default_pbackfail,
- _IO_default_setbuf,
- _IO_default_sync,
- _IO_default_finish,
- _IO_default_close,
- _IO_default_stat,
- _IO_default_seek,
- _IO_default_seekoff,
- _IO_default_seekpos,
- _IO_default_uflow
-};
-
-static int
-helper_vfprintf(fp, fmt0, ap)
- register _IO_FILE* fp;
- char const *fmt0;
- _IO_va_list ap;
-{
- char buf[_IO_BUFSIZ];
- struct helper_file helper;
- register _IO_FILE *hp = (_IO_FILE*)&helper;
- int result, to_flush;
-
- /* initialize helper */
- helper._put_stream = fp;
- hp->_IO_write_base = buf;
- hp->_IO_write_ptr = buf;
- hp->_IO_write_end = buf+_IO_BUFSIZ;
- hp->_IO_file_flags = _IO_MAGIC|_IO_NO_READS;
- hp->_jumps = &_IO_helper_jumps;
-
- /* Now print to helper instead. */
- result = _IO_vfprintf(hp, fmt0, ap);
-
- /* Now flush anything from the helper to the fp. */
- if ((to_flush = hp->_IO_write_ptr - hp->_IO_write_base) > 0)
- {
- if (_IO_sputn(fp, hp->_IO_write_base, to_flush) != to_flush)
- return EOF;
- }
- return result;
-}
-
-#ifdef FLOATING_POINT
-
-#include "floatio.h"
-#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
-#define DEFPREC 6
-extern double modf __P((double, double*));
-
-#else /* no FLOATING_POINT */
-
-#define BUF 40
-
-#endif /* FLOATING_POINT */
-
-
-/*
- * Macros for converting digits to letters and vice versa
- */
-#define to_digit(c) ((c) - '0')
-#define is_digit(c) ((unsigned)to_digit(c) <= 9)
-#define to_char(n) ((n) + '0')
-
-/*
- * Flags used during conversion.
- */
-#define LONGINT 0x01 /* long integer */
-#define LONGDBL 0x02 /* long double; unimplemented */
-#define SHORTINT 0x04 /* short integer */
-#define ALT 0x08 /* alternate form */
-#define LADJUST 0x10 /* left adjustment */
-#define ZEROPAD 0x20 /* zero (as opposed to blank) pad */
-#define HEXPREFIX 0x40 /* add 0x or 0X prefix */
-
-int
-_IO_vfprintf(fp, fmt0, ap)
- register _IO_FILE* fp;
- char const *fmt0;
- _IO_va_list ap;
-{
- register const char *fmt; /* format string */
- register int ch; /* character from fmt */
- register int n; /* handy integer (short term usage) */
- register char *cp; /* handy char pointer (short term usage) */
- const char *fmark; /* for remembering a place in fmt */
- register int flags; /* flags as above */
- int ret; /* return value accumulator */
- int width; /* width from format (%8d), or 0 */
- int prec; /* precision from format (%.3d), or -1 */
- char sign; /* sign prefix (' ', '+', '-', or \0) */
-#ifdef FLOATING_POINT
- int softsign; /* temporary negative sign for floats */
- double _double; /* double precision arguments %[eEfgG] */
-#ifndef _IO_USE_DTOA
- int fpprec; /* `extra' floating precision in [eEfgG] */
-#endif
-#endif
- unsigned long _ulong; /* integer arguments %[diouxX] */
- enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */
- int dprec; /* a copy of prec if [diouxX], 0 otherwise */
- int dpad; /* extra 0 padding needed for integers */
- int fieldsz; /* field size expanded by sign, dpad etc */
- /* The initialization of 'size' is to suppress a warning that
- 'size' might be used unitialized. It seems gcc can't
- quite grok this spaghetti code ... */
- int size = 0; /* size of converted field or string */
- char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
- char ox[2]; /* space for 0x hex-prefix */
-
- /*
- * BEWARE, these `goto error' on error, and PAD uses `n'.
- */
-#define PRINT(ptr, len) \
- do { if (_IO_sputn(fp,ptr, len) != len) goto error; } while (0)
-#define PAD_SP(howmany) if (_IO_padn(fp, ' ', howmany) < (howmany)) goto error;
-#define PAD_0(howmany) if (_IO_padn(fp, '0', howmany) < (howmany)) goto error;
-
- /*
- * To extend shorts properly, we need both signed and unsigned
- * argument extraction methods.
- */
-#define SARG() \
- (flags&LONGINT ? va_arg(ap, long) : \
- flags&SHORTINT ? (long)(short)va_arg(ap, int) : \
- (long)va_arg(ap, int))
-#define UARG() \
- (flags&LONGINT ? va_arg(ap, unsigned long) : \
- flags&SHORTINT ? (unsigned long)(unsigned short)va_arg(ap, int) : \
- (unsigned long)va_arg(ap, unsigned int))
-
- /* optimise stderr (and other unbuffered Unix files) */
- if (fp->_IO_file_flags & _IO_UNBUFFERED)
- return helper_vfprintf(fp, fmt0, ap);
-
- fmt = fmt0;
- ret = 0;
-
- /*
- * Scan the format for conversions (`%' character).
- */
- for (;;) {
- for (fmark = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++)
- /* void */;
- if ((n = fmt - fmark) != 0) {
- PRINT(fmark, n);
- ret += n;
- }
- if (ch == '\0')
- goto done;
- fmt++; /* skip over '%' */
-
- flags = 0;
- dprec = 0;
-#if defined(FLOATING_POINT) && !defined (_IO_USE_DTOA)
- fpprec = 0;
-#endif
- width = 0;
- prec = -1;
- sign = '\0';
-
-rflag: ch = *fmt++;
-reswitch: switch (ch) {
- case ' ':
- /*
- * ``If the space and + flags both appear, the space
- * flag will be ignored.''
- * -- ANSI X3J11
- */
- if (!sign)
- sign = ' ';
- goto rflag;
- case '#':
- flags |= ALT;
- goto rflag;
- case '*':
- /*
- * ``A negative field width argument is taken as a
- * - flag followed by a positive field width.''
- * -- ANSI X3J11
- * They don't exclude field widths read from args.
- */
- if ((width = va_arg(ap, int)) >= 0)
- goto rflag;
- width = -width;
- /* FALLTHROUGH */
- case '-':
- flags |= LADJUST;
- flags &= ~ZEROPAD; /* '-' disables '0' */
- goto rflag;
- case '+':
- sign = '+';
- goto rflag;
- case '.':
- if ((ch = *fmt++) == '*') {
- n = va_arg(ap, int);
- prec = n < 0 ? -1 : n;
- goto rflag;
- }
- n = 0;
- while (is_digit(ch)) {
- n = 10 * n + to_digit(ch);
- ch = *fmt++;
- }
- prec = n < 0 ? -1 : n;
- goto reswitch;
- case '0':
- /*
- * ``Note that 0 is taken as a flag, not as the
- * beginning of a field width.''
- * -- ANSI X3J11
- */
- if (!(flags & LADJUST))
- flags |= ZEROPAD; /* '-' disables '0' */
- goto rflag;
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- n = 0;
- do {
- n = 10 * n + to_digit(ch);
- ch = *fmt++;
- } while (is_digit(ch));
- width = n;
- goto reswitch;
-#ifdef FLOATING_POINT
- case 'L':
- flags |= LONGDBL;
- goto rflag;
-#endif
- case 'h':
- flags |= SHORTINT;
- goto rflag;
- case 'l':
- flags |= LONGINT;
- goto rflag;
- case 'c':
- *(cp = buf) = va_arg(ap, int);
- size = 1;
- sign = '\0';
- break;
- case 'D':
- flags |= LONGINT;
- /*FALLTHROUGH*/
- case 'd':
- case 'i':
- _ulong = SARG();
- if ((long)_ulong < 0) {
- _ulong = -_ulong;
- sign = '-';
- }
- base = DEC;
- goto number;
-#ifdef FLOATING_POINT
- case 'e':
- case 'E':
- case 'f':
- case 'F':
- case 'g':
- case 'G':
- _double = va_arg(ap, double);
-#ifdef _IO_USE_DTOA
- {
- int fmt_flags = 0;
- int fill = ' ';
- if (flags & ALT)
- fmt_flags |= _IO_SHOWPOINT;
- if (flags & LADJUST)
- fmt_flags |= _IO_LEFT;
- else if (flags & ZEROPAD)
- fmt_flags |= _IO_INTERNAL, fill = '0';
- n = _IO_outfloat(_double, fp, ch, width,
- prec < 0 ? DEFPREC : prec,
- fmt_flags, sign, fill);
- if (n < 0)
- goto error;
- ret += n;
- }
- /* CHECK ERROR! */
- continue;
-#else
- /*
- * don't do unrealistic precision; just pad it with
- * zeroes later, so buffer size stays rational.
- */
- if (prec > MAXFRACT) {
- if ((ch != 'g' && ch != 'G') || (flags&ALT))
- fpprec = prec - MAXFRACT;
- prec = MAXFRACT;
- } else if (prec == -1)
- prec = DEFPREC;
- /* __cvt_double may have to round up before the
- "start" of its buffer, i.e.
- ``intf("%.2f", (double)9.999);'';
- if the first character is still NUL, it did.
- softsign avoids negative 0 if _double < 0 but
- no significant digits will be shown. */
- cp = buf;
- *cp = '\0';
- size = __cvt_double(_double, prec, flags, &softsign,
- ch, cp, buf + sizeof(buf));
- if (softsign)
- sign = '-';
- if (*cp == '\0')
- cp++;
- break;
-#endif
-#endif /* FLOATING_POINT */
- case 'n':
- if (flags & LONGINT)
- *va_arg(ap, long *) = ret;
- else if (flags & SHORTINT)
- *va_arg(ap, short *) = ret;
- else
- *va_arg(ap, int *) = ret;
- continue; /* no output */
- case 'O':
- flags |= LONGINT;
- /*FALLTHROUGH*/
- case 'o':
- _ulong = UARG();
- base = OCT;
- goto nosign;
- case 'p':
- /*
- * ``The argument shall be a pointer to void. The
- * value of the pointer is converted to a sequence
- * of printable characters, in an implementation-
- * defined manner.''
- * -- ANSI X3J11
- */
- /* NOSTRICT */
- _ulong = (unsigned long)va_arg(ap, void *);
- base = HEX;
- flags |= HEXPREFIX;
- ch = 'x';
- goto nosign;
- case 's':
- if ((cp = va_arg(ap, char *)) == NULL)
- cp = "(null)";
- if (prec >= 0) {
- /*
- * can't use strlen; can only look for the
- * NUL in the first `prec' characters, and
- * strlen() will go further.
- */
- char *p = (char*)memchr(cp, 0, prec);
-
- if (p != NULL) {
- size = p - cp;
- if (size > prec)
- size = prec;
- } else
- size = prec;
- } else
- size = strlen(cp);
- sign = '\0';
- break;
- case 'U':
- flags |= LONGINT;
- /*FALLTHROUGH*/
- case 'u':
- _ulong = UARG();
- base = DEC;
- goto nosign;
- case 'X':
- case 'x':
- _ulong = UARG();
- base = HEX;
- /* leading 0x/X only if non-zero */
- if (flags & ALT && _ulong != 0)
- flags |= HEXPREFIX;
-
- /* unsigned conversions */
-nosign: sign = '\0';
- /*
- * ``... diouXx conversions ... if a precision is
- * specified, the 0 flag will be ignored.''
- * -- ANSI X3J11
- */
-number: if ((dprec = prec) >= 0)
- flags &= ~ZEROPAD;
-
- /*
- * ``The result of converting a zero value with an
- * explicit precision of zero is no characters.''
- * -- ANSI X3J11
- */
- cp = buf + BUF;
- if (_ulong != 0 || prec != 0) {
- char *xdigs; /* digits for [xX] conversion */
- /*
- * unsigned mod is hard, and unsigned mod
- * by a constant is easier than that by
- * a variable; hence this switch.
- */
- switch (base) {
- case OCT:
- do {
- *--cp = to_char(_ulong & 7);
- _ulong >>= 3;
- } while (_ulong);
- /* handle octal leading 0 */
- if (flags & ALT && *cp != '0')
- *--cp = '0';
- break;
-
- case DEC:
- /* many numbers are 1 digit */
- while (_ulong >= 10) {
- *--cp = to_char(_ulong % 10);
- _ulong /= 10;
- }
- *--cp = to_char(_ulong);
- break;
-
- case HEX:
- if (ch == 'X')
- xdigs = "0123456789ABCDEF";
- else /* ch == 'x' || ch == 'p' */
- xdigs = "0123456789abcdef";
- do {
- *--cp = xdigs[_ulong & 15];
- _ulong >>= 4;
- } while (_ulong);
- break;
-
- default:
- cp = "bug in vform: bad base";
- goto skipsize;
- }
- }
- size = buf + BUF - cp;
- skipsize:
- break;
- default: /* "%?" prints ?, unless ? is NUL */
- if (ch == '\0')
- goto done;
- /* pretend it was %c with argument ch */
- cp = buf;
- *cp = ch;
- size = 1;
- sign = '\0';
- break;
- }
-
- /*
- * All reasonable formats wind up here. At this point,
- * `cp' points to a string which (if not flags&LADJUST)
- * should be padded out to `width' places. If
- * flags&ZEROPAD, it should first be prefixed by any
- * sign or other prefix; otherwise, it should be blank
- * padded before the prefix is emitted. After any
- * left-hand padding and prefixing, emit zeroes
- * required by a decimal [diouxX] precision, then print
- * the string proper, then emit zeroes required by any
- * leftover floating precision; finally, if LADJUST,
- * pad with blanks.
- */
-
- /*
- * compute actual size, so we know how much to pad.
- */
-#if defined(FLOATING_POINT) && !defined (_IO_USE_DTOA)
- fieldsz = size + fpprec;
-#else
- fieldsz = size;
-#endif
- dpad = dprec - size;
- if (dpad < 0)
- dpad = 0;
-
- if (sign)
- fieldsz++;
- else if (flags & HEXPREFIX)
- fieldsz += 2;
- fieldsz += dpad;
-
- /* right-adjusting blank padding */
- if ((flags & (LADJUST|ZEROPAD)) == 0)
- PAD_SP(width - fieldsz);
-
- /* prefix */
- if (sign) {
- PRINT(&sign, 1);
- } else if (flags & HEXPREFIX) {
- ox[0] = '0';
- ox[1] = ch;
- PRINT(ox, 2);
- }
-
- /* right-adjusting zero padding */
- if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
- PAD_0(width - fieldsz);
-
- /* leading zeroes from decimal precision */
- PAD_0(dpad);
-
- /* the string or number proper */
- PRINT(cp, size);
-
-#if defined(FLOATING_POINT) && !defined (_IO_USE_DTOA)
- /* trailing f.p. zeroes */
- PAD_0(fpprec);
-#endif
-
- /* left-adjusting padding (always blank) */
- if (flags & LADJUST)
- PAD_SP(width - fieldsz);
-
- /* finally, adjust ret */
- ret += width > fieldsz ? width : fieldsz;
-
- }
-done:
- return ret;
-error:
- return EOF;
- /* NOTREACHED */
-}
-
-#if defined(FLOATING_POINT) && !defined(_IO_USE_DTOA)
-
-static char *exponent(register char *p, register int exp, int fmtch)
-{
- register char *t;
- char expbuf[MAXEXP];
-
- *p++ = fmtch;
- if (exp < 0) {
- exp = -exp;
- *p++ = '-';
- }
- else
- *p++ = '+';
- t = expbuf + MAXEXP;
- if (exp > 9) {
- do {
- *--t = to_char(exp % 10);
- } while ((exp /= 10) > 9);
- *--t = to_char(exp);
- for (; t < expbuf + MAXEXP; *p++ = *t++);
- }
- else {
- *p++ = '0';
- *p++ = to_char(exp);
- }
- return (p);
-}
-
-static char * round(double fract, int *exp,
- register char *start, register char *end,
- char ch, int *signp)
-{
- double tmp;
-
- if (fract)
- (void)modf(fract * 10, &tmp);
- else
- tmp = to_digit(ch);
- if (tmp > 4)
- for (;; --end) {
- if (*end == '.')
- --end;
- if (++*end <= '9')
- break;
- *end = '0';
- if (end == start) {
- if (exp) { /* e/E; increment exponent */
- *end = '1';
- ++*exp;
- }
- else { /* f; add extra digit */
- *--end = '1';
- --start;
- }
- break;
- }
- }
- /* ``"%.3f", (double)-0.0004'' gives you a negative 0. */
- else if (*signp == '-')
- for (;; --end) {
- if (*end == '.')
- --end;
- if (*end != '0')
- break;
- if (end == start)
- *signp = 0;
- }
- return (start);
-}
-
-int __cvt_double(double number, register int prec, int flags, int *signp,
- int fmtch, char *startp, char *endp)
-{
- register char *p, *t;
- register double fract;
- int dotrim = 0, expcnt, gformat = 0;
- double integer, tmp;
-
- expcnt = 0;
- if (number < 0) {
- number = -number;
- *signp = '-';
- } else
- *signp = 0;
-
- fract = modf(number, &integer);
-
- /* get an extra slot for rounding. */
- t = ++startp;
-
- /*
- * get integer portion of number; put into the end of the buffer; the
- * .01 is added for modf(356.0 / 10, &integer) returning .59999999...
- */
- for (p = endp - 1; integer; ++expcnt) {
- tmp = modf(integer / 10, &integer);
- *p-- = to_char((int)((tmp + .01) * 10));
- }
- switch (fmtch) {
- case 'f':
- case 'F':
- /* reverse integer into beginning of buffer */
- if (expcnt)
- for (; ++p < endp; *t++ = *p);
- else
- *t++ = '0';
- /*
- * if precision required or alternate flag set, add in a
- * decimal point.
- */
- if (prec || flags&ALT)
- *t++ = '.';
- /* if requires more precision and some fraction left */
- if (fract) {
- if (prec)
- do {
- fract = modf(fract * 10, &tmp);
- *t++ = to_char((int)tmp);
- } while (--prec && fract);
- if (fract)
- startp = round(fract, (int *)NULL, startp,
- t - 1, (char)0, signp);
- }
- for (; prec--; *t++ = '0');
- break;
- case 'e':
- case 'E':
-eformat: if (expcnt) {
- *t++ = *++p;
- if (prec || flags&ALT)
- *t++ = '.';
- /* if requires more precision and some integer left */
- for (; prec && ++p < endp; --prec)
- *t++ = *p;
- /*
- * if done precision and more of the integer component,
- * round using it; adjust fract so we don't re-round
- * later.
- */
- if (!prec && ++p < endp) {
- fract = 0;
- startp = round((double)0, &expcnt, startp,
- t - 1, *p, signp);
- }
- /* adjust expcnt for digit in front of decimal */
- --expcnt;
- }
- /* until first fractional digit, decrement exponent */
- else if (fract) {
- /* adjust expcnt for digit in front of decimal */
- for (expcnt = -1;; --expcnt) {
- fract = modf(fract * 10, &tmp);
- if (tmp)
- break;
- }
- *t++ = to_char((int)tmp);
- if (prec || flags&ALT)
- *t++ = '.';
- }
- else {
- *t++ = '0';
- if (prec || flags&ALT)
- *t++ = '.';
- }
- /* if requires more precision and some fraction left */
- if (fract) {
- if (prec)
- do {
- fract = modf(fract * 10, &tmp);
- *t++ = to_char((int)tmp);
- } while (--prec && fract);
- if (fract)
- startp = round(fract, &expcnt, startp,
- t - 1, (char)0, signp);
- }
- /* if requires more precision */
- for (; prec--; *t++ = '0');
-
- /* unless alternate flag, trim any g/G format trailing 0's */
- if (gformat && !(flags&ALT)) {
- while (t > startp && *--t == '0');
- if (*t == '.')
- --t;
- ++t;
- }
- t = exponent(t, expcnt, fmtch);
- break;
- case 'g':
- case 'G':
- /* a precision of 0 is treated as a precision of 1. */
- if (!prec)
- ++prec;
- /*
- * ``The style used depends on the value converted; style e
- * will be used only if the exponent resulting from the
- * conversion is less than -4 or greater than the precision.''
- * -- ANSI X3J11
- */
- if (expcnt > prec || (!expcnt && fract && fract < .0001)) {
- /*
- * g/G format counts "significant digits, not digits of
- * precision; for the e/E format, this just causes an
- * off-by-one problem, i.e. g/G considers the digit
- * before the decimal point significant and e/E doesn't
- * count it as precision.
- */
- --prec;
- fmtch -= 2; /* G->E, g->e */
- gformat = 1;
- goto eformat;
- }
- /*
- * reverse integer into beginning of buffer,
- * note, decrement precision
- */
- if (expcnt)
- for (; ++p < endp; *t++ = *p, --prec);
- else
- *t++ = '0';
- /*
- * if precision required or alternate flag set, add in a
- * decimal point. If no digits yet, add in leading 0.
- */
- if (prec || flags&ALT) {
- dotrim = 1;
- *t++ = '.';
- }
- else
- dotrim = 0;
- /* if requires more precision and some fraction left */
- if (fract) {
- if (prec) {
- /* If no integer part, don't count initial
- * zeros as significant digits. */
- do {
- fract = modf(fract * 10, &tmp);
- *t++ = to_char((int)tmp);
- } while(!tmp && !expcnt);
- while (--prec && fract) {
- fract = modf(fract * 10, &tmp);
- *t++ = to_char((int)tmp);
- }
- }
- if (fract)
- startp = round(fract, (int *)NULL, startp,
- t - 1, (char)0, signp);
- }
- /* alternate format, adds 0's for precision, else trim 0's */
- if (flags&ALT)
- for (; prec--; *t++ = '0');
- else if (dotrim) {
- while (t > startp && *--t == '0');
- if (*t != '.')
- ++t;
- }
- }
- return (t - startp);
-}
-
-#endif /* defined(FLOATING_POINT) && !defined(_IO_USE_DTOA) */
diff --git a/gnu/lib/libg++/libio/iovfscanf.c b/gnu/lib/libg++/libio/iovfscanf.c
deleted file mode 100644
index 909f1ac..0000000
--- a/gnu/lib/libg++/libio/iovfscanf.c
+++ /dev/null
@@ -1,784 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/* Extensively hacked for GNU iostream by Per Bothner 1991, 1992, 1993.
- Changes copyright Free Software Foundation 1992, 1993. */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "%W% (Berkeley) %G%";
-#endif /* LIBC_SCCS and not lint */
-
-#include <libioP.h>
-#include <ctype.h>
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#ifndef NO_FLOATING_POINT
-#define FLOATING_POINT
-#endif
-
-#ifdef FLOATING_POINT
-#include "floatio.h"
-#define BUF (MAXEXP+MAXFRACT+3) /* 3 = sign + decimal point + NUL */
-#else
-#define BUF 40
-#endif
-
-/*
- * Flags used during conversion.
- */
-#define LONG 0x01 /* l: long or double */
-#define LONGDBL 0x02 /* L: long double; unimplemented */
-#define SHORT 0x04 /* h: short */
-#define SUPPRESS 0x08 /* suppress assignment */
-#define POINTER 0x10 /* weird %p pointer (`fake hex') */
-#define NOSKIP 0x20 /* do not skip blanks */
-#define WIDTH 0x40 /* width */
-
-/*
- * The following are used in numeric conversions only:
- * SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point;
- * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral.
- */
-#define SIGNOK 0x40 /* +/- is (still) legal */
-#define NDIGITS 0x80 /* no digits detected */
-
-#define DPTOK 0x100 /* (float) decimal point is still legal */
-#define EXPOK 0x200 /* (float) exponent (e+3, etc) still legal */
-
-#define PFXOK 0x100 /* 0x prefix is (still) legal */
-#define NZDIGITS 0x200 /* no zero digits detected */
-
-/*
- * Conversion types.
- */
-#define CT_CHAR 0 /* %c conversion */
-#define CT_CCL 1 /* %[...] conversion */
-#define CT_STRING 2 /* %s conversion */
-#define CT_INT 3 /* integer, i.e., strtol or strtoul */
-#define CT_FLOAT 4 /* floating, i.e., strtod */
-
-#define u_char unsigned char
-#define u_long unsigned long
-
-extern u_long strtoul __P((const char*, char**, int));
-extern long strtol __P((const char*, char**, int));
-static const u_char *__sccl __P((char *tab, const u_char *fmt));
-#ifndef _IO_USE_DTOA
-extern double atof();
-#endif
-
-/* If errp != NULL, *errp|=1 if we see a premature EOF;
- *errp|=2 if we an invalid character. */
-
-int
-_IO_vfscanf(fp, fmt0, ap, errp)
- register _IO_FILE *fp;
- char const *fmt0;
- _IO_va_list ap;
- int *errp;
-{
- register const u_char *fmt = (const u_char *)fmt0;
- register int c; /* character from format, or conversion */
- register _IO_ssize_t width; /* field width, or 0 */
- register char *p; /* points into all kinds of strings */
- register int n; /* handy integer */
- register int flags = 0; /* flags as defined above */
- register char *p0; /* saves original value of p when necessary */
- int nassigned; /* number of fields assigned */
- int nread; /* number of characters consumed from fp */
- /* Assignments to base and ccfn are just to suppress warnings from gcc.*/
- int base = 0; /* base argument to strtol/strtoul */
- typedef u_long (*strtoulfn) __P((const char*, char**, int));
- strtoulfn ccfn = 0;
- /* conversion function (strtol/strtoul) */
- char ccltab[256]; /* character class table for %[...] */
- char buf[BUF]; /* buffer for numeric conversions */
- int seen_eof = 0;
-
- /* `basefix' is used to avoid `if' tests in the integer scanner */
- static short basefix[17] =
- { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
-
- nassigned = 0;
- nread = 0;
- for (;;) {
- c = *fmt++;
- if (c == 0)
- goto done;
- if (isspace(c)) {
- for (;;) {
- c = _IO_getc(fp);
- if (c == EOF) {
- seen_eof++;
- break;
- }
- if (!isspace(c)) {
- _IO_ungetc (c, fp);
- break;
- }
- nread++;
- }
- continue;
- }
- if (c != '%')
- goto literal;
- width = 0;
- flags = 0;
- /*
- * switch on the format. continue if done;
- * break once format type is derived.
- */
-again: c = *fmt++;
- switch (c) {
- case '%':
-literal:
- n = _IO_getc(fp);
- if (n == EOF)
- goto eof_failure;
- if (n != c) {
- _IO_ungetc (n, fp);
- goto match_failure;
- }
- nread++;
- continue;
-
- case '*':
- if (flags) goto control_failure;
- flags = SUPPRESS;
- goto again;
- case 'l':
- if (flags & ~(SUPPRESS | WIDTH)) goto control_failure;
- flags |= LONG;
- goto again;
- case 'L':
- if (flags & ~(SUPPRESS | WIDTH)) goto control_failure;
- flags |= LONGDBL;
- goto again;
- case 'h':
- if (flags & ~(SUPPRESS | WIDTH)) goto control_failure;
- flags |= SHORT;
- goto again;
-
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- if (flags & ~(SUPPRESS | WIDTH)) goto control_failure;
- flags |= WIDTH;
- width = width * 10 + c - '0';
- goto again;
-
- /*
- * Conversions.
- * Those marked `compat' are for 4.[123]BSD compatibility.
- *
- * (According to ANSI, E and X formats are supposed
- * to the same as e and x. Sorry about that.)
- */
- case 'D': /* compat */
- flags |= LONG;
- /* FALLTHROUGH */
- case 'd':
- c = CT_INT;
- ccfn = (strtoulfn)strtol;
- base = 10;
- break;
-
- case 'i':
- c = CT_INT;
- ccfn = (strtoulfn)strtol;
- base = 0;
- break;
-
- case 'O': /* compat */
- flags |= LONG;
- /* FALLTHROUGH */
- case 'o':
- c = CT_INT;
- ccfn = strtoul;
- base = 8;
- break;
-
- case 'u':
- c = CT_INT;
- ccfn = strtoul;
- base = 10;
- break;
-
- case 'X':
- case 'x':
- flags |= PFXOK; /* enable 0x prefixing */
- c = CT_INT;
- ccfn = strtoul;
- base = 16;
- break;
-
-#ifdef FLOATING_POINT
- case 'E': case 'F':
- case 'e': case 'f': case 'g':
- c = CT_FLOAT;
- break;
-#endif
-
- case 's':
- c = CT_STRING;
- break;
-
- case '[':
- fmt = __sccl(ccltab, fmt);
- flags |= NOSKIP;
- c = CT_CCL;
- break;
-
- case 'c':
- flags |= NOSKIP;
- c = CT_CHAR;
- break;
-
- case 'p': /* pointer format is like hex */
- flags |= POINTER | PFXOK;
- c = CT_INT;
- ccfn = strtoul;
- base = 16;
- break;
-
- case 'n':
- if (flags & SUPPRESS) /* ??? */
- continue;
- if (flags & SHORT)
- *va_arg(ap, short *) = nread;
- else if (flags & LONG)
- *va_arg(ap, long *) = nread;
- else
- *va_arg(ap, int *) = nread;
- continue;
-
- /*
- * Disgusting backwards compatibility hacks. XXX
- */
- case '\0': /* compat */
- nassigned = EOF;
- goto done;
-
- default: /* compat */
- if (isupper(c))
- flags |= LONG;
- c = CT_INT;
- ccfn = (strtoulfn)strtol;
- base = 10;
- break;
- }
-
- /*
- * We have a conversion that requires input.
- */
- if (_IO_peekc(fp) == EOF)
- goto eof_failure;
-
- /*
- * Consume leading white space, except for formats
- * that suppress this.
- */
- if ((flags & NOSKIP) == 0) {
- n = (unsigned char)*fp->_IO_read_ptr;
- while (isspace(n)) {
- fp->_IO_read_ptr++;
- nread++;
- n = _IO_peekc(fp);
- if (n == EOF)
- goto eof_failure;
- }
- /* Note that there is at least one character in
- the buffer, so conversions that do not set NOSKIP
- can no longer result in an input failure. */
- }
-
- /*
- * Do the conversion.
- */
- switch (c) {
-
- case CT_CHAR:
- /* scan arbitrary characters (sets NOSKIP) */
- if (width == 0) /* FIXME! */
- width = 1;
- if (flags & SUPPRESS) {
- _IO_size_t sum = 0;
- for (;;) {
- n = fp->_IO_read_end - fp->_IO_read_ptr;
- if (n < (int)width) {
- sum += n;
- width -= n;
- fp->_IO_read_ptr += n;
- if (__underflow(fp) == EOF)
- if (sum == 0)
- goto eof_failure;
- else {
- seen_eof++;
- break;
- }
- } else {
- sum += width;
- fp->_IO_read_ptr += width;
- break;
- }
- }
- nread += sum;
- } else {
- _IO_size_t r =
- (*fp->_jumps->__xsgetn)(fp,
- (char*)va_arg(ap, char*),
- width);
- if (r != width)
- goto eof_failure;
- nread += r;
- nassigned++;
- }
- break;
-
- case CT_CCL:
- /* scan a (nonempty) character class (sets NOSKIP) */
- if (width == 0)
- width = ~0; /* `infinity' */
- /* take only those things in the class */
- if (flags & SUPPRESS) {
- n = 0;
- while (ccltab[(unsigned char)*fp->_IO_read_ptr]) {
- n++, fp->_IO_read_ptr++;
- if (--width == 0)
- break;
- if (_IO_peekc(fp) == EOF) {
- if (n == 0)
- goto eof_failure;
- seen_eof++;
- break;
- }
- }
- if (n == 0)
- goto match_failure;
- } else {
- p0 = p = va_arg(ap, char *);
- while (ccltab[(unsigned char)*fp->_IO_read_ptr]) {
- *p++ = *fp->_IO_read_ptr++;
- if (--width == 0)
- break;
- if (_IO_peekc(fp) == EOF) {
- if (p == p0)
- goto eof_failure;
- seen_eof++;
- break;
- }
- }
- n = p - p0;
- if (n == 0)
- goto match_failure;
- *p = 0;
- nassigned++;
- }
- nread += n;
- break;
-
- case CT_STRING:
- /* like CCL, but zero-length string OK, & no NOSKIP */
- if (width == 0)
- width = ~0;
- if (flags & SUPPRESS) {
- n = 0;
- while (!isspace((unsigned char)*fp->_IO_read_ptr)) {
- n++, fp->_IO_read_ptr++;
- if (--width == 0)
- break;
- if (_IO_peekc(fp) == EOF) {
- seen_eof++;
- break;
- }
- }
- nread += n;
- } else {
- p0 = p = va_arg(ap, char *);
- while (!isspace((unsigned char)*fp->_IO_read_ptr)) {
- *p++ = *fp->_IO_read_ptr++;
- if (--width == 0)
- break;
- if (_IO_peekc(fp) == EOF) {
- seen_eof++;
- break;
- }
- }
- *p = 0;
- nread += p - p0;
- nassigned++;
- }
- continue;
-
- case CT_INT:
- /* scan an integer as if by strtol/strtoul */
- if (width == 0 || width > sizeof(buf) - 1)
- width = sizeof(buf) - 1;
- flags |= SIGNOK | NDIGITS | NZDIGITS;
- for (p = buf; width; width--) {
- c = (unsigned char)*fp->_IO_read_ptr;
- /*
- * Switch on the character; `goto ok'
- * if we accept it as a part of number.
- */
- switch (c) {
-
- /*
- * The digit 0 is always legal, but is
- * special. For %i conversions, if no
- * digits (zero or nonzero) have been
- * scanned (only signs), we will have
- * base==0. In that case, we should set
- * it to 8 and enable 0x prefixing.
- * Also, if we have not scanned zero digits
- * before this, do not turn off prefixing
- * (someone else will turn it off if we
- * have scanned any nonzero digits).
- */
- case '0':
- if (base == 0) {
- base = 8;
- flags |= PFXOK;
- }
- if (flags & NZDIGITS)
- flags &= ~(SIGNOK|NZDIGITS|NDIGITS);
- else
- flags &= ~(SIGNOK|PFXOK|NDIGITS);
- goto ok;
-
- /* 1 through 7 always legal */
- case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- base = basefix[base];
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* digits 8 and 9 ok iff decimal or hex */
- case '8': case '9':
- base = basefix[base];
- if (base <= 8)
- break; /* not legal here */
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* letters ok iff hex */
- case 'A': case 'B': case 'C':
- case 'D': case 'E': case 'F':
- case 'a': case 'b': case 'c':
- case 'd': case 'e': case 'f':
- /* no need to fix base here */
- if (base <= 10)
- break; /* not legal here */
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* sign ok only as first character */
- case '+': case '-':
- if (flags & SIGNOK) {
- flags &= ~SIGNOK;
- goto ok;
- }
- break;
-
- /* x ok iff flag still set & 2nd char */
- case 'x': case 'X':
- if (flags & PFXOK && p == buf + 1) {
- base = 16; /* if %i */
- flags &= ~PFXOK;
- goto ok;
- }
- break;
- }
-
- /*
- * If we got here, c is not a legal character
- * for a number. Stop accumulating digits.
- */
- break;
- ok:
- /*
- * c is legal: store it and look at the next.
- */
- *p++ = c;
- fp->_IO_read_ptr++;
- if (_IO_peekc(fp) == EOF) {
- seen_eof++;
- break; /* EOF */
- }
- }
- /*
- * If we had only a sign, it is no good; push
- * back the sign. If the number ends in `x',
- * it was [sign] '0' 'x', so push back the x
- * and treat it as [sign] '0'.
- */
- if (flags & NDIGITS) {
- if (p > buf)
- (void) _IO_ungetc(*(u_char *)--p, fp);
- goto match_failure;
- }
- c = ((u_char *)p)[-1];
- if (c == 'x' || c == 'X') {
- --p;
- (void) _IO_ungetc (c, fp);
- }
- if ((flags & SUPPRESS) == 0) {
- u_long res;
-
- *p = 0;
- res = (*ccfn)(buf, (char **)NULL, base);
- if (flags & POINTER)
- *va_arg(ap, void **) = (void *)res;
- else if (flags & SHORT)
- *va_arg(ap, short *) = res;
- else if (flags & LONG)
- *va_arg(ap, long *) = res;
- else
- *va_arg(ap, int *) = res;
- nassigned++;
- }
- nread += p - buf;
- break;
-
-#ifdef FLOATING_POINT
- case CT_FLOAT:
- /* scan a floating point number as if by strtod */
- if (width == 0 || width > sizeof(buf) - 1)
- width = sizeof(buf) - 1;
- flags |= SIGNOK | NDIGITS | DPTOK | EXPOK;
- for (p = buf; width; width--) {
- c = (unsigned char)*fp->_IO_read_ptr;
- /*
- * This code mimicks the integer conversion
- * code, but is much simpler.
- */
- switch (c) {
-
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- case '8': case '9':
- flags &= ~(SIGNOK | NDIGITS);
- goto fok;
-
- case '+': case '-':
- if (flags & SIGNOK) {
- flags &= ~SIGNOK;
- goto fok;
- }
- break;
- case '.':
- if (flags & DPTOK) {
- flags &= ~(SIGNOK | DPTOK);
- goto fok;
- }
- break;
- case 'e': case 'E':
- /* no exponent without some digits */
- if ((flags&(NDIGITS|EXPOK)) == EXPOK) {
- flags =
- (flags & ~(EXPOK|DPTOK)) |
- SIGNOK | NDIGITS;
- goto fok;
- }
- break;
- }
- break;
- fok:
- *p++ = c;
- fp->_IO_read_ptr++;
- if (_IO_peekc(fp) == EOF) {
- seen_eof++;
- break; /* EOF */
- }
- }
- /*
- * If no digits, might be missing exponent digits
- * (just give back the exponent) or might be missing
- * regular digits, but had sign and/or decimal point.
- */
- if (flags & NDIGITS) {
- if (flags & EXPOK) {
- /* no digits at all */
- while (p > buf)
- _IO_ungetc (*(u_char *)--p, fp);
- goto match_failure;
- }
- /* just a bad exponent (e and maybe sign) */
- c = *(u_char *)--p;
- if (c != 'e' && c != 'E') {
- (void) _IO_ungetc (c, fp);/* sign */
- c = *(u_char *)--p;
- }
- (void) _IO_ungetc (c, fp);
- }
- if ((flags & SUPPRESS) == 0) {
- double res;
- *p = 0;
-#ifdef _IO_USE_DTOA
- res = _IO_strtod(buf, NULL);
-#else
- res = atof(buf);
-#endif
- if (flags & LONG)
- *va_arg(ap, double *) = res;
- else
- *va_arg(ap, float *) = res;
- nassigned++;
- }
- nread += p - buf;
- break;
-#endif /* FLOATING_POINT */
- }
- }
-eof_failure:
- seen_eof++;
-input_failure:
- if (nassigned == 0)
- nassigned = -1;
-control_failure:
-match_failure:
- if (errp)
- *errp |= 2;
-done:
- if (errp && seen_eof)
- *errp |= 1;
- return (nassigned);
-}
-
-/*
- * Fill in the given table from the scanset at the given format
- * (just after `['). Return a pointer to the character past the
- * closing `]'. The table has a 1 wherever characters should be
- * considered part of the scanset.
- */
-static const u_char *__sccl(tab, fmt)
- register char *tab;
- register const u_char *fmt;
-{
- register int c, n, v;
-
- /* first `clear' the whole table */
- c = *fmt++; /* first char hat => negated scanset */
- if (c == '^') {
- v = 1; /* default => accept */
- c = *fmt++; /* get new first char */
- } else
- v = 0; /* default => reject */
- /* should probably use memset here */
- for (n = 0; n < 256; n++)
- tab[n] = v;
- if (c == 0)
- return (fmt - 1);/* format ended before closing ] */
-
- /*
- * Now set the entries corresponding to the actual scanset
- * to the opposite of the above.
- *
- * The first character may be ']' (or '-') without being special;
- * the last character may be '-'.
- */
- v = 1 - v;
- for (;;) {
- tab[c] = v; /* take character c */
-doswitch:
- n = *fmt++; /* and examine the next */
- switch (n) {
-
- case 0: /* format ended too soon */
- return (fmt - 1);
-
- case '-':
- /*
- * A scanset of the form
- * [01+-]
- * is defined as `the digit 0, the digit 1,
- * the character +, the character -', but
- * the effect of a scanset such as
- * [a-zA-Z0-9]
- * is implementation defined. The V7 Unix
- * scanf treats `a-z' as `the letters a through
- * z', but treats `a-a' as `the letter a, the
- * character -, and the letter a'.
- *
- * For compatibility, the `-' is not considerd
- * to define a range if the character following
- * it is either a close bracket (required by ANSI)
- * or is not numerically greater than the character
- * we just stored in the table (c).
- */
- n = *fmt;
- if (n == ']' || n < c) {
- c = '-';
- break; /* resume the for(;;) */
- }
- fmt++;
- do { /* fill in the range */
- tab[++c] = v;
- } while (c < n);
-#if 1 /* XXX another disgusting compatibility hack */
- /*
- * Alas, the V7 Unix scanf also treats formats
- * such as [a-c-e] as `the letters a through e'.
- * This too is permitted by the standard....
- */
- goto doswitch;
-#else
- c = *fmt++;
- if (c == 0)
- return (fmt - 1);
- if (c == ']')
- return (fmt);
-#endif
- break;
-
- case ']': /* end of scanset */
- return (fmt);
-
- default: /* just another character */
- c = n;
- break;
- }
- }
- /* NOTREACHED */
-}
diff --git a/gnu/lib/libg++/libio/isgetline.cc b/gnu/lib/libg++/libio/isgetline.cc
deleted file mode 100644
index 87722af..0000000
--- a/gnu/lib/libg++/libio/isgetline.cc
+++ /dev/null
@@ -1,140 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include <libioP.h>
-#include "iostream.h"
-#include <string.h>
-
-istream& istream::getline(char* buf, int len, char delim)
-{
- _gcount = 0;
- if (len <= 0)
- {
- set(ios::failbit);
- return *this;
- }
- int ch;
- if (ipfx1())
- {
- streambuf *sb = rdbuf();
- _gcount = _IO_getline(sb, buf, len - 1, delim, -1);
- ch = sb->sbumpc();
- if (ch == EOF)
- set (_gcount == 0 ? (ios::failbit|ios::eofbit) : ios::eofbit);
- else if (ch != (unsigned char) delim)
- {
- set(ios::failbit);
- sb->sungetc(); // Leave delimiter unread.
- }
- }
- else
- ch = EOF;
- buf[_gcount] = '\0';
- if (ch == (unsigned char)delim)
- _gcount++; // The delimiter is counted in the gcount().
- return *this;
-}
-
-istream& istream::get(char* buf, int len, char delim)
-{
- _gcount = 0;
- if (len <= 0)
- {
- set(ios::failbit);
- return *this;
- }
- if (ipfx1())
- {
- streambuf *sbuf = rdbuf();
- long count = _IO_getline(sbuf, buf, len - 1, delim, -1);
- if (count == 0 && sbuf->sgetc() == EOF)
- set(ios::failbit|ios::eofbit);
- else
- _gcount = count;
- }
- buf[_gcount] = '\0';
- return *this;
-}
-
-
-// from Doug Schmidt
-
-#define CHUNK_SIZE 512
-
-/* Reads an arbitrarily long input line terminated by a user-specified
- TERMINATOR. Super-nifty trick using recursion avoids unnecessary calls
- to NEW! */
-
-char *_sb_readline (streambuf *sb, long& total, char terminator)
-{
- char buf[CHUNK_SIZE];
- char *ptr;
- int ch;
-
- _IO_size_t count = _IO_getline(sb, buf, CHUNK_SIZE, terminator, -1);
- ch = sb->sbumpc();
- long old_total = total;
- total += count;
- if (ch != EOF && ch != terminator) {
- total++; // Include ch in total.
- ptr = _sb_readline(sb, total, terminator);
- if (ptr) {
- memcpy(ptr + old_total, buf, count);
- ptr[old_total+count] = ch;
- }
- return ptr;
- }
-
- if (ptr = new char[total+1]) {
- ptr[total] = '\0';
- memcpy(ptr + total - count, buf, count);
- return ptr;
- }
- else
- return NULL;
-}
-
-/* Reads an arbitrarily long input line terminated by TERMINATOR.
- This routine allocates its own memory, so the user should
- only supply the address of a (char *). */
-
-istream& istream::gets(char **s, char delim /* = '\n' */)
-{
- if (ipfx1()) {
- long size = 0;
- streambuf *sb = rdbuf();
- *s = _sb_readline (sb, size, delim);
- _gcount = *s ? size : 0;
- if (sb->_flags & _IO_EOF_SEEN) {
- set(ios::eofbit);
- if (_gcount == 0)
- set(ios::failbit);
- }
- }
- else {
- _gcount = 0;
- *s = NULL;
- }
- return *this;
-}
diff --git a/gnu/lib/libg++/libio/isgetsb.cc b/gnu/lib/libg++/libio/isgetsb.cc
deleted file mode 100644
index 2c5397f..0000000
--- a/gnu/lib/libg++/libio/isgetsb.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#include "iostream.h"
-#include <string.h>
-
-istream& istream::get(streambuf& sb, char delim /* = '\n' */)
-{
- _gcount = 0;
- if (ipfx1())
- {
- register streambuf* isb = rdbuf();
- for (;;)
- {
- streamsize len = isb->_IO_read_end - isb->_IO_read_ptr;
- if (len <= 0)
- if (__underflow(isb) == EOF)
- break;
- else
- len = isb->_IO_read_end - isb->_IO_read_ptr;
- char *delimp = (char*)memchr((void*)isb->_IO_read_ptr, delim, len);
- if (delimp != NULL)
- len = delimp - isb->_IO_read_ptr;
- int written = sb.sputn(isb->_IO_read_ptr, len);
- isb->_IO_read_ptr += written;
- _gcount += written;
- if (written != len)
- {
- set(ios::failbit);
- break;
- }
- if (delimp != NULL)
- break;
- }
- }
- return *this;
-}
diff --git a/gnu/lib/libg++/libio/isscan.cc b/gnu/lib/libg++/libio/isscan.cc
deleted file mode 100644
index 4e4ef83..0000000
--- a/gnu/lib/libg++/libio/isscan.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#include <iostream.h>
-#include <stdarg.h>
-
-istream& istream::scan(const char *format ...)
-{
- if (ipfx0()) {
- va_list ap;
- va_start(ap, format);
- _strbuf->vscan(format, ap, this);
- va_end(ap);
- }
- return *this;
-}
-
-istream& istream::vscan(const char *format, _IO_va_list args)
-{
- if (ipfx0())
- _strbuf->vscan(format, args, this);
- return *this;
-}
diff --git a/gnu/lib/libg++/libio/osform.cc b/gnu/lib/libg++/libio/osform.cc
deleted file mode 100644
index b4d4999..0000000
--- a/gnu/lib/libg++/libio/osform.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#include <iostream.h>
-#include <stdarg.h>
-
-ostream& ostream::form(const char *format ...)
-{
- if (opfx()) {
- va_list ap;
- va_start(ap, format);
- _IO_vfprintf(rdbuf(), format, ap);
- va_end(ap);
- }
- return *this;
-}
-
-ostream& ostream::vform(const char *format, _IO_va_list args)
-{
- if (opfx())
- _IO_vfprintf(rdbuf(), format, args);
- return *this;
-}
-
-ostream& ostream::operator<<(const void *p)
-{
- if (opfx()) {
- form("%p", p);
- osfx();
- }
- return *this;
-}
diff --git a/gnu/lib/libg++/libio/outfloat.c b/gnu/lib/libg++/libio/outfloat.c
deleted file mode 100644
index 83101b5..0000000
--- a/gnu/lib/libg++/libio/outfloat.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-
-/* Format floating-point number and print them.
- Return number of chars printed, or EOF on error.
-
- sign_mode == '+' : print "-" or "+"
- sign_mode == ' ' : print "-" or " "
- sign_mode == '\0' : print "-' or ""
-*/
-
-int _IO_outfloat(value, sb, type, width, precision, flags,
- sign_mode, fill)
- double value;
- _IO_FILE *sb;
- int type;
- int width;
- int precision;
- int flags;
- int sign_mode;
- int fill;
-{
- int count = 0;
-#define PUT(x) do {if (_IO_putc(x, sb) < 0) goto error; count++;} while (0)
-#define PUTN(p, n) \
- do {int _n=n; count+=_n; if (_IO_sputn(sb, p,_n) != _n) goto error;} while(0)
-#define PADN(fill, n) \
- do {int _n = n; count+=_n; if (_IO_padn(sb, fill, _n) != _n) goto error;} while (0)
- int pad_kind = flags & (_IO_LEFT|_IO_RIGHT|_IO_INTERNAL);
- int skip_zeroes = 0;
- int show_dot = (flags & _IO_SHOWPOINT) != 0;
- int decpt;
- int sign;
- int mode;
- int exponent_size;
- int print_sign;
- int trailing_zeroes, useful_digits;
- int padding, unpadded_width;
- char *p;
- char *exponent_start;
- register int i;
-#define EBUF_SIZE 12
-#define EBUF_END &ebuf[EBUF_SIZE]
- char ebuf[EBUF_SIZE];
- char *end;
- int exp = 0;
- switch (type)
- {
- case 'f':
- mode = 3;
- break;
- case 'e':
- case 'E':
- exp = type;
- mode = 2;
- if (precision != 999)
- precision++; /* Add one to include digit before decimal point. */
- break;
- case 'g':
- case 'G':
- exp = type == 'g' ? 'e' : 'E';
- if (precision == 0) precision = 1;
- if (!(flags & _IO_SHOWPOINT))
- skip_zeroes = 1;
- type = 'g';
- mode = 2;
- break;
- }
- /* Do the actual convension */
- if (precision == 999 && mode != 3)
- mode = 0;
- p = _IO_dtoa(value, mode, precision, &decpt, &sign, &end);
- useful_digits = end-p;
- exponent_start = EBUF_END;
- if (mode == 0)
- precision = useful_digits;
- /* Check if we need to emit an exponent. */
- if (mode != 3 && decpt != 9999)
- {
- i = decpt - 1;
- if ((type != 'g' && type != 'F') || i < -4 || i >= precision)
- {
- /* Print the exponent into ebuf.
- We write ebuf in reverse order (right-to-left). */
- char sign;
- if (i >= 0)
- sign = '+';
- else
- sign = '-', i = -i;
- /* Note: ANSI requires at least 2 exponent digits. */
- do {
- *--exponent_start = (i % 10) + '0';
- i /= 10;
- } while (i >= 10);
- *--exponent_start = i + '0';
- *--exponent_start = sign;
- *--exponent_start = exp;
- }
- }
- exponent_size = EBUF_END - exponent_start;
- if (mode == 1)
- precision = 1;
- /* If we print an exponent, always show just one digit before point. */
- if (exponent_size)
- decpt = 1;
- if (decpt == 9999)
- { /* Infinity or NaN */
- decpt = useful_digits;
- precision = 0;
- show_dot = 0;
- }
-
- /* dtoa truncates trailing zeroes. Set the variable trailing_zeroes to
- the number of 0's we have to add (after the decimal point). */
- if (skip_zeroes)
- trailing_zeroes = 0;
- else if (type == 'f')
- trailing_zeroes = useful_digits <= decpt ? precision
- : precision-(useful_digits-decpt);
- else if (exponent_size) /* 'e' 'E' or 'g' format using exponential notation*/
- trailing_zeroes = precision - useful_digits;
- else /* 'g' format not using exponential notation. */
- trailing_zeroes = useful_digits <= decpt ? precision - decpt
- : precision-useful_digits;
- if (trailing_zeroes < 0) trailing_zeroes = 0;
-
- if (trailing_zeroes != 0 || useful_digits > decpt)
- show_dot = 1;
- if (sign_mode == 0)
- print_sign = sign ? '-' : 0;
- else if (sign_mode == '+')
- print_sign = sign ? '-' : '+';
- else /* if (sign_mode == ' ') */
- print_sign = sign ? '-' : ' ';
-
- /* Calculate the width (before padding). */
- unpadded_width =
- (print_sign != 0) + trailing_zeroes + exponent_size + show_dot
- + useful_digits
- + (decpt > useful_digits ? decpt - useful_digits
- : decpt > 0 ? 0 : 1 - decpt);
-
- padding = width > unpadded_width ? width - unpadded_width : 0;
- if (padding > 0 && pad_kind != _IO_LEFT && pad_kind != _IO_INTERNAL)
- PADN(fill, padding); /* Default (right) adjust */
- if (print_sign)
- PUT(print_sign);
- if (pad_kind == _IO_INTERNAL && padding > 0)
- PADN(fill, padding);
- if (decpt > 0)
- {
- if (useful_digits >= decpt)
- PUTN(p, decpt);
- else
- {
- PUTN(p, useful_digits);
- PADN('0', decpt-useful_digits);
- }
- if (show_dot)
- {
- PUT('.');
- /* Print digits after the decimal point. */
- if (useful_digits > decpt)
- PUTN(p + decpt, useful_digits-decpt);
- }
- }
- else
- {
- PUT('0');
- if (show_dot)
- {
- PUT('.');
- PADN('0', -decpt);
- /* Print digits after the decimal point. */
- PUTN(p, useful_digits);
- }
- }
- PADN('0', trailing_zeroes);
- if (exponent_size)
- PUTN(exponent_start, exponent_size);
- if (pad_kind == _IO_LEFT && padding > 0) /* Left adjustment*/
- PADN(fill, padding);
- return count;
- error:
- return EOF;
-}
diff --git a/gnu/lib/libg++/libio/parsestream.cc b/gnu/lib/libg++/libio/parsestream.cc
deleted file mode 100644
index 3e986e3..0000000
--- a/gnu/lib/libg++/libio/parsestream.cc
+++ /dev/null
@@ -1,317 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License.
-
-Written by Per Bothner (bothner@cygnus.com). */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include "libioP.h"
-#include "parsestream.h"
-#include <stdlib.h>
-
-streambuf* parsebuf::setbuf(char*, int)
-{
- return NULL;
-}
-
-int parsebuf::tell_in_line()
-{
- return 0;
-}
-
-int parsebuf::pbackfail(int c)
-{
- if (c == EOF)
- return 0;
- if (seekoff(-1, ios::cur) == EOF)
- return EOF;
- return (unsigned char)c;
-}
-
-char* parsebuf::current_line() { return NULL; }
-
-streampos parsebuf::seekoff(streamoff offset, _seek_dir dir, int)
-{
- // Make offset relative to line start.
- switch (dir) {
- case ios::beg:
- offset -= pos_at_line_start;
- break;
- case ios::cur:
- offset += tell_in_line();
- break;
- default:
- return EOF;
- }
- if (offset < -1)
- return EOF;
- if (offset > _line_length + 1)
- return EOF;
- return seek_in_line(offset) + pos_at_line_start;
-}
-
-// string_parsebuf invariants:
-// The reserve ares (base() .. ebuf()) is always the entire string.
-// The get area (eback() .. egptr()) is the extended current line
-// (i.e. with the '\n' at either end, if these exist).
-
-string_parsebuf::string_parsebuf(char *buf, int len,
- int delete_at_close /* = 0*/)
-: parsebuf()
-{
- setb(buf, buf+len, delete_at_close);
- register char *ptr = buf;
- while (ptr < ebuf() && *ptr != '\n') ptr++;
- _line_length = ptr - buf;
- setg(buf, buf, ptr);
-}
-
-int string_parsebuf::underflow()
-{
- register char* ptr = egptr(); // Point to end of current_line
- do {
- int i = right() - ptr;
- if (i <= 0)
- return EOF;
- ptr++; i--; // Skip '\n'.
- char *line_start = ptr;
- while (ptr < right() && *ptr == '\n') ptr++;
- setg(line_start-1, line_start, ptr + (ptr < right()));
- pos_at_line_start = line_start - left();
- _line_length = ptr - line_start;
- __line_number++;
- } while (gptr() == ptr);
- return *gptr();
-}
-
-char* string_parsebuf::current_line()
-{
- char *ptr = eback();
- if (__line_number > 0)
- ptr++; // Skip '\n' at end of previous line.
- return ptr;
-}
-
-int string_parsebuf::tell_in_line()
-{
- int offset = gptr() - eback();
- if (__line_number > 0)
- offset--;
- return offset;
-}
-
-int string_parsebuf::seek_in_line(int i)
-{
- int delta = i - tell_in_line();
- gbump(delta); // FIXME: Needs error (bounds) checking!
- return i;
-}
-
-static const char NewLine[1] = { '\n' };
-
-general_parsebuf::general_parsebuf(streambuf *buf, int delete_arg_buf)
- : parsebuf()
-{
- delete_buf = delete_arg_buf;
- sbuf = buf;
- int buf_size = 128;
- char* buffer = ALLOC_BUF(buf_size);
- setb(buffer, buffer+buf_size, 1);
-// setg(buffer, buffer, buffer);
-}
-
-general_parsebuf::~general_parsebuf()
-{
- if (delete_buf)
- delete sbuf;
-}
-
-int general_parsebuf::underflow()
-{
- register char *ptr = base();
- int has_newline = eback() < gptr() && gptr()[-1] == '\n';
- if (has_newline)
- *ptr++ = '\n';
- register streambuf *sb = sbuf;
- register int ch;
- for (;;) {
- ch = sb->sbumpc();
- if (ch == EOF)
- break;
- if (ptr == ebuf()) {
- int old_size = ebuf() - base();
- char *new_buffer = new char[old_size * 2];
- memcpy(new_buffer, base(), old_size);
- setb(new_buffer, new_buffer + 2 * old_size, 1);
- ptr = new_buffer + old_size;
- }
- *ptr++ = ch;
- if (ch == '\n')
- break;
- }
- char *cur_pos = base() + has_newline;
- pos_at_line_start += _line_length + 1;
- _line_length = ptr - cur_pos;
- if (ch != EOF || _line_length > 0)
- __line_number++;
- setg(base(), cur_pos, ptr);
- return ptr == cur_pos ? EOF : cur_pos[0];
-}
-
-char* general_parsebuf::current_line()
-{
- char* ret = base();
- if (__line_number > 1)
- ret++; // Move past '\n' from end of previous line.
- return ret;
-}
-
-int general_parsebuf::tell_in_line()
-{
- int off = gptr() - base();
- if (__line_number > 1)
- off--; // Subtract 1 for '\n' from end of previous line.
- return off;
-}
-
-int general_parsebuf::seek_in_line(int i)
-{
- if (__line_number == 0)
- (void)general_parsebuf::underflow();
- if (__line_number > 1)
- i++; // Add 1 for '\n' from end of previous line.
- if (i < 0) i = 0;
- int len = egptr() - eback();
- if (i > len) i = len;
- setg(base(), base() + i, egptr());
- return i;
-}
-
-func_parsebuf::func_parsebuf(CharReader func, void *argm) : parsebuf()
-{
- read_func = func;
- arg = argm;
- buf_start = NULL;
- buf_end = NULL;
- setb((char*)NewLine, (char*)NewLine+1, 0);
- setg((char*)NewLine, (char*)NewLine+1, (char*)NewLine+1);
- backed_up_to_newline = 0;
-}
-
-int func_parsebuf::tell_in_line()
-{
- if (buf_start == NULL)
- return 0;
- if (egptr() != (char*)NewLine+1)
- // Get buffer was line buffer.
- return gptr() - buf_start;
- if (backed_up_to_newline)
- return -1; // Get buffer is '\n' preceding current line.
- // Get buffer is '\n' following current line.
- return (buf_end - buf_start) + (gptr() - (char*)NewLine);
-}
-
-char* func_parsebuf::current_line()
-{
- return buf_start;
-}
-
-int func_parsebuf::seek_in_line(int i)
-{
- if (i < 0) {
- // Back up to preceding '\n'.
- if (i < -1) i = -1;
- backed_up_to_newline = 1;
- setg((char*)NewLine, (char*)NewLine+(i+1), (char*)NewLine+1);
- return i;
- }
- backed_up_to_newline = 0;
- int line_length = buf_end-buf_start;
- if (i <= line_length) {
- setg(buf_start, buf_start+i, buf_end);
- return i;
- }
- i -= line_length;
- if (i > 0) i = 1;
- setg((char*)NewLine, (char*)NewLine+i, (char*)NewLine+1);
- return line_length + i;
-}
-
-int func_parsebuf::underflow()
-{
- retry:
- if (gptr() < egptr())
- return *gptr();
- if (gptr() != (char*)NewLine+1) {
- // Get buffer was line buffer. Move to following '\n'.
- setg((char*)NewLine, (char*)NewLine, (char*)NewLine+1);
- return *gptr();
- }
- if (backed_up_to_newline)
- // Get buffer was '\n' preceding current line. Move to current line.
- backed_up_to_newline = 0;
- else {
- // Get buffer was '\n' following current line. Read new line.
- if (buf_start) free(buf_start);
- char *str = (*read_func)(arg);
- buf_start = str;
- if (str == NULL)
- return EOF;
- // Initially, _line_length == -1, so pos_at_line_start becomes 0.
- pos_at_line_start += _line_length + 1;
- _line_length = strlen(str);
- buf_end = str + _line_length;
- __line_number++;
- }
- setg(buf_start, buf_start, buf_end);
- goto retry;
-}
-
-#if 0
-size_t parsebuf::line_length()
-{
- if (current_line_length == (size_t)(-1)) // Initial value;
- (void)sgetc();
- return current_line_length;
-}
-#endif
-
-int parsebuf::seek_in_line(int i)
-{
-#if 1
- abort();
- return 0; // Suppress warning.
-#else
- if (i > 0) {
- size_t len = line_length();
- if ((unsigned)i > len) i = len;
- }
- else if (i < -1) i = -1;
- int new_pos = seekoff(pos_at_line_start + i, ios::beg);
- if (new_pos == EOF)
- return tell_in_line();
- else return new_pos - pos_at_line_start;
-#endif
-}
diff --git a/gnu/lib/libg++/libio/pfstream.cc b/gnu/lib/libg++/libio/pfstream.cc
deleted file mode 100644
index 3dfa16f..0000000
--- a/gnu/lib/libg++/libio/pfstream.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Written by Per Bothner (bothner@cygnus.com). */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include "libioP.h"
-#include <pfstream.h>
-#include <procbuf.h>
-
-ipfstream::ipfstream(const char *name, int mode, int prot)
-{
- const char* p;
-
- // Look for '| command' (as used by ftp).
- for (p = name; *p == ' ' || *p == '\t'; p++) ;
- if (*p == '|') {
- procbuf *pbuf = new procbuf();
- init(pbuf);
- if (!pbuf->open(p+1, mode))
- set(ios::badbit);
- return;
- }
-
- // Look for 'command |'
- while (*p) p++; // Point to last
- while (p[-1] == ' ' || p[-1] == '\t' || p[-1] == '\n') p--;
- if (p[-1] == '|') {
- // Must remove the final '|'.
- p--;
-#if !defined (__GNUC__) || defined (__STRICT_ANSI__)
- char *command = new char[p-name+1];
-#else
- char command[p-name+1];
-#endif
- memcpy(command, name, p-name);
- command[p-name] = '\0';
-
- procbuf *pbuf = new procbuf();
- if (pbuf->open(command, mode))
- set(ios::badbit);
-#if !defined (__GNUC__) || defined (__STRICT_ANSI__)
- delete command;
-#endif
- return;
- }
-
- init(new filebuf());
- if (!rdbuf()->open(name, mode, prot))
- set(ios::badbit);
-}
-
-opfstream::opfstream(const char *name, int mode, int prot)
-{
- const char *p;
- // Look for '| command'.
- for (p = name; *p == ' ' || *p == '\t'; p++) ;
- if (*p == '|') {
- procbuf *pbuf = new procbuf();
- init(pbuf);
- if (!pbuf->open(p+1, mode))
- set(ios::badbit);
- }
- else {
- init(new filebuf());
- if (!rdbuf()->open(name, mode, prot))
- set(ios::badbit);
- }
-}
diff --git a/gnu/lib/libg++/libio/procbuf.cc b/gnu/lib/libg++/libio/procbuf.cc
deleted file mode 100644
index 797bf48..0000000
--- a/gnu/lib/libg++/libio/procbuf.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Written by Per Bothner (bothner@cygnus.com). */
-
-#define _POSIX_SOURCE
-#include "libioP.h"
-#include "procbuf.h"
-
-procbuf::procbuf(const char *command, int mode) : filebuf()
-{
- _IO_proc_open(this, command, (mode & ios::in) ? "r" : "w");
-}
-
-procbuf *procbuf::open(const char *command, int mode)
-{
- return (procbuf*)_IO_proc_open(this, command, (mode & ios::in) ? "r" : "w");
-}
-
-/* #define USE_SIGMASK */
-
-int procbuf::sys_close()
-{
- return _IO_proc_close(this);
-}
-
-procbuf::~procbuf()
-{
- close();
-}
diff --git a/gnu/lib/libg++/libio/sbform.cc b/gnu/lib/libg++/libio/sbform.cc
deleted file mode 100644
index 42f91e3..0000000
--- a/gnu/lib/libg++/libio/sbform.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#include "streambuf.h"
-#include <stdarg.h>
-
-int streambuf::vform(char const *fmt0, _IO_va_list ap)
-{
- return _IO_vfprintf(this, fmt0, ap);
-}
-int streambuf::form(char const *format ...)
-{
- va_list ap;
- va_start(ap, format);
- int count = _IO_vfprintf(this, format, ap);
- va_end(ap);
- return count;
-}
diff --git a/gnu/lib/libg++/libio/sbgetline.cc b/gnu/lib/libg++/libio/sbgetline.cc
deleted file mode 100644
index f8ee260..0000000
--- a/gnu/lib/libg++/libio/sbgetline.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#include "streambuf.h"
-
-long streambuf::sgetline(char* buf, _IO_size_t n, char delim, int extract_delim)
-{
- return _IO_getline(this, buf, n, delim, extract_delim);
-}
diff --git a/gnu/lib/libg++/libio/sbscan.cc b/gnu/lib/libg++/libio/sbscan.cc
deleted file mode 100644
index d9af571..0000000
--- a/gnu/lib/libg++/libio/sbscan.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "libioP.h"
-#include "streambuf.h"
-#include <stdarg.h>
-
-int streambuf::vscan(char const *fmt0, _IO_va_list ap, ios* stream /* = NULL*/)
-{
- int errcode = 0;
- int count = _IO_vfscanf(this, fmt0, ap, &errcode);
- if (stream)
- stream->setstate((ios::iostate)errcode);
- return count;
-}
-int streambuf::scan(char const *format ...)
-{
- va_list ap;
- va_start(ap, format);
- int count = _IO_vfscanf(this, format, ap, NULL);
- va_end(ap);
- return count;
-}
diff --git a/gnu/lib/libg++/libio/stdiostream.cc b/gnu/lib/libg++/libio/stdiostream.cc
deleted file mode 100644
index f6de524..0000000
--- a/gnu/lib/libg++/libio/stdiostream.cc
+++ /dev/null
@@ -1,159 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Written by Per Bothner (bothner@cygnus.com). */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include <stdiostream.h>
-#include "libioP.h"
-
-// A stdiobuf is "tied" to a FILE object (as used by the stdio package).
-// Thus a stdiobuf is always synchronized with the corresponding FILE,
-// though at the cost of some overhead. (If you use the implementation
-// of stdio supplied with this library, you don't need stdiobufs.)
-// This implementation inherits from filebuf, but implement the virtual
-// functions sys_read/..., using the stdio functions fread/... instead
-// of the low-level read/... system calls. This has the advantage that
-// we get all of the nice filebuf semantics automatically, though
-// with some overhead.
-
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-#ifndef SEEK_CUR
-#define SEEK_CUR 1
-#endif
-#ifndef SEEK_END
-#define SEEK_END 2
-#endif
-
-stdiobuf::stdiobuf(FILE *f) : filebuf(fileno(f))
-{
- _file = f;
- // Turn off buffer in stdiobuf. Instead, rely on buffering in (FILE).
- // Thus the stdiobuf will be synchronized with the FILE.
- setbuf(NULL, 0);
-}
-
-stdiobuf::~stdiobuf()
-{
- /* Only needed if we're buffered. Not buffered is the default. */
- _IO_do_flush((_IO_FILE*)this);
-}
-
-streamsize stdiobuf::sys_read(char* buf, streamsize size)
-{
- // A minor optimization, but it makes a noticable difference.
- // A bigger optimization would be to write stdiobuf::underflow,
- // but that has some modularity disadvantages. Re-evaluate that
- // after we have gotten rid of the double indirection. FIXME
- if (size == 1)
- {
- register ch = getc(_file);
- if (ch == EOF)
- return 0;
- *buf = (char)ch;
- return 1;
- }
- else
- return fread(buf, 1, size, _file);
-}
-
-streamsize stdiobuf::sys_write(const char *buf, streamsize n)
-{
- _IO_ssize_t count = fwrite(buf, 1, n, _file);
- if (_offset >= 0)
- _offset += n;
- return count;
-}
-
-streampos stdiobuf::sys_seek(streamoff offset, _seek_dir dir)
-{
- // Normally, equivalent to: fdir=dir
- int fdir =
- (dir == ios::beg) ? SEEK_SET :
- (dir == ios::cur) ? SEEK_CUR :
- (dir == ios::end) ? SEEK_END :
- dir;
- return fseek(_file, offset, fdir);
-}
-
-int stdiobuf::sys_close()
-{
- int status = fclose(_file);
- _file = NULL;
- return status;
-}
-
-int stdiobuf::sync()
-{
- if (_IO_do_flush((_IO_FILE*)this))
- return EOF;
- if (!(xflags() & _IO_NO_WRITES))
- if (fflush(_file))
- return EOF;
- return 0;
-}
-
-int stdiobuf::overflow(int c /* = EOF*/)
-{
- if (filebuf::overflow(c) == EOF)
- return EOF;
- if (c != EOF)
- return c;
- return fflush(_file);
-}
-
-streamsize stdiobuf::xsputn(const char* s, streamsize n)
-{
- if (buffered ())
- {
- // The filebuf implementation of sputn loses.
- return streambuf::xsputn(s, n);
- }
- else
- return fwrite (s, 1, n, _file);
-}
-
-void stdiobuf::buffered (int b)
-{
- if (b)
- {
- if (_flags & _IO_UNBUFFERED)
- { /* Was unbuffered, make it buffered. */
- _flags &= ~_IO_UNBUFFERED;
- }
- }
- else
- {
- if (!(_flags & _IO_UNBUFFERED))
- { /* Was buffered, make it unbuffered. */
- setbuf(NULL, 0);
- }
- }
-}
diff --git a/gnu/lib/libg++/libio/stdstrbufs.cc b/gnu/lib/libg++/libio/stdstrbufs.cc
deleted file mode 100644
index 6598c1f..0000000
--- a/gnu/lib/libg++/libio/stdstrbufs.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-Copyright (C) 1994 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 file provides definitions of _IO_stdin, _IO_stdout, and _IO_stderr
- for C++ code. Compare stdfiles.c.
- (The difference is that here the vtable field is set to
- point to builtinbuf's vtable, so the objects are effectively
- of class builtinbuf.) */
-
-#include "libioP.h"
-#include <stdio.h>
-
-#ifndef STD_VTABLE
-#define STD_VTABLE builtinbuf_vtable
-#endif
-
-#define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
- struct _IO_FILE_plus NAME = {FILEBUF_LITERAL(CHAIN, FLAGS, FD), STD_VTABLE}
-
-DEF_STDFILE(_IO_stdin_, 0, 0, _IO_NO_WRITES);
-DEF_STDFILE(_IO_stdout_, 1, &_IO_stdin_.file, _IO_NO_READS);
-DEF_STDFILE(_IO_stderr_, 2, &_IO_stdout_.file,
- _IO_NO_READS+_IO_UNBUFFERED);
-
-#ifdef _STDIO_USES_IOSTREAM
-_IO_FILE *_IO_list_all = &_IO_stderr_.file;
-#else /* !_STDIO_USES_IOSTREAM */
-#include "stdiostream.h"
-
-struct _IO_fake_stdiobuf {
- _IO_FILE file;
- const void *vtable;
- FILE *stdio_file;
-};
-
-/* Define stdiobuf_vtable as a name for the virtual function table
- of the stdiobuf class. */
-#ifndef stdiobuf_vtable
-#ifdef __GNUC__
-extern char stdiobuf_vtable[]
- asm (_G_VTABLE_LABEL_PREFIX
-#if _G_VTABLE_LABEL_HAS_LENGTH
- "8"
-#endif
- "stdiobuf");
-#else /* !__GNUC__ */
-#if _G_VTABLE_LABEL_HAS_LENGTH
-#define stdiobuf_vtable _G_VTABLE_LABEL_PREFIX_ID##8stdiobuf
-#else
-#define stdiobuf_vtable _G_VTABLE_LABEL_PREFIX_ID##stdiobuf
-#endif
-extern char stdiobuf_vtable[];
-#endif /* !__GNUC__ */
-#endif /* !stdiobuf_vtable */
-
-#define DEF_STDIOFILE(NAME, FD, FILE, FLAGS, CHAIN) \
- struct _IO_fake_stdiobuf NAME = \
- {{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+_IO_UNBUFFERED+FLAGS, \
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, &_IO_streambuf_jumps, FD},\
- stdiobuf_vtable, FILE}
-
-DEF_STDIOFILE(_IO_stdin_buf, 0, stdin, _IO_NO_WRITES, &_IO_stderr_.file);
-DEF_STDIOFILE(_IO_stdout_buf, 1, stdout, _IO_NO_READS, &_IO_stdin_buf.file);
-DEF_STDIOFILE(_IO_stderr_buf, 2, stderr, _IO_NO_READS, &_IO_stdout_buf.file);
-
-_IO_FILE *_IO_list_all = &_IO_stderr_buf.file;
-#endif /* !_STDIO_USES_IOSTREAM */
diff --git a/gnu/lib/libg++/libio/stdstreams.cc b/gnu/lib/libg++/libio/stdstreams.cc
deleted file mode 100644
index 18055a7..0000000
--- a/gnu/lib/libg++/libio/stdstreams.cc
+++ /dev/null
@@ -1,143 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Written by Per Bothner (bothner@cygnus.com). */
-
-#include "libioP.h"
-#include "streambuf.h"
-#include <stdio.h>
-
-// The ANSI draft requires that operations on cin/cout/cerr can be
-// mixed with operations on stdin/stdout/stderr on a character by
-// character basis. This normally requires that the streambuf's
-// used by cin/cout/cerr be stdiostreams. However, if the stdio
-// implementation is the one that is built using this library,
-// then we don't need to, since in that case stdin/stdout/stderr
-// are identical to _IO_stdin/_IO_stdout/_IO_stderr.
-
-#include "libio.h"
-
-#ifdef _STDIO_USES_IOSTREAM
-#define CIN_SBUF _IO_stdin_
-#define COUT_SBUF _IO_stdout_
-#define CERR_SBUF _IO_stderr_
-static int use_stdiobuf = 0;
-#else
-#define CIN_SBUF _IO_stdin_buf
-#define COUT_SBUF _IO_stdout_buf
-#define CERR_SBUF _IO_stderr_buf
-static int use_stdiobuf = 1;
-#endif
-
-#define cin CIN
-#define cout COUT
-#define cerr CERR
-#define clog CLOG
-#include "iostream.h"
-#undef cin
-#undef cout
-#undef cerr
-#undef clog
-
-#ifdef __GNUG__
-#define PAD 0 /* g++ allows 0-length arrays. */
-#else
-#define PAD 1
-#endif
-struct _fake_istream {
- struct myfields {
-#ifdef __GNUC__
- _ios_fields *vb; /* pointer to virtual base class ios */
- _IO_ssize_t _gcount;
-#else
- /* This is supposedly correct for cfront. */
- _IO_ssize_t _gcount;
- void *vptr;
- _ios_fields *vb; /* pointer to virtual base class ios */
-#endif
- } mine;
- _ios_fields base;
- char filler[sizeof(struct istream)-sizeof(struct _ios_fields)+PAD];
-};
-struct _fake_ostream {
- struct myfields {
-#ifndef __GNUC__
- void *vptr;
-#endif
- _ios_fields *vb; /* pointer to virtual base class ios */
- } mine;
- _ios_fields base;
- char filler[sizeof(struct ostream)-sizeof(struct _ios_fields)+PAD];
-};
-
-#define STD_STR(SBUF, TIE, EXTRA_FLAGS) \
- (streambuf*)&SBUF, TIE, 0, ios::dont_close|ios::skipws|EXTRA_FLAGS, ' ',0,0,6
-
-#ifdef __GNUC__
-#define OSTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \
- _fake_ostream NAME = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }};
-#define ISTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \
- _fake_istream NAME = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }};
-#else
-#define OSTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \
- _fake_ostream NAME = { {0, &NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }};
-#define ISTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \
- _fake_istream NAME = {{0, 0, &NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS)}};
-#endif
-
-OSTREAM_DEF(cout, COUT_SBUF, NULL, 0)
-OSTREAM_DEF(cerr, CERR_SBUF,(ostream*)&cout, ios::unitbuf)
-ISTREAM_DEF(cin, CIN_SBUF, (ostream*)&cout, 0)
-
-/* Only for (partial) compatibility with AT&T's library. */
-OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0)
-
-// Switches between using _IO_std{in,out,err} and __std{in,out,err}_buf
-// for standard streams. This does not normally need to be called
-// explicitly, but is provided for AT&T compatibility.
-
-int ios::sync_with_stdio(int new_state)
-{
-#ifdef _STDIO_USES_IOSTREAM
- // It is always synced.
- return 0;
-#else
- if (new_state == use_stdiobuf) // The usual case now.
- return use_stdiobuf;
- if (new_state) {
- cin.base._strbuf = (streambuf*)&_IO_stdin_buf;
- cout.base._strbuf = (streambuf*)&_IO_stdout_buf;
- cerr.base._strbuf = (streambuf*)&_IO_stderr_buf;
- clog.base._strbuf = (streambuf*)&_IO_stderr_buf;
- } else {
- cin.base._strbuf = (streambuf*)_IO_stdin;
- cout.base._strbuf = (streambuf*)_IO_stdout;
- cerr.base._strbuf = (streambuf*)_IO_stderr;
- clog.base._strbuf = (streambuf*)_IO_stderr;
- }
- int old_state = use_stdiobuf;
- use_stdiobuf = new_state;
- return old_state;
-#endif
-}
diff --git a/gnu/lib/libg++/libio/stream.cc b/gnu/lib/libg++/libio/stream.cc
deleted file mode 100644
index 543071c..0000000
--- a/gnu/lib/libg++/libio/stream.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include <stdarg.h>
-#include "libioP.h"
-#include "stream.h"
-#include "strstream.h"
-
-static char Buffer[_IO_BUFSIZ];
-#define EndBuffer (Buffer+_IO_BUFSIZ)
-static char* next_chunk = Buffer; // Start of available part of Buffer.
-
-char* form(const char* format, ...)
-{
- int space_left = EndBuffer - next_chunk;
- // If less that 25% of the space is available start over.
- if (space_left < (_IO_BUFSIZ>>2))
- next_chunk = Buffer;
- char* buf = next_chunk;
-
- strstreambuf stream(buf, EndBuffer-buf-1, buf);
- va_list ap;
- va_start(ap, format);
- int count = stream.vform(format, ap);
- va_end(ap);
- stream.sputc(0);
- next_chunk = buf + stream.pcount();
- return buf;
-}
-
-#define u_long unsigned long
-
-static char* itoa(unsigned long i, int size, int neg, int base)
-{
- // Conservative estimate: If base==2, might need 8 characters
- // for each input byte, but normally 3 is plenty.
- int needed = size ? size
- : (base >= 8 ? 3 : 8) * sizeof(unsigned long) + 2;
- int space_left = EndBuffer - next_chunk;
- if (space_left <= needed)
- next_chunk = Buffer; // start over.
-
- char* buf = next_chunk;
-
- register char* ptr = buf+needed+1;
- next_chunk = ptr;
-
- if (needed < (2+neg) || ptr > EndBuffer)
- return NULL;
- *--ptr = 0;
-
- if (i == 0)
- *--ptr = '0';
- while (i != 0 && ptr > buf) {
- int ch = i % base;
- i = i / base;
- if (ch >= 10)
- ch += 'a' - 10;
- else
- ch += '0';
- *--ptr = ch;
- }
- if (neg)
- *--ptr = '-';
- if (size == 0)
- return ptr;
- while (ptr > buf)
- *--ptr = ' ';
- return buf;
-}
-
-char* dec(long i, int len /* = 0 */)
-{
- if (i >= 0) return itoa((unsigned long)i, len, 0, 10);
- else return itoa((unsigned long)(-i), len, 1, 10);
-}
-char* dec(int i, int len /* = 0 */)
-{
- if (i >= 0) return itoa((unsigned long)i, len, 0, 10);
- else return itoa((unsigned long)(-i), len, 1, 10);
-}
-char* dec(unsigned long i, int len /* = 0 */)
-{
- return itoa(i, len, 0, 10);
-}
-char* dec(unsigned int i, int len /* = 0 */)
-{
- return itoa(i, len, 0, 10);
-}
-
-char* hex(long i, int len /* = 0 */)
-{
- return itoa((unsigned long)i, len, 0, 16);
-}
-char* hex(int i, int len /* = 0 */)
-{
- return itoa((unsigned long)i, len, 0, 16);
-}
-char* hex(unsigned long i, int len /* = 0 */)
-{
- return itoa(i, len, 0, 16);
-}
-char* hex(unsigned int i, int len /* = 0 */)
-{
- return itoa(i, len, 0, 16);
-}
-
-char* oct(long i, int len /* = 0 */)
-{
- return itoa((unsigned long)i, len, 0, 8);
-}
-char* oct(int i, int len /* = 0 */)
-{
- return itoa((unsigned long)i, len, 0, 8);
-}
-char* oct(unsigned long i, int len /* = 0 */)
-{
- return itoa(i, len, 0, 8);
-}
-char* oct(unsigned int i, int len /* = 0 */)
-{
- return itoa(i, len, 0, 8);
-}
diff --git a/gnu/lib/libg++/libio/streambuf.cc b/gnu/lib/libg++/libio/streambuf.cc
deleted file mode 100644
index a484572..0000000
--- a/gnu/lib/libg++/libio/streambuf.cc
+++ /dev/null
@@ -1,341 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1991, 1992, 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). */
-
-#define _STREAM_COMPAT
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include "iostreamP.h"
-#include <string.h>
-#include <stdarg.h>
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-
-void streambuf::_un_link() { _IO_un_link(this); }
-
-void streambuf::_link_in() { _IO_link_in(this); }
-
-int streambuf::switch_to_get_mode()
-{ return _IO_switch_to_get_mode(this); }
-
-void streambuf::free_backup_area()
-{ _IO_free_backup_area(this); }
-
-#if 0
-int streambuf::switch_to_put_mode()
-{ return _IO_:switch_to_put_mode(this); }
-#endif
-
-int __overflow(streambuf* sb, int c)
-{
- return sb->overflow(c);
-}
-
-int streambuf::underflow()
-{ return EOF; }
-
-int streambuf::overflow(int c /* = EOF */)
-{ return EOF; }
-
-streamsize streambuf::xsputn(register const char* s, streamsize n)
-{ return _IO_default_xsputn(this, s, n); }
-
-streamsize streambuf::xsgetn(char* s, streamsize n)
-{ return _IO_default_xsgetn(this, s, n); }
-
-int streambuf::ignore(int n)
-{
- register int more = n;
- for (;;) {
- int count = _IO_read_end - _IO_read_ptr; // Data available.
- if (count > 0) {
- if (count > more)
- count = more;
- _IO_read_ptr += count;
- more -= count;
- }
- if (more == 0 || __underflow(this) == EOF)
- break;
- }
- return n - more;
-}
-
-int streambuf::sync()
-{
- if (pptr() == pbase())
- return 0;
- return EOF;
-}
-
-int streambuf::pbackfail(int c)
-{
- return _IO_default_pbackfail(this, c);
-}
-
-streambuf* streambuf::setbuf(char* p, int len)
-{
- if (sync() == EOF)
- return NULL;
- if (p == NULL || len == 0) {
- unbuffered(1);
- setb(_shortbuf, _shortbuf+1, 0);
- }
- else {
- unbuffered(0);
- setb(p, p+len, 0);
- }
- setp(0, 0);
- setg(0, 0, 0);
- return this;
-}
-
-streampos streambuf::seekpos(streampos pos, int mode)
-{
- return seekoff(pos, ios::beg, mode);
-}
-
-streampos streambuf::sseekpos(streampos pos, int mode)
-{
- return _IO_seekpos (this, pos, convert_to_seekflags (0, mode));
-}
-
-void streambuf::setb(char* b, char* eb, int a)
-{ _IO_setb(this, b, eb, a); }
-
-int streambuf::doallocate() { return _IO_default_doallocate(this); }
-
-void streambuf::doallocbuf() { _IO_doallocbuf(this); }
-
-/* The following are jump table entries that just call the virtual method */
-
-static int _IO_sb_overflow(_IO_FILE *fp, int c)
-{ return ((streambuf*)fp)->overflow(c); }
-static int _IO_sb_underflow(_IO_FILE *fp)
-{ return ((streambuf*)fp)->underflow(); }
-static _IO_size_t _IO_sb_xsputn(_IO_FILE *fp, const void *s, _IO_size_t n)
-{ return ((streambuf*)fp)->xsputn((const char*)s, n); }
-static _IO_size_t _IO_sb_xsgetn(_IO_FILE *fp, void *s, _IO_size_t n)
-{ return ((streambuf*)fp)->xsgetn((char*)s, n); }
-static int _IO_sb_close(_IO_FILE *fp)
-{ return ((streambuf*)fp)->sys_close(); }
-static int _IO_sb_stat(_IO_FILE *fp, void *b)
-{ return ((streambuf*)fp)->sys_stat(b); }
-static int _IO_sb_doallocate(_IO_FILE *fp)
-{ return ((streambuf*)fp)->doallocate(); }
-
-static _IO_pos_t _IO_sb_seekoff(_IO_FILE *fp, _IO_off_t pos, _IO_seekflags m)
-{
- int mode = ((m & _IO_seek_not_in) ? 0 : ios::in)
- + ((m & _IO_seek_not_out) ? 0 : ios::out);
- return ((streambuf*)fp)->seekoff(pos, (_seek_dir)((int)m & 3), mode);
-}
-
-static _IO_pos_t _IO_sb_seekpos(_IO_FILE *fp, _IO_pos_t pos, _IO_seekflags m)
-{
- int mode = ((m & _IO_seek_not_in) ? 0 : ios::in)
- + ((m & _IO_seek_not_out) ? 0 : ios::out);
- return ((streambuf*)fp)->seekpos(pos, mode);
-}
-
-static int _IO_sb_pbackfail(_IO_FILE *fp, int ch)
-{ return ((streambuf*)fp)->pbackfail(ch); }
-static void _IO_sb_finish(_IO_FILE *fp)
-{ ((streambuf*)fp)->~streambuf(); }
-static _IO_ssize_t _IO_sb_read(_IO_FILE *fp, void *buf, _IO_ssize_t n)
-{ return ((streambuf*)fp)->sys_read((char*)buf, n); }
-static _IO_ssize_t _IO_sb_write(_IO_FILE *fp, const void *buf, _IO_ssize_t n)
-{ return ((streambuf*)fp)->sys_write((const char*)buf, n); }
-static int _IO_sb_sync(_IO_FILE *fp)
-{ return ((streambuf*)fp)->sync(); }
-static _IO_pos_t _IO_sb_seek(_IO_FILE *fp, _IO_off_t off, int dir)
-{ return ((streambuf*)fp)->sys_seek(off, (_seek_dir)dir); }
-static int _IO_sb_setbuf(_IO_FILE *fp, char *buf, _IO_ssize_t n)
-{ return ((streambuf*)fp)->setbuf(buf, n) == NULL ? EOF : 0; }
-
-/* This callbacks in this jumptable just call the corresponding
- virtual function, so that C functions can access (potentially user-defined)
- streambuf-derived objects.
- Contrast the builtinbuf class, which does the converse: Allow
- C++ virtual calls to to be used on _IO_FILE objects that are builtin
- (or defined by C code). */
-
-
-struct _IO_jump_t _IO_streambuf_jumps = {
- _IO_sb_overflow,
- _IO_sb_underflow,
- _IO_sb_xsputn,
- _IO_sb_xsgetn,
- _IO_sb_read,
- _IO_sb_write,
- _IO_sb_doallocate,
- _IO_sb_pbackfail,
- _IO_sb_setbuf,
- _IO_sb_sync,
- _IO_sb_finish,
- _IO_sb_close,
- _IO_sb_stat,
- _IO_sb_seek,
- _IO_sb_seekoff,
- _IO_sb_seekpos,
- _IO_default_uflow
-};
-
-streambuf::streambuf(int flags)
-{
- _IO_init(this, flags);
- _jumps = &_IO_streambuf_jumps;
-}
-
-streambuf::~streambuf() { _IO_default_finish(this); }
-
-streampos
-streambuf::seekoff(streamoff, _seek_dir, int mode /*=ios::in|ios::out*/)
-{
- return EOF;
-}
-
-streampos
-streambuf::sseekoff(streamoff o , _seek_dir d, int m /*=ios::in|ios::out*/)
-{
- return _IO_seekoff (this, o, convert_to_seekflags (d, m));
-}
-
-int streambuf::sputbackc(char c)
-{
- return _IO_sputbackc(this, c);
-}
-
-int streambuf::sungetc()
-{
- return _IO_sungetc(this);
-}
-
-#if 0 /* Work in progress */
-void streambuf::collumn(int c)
-{
- if (c == -1)
- _collumn = -1;
- else
- _collumn = c - (_IO_write_ptr - _IO_write_base);
-}
-#endif
-
-
-int streambuf::get_column()
-{
- if (_cur_column)
- return _IO_adjust_column(_cur_column - 1, pbase(), pptr() - pbase());
- return -1;
-}
-
-int streambuf::set_column(int i)
-{
- _cur_column = i+1;
- return 0;
-}
-
-int streambuf::flush_all() { return _IO_flush_all (); }
-
-void streambuf::flush_all_linebuffered()
-{ _IO_flush_all_linebuffered(); }
-
-int streambuf::sys_stat(void *)
-{
-#ifdef EIO
- errno = EIO;
-#endif
- return -1;
-}
-
-streamsize streambuf::sys_read(char* buf, streamsize size)
-{
- return 0;
-}
-
-streamsize streambuf::sys_write(const char* buf, streamsize size)
-{
- return 0;
-}
-
-streampos streambuf::sys_seek(streamoff, _seek_dir)
-{
- return EOF;
-}
-
-int streambuf::sys_close() { return 0; /* Suceess; do nothing */ }
-
-streammarker::streammarker(streambuf *sb)
-{
- _IO_init_marker(this, sb);
-}
-
-streammarker::~streammarker()
-{
- _IO_remove_marker(this);
-}
-
-#define BAD_DELTA EOF
-
-int streammarker::delta(streammarker& other_mark)
-{
- return _IO_marker_difference(this, &other_mark);
-}
-
-int streammarker::delta()
-{
- return _IO_marker_delta(this);
-}
-
-int streambuf::seekmark(streammarker& mark, int delta /* = 0 */)
-{
- return _IO_seekmark(this, &mark, delta);
-}
-
-void streambuf::unsave_markers()
-{
- _IO_unsave_markers(this);
-}
-
-int ios::readable() { return !(rdbuf()->_flags & _IO_NO_READS); }
-int ios::writable() { return !(rdbuf()->_flags & _IO_NO_WRITES); }
-int ios::is_open() { return rdbuf()
- && (rdbuf()->_flags & _IO_NO_READS+_IO_NO_WRITES)
- != _IO_NO_READS+_IO_NO_WRITES; }
-
-#if defined(linux)
-#define IO_CLEANUP
-#endif
-
-#ifdef IO_CLEANUP
- IO_CLEANUP
-#else
-struct __io_defs {
- ~__io_defs() { _IO_cleanup (); }
-};
-__io_defs io_defs__;
-#endif
diff --git a/gnu/lib/libg++/libio/strops.c b/gnu/lib/libg++/libio/strops.c
deleted file mode 100644
index 1332d0b..0000000
--- a/gnu/lib/libg++/libio/strops.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-#include "strfile.h"
-#include "libioP.h"
-#include <string.h>
-
-#define LEN(fp) (((_IO_strfile*)(fp))->_s._len)
-
-#ifdef TODO
-/* An "unbounded buffer" is when a buffer is supplied, but with no
- specified length. An example is the buffer argument to sprintf.
- */
-#endif
-
-void
-_IO_str_init_static (fp, ptr, size, pstart)
- _IO_FILE *fp;
- char *ptr;
- int size;
- char *pstart;
-{
- if (size == 0)
- size = strlen(ptr);
- else if (size < 0)
- {
- /* If size is negative 'the characters are assumed to
- continue indefinitely.' This is kind of messy ... */
-#if 1
- int s;
- size = 512;
- /* Try increasing powers of 2, as long as we don't wrap around.
- This can lose in pathological cases (ptr near the end
- of the address space). A better solution might be to
- adjust the size on underflow/overflow. FIXME. */
- for (s; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; )
- size = s;
- size = s;
-#else
- /* The following semi-portable kludge assumes that
- sizeof(unsigned long) == sizeof(char*). Hence,
- (unsigned long)(-1) should be the largest possible address. */
- unsigned long highest = (unsigned long)(-1);
- /* Pointers are signed on some brain-damaged systems, in
- which case we divide by two to get the maximum signed address. */
- if ((char*)highest < ptr)
- highest >>= 1;
- size = (char*)highest - ptr;
-#endif
- }
- _IO_setb(fp, ptr, ptr+size, 0);
-
- fp->_IO_write_base = ptr;
- fp->_IO_read_base = ptr;
- fp->_IO_read_ptr = ptr;
- if (pstart)
- {
- fp->_IO_write_ptr = pstart;
- fp->_IO_write_end = ptr+size;
- fp->_IO_read_end = pstart;
- }
- else
- {
- fp->_IO_write_ptr = ptr;
- fp->_IO_write_end = ptr;
- fp->_IO_read_end = ptr+size;
- }
- LEN(fp) = size;
- /* A null _allocate_buffer function flags the strfile as being static. */
- (((_IO_strfile*)(fp))->_s._allocate_buffer) = (_IO_alloc_type)0;
-}
-
-void
-_IO_str_init_readonly (fp, ptr, size)
- _IO_FILE *fp;
- const char *ptr;
- int size;
-{
- _IO_str_init_static (fp, (char*)ptr, size, NULL);
- fp->_IO_file_flags |= _IO_NO_WRITES;
-}
-
-int _IO_str_overflow (fp, c)
- register _IO_FILE* fp;
- int c;
-{
- int flush_only = c == EOF;
- _IO_size_t pos = fp->_IO_write_ptr - fp->_IO_write_base;
- _IO_size_t get_pos = fp->_IO_read_ptr - fp->_IO_read_base;
- if (fp->_flags & _IO_NO_WRITES)
- return flush_only ? 0 : EOF;
- if (pos > LEN(fp)) LEN(fp) = pos;
- if ((fp->_flags & _IO_TIED_PUT_GET) && !(fp->_flags & _IO_CURRENTLY_PUTTING))
- {
- pos = get_pos;
- fp->_flags |= _IO_CURRENTLY_PUTTING;
- get_pos = LEN(fp);
- }
- if (pos >= _IO_blen(fp) + flush_only)
- {
- if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */
- {
-#ifdef TODO
- if (indefinite size)
- {
- fp->_IO_buf_end += 512;
- }
- else
-#endif
- return EOF;
- }
- else
- {
- char *new_buf;
- _IO_size_t new_size = 2 * _IO_blen(fp);
- new_buf
- = (char*)(*((_IO_strfile*)fp)->_s._allocate_buffer)(new_size);
- if (new_buf == NULL)
- {
- /* __ferror(fp) = 1; */
- return EOF;
- }
- memcpy(new_buf, fp->_IO_buf_base, _IO_blen(fp));
-#if 0
- if (lenp == &LEN(fp)) /* use '\0'-filling */
- memset(new_buf + pos, 0, blen() - pos);
-#endif
- if (fp->_IO_buf_base)
- {
- (*((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base);
- /* Make sure _IO_setb won't try to delete _IO_buf_base. */
- fp->_IO_buf_base = NULL;
- }
- _IO_setb(fp, new_buf, new_buf + new_size, 1);
- fp->_IO_write_base = new_buf;
- }
- fp->_IO_write_end = fp->_IO_buf_end;
- }
-
- fp->_IO_write_ptr = fp->_IO_buf_base + pos;
-
- fp->_IO_read_base = fp->_IO_buf_base;
- fp->_IO_read_ptr = fp->_IO_buf_base + get_pos;;
- fp->_IO_read_end = fp->_IO_buf_base + LEN(fp);;
-
- if (!flush_only)
- *fp->_IO_write_ptr++ = (unsigned char) c;
- return c;
-}
-
-int
-_IO_str_underflow (fp)
- register _IO_FILE* fp;
-{
- _IO_size_t ppos = fp->_IO_write_ptr - fp->_IO_write_base;
- if (ppos > LEN(fp)) LEN(fp) = ppos;
- if ((fp->_flags & _IO_TIED_PUT_GET) && (fp->_flags & _IO_CURRENTLY_PUTTING))
- {
- fp->_flags &= ~_IO_CURRENTLY_PUTTING;
- fp->_IO_write_ptr = fp->_IO_write_end;
- }
- fp->_IO_read_end = fp->_IO_read_base + LEN(fp);
- if (fp->_IO_read_ptr < fp->_IO_read_end)
- return *fp->_IO_read_ptr;
- else
- return EOF;
-}
-
-_IO_ssize_t
-_IO_str_count (fp)
- register _IO_FILE *fp;
-{
- _IO_ssize_t put_len = fp->_IO_write_ptr - fp->_IO_write_base;
- if (put_len < ((_IO_strfile*)fp)->_s._len)
- put_len = ((_IO_strfile*)fp)->_s._len;
- return put_len;
-}
-
-_IO_pos_t
-_IO_str_seekoff(fp, offset, mode)
- register _IO_FILE *fp;
- _IO_off_t offset;
- _IO_seekflags mode;
-{
- _IO_ssize_t cur_size = _IO_str_count(fp);
- _IO_pos_t new_pos = EOF;
- int dir = mode & 3;
-
- /* Move the get pointer, if requested. */
- if (!(mode & _IO_seek_not_in))
- {
- switch (dir)
- {
- case _IO_seek_end:
- offset += cur_size;
- break;
- case _IO_seek_cur:
- offset += fp->_IO_read_ptr - fp->_IO_read_base;
- break;
- default: /* case _IO_seek_set: */
- break;
- }
- if (offset < 0 || (_IO_size_t)offset > cur_size)
- return EOF;
- fp->_IO_read_ptr = fp->_IO_read_base + offset;
- fp->_IO_read_end = fp->_IO_read_base + cur_size;
- new_pos = offset;
- }
-
- /* Move the put pointer, if requested. */
- if (!(mode & _IO_seek_not_out))
- {
- switch (dir)
- {
- case _IO_seek_end:
- offset += cur_size;
- break;
- case _IO_seek_cur:
- offset += fp->_IO_write_ptr - fp->_IO_write_base;
- break;
- default: /* case _IO_seek_set: */
- break;
- }
- if (offset < 0 || (_IO_size_t)offset > cur_size)
- return EOF;
- fp->_IO_write_ptr = fp->_IO_write_base + offset;
- new_pos = offset;
- }
- return new_pos;
-}
-
-int
-_IO_str_pbackfail(fp, c)
- register _IO_FILE *fp;
- int c;
-{
- if ((fp->_flags & _IO_NO_WRITES) && c != EOF)
- return EOF;
- return _IO_default_pbackfail(fp, c);
-}
-
-void
-_IO_str_finish(fp)
- register _IO_FILE* fp;
-{
- if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
- (((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base);
- fp->_IO_buf_base = NULL;
-
- _IO_default_finish(fp);
-}
-
-struct _IO_jump_t _IO_str_jumps = {
- _IO_str_overflow,
- _IO_str_underflow,
- _IO_default_xsputn,
- _IO_default_xsgetn,
- _IO_default_read,
- _IO_default_write,
- _IO_default_doallocate,
- _IO_str_pbackfail,
- _IO_default_setbuf,
- _IO_default_sync,
- _IO_str_finish,
- _IO_default_close,
- _IO_default_stat,
- _IO_default_seek,
- _IO_str_seekoff,
- _IO_default_seekpos,
- _IO_default_uflow
-};
diff --git a/gnu/lib/libg++/libio/strstream.cc b/gnu/lib/libg++/libio/strstream.cc
deleted file mode 100644
index e5917f0..0000000
--- a/gnu/lib/libg++/libio/strstream.cc
+++ /dev/null
@@ -1,133 +0,0 @@
-/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 Free Software Foundation
-
-This file is part of the GNU IO Library. This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* Written by Per Bothner (bothner@cygnus.com). */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-#include "iostreamP.h"
-#include "strstream.h"
-#include <string.h>
-
-static void* default_alloc(_IO_size_t size)
-{
- return (void*)new char[size];
-}
-
-static void default_free(void* ptr)
-{
- delete [] (char*)ptr;
-}
-
-/* Set to use the _IO_str_jump jumptable, for efficiency */
-
-#define SET_STR_JUMPS(STRBUF) \
- (STRBUF)->_jumps = &_IO_str_jumps,\
- (STRBUF)->_vtable() = builtinbuf_vtable;
-
-istrstream::istrstream(const char *cp, int n)
-{
- init(new strstreambuf(cp, n));
- SET_STR_JUMPS(_strbuf);
-}
-
-ostrstream::ostrstream()
-{
- init(new strstreambuf());
- SET_STR_JUMPS(_strbuf);
-}
-
-strstreambase::strstreambase(char *cp, int n, int mode)
-{
- char *pstart;
- if (mode == ios::app || mode == ios::ate)
- pstart = cp + strlen(cp);
- else
- pstart = cp;
- init(new strstreambuf(cp, n, pstart));
- SET_STR_JUMPS(_strbuf);
-}
-
-char *strstreambuf::str()
-{
- freeze(1);
- return base();
-}
-
-_IO_ssize_t strstreambuf::pcount () { return _IO_write_ptr - _IO_write_base; }
-
-int strstreambuf::overflow(int c /* = EOF */)
-{
- return _IO_str_overflow (this, c);
-}
-
-int strstreambuf::underflow()
-{
- return _IO_str_underflow(this);
-}
-
-
-void strstreambuf::init_dynamic(_IO_alloc_type alloc, _IO_free_type free,
- int initial_size)
-
-{
- _s._len = 0;
- if (initial_size < 16)
- initial_size = 16;
- _s._allocate_buffer = alloc ? alloc : default_alloc;
- _s._free_buffer = free ? free : default_free;
- char * buf = (char*)(*_s._allocate_buffer)(initial_size);
- setb(buf, buf + initial_size, 1);
- setp(buf, buf + initial_size);
- setg(buf, buf, buf);
-}
-
-void strstreambuf::init_static(char *ptr, int size, char *pstart)
-{
- _IO_str_init_static (this, ptr, size, pstart);
-}
-
-void strstreambuf::init_readonly (const char *ptr, int size)
-{
- _IO_str_init_readonly (this, ptr, size);
-}
-
-strstreambuf::~strstreambuf()
-{
- if (_IO_buf_base && !(_flags & _IO_USER_BUF))
- (_s._free_buffer)(_IO_buf_base);
- _IO_buf_base = NULL;
-}
-
-streampos strstreambuf::seekoff(streamoff off, _seek_dir dir,
- int mode /*=ios::in|ios::out*/)
-{
- return _IO_str_seekoff (this, off, convert_to_seekflags(dir, mode));
-}
-
-int strstreambuf::pbackfail(int c)
-{
- return _IO_str_pbackfail (this, c);
-}
diff --git a/gnu/lib/libg++/librx/rx.c b/gnu/lib/libg++/librx/rx.c
deleted file mode 100644
index 58add67..0000000
--- a/gnu/lib/libg++/librx/rx.c
+++ /dev/null
@@ -1,7163 +0,0 @@
-/* Copyright (C) 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of the librx library.
-
-Librx is free software; you can redistribute it and/or modify it under
-the terms of the GNU Library General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-Librx is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this software; see the file COPYING.LIB. If not,
-write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA
-02139, USA. */
-
-#define _RX_C_
-
-/* NOTE!!! AIX is so losing it requires this to be the first thing in the
- * file.
- * Do not put ANYTHING before it!
- */
-#if !defined (__GNUC__) && defined (_AIX)
- #pragma alloca
-#endif
-
-char rx_version_string[] = "GNU Rx version 0.06";
-
- /* ``Too hard!''
- * -- anon.
- */
-
-
-#include <stdio.h>
-#include <ctype.h>
-#ifndef isgraph
-#define isgraph(c) (isprint (c) && !isspace (c))
-#endif
-#ifndef isblank
-#define isblank(c) ((c) == ' ' || (c) == '\t')
-#endif
-
-#include <sys/types.h>
-#include <sys/param.h> /* for BSD */
-
-#undef MAX
-#undef MIN
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
-typedef char boolean;
-#define false 0
-#define true 1
-
-#ifndef RX_DECL
-#define RX_DECL static
-#endif
-
-#ifndef __GCC__
-#undef __inline__
-#define __inline__
-#endif
-
-/* Emacs already defines alloca, sometimes. */
-#ifndef alloca
-
-/* Make alloca work the best possible way. */
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not __GNUC__ */
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#else /* not __GNUC__ or HAVE_ALLOCA_H */
-#ifndef _AIX /* Already did AIX, up at the top. */
-char *alloca ();
-#endif /* not _AIX */
-#endif /* not HAVE_ALLOCA_H */
-#endif /* not __GNUC__ */
-
-#endif /* not alloca */
-
-/* Memory management and stuff for emacs. */
-
-#define CHARBITS 8
-#define remalloc(M, S) (M ? realloc (M, S) : malloc (S))
-
-
-/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we
- * use `alloca' instead of `malloc' for the backtracking stack.
- *
- * Emacs will die miserably if we don't do this.
- */
-
-#ifdef REGEX_MALLOC
-#define REGEX_ALLOCATE malloc
-#else /* not REGEX_MALLOC */
-#define REGEX_ALLOCATE alloca
-#endif /* not REGEX_MALLOC */
-
-#ifdef RX_WANT_RX_DEFS
-#define RX_DECL extern
-#define RX_DEF_QUAL
-#else
-#define RX_WANT_RX_DEFS
-#define RX_DECL static
-#define RX_DEF_QUAL static
-#endif
-#include "rx.h"
-#undef RX_DECL
-#define RX_DECL RX_DEF_QUAL
-
-
-#ifndef emacs
-
-#ifdef SYNTAX_TABLE
-extern char *re_syntax_table;
-#else /* not SYNTAX_TABLE */
-
-/* RX_DECL char re_syntax_table[CHAR_SET_SIZE]; */
-
-#ifdef __STDC__
-static void
-init_syntax_once (void)
-#else
-static void
-init_syntax_once ()
-#endif
-{
- register int c;
- static int done = 0;
-
- if (done)
- return;
-
- bzero (re_syntax_table, sizeof re_syntax_table);
-
- for (c = 'a'; c <= 'z'; c++)
- re_syntax_table[c] = Sword;
-
- for (c = 'A'; c <= 'Z'; c++)
- re_syntax_table[c] = Sword;
-
- for (c = '0'; c <= '9'; c++)
- re_syntax_table[c] = Sword;
-
- re_syntax_table['_'] = Sword;
-
- done = 1;
-}
-#endif /* not SYNTAX_TABLE */
-#endif /* not emacs */
-
-/* Compile with `-DRX_DEBUG' and use the following flags.
- *
- * Debugging flags:
- * rx_debug - print information as a regexp is compiled
- * rx_debug_trace - print information as a regexp is executed
- */
-
-#ifdef RX_DEBUG
-
-int rx_debug_compile = 0;
-int rx_debug_trace = 0;
-static struct re_pattern_buffer * dbug_rxb = 0;
-
-#ifdef __STDC__
-typedef void (*side_effect_printer) (struct rx *, void *, FILE *);
-#else
-typedef void (*side_effect_printer) ();
-#endif
-
-#ifdef __STDC__
-static void print_cset (struct rx *rx, rx_Bitset cset, FILE * fp);
-#else
-static void print_cset ();
-#endif
-
-#ifdef __STDC__
-static void
-print_rexp (struct rx *rx,
- struct rexp_node *node, int depth,
- side_effect_printer seprint, FILE * fp)
-#else
-static void
-print_rexp (rx, node, depth, seprint, fp)
- struct rx *rx;
- struct rexp_node *node;
- int depth;
- side_effect_printer seprint;
- FILE * fp;
-#endif
-{
- if (!node)
- return;
- else
- {
- switch (node->type)
- {
- case r_cset:
- {
- fprintf (fp, "%*s", depth, "");
- print_cset (rx, node->params.cset, fp);
- fputc ('\n', fp);
- break;
- }
-
- case r_opt:
- case r_star:
- fprintf (fp, "%*s%s\n", depth, "",
- node->type == r_opt ? "opt" : "star");
- print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp);
- break;
-
- case r_2phase_star:
- fprintf (fp, "%*s2phase star\n", depth, "");
- print_rexp (rx, node->params.pair.right, depth + 3, seprint, fp);
- print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp);
- break;
-
-
- case r_alternate:
- case r_concat:
- fprintf (fp, "%*s%s\n", depth, "",
- node->type == r_alternate ? "alt" : "concat");
- print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp);
- print_rexp (rx, node->params.pair.right, depth + 3, seprint, fp);
- break;
- case r_side_effect:
- fprintf (fp, "%*sSide effect: ", depth, "");
- seprint (rx, node->params.side_effect, fp);
- fputc ('\n', fp);
- }
- }
-}
-
-#ifdef __STDC__
-static void
-print_nfa (struct rx * rx,
- struct rx_nfa_state * n,
- side_effect_printer seprint, FILE * fp)
-#else
-static void
-print_nfa (rx, n, seprint, fp)
- struct rx * rx;
- struct rx_nfa_state * n;
- side_effect_printer seprint;
- FILE * fp;
-#endif
-{
- while (n)
- {
- struct rx_nfa_edge *e = n->edges;
- struct rx_possible_future *ec = n->futures;
- fprintf (fp, "node %d %s\n", n->id,
- n->is_final ? "final" : (n->is_start ? "start" : ""));
- while (e)
- {
- fprintf (fp, " edge to %d, ", e->dest->id);
- switch (e->type)
- {
- case ne_epsilon:
- fprintf (fp, "epsilon\n");
- break;
- case ne_side_effect:
- fprintf (fp, "side effect ");
- seprint (rx, e->params.side_effect, fp);
- fputc ('\n', fp);
- break;
- case ne_cset:
- fprintf (fp, "cset ");
- print_cset (rx, e->params.cset, fp);
- fputc ('\n', fp);
- break;
- }
- e = e->next;
- }
-
- while (ec)
- {
- int x;
- struct rx_nfa_state_set * s;
- struct rx_se_list * l;
- fprintf (fp, " eclosure to {");
- for (s = ec->destset; s; s = s->cdr)
- fprintf (fp, "%d ", s->car->id);
- fprintf (fp, "} (");
- for (l = ec->effects; l; l = l->cdr)
- {
- seprint (rx, l->car, fp);
- fputc (' ', fp);
- }
- fprintf (fp, ")\n");
- ec = ec->next;
- }
- n = n->next;
- }
-}
-
-static char * efnames [] =
-{
- "bogon",
- "re_se_try",
- "re_se_pushback",
- "re_se_push0",
- "re_se_pushpos",
- "re_se_chkpos",
- "re_se_poppos",
- "re_se_at_dot",
- "re_se_syntax",
- "re_se_not_syntax",
- "re_se_begbuf",
- "re_se_hat",
- "re_se_wordbeg",
- "re_se_wordbound",
- "re_se_notwordbound",
- "re_se_wordend",
- "re_se_endbuf",
- "re_se_dollar",
- "re_se_fail",
-};
-
-static char * efnames2[] =
-{
- "re_se_win"
- "re_se_lparen",
- "re_se_rparen",
- "re_se_backref",
- "re_se_iter",
- "re_se_end_iter",
- "re_se_tv"
-};
-
-static char * inx_names[] =
-{
- "rx_backtrack_point",
- "rx_do_side_effects",
- "rx_cache_miss",
- "rx_next_char",
- "rx_backtrack",
- "rx_error_inx",
- "rx_num_instructions"
-};
-
-
-#ifdef __STDC__
-static void
-re_seprint (struct rx * rx, void * effect, FILE * fp)
-#else
-static void
-re_seprint (rx, effect, fp)
- struct rx * rx;
- void * effect;
- FILE * fp;
-#endif
-{
- if ((int)effect < 0)
- fputs (efnames[-(int)effect], fp);
- else if (dbug_rxb)
- {
- struct re_se_params * p = &dbug_rxb->se_params[(int)effect];
- fprintf (fp, "%s(%d,%d)", efnames2[p->se], p->op1, p->op2);
- }
- else
- fprintf (fp, "[complex op # %d]", (int)effect);
-}
-
-
-/* These are so the regex.c regression tests will compile. */
-void
-print_compiled_pattern (rxb)
- struct re_pattern_buffer * rxb;
-{
-}
-
-void
-print_fastmap (fm)
- char * fm;
-{
-}
-
-#endif /* RX_DEBUG */
-
-
-
-/* This page: Bitsets. Completely unintersting. */
-
-#ifdef __STDC__
-RX_DECL int
-rx_bitset_is_equal (int size, rx_Bitset a, rx_Bitset b)
-#else
-RX_DECL int
-rx_bitset_is_equal (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
-#endif
-{
- int x;
- RX_subset s = b[0];
- b[0] = ~a[0];
-
- for (x = rx_bitset_numb_subsets(size) - 1; a[x] == b[x]; --x)
- ;
-
- b[0] = s;
- return !x && s == a[0];
-}
-
-#ifdef __STDC__
-RX_DECL int
-rx_bitset_is_subset (int size, rx_Bitset a, rx_Bitset b)
-#else
-RX_DECL int
-rx_bitset_is_subset (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
-#endif
-{
- int x = rx_bitset_numb_subsets(size) - 1;
- while (x-- && (a[x] & b[x]) == a[x]);
- return x == -1;
-}
-
-
-#ifdef __STDC__
-RX_DECL int
-rx_bitset_empty (int size, rx_Bitset set)
-#else
-RX_DECL int
-rx_bitset_empty (size, set)
- int size;
- rx_Bitset set;
-#endif
-{
- int x;
- RX_subset s = set[0];
- set[0] = 1;
- for (x = rx_bitset_numb_subsets(size) - 1; !set[x]; --x)
- ;
- set[0] = s;
- return !s;
-}
-
-#ifdef __STDC__
-RX_DECL void
-rx_bitset_null (int size, rx_Bitset b)
-#else
-RX_DECL void
-rx_bitset_null (size, b)
- int size;
- rx_Bitset b;
-#endif
-{
- bzero (b, rx_sizeof_bitset(size));
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_bitset_universe (int size, rx_Bitset b)
-#else
-RX_DECL void
-rx_bitset_universe (size, b)
- int size;
- rx_Bitset b;
-#endif
-{
- int x = rx_bitset_numb_subsets (size);
- while (x--)
- *b++ = ~(RX_subset)0;
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_bitset_complement (int size, rx_Bitset b)
-#else
-RX_DECL void
-rx_bitset_complement (size, b)
- int size;
- rx_Bitset b;
-#endif
-{
- int x = rx_bitset_numb_subsets (size);
- while (x--)
- {
- *b = ~*b;
- ++b;
- }
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_bitset_assign (int size, rx_Bitset a, rx_Bitset b)
-#else
-RX_DECL void
-rx_bitset_assign (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
-#endif
-{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] = b[x];
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_bitset_union (int size, rx_Bitset a, rx_Bitset b)
-#else
-RX_DECL void
-rx_bitset_union (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
-#endif
-{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] |= b[x];
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_bitset_intersection (int size,
- rx_Bitset a, rx_Bitset b)
-#else
-RX_DECL void
-rx_bitset_intersection (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
-#endif
-{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] &= b[x];
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_bitset_difference (int size, rx_Bitset a, rx_Bitset b)
-#else
-RX_DECL void
-rx_bitset_difference (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
-#endif
-{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] &= ~ b[x];
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_bitset_revdifference (int size,
- rx_Bitset a, rx_Bitset b)
-#else
-RX_DECL void
-rx_bitset_revdifference (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
-#endif
-{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] = ~a[x] & b[x];
-}
-
-#ifdef __STDC__
-RX_DECL void
-rx_bitset_xor (int size, rx_Bitset a, rx_Bitset b)
-#else
-RX_DECL void
-rx_bitset_xor (size, a, b)
- int size;
- rx_Bitset a;
- rx_Bitset b;
-#endif
-{
- int x;
- for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x)
- a[x] ^= b[x];
-}
-
-
-#ifdef __STDC__
-RX_DECL unsigned long
-rx_bitset_hash (int size, rx_Bitset b)
-#else
-RX_DECL unsigned long
-rx_bitset_hash (size, b)
- int size;
- rx_Bitset b;
-#endif
-{
- int x;
- unsigned long hash = (unsigned long)rx_bitset_hash;
-
- for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)
- hash ^= rx_bitset_subset_val(b, x);
-
- return hash;
-}
-
-
-RX_DECL RX_subset rx_subset_singletons [RX_subset_bits] =
-{
- 0x1,
- 0x2,
- 0x4,
- 0x8,
- 0x10,
- 0x20,
- 0x40,
- 0x80,
- 0x100,
- 0x200,
- 0x400,
- 0x800,
- 0x1000,
- 0x2000,
- 0x4000,
- 0x8000,
- 0x10000,
- 0x20000,
- 0x40000,
- 0x80000,
- 0x100000,
- 0x200000,
- 0x400000,
- 0x800000,
- 0x1000000,
- 0x2000000,
- 0x4000000,
- 0x8000000,
- 0x10000000,
- 0x20000000,
- 0x40000000,
- 0x80000000
-};
-
-#ifdef RX_DEBUG
-
-#ifdef __STDC__
-static void
-print_cset (struct rx *rx, rx_Bitset cset, FILE * fp)
-#else
-static void
-print_cset (rx, cset, fp)
- struct rx *rx;
- rx_Bitset cset;
- FILE * fp;
-#endif
-{
- int x;
- fputc ('[', fp);
- for (x = 0; x < rx->local_cset_size; ++x)
- if (isprint(x) && RX_bitset_member (cset, x))
- fputc (x, fp);
- fputc (']', fp);
-}
-
-#endif /* RX_DEBUG */
-
-
-
-static unsigned long rx_hash_masks[4] =
-{
- 0x12488421,
- 0x96699669,
- 0xbe7dd7eb,
- 0xffffffff
-};
-
-
-/* Hash tables */
-#ifdef __STDC__
-RX_DECL struct rx_hash_item *
-rx_hash_find (struct rx_hash * table,
- unsigned long hash,
- void * value,
- struct rx_hash_rules * rules)
-#else
-RX_DECL struct rx_hash_item *
-rx_hash_find (table, hash, value, rules)
- struct rx_hash * table;
- unsigned long hash;
- void * value;
- struct rx_hash_rules * rules;
-#endif
-{
- rx_hash_eq eq = rules->eq;
- int maskc = 0;
- long mask = rx_hash_masks [0];
- int bucket = (hash & mask) % 13;
-
- while (table->children [bucket])
- {
- table = table->children [bucket];
- ++maskc;
- mask = rx_hash_masks[maskc];
- bucket = (hash & mask) % 13;
- }
-
- {
- struct rx_hash_item * it = table->buckets[bucket];
- while (it)
- if (eq (it->data, value))
- return it;
- else
- it = it->next_same_hash;
- }
-
- return 0;
-}
-
-
-#ifdef __STDC__
-RX_DECL struct rx_hash_item *
-rx_hash_store (struct rx_hash * table,
- unsigned long hash,
- void * value,
- struct rx_hash_rules * rules)
-#else
-RX_DECL struct rx_hash_item *
-rx_hash_store (table, hash, value, rules)
- struct rx_hash * table;
- unsigned long hash;
- void * value;
- struct rx_hash_rules * rules;
-#endif
-{
- rx_hash_eq eq = rules->eq;
- int maskc = 0;
- long mask = rx_hash_masks[0];
- int bucket = (hash & mask) % 13;
- int depth = 0;
-
- while (table->children [bucket])
- {
- table = table->children [bucket];
- ++maskc;
- mask = rx_hash_masks[maskc];
- bucket = (hash & mask) % 13;
- ++depth;
- }
-
- {
- struct rx_hash_item * it = table->buckets[bucket];
- while (it)
- if (eq (it->data, value))
- return it;
- else
- it = it->next_same_hash;
- }
-
- {
- if ( (depth < 3)
- && (table->bucket_size [bucket] >= 4))
- {
- struct rx_hash * newtab = ((struct rx_hash *)
- rules->hash_alloc (rules));
- if (!newtab)
- goto add_to_bucket;
- bzero (newtab, sizeof (*newtab));
- newtab->parent = table;
- {
- struct rx_hash_item * them = table->buckets[bucket];
- unsigned long newmask = rx_hash_masks[maskc + 1];
- while (them)
- {
- struct rx_hash_item * save = them->next_same_hash;
- int new_buck = (them->hash & newmask) % 13;
- them->next_same_hash = newtab->buckets[new_buck];
- newtab->buckets[new_buck] = them;
- them->table = newtab;
- them = save;
- ++newtab->bucket_size[new_buck];
- ++newtab->refs;
- }
- table->refs = (table->refs - table->bucket_size[bucket] + 1);
- table->bucket_size[bucket] = 0;
- table->buckets[bucket] = 0;
- table->children[bucket] = newtab;
- table = newtab;
- bucket = (hash & newmask) % 13;
- }
- }
- }
- add_to_bucket:
- {
- struct rx_hash_item * it = ((struct rx_hash_item *)
- rules->hash_item_alloc (rules, value));
- if (!it)
- return 0;
- it->hash = hash;
- it->table = table;
- /* DATA and BINDING are to be set in hash_item_alloc */
- it->next_same_hash = table->buckets [bucket];
- table->buckets[bucket] = it;
- ++table->bucket_size [bucket];
- ++table->refs;
- return it;
- }
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_hash_free (struct rx_hash_item * it, struct rx_hash_rules * rules)
-#else
-RX_DECL void
-rx_hash_free (it, rules)
- struct rx_hash_item * it;
- struct rx_hash_rules * rules;
-#endif
-{
- if (it)
- {
- struct rx_hash * table = it->table;
- unsigned long hash = it->hash;
- int depth = (table->parent
- ? (table->parent->parent
- ? (table->parent->parent->parent
- ? 3
- : 2)
- : 1)
- : 0);
- int bucket = (hash & rx_hash_masks [depth]) % 13;
- struct rx_hash_item ** pos = &table->buckets [bucket];
-
- while (*pos != it)
- pos = &(*pos)->next_same_hash;
- *pos = it->next_same_hash;
- rules->free_hash_item (it, rules);
- --table->bucket_size[bucket];
- --table->refs;
- while (!table->refs && depth)
- {
- struct rx_hash * save = table;
- table = table->parent;
- --depth;
- bucket = (hash & rx_hash_masks [depth]) % 13;
- --table->refs;
- table->children[bucket] = 0;
- rules->free_hash (save, rules);
- }
- }
-}
-
-#ifdef __STDC__
-RX_DECL void
-rx_free_hash_table (struct rx_hash * tab, rx_hash_freefn freefn,
- struct rx_hash_rules * rules)
-#else
-RX_DECL void
-rx_free_hash_table (tab, freefn, rules)
- struct rx_hash * tab;
- rx_hash_freefn freefn;
- struct rx_hash_rules * rules;
-#endif
-{
- int x;
-
- for (x = 0; x < 13; ++x)
- if (tab->children[x])
- {
- rx_free_hash_table (tab->children[x], freefn, rules);
- rules->free_hash (tab->children[x], rules);
- }
- else
- {
- struct rx_hash_item * them = tab->buckets[x];
- while (them)
- {
- struct rx_hash_item * that = them;
- them = that->next_same_hash;
- freefn (that);
- rules->free_hash_item (that, rules);
- }
- }
-}
-
-
-
-/* Utilities for manipulating bitset represntations of characters sets. */
-
-#ifdef __STDC__
-RX_DECL rx_Bitset
-rx_cset (struct rx *rx)
-#else
-RX_DECL rx_Bitset
-rx_cset (rx)
- struct rx *rx;
-#endif
-{
- rx_Bitset b = (rx_Bitset) malloc (rx_sizeof_bitset (rx->local_cset_size));
- if (b)
- rx_bitset_null (rx->local_cset_size, b);
- return b;
-}
-
-
-#ifdef __STDC__
-RX_DECL rx_Bitset
-rx_copy_cset (struct rx *rx, rx_Bitset a)
-#else
-RX_DECL rx_Bitset
-rx_copy_cset (rx, a)
- struct rx *rx;
- rx_Bitset a;
-#endif
-{
- rx_Bitset cs = rx_cset (rx);
-
- if (cs)
- rx_bitset_union (rx->local_cset_size, cs, a);
-
- return cs;
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_free_cset (struct rx * rx, rx_Bitset c)
-#else
-RX_DECL void
-rx_free_cset (rx, c)
- struct rx * rx;
- rx_Bitset c;
-#endif
-{
- if (c)
- free ((char *)c);
-}
-
-
-/* Hash table memory allocation policy for the regexp compiler */
-
-#ifdef __STDC__
-static struct rx_hash *
-compiler_hash_alloc (struct rx_hash_rules * rules)
-#else
-static struct rx_hash *
-compiler_hash_alloc (rules)
- struct rx_hash_rules * rules;
-#endif
-{
- return (struct rx_hash *)malloc (sizeof (struct rx_hash));
-}
-
-
-#ifdef __STDC__
-static struct rx_hash_item *
-compiler_hash_item_alloc (struct rx_hash_rules * rules, void * value)
-#else
-static struct rx_hash_item *
-compiler_hash_item_alloc (rules, value)
- struct rx_hash_rules * rules;
- void * value;
-#endif
-{
- struct rx_hash_item * it;
- it = (struct rx_hash_item *)malloc (sizeof (*it));
- if (it)
- {
- it->data = value;
- it->binding = 0;
- }
- return it;
-}
-
-
-#ifdef __STDC__
-static void
-compiler_free_hash (struct rx_hash * tab,
- struct rx_hash_rules * rules)
-#else
-static void
-compiler_free_hash (tab, rules)
- struct rx_hash * tab;
- struct rx_hash_rules * rules;
-#endif
-{
- free ((char *)tab);
-}
-
-
-#ifdef __STDC__
-static void
-compiler_free_hash_item (struct rx_hash_item * item,
- struct rx_hash_rules * rules)
-#else
-static void
-compiler_free_hash_item (item, rules)
- struct rx_hash_item * item;
- struct rx_hash_rules * rules;
-#endif
-{
- free ((char *)item);
-}
-
-
-/* This page: REXP_NODE (expression tree) structures. */
-
-#ifdef __STDC__
-RX_DECL struct rexp_node *
-rexp_node (struct rx *rx,
- enum rexp_node_type type)
-#else
-RX_DECL struct rexp_node *
-rexp_node (rx, type)
- struct rx *rx;
- enum rexp_node_type type;
-#endif
-{
- struct rexp_node *n;
-
- n = (struct rexp_node *)malloc (sizeof (*n));
- bzero (n, sizeof (*n));
- if (n)
- n->type = type;
- return n;
-}
-
-
-/* free_rexp_node assumes that the bitset passed to rx_mk_r_cset
- * can be freed using rx_free_cset.
- */
-#ifdef __STDC__
-RX_DECL struct rexp_node *
-rx_mk_r_cset (struct rx * rx,
- rx_Bitset b)
-#else
-RX_DECL struct rexp_node *
-rx_mk_r_cset (rx, b)
- struct rx * rx;
- rx_Bitset b;
-#endif
-{
- struct rexp_node * n = rexp_node (rx, r_cset);
- if (n)
- n->params.cset = b;
- return n;
-}
-
-
-#ifdef __STDC__
-RX_DECL struct rexp_node *
-rx_mk_r_concat (struct rx * rx,
- struct rexp_node * a,
- struct rexp_node * b)
-#else
-RX_DECL struct rexp_node *
-rx_mk_r_concat (rx, a, b)
- struct rx * rx;
- struct rexp_node * a;
- struct rexp_node * b;
-#endif
-{
- struct rexp_node * n = rexp_node (rx, r_concat);
- if (n)
- {
- n->params.pair.left = a;
- n->params.pair.right = b;
- }
- return n;
-}
-
-
-#ifdef __STDC__
-RX_DECL struct rexp_node *
-rx_mk_r_alternate (struct rx * rx,
- struct rexp_node * a,
- struct rexp_node * b)
-#else
-RX_DECL struct rexp_node *
-rx_mk_r_alternate (rx, a, b)
- struct rx * rx;
- struct rexp_node * a;
- struct rexp_node * b;
-#endif
-{
- struct rexp_node * n = rexp_node (rx, r_alternate);
- if (n)
- {
- n->params.pair.left = a;
- n->params.pair.right = b;
- }
- return n;
-}
-
-
-#ifdef __STDC__
-RX_DECL struct rexp_node *
-rx_mk_r_opt (struct rx * rx,
- struct rexp_node * a)
-#else
-RX_DECL struct rexp_node *
-rx_mk_r_opt (rx, a)
- struct rx * rx;
- struct rexp_node * a;
-#endif
-{
- struct rexp_node * n = rexp_node (rx, r_opt);
- if (n)
- {
- n->params.pair.left = a;
- n->params.pair.right = 0;
- }
- return n;
-}
-
-
-#ifdef __STDC__
-RX_DECL struct rexp_node *
-rx_mk_r_star (struct rx * rx,
- struct rexp_node * a)
-#else
-RX_DECL struct rexp_node *
-rx_mk_r_star (rx, a)
- struct rx * rx;
- struct rexp_node * a;
-#endif
-{
- struct rexp_node * n = rexp_node (rx, r_star);
- if (n)
- {
- n->params.pair.left = a;
- n->params.pair.right = 0;
- }
- return n;
-}
-
-
-#ifdef __STDC__
-RX_DECL struct rexp_node *
-rx_mk_r_2phase_star (struct rx * rx,
- struct rexp_node * a,
- struct rexp_node * b)
-#else
-RX_DECL struct rexp_node *
-rx_mk_r_2phase_star (rx, a, b)
- struct rx * rx;
- struct rexp_node * a;
- struct rexp_node * b;
-#endif
-{
- struct rexp_node * n = rexp_node (rx, r_2phase_star);
- if (n)
- {
- n->params.pair.left = a;
- n->params.pair.right = b;
- }
- return n;
-}
-
-
-#ifdef __STDC__
-RX_DECL struct rexp_node *
-rx_mk_r_side_effect (struct rx * rx,
- rx_side_effect a)
-#else
-RX_DECL struct rexp_node *
-rx_mk_r_side_effect (rx, a)
- struct rx * rx;
- rx_side_effect a;
-#endif
-{
- struct rexp_node * n = rexp_node (rx, r_side_effect);
- if (n)
- {
- n->params.side_effect = a;
- n->params.pair.right = 0;
- }
- return n;
-}
-
-
-#ifdef __STDC__
-RX_DECL struct rexp_node *
-rx_mk_r_data (struct rx * rx,
- void * a)
-#else
-RX_DECL struct rexp_node *
-rx_mk_r_data (rx, a)
- struct rx * rx;
- void * a;
-#endif
-{
- struct rexp_node * n = rexp_node (rx, r_data);
- if (n)
- {
- n->params.pair.left = a;
- n->params.pair.right = 0;
- }
- return n;
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_free_rexp (struct rx * rx, struct rexp_node * node)
-#else
-RX_DECL void
-rx_free_rexp (rx, node)
- struct rx * rx;
- struct rexp_node * node;
-#endif
-{
- if (node)
- {
- switch (node->type)
- {
- case r_cset:
- if (node->params.cset)
- rx_free_cset (rx, node->params.cset);
-
- case r_side_effect:
- break;
-
- case r_concat:
- case r_alternate:
- case r_2phase_star:
- case r_opt:
- case r_star:
- rx_free_rexp (rx, node->params.pair.left);
- rx_free_rexp (rx, node->params.pair.right);
- break;
-
- case r_data:
- /* This shouldn't occur. */
- break;
- }
- free ((char *)node);
- }
-}
-
-
-#ifdef __STDC__
-RX_DECL struct rexp_node *
-rx_copy_rexp (struct rx *rx,
- struct rexp_node *node)
-#else
-RX_DECL struct rexp_node *
-rx_copy_rexp (rx, node)
- struct rx *rx;
- struct rexp_node *node;
-#endif
-{
- if (!node)
- return 0;
- else
- {
- struct rexp_node *n = rexp_node (rx, node->type);
- if (!n)
- return 0;
- switch (node->type)
- {
- case r_cset:
- n->params.cset = rx_copy_cset (rx, node->params.cset);
- if (!n->params.cset)
- {
- rx_free_rexp (rx, n);
- return 0;
- }
- break;
-
- case r_side_effect:
- n->params.side_effect = node->params.side_effect;
- break;
-
- case r_concat:
- case r_alternate:
- case r_opt:
- case r_2phase_star:
- case r_star:
- n->params.pair.left =
- rx_copy_rexp (rx, node->params.pair.left);
- n->params.pair.right =
- rx_copy_rexp (rx, node->params.pair.right);
- if ( (node->params.pair.left && !n->params.pair.left)
- || (node->params.pair.right && !n->params.pair.right))
- {
- rx_free_rexp (rx, n);
- return 0;
- }
- break;
- case r_data:
- /* shouldn't happen */
- break;
- }
- return n;
- }
-}
-
-
-
-/* This page: functions to build and destroy graphs that describe nfa's */
-
-/* Constructs a new nfa node. */
-#ifdef __STDC__
-RX_DECL struct rx_nfa_state *
-rx_nfa_state (struct rx *rx)
-#else
-RX_DECL struct rx_nfa_state *
-rx_nfa_state (rx)
- struct rx *rx;
-#endif
-{
- struct rx_nfa_state * n = (struct rx_nfa_state *)malloc (sizeof (*n));
- if (!n)
- return 0;
- bzero (n, sizeof (*n));
- n->next = rx->nfa_states;
- rx->nfa_states = n;
- return n;
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_free_nfa_state (struct rx_nfa_state * n)
-#else
-RX_DECL void
-rx_free_nfa_state (n)
- struct rx_nfa_state * n;
-#endif
-{
- free ((char *)n);
-}
-
-
-/* This looks up an nfa node, given a numeric id. Numeric id's are
- * assigned after the nfa has been built.
- */
-#ifdef __STDC__
-RX_DECL struct rx_nfa_state *
-rx_id_to_nfa_state (struct rx * rx,
- int id)
-#else
-RX_DECL struct rx_nfa_state *
-rx_id_to_nfa_state (rx, id)
- struct rx * rx;
- int id;
-#endif
-{
- struct rx_nfa_state * n;
- for (n = rx->nfa_states; n; n = n->next)
- if (n->id == id)
- return n;
- return 0;
-}
-
-
-/* This adds an edge between two nodes, but doesn't initialize the
- * edge label.
- */
-
-#ifdef __STDC__
-RX_DECL struct rx_nfa_edge *
-rx_nfa_edge (struct rx *rx,
- enum rx_nfa_etype type,
- struct rx_nfa_state *start,
- struct rx_nfa_state *dest)
-#else
-RX_DECL struct rx_nfa_edge *
-rx_nfa_edge (rx, type, start, dest)
- struct rx *rx;
- enum rx_nfa_etype type;
- struct rx_nfa_state *start;
- struct rx_nfa_state *dest;
-#endif
-{
- struct rx_nfa_edge *e;
- e = (struct rx_nfa_edge *)malloc (sizeof (*e));
- if (!e)
- return 0;
- e->next = start->edges;
- start->edges = e;
- e->type = type;
- e->dest = dest;
- return e;
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_free_nfa_edge (struct rx_nfa_edge * e)
-#else
-RX_DECL void
-rx_free_nfa_edge (e)
- struct rx_nfa_edge * e;
-#endif
-{
- free ((char *)e);
-}
-
-
-/* This constructs a POSSIBLE_FUTURE, which is a kind epsilon-closure
- * of an NFA. These are added to an nfa automaticly by eclose_nfa.
- */
-
-#ifdef __STDC__
-static struct rx_possible_future *
-rx_possible_future (struct rx * rx,
- struct rx_se_list * effects)
-#else
-static struct rx_possible_future *
-rx_possible_future (rx, effects)
- struct rx * rx;
- struct rx_se_list * effects;
-#endif
-{
- struct rx_possible_future *ec;
- ec = (struct rx_possible_future *) malloc (sizeof (*ec));
- if (!ec)
- return 0;
- ec->destset = 0;
- ec->next = 0;
- ec->effects = effects;
- return ec;
-}
-
-
-#ifdef __STDC__
-static void
-rx_free_possible_future (struct rx_possible_future * pf)
-#else
-static void
-rx_free_possible_future (pf)
- struct rx_possible_future * pf;
-#endif
-{
- free ((char *)pf);
-}
-
-
-#ifdef __STDC__
-RX_DECL void
-rx_free_nfa (struct rx *rx)
-#else
-RX_DECL void
-rx_free_nfa (rx)
- struct rx *rx;
-#endif
-{
- while (rx->nfa_states)
- {
- while (rx->nfa_states->edges)
- {
- switch (rx->nfa_states->edges->type)
- {
- case ne_cset:
- rx_free_cset (rx, rx->nfa_states->edges->params.cset);
- break;
- default:
- break;
- }
- {
- struct rx_nfa_edge * e;
- e = rx->nfa_states->edges;
- rx->nfa_states->edges = rx->nfa_states->edges->next;
- rx_free_nfa_edge (e);
- }
- } /* while (rx->nfa_states->edges) */
- {
- /* Iterate over the partial epsilon closures of rx->nfa_states */
- struct rx_possible_future * pf = rx->nfa_states->futures;
- while (pf)
- {
- struct rx_possible_future * pft = pf;
- pf = pf->next;
- rx_free_possible_future (pft);
- }
- }
- {
- struct rx_nfa_state *n;
- n = rx->nfa_states;
- rx->nfa_states = rx->nfa_states->next;
- rx_free_nfa_state (n);
- }
- }
-}
-
-
-
-/* This page: translating a pattern expression into an nfa and doing the
- * static part of the nfa->super-nfa translation.
- */
-
-/* This is the thompson regexp->nfa algorithm.
- * It is modified to allow for `side-effect epsilons.' Those are
- * edges that are taken whenever a similar epsilon edge would be,
- * but which imply that some side effect occurs when the edge
- * is taken.
- *
- * Side effects are used to model parts of the pattern langauge
- * that are not regular (in the formal sense).
- */
-
-#ifdef __STDC__
-RX_DECL int
-rx_build_nfa (struct rx *rx,
- struct rexp_node *rexp,
- struct rx_nfa_state **start,
- struct rx_nfa_state **end)
-#else
-RX_DECL int
-rx_build_nfa (rx, rexp, start, end)
- struct rx *rx;
- struct rexp_node *rexp;
- struct rx_nfa_state **start;
- struct rx_nfa_state **end;
-#endif
-{
- struct rx_nfa_edge *edge;
-
- /* Start & end nodes may have been allocated by the caller. */
- *start = *start ? *start : rx_nfa_state (rx);
-
- if (!*start)
- return 0;
-
- if (!rexp)
- {
- *end = *start;
- return 1;
- }
-
- *end = *end ? *end : rx_nfa_state (rx);
-
- if (!*end)
- {
- rx_free_nfa_state (*start);
- return 0;
- }
-
- switch (rexp->type)
- {
- case r_data:
- return 0;
-
- case r_cset:
- edge = rx_nfa_edge (rx, ne_cset, *start, *end);
- if (!edge)
- return 0;
- edge->params.cset = rx_copy_cset (rx, rexp->params.cset);
- if (!edge->params.cset)
- {
- rx_free_nfa_edge (edge);
- return 0;
- }
- return 1;
-
- case r_opt:
- return (rx_build_nfa (rx, rexp->params.pair.left, start, end)
- && rx_nfa_edge (rx, ne_epsilon, *start, *end));
-
- case r_star:
- {
- struct rx_nfa_state * star_start = 0;
- struct rx_nfa_state * star_end = 0;
- return (rx_build_nfa (rx, rexp->params.pair.left,
- &star_start, &star_end)
- && star_start
- && star_end
- && rx_nfa_edge (rx, ne_epsilon, star_start, star_end)
- && rx_nfa_edge (rx, ne_epsilon, *start, star_start)
- && rx_nfa_edge (rx, ne_epsilon, star_end, *end)
-
- && rx_nfa_edge (rx, ne_epsilon, star_end, star_start));
- }
-
- case r_2phase_star:
- {
- struct rx_nfa_state * star_start = 0;
- struct rx_nfa_state * star_end = 0;
- struct rx_nfa_state * loop_exp_start = 0;
- struct rx_nfa_state * loop_exp_end = 0;
-
- return (rx_build_nfa (rx, rexp->params.pair.left,
- &star_start, &star_end)
- && rx_build_nfa (rx, rexp->params.pair.right,
- &loop_exp_start, &loop_exp_end)
- && star_start
- && star_end
- && loop_exp_end
- && loop_exp_start
- && rx_nfa_edge (rx, ne_epsilon, star_start, *end)
- && rx_nfa_edge (rx, ne_epsilon, *start, star_start)
- && rx_nfa_edge (rx, ne_epsilon, star_end, *end)
-
- && rx_nfa_edge (rx, ne_epsilon, star_end, loop_exp_start)
- && rx_nfa_edge (rx, ne_epsilon, loop_exp_end, star_start));
- }
-
-
- case r_concat:
- {
- struct rx_nfa_state *shared = 0;
- return
- (rx_build_nfa (rx, rexp->params.pair.left, start, &shared)
- && rx_build_nfa (rx, rexp->params.pair.right, &shared, end));
- }
-
- case r_alternate:
- {
- struct rx_nfa_state *ls = 0;
- struct rx_nfa_state *le = 0;
- struct rx_nfa_state *rs = 0;
- struct rx_nfa_state *re = 0;
- return (rx_build_nfa (rx, rexp->params.pair.left, &ls, &le)
- && rx_build_nfa (rx, rexp->params.pair.right, &rs, &re)
- && rx_nfa_edge (rx, ne_epsilon, *start, ls)
- && rx_nfa_edge (rx, ne_epsilon, *start, rs)
- && rx_nfa_edge (rx, ne_epsilon, le, *end)
- && rx_nfa_edge (rx, ne_epsilon, re, *end));
- }
-
- case r_side_effect:
- edge = rx_nfa_edge (rx, ne_side_effect, *start, *end);
- if (!edge)
- return 0;
- edge->params.side_effect = rexp->params.side_effect;
- return 1;
- }
-
- /* this should never happen */
- return 0;
-}
-
-
-/* RX_NAME_NFA_STATES identifies all nodes with outgoing non-epsilon
- * transitions. Only these nodes can occur in super-states.
- * All nodes are given an integer id.
- * The id is non-negative if the node has non-epsilon out-transitions, negative
- * otherwise (this is because we want the non-negative ids to be used as
- * array indexes in a few places).
- */
-
-#ifdef __STDC__
-RX_DECL void
-rx_name_nfa_states (struct rx *rx)
-#else
-RX_DECL void
-rx_name_nfa_states (rx)
- struct rx *rx;
-#endif
-{
- struct rx_nfa_state *n = rx->nfa_states;
-
- rx->nodec = 0;
- rx->epsnodec = -1;
-
- while (n)
- {
- struct rx_nfa_edge *e = n->edges;
-
- if (n->is_start)
- n->eclosure_needed = 1;
-
- while (e)
- {
- switch (e->type)
- {
- case ne_epsilon:
- case ne_side_effect:
- break;
-
- case ne_cset:
- n->id = rx->nodec++;
- {
- struct rx_nfa_edge *from_n = n->edges;
- while (from_n)
- {
- from_n->dest->eclosure_needed = 1;
- from_n = from_n->next;
- }
- }
- goto cont;
- }
- e = e->next;
- }
- n->id = rx->epsnodec--;
- cont:
- n = n->next;
- }
- rx->epsnodec = -rx->epsnodec;
-}
-
-
-/* This page: data structures for the static part of the nfa->supernfa
- * translation.
- *
- * There are side effect lists -- lists of side effects occuring
- * along an uninterrupted, acyclic path of side-effect epsilon edges.
- * Such paths are collapsed to single edges in the course of computing
- * epsilon closures. Such single edges are labled with a list of all
- * the side effects entailed in crossing them. Like lists of side
- * effects are made == by the constructors below.
- *
- * There are also nfa state sets. These are used to hold a list of all
- * states reachable from a starting state for a given type of transition
- * and side effect list. These are also hash-consed.
- */
-
-/* The next several functions compare, construct, etc. lists of side
- * effects. See ECLOSE_NFA (below) for details.
- */
-
-/* Ordering of rx_se_list
- * (-1, 0, 1 return value convention).
- */
-
-#ifdef __STDC__
-static int
-se_list_cmp (void * va, void * vb)
-#else
-static int
-se_list_cmp (va, vb)
- void * va;
- void * vb;
-#endif
-{
- struct rx_se_list * a = (struct rx_se_list *)va;
- struct rx_se_list * b = (struct rx_se_list *)vb;
-
- return ((va == vb)
- ? 0
- : (!va
- ? -1
- : (!vb
- ? 1
- : ((long)a->car < (long)b->car
- ? 1
- : ((long)a->car > (long)b->car
- ? -1
- : se_list_cmp ((void *)a->cdr, (void *)b->cdr))))));
-}
-
-
-#ifdef __STDC__
-static int
-se_list_equal (void * va, void * vb)
-#else
-static int
-se_list_equal (va, vb)
- void * va;
- void * vb;
-#endif
-{
- return !(se_list_cmp (va, vb));
-}
-
-static struct rx_hash_rules se_list_hash_rules =
-{
- se_list_equal,
- compiler_hash_alloc,
- compiler_free_hash,
- compiler_hash_item_alloc,
- compiler_free_hash_item
-};
-
-
-#ifdef __STDC__
-static struct rx_se_list *
-side_effect_cons (struct rx * rx,
- void * se, struct rx_se_list * list)
-#else
-static struct rx_se_list *
-side_effect_cons (rx, se, list)
- struct rx * rx;
- void * se;
- struct rx_se_list * list;
-#endif
-{
- struct rx_se_list * l;
- l = ((struct rx_se_list *) malloc (sizeof (*l)));
- if (!l)
- return 0;
- l->car = se;
- l->cdr = list;
- return l;
-}
-
-
-#ifdef __STDC__
-static struct rx_se_list *
-hash_cons_se_prog (struct rx * rx,
- struct rx_hash * memo,
- void * car, struct rx_se_list * cdr)
-#else
-static struct rx_se_list *
-hash_cons_se_prog (rx, memo, car, cdr)
- struct rx * rx;
- struct rx_hash * memo;
- void * car;
- struct rx_se_list * cdr;
-#endif
-{
- long hash = (long)car ^ (long)cdr;
- struct rx_se_list template;
-
- template.car = car;
- template.cdr = cdr;
- {
- struct rx_hash_item * it = rx_hash_store (memo, hash,
- (void *)&template,
- &se_list_hash_rules);
- if (!it)
- return 0;
- if (it->data == (void *)&template)
- {
- struct rx_se_list * consed;
- consed = (struct rx_se_list *) malloc (sizeof (*consed));
- *consed = template;
- it->data = (void *)consed;
- }
- return (struct rx_se_list *)it->data;
- }
-}
-
-
-#ifdef __STDC__
-static struct rx_se_list *
-hash_se_prog (struct rx * rx, struct rx_hash * memo, struct rx_se_list * prog)
-#else
-static struct rx_se_list *
-hash_se_prog (rx, memo, prog)
- struct rx * rx;
- struct rx_hash * memo;
- struct rx_se_list * prog;
-#endif
-{
- struct rx_se_list * answer = 0;
- while (prog)
- {
- answer = hash_cons_se_prog (rx, memo, prog->car, answer);
- if (!answer)
- return 0;
- prog = prog->cdr;
- }
- return answer;
-}
-
-#ifdef __STDC__
-static int
-nfa_set_cmp (void * va, void * vb)
-#else
-static int
-nfa_set_cmp (va, vb)
- void * va;
- void * vb;
-#endif
-{
- struct rx_nfa_state_set * a = (struct rx_nfa_state_set *)va;
- struct rx_nfa_state_set * b = (struct rx_nfa_state_set *)vb;
-
- return ((va == vb)
- ? 0
- : (!va
- ? -1
- : (!vb
- ? 1
- : (a->car->id < b->car->id
- ? 1
- : (a->car->id > b->car->id
- ? -1
- : nfa_set_cmp ((void *)a->cdr, (void *)b->cdr))))));
-}
-
-#ifdef __STDC__
-static int
-nfa_set_equal (void * va, void * vb)
-#else
-static int
-nfa_set_equal (va, vb)
- void * va;
- void * vb;
-#endif
-{
- return !nfa_set_cmp (va, vb);
-}
-
-static struct rx_hash_rules nfa_set_hash_rules =
-{
- nfa_set_equal,
- compiler_hash_alloc,
- compiler_free_hash,
- compiler_hash_item_alloc,
- compiler_free_hash_item
-};
-
-
-#ifdef __STDC__
-static struct rx_nfa_state_set *
-nfa_set_cons (struct rx * rx,
- struct rx_hash * memo, struct rx_nfa_state * state,
- struct rx_nfa_state_set * set)
-#else
-static struct rx_nfa_state_set *
-nfa_set_cons (rx, memo, state, set)
- struct rx * rx;
- struct rx_hash * memo;
- struct rx_nfa_state * state;
- struct rx_nfa_state_set * set;
-#endif
-{
- struct rx_nfa_state_set template;
- struct rx_hash_item * node;
- template.car = state;
- template.cdr = set;
- node = rx_hash_store (memo,
- (((long)state) >> 8) ^ (long)set,
- &template, &nfa_set_hash_rules);
- if (!node)
- return 0;
- if (node->data == &template)
- {
- struct rx_nfa_state_set * l;
- l = (struct rx_nfa_state_set *) malloc (sizeof (*l));
- node->data = (void *) l;
- if (!l)
- return 0;
- *l = template;
- }
- return (struct rx_nfa_state_set *)node->data;
-}
-
-
-#ifdef __STDC__
-static struct rx_nfa_state_set *
-nfa_set_enjoin (struct rx * rx,
- struct rx_hash * memo, struct rx_nfa_state * state,
- struct rx_nfa_state_set * set)
-#else
-static struct rx_nfa_state_set *
-nfa_set_enjoin (rx, memo, state, set)
- struct rx * rx;
- struct rx_hash * memo;
- struct rx_nfa_state * state;
- struct rx_nfa_state_set * set;
-#endif
-{
- if (!set || state->id < set->car->id)
- return nfa_set_cons (rx, memo, state, set);
- if (state->id == set->car->id)
- return set;
- else
- {
- struct rx_nfa_state_set * newcdr
- = nfa_set_enjoin (rx, memo, state, set->cdr);
- if (newcdr != set->cdr)
- set = nfa_set_cons (rx, memo, set->car, newcdr);
- return set;
- }
-}
-
-
-
-/* This page: computing epsilon closures. The closures aren't total.
- * Each node's closures are partitioned according to the side effects entailed
- * along the epsilon edges. Return true on success.
- */
-
-struct eclose_frame
-{
- struct rx_se_list *prog_backwards;
-};
-
-
-#ifdef __STDC__
-static int
-eclose_node (struct rx *rx, struct rx_nfa_state *outnode,
- struct rx_nfa_state *node, struct eclose_frame *frame)
-#else
-static int
-eclose_node (rx, outnode, node, frame)
- struct rx *rx;
- struct rx_nfa_state *outnode;
- struct rx_nfa_state *node;
- struct eclose_frame *frame;
-#endif
-{
- struct rx_nfa_edge *e = node->edges;
-
- /* For each node, we follow all epsilon paths to build the closure.
- * The closure omits nodes that have only epsilon edges.
- * The closure is split into partial closures -- all the states in
- * a partial closure are reached by crossing the same list of
- * of side effects (though not necessarily the same path).
- */
- if (node->mark)
- return 1;
- node->mark = 1;
-
- if (node->id >= 0 || node->is_final)
- {
- struct rx_possible_future **ec;
- struct rx_se_list * prog_in_order
- = ((struct rx_se_list *)hash_se_prog (rx,
- &rx->se_list_memo,
- frame->prog_backwards));
- int cmp;
-
- ec = &outnode->futures;
-
- while (*ec)
- {
- cmp = se_list_cmp ((void *)(*ec)->effects, (void *)prog_in_order);
- if (cmp <= 0)
- break;
- ec = &(*ec)->next;
- }
- if (!*ec || (cmp < 0))
- {
- struct rx_possible_future * saved = *ec;
- *ec = rx_possible_future (rx, prog_in_order);
- (*ec)->next = saved;
- if (!*ec)
- return 0;
- }
- if (node->id >= 0)
- {
- (*ec)->destset = nfa_set_enjoin (rx, &rx->set_list_memo,
- node, (*ec)->destset);
- if (!(*ec)->destset)
- return 0;
- }
- }
-
- while (e)
- {
- switch (e->type)
- {
- case ne_epsilon:
- if (!eclose_node (rx, outnode, e->dest, frame))
- return 0;
- break;
- case ne_side_effect:
- {
- frame->prog_backwards = side_effect_cons (rx,
- e->params.side_effect,
- frame->prog_backwards);
- if (!frame->prog_backwards)
- return 0;
- if (!eclose_node (rx, outnode, e->dest, frame))
- return 0;
- {
- struct rx_se_list * dying = frame->prog_backwards;
- frame->prog_backwards = frame->prog_backwards->cdr;
- free ((char *)dying);
- }
- break;
- }
- default:
- break;
- }
- e = e->next;
- }
- node->mark = 0;
- return 1;
-}
-
-
-#ifdef __STDC__
-RX_DECL int
-rx_eclose_nfa (struct rx *rx)
-#else
-RX_DECL int
-rx_eclose_nfa (rx)
- struct rx *rx;
-#endif
-{
- struct rx_nfa_state *n = rx->nfa_states;
- struct eclose_frame frame;
- static int rx_id = 0;
-
- frame.prog_backwards = 0;
- rx->rx_id = rx_id++;
- bzero (&rx->se_list_memo, sizeof (rx->se_list_memo));
- bzero (&rx->set_list_memo, sizeof (rx->set_list_memo));
- while (n)
- {
- n->futures = 0;
- if (n->eclosure_needed && !eclose_node (rx, n, n, &frame))
- return 0;
- /* clear_marks (rx); */
- n = n->next;
- }
- return 1;
-}
-
-
-/* This deletes epsilon edges from an NFA. After running eclose_node,
- * we have no more need for these edges. They are removed to simplify
- * further operations on the NFA.
- */
-
-#ifdef __STDC__
-RX_DECL void
-rx_delete_epsilon_transitions (struct rx *rx)
-#else
-RX_DECL void
-rx_delete_epsilon_transitions (rx)
- struct rx *rx;
-#endif
-{
- struct rx_nfa_state *n = rx->nfa_states;
- struct rx_nfa_edge **e;
-
- while (n)
- {
- e = &n->edges;
- while (*e)
- {
- struct rx_nfa_edge *t;
- switch ((*e)->type)
- {
- case ne_epsilon:
- case ne_side_effect:
- t = *e;
- *e = t->next;
- rx_free_nfa_edge (t);
- break;
-
- default:
- e = &(*e)->next;
- break;
- }
- }
- n = n->next;
- }
-}
-
-
-/* This page: storing the nfa in a contiguous region of memory for
- * subsequent conversion to a super-nfa.
- */
-
-/* This is for qsort on an array of nfa_states. The order
- * is based on state ids and goes
- * [0...MAX][MIN..-1] where (MAX>=0) and (MIN<0)
- * This way, positive ids double as array indices.
- */
-
-#ifdef __STDC__
-static int
-nfacmp (void * va, void * vb)
-#else
-static int
-nfacmp (va, vb)
- void * va;
- void * vb;
-#endif
-{
- struct rx_nfa_state **a = (struct rx_nfa_state **)va;
- struct rx_nfa_state **b = (struct rx_nfa_state **)vb;
- return (*a == *b /* &&&& 3.18 */
- ? 0
- : (((*a)->id < 0) == ((*b)->id < 0)
- ? (((*a)->id < (*b)->id) ? -1 : 1)
- : (((*a)->id < 0)
- ? 1 : -1)));
-}
-
-#ifdef __STDC__
-static int
-count_hash_nodes (struct rx_hash * st)
-#else
-static int
-count_hash_nodes (st)
- struct rx_hash * st;
-#endif
-{
- int x;
- int count = 0;
- for (x = 0; x < 13; ++x)
- count += ((st->children[x])
- ? count_hash_nodes (st->children[x])
- : st->bucket_size[x]);
-
- return count;
-}
-
-
-#ifdef __STDC__
-static void
-se_memo_freer (struct rx_hash_item * node)
-#else
-static void
-se_memo_freer (node)
- struct rx_hash_item * node;
-#endif
-{
- free ((char *)node->data);
-}
-
-
-#ifdef __STDC__
-static void
-nfa_set_freer (struct rx_hash_item * node)
-#else
-static void
-nfa_set_freer (node)
- struct rx_hash_item * node;
-#endif
-{
- free ((char *)node->data);
-}
-
-
-/* This copies an entire NFA into a single malloced block of memory.
- * Mostly this is for compatability with regex.c, though it is convenient
- * to have the nfa nodes in an array.
- */
-
-#ifdef __STDC__
-RX_DECL int
-rx_compactify_nfa (struct rx *rx,
- void **mem, unsigned long *size)
-#else
-RX_DECL int
-rx_compactify_nfa (rx, mem, size)
- struct rx *rx;
- void **mem;
- unsigned long *size;
-#endif
-{
- int total_nodec;
- struct rx_nfa_state *n;
- int edgec = 0;
- int eclosec = 0;
- int se_list_consc = count_hash_nodes (&rx->se_list_memo);
- int nfa_setc = count_hash_nodes (&rx->set_list_memo);
- unsigned long total_size;
-
- /* This takes place in two stages. First, the total size of the
- * nfa is computed, then structures are copied.
- */
- n = rx->nfa_states;
- total_nodec = 0;
- while (n)
- {
- struct rx_nfa_edge *e = n->edges;
- struct rx_possible_future *ec = n->futures;
- ++total_nodec;
- while (e)
- {
- ++edgec;
- e = e->next;
- }
- while (ec)
- {
- ++eclosec;
- ec = ec->next;
- }
- n = n->next;
- }
-
- total_size = (total_nodec * sizeof (struct rx_nfa_state)
- + edgec * rx_sizeof_bitset (rx->local_cset_size)
- + edgec * sizeof (struct rx_nfa_edge)
- + nfa_setc * sizeof (struct rx_nfa_state_set)
- + eclosec * sizeof (struct rx_possible_future)
- + se_list_consc * sizeof (struct rx_se_list)
- + rx->reserved);
-
- if (total_size > *size)
- {
- *mem = remalloc (*mem, total_size);
- if (*mem)
- *size = total_size;
- else
- return 0;
- }
- /* Now we've allocated the memory; this copies the NFA. */
- {
- static struct rx_nfa_state **scratch = 0;
- static int scratch_alloc = 0;
- struct rx_nfa_state *state_base = (struct rx_nfa_state *) * mem;
- struct rx_nfa_state *new_state = state_base;
- struct rx_nfa_edge *new_edge =
- (struct rx_nfa_edge *)
- ((char *) state_base + total_nodec * sizeof (struct rx_nfa_state));
- struct rx_se_list * new_se_list =
- (struct rx_se_list *)
- ((char *)new_edge + edgec * sizeof (struct rx_nfa_edge));
- struct rx_possible_future *new_close =
- ((struct rx_possible_future *)
- ((char *) new_se_list
- + se_list_consc * sizeof (struct rx_se_list)));
- struct rx_nfa_state_set * new_nfa_set =
- ((struct rx_nfa_state_set *)
- ((char *)new_close + eclosec * sizeof (struct rx_possible_future)));
- char *new_bitset =
- ((char *) new_nfa_set + nfa_setc * sizeof (struct rx_nfa_state_set));
- int x;
- struct rx_nfa_state *n;
-
- if (scratch_alloc < total_nodec)
- {
- scratch = ((struct rx_nfa_state **)
- remalloc (scratch, total_nodec * sizeof (*scratch)));
- if (scratch)
- scratch_alloc = total_nodec;
- else
- {
- scratch_alloc = 0;
- return 0;
- }
- }
-
- for (x = 0, n = rx->nfa_states; n; n = n->next)
- scratch[x++] = n;
-
- qsort (scratch, total_nodec,
- sizeof (struct rx_nfa_state *), (int (*)())nfacmp);
-
- for (x = 0; x < total_nodec; ++x)
- {
- struct rx_possible_future *eclose = scratch[x]->futures;
- struct rx_nfa_edge *edge = scratch[x]->edges;
- struct rx_nfa_state *cn = new_state++;
- cn->futures = 0;
- cn->edges = 0;
- cn->next = (x == total_nodec - 1) ? 0 : (cn + 1);
- cn->id = scratch[x]->id;
- cn->is_final = scratch[x]->is_final;
- cn->is_start = scratch[x]->is_start;
- cn->mark = 0;
- while (edge)
- {
- int indx = (edge->dest->id < 0
- ? (total_nodec + edge->dest->id)
- : edge->dest->id);
- struct rx_nfa_edge *e = new_edge++;
- rx_Bitset cset = (rx_Bitset) new_bitset;
- new_bitset += rx_sizeof_bitset (rx->local_cset_size);
- rx_bitset_null (rx->local_cset_size, cset);
- rx_bitset_union (rx->local_cset_size, cset, edge->params.cset);
- e->next = cn->edges;
- cn->edges = e;
- e->type = edge->type;
- e->dest = state_base + indx;
- e->params.cset = cset;
- edge = edge->next;
- }
- while (eclose)
- {
- struct rx_possible_future *ec = new_close++;
- struct rx_hash_item * sp;
- struct rx_se_list ** sepos;
- struct rx_se_list * sesrc;
- struct rx_nfa_state_set * destlst;
- struct rx_nfa_state_set ** destpos;
- ec->next = cn->futures;
- cn->futures = ec;
- for (sepos = &ec->effects, sesrc = eclose->effects;
- sesrc;
- sesrc = sesrc->cdr, sepos = &(*sepos)->cdr)
- {
- sp = rx_hash_find (&rx->se_list_memo,
- (long)sesrc->car ^ (long)sesrc->cdr,
- sesrc, &se_list_hash_rules);
- if (sp->binding)
- {
- sesrc = (struct rx_se_list *)sp->binding;
- break;
- }
- *new_se_list = *sesrc;
- sp->binding = (void *)new_se_list;
- *sepos = new_se_list;
- ++new_se_list;
- }
- *sepos = sesrc;
- for (destpos = &ec->destset, destlst = eclose->destset;
- destlst;
- destpos = &(*destpos)->cdr, destlst = destlst->cdr)
- {
- sp = rx_hash_find (&rx->set_list_memo,
- ((((long)destlst->car) >> 8)
- ^ (long)destlst->cdr),
- destlst, &nfa_set_hash_rules);
- if (sp->binding)
- {
- destlst = (struct rx_nfa_state_set *)sp->binding;
- break;
- }
- *new_nfa_set = *destlst;
- new_nfa_set->car = state_base + destlst->car->id;
- sp->binding = (void *)new_nfa_set;
- *destpos = new_nfa_set;
- ++new_nfa_set;
- }
- *destpos = destlst;
- eclose = eclose->next;
- }
- }
- }
- rx_free_hash_table (&rx->se_list_memo, se_memo_freer, &se_list_hash_rules);
- bzero (&rx->se_list_memo, sizeof (rx->se_list_memo));
- rx_free_hash_table (&rx->set_list_memo, nfa_set_freer, &nfa_set_hash_rules);
- bzero (&rx->set_list_memo, sizeof (rx->set_list_memo));
-
- rx_free_nfa (rx);
- rx->nfa_states = (struct rx_nfa_state *)*mem;
- return 1;
-}
-
-
-/* The functions in the next several pages define the lazy-NFA-conversion used
- * by matchers. The input to this construction is an NFA such as
- * is built by compactify_nfa (rx.c). The output is the superNFA.
- */
-
-/* Match engines can use arbitrary values for opcodes. So, the parse tree
- * is built using instructions names (enum rx_opcode), but the superstate
- * nfa is populated with mystery opcodes (void *).
- *
- * For convenience, here is an id table. The opcodes are == to their inxs
- *
- * The lables in re_search_2 would make good values for instructions.
- */
-
-void * rx_id_instruction_table[rx_num_instructions] =
-{
- (void *) rx_backtrack_point,
- (void *) rx_do_side_effects,
- (void *) rx_cache_miss,
- (void *) rx_next_char,
- (void *) rx_backtrack,
- (void *) rx_error_inx
-};
-
-
-
-/* Memory mgt. for superstate graphs. */
-
-#ifdef __STDC__
-static char *
-rx_cache_malloc (struct rx_cache * cache, int bytes)
-#else
-static char *
-rx_cache_malloc (cache, bytes)
- struct rx_cache * cache;
- int bytes;
-#endif
-{
- while (cache->bytes_left < bytes)
- {
- if (cache->memory_pos)
- cache->memory_pos = cache->memory_pos->next;
- if (!cache->memory_pos)
- {
- cache->morecore (cache);
- if (!cache->memory_pos)
- return 0;
- }
- cache->bytes_left = cache->memory_pos->bytes;
- cache->memory_addr = ((char *)cache->memory_pos
- + sizeof (struct rx_blocklist));
- }
- cache->bytes_left -= bytes;
- {
- char * addr = cache->memory_addr;
- cache->memory_addr += bytes;
- return addr;
- }
-}
-
-#ifdef __STDC__
-static void
-rx_cache_free (struct rx_cache * cache,
- struct rx_freelist ** freelist, char * mem)
-#else
-static void
-rx_cache_free (cache, freelist, mem)
- struct rx_cache * cache;
- struct rx_freelist ** freelist;
- char * mem;
-#endif
-{
- struct rx_freelist * it = (struct rx_freelist *)mem;
- it->next = *freelist;
- *freelist = it;
-}
-
-
-/* The partially instantiated superstate graph has a transition
- * table at every node. There is one entry for every character.
- * This fills in the transition for a set.
- */
-#ifdef __STDC__
-static void
-install_transition (struct rx_superstate *super,
- struct rx_inx *answer, rx_Bitset trcset)
-#else
-static void
-install_transition (super, answer, trcset)
- struct rx_superstate *super;
- struct rx_inx *answer;
- rx_Bitset trcset;
-#endif
-{
- struct rx_inx * transitions = super->transitions;
- int chr;
- for (chr = 0; chr < 256; )
- if (!*trcset)
- {
- ++trcset;
- chr += 32;
- }
- else
- {
- RX_subset sub = *trcset;
- RX_subset mask = 1;
- int bound = chr + 32;
- while (chr < bound)
- {
- if (sub & mask)
- transitions [chr] = *answer;
- ++chr;
- mask <<= 1;
- }
- ++trcset;
- }
-}
-
-
-#ifdef __STDC__
-static int
-qlen (struct rx_superstate * q)
-#else
-static int
-qlen (q)
- struct rx_superstate * q;
-#endif
-{
- int count = 1;
- struct rx_superstate * it;
- if (!q)
- return 0;
- for (it = q->next_recyclable; it != q; it = it->next_recyclable)
- ++count;
- return count;
-}
-
-#ifdef __STDC__
-static void
-check_cache (struct rx_cache * cache)
-#else
-static void
-check_cache (cache)
- struct rx_cache * cache;
-#endif
-{
- struct rx_cache * you_fucked_up = 0;
- int total = cache->superstates;
- int semi = cache->semifree_superstates;
- if (semi != qlen (cache->semifree_superstate))
- check_cache (you_fucked_up);
- if ((total - semi) != qlen (cache->lru_superstate))
- check_cache (you_fucked_up);
-}
-
-/* When a superstate is old and neglected, it can enter a
- * semi-free state. A semi-free state is slated to die.
- * Incoming transitions to a semi-free state are re-written
- * to cause an (interpreted) fault when they are taken.
- * The fault handler revives the semi-free state, patches
- * incoming transitions back to normal, and continues.
- *
- * The idea is basicly to free in two stages, aborting
- * between the two if the state turns out to be useful again.
- * When a free is aborted, the rescued superstate is placed
- * in the most-favored slot to maximize the time until it
- * is next semi-freed.
- */
-
-#ifdef __STDC__
-static void
-semifree_superstate (struct rx_cache * cache)
-#else
-static void
-semifree_superstate (cache)
- struct rx_cache * cache;
-#endif
-{
- int disqualified = cache->semifree_superstates;
- if (disqualified == cache->superstates)
- return;
- while (cache->lru_superstate->locks)
- {
- cache->lru_superstate = cache->lru_superstate->next_recyclable;
- ++disqualified;
- if (disqualified == cache->superstates)
- return;
- }
- {
- struct rx_superstate * it = cache->lru_superstate;
- it->next_recyclable->prev_recyclable = it->prev_recyclable;
- it->prev_recyclable->next_recyclable = it->next_recyclable;
- cache->lru_superstate = (it == it->next_recyclable
- ? 0
- : it->next_recyclable);
- if (!cache->semifree_superstate)
- {
- cache->semifree_superstate = it;
- it->next_recyclable = it;
- it->prev_recyclable = it;
- }
- else
- {
- it->prev_recyclable = cache->semifree_superstate->prev_recyclable;
- it->next_recyclable = cache->semifree_superstate;
- it->prev_recyclable->next_recyclable = it;
- it->next_recyclable->prev_recyclable = it;
- }
- {
- struct rx_distinct_future *df;
- it->is_semifree = 1;
- ++cache->semifree_superstates;
- df = it->transition_refs;
- if (df)
- {
- df->prev_same_dest->next_same_dest = 0;
- for (df = it->transition_refs; df; df = df->next_same_dest)
- {
- df->future_frame.inx = cache->instruction_table[rx_cache_miss];
- df->future_frame.data = 0;
- df->future_frame.data_2 = (void *) df;
- /* If there are any NEXT-CHAR instruction frames that
- * refer to this state, we convert them to CACHE-MISS frames.
- */
- if (!df->effects
- && (df->edge->options->next_same_super_edge[0]
- == df->edge->options))
- install_transition (df->present, &df->future_frame,
- df->edge->cset);
- }
- df = it->transition_refs;
- df->prev_same_dest->next_same_dest = df;
- }
- }
- }
-}
-
-
-#ifdef __STDC__
-static void
-refresh_semifree_superstate (struct rx_cache * cache,
- struct rx_superstate * super)
-#else
-static void
-refresh_semifree_superstate (cache, super)
- struct rx_cache * cache;
- struct rx_superstate * super;
-#endif
-{
- struct rx_distinct_future *df;
-
- if (super->transition_refs)
- {
- super->transition_refs->prev_same_dest->next_same_dest = 0;
- for (df = super->transition_refs; df; df = df->next_same_dest)
- {
- df->future_frame.inx = cache->instruction_table[rx_next_char];
- df->future_frame.data = (void *) super->transitions;
- /* CACHE-MISS instruction frames that refer to this state,
- * must be converted to NEXT-CHAR frames.
- */
- if (!df->effects
- && (df->edge->options->next_same_super_edge[0]
- == df->edge->options))
- install_transition (df->present, &df->future_frame,
- df->edge->cset);
- }
- super->transition_refs->prev_same_dest->next_same_dest
- = super->transition_refs;
- }
- if (cache->semifree_superstate == super)
- cache->semifree_superstate = (super->prev_recyclable == super
- ? 0
- : super->prev_recyclable);
- super->next_recyclable->prev_recyclable = super->prev_recyclable;
- super->prev_recyclable->next_recyclable = super->next_recyclable;
-
- if (!cache->lru_superstate)
- (cache->lru_superstate
- = super->next_recyclable
- = super->prev_recyclable
- = super);
- else
- {
- super->next_recyclable = cache->lru_superstate;
- super->prev_recyclable = cache->lru_superstate->prev_recyclable;
- super->next_recyclable->prev_recyclable = super;
- super->prev_recyclable->next_recyclable = super;
- }
- super->is_semifree = 0;
- --cache->semifree_superstates;
-}
-
-#ifdef __STDC__
-static void
-rx_refresh_this_superstate (struct rx_cache * cache, struct rx_superstate * superstate)
-#else
-static void
-rx_refresh_this_superstate (cache, superstate)
- struct rx_cache * cache;
- struct rx_superstate * superstate;
-#endif
-{
- if (superstate->is_semifree)
- refresh_semifree_superstate (cache, superstate);
- else if (cache->lru_superstate == superstate)
- cache->lru_superstate = superstate->next_recyclable;
- else if (superstate != cache->lru_superstate->prev_recyclable)
- {
- superstate->next_recyclable->prev_recyclable
- = superstate->prev_recyclable;
- superstate->prev_recyclable->next_recyclable
- = superstate->next_recyclable;
- superstate->next_recyclable = cache->lru_superstate;
- superstate->prev_recyclable = cache->lru_superstate->prev_recyclable;
- superstate->next_recyclable->prev_recyclable = superstate;
- superstate->prev_recyclable->next_recyclable = superstate;
- }
-}
-
-#ifdef __STDC__
-static void
-release_superset_low (struct rx_cache * cache,
- struct rx_superset *set)
-#else
-static void
-release_superset_low (cache, set)
- struct rx_cache * cache;
- struct rx_superset *set;
-#endif
-{
- if (!--set->refs)
- {
- if (set->cdr)
- release_superset_low (cache, set->cdr);
-
- set->starts_for = 0;
-
- rx_hash_free
- (rx_hash_find
- (&cache->superset_table,
- (unsigned long)set->car ^ set->id ^ (unsigned long)set->cdr,
- (void *)set,
- &cache->superset_hash_rules),
- &cache->superset_hash_rules);
- rx_cache_free (cache, &cache->free_supersets, (char *)set);
- }
-}
-
-#ifdef __STDC__
-RX_DECL void
-rx_release_superset (struct rx *rx,
- struct rx_superset *set)
-#else
-RX_DECL void
-rx_release_superset (rx, set)
- struct rx *rx;
- struct rx_superset *set;
-#endif
-{
- release_superset_low (rx->cache, set);
-}
-
-/* This tries to add a new superstate to the superstate freelist.
- * It might, as a result, free some edge pieces or hash tables.
- * If nothing can be freed because too many locks are being held, fail.
- */
-
-#ifdef __STDC__
-static int
-rx_really_free_superstate (struct rx_cache * cache)
-#else
-static int
-rx_really_free_superstate (cache)
- struct rx_cache * cache;
-#endif
-{
- int locked_superstates = 0;
- struct rx_superstate * it;
-
- if (!cache->superstates)
- return 0;
-
- {
- /* This is a total guess. The idea is that we should expect as
- * many misses as we've recently experienced. I.e., cache->misses
- * should be the same as cache->semifree_superstates.
- */
- while ((cache->hits + cache->misses) > cache->superstates_allowed)
- {
- cache->hits >>= 1;
- cache->misses >>= 1;
- }
- if ( ((cache->hits + cache->misses) * cache->semifree_superstates)
- < (cache->superstates * cache->misses))
- {
- semifree_superstate (cache);
- semifree_superstate (cache);
- }
- }
-
- while (cache->semifree_superstate && cache->semifree_superstate->locks)
- {
- refresh_semifree_superstate (cache, cache->semifree_superstate);
- ++locked_superstates;
- if (locked_superstates == cache->superstates)
- return 0;
- }
-
- if (cache->semifree_superstate)
- {
- it = cache->semifree_superstate;
- it->next_recyclable->prev_recyclable = it->prev_recyclable;
- it->prev_recyclable->next_recyclable = it->next_recyclable;
- cache->semifree_superstate = ((it == it->next_recyclable)
- ? 0
- : it->next_recyclable);
- --cache->semifree_superstates;
- }
- else
- {
- while (cache->lru_superstate->locks)
- {
- cache->lru_superstate = cache->lru_superstate->next_recyclable;
- ++locked_superstates;
- if (locked_superstates == cache->superstates)
- return 0;
- }
- it = cache->lru_superstate;
- it->next_recyclable->prev_recyclable = it->prev_recyclable;
- it->prev_recyclable->next_recyclable = it->next_recyclable;
- cache->lru_superstate = ((it == it->next_recyclable)
- ? 0
- : it->next_recyclable);
- }
-
- if (it->transition_refs)
- {
- struct rx_distinct_future *df;
- for (df = it->transition_refs,
- df->prev_same_dest->next_same_dest = 0;
- df;
- df = df->next_same_dest)
- {
- df->future_frame.inx = cache->instruction_table[rx_cache_miss];
- df->future_frame.data = 0;
- df->future_frame.data_2 = (void *) df;
- df->future = 0;
- }
- it->transition_refs->prev_same_dest->next_same_dest =
- it->transition_refs;
- }
- {
- struct rx_super_edge *tc = it->edges;
- while (tc)
- {
- struct rx_distinct_future * df;
- struct rx_super_edge *tct = tc->next;
- df = tc->options;
- df->next_same_super_edge[1]->next_same_super_edge[0] = 0;
- while (df)
- {
- struct rx_distinct_future *dft = df;
- df = df->next_same_super_edge[0];
-
-
- if (dft->future && dft->future->transition_refs == dft)
- {
- dft->future->transition_refs = dft->next_same_dest;
- if (dft->future->transition_refs == dft)
- dft->future->transition_refs = 0;
- }
- dft->next_same_dest->prev_same_dest = dft->prev_same_dest;
- dft->prev_same_dest->next_same_dest = dft->next_same_dest;
- rx_cache_free (cache, &cache->free_discernable_futures,
- (char *)dft);
- }
- rx_cache_free (cache, &cache->free_transition_classes, (char *)tc);
- tc = tct;
- }
- }
-
- if (it->contents->superstate == it)
- it->contents->superstate = 0;
- release_superset_low (cache, it->contents);
- rx_cache_free (cache, &cache->free_superstates, (char *)it);
- --cache->superstates;
- return 1;
-}
-
-#ifdef __STDC__
-static char *
-rx_cache_get (struct rx_cache * cache,
- struct rx_freelist ** freelist)
-#else
-static char *
-rx_cache_get (cache, freelist)
- struct rx_cache * cache;
- struct rx_freelist ** freelist;
-#endif
-{
- while (!*freelist && rx_really_free_superstate (cache))
- ;
- if (!*freelist)
- return 0;
- {
- struct rx_freelist * it = *freelist;
- *freelist = it->next;
- return (char *)it;
- }
-}
-
-#ifdef __STDC__
-static char *
-rx_cache_malloc_or_get (struct rx_cache * cache,
- struct rx_freelist ** freelist, int bytes)
-#else
-static char *
-rx_cache_malloc_or_get (cache, freelist, bytes)
- struct rx_cache * cache;
- struct rx_freelist ** freelist;
- int bytes;
-#endif
-{
- if (!*freelist)
- {
- char * answer = rx_cache_malloc (cache, bytes);
- if (answer)
- return answer;
- }
-
- return rx_cache_get (cache, freelist);
-}
-
-#ifdef __STDC__
-static char *
-rx_cache_get_superstate (struct rx_cache * cache)
-#else
-static char *
-rx_cache_get_superstate (cache)
- struct rx_cache * cache;
-#endif
-{
- char * answer;
- int bytes = ( sizeof (struct rx_superstate)
- + cache->local_cset_size * sizeof (struct rx_inx));
- if (!cache->free_superstates
- && (cache->superstates < cache->superstates_allowed))
- {
- answer = rx_cache_malloc (cache, bytes);
- if (answer)
- {
- ++cache->superstates;
- return answer;
- }
- }
- answer = rx_cache_get (cache, &cache->free_superstates);
- if (!answer)
- {
- answer = rx_cache_malloc (cache, bytes);
- if (answer)
- ++cache->superstates_allowed;
- }
- ++cache->superstates;
- return answer;
-}
-
-
-
-#ifdef __STDC__
-static int
-supersetcmp (void * va, void * vb)
-#else
-static int
-supersetcmp (va, vb)
- void * va;
- void * vb;
-#endif
-{
- struct rx_superset * a = (struct rx_superset *)va;
- struct rx_superset * b = (struct rx_superset *)vb;
- return ( (a == b)
- || (a && b && (a->car == b->car) && (a->cdr == b->cdr)));
-}
-
-#ifdef __STDC__
-static struct rx_hash_item *
-superset_allocator (struct rx_hash_rules * rules, void * val)
-#else
-static struct rx_hash_item *
-superset_allocator (rules, val)
- struct rx_hash_rules * rules;
- void * val;
-#endif
-{
- struct rx_cache * cache
- = ((struct rx_cache *)
- ((char *)rules
- - (unsigned long)(&((struct rx_cache *)0)->superset_hash_rules)));
- struct rx_superset * template = (struct rx_superset *)val;
- struct rx_superset * newset
- = ((struct rx_superset *)
- rx_cache_malloc_or_get (cache,
- &cache->free_supersets,
- sizeof (*template)));
- if (!newset)
- return 0;
- newset->refs = 0;
- newset->car = template->car;
- newset->id = template->car->id;
- newset->cdr = template->cdr;
- newset->superstate = 0;
- rx_protect_superset (rx, template->cdr);
- newset->hash_item.data = (void *)newset;
- newset->hash_item.binding = 0;
- return &newset->hash_item;
-}
-
-#ifdef __STDC__
-static struct rx_hash *
-super_hash_allocator (struct rx_hash_rules * rules)
-#else
-static struct rx_hash *
-super_hash_allocator (rules)
- struct rx_hash_rules * rules;
-#endif
-{
- struct rx_cache * cache
- = ((struct rx_cache *)
- ((char *)rules
- - (unsigned long)(&((struct rx_cache *)0)->superset_hash_rules)));
- return ((struct rx_hash *)
- rx_cache_malloc_or_get (cache,
- &cache->free_hash, sizeof (struct rx_hash)));
-}
-
-
-#ifdef __STDC__
-static void
-super_hash_liberator (struct rx_hash * hash, struct rx_hash_rules * rules)
-#else
-static void
-super_hash_liberator (hash, rules)
- struct rx_hash * hash;
- struct rx_hash_rules * rules;
-#endif
-{
- struct rx_cache * cache
- = ((struct rx_cache *)
- (char *)rules - (long)(&((struct rx_cache *)0)->superset_hash_rules));
- rx_cache_free (cache, &cache->free_hash, (char *)hash);
-}
-
-#ifdef __STDC__
-static void
-superset_hash_item_liberator (struct rx_hash_item * it,
- struct rx_hash_rules * rules)
-#else
-static void
-superset_hash_item_liberator (it, rules) /* Well, it does ya know. */
- struct rx_hash_item * it;
- struct rx_hash_rules * rules;
-#endif
-{
-}
-
-int rx_cache_bound = 128;
-static int rx_default_cache_got = 0;
-
-#ifdef __STDC__
-static int
-bytes_for_cache_size (int supers, int cset_size)
-#else
-static int
-bytes_for_cache_size (supers, cset_size)
- int supers;
- int cset_size;
-#endif
-{
- /* What the hell is this? !!!*/
- return (int)
- ((float)supers *
- ( (1.03 * (float) ( rx_sizeof_bitset (cset_size)
- + sizeof (struct rx_super_edge)))
- + (1.80 * (float) sizeof (struct rx_possible_future))
- + (float) ( sizeof (struct rx_superstate)
- + cset_size * sizeof (struct rx_inx))));
-}
-
-#ifdef __STDC__
-static void
-rx_morecore (struct rx_cache * cache)
-#else
-static void
-rx_morecore (cache)
- struct rx_cache * cache;
-#endif
-{
- if (rx_default_cache_got >= rx_cache_bound)
- return;
-
- rx_default_cache_got += 16;
- cache->superstates_allowed = rx_cache_bound;
- {
- struct rx_blocklist ** pos = &cache->memory;
- int size = bytes_for_cache_size (16, cache->local_cset_size);
- while (*pos)
- pos = &(*pos)->next;
- *pos = ((struct rx_blocklist *)
- malloc (size + sizeof (struct rx_blocklist)));
- if (!*pos)
- return;
-
- (*pos)->next = 0;
- (*pos)->bytes = size;
- cache->memory_pos = *pos;
- cache->memory_addr = (char *)*pos + sizeof (**pos);
- cache->bytes_left = size;
- }
-}
-
-static struct rx_cache default_cache =
-{
- {
- supersetcmp,
- super_hash_allocator,
- super_hash_liberator,
- superset_allocator,
- superset_hash_item_liberator,
- },
- 0,
- 0,
- 0,
- 0,
- rx_morecore,
-
- 0,
- 0,
- 0,
- 0,
- 0,
-
- 0,
- 0,
-
- 0,
-
- 0,
- 0,
- 0,
- 0,
- 128,
-
- 256,
- rx_id_instruction_table,
-
- {
- 0,
- 0,
- {0},
- {0},
- {0}
- }
-};
-
-/* This adds an element to a superstate set. These sets are lists, such
- * that lists with == elements are ==. The empty set is returned by
- * superset_cons (rx, 0, 0) and is NOT equivelent to
- * (struct rx_superset)0.
- */
-
-#ifdef __STDC__
-RX_DECL struct rx_superset *
-rx_superset_cons (struct rx * rx,
- struct rx_nfa_state *car, struct rx_superset *cdr)
-#else
-RX_DECL struct rx_superset *
-rx_superset_cons (rx, car, cdr)
- struct rx * rx;
- struct rx_nfa_state *car;
- struct rx_superset *cdr;
-#endif
-{
- struct rx_cache * cache = rx->cache;
- if (!car && !cdr)
- {
- if (!cache->empty_superset)
- {
- cache->empty_superset
- = ((struct rx_superset *)
- rx_cache_malloc_or_get (cache, &cache->free_supersets,
- sizeof (struct rx_superset)));
- if (!cache->empty_superset)
- return 0;
- bzero (cache->empty_superset, sizeof (struct rx_superset));
- cache->empty_superset->refs = 1000;
- }
- return cache->empty_superset;
- }
- {
- struct rx_superset template;
- struct rx_hash_item * hit;
- template.car = car;
- template.cdr = cdr;
- template.id = car->id;
- hit = rx_hash_store (&cache->superset_table,
- (unsigned long)car ^ car->id ^ (unsigned long)cdr,
- (void *)&template,
- &cache->superset_hash_rules);
- return (hit
- ? (struct rx_superset *)hit->data
- : 0);
- }
-}
-
-/* This computes a union of two NFA state sets. The sets do not have the
- * same representation though. One is a RX_SUPERSET structure (part
- * of the superstate NFA) and the other is an NFA_STATE_SET (part of the NFA).
- */
-
-#ifdef __STDC__
-RX_DECL struct rx_superset *
-rx_superstate_eclosure_union
- (struct rx * rx, struct rx_superset *set, struct rx_nfa_state_set *ecl)
-#else
-RX_DECL struct rx_superset *
-rx_superstate_eclosure_union (rx, set, ecl)
- struct rx * rx;
- struct rx_superset *set;
- struct rx_nfa_state_set *ecl;
-#endif
-{
- if (!ecl)
- return set;
-
- if (!set->car)
- return rx_superset_cons (rx, ecl->car,
- rx_superstate_eclosure_union (rx, set, ecl->cdr));
- if (set->car == ecl->car)
- return rx_superstate_eclosure_union (rx, set, ecl->cdr);
-
- {
- struct rx_superset * tail;
- struct rx_nfa_state * first;
-
- if (set->car > ecl->car)
- {
- tail = rx_superstate_eclosure_union (rx, set->cdr, ecl);
- first = set->car;
- }
- else
- {
- tail = rx_superstate_eclosure_union (rx, set, ecl->cdr);
- first = ecl->car;
- }
- if (!tail)
- return 0;
- else
- {
- struct rx_superset * answer;
- answer = rx_superset_cons (rx, first, tail);
- if (!answer)
- {
- rx_protect_superset (rx, tail);
- rx_release_superset (rx, tail);
- return 0;
- }
- else
- return answer;
- }
- }
-}
-
-
-
-
-/*
- * This makes sure that a list of rx_distinct_futures contains
- * a future for each possible set of side effects in the eclosure
- * of a given state. This is some of the work of filling in a
- * superstate transition.
- */
-
-#ifdef __STDC__
-static struct rx_distinct_future *
-include_futures (struct rx *rx,
- struct rx_distinct_future *df, struct rx_nfa_state
- *state, struct rx_superstate *superstate)
-#else
-static struct rx_distinct_future *
-include_futures (rx, df, state, superstate)
- struct rx *rx;
- struct rx_distinct_future *df;
- struct rx_nfa_state *state;
- struct rx_superstate *superstate;
-#endif
-{
- struct rx_possible_future *future;
- struct rx_cache * cache = rx->cache;
- for (future = state->futures; future; future = future->next)
- {
- struct rx_distinct_future *dfp;
- struct rx_distinct_future *insert_before = 0;
- if (df)
- df->next_same_super_edge[1]->next_same_super_edge[0] = 0;
- for (dfp = df; dfp; dfp = dfp->next_same_super_edge[0])
- if (dfp->effects == future->effects)
- break;
- else
- {
- int order = rx->se_list_cmp (rx, dfp->effects, future->effects);
- if (order > 0)
- {
- insert_before = dfp;
- dfp = 0;
- break;
- }
- }
- if (df)
- df->next_same_super_edge[1]->next_same_super_edge[0] = df;
- if (!dfp)
- {
- dfp
- = ((struct rx_distinct_future *)
- rx_cache_malloc_or_get (cache, &cache->free_discernable_futures,
- sizeof (struct rx_distinct_future)));
- if (!dfp)
- return 0;
- if (!df)
- {
- df = insert_before = dfp;
- df->next_same_super_edge[0] = df->next_same_super_edge[1] = df;
- }
- else if (!insert_before)
- insert_before = df;
- else if (insert_before == df)
- df = dfp;
-
- dfp->next_same_super_edge[0] = insert_before;
- dfp->next_same_super_edge[1]
- = insert_before->next_same_super_edge[1];
- dfp->next_same_super_edge[1]->next_same_super_edge[0] = dfp;
- dfp->next_same_super_edge[0]->next_same_super_edge[1] = dfp;
- dfp->next_same_dest = dfp->prev_same_dest = dfp;
- dfp->future = 0;
- dfp->present = superstate;
- dfp->future_frame.inx = rx->instruction_table[rx_cache_miss];
- dfp->future_frame.data = 0;
- dfp->future_frame.data_2 = (void *) dfp;
- dfp->side_effects_frame.inx
- = rx->instruction_table[rx_do_side_effects];
- dfp->side_effects_frame.data = 0;
- dfp->side_effects_frame.data_2 = (void *) dfp;
- dfp->effects = future->effects;
- }
- }
- return df;
-}
-
-
-
-/* This constructs a new superstate from its state set. The only
- * complexity here is memory management.
- */
-#ifdef __STDC__
-RX_DECL struct rx_superstate *
-rx_superstate (struct rx *rx,
- struct rx_superset *set)
-#else
-RX_DECL struct rx_superstate *
-rx_superstate (rx, set)
- struct rx *rx;
- struct rx_superset *set;
-#endif
-{
- struct rx_cache * cache = rx->cache;
- struct rx_superstate * superstate = 0;
-
- /* Does the superstate already exist in the cache? */
- if (set->superstate)
- {
- if (set->superstate->rx_id != rx->rx_id)
- {
- /* Aha. It is in the cache, but belongs to a superstate
- * that refers to an NFA that no longer exists.
- * (We know it no longer exists because it was evidently
- * stored in the same region of memory as the current nfa
- * yet it has a different id.)
- */
- superstate = set->superstate;
- if (!superstate->is_semifree)
- {
- if (cache->lru_superstate == superstate)
- {
- cache->lru_superstate = superstate->next_recyclable;
- if (cache->lru_superstate == superstate)
- cache->lru_superstate = 0;
- }
- {
- superstate->next_recyclable->prev_recyclable
- = superstate->prev_recyclable;
- superstate->prev_recyclable->next_recyclable
- = superstate->next_recyclable;
- if (!cache->semifree_superstate)
- {
- (cache->semifree_superstate
- = superstate->next_recyclable
- = superstate->prev_recyclable
- = superstate);
- }
- else
- {
- superstate->next_recyclable = cache->semifree_superstate;
- superstate->prev_recyclable
- = cache->semifree_superstate->prev_recyclable;
- superstate->next_recyclable->prev_recyclable
- = superstate;
- superstate->prev_recyclable->next_recyclable
- = superstate;
- cache->semifree_superstate = superstate;
- }
- ++cache->semifree_superstates;
- }
- }
- set->superstate = 0;
- goto handle_cache_miss;
- }
- ++cache->hits;
- superstate = set->superstate;
-
- rx_refresh_this_superstate (cache, superstate);
- return superstate;
- }
-
- handle_cache_miss:
-
- /* This point reached only for cache misses. */
- ++cache->misses;
-#if RX_DEBUG
- if (rx_debug_trace > 1)
- {
- struct rx_superset * setp = set;
- fprintf (stderr, "Building a superstet %d(%d): ", rx->rx_id, set);
- while (setp)
- {
- fprintf (stderr, "%d ", setp->id);
- setp = setp->cdr;
- }
- fprintf (stderr, "(%d)\n", set);
- }
-#endif
- superstate = (struct rx_superstate *)rx_cache_get_superstate (cache);
- if (!superstate)
- return 0;
-
- if (!cache->lru_superstate)
- (cache->lru_superstate
- = superstate->next_recyclable
- = superstate->prev_recyclable
- = superstate);
- else
- {
- superstate->next_recyclable = cache->lru_superstate;
- superstate->prev_recyclable = cache->lru_superstate->prev_recyclable;
- ( superstate->prev_recyclable->next_recyclable
- = superstate->next_recyclable->prev_recyclable
- = superstate);
- }
- superstate->rx_id = rx->rx_id;
- superstate->transition_refs = 0;
- superstate->locks = 0;
- superstate->is_semifree = 0;
- set->superstate = superstate;
- superstate->contents = set;
- rx_protect_superset (rx, set);
- superstate->edges = 0;
- {
- int x;
- /* None of the transitions from this superstate are known yet. */
- for (x = 0; x < rx->local_cset_size; ++x) /* &&&&& 3.8 % */
- {
- struct rx_inx * ifr = &superstate->transitions[x];
- ifr->inx = rx->instruction_table [rx_cache_miss];
- ifr->data = ifr->data_2 = 0;
- }
- }
- return superstate;
-}
-
-
-/* This computes the destination set of one edge of the superstate NFA.
- * Note that a RX_DISTINCT_FUTURE is a superstate edge.
- * Returns 0 on an allocation failure.
- */
-
-#ifdef __STDC__
-static int
-solve_destination (struct rx *rx, struct rx_distinct_future *df)
-#else
-static int
-solve_destination (rx, df)
- struct rx *rx;
- struct rx_distinct_future *df;
-#endif
-{
- struct rx_super_edge *tc = df->edge;
- struct rx_superset *nfa_state;
- struct rx_superset *nil_set = rx_superset_cons (rx, 0, 0);
- struct rx_superset *solution = nil_set;
- struct rx_superstate *dest;
-
- rx_protect_superset (rx, solution);
- /* Iterate over all NFA states in the state set of this superstate. */
- for (nfa_state = df->present->contents;
- nfa_state->car;
- nfa_state = nfa_state->cdr)
- {
- struct rx_nfa_edge *e;
- /* Iterate over all edges of each NFA state. */
- for (e = nfa_state->car->edges; e; e = e->next)
- /* If we find an edge that is labeled with
- * the characters we are solving for.....
- */
- if (rx_bitset_is_subset (rx->local_cset_size,
- tc->cset, e->params.cset))
- {
- struct rx_nfa_state *n = e->dest;
- struct rx_possible_future *pf;
- /* ....search the partial epsilon closures of the destination
- * of that edge for a path that involves the same set of
- * side effects we are solving for.
- * If we find such a RX_POSSIBLE_FUTURE, we add members to the
- * stateset we are computing.
- */
- for (pf = n->futures; pf; pf = pf->next)
- if (pf->effects == df->effects)
- {
- struct rx_superset * old_sol;
- old_sol = solution;
- solution = rx_superstate_eclosure_union (rx, solution,
- pf->destset);
- if (!solution)
- return 0;
- rx_protect_superset (rx, solution);
- rx_release_superset (rx, old_sol);
- }
- }
- }
- /* It is possible that the RX_DISTINCT_FUTURE we are working on has
- * the empty set of NFA states as its definition. In that case, this
- * is a failure point.
- */
- if (solution == nil_set)
- {
- df->future_frame.inx = (void *) rx_backtrack;
- df->future_frame.data = 0;
- df->future_frame.data_2 = 0;
- return 1;
- }
- dest = rx_superstate (rx, solution);
- rx_release_superset (rx, solution);
- if (!dest)
- return 0;
-
- {
- struct rx_distinct_future *dft;
- dft = df;
- df->prev_same_dest->next_same_dest = 0;
- while (dft)
- {
- dft->future = dest;
- dft->future_frame.inx = rx->instruction_table[rx_next_char];
- dft->future_frame.data = (void *) dest->transitions;
- dft = dft->next_same_dest;
- }
- df->prev_same_dest->next_same_dest = df;
- }
- if (!dest->transition_refs)
- dest->transition_refs = df;
- else
- {
- struct rx_distinct_future *dft = dest->transition_refs->next_same_dest;
- dest->transition_refs->next_same_dest = df->next_same_dest;
- df->next_same_dest->prev_same_dest = dest->transition_refs;
- df->next_same_dest = dft;
- dft->prev_same_dest = df;
- }
- return 1;
-}
-
-
-/* This takes a superstate and a character, and computes some edges
- * from the superstate NFA. In particular, this computes all edges
- * that lead from SUPERSTATE given CHR. This function also
- * computes the set of characters that share this edge set.
- * This returns 0 on allocation error.
- * The character set and list of edges are returned through
- * the paramters CSETOUT and DFOUT.
-} */
-
-#ifdef __STDC__
-static int
-compute_super_edge (struct rx *rx, struct rx_distinct_future **dfout,
- rx_Bitset csetout, struct rx_superstate *superstate,
- unsigned char chr)
-#else
-static int
-compute_super_edge (rx, dfout, csetout, superstate, chr)
- struct rx *rx;
- struct rx_distinct_future **dfout;
- rx_Bitset csetout;
- struct rx_superstate *superstate;
- unsigned char chr;
-#endif
-{
- struct rx_superset *stateset = superstate->contents;
-
- /* To compute the set of characters that share edges with CHR,
- * we start with the full character set, and subtract.
- */
- rx_bitset_universe (rx->local_cset_size, csetout);
- *dfout = 0;
-
- /* Iterate over the NFA states in the superstate state-set. */
- while (stateset->car)
- {
- struct rx_nfa_edge *e;
- for (e = stateset->car->edges; e; e = e->next)
- if (RX_bitset_member (e->params.cset, chr))
- {
- /* If we find an NFA edge that applies, we make sure there
- * are corresponding edges in the superstate NFA.
- */
- {
- struct rx_distinct_future * saved;
- saved = *dfout;
- *dfout = include_futures (rx, *dfout, e->dest, superstate);
- if (!*dfout)
- {
- struct rx_distinct_future * df;
- df = saved;
- df->next_same_super_edge[1]->next_same_super_edge[0] = 0;
- while (df)
- {
- struct rx_distinct_future *dft;
- dft = df;
- df = df->next_same_super_edge[0];
-
- if (dft->future && dft->future->transition_refs == dft)
- {
- dft->future->transition_refs = dft->next_same_dest;
- if (dft->future->transition_refs == dft)
- dft->future->transition_refs = 0;
- }
- dft->next_same_dest->prev_same_dest = dft->prev_same_dest;
- dft->prev_same_dest->next_same_dest = dft->next_same_dest;
- rx_cache_free (rx->cache,
- &rx->cache->free_discernable_futures,
- (char *)dft);
- }
- return 0;
- }
- }
- /* We also trim the character set a bit. */
- rx_bitset_intersection (rx->local_cset_size,
- csetout, e->params.cset);
- }
- else
- /* An edge that doesn't apply at least tells us some characters
- * that don't share the same edge set as CHR.
- */
- rx_bitset_difference (rx->local_cset_size, csetout, e->params.cset);
- stateset = stateset->cdr;
- }
- return 1;
-}
-
-
-/* This is a constructor for RX_SUPER_EDGE structures. These are
- * wrappers for lists of superstate NFA edges that share character sets labels.
- * If a transition class contains more than one rx_distinct_future (superstate
- * edge), then it represents a non-determinism in the superstate NFA.
- */
-
-#ifdef __STDC__
-static struct rx_super_edge *
-rx_super_edge (struct rx *rx,
- struct rx_superstate *super, rx_Bitset cset,
- struct rx_distinct_future *df)
-#else
-static struct rx_super_edge *
-rx_super_edge (rx, super, cset, df)
- struct rx *rx;
- struct rx_superstate *super;
- rx_Bitset cset;
- struct rx_distinct_future *df;
-#endif
-{
- struct rx_super_edge *tc =
- (struct rx_super_edge *)rx_cache_malloc_or_get
- (rx->cache, &rx->cache->free_transition_classes,
- sizeof (struct rx_super_edge) + rx_sizeof_bitset (rx->local_cset_size));
-
- if (!tc)
- return 0;
- tc->next = super->edges;
- super->edges = tc;
- tc->rx_backtrack_frame.inx = rx->instruction_table[rx_backtrack_point];
- tc->rx_backtrack_frame.data = 0;
- tc->rx_backtrack_frame.data_2 = (void *) tc;
- tc->options = df;
- tc->cset = (rx_Bitset) ((char *) tc + sizeof (*tc));
- rx_bitset_assign (rx->local_cset_size, tc->cset, cset);
- if (df)
- {
- struct rx_distinct_future * dfp = df;
- df->next_same_super_edge[1]->next_same_super_edge[0] = 0;
- while (dfp)
- {
- dfp->edge = tc;
- dfp = dfp->next_same_super_edge[0];
- }
- df->next_same_super_edge[1]->next_same_super_edge[0] = df;
- }
- return tc;
-}
-
-
-/* There are three kinds of cache miss. The first occurs when a
- * transition is taken that has never been computed during the
- * lifetime of the source superstate. That cache miss is handled by
- * calling COMPUTE_SUPER_EDGE. The second kind of cache miss
- * occurs when the destination superstate of a transition doesn't
- * exist. SOLVE_DESTINATION is used to construct the destination superstate.
- * Finally, the third kind of cache miss occurs when the destination
- * superstate of a transition is in a `semi-free state'. That case is
- * handled by UNFREE_SUPERSTATE.
- *
- * The function of HANDLE_CACHE_MISS is to figure out which of these
- * cases applies.
- */
-
-#ifdef __STDC__
-static void
-install_partial_transition (struct rx_superstate *super,
- struct rx_inx *answer,
- RX_subset set, int offset)
-#else
-static void
-install_partial_transition (super, answer, set, offset)
- struct rx_superstate *super;
- struct rx_inx *answer;
- RX_subset set;
- int offset;
-#endif
-{
- int start = offset;
- int end = start + 32;
- RX_subset pos = 1;
- struct rx_inx * transitions = super->transitions;
-
- while (start < end)
- {
- if (set & pos)
- transitions[start] = *answer;
- pos <<= 1;
- ++start;
- }
-}
-
-
-#ifdef __STDC__
-RX_DECL struct rx_inx *
-rx_handle_cache_miss
- (struct rx *rx, struct rx_superstate *super, unsigned char chr, void *data)
-#else
-RX_DECL struct rx_inx *
-rx_handle_cache_miss (rx, super, chr, data)
- struct rx *rx;
- struct rx_superstate *super;
- unsigned char chr;
- void *data;
-#endif
-{
- int offset = chr / RX_subset_bits;
- struct rx_distinct_future *df = data;
-
- if (!df) /* must be the shared_cache_miss_frame */
- {
- /* Perhaps this is just a transition waiting to be filled. */
- struct rx_super_edge *tc;
- RX_subset mask = rx_subset_singletons [chr % RX_subset_bits];
-
- for (tc = super->edges; tc; tc = tc->next)
- if (tc->cset[offset] & mask)
- {
- struct rx_inx * answer;
- df = tc->options;
- answer = ((tc->options->next_same_super_edge[0] != tc->options)
- ? &tc->rx_backtrack_frame
- : (df->effects
- ? &df->side_effects_frame
- : &df->future_frame));
- install_partial_transition (super, answer,
- tc->cset [offset], offset * 32);
- return answer;
- }
- /* Otherwise, it's a flushed or newly encountered edge. */
- {
- char cset_space[1024]; /* this limit is far from unreasonable */
- rx_Bitset trcset;
- struct rx_inx *answer;
-
- if (rx_sizeof_bitset (rx->local_cset_size) > sizeof (cset_space))
- return 0; /* If the arbitrary limit is hit, always fail */
- /* cleanly. */
- trcset = (rx_Bitset)cset_space;
- rx_lock_superstate (rx, super);
- if (!compute_super_edge (rx, &df, trcset, super, chr))
- {
- rx_unlock_superstate (rx, super);
- return 0;
- }
- if (!df) /* We just computed the fail transition. */
- {
- static struct rx_inx
- shared_fail_frame = { (void *)rx_backtrack, 0, 0 };
- answer = &shared_fail_frame;
- }
- else
- {
- tc = rx_super_edge (rx, super, trcset, df);
- if (!tc)
- {
- rx_unlock_superstate (rx, super);
- return 0;
- }
- answer = ((tc->options->next_same_super_edge[0] != tc->options)
- ? &tc->rx_backtrack_frame
- : (df->effects
- ? &df->side_effects_frame
- : &df->future_frame));
- }
- install_partial_transition (super, answer,
- trcset[offset], offset * 32);
- rx_unlock_superstate (rx, super);
- return answer;
- }
- }
- else if (df->future) /* A cache miss on an edge with a future? Must be
- * a semi-free destination. */
- {
- if (df->future->is_semifree)
- refresh_semifree_superstate (rx->cache, df->future);
- return &df->future_frame;
- }
- else
- /* no future superstate on an existing edge */
- {
- rx_lock_superstate (rx, super);
- if (!solve_destination (rx, df))
- {
- rx_unlock_superstate (rx, super);
- return 0;
- }
- if (!df->effects
- && (df->edge->options->next_same_super_edge[0] == df->edge->options))
- install_partial_transition (super, &df->future_frame,
- df->edge->cset[offset], offset * 32);
- rx_unlock_superstate (rx, super);
- return &df->future_frame;
- }
-}
-
-
-
-
-/* The rest of the code provides a regex.c compatable interface. */
-
-
-__const__ char *re_error_msg[] =
-{
- 0, /* REG_NOUT */
- "No match", /* REG_NOMATCH */
- "Invalid regular expression", /* REG_BADPAT */
- "Invalid collation character", /* REG_ECOLLATE */
- "Invalid character class name", /* REG_ECTYPE */
- "Trailing backslash", /* REG_EESCAPE */
- "Invalid back reference", /* REG_ESUBREG */
- "Unmatched [ or [^", /* REG_EBRACK */
- "Unmatched ( or \\(", /* REG_EPAREN */
- "Unmatched \\{", /* REG_EBRACE */
- "Invalid content of \\{\\}", /* REG_BADBR */
- "Invalid range end", /* REG_ERANGE */
- "Memory exhausted", /* REG_ESPACE */
- "Invalid preceding regular expression", /* REG_BADRPT */
- "Premature end of regular expression", /* REG_EEND */
- "Regular expression too big", /* REG_ESIZE */
- "Unmatched ) or \\)", /* REG_ERPAREN */
-};
-
-
-
-/*
- * Macros used while compiling patterns.
- *
- * By convention, PEND points just past the end of the uncompiled pattern,
- * P points to the read position in the pattern. `translate' is the name
- * of the translation table (`TRANSLATE' is the name of a macro that looks
- * things up in `translate').
- */
-
-
-/*
- * Fetch the next character in the uncompiled pattern---translating it
- * if necessary. *Also cast from a signed character in the constant
- * string passed to us by the user to an unsigned char that we can use
- * as an array index (in, e.g., `translate').
- */
-#define PATFETCH(c) \
- do {if (p == pend) return REG_EEND; \
- c = (unsigned char) *p++; \
- c = translate[c]; \
- } while (0)
-
-/*
- * Fetch the next character in the uncompiled pattern, with no
- * translation.
- */
-#define PATFETCH_RAW(c) \
- do {if (p == pend) return REG_EEND; \
- c = (unsigned char) *p++; \
- } while (0)
-
-/* Go backwards one character in the pattern. */
-#define PATUNFETCH p--
-
-
-#define TRANSLATE(d) translate[(unsigned char) (d)]
-
-typedef unsigned regnum_t;
-
-/* Since offsets can go either forwards or backwards, this type needs to
- * be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1.
- */
-typedef int pattern_offset_t;
-
-typedef struct
-{
- struct rexp_node ** top_expression; /* was begalt */
- struct rexp_node ** last_expression; /* was laststart */
- pattern_offset_t inner_group_offset;
- regnum_t regnum;
-} compile_stack_elt_t;
-
-typedef struct
-{
- compile_stack_elt_t *stack;
- unsigned size;
- unsigned avail; /* Offset of next open position. */
-} compile_stack_type;
-
-
-#define INIT_COMPILE_STACK_SIZE 32
-
-#define COMPILE_STACK_EMPTY (compile_stack.avail == 0)
-#define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size)
-
-/* The next available element. */
-#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail])
-
-
-/* Set the bit for character C in a list. */
-#define SET_LIST_BIT(c) \
- (b[((unsigned char) (c)) / CHARBITS] \
- |= 1 << (((unsigned char) c) % CHARBITS))
-
-/* Get the next unsigned number in the uncompiled pattern. */
-#define GET_UNSIGNED_NUMBER(num) \
- { if (p != pend) \
- { \
- PATFETCH (c); \
- while (isdigit (c)) \
- { \
- if (num < 0) \
- num = 0; \
- num = num * 10 + c - '0'; \
- if (p == pend) \
- break; \
- PATFETCH (c); \
- } \
- } \
- }
-
-#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
-
-#define IS_CHAR_CLASS(string) \
- (!strcmp (string, "alpha") || !strcmp (string, "upper") \
- || !strcmp (string, "lower") || !strcmp (string, "digit") \
- || !strcmp (string, "alnum") || !strcmp (string, "xdigit") \
- || !strcmp (string, "space") || !strcmp (string, "print") \
- || !strcmp (string, "punct") || !strcmp (string, "graph") \
- || !strcmp (string, "cntrl") || !strcmp (string, "blank"))
-
-
-/* These predicates are used in regex_compile. */
-
-/* P points to just after a ^ in PATTERN. Return true if that ^ comes
- * after an alternative or a begin-subexpression. We assume there is at
- * least one character before the ^.
- */
-
-#ifdef __STDC__
-static boolean
-at_begline_loc_p (__const__ char *pattern, __const__ char * p, reg_syntax_t syntax)
-#else
-static boolean
-at_begline_loc_p (pattern, p, syntax)
- __const__ char *pattern;
- __const__ char * p;
- reg_syntax_t syntax;
-#endif
-{
- __const__ char *prev = p - 2;
- boolean prev_prev_backslash = ((prev > pattern) && (prev[-1] == '\\'));
-
- return
-
- (/* After a subexpression? */
- ((*prev == '(') && ((syntax & RE_NO_BK_PARENS) || prev_prev_backslash))
- ||
- /* After an alternative? */
- ((*prev == '|') && ((syntax & RE_NO_BK_VBAR) || prev_prev_backslash))
- );
-}
-
-/* The dual of at_begline_loc_p. This one is for $. We assume there is
- * at least one character after the $, i.e., `P < PEND'.
- */
-
-#ifdef __STDC__
-static boolean
-at_endline_loc_p (__const__ char *p, __const__ char *pend, int syntax)
-#else
-static boolean
-at_endline_loc_p (p, pend, syntax)
- __const__ char *p;
- __const__ char *pend;
- int syntax;
-#endif
-{
- __const__ char *next = p;
- boolean next_backslash = (*next == '\\');
- __const__ char *next_next = (p + 1 < pend) ? (p + 1) : 0;
-
- return
- (
- /* Before a subexpression? */
- ((syntax & RE_NO_BK_PARENS)
- ? (*next == ')')
- : (next_backslash && next_next && (*next_next == ')')))
- ||
- /* Before an alternative? */
- ((syntax & RE_NO_BK_VBAR)
- ? (*next == '|')
- : (next_backslash && next_next && (*next_next == '|')))
- );
-}
-
-
-unsigned char rx_id_translation[256] =
-{
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
- 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
-
- 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
- 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
- 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
- 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
- 160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
- 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
- 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
- 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
-
- 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
- 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
- 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
- 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
- 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
- 250, 251, 252, 253, 254, 255
-};
-
-/* The compiler keeps an inverted translation table.
- * This looks up/inititalize elements.
- * VALID is an array of booleans that validate CACHE.
- */
-
-#ifdef __STDC__
-static rx_Bitset
-inverse_translation (struct re_pattern_buffer * rxb,
- char * valid, rx_Bitset cache,
- unsigned char * translate, int c)
-#else
-static rx_Bitset
-inverse_translation (rxb, valid, cache, translate, c)
- struct re_pattern_buffer * rxb;
- char * valid;
- rx_Bitset cache;
- unsigned char * translate;
- int c;
-#endif
-{
- rx_Bitset cs
- = cache + c * rx_bitset_numb_subsets (rxb->rx.local_cset_size);
-
- if (!valid[c])
- {
- int x;
- int c_tr = TRANSLATE(c);
- rx_bitset_null (rxb->rx.local_cset_size, cs);
- for (x = 0; x < 256; ++x) /* &&&& 13.37 */
- if (TRANSLATE(x) == c_tr)
- RX_bitset_enjoin (cs, x);
- valid[c] = 1;
- }
- return cs;
-}
-
-
-
-
-/* More subroutine declarations and macros for regex_compile. */
-
-/* Returns true if REGNUM is in one of COMPILE_STACK's elements and
- false if it's not. */
-
-#ifdef __STDC__
-static boolean
-group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum)
-#else
-static boolean
-group_in_compile_stack (compile_stack, regnum)
- compile_stack_type compile_stack;
- regnum_t regnum;
-#endif
-{
- int this_element;
-
- for (this_element = compile_stack.avail - 1;
- this_element >= 0;
- this_element--)
- if (compile_stack.stack[this_element].regnum == regnum)
- return true;
-
- return false;
-}
-
-
-/*
- * Read the ending character of a range (in a bracket expression) from the
- * uncompiled pattern *P_PTR (which ends at PEND). We assume the
- * starting character is in `P[-2]'. (`P[-1]' is the character `-'.)
- * Then we set the translation of all bits between the starting and
- * ending characters (inclusive) in the compiled pattern B.
- *
- * Return an error code.
- *
- * We use these short variable names so we can use the same macros as
- * `regex_compile' itself.
- */
-
-#ifdef __STDC__
-static reg_errcode_t
-compile_range (struct re_pattern_buffer * rxb, rx_Bitset cs,
- __const__ char ** p_ptr, __const__ char * pend,
- unsigned char * translate, reg_syntax_t syntax,
- rx_Bitset inv_tr, char * valid_inv_tr)
-#else
-static reg_errcode_t
-compile_range (rxb, cs, p_ptr, pend, translate, syntax, inv_tr, valid_inv_tr)
- struct re_pattern_buffer * rxb;
- rx_Bitset cs;
- __const__ char ** p_ptr;
- __const__ char * pend;
- unsigned char * translate;
- reg_syntax_t syntax;
- rx_Bitset inv_tr;
- char * valid_inv_tr;
-#endif
-{
- unsigned this_char;
-
- __const__ char *p = *p_ptr;
-
- unsigned char range_end;
- unsigned char range_start = TRANSLATE(p[-2]);
-
- if (p == pend)
- return REG_ERANGE;
-
- PATFETCH (range_end);
-
- (*p_ptr)++;
-
- if (range_start > range_end)
- return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
-
- for (this_char = range_start; this_char <= range_end; this_char++)
- {
- rx_Bitset it =
- inverse_translation (rxb, valid_inv_tr, inv_tr, translate, this_char);
- rx_bitset_union (rxb->rx.local_cset_size, cs, it);
- }
-
- return REG_NOERROR;
-}
-
-
-/* This searches a regexp for backreference side effects.
- * It fills in the array OUT with 1 at the index of every register pair
- * referenced by a backreference.
- *
- * This is used to help optimize patterns for searching. The information is
- * useful because, if the caller doesn't want register values, backreferenced
- * registers are the only registers for which we need rx_backtrack.
- */
-
-#ifdef __STDC__
-static void
-find_backrefs (char * out, struct rexp_node * rexp,
- struct re_se_params * params)
-#else
-static void
-find_backrefs (out, rexp, params)
- char * out;
- struct rexp_node * rexp;
- struct re_se_params * params;
-#endif
-{
- if (rexp)
- switch (rexp->type)
- {
- case r_cset:
- case r_data:
- return;
- case r_alternate:
- case r_concat:
- case r_opt:
- case r_star:
- case r_2phase_star:
- find_backrefs (out, rexp->params.pair.left, params);
- find_backrefs (out, rexp->params.pair.right, params);
- return;
- case r_side_effect:
- if ( ((long)rexp->params.side_effect >= 0)
- && (params [(long)rexp->params.side_effect].se == re_se_backref))
- out[ params [(long)rexp->params.side_effect].op1] = 1;
- return;
- }
-}
-
-
-
-/* Returns 0 unless the pattern can match the empty string. */
-
-#ifdef __STDC__
-static int
-compute_fastset (struct re_pattern_buffer * rxb, struct rexp_node * rexp)
-#else
-static int
-compute_fastset (rxb, rexp)
- struct re_pattern_buffer * rxb;
- struct rexp_node * rexp;
-#endif
-{
- if (!rexp)
- return 1;
- switch (rexp->type)
- {
- case r_data:
- return 1;
- case r_cset:
- {
- rx_bitset_union (rxb->rx.local_cset_size,
- rxb->fastset, rexp->params.cset);
- }
- return 0;
- case r_concat:
- return (compute_fastset (rxb, rexp->params.pair.left)
- && compute_fastset (rxb, rexp->params.pair.right));
- case r_2phase_star:
- compute_fastset (rxb, rexp->params.pair.left);
- /* compute_fastset (rxb, rexp->params.pair.right); nope... */
- return 1;
- case r_alternate:
- return !!(compute_fastset (rxb, rexp->params.pair.left)
- + compute_fastset (rxb, rexp->params.pair.right));
- case r_opt:
- case r_star:
- compute_fastset (rxb, rexp->params.pair.left);
- return 1;
- case r_side_effect:
- return 1;
- }
-
- /* this should never happen */
- return 0;
-}
-
-
-/* returns
- * 1 -- yes, definately anchored by the given side effect.
- * 2 -- maybe anchored, maybe the empty string.
- * 0 -- definately not anchored
- * There is simply no other possibility.
- */
-
-#ifdef __STDC__
-static int
-is_anchored (struct rexp_node * rexp, rx_side_effect se)
-#else
-static int
-is_anchored (rexp, se)
- struct rexp_node * rexp;
- rx_side_effect se;
-#endif
-{
- if (!rexp)
- return 2;
- switch (rexp->type)
- {
- case r_cset:
- case r_data:
- return 0;
- case r_concat:
- case r_2phase_star:
- {
- int l = is_anchored (rexp->params.pair.left, se);
- return (l == 2 ? is_anchored (rexp->params.pair.right, se) : l);
- }
- case r_alternate:
- {
- int l = is_anchored (rexp->params.pair.left, se);
- int r = l ? is_anchored (rexp->params.pair.right, se) : 0;
- return MAX (l, r);
- }
- case r_opt:
- case r_star:
- return is_anchored (rexp->params.pair.left, se) ? 2 : 0;
-
- case r_side_effect:
- return ((rexp->params.side_effect == se)
- ? 1 : 2);
- }
-
- /* this should never happen */
- return 0;
-}
-
-
-/* This removes register assignments that aren't required by backreferencing.
- * This can speed up explore_future, especially if it eliminates
- * non-determinism in the superstate NFA.
- *
- * NEEDED is an array of characters, presumably filled in by FIND_BACKREFS.
- * The non-zero elements of the array indicate which register assignments
- * can NOT be removed from the expression.
- */
-
-#ifdef __STDC__
-static struct rexp_node *
-remove_unecessary_side_effects (struct rx * rx, char * needed,
- struct rexp_node * rexp,
- struct re_se_params * params)
-#else
-static struct rexp_node *
-remove_unecessary_side_effects (rx, needed, rexp, params)
- struct rx * rx;
- char * needed;
- struct rexp_node * rexp;
- struct re_se_params * params;
-#endif
-{
- struct rexp_node * l;
- struct rexp_node * r;
- if (!rexp)
- return 0;
- else
- switch (rexp->type)
- {
- case r_cset:
- case r_data:
- return rexp;
- case r_alternate:
- case r_concat:
- case r_2phase_star:
- l = remove_unecessary_side_effects (rx, needed,
- rexp->params.pair.left, params);
- r = remove_unecessary_side_effects (rx, needed,
- rexp->params.pair.right, params);
- if ((l && r) || (rexp->type != r_concat))
- {
- rexp->params.pair.left = l;
- rexp->params.pair.right = r;
- return rexp;
- }
- else
- {
- rexp->params.pair.left = rexp->params.pair.right = 0;
- rx_free_rexp (rx, rexp);
- return l ? l : r;
- }
- case r_opt:
- case r_star:
- l = remove_unecessary_side_effects (rx, needed,
- rexp->params.pair.left, params);
- if (l)
- {
- rexp->params.pair.left = l;
- return rexp;
- }
- else
- {
- rexp->params.pair.left = 0;
- rx_free_rexp (rx, rexp);
- return 0;
- }
- case r_side_effect:
- {
- int se = (long)rexp->params.side_effect;
- if ( (se >= 0)
- && ( ((enum re_side_effects)params[se].se == re_se_lparen)
- || ((enum re_side_effects)params[se].se == re_se_rparen))
- && (params [se].op1 > 0)
- && (!needed [params [se].op1]))
- {
- rx_free_rexp (rx, rexp);
- return 0;
- }
- else
- return rexp;
- }
- }
-
- /* this should never happen */
- return 0;
-}
-
-
-
-#ifdef __STDC__
-static int
-pointless_if_repeated (struct rexp_node * node, struct re_se_params * params)
-#else
-static int
-pointless_if_repeated (node, params)
- struct rexp_node * node;
- struct re_se_params * params;
-#endif
-{
- if (!node)
- return 1;
- switch (node->type)
- {
- case r_cset:
- return 0;
- case r_alternate:
- case r_concat:
- case r_2phase_star:
- return (pointless_if_repeated (node->params.pair.left, params)
- && pointless_if_repeated (node->params.pair.right, params));
- case r_opt:
- case r_star:
- return pointless_if_repeated (node->params.pair.left, params);
- case r_side_effect:
- switch (((long)node->params.side_effect < 0)
- ? (enum re_side_effects)node->params.side_effect
- : (enum re_side_effects)params[(long)node->params.side_effect].se)
- {
- case re_se_try:
- case re_se_at_dot:
- case re_se_begbuf:
- case re_se_hat:
- case re_se_wordbeg:
- case re_se_wordbound:
- case re_se_notwordbound:
- case re_se_wordend:
- case re_se_endbuf:
- case re_se_dollar:
- case re_se_fail:
- case re_se_win:
- return 1;
- case re_se_lparen:
- case re_se_rparen:
- case re_se_iter:
- case re_se_end_iter:
- case re_se_syntax:
- case re_se_not_syntax:
- case re_se_backref:
- return 0;
- }
- case r_data:
- default:
- return 0;
- }
-}
-
-
-
-#ifdef __STDC__
-static int
-registers_on_stack (struct re_pattern_buffer * rxb,
- struct rexp_node * rexp, int in_danger,
- struct re_se_params * params)
-#else
-static int
-registers_on_stack (rxb, rexp, in_danger, params)
- struct re_pattern_buffer * rxb;
- struct rexp_node * rexp;
- int in_danger;
- struct re_se_params * params;
-#endif
-{
- if (!rexp)
- return 0;
- else
- switch (rexp->type)
- {
- case r_cset:
- case r_data:
- return 0;
- case r_alternate:
- case r_concat:
- return ( registers_on_stack (rxb, rexp->params.pair.left,
- in_danger, params)
- || (registers_on_stack
- (rxb, rexp->params.pair.right,
- in_danger, params)));
- case r_opt:
- return registers_on_stack (rxb, rexp->params.pair.left, 0, params);
- case r_star:
- return registers_on_stack (rxb, rexp->params.pair.left, 1, params);
- case r_2phase_star:
- return
- ( registers_on_stack (rxb, rexp->params.pair.left, 1, params)
- || registers_on_stack (rxb, rexp->params.pair.right, 1, params));
- case r_side_effect:
- {
- int se = (long)rexp->params.side_effect;
- if ( in_danger
- && (se >= 0)
- && (params [se].op1 > 0)
- && ( ((enum re_side_effects)params[se].se == re_se_lparen)
- || ((enum re_side_effects)params[se].se == re_se_rparen)))
- return 1;
- else
- return 0;
- }
- }
-
- /* this should never happen */
- return 0;
-}
-
-
-
-static char idempotent_complex_se[] =
-{
-#define RX_WANT_SE_DEFS 1
-#undef RX_DEF_SE
-#undef RX_DEF_CPLX_SE
-#define RX_DEF_SE(IDEM, NAME, VALUE)
-#define RX_DEF_CPLX_SE(IDEM, NAME, VALUE) IDEM,
-#include "rx.h"
-#undef RX_DEF_SE
-#undef RX_DEF_CPLX_SE
-#undef RX_WANT_SE_DEFS
- 23
-};
-
-static char idempotent_se[] =
-{
- 13,
-#define RX_WANT_SE_DEFS 1
-#undef RX_DEF_SE
-#undef RX_DEF_CPLX_SE
-#define RX_DEF_SE(IDEM, NAME, VALUE) IDEM,
-#define RX_DEF_CPLX_SE(IDEM, NAME, VALUE)
-#include "rx.h"
-#undef RX_DEF_SE
-#undef RX_DEF_CPLX_SE
-#undef RX_WANT_SE_DEFS
- 42
-};
-
-
-
-
-#ifdef __STDC__
-static int
-has_any_se (struct rx * rx,
- struct rexp_node * rexp)
-#else
-static int
-has_any_se (rx, rexp)
- struct rx * rx;
- struct rexp_node * rexp;
-#endif
-{
- if (!rexp)
- return 0;
-
- switch (rexp->type)
- {
- case r_cset:
- case r_data:
- return 0;
-
- case r_side_effect:
- return 1;
-
- case r_2phase_star:
- case r_concat:
- case r_alternate:
- return
- ( has_any_se (rx, rexp->params.pair.left)
- || has_any_se (rx, rexp->params.pair.right));
-
- case r_opt:
- case r_star:
- return has_any_se (rx, rexp->params.pair.left);
- }
-
- /* this should never happen */
- return 0;
-}
-
-
-
-/* This must be called AFTER `convert_hard_loops' for a given REXP. */
-#ifdef __STDC__
-static int
-has_non_idempotent_epsilon_path (struct rx * rx,
- struct rexp_node * rexp,
- struct re_se_params * params)
-#else
-static int
-has_non_idempotent_epsilon_path (rx, rexp, params)
- struct rx * rx;
- struct rexp_node * rexp;
- struct re_se_params * params;
-#endif
-{
- if (!rexp)
- return 0;
-
- switch (rexp->type)
- {
- case r_cset:
- case r_data:
- case r_star:
- return 0;
-
- case r_side_effect:
- return
- !((long)rexp->params.side_effect > 0
- ? idempotent_complex_se [ params [(long)rexp->params.side_effect].se ]
- : idempotent_se [-(long)rexp->params.side_effect]);
-
- case r_alternate:
- return
- ( has_non_idempotent_epsilon_path (rx,
- rexp->params.pair.left, params)
- || has_non_idempotent_epsilon_path (rx,
- rexp->params.pair.right, params));
-
- case r_2phase_star:
- case r_concat:
- return
- ( has_non_idempotent_epsilon_path (rx,
- rexp->params.pair.left, params)
- && has_non_idempotent_epsilon_path (rx,
- rexp->params.pair.right, params));
-
- case r_opt:
- return has_non_idempotent_epsilon_path (rx,
- rexp->params.pair.left, params);
- }
-
- /* this should never happen */
- return 0;
-}
-
-
-
-/* This computes rougly what it's name suggests. It can (and does) go wrong
- * in the direction of returning spurious 0 without causing disasters.
- */
-#ifdef __STDC__
-static int
-begins_with_complex_se (struct rx * rx, struct rexp_node * rexp)
-#else
-static int
-begins_with_complex_se (rx, rexp)
- struct rx * rx;
- struct rexp_node * rexp;
-#endif
-{
- if (!rexp)
- return 0;
-
- switch (rexp->type)
- {
- case r_cset:
- case r_data:
- return 0;
-
- case r_side_effect:
- return ((long)rexp->params.side_effect >= 0);
-
- case r_alternate:
- return
- ( begins_with_complex_se (rx, rexp->params.pair.left)
- && begins_with_complex_se (rx, rexp->params.pair.right));
-
-
- case r_concat:
- return has_any_se (rx, rexp->params.pair.left);
- case r_opt:
- case r_star:
- case r_2phase_star:
- return 0;
- }
-
- /* this should never happen */
- return 0;
-}
-
-
-/* This destructively removes some of the re_se_tv side effects from
- * a rexp tree. In particular, during parsing re_se_tv was inserted on the
- * right half of every | to guarantee that posix path preference could be
- * honored. This function removes some which it can be determined aren't
- * needed.
- */
-
-#ifdef __STDC__
-static void
-speed_up_alt (struct rx * rx,
- struct rexp_node * rexp,
- int unposix)
-#else
-static void
-speed_up_alt (rx, rexp, unposix)
- struct rx * rx;
- struct rexp_node * rexp;
- int unposix;
-#endif
-{
- if (!rexp)
- return;
-
- switch (rexp->type)
- {
- case r_cset:
- case r_data:
- case r_side_effect:
- return;
-
- case r_opt:
- case r_star:
- speed_up_alt (rx, rexp->params.pair.left, unposix);
- return;
-
- case r_2phase_star:
- case r_concat:
- speed_up_alt (rx, rexp->params.pair.left, unposix);
- speed_up_alt (rx, rexp->params.pair.right, unposix);
- return;
-
- case r_alternate:
- /* the right child is guaranteed to be (concat re_se_tv <subexp>) */
-
- speed_up_alt (rx, rexp->params.pair.left, unposix);
- speed_up_alt (rx, rexp->params.pair.right->params.pair.right, unposix);
-
- if ( unposix
- || (begins_with_complex_se
- (rx, rexp->params.pair.right->params.pair.right))
- || !( has_any_se (rx, rexp->params.pair.right->params.pair.right)
- || has_any_se (rx, rexp->params.pair.left)))
- {
- struct rexp_node * conc = rexp->params.pair.right;
- rexp->params.pair.right = conc->params.pair.right;
- conc->params.pair.right = 0;
- rx_free_rexp (rx, conc);
- }
- }
-}
-
-
-
-
-
-/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX.
- Returns one of error codes defined in `regex.h', or zero for success.
-
- Assumes the `allocated' (and perhaps `buffer') and `translate'
- fields are set in BUFP on entry.
-
- If it succeeds, results are put in BUFP (if it returns an error, the
- contents of BUFP are undefined):
- `buffer' is the compiled pattern;
- `syntax' is set to SYNTAX;
- `used' is set to the length of the compiled pattern;
- `fastmap_accurate' is set to zero;
- `re_nsub' is set to the number of groups in PATTERN;
- `not_bol' and `not_eol' are set to zero.
-
- The `fastmap' and `newline_anchor' fields are neither
- examined nor set. */
-
-
-
-#ifdef __STDC__
-RX_DECL reg_errcode_t
-rx_compile (__const__ char *pattern, int size,
- reg_syntax_t syntax,
- struct re_pattern_buffer * rxb)
-#else
-RX_DECL reg_errcode_t
-rx_compile (pattern, size, syntax, rxb)
- __const__ char *pattern;
- int size;
- reg_syntax_t syntax;
- struct re_pattern_buffer * rxb;
-#endif
-{
- RX_subset
- inverse_translate [CHAR_SET_SIZE * rx_bitset_numb_subsets(CHAR_SET_SIZE)];
- char
- validate_inv_tr [CHAR_SET_SIZE * rx_bitset_numb_subsets(CHAR_SET_SIZE)];
-
- /* We fetch characters from PATTERN here. Even though PATTERN is
- `char *' (i.e., signed), we declare these variables as unsigned, so
- they can be reliably used as array indices. */
- register unsigned char c, c1;
-
- /* A random tempory spot in PATTERN. */
- __const__ char *p1;
-
- /* Keeps track of unclosed groups. */
- compile_stack_type compile_stack;
-
- /* Points to the current (ending) position in the pattern. */
- __const__ char *p = pattern;
- __const__ char *pend = pattern + size;
-
- /* How to translate the characters in the pattern. */
- unsigned char *translate = (rxb->translate
- ? rxb->translate
- : rx_id_translation);
-
- /* When parsing is done, this will hold the expression tree. */
- struct rexp_node * rexp = 0;
-
- /* In the midst of compilation, this holds onto the regexp
- * first parst while rexp goes on to aquire additional constructs.
- */
- struct rexp_node * orig_rexp = 0;
- struct rexp_node * fewer_side_effects = 0;
-
- /* This and top_expression are saved on the compile stack. */
- struct rexp_node ** top_expression = &rexp;
- struct rexp_node ** last_expression = top_expression;
-
- /* Parameter to `goto append_node' */
- struct rexp_node * append;
-
- /* Counts open-groups as they are encountered. This is the index of the
- * innermost group being compiled.
- */
- regnum_t regnum = 0;
-
- /* Place in the uncompiled pattern (i.e., the {) to
- * which to go back if the interval is invalid.
- */
- __const__ char *beg_interval;
-
- struct re_se_params * params = 0;
- int paramc = 0; /* How many complex side effects so far? */
-
- rx_side_effect side; /* param to `goto add_side_effect' */
-
- bzero (validate_inv_tr, sizeof (validate_inv_tr));
-
- rxb->rx.instruction_table = rx_id_instruction_table;
-
-
- /* Initialize the compile stack. */
- compile_stack.stack = (( compile_stack_elt_t *) malloc ((INIT_COMPILE_STACK_SIZE) * sizeof ( compile_stack_elt_t)));
- if (compile_stack.stack == 0)
- return REG_ESPACE;
-
- compile_stack.size = INIT_COMPILE_STACK_SIZE;
- compile_stack.avail = 0;
-
- /* Initialize the pattern buffer. */
- rxb->rx.cache = &default_cache;
- rxb->syntax = syntax;
- rxb->fastmap_accurate = 0;
- rxb->not_bol = rxb->not_eol = 0;
- rxb->least_subs = 0;
-
- /* Always count groups, whether or not rxb->no_sub is set.
- * The whole pattern is implicitly group 0, so counting begins
- * with 1.
- */
- rxb->re_nsub = 0;
-
-#if !defined (emacs) && !defined (SYNTAX_TABLE)
- /* Initialize the syntax table. */
- init_syntax_once ();
-#endif
-
- /* Loop through the uncompiled pattern until we're at the end. */
- while (p != pend)
- {
- PATFETCH (c);
-
- switch (c)
- {
- case '^':
- {
- if ( /* If at start of pattern, it's an operator. */
- p == pattern + 1
- /* If context independent, it's an operator. */
- || syntax & RE_CONTEXT_INDEP_ANCHORS
- /* Otherwise, depends on what's come before. */
- || at_begline_loc_p (pattern, p, syntax))
- {
- struct rexp_node * n
- = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_hat);
- if (!n)
- return REG_ESPACE;
- append = n;
- goto append_node;
- }
- else
- goto normal_char;
- }
- break;
-
-
- case '$':
- {
- if ( /* If at end of pattern, it's an operator. */
- p == pend
- /* If context independent, it's an operator. */
- || syntax & RE_CONTEXT_INDEP_ANCHORS
- /* Otherwise, depends on what's next. */
- || at_endline_loc_p (p, pend, syntax))
- {
- struct rexp_node * n
- = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_dollar);
- if (!n)
- return REG_ESPACE;
- append = n;
- goto append_node;
- }
- else
- goto normal_char;
- }
- break;
-
-
- case '+':
- case '?':
- if ((syntax & RE_BK_PLUS_QM)
- || (syntax & RE_LIMITED_OPS))
- goto normal_char;
-
- handle_plus:
- case '*':
- /* If there is no previous pattern... */
- if (pointless_if_repeated (*last_expression, params))
- {
- if (syntax & RE_CONTEXT_INVALID_OPS)
- return REG_BADRPT;
- else if (!(syntax & RE_CONTEXT_INDEP_OPS))
- goto normal_char;
- }
-
- {
- /* 1 means zero (many) matches is allowed. */
- char zero_times_ok = 0, many_times_ok = 0;
-
- /* If there is a sequence of repetition chars, collapse it
- down to just one (the right one). We can't combine
- interval operators with these because of, e.g., `a{2}*',
- which should only match an even number of `a's. */
-
- for (;;)
- {
- zero_times_ok |= c != '+';
- many_times_ok |= c != '?';
-
- if (p == pend)
- break;
-
- PATFETCH (c);
-
- if (c == '*'
- || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?')))
- ;
-
- else if (syntax & RE_BK_PLUS_QM && c == '\\')
- {
- if (p == pend) return REG_EESCAPE;
-
- PATFETCH (c1);
- if (!(c1 == '+' || c1 == '?'))
- {
- PATUNFETCH;
- PATUNFETCH;
- break;
- }
-
- c = c1;
- }
- else
- {
- PATUNFETCH;
- break;
- }
-
- /* If we get here, we found another repeat character. */
- }
-
- /* Star, etc. applied to an empty pattern is equivalent
- to an empty pattern. */
- if (!last_expression)
- break;
-
- /* Now we know whether or not zero matches is allowed
- * and also whether or not two or more matches is allowed.
- */
-
- {
- struct rexp_node * inner_exp = *last_expression;
- int need_sync = 0;
-
- if (many_times_ok
- && has_non_idempotent_epsilon_path (&rxb->rx,
- inner_exp, params))
- {
- struct rexp_node * pusher
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)re_se_pushpos);
- struct rexp_node * checker
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)re_se_chkpos);
- struct rexp_node * pushback
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)re_se_pushback);
- rx_Bitset cs = rx_cset (&rxb->rx);
- struct rexp_node * lit_t = rx_mk_r_cset (&rxb->rx, cs);
- struct rexp_node * fake_state
- = rx_mk_r_concat (&rxb->rx, pushback, lit_t);
- struct rexp_node * phase2
- = rx_mk_r_concat (&rxb->rx, checker, fake_state);
- struct rexp_node * popper
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)re_se_poppos);
- struct rexp_node * star
- = rx_mk_r_2phase_star (&rxb->rx, inner_exp, phase2);
- struct rexp_node * a
- = rx_mk_r_concat (&rxb->rx, pusher, star);
- struct rexp_node * whole_thing
- = rx_mk_r_concat (&rxb->rx, a, popper);
- if (!(pusher && star && pushback && lit_t && fake_state
- && lit_t && phase2 && checker && popper
- && a && whole_thing))
- return REG_ESPACE;
- RX_bitset_enjoin (cs, 't');
- *last_expression = whole_thing;
- }
- else
- {
- struct rexp_node * star =
- (many_times_ok ? rx_mk_r_star : rx_mk_r_opt)
- (&rxb->rx, *last_expression);
- if (!star)
- return REG_ESPACE;
- *last_expression = star;
- need_sync = has_any_se (&rxb->rx, *last_expression);
- }
- if (!zero_times_ok)
- {
- struct rexp_node * concat
- = rx_mk_r_concat (&rxb->rx, inner_exp,
- rx_copy_rexp (&rxb->rx,
- *last_expression));
- if (!concat)
- return REG_ESPACE;
- *last_expression = concat;
- }
- if (need_sync)
- {
- int sync_se = paramc;
- params = (params
- ? ((struct re_se_params *)
- realloc (params,
- sizeof (*params) * (1 + paramc)))
- : ((struct re_se_params *)
- malloc (sizeof (*params))));
- if (!params)
- return REG_ESPACE;
- ++paramc;
- params [sync_se].se = re_se_tv;
- side = (rx_side_effect)sync_se;
- goto add_side_effect;
- }
- }
- /* The old regex.c used to optimize `.*\n'.
- * Maybe rx should too?
- */
- }
- break;
-
-
- case '.':
- {
- rx_Bitset cs = rx_cset (&rxb->rx);
- struct rexp_node * n = rx_mk_r_cset (&rxb->rx, cs);
- if (!(cs && n))
- return REG_ESPACE;
-
- rx_bitset_universe (rxb->rx.local_cset_size, cs);
- if (!(rxb->syntax & RE_DOT_NEWLINE))
- RX_bitset_remove (cs, '\n');
- if (!(rxb->syntax & RE_DOT_NOT_NULL))
- RX_bitset_remove (cs, 0);
-
- append = n;
- goto append_node;
- break;
- }
-
-
- case '[':
- if (p == pend) return REG_EBRACK;
- {
- boolean had_char_class = false;
- rx_Bitset cs = rx_cset (&rxb->rx);
- struct rexp_node * node = rx_mk_r_cset (&rxb->rx, cs);
- int is_inverted = *p == '^';
-
- if (!(node && cs))
- return REG_ESPACE;
-
- /* This branch of the switch is normally exited with
- *`goto append_node'
- */
- append = node;
-
- if (is_inverted)
- p++;
-
- /* Remember the first position in the bracket expression. */
- p1 = p;
-
- /* Read in characters and ranges, setting map bits. */
- for (;;)
- {
- if (p == pend) return REG_EBRACK;
-
- PATFETCH (c);
-
- /* \ might escape characters inside [...] and [^...]. */
- if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\')
- {
- if (p == pend) return REG_EESCAPE;
-
- PATFETCH (c1);
- {
- rx_Bitset it = inverse_translation (rxb,
- validate_inv_tr,
- inverse_translate,
- translate,
- c1);
- rx_bitset_union (rxb->rx.local_cset_size, cs, it);
- }
- continue;
- }
-
- /* Could be the end of the bracket expression. If it's
- not (i.e., when the bracket expression is `[]' so
- far), the ']' character bit gets set way below. */
- if (c == ']' && p != p1 + 1)
- goto finalize_class_and_append;
-
- /* Look ahead to see if it's a range when the last thing
- was a character class. */
- if (had_char_class && c == '-' && *p != ']')
- return REG_ERANGE;
-
- /* Look ahead to see if it's a range when the last thing
- was a character: if this is a hyphen not at the
- beginning or the end of a list, then it's the range
- operator. */
- if (c == '-'
- && !(p - 2 >= pattern && p[-2] == '[')
- && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^')
- && *p != ']')
- {
- reg_errcode_t ret
- = compile_range (rxb, cs, &p, pend, translate, syntax,
- inverse_translate, validate_inv_tr);
- if (ret != REG_NOERROR) return ret;
- }
-
- else if (p[0] == '-' && p[1] != ']')
- { /* This handles ranges made up of characters only. */
- reg_errcode_t ret;
-
- /* Move past the `-'. */
- PATFETCH (c1);
-
- ret = compile_range (rxb, cs, &p, pend, translate, syntax,
- inverse_translate, validate_inv_tr);
- if (ret != REG_NOERROR) return ret;
- }
-
- /* See if we're at the beginning of a possible character
- class. */
-
- else if ((syntax & RE_CHAR_CLASSES)
- && (c == '[') && (*p == ':'))
- {
- char str[CHAR_CLASS_MAX_LENGTH + 1];
-
- PATFETCH (c);
- c1 = 0;
-
- /* If pattern is `[[:'. */
- if (p == pend) return REG_EBRACK;
-
- for (;;)
- {
- PATFETCH (c);
- if (c == ':' || c == ']' || p == pend
- || c1 == CHAR_CLASS_MAX_LENGTH)
- break;
- str[c1++] = c;
- }
- str[c1] = '\0';
-
- /* If isn't a word bracketed by `[:' and:`]':
- undo the ending character, the letters, and leave
- the leading `:' and `[' (but set bits for them). */
- if (c == ':' && *p == ']')
- {
- int ch;
- boolean is_alnum = !strcmp (str, "alnum");
- boolean is_alpha = !strcmp (str, "alpha");
- boolean is_blank = !strcmp (str, "blank");
- boolean is_cntrl = !strcmp (str, "cntrl");
- boolean is_digit = !strcmp (str, "digit");
- boolean is_graph = !strcmp (str, "graph");
- boolean is_lower = !strcmp (str, "lower");
- boolean is_print = !strcmp (str, "print");
- boolean is_punct = !strcmp (str, "punct");
- boolean is_space = !strcmp (str, "space");
- boolean is_upper = !strcmp (str, "upper");
- boolean is_xdigit = !strcmp (str, "xdigit");
-
- if (!IS_CHAR_CLASS (str)) return REG_ECTYPE;
-
- /* Throw away the ] at the end of the character
- class. */
- PATFETCH (c);
-
- if (p == pend) return REG_EBRACK;
-
- for (ch = 0; ch < 1 << CHARBITS; ch++)
- {
- if ( (is_alnum && isalnum (ch))
- || (is_alpha && isalpha (ch))
- || (is_blank && isblank (ch))
- || (is_cntrl && iscntrl (ch))
- || (is_digit && isdigit (ch))
- || (is_graph && isgraph (ch))
- || (is_lower && islower (ch))
- || (is_print && isprint (ch))
- || (is_punct && ispunct (ch))
- || (is_space && isspace (ch))
- || (is_upper && isupper (ch))
- || (is_xdigit && isxdigit (ch)))
- {
- rx_Bitset it =
- inverse_translation (rxb,
- validate_inv_tr,
- inverse_translate,
- translate,
- ch);
- rx_bitset_union (rxb->rx.local_cset_size,
- cs, it);
- }
- }
- had_char_class = true;
- }
- else
- {
- c1++;
- while (c1--)
- PATUNFETCH;
- {
- rx_Bitset it =
- inverse_translation (rxb,
- validate_inv_tr,
- inverse_translate,
- translate,
- '[');
- rx_bitset_union (rxb->rx.local_cset_size,
- cs, it);
- }
- {
- rx_Bitset it =
- inverse_translation (rxb,
- validate_inv_tr,
- inverse_translate,
- translate,
- ':');
- rx_bitset_union (rxb->rx.local_cset_size,
- cs, it);
- }
- had_char_class = false;
- }
- }
- else
- {
- had_char_class = false;
- {
- rx_Bitset it = inverse_translation (rxb,
- validate_inv_tr,
- inverse_translate,
- translate,
- c);
- rx_bitset_union (rxb->rx.local_cset_size, cs, it);
- }
- }
- }
-
- finalize_class_and_append:
- if (is_inverted)
- {
- rx_bitset_complement (rxb->rx.local_cset_size, cs);
- if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
- RX_bitset_remove (cs, '\n');
- }
- goto append_node;
- }
- break;
-
-
- case '(':
- if (syntax & RE_NO_BK_PARENS)
- goto handle_open;
- else
- goto normal_char;
-
-
- case ')':
- if (syntax & RE_NO_BK_PARENS)
- goto handle_close;
- else
- goto normal_char;
-
-
- case '\n':
- if (syntax & RE_NEWLINE_ALT)
- goto handle_alt;
- else
- goto normal_char;
-
-
- case '|':
- if (syntax & RE_NO_BK_VBAR)
- goto handle_alt;
- else
- goto normal_char;
-
-
- case '{':
- if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
- goto handle_interval;
- else
- goto normal_char;
-
-
- case '\\':
- if (p == pend) return REG_EESCAPE;
-
- /* Do not translate the character after the \, so that we can
- distinguish, e.g., \B from \b, even if we normally would
- translate, e.g., B to b. */
- PATFETCH_RAW (c);
-
- switch (c)
- {
- case '(':
- if (syntax & RE_NO_BK_PARENS)
- goto normal_backslash;
-
- handle_open:
- rxb->re_nsub++;
- regnum++;
- if (COMPILE_STACK_FULL)
- {
- ((compile_stack.stack) =
- (compile_stack_elt_t *) realloc (compile_stack.stack, ( compile_stack.size << 1) * sizeof (
- compile_stack_elt_t)));
- if (compile_stack.stack == 0) return REG_ESPACE;
-
- compile_stack.size <<= 1;
- }
-
- if (*last_expression)
- {
- struct rexp_node * concat
- = rx_mk_r_concat (&rxb->rx, *last_expression, 0);
- if (!concat)
- return REG_ESPACE;
- *last_expression = concat;
- last_expression = &concat->params.pair.right;
- }
-
- /*
- * These are the values to restore when we hit end of this
- * group.
- */
- COMPILE_STACK_TOP.top_expression = top_expression;
- COMPILE_STACK_TOP.last_expression = last_expression;
- COMPILE_STACK_TOP.regnum = regnum;
-
- compile_stack.avail++;
-
- top_expression = last_expression;
- break;
-
-
- case ')':
- if (syntax & RE_NO_BK_PARENS) goto normal_backslash;
-
- handle_close:
- /* See similar code for backslashed left paren above. */
- if (COMPILE_STACK_EMPTY)
- if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
- goto normal_char;
- else
- return REG_ERPAREN;
-
- /* Since we just checked for an empty stack above, this
- ``can't happen''. */
-
- {
- /* We don't just want to restore into `regnum', because
- later groups should continue to be numbered higher,
- as in `(ab)c(de)' -- the second group is #2. */
- regnum_t this_group_regnum;
- struct rexp_node ** inner = top_expression;
-
- compile_stack.avail--;
- top_expression = COMPILE_STACK_TOP.top_expression;
- last_expression = COMPILE_STACK_TOP.last_expression;
- this_group_regnum = COMPILE_STACK_TOP.regnum;
- {
- int left_se = paramc;
- int right_se = paramc + 1;
-
- params = (params
- ? ((struct re_se_params *)
- realloc (params,
- (paramc + 2) * sizeof (params[0])))
- : ((struct re_se_params *)
- malloc (2 * sizeof (params[0]))));
- if (!params)
- return REG_ESPACE;
- paramc += 2;
-
- params[left_se].se = re_se_lparen;
- params[left_se].op1 = this_group_regnum;
- params[right_se].se = re_se_rparen;
- params[right_se].op1 = this_group_regnum;
- {
- struct rexp_node * left
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)left_se);
- struct rexp_node * right
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)right_se);
- struct rexp_node * c1
- = (*inner
- ? rx_mk_r_concat (&rxb->rx, left, *inner) : left);
- struct rexp_node * c2
- = rx_mk_r_concat (&rxb->rx, c1, right);
- if (!(left && right && c1 && c2))
- return REG_ESPACE;
- *inner = c2;
- }
- }
- break;
- }
-
- case '|': /* `\|'. */
- if ((syntax & RE_LIMITED_OPS) || (syntax & RE_NO_BK_VBAR))
- goto normal_backslash;
- handle_alt:
- if (syntax & RE_LIMITED_OPS)
- goto normal_char;
-
- {
- struct rexp_node * alt
- = rx_mk_r_alternate (&rxb->rx, *top_expression, 0);
- if (!alt)
- return REG_ESPACE;
- *top_expression = alt;
- last_expression = &alt->params.pair.right;
- {
- int sync_se = paramc;
-
- params = (params
- ? ((struct re_se_params *)
- realloc (params,
- (paramc + 1) * sizeof (params[0])))
- : ((struct re_se_params *)
- malloc (sizeof (params[0]))));
- if (!params)
- return REG_ESPACE;
- ++paramc;
-
- params[sync_se].se = re_se_tv;
- {
- struct rexp_node * sync
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)sync_se);
- struct rexp_node * conc
- = rx_mk_r_concat (&rxb->rx, sync, 0);
-
- if (!sync || !conc)
- return REG_ESPACE;
-
- *last_expression = conc;
- last_expression = &conc->params.pair.right;
- }
- }
- }
- break;
-
-
- case '{':
- /* If \{ is a literal. */
- if (!(syntax & RE_INTERVALS)
- /* If we're at `\{' and it's not the open-interval
- operator. */
- || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
- || (p - 2 == pattern && p == pend))
- goto normal_backslash;
-
- handle_interval:
- {
- /* If got here, then the syntax allows intervals. */
-
- /* At least (most) this many matches must be made. */
- int lower_bound = -1, upper_bound = -1;
-
- beg_interval = p - 1;
-
- if (p == pend)
- {
- if (syntax & RE_NO_BK_BRACES)
- goto unfetch_interval;
- else
- return REG_EBRACE;
- }
-
- GET_UNSIGNED_NUMBER (lower_bound);
-
- if (c == ',')
- {
- GET_UNSIGNED_NUMBER (upper_bound);
- if (upper_bound < 0) upper_bound = RE_DUP_MAX;
- }
- else
- /* Interval such as `{1}' => match exactly once. */
- upper_bound = lower_bound;
-
- if (lower_bound < 0 || upper_bound > RE_DUP_MAX
- || lower_bound > upper_bound)
- {
- if (syntax & RE_NO_BK_BRACES)
- goto unfetch_interval;
- else
- return REG_BADBR;
- }
-
- if (!(syntax & RE_NO_BK_BRACES))
- {
- if (c != '\\') return REG_EBRACE;
- PATFETCH (c);
- }
-
- if (c != '}')
- {
- if (syntax & RE_NO_BK_BRACES)
- goto unfetch_interval;
- else
- return REG_BADBR;
- }
-
- /* We just parsed a valid interval. */
-
- /* If it's invalid to have no preceding re. */
- if (pointless_if_repeated (*last_expression, params))
- {
- if (syntax & RE_CONTEXT_INVALID_OPS)
- return REG_BADRPT;
- else if (!(syntax & RE_CONTEXT_INDEP_OPS))
- goto unfetch_interval;
- /* was: else laststart = b; */
- }
-
- /* If the upper bound is zero, don't want to iterate
- * at all.
- */
- if (upper_bound == 0)
- {
- if (*last_expression)
- {
- rx_free_rexp (&rxb->rx, *last_expression);
- *last_expression = 0;
- }
- }
- else
- /* Otherwise, we have a nontrivial interval. */
- {
- int iter_se = paramc;
- int end_se = paramc + 1;
- params = (params
- ? ((struct re_se_params *)
- realloc (params,
- sizeof (*params) * (2 + paramc)))
- : ((struct re_se_params *)
- malloc (2 * sizeof (*params))));
- if (!params)
- return REG_ESPACE;
- paramc += 2;
- params [iter_se].se = re_se_iter;
- params [iter_se].op1 = lower_bound;
- params[iter_se].op2 = upper_bound;
-
- params[end_se].se = re_se_end_iter;
- params[end_se].op1 = lower_bound;
- params[end_se].op2 = upper_bound;
- {
- struct rexp_node * push0
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)re_se_push0);
- struct rexp_node * start_one_iter
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)iter_se);
- struct rexp_node * phase1
- = rx_mk_r_concat (&rxb->rx, start_one_iter,
- *last_expression);
- struct rexp_node * pushback
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)re_se_pushback);
- rx_Bitset cs = rx_cset (&rxb->rx);
- struct rexp_node * lit_t
- = rx_mk_r_cset (&rxb->rx, cs);
- struct rexp_node * phase2
- = rx_mk_r_concat (&rxb->rx, pushback, lit_t);
- struct rexp_node * loop
- = rx_mk_r_2phase_star (&rxb->rx, phase1, phase2);
- struct rexp_node * push_n_loop
- = rx_mk_r_concat (&rxb->rx, push0, loop);
- struct rexp_node * final_test
- = rx_mk_r_side_effect (&rxb->rx,
- (rx_side_effect)end_se);
- struct rexp_node * full_exp
- = rx_mk_r_concat (&rxb->rx, push_n_loop, final_test);
-
- if (!(push0 && start_one_iter && phase1
- && pushback && lit_t && phase2
- && loop && push_n_loop && final_test && full_exp))
- return REG_ESPACE;
-
- RX_bitset_enjoin(cs, 't');
-
- *last_expression = full_exp;
- }
- }
- beg_interval = 0;
- }
- break;
-
- unfetch_interval:
- /* If an invalid interval, match the characters as literals. */
- p = beg_interval;
- beg_interval = NULL;
-
- /* normal_char and normal_backslash need `c'. */
- PATFETCH (c);
-
- if (!(syntax & RE_NO_BK_BRACES))
- {
- if (p > pattern && p[-1] == '\\')
- goto normal_backslash;
- }
- goto normal_char;
-
-#ifdef emacs
- /* There is no way to specify the before_dot and after_dot
- operators. rms says this is ok. --karl */
- case '=':
- side = at_dot;
- goto add_side_effect;
- break;
-
- case 's':
- case 'S':
- {
- rx_Bitset cs = cset (&rxb->rx);
- struct rexp_node * set = rx_mk_r_cset (&rxb->rx, cs);
- if (!(cs && set))
- return REG_ESPACE;
- if (c == 'S')
- rx_bitset_universe (rxb->rx.local_cset_size, cs);
-
- PATFETCH (c);
- {
- int x;
- char code = syntax_spec_code (c);
- for (x = 0; x < 256; ++x)
- {
-
- if (SYNTAX (x) & code)
- {
- rx_Bitset it =
- inverse_translation (rxb, validate_inv_tr,
- inverse_translate,
- translate, x);
- rx_bitset_xor (rxb->rx.local_cset_size, cs, it);
- }
- }
- }
- goto append_node;
- }
- break;
-#endif /* emacs */
-
-
- case 'w':
- case 'W':
- {
- rx_Bitset cs = rx_cset (&rxb->rx);
- struct rexp_node * n = (cs ? rx_mk_r_cset (&rxb->rx, cs) : 0);
- if (!(cs && n))
- return REG_ESPACE;
- if (c == 'W')
- rx_bitset_universe (rxb->rx.local_cset_size ,cs);
- {
- int x;
- for (x = rxb->rx.local_cset_size - 1; x > 0; --x)
- if (re_syntax_table[x] & Sword)
- RX_bitset_toggle (cs, x);
- }
- append = n;
- goto append_node;
- }
- break;
-
-/* With a little extra work, some of these side effects could be optimized
- * away (basicly by looking at what we already know about the surrounding
- * chars).
- */
- case '<':
- side = (rx_side_effect)re_se_wordbeg;
- goto add_side_effect;
- break;
-
- case '>':
- side = (rx_side_effect)re_se_wordend;
- goto add_side_effect;
- break;
-
- case 'b':
- side = (rx_side_effect)re_se_wordbound;
- goto add_side_effect;
- break;
-
- case 'B':
- side = (rx_side_effect)re_se_notwordbound;
- goto add_side_effect;
- break;
-
- case '`':
- side = (rx_side_effect)re_se_begbuf;
- goto add_side_effect;
- break;
-
- case '\'':
- side = (rx_side_effect)re_se_endbuf;
- goto add_side_effect;
- break;
-
- add_side_effect:
- {
- struct rexp_node * se
- = rx_mk_r_side_effect (&rxb->rx, side);
- if (!se)
- return REG_ESPACE;
- append = se;
- goto append_node;
- }
- break;
-
- case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
- if (syntax & RE_NO_BK_REFS)
- goto normal_char;
-
- c1 = c - '0';
-
- if (c1 > regnum)
- return REG_ESUBREG;
-
- /* Can't back reference to a subexpression if inside of it. */
- if (group_in_compile_stack (compile_stack, c1))
- return REG_ESUBREG;
-
- {
- int backref_se = paramc;
- params = (params
- ? ((struct re_se_params *)
- realloc (params,
- sizeof (*params) * (1 + paramc)))
- : ((struct re_se_params *)
- malloc (sizeof (*params))));
- if (!params)
- return REG_ESPACE;
- ++paramc;
- params[backref_se].se = re_se_backref;
- params[backref_se].op1 = c1;
- side = (rx_side_effect)backref_se;
- goto add_side_effect;
- }
- break;
-
- case '+':
- case '?':
- if (syntax & RE_BK_PLUS_QM)
- goto handle_plus;
- else
- goto normal_backslash;
-
- default:
- normal_backslash:
- /* You might think it would be useful for \ to mean
- not to translate; but if we don't translate it
- it will never match anything. */
- c = TRANSLATE (c);
- goto normal_char;
- }
- break;
-
-
- default:
- /* Expects the character in `c'. */
- normal_char:
- {
- rx_Bitset cs = rx_cset(&rxb->rx);
- struct rexp_node * match = rx_mk_r_cset (&rxb->rx, cs);
- rx_Bitset it;
- if (!(cs && match))
- return REG_ESPACE;
- it = inverse_translation (rxb, validate_inv_tr,
- inverse_translate, translate, c);
- rx_bitset_union (CHAR_SET_SIZE, cs, it);
- append = match;
-
- append_node:
- /* This genericly appends the rexp APPEND to *LAST_EXPRESSION
- * and then parses the next character normally.
- */
- if (*last_expression)
- {
- struct rexp_node * concat
- = rx_mk_r_concat (&rxb->rx, *last_expression, append);
- if (!concat)
- return REG_ESPACE;
- *last_expression = concat;
- last_expression = &concat->params.pair.right;
- }
- else
- *last_expression = append;
- }
- } /* switch (c) */
- } /* while p != pend */
-
-
- {
- int win_se = paramc;
- params = (params
- ? ((struct re_se_params *)
- realloc (params,
- sizeof (*params) * (1 + paramc)))
- : ((struct re_se_params *)
- malloc (sizeof (*params))));
- if (!params)
- return REG_ESPACE;
- ++paramc;
- params[win_se].se = re_se_win;
- {
- struct rexp_node * se
- = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)win_se);
- struct rexp_node * concat
- = rx_mk_r_concat (&rxb->rx, rexp, se);
- if (!(se && concat))
- return REG_ESPACE;
- rexp = concat;
- }
- }
-
-
- /* Through the pattern now. */
-
- if (!COMPILE_STACK_EMPTY)
- return REG_EPAREN;
-
- free (compile_stack.stack);
-
- orig_rexp = rexp;
-#ifdef RX_DEBUG
- if (rx_debug_compile)
- {
- dbug_rxb = rxb;
- fputs ("\n\nCompiling ", stdout);
- fwrite (pattern, 1, size, stdout);
- fputs (":\n", stdout);
- rxb->se_params = params;
- print_rexp (&rxb->rx, orig_rexp, 2, re_seprint, stdout);
- }
-#endif
- {
- rx_Bitset cs = rx_cset(&rxb->rx);
- rx_Bitset cs2 = rx_cset(&rxb->rx);
- char * se_map = (char *) alloca (paramc);
- struct rexp_node * new_rexp = 0;
-
-
- bzero (se_map, paramc);
- find_backrefs (se_map, rexp, params);
- fewer_side_effects =
- remove_unecessary_side_effects (&rxb->rx, se_map,
- rx_copy_rexp (&rxb->rx, rexp), params);
-
- speed_up_alt (&rxb->rx, rexp, 0);
- speed_up_alt (&rxb->rx, fewer_side_effects, 1);
-
- {
- char * syntax_parens = rxb->syntax_parens;
- if (syntax_parens == (char *)0x1)
- rexp = remove_unecessary_side_effects
- (&rxb->rx, se_map, rexp, params);
- else if (syntax_parens)
- {
- int x;
- for (x = 0; x < paramc; ++x)
- if (( (params[x].se == re_se_lparen)
- || (params[x].se == re_se_rparen))
- && (!syntax_parens [params[x].op1]))
- se_map [x] = 1;
- rexp = remove_unecessary_side_effects
- (&rxb->rx, se_map, rexp, params);
- }
- }
-
- /* At least one more optimization would be nice to have here but i ran out
- * of time. The idea would be to delay side effects.
- * For examle, `(abc)' is the same thing as `abc()' except that the
- * left paren is offset by 3 (which we know at compile time).
- * (In this comment, write that second pattern `abc(:3:)'
- * where `(:3:' is a syntactic unit.)
- *
- * Trickier: `(abc|defg)' is the same as `(abc(:3:|defg(:4:))'
- * (The paren nesting may be hard to follow -- that's an alternation
- * of `abc(:3:' and `defg(:4:' inside (purely syntactic) parens
- * followed by the closing paren from the original expression.)
- *
- * Neither the expression tree representation nor the the nfa make
- * this very easy to write. :(
- */
-
- /* What we compile is different than what the parser returns.
- * Suppose the parser returns expression R.
- * Let R' be R with unnecessary register assignments removed
- * (see REMOVE_UNECESSARY_SIDE_EFFECTS, above).
- *
- * What we will compile is the expression:
- *
- * m{try}R{win}\|s{try}R'{win}
- *
- * {try} and {win} denote side effect epsilons (see EXPLORE_FUTURE).
- *
- * When trying a match, we insert an `m' at the beginning of the
- * string if the user wants registers to be filled, `s' if not.
- */
- new_rexp =
- rx_mk_r_alternate
- (&rxb->rx,
- rx_mk_r_concat (&rxb->rx, rx_mk_r_cset (&rxb->rx, cs2), rexp),
- rx_mk_r_concat (&rxb->rx,
- rx_mk_r_cset (&rxb->rx, cs), fewer_side_effects));
-
- if (!(new_rexp && cs && cs2))
- return REG_ESPACE;
- RX_bitset_enjoin (cs2, '\0'); /* prefixed to the rexp used for matching. */
- RX_bitset_enjoin (cs, '\1'); /* prefixed to the rexp used for searching. */
- rexp = new_rexp;
- }
-
-#ifdef RX_DEBUG
- if (rx_debug_compile)
- {
- fputs ("\n...which is compiled as:\n", stdout);
- print_rexp (&rxb->rx, rexp, 2, re_seprint, stdout);
- }
-#endif
- {
- struct rx_nfa_state *start = 0;
- struct rx_nfa_state *end = 0;
-
- if (!rx_build_nfa (&rxb->rx, rexp, &start, &end))
- return REG_ESPACE; /* */
- else
- {
- void * mem = (void *)rxb->buffer;
- unsigned long size = rxb->allocated;
- int start_id;
- char * perm_mem;
- int iterator_size = paramc * sizeof (params[0]);
-
- end->is_final = 1;
- start->is_start = 1;
- rx_name_nfa_states (&rxb->rx);
- start_id = start->id;
-#ifdef RX_DEBUG
- if (rx_debug_compile)
- {
- fputs ("...giving the NFA: \n", stdout);
- dbug_rxb = rxb;
- print_nfa (&rxb->rx, rxb->rx.nfa_states, re_seprint, stdout);
- }
-#endif
- if (!rx_eclose_nfa (&rxb->rx))
- return REG_ESPACE;
- else
- {
- rx_delete_epsilon_transitions (&rxb->rx);
-
- /* For compatability reasons, we need to shove the
- * compiled nfa into one chunk of malloced memory.
- */
- rxb->rx.reserved = ( sizeof (params[0]) * paramc
- + rx_sizeof_bitset (rxb->rx.local_cset_size));
-#ifdef RX_DEBUG
- if (rx_debug_compile)
- {
- dbug_rxb = rxb;
- fputs ("...which cooks down (uncompactified) to: \n", stdout);
- print_nfa (&rxb->rx, rxb->rx.nfa_states, re_seprint, stdout);
- }
-#endif
- if (!rx_compactify_nfa (&rxb->rx, &mem, &size))
- return REG_ESPACE;
- rxb->buffer = mem;
- rxb->allocated = size;
- rxb->rx.buffer = mem;
- rxb->rx.allocated = size;
- perm_mem = ((char *)rxb->rx.buffer
- + rxb->rx.allocated - rxb->rx.reserved);
- rxb->se_params = ((struct re_se_params *)perm_mem);
- bcopy (params, rxb->se_params, iterator_size);
- perm_mem += iterator_size;
- rxb->fastset = (rx_Bitset) perm_mem;
- rxb->start = rx_id_to_nfa_state (&rxb->rx, start_id);
- }
- rx_bitset_null (rxb->rx.local_cset_size, rxb->fastset);
- rxb->can_match_empty = compute_fastset (rxb, orig_rexp);
- rxb->match_regs_on_stack =
- registers_on_stack (rxb, orig_rexp, 0, params);
- rxb->search_regs_on_stack =
- registers_on_stack (rxb, fewer_side_effects, 0, params);
- if (rxb->can_match_empty)
- rx_bitset_universe (rxb->rx.local_cset_size, rxb->fastset);
- rxb->is_anchored = is_anchored (orig_rexp, (rx_side_effect) re_se_hat);
- rxb->begbuf_only = is_anchored (orig_rexp,
- (rx_side_effect) re_se_begbuf);
- }
- rx_free_rexp (&rxb->rx, rexp);
- if (params)
- free (params);
-#ifdef RX_DEBUG
- if (rx_debug_compile)
- {
- dbug_rxb = rxb;
- fputs ("...which cooks down to: \n", stdout);
- print_nfa (&rxb->rx, rxb->rx.nfa_states, re_seprint, stdout);
- }
-#endif
- }
- return REG_NOERROR;
-}
-
-
-
-/* This table gives an error message for each of the error codes listed
- in regex.h. Obviously the order here has to be same as there. */
-
-__const__ char * rx_error_msg[] =
-{ 0, /* REG_NOERROR */
- "No match", /* REG_NOMATCH */
- "Invalid regular expression", /* REG_BADPAT */
- "Invalid collation character", /* REG_ECOLLATE */
- "Invalid character class name", /* REG_ECTYPE */
- "Trailing backslash", /* REG_EESCAPE */
- "Invalid back reference", /* REG_ESUBREG */
- "Unmatched [ or [^", /* REG_EBRACK */
- "Unmatched ( or \\(", /* REG_EPAREN */
- "Unmatched \\{", /* REG_EBRACE */
- "Invalid content of \\{\\}", /* REG_BADBR */
- "Invalid range end", /* REG_ERANGE */
- "Memory exhausted", /* REG_ESPACE */
- "Invalid preceding regular expression", /* REG_BADRPT */
- "Premature end of regular expression", /* REG_EEND */
- "Regular expression too big", /* REG_ESIZE */
- "Unmatched ) or \\)", /* REG_ERPAREN */
-};
-
-
-
-
-char rx_slowmap [256] =
-{
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-
-#ifdef __STDC__
-RX_DECL void
-rx_blow_up_fastmap (struct re_pattern_buffer * rxb)
-#else
-RX_DECL void
-rx_blow_up_fastmap (rxb)
- struct re_pattern_buffer * rxb;
-#endif
-{
- int x;
- for (x = 0; x < 256; ++x) /* &&&& 3.6 % */
- rxb->fastmap [x] = !!RX_bitset_member (rxb->fastset, x);
- rxb->fastmap_accurate = 1;
-}
-
-
-
-
-#if !defined(REGEX_MALLOC) && !defined(__GNUC__)
-#define RE_SEARCH_2_FN inner_re_search_2
-#define RE_S2_QUAL static
-#else
-#define RE_SEARCH_2_FN re_search_2
-#define RE_S2_QUAL
-#endif
-
-struct re_search_2_closure
-{
- __const__ char * string1;
- int size1;
- __const__ char * string2;
- int size2;
-};
-
-
-static __inline__ enum rx_get_burst_return
-re_search_2_get_burst (pos, vclosure, stop)
- struct rx_string_position * pos;
- void * vclosure;
- int stop;
-{
- struct re_search_2_closure * closure;
- closure = (struct re_search_2_closure *)vclosure;
- if (!closure->string2)
- {
- int inset;
-
- inset = pos->pos - pos->string;
- if ((inset < 0) || (inset > closure->size1))
- return rx_get_burst_no_more;
- else
- {
- pos->pos = closure->string1 + inset;
- pos->string = closure->string1;
- pos->size = closure->size1;
- pos->end = ((__const__ unsigned char *)
- MIN(closure->string1 + closure->size1,
- closure->string1 + stop));
- pos->offset = 0;
- return ((pos->pos < pos->end)
- ? rx_get_burst_ok
- : rx_get_burst_no_more);
- }
- }
- else if (!closure->string1)
- {
- int inset;
-
- inset = pos->pos - pos->string;
- pos->pos = closure->string2 + inset;
- pos->string = closure->string2;
- pos->size = closure->size2;
- pos->end = ((__const__ unsigned char *)
- MIN(closure->string2 + closure->size2,
- closure->string2 + stop));
- pos->offset = 0;
- return ((pos->pos < pos->end)
- ? rx_get_burst_ok
- : rx_get_burst_no_more);
- }
- else
- {
- int inset;
-
- inset = pos->pos - pos->string;
- if (inset < closure->size1)
- {
- pos->pos = closure->string1 + inset;
- pos->string = closure->string1;
- pos->size = closure->size1;
- pos->end = ((__const__ unsigned char *)
- MIN(closure->string1 + closure->size1,
- closure->string1 + stop));
- pos->offset = 0;
- return rx_get_burst_ok;
- }
- else
- {
- pos->pos = closure->string2 + inset - closure->size1;
- pos->string = closure->string2;
- pos->size = closure->size2;
- pos->end = ((__const__ unsigned char *)
- MIN(closure->string2 + closure->size2,
- closure->string2 + stop - closure->size1));
- pos->offset = closure->size1;
- return ((pos->pos < pos->end)
- ? rx_get_burst_ok
- : rx_get_burst_no_more);
- }
- }
-}
-
-
-static __inline__ enum rx_back_check_return
-re_search_2_back_check (pos, lparen, rparen, translate, vclosure, stop)
- struct rx_string_position * pos;
- int lparen;
- int rparen;
- unsigned char * translate;
- void * vclosure;
- int stop;
-{
- struct rx_string_position there;
- struct rx_string_position past;
-
- there = *pos;
- there.pos = there.string + lparen - there.offset;
- re_search_2_get_burst (&there, vclosure, stop);
-
- past = *pos;
- past.pos = past.string + rparen - there.offset;
- re_search_2_get_burst (&past, vclosure, stop);
-
- ++pos->pos;
- re_search_2_get_burst (pos, vclosure, stop);
-
- while ( (there.pos != past.pos)
- && (pos->pos != pos->end))
- if (TRANSLATE(*there.pos) != TRANSLATE(*pos->pos))
- return rx_back_check_fail;
- else
- {
- ++there.pos;
- ++pos->pos;
- if (there.pos == there.end)
- re_search_2_get_burst (&there, vclosure, stop);
- if (pos->pos == pos->end)
- re_search_2_get_burst (pos, vclosure, stop);
- }
-
- if (there.pos != past.pos)
- return rx_back_check_fail;
- --pos->pos;
- re_search_2_get_burst (pos, vclosure, stop);
- return rx_back_check_pass;
-}
-
-static __inline__ int
-re_search_2_fetch_char (pos, offset, app_closure, stop)
- struct rx_string_position * pos;
- int offset;
- void * app_closure;
- int stop;
-{
- struct re_search_2_closure * closure;
- closure = (struct re_search_2_closure *)app_closure;
- if (offset == 0)
- return *pos->pos;
- if (pos->pos == pos->end)
- return *closure->string2;
- else
- return *pos->pos;
-}
-
-
-#ifdef __STDC__
-RE_S2_QUAL int
-RE_SEARCH_2_FN (struct re_pattern_buffer *rxb,
- __const__ char * string1, int size1,
- __const__ char * string2, int size2,
- int startpos, int range,
- struct re_registers *regs,
- int stop)
-#else
-RE_S2_QUAL int
-RE_SEARCH_2_FN (rxb,
- string1, size1, string2, size2, startpos, range, regs, stop)
- struct re_pattern_buffer *rxb;
- __const__ char * string1;
- int size1;
- __const__ char * string2;
- int size2;
- int startpos;
- int range;
- struct re_registers *regs;
- int stop;
-#endif
-{
- int answer;
- struct re_search_2_closure closure;
- closure.string1 = string1;
- closure.size1 = size1;
- closure.string2 = string2;
- closure.size2 = size2;
- answer = rx_search (rxb, startpos, range, stop, size1 + size2,
- re_search_2_get_burst,
- re_search_2_back_check,
- re_search_2_fetch_char,
- (void *)&closure,
- regs,
- 0,
- 0);
- switch (answer)
- {
- case rx_search_continuation:
- abort ();
- case rx_search_error:
- return -2;
- case rx_search_soft_fail:
- case rx_search_fail:
- return -1;
- default:
- return answer;
- }
-}
-
-/* Export rx_search to callers outside this file. */
-
-int
-re_rx_search (rxb, startpos, range, stop, total_size,
- get_burst, back_check, fetch_char,
- app_closure, regs, resume_state, save_state)
- struct re_pattern_buffer * rxb;
- int startpos;
- int range;
- int stop;
- int total_size;
- rx_get_burst_fn get_burst;
- rx_back_check_fn back_check;
- rx_fetch_char_fn fetch_char;
- void * app_closure;
- struct re_registers * regs;
- struct rx_search_state * resume_state;
- struct rx_search_state * save_state;
-{
- return rx_search (rxb, startpos, range, stop, total_size,
- get_burst, back_check, fetch_char, app_closure,
- regs, resume_state, save_state);
-}
-
-#if !defined(REGEX_MALLOC) && !defined(__GNUC__)
-#ifdef __STDC__
-int
-re_search_2 (struct re_pattern_buffer *rxb,
- __const__ char * string1, int size1,
- __const__ char * string2, int size2,
- int startpos, int range,
- struct re_registers *regs,
- int stop)
-#else
-int
-re_search_2 (rxb, string1, size1, string2, size2, startpos, range, regs, stop)
- struct re_pattern_buffer *rxb;
- __const__ char * string1;
- int size1;
- __const__ char * string2;
- int size2;
- int startpos;
- int range;
- struct re_registers *regs;
- int stop;
-#endif
-{
- int ret;
- ret = inner_re_search_2 (rxb, string1, size1, string2, size2, startpos,
- range, regs, stop);
- alloca (0);
- return ret;
-}
-#endif
-
-
-/* Like re_search_2, above, but only one string is specified, and
- * doesn't let you say where to stop matching.
- */
-
-#ifdef __STDC__
-int
-re_search (struct re_pattern_buffer * rxb, __const__ char *string,
- int size, int startpos, int range,
- struct re_registers *regs)
-#else
-int
-re_search (rxb, string, size, startpos, range, regs)
- struct re_pattern_buffer * rxb;
- __const__ char * string;
- int size;
- int startpos;
- int range;
- struct re_registers *regs;
-#endif
-{
- return re_search_2 (rxb, 0, 0, string, size, startpos, range, regs, size);
-}
-
-#ifdef __STDC__
-int
-re_match_2 (struct re_pattern_buffer * rxb,
- __const__ char * string1, int size1,
- __const__ char * string2, int size2,
- int pos, struct re_registers *regs, int stop)
-#else
-int
-re_match_2 (rxb, string1, size1, string2, size2, pos, regs, stop)
- struct re_pattern_buffer * rxb;
- __const__ char * string1;
- int size1;
- __const__ char * string2;
- int size2;
- int pos;
- struct re_registers *regs;
- int stop;
-#endif
-{
- struct re_registers some_regs;
- regoff_t start;
- regoff_t end;
- int srch;
- int save = rxb->regs_allocated;
- struct re_registers * regs_to_pass = regs;
-
- if (!regs)
- {
- some_regs.start = &start;
- some_regs.end = &end;
- some_regs.num_regs = 1;
- regs_to_pass = &some_regs;
- rxb->regs_allocated = REGS_FIXED;
- }
-
- srch = re_search_2 (rxb, string1, size1, string2, size2,
- pos, 1, regs_to_pass, stop);
- if (regs_to_pass != regs)
- rxb->regs_allocated = save;
- if (srch < 0)
- return srch;
- return regs_to_pass->end[0] - regs_to_pass->start[0];
-}
-
-/* re_match is like re_match_2 except it takes only a single string. */
-
-#ifdef __STDC__
-int
-re_match (struct re_pattern_buffer * rxb,
- __const__ char * string,
- int size, int pos,
- struct re_registers *regs)
-#else
-int
-re_match (rxb, string, size, pos, regs)
- struct re_pattern_buffer * rxb;
- __const__ char *string;
- int size;
- int pos;
- struct re_registers *regs;
-#endif
-{
- return re_match_2 (rxb, string, size, 0, 0, pos, regs, size);
-}
-
-
-
-/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
- also be assigned to arbitrarily: each pattern buffer stores its own
- syntax, so it can be changed between regex compilations. */
-reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS;
-
-
-/* Specify the precise syntax of regexps for compilation. This provides
- for compatibility for various utilities which historically have
- different, incompatible syntaxes.
-
- The argument SYNTAX is a bit mask comprised of the various bits
- defined in regex.h. We return the old syntax. */
-
-#ifdef __STDC__
-reg_syntax_t
-re_set_syntax (reg_syntax_t syntax)
-#else
-reg_syntax_t
-re_set_syntax (syntax)
- reg_syntax_t syntax;
-#endif
-{
- reg_syntax_t ret = re_syntax_options;
-
- re_syntax_options = syntax;
- return ret;
-}
-
-
-/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
- ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use
- this memory for recording register information. STARTS and ENDS
- must be allocated using the malloc library routine, and must each
- be at least NUM_REGS * sizeof (regoff_t) bytes long.
-
- If NUM_REGS == 0, then subsequent matches should allocate their own
- register data.
-
- Unless this function is called, the first search or match using
- PATTERN_BUFFER will allocate its own register data, without
- freeing the old data. */
-
-#ifdef __STDC__
-void
-re_set_registers (struct re_pattern_buffer *bufp,
- struct re_registers *regs,
- unsigned num_regs,
- regoff_t * starts, regoff_t * ends)
-#else
-void
-re_set_registers (bufp, regs, num_regs, starts, ends)
- struct re_pattern_buffer *bufp;
- struct re_registers *regs;
- unsigned num_regs;
- regoff_t * starts;
- regoff_t * ends;
-#endif
-{
- if (num_regs)
- {
- bufp->regs_allocated = REGS_REALLOCATE;
- regs->num_regs = num_regs;
- regs->start = starts;
- regs->end = ends;
- }
- else
- {
- bufp->regs_allocated = REGS_UNALLOCATED;
- regs->num_regs = 0;
- regs->start = regs->end = (regoff_t) 0;
- }
-}
-
-
-
-
-#ifdef __STDC__
-static int
-cplx_se_sublist_len (struct rx_se_list * list)
-#else
-static int
-cplx_se_sublist_len (list)
- struct rx_se_list * list;
-#endif
-{
- int x = 0;
- while (list)
- {
- if ((long)list->car >= 0)
- ++x;
- list = list->cdr;
- }
- return x;
-}
-
-
-/* For rx->se_list_cmp */
-
-#ifdef __STDC__
-static int
-posix_se_list_order (struct rx * rx,
- struct rx_se_list * a, struct rx_se_list * b)
-#else
-static int
-posix_se_list_order (rx, a, b)
- struct rx * rx;
- struct rx_se_list * a;
- struct rx_se_list * b;
-#endif
-{
- int al = cplx_se_sublist_len (a);
- int bl = cplx_se_sublist_len (b);
-
- if (!al && !bl)
- return ((a == b)
- ? 0
- : ((a < b) ? -1 : 1));
-
- else if (!al)
- return -1;
-
- else if (!bl)
- return 1;
-
- else
- {
- rx_side_effect * av = ((rx_side_effect *)
- alloca (sizeof (rx_side_effect) * (al + 1)));
- rx_side_effect * bv = ((rx_side_effect *)
- alloca (sizeof (rx_side_effect) * (bl + 1)));
- struct rx_se_list * ap = a;
- struct rx_se_list * bp = b;
- int ai, bi;
-
- for (ai = al - 1; ai >= 0; --ai)
- {
- while ((long)ap->car < 0)
- ap = ap->cdr;
- av[ai] = ap->car;
- ap = ap->cdr;
- }
- av[al] = (rx_side_effect)-2;
- for (bi = bl - 1; bi >= 0; --bi)
- {
- while ((long)bp->car < 0)
- bp = bp->cdr;
- bv[bi] = bp->car;
- bp = bp->cdr;
- }
- bv[bl] = (rx_side_effect)-1;
-
- {
- int ret;
- int x = 0;
- while (av[x] == bv[x])
- ++x;
- ret = (((unsigned *)(av[x]) < (unsigned *)(bv[x])) ? -1 : 1);
- return ret;
- }
- }
-}
-
-
-
-
-/* re_compile_pattern is the GNU regular expression compiler: it
- compiles PATTERN (of length SIZE) and puts the result in RXB.
- Returns 0 if the pattern was valid, otherwise an error string.
-
- Assumes the `allocated' (and perhaps `buffer') and `translate' fields
- are set in RXB on entry.
-
- We call rx_compile to do the actual compilation. */
-
-#ifdef __STDC__
-__const__ char *
-re_compile_pattern (__const__ char *pattern,
- int length,
- struct re_pattern_buffer * rxb)
-#else
-__const__ char *
-re_compile_pattern (pattern, length, rxb)
- __const__ char *pattern;
- int length;
- struct re_pattern_buffer * rxb;
-#endif
-{
- reg_errcode_t ret;
-
- /* GNU code is written to assume at least RE_NREGS registers will be set
- (and at least one extra will be -1). */
- rxb->regs_allocated = REGS_UNALLOCATED;
-
- /* And GNU code determines whether or not to get register information
- by passing null for the REGS argument to re_match, etc., not by
- setting no_sub. */
- rxb->no_sub = 0;
-
- rxb->rx.local_cset_size = 256;
-
- /* Match anchors at newline. */
- rxb->newline_anchor = 1;
-
- rxb->re_nsub = 0;
- rxb->start = 0;
- rxb->se_params = 0;
- rxb->rx.nodec = 0;
- rxb->rx.epsnodec = 0;
- rxb->rx.instruction_table = 0;
- rxb->rx.nfa_states = 0;
- rxb->rx.se_list_cmp = posix_se_list_order;
- rxb->rx.start_set = 0;
-
- ret = rx_compile (pattern, length, re_syntax_options, rxb);
- alloca (0);
- return rx_error_msg[(int) ret];
-}
-
-
-
-#ifdef __STDC__
-int
-re_compile_fastmap (struct re_pattern_buffer * rxb)
-#else
-int
-re_compile_fastmap (rxb)
- struct re_pattern_buffer * rxb;
-#endif
-{
- rx_blow_up_fastmap (rxb);
- return 0;
-}
-
-
-
-
-#if !defined(BSD) || (BSD < 199306)
-/* Entry points compatible with 4.2 BSD regex library. We don't define
- them if this is an Emacs or POSIX compilation. */
-
-#if (!defined (emacs) && !defined (_POSIX_SOURCE)) || defined(USE_BSD_REGEX)
-
-/* BSD has one and only one pattern buffer. */
-static struct re_pattern_buffer rx_comp_buf;
-
-#ifdef __STDC__
-char *
-re_comp (__const__ char *s)
-#else
-char *
-re_comp (s)
- __const__ char *s;
-#endif
-{
- reg_errcode_t ret;
-
- if (!s || (*s == '\0'))
- {
- if (!rx_comp_buf.buffer)
- return "No previous regular expression";
- return 0;
- }
-
- if (!rx_comp_buf.fastmap)
- {
- rx_comp_buf.fastmap = (char *) malloc (1 << CHARBITS);
- if (!rx_comp_buf.fastmap)
- return "Memory exhausted";
- }
-
- /* Since `rx_exec' always passes NULL for the `regs' argument, we
- don't need to initialize the pattern buffer fields which affect it. */
-
- /* Match anchors at newlines. */
- rx_comp_buf.newline_anchor = 1;
-
- rx_comp_buf.re_nsub = 0;
- rx_comp_buf.start = 0;
- rx_comp_buf.se_params = 0;
- rx_comp_buf.rx.nodec = 0;
- rx_comp_buf.rx.epsnodec = 0;
- rx_comp_buf.rx.instruction_table = 0;
- rx_comp_buf.rx.nfa_states = 0;
- rx_comp_buf.rx.local_cset_size = 256;
- rx_comp_buf.rx.start = 0;
- rx_comp_buf.rx.se_list_cmp = posix_se_list_order;
- rx_comp_buf.rx.start_set = 0;
-
- ret = rx_compile (s, strlen (s), re_syntax_options, &rx_comp_buf);
- alloca (0);
-
- /* Yes, we're discarding `__const__' here. */
- return (char *) rx_error_msg[(int) ret];
-}
-
-
-#ifdef __STDC__
-int
-re_exec (__const__ char *s)
-#else
-int
-re_exec (s)
- __const__ char *s;
-#endif
-{
- __const__ int len = strlen (s);
- return
- 0 <= re_search (&rx_comp_buf, s, len, 0, len, (struct re_registers *) 0);
-}
-#endif /* not emacs and not _POSIX_SOURCE */
-
-
-
-/* POSIX.2 functions. Don't define these for Emacs. */
-
-#if !defined(emacs)
-
-/* regcomp takes a regular expression as a string and compiles it.
-
- PREG is a regex_t *. We do not expect any fields to be initialized,
- since POSIX says we shouldn't. Thus, we set
-
- `buffer' to the compiled pattern;
- `used' to the length of the compiled pattern;
- `syntax' to RE_SYNTAX_POSIX_EXTENDED if the
- REG_EXTENDED bit in CFLAGS is set; otherwise, to
- RE_SYNTAX_POSIX_BASIC;
- `newline_anchor' to REG_NEWLINE being set in CFLAGS;
- `fastmap' and `fastmap_accurate' to zero;
- `re_nsub' to the number of subexpressions in PATTERN.
-
- PATTERN is the address of the pattern string.
-
- CFLAGS is a series of bits which affect compilation.
-
- If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we
- use POSIX basic syntax.
-
- If REG_NEWLINE is set, then . and [^...] don't match newline.
- Also, regexec will try a match beginning after every newline.
-
- If REG_ICASE is set, then we considers upper- and lowercase
- versions of letters to be equivalent when matching.
-
- If REG_NOSUB is set, then when PREG is passed to regexec, that
- routine will report only success or failure, and nothing about the
- registers.
-
- It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for
- the return codes and their meanings.) */
-
-
-#ifdef __STDC__
-int
-regcomp (regex_t * preg, __const__ char * pattern, int cflags)
-#else
-int
-regcomp (preg, pattern, cflags)
- regex_t * preg;
- __const__ char * pattern;
- int cflags;
-#endif
-{
- reg_errcode_t ret;
- unsigned syntax
- = cflags & REG_EXTENDED ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
-
- /* regex_compile will allocate the space for the compiled pattern. */
- preg->buffer = 0;
- preg->allocated = 0;
-
- preg->fastmap = malloc (256);
- if (!preg->fastmap)
- return REG_ESPACE;
- preg->fastmap_accurate = 0;
-
- if (cflags & REG_ICASE)
- {
- unsigned i;
-
- preg->translate = (unsigned char *) malloc (256);
- if (!preg->translate)
- return (int) REG_ESPACE;
-
- /* Map uppercase characters to corresponding lowercase ones. */
- for (i = 0; i < CHAR_SET_SIZE; i++)
- preg->translate[i] = isupper (i) ? tolower (i) : i;
- }
- else
- preg->translate = 0;
-
- /* If REG_NEWLINE is set, newlines are treated differently. */
- if (cflags & REG_NEWLINE)
- { /* REG_NEWLINE implies neither . nor [^...] match newline. */
- syntax &= ~RE_DOT_NEWLINE;
- syntax |= RE_HAT_LISTS_NOT_NEWLINE;
- /* It also changes the matching behavior. */
- preg->newline_anchor = 1;
- }
- else
- preg->newline_anchor = 0;
-
- preg->no_sub = !!(cflags & REG_NOSUB);
-
- /* POSIX says a null character in the pattern terminates it, so we
- can use strlen here in compiling the pattern. */
- preg->re_nsub = 0;
- preg->start = 0;
- preg->se_params = 0;
- preg->rx.nodec = 0;
- preg->rx.epsnodec = 0;
- preg->rx.instruction_table = 0;
- preg->rx.nfa_states = 0;
- preg->rx.local_cset_size = 256;
- preg->rx.start = 0;
- preg->rx.se_list_cmp = posix_se_list_order;
- preg->rx.start_set = 0;
- ret = rx_compile (pattern, strlen (pattern), syntax, preg);
- alloca (0);
-
- /* POSIX doesn't distinguish between an unmatched open-group and an
- unmatched close-group: both are REG_EPAREN. */
- if (ret == REG_ERPAREN) ret = REG_EPAREN;
-
- return (int) ret;
-}
-
-
-/* regexec searches for a given pattern, specified by PREG, in the
- string STRING.
-
- If NMATCH is zero or REG_NOSUB was set in the cflags argument to
- `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at
- least NMATCH elements, and we set them to the offsets of the
- corresponding matched substrings.
-
- EFLAGS specifies `execution flags' which affect matching: if
- REG_NOTBOL is set, then ^ does not match at the beginning of the
- string; if REG_NOTEOL is set, then $ does not match at the end.
-
- We return 0 if we find a match and REG_NOMATCH if not. */
-
-#ifdef __STDC__
-int
-regexec (__const__ regex_t *preg, __const__ char *string,
- size_t nmatch, regmatch_t pmatch[],
- int eflags)
-#else
-int
-regexec (preg, string, nmatch, pmatch, eflags)
- __const__ regex_t *preg;
- __const__ char *string;
- size_t nmatch;
- regmatch_t pmatch[];
- int eflags;
-#endif
-{
- int ret;
- struct re_registers regs;
- regex_t private_preg;
- int len = strlen (string);
- boolean want_reg_info = !preg->no_sub && nmatch > 0;
-
- private_preg = *preg;
-
- private_preg.not_bol = !!(eflags & REG_NOTBOL);
- private_preg.not_eol = !!(eflags & REG_NOTEOL);
-
- /* The user has told us exactly how many registers to return
- * information about, via `nmatch'. We have to pass that on to the
- * matching routines.
- */
- private_preg.regs_allocated = REGS_FIXED;
-
- if (want_reg_info)
- {
- regs.num_regs = nmatch;
- regs.start = (( regoff_t *) malloc ((nmatch) * sizeof ( regoff_t)));
- regs.end = (( regoff_t *) malloc ((nmatch) * sizeof ( regoff_t)));
- if (regs.start == 0 || regs.end == 0)
- return (int) REG_NOMATCH;
- }
-
- /* Perform the searching operation. */
- ret = re_search (&private_preg,
- string, len,
- /* start: */ 0,
- /* range: */ len,
- want_reg_info ? &regs : (struct re_registers *) 0);
-
- /* Copy the register information to the POSIX structure. */
- if (want_reg_info)
- {
- if (ret >= 0)
- {
- unsigned r;
-
- for (r = 0; r < nmatch; r++)
- {
- pmatch[r].rm_so = regs.start[r];
- pmatch[r].rm_eo = regs.end[r];
- }
- }
-
- /* If we needed the temporary register info, free the space now. */
- free (regs.start);
- free (regs.end);
- }
-
- /* We want zero return to mean success, unlike `re_search'. */
- return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
-}
-
-
-/* Returns a message corresponding to an error code, ERRCODE, returned
- from either regcomp or regexec. */
-
-#ifdef __STDC__
-size_t
-regerror (int errcode, __const__ regex_t *preg,
- char *errbuf, size_t errbuf_size)
-#else
-size_t
-regerror (errcode, preg, errbuf, errbuf_size)
- int errcode;
- __const__ regex_t *preg;
- char *errbuf;
- size_t errbuf_size;
-#endif
-{
- __const__ char *msg
- = rx_error_msg[errcode] == 0 ? "Success" : rx_error_msg[errcode];
- size_t msg_size = strlen (msg) + 1; /* Includes the 0. */
-
- if (errbuf_size != 0)
- {
- if (msg_size > errbuf_size)
- {
- strncpy (errbuf, msg, errbuf_size - 1);
- errbuf[errbuf_size - 1] = 0;
- }
- else
- strcpy (errbuf, msg);
- }
-
- return msg_size;
-}
-
-
-/* Free dynamically allocated space used by PREG. */
-
-#ifdef __STDC__
-void
-regfree (regex_t *preg)
-#else
-void
-regfree (preg)
- regex_t *preg;
-#endif
-{
- if (preg->buffer != 0)
- free (preg->buffer);
- preg->buffer = 0;
- preg->allocated = 0;
-
- if (preg->fastmap != 0)
- free (preg->fastmap);
- preg->fastmap = 0;
- preg->fastmap_accurate = 0;
-
- if (preg->translate != 0)
- free (preg->translate);
- preg->translate = 0;
-}
-
-#endif /* not emacs */
-#endif /* not BSD4.4 */
-
-
-
-
OpenPOWER on IntegriCloud