Import of libg++ 2.7.2.

This commit is contained in:
phil 1996-12-17 18:55:08 +00:00
parent 1460fbef53
commit 1496ef1851
49 changed files with 471 additions and 341 deletions

View File

@ -169,7 +169,7 @@ void <T><C>VHMap::resize(unsigned int newsize)
(*this)[oldtab[i]] = oldcont[i];
delete [] oldtab;
delete [] oldcont;
delete oldstatus;
delete [] oldstatus;
}
Pix <T><C>VHMap::first()

View File

@ -332,9 +332,9 @@ static int gsort (<T> *base_ptr, int total_elems, <T>Comparator cmp)
<T> *left_ptr;
<T> *right_ptr;
stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */
stack_node *top = stack + 1;
stack_node *top = stack;
while (STACK_NOT_EMPTY)
for (;;)
{
{
<T> *pivot = &pivot_buffer;
@ -362,7 +362,10 @@ static int gsort (<T> *base_ptr, int total_elems, <T>Comparator cmp)
/* Here's the famous ``collapse the walls'' section of quicksort.
Gotta like those tight inner loops! They are the main reason
that this algorithm runs much faster than others. */
that this algorithm runs much faster than others.
[Yeah, but there is a function call in the inner loop,
which makes the speed claim rather dubious. --Per Bothner] */
do
{
while ((*cmp) (*left_ptr, *pivot) < 0)
@ -395,8 +398,13 @@ static int gsort (<T> *base_ptr, int total_elems, <T>Comparator cmp)
if ((right_ptr - lo) <= max_thresh)
{
if ((hi - left_ptr) <= max_thresh) /* Ignore both small partitions. */
POP (lo, hi);
if ((hi - left_ptr) <= max_thresh)
{ /* Ignore both small partitions. */
if (STACK_NOT_EMPTY)
POP (lo, hi);
else
break; /* No pending partitions - we're done. */
}
else /* Ignore small left partition. */
lo = left_ptr;
}

View File

@ -49,9 +49,9 @@ case "$1" in
#
# -version
#
# 2.7.1 is substituted by the build process.
# 2.7.2 is substituted by the build process.
# We currently use the libg++ version number (extracted from ../Makefile).
echo "$name: version 2.7.1" ;
echo "$name: version 2.7.2" ;
exit 0;
;;
-requires)

View File

@ -24,7 +24,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <new.h>
AllocRing::AllocRing(int max)
:n(max), current(0), nodes(new AllocQNode[max])
:nodes(new AllocQNode[max]), n(max), current(0)
{
for (int i = 0; i < n; ++i)
{

View File

@ -34,7 +34,7 @@ public:
int n(int xn);
double u();
double u(int xu);
double u(double xu);
virtual double operator()();
@ -50,6 +50,6 @@ inline int Binomial::n() { return pN; }
inline int Binomial::n(int xn) { int tmp = pN; pN = xn; return tmp; }
inline double Binomial::u() { return pU; }
inline double Binomial::u(int xu) { double tmp = pU; pU = xu; return tmp; }
inline double Binomial::u(double xu) { double tmp = pU; pU = xu; return tmp; }
#endif

View File

@ -44,7 +44,8 @@ void BitSet::error(const char* msg) const
BitSetRep _nilBitSetRep = { 0, 1, 0, {0} }; // nil BitSets point here
#define ONES ((_BS_word)(~0L))
#define MAXBitSetRep_SIZE ((1U << (sizeof(unsigned short)*CHAR_BIT - 1)) - 1)
#define MASK1(BITNO) ((_BS_word)1 << (BITNO))
#define MAXBitSetRep_SIZE (((_BS_word)1 << (sizeof(unsigned short)*CHAR_BIT - 1)) - 1)
#define MINBitSetRep_SIZE (sizeof(_BS_word)*CHAR_BIT)
#ifndef MALLOC_MIN_OVERHEAD
@ -102,7 +103,8 @@ BitSetRep* BitSetalloc(BitSetRep* old, const _BS_word* src, int srclen,
memcpy(rep->s, src, srclen * sizeof(_BS_word));
// BUG fix: extend virtual bit! 20 Oct 1992 Kevin Karplus
if (rep->virt)
memset(&rep->s[srclen], ONES, (newlen - srclen) * sizeof(_BS_word));
memset(&rep->s[srclen], (char)ONES,
(newlen - srclen) * sizeof(_BS_word));
if (old != rep && old != 0) delete old;
return rep;
}
@ -122,7 +124,8 @@ BitSetRep* BitSetresize(BitSetRep* old, int newlen)
rep->virt = old->virt;
// BUG fix: extend virtual bit! 20 Oct 1992 Kevin Karplus
if (rep->virt)
memset(&rep->s[old->len], ONES, (newlen - old->len) * sizeof(_BS_word));
memset(&rep->s[old->len], (char)ONES,
(newlen - old->len) * sizeof(_BS_word));
delete old;
}
else
@ -130,7 +133,7 @@ BitSetRep* BitSetresize(BitSetRep* old, int newlen)
rep = old;
if (rep->len < newlen)
memset(&rep->s[rep->len],
rep->virt ? ONES : 0,
rep->virt ? (char)ONES : (char)0,
(newlen - rep->len) * sizeof(_BS_word));
}
@ -416,7 +419,7 @@ int BitSet::count(int b) const
}
else
{
_BS_word maxbit = 1U << (BITSETBITS - 1);
_BS_word maxbit = MASK1 (BITSETBITS - 1);
while (s < tops)
{
_BS_word a = *s++;
@ -557,7 +560,7 @@ void BitSet::set(int p)
rep = BitSetresize(rep, index+1);
}
rep->s[index] |= (1U << pos);
rep->s[index] |= MASK1 (pos);
}
void BitSet::clear()
@ -577,7 +580,7 @@ void BitSet::clear(int p)
else
rep = BitSetresize(rep, index+1);
}
rep->s[index] &= ~(1U << BitSet_pos(p));
rep->s[index] &= ~MASK1(BitSet_pos(p));
}
void BitSet::invert(int p)
@ -585,7 +588,7 @@ void BitSet::invert(int p)
if (p < 0) error("Illegal bit index");
int index = BitSet_index(p);
if (index >= rep->len) rep = BitSetresize(rep, index+1);
rep->s[index] ^= (1U << BitSet_pos(p));
rep->s[index] ^= MASK1(BitSet_pos(p));
}
void BitSet::set(int from, int to)
@ -822,7 +825,7 @@ int BitSet::prev(int p, int b) const
_BS_word a = s[j];
int i = pos;
_BS_word maxbit = 1U << pos;
_BS_word maxbit = MASK1(pos);
if (b == 1)
{
@ -832,7 +835,7 @@ int BitSet::prev(int p, int b) const
return j * BITSETBITS + i;
a <<= 1;
}
maxbit = 1U << (BITSETBITS - 1);
maxbit = MASK1(BITSETBITS - 1);
for (--j; j >= 0; --j)
{
a = s[j];
@ -856,7 +859,7 @@ int BitSet::prev(int p, int b) const
a <<= 1;
}
}
maxbit = 1U << (BITSETBITS - 1);
maxbit = MASK1(BITSETBITS - 1);
for (--j; j >= 0; --j)
{
a = s[j];
@ -1074,7 +1077,7 @@ void BitSet::printon(ostream& os, char f, char t, char star) const
{
_BS_word a = *s;
_BS_word mask = ONES;
_BS_word himask = (1U << (BITSETBITS - 1)) - 1;
_BS_word himask = MASK1(BITSETBITS - 1) - 1;
if (rep->len != 0)
{
for (int j = 0; j < BITSETBITS && a != mask; ++j)

View File

@ -46,8 +46,6 @@ extern BitSetRep* BitSetresize(BitSetRep*, int);
extern BitSetRep* BitSetop(const BitSetRep*, const BitSetRep*,
BitSetRep*, char);
extern BitSetRep* BitSetcmpl(const BitSetRep*, BitSetRep*);
extern BitSetRep _nilBitSetRep;
class BitSet;
@ -72,7 +70,18 @@ class BitSet
protected:
BitSetRep* rep;
enum BS_op {
BS_and = (int) '&',
BS_or = (int) '|',
BS_xor = (int) '^',
BS_diff = (int) '-',
BS_inv = (int) '~'
};
BitSet(const BitSet& x, const BitSet& y, enum BS_op op)
{ rep = BitSetop (x.rep, y.rep, NULL, (char) op); }
BitSet(const BitSet& x, enum BS_op /* op */)
{ rep = BitSetcmpl (x.rep, NULL); }
public:
// constructors
@ -93,7 +102,6 @@ public:
friend int operator >= (const BitSet& x, const BitSet& y);
friend int lcompare(const BitSet& x, const BitSet& y);
// operations on self
BitSet& operator |= (const BitSet& y);
@ -103,6 +111,14 @@ public:
void complement();
// functional operators
friend BitSet operator & (const BitSet& x, const BitSet& y);
friend BitSet operator | (const BitSet& x, const BitSet& y);
friend BitSet operator ^ (const BitSet& x, const BitSet& y);
friend BitSet operator - (const BitSet& x, const BitSet& y);
friend BitSet operator ~ (const BitSet& x);
// individual bit manipulation
void set(int pos);
@ -152,13 +168,17 @@ public:
void printon(ostream& s,
char f='0', char t='1', char star='*') const;
// procedural versions of operators
#ifndef __STRICT_ANSI__
// procedural versions of operators
// The first three of these are incompatible with ANSI C++ digraphs.
// In any case, it's not a great interface.
friend void and(const BitSet& x, const BitSet& y, BitSet& r);
friend void or(const BitSet& x, const BitSet& y, BitSet& r);
friend void xor(const BitSet& x, const BitSet& y, BitSet& r);
friend void diff(const BitSet& x, const BitSet& y, BitSet& r);
friend void complement(const BitSet& x, BitSet& r);
#endif
// misc
@ -181,7 +201,6 @@ inline int BitSet_pos(int l)
return l & (BITSETBITS - 1);
}
inline BitSet::BitSet() : rep(&_nilBitSetRep) {}
inline BitSet::BitSet(const BitSet& x) :rep(BitSetcopy(0, x.rep)) {}
@ -200,6 +219,7 @@ inline int operator > (const BitSet& x, const BitSet& y) { return y < x; }
inline int operator >= (const BitSet& x, const BitSet& y) { return y <= x; }
#ifndef __STRICT_ANSI__
inline void and(const BitSet& x, const BitSet& y, BitSet& r)
{
r.rep = BitSetop(x.rep, y.rep, r.rep, '&');
@ -224,91 +244,61 @@ inline void complement(const BitSet& x, BitSet& r)
{
r.rep = BitSetcmpl(x.rep, r.rep);
}
#if defined(__GNUG__) && !defined(_G_NO_NRV)
inline BitSet operator & (const BitSet& x, const BitSet& y) return r
{
and(x, y, r);
}
inline BitSet operator | (const BitSet& x, const BitSet& y) return r
{
or(x, y, r);
}
inline BitSet operator ^ (const BitSet& x, const BitSet& y) return r
{
xor(x, y, r);
}
inline BitSet operator - (const BitSet& x, const BitSet& y) return r
{
diff(x, y, r);
}
inline BitSet operator ~ (const BitSet& x) return r
{
::complement(x, r);
}
#else /* NO_NRV */
#endif
inline BitSet operator & (const BitSet& x, const BitSet& y)
{
BitSet r; and(x, y, r); return r;
return BitSet::BitSet(x, y, BitSet::BS_and);
}
inline BitSet operator | (const BitSet& x, const BitSet& y)
{
BitSet r; or(x, y, r); return r;
return BitSet::BitSet(x, y, BitSet::BS_or);
}
inline BitSet operator ^ (const BitSet& x, const BitSet& y)
{
BitSet r; xor(x, y, r); return r;
return BitSet::BitSet(x, y, BitSet::BS_xor);
}
inline BitSet operator - (const BitSet& x, const BitSet& y)
{
BitSet r; diff(x, y, r); return r;
return BitSet::BitSet(x, y, BitSet::BS_diff);
}
inline BitSet operator ~ (const BitSet& x)
{
BitSet r; ::complement(x, r); return r;
return BitSet::BitSet(x, BitSet::BS_inv);
}
#endif
inline BitSet& BitSet::operator &= (const BitSet& y)
{
and(*this, y, *this);
rep = BitSetop(rep, y.rep, rep, '&');
return *this;
}
inline BitSet& BitSet::operator |= (const BitSet& y)
{
or(*this, y, *this);
rep = BitSetop(rep, y.rep, rep, '|');
return *this;
}
inline BitSet& BitSet::operator ^= (const BitSet& y)
{
xor(*this, y, *this);
rep = BitSetop(rep, y.rep, rep, '^');
return *this;
}
inline BitSet& BitSet::operator -= (const BitSet& y)
{
diff(*this, y, *this);
rep = BitSetop(rep, y.rep, rep, '-');
return *this;
}
inline void BitSet::complement()
{
::complement(*this, *this);
rep = BitSetcmpl(rep, rep);
}
inline int BitSet::virtual_bit() const
@ -326,7 +316,7 @@ inline int BitSet::test(int p) const
if (p < 0) error("Illegal bit index");
int index = BitSet_index(p);
return (index >= rep->len)? rep->virt :
((rep->s[index] & (1 << BitSet_pos(p))) != 0);
((rep->s[index] & ((_BS_word)1 << BitSet_pos(p))) != 0);
}

View File

@ -163,9 +163,11 @@ public:
friend void mod(const Integer& x, const Integer& y, Integer& dest);
friend void divide(const Integer& x, const Integer& y,
Integer& q, Integer& r);
#ifndef __STRICT_ANSI__
friend void and(const Integer& x, const Integer& y, Integer& dest);
friend void or(const Integer& x, const Integer& y, Integer& dest);
friend void xor(const Integer& x, const Integer& y, Integer& dest);
friend void xor(const Integer& x, const Integer& y, Integer& dest);
#endif
friend void lshift(const Integer& x, const Integer& y, Integer& dest);
friend void rshift(const Integer& x, const Integer& y, Integer& dest);
friend void pow(const Integer& x, const Integer& y, Integer& dest);
@ -178,9 +180,11 @@ public:
friend void div(const Integer& x, long y, Integer& dest);
friend void mod(const Integer& x, long y, Integer& dest);
friend void divide(const Integer& x, long y, Integer& q, long& r);
#ifndef __STRICT_ANSI__
friend void and(const Integer& x, long y, Integer& dest);
friend void or(const Integer& x, long y, Integer& dest);
friend void xor(const Integer& x, long y, Integer& dest);
#endif
friend void lshift(const Integer& x, long y, Integer& dest);
friend void rshift(const Integer& x, long y, Integer& dest);
friend void pow(const Integer& x, long y, Integer& dest);
@ -190,9 +194,21 @@ public:
friend void add(long x, const Integer& y, Integer& dest);
friend void sub(long x, const Integer& y, Integer& dest);
friend void mul(long x, const Integer& y, Integer& dest);
#ifndef __STRICT_ANSI__
friend void and(long x, const Integer& y, Integer& dest);
friend void or(long x, const Integer& y, Integer& dest);
friend void xor(long x, const Integer& y, Integer& dest);
#endif
friend Integer operator & (const Integer&, const Integer&);
friend Integer operator & (const Integer&, long);
friend Integer operator & (long, const Integer&);
friend Integer operator | (const Integer&, const Integer&);
friend Integer operator | (const Integer&, long);
friend Integer operator | (long, const Integer&);
friend Integer operator ^ (const Integer&, const Integer&);
friend Integer operator ^ (const Integer&, long);
friend Integer operator ^ (long, const Integer&);
// coercion & conversion
@ -250,15 +266,6 @@ public:
Integer operator << (const Integer&, long);
Integer operator >> (const Integer&, const Integer&);
Integer operator >> (const Integer&, long);
Integer operator & (const Integer&, const Integer&);
Integer operator & (const Integer&, long);
Integer operator & (long, const Integer&);
Integer operator | (const Integer&, const Integer&);
Integer operator | (const Integer&, long);
Integer operator | (long, const Integer&);
Integer operator ^ (const Integer&, const Integer&);
Integer operator ^ (const Integer&, long);
Integer operator ^ (long, const Integer&);
Integer abs(const Integer&); // absolute value
Integer sqr(const Integer&); // square
@ -365,6 +372,7 @@ inline void mod(const Integer& x, const Integer& y, Integer& dest)
dest.rep = mod(x.rep, y.rep, dest.rep);
}
#ifndef __STRICT_ANSI__
inline void and(const Integer& x, const Integer& y, Integer& dest)
{
dest.rep = bitop(x.rep, y.rep, dest.rep, '&');
@ -379,6 +387,7 @@ inline void xor(const Integer& x, const Integer& y, Integer& dest)
{
dest.rep = bitop(x.rep, y.rep, dest.rep, '^');
}
#endif
inline void lshift(const Integer& x, const Integer& y, Integer& dest)
{
@ -420,6 +429,7 @@ inline void mod(const Integer& x, long y, Integer& dest)
dest.rep = mod(x.rep, y, dest.rep);
}
#ifndef __STRICT_ANSI__
inline void and(const Integer& x, long y, Integer& dest)
{
dest.rep = bitop(x.rep, y, dest.rep, '&');
@ -434,6 +444,7 @@ inline void xor(const Integer& x, long y, Integer& dest)
{
dest.rep = bitop(x.rep, y, dest.rep, '^');
}
#endif
inline void lshift(const Integer& x, long y, Integer& dest)
{
@ -480,6 +491,7 @@ inline void mul(long x, const Integer& y, Integer& dest)
dest.rep = multiply(y.rep, x, dest.rep);
}
#ifndef __STRICT_ANSI__
inline void and(long x, const Integer& y, Integer& dest)
{
dest.rep = bitop(y.rep, x, dest.rep, '&');
@ -494,6 +506,7 @@ inline void xor(long x, const Integer& y, Integer& dest)
{
dest.rep = bitop(y.rep, x, dest.rep, '^');
}
#endif
// operator versions
@ -613,38 +626,38 @@ inline Integer& Integer::operator *= (long y)
inline Integer& Integer::operator &= (const Integer& y)
{
and(*this, y, *this);
rep = bitop(rep, y.rep, rep, '&');
return *this;
}
inline Integer& Integer::operator &= (long y)
{
and(*this, y, *this);
rep = bitop(rep, y, rep, '&');
return *this;
}
inline Integer& Integer::operator |= (const Integer& y)
{
or(*this, y, *this);
rep = bitop(rep, y.rep, rep, '|');
return *this;
}
inline Integer& Integer::operator |= (long y)
{
or(*this, y, *this);
rep = bitop(rep, y, rep, '|');
return *this;
}
inline Integer& Integer::operator ^= (const Integer& y)
{
xor(*this, y, *this);
rep = bitop(rep, y.rep, rep, '^');
return *this;
}
inline Integer& Integer::operator ^= (long y)
{
xor(*this, y, *this);
rep = bitop(rep, y, rep, '^');
return *this;
}
@ -801,47 +814,47 @@ inline Integer sqr(const Integer& x) return r
inline Integer operator & (const Integer& x, const Integer& y) return r
{
and(x, y, r);
r.rep = bitop(x.rep, y.rep, r.rep, '&');
}
inline Integer operator & (const Integer& x, long y) return r
{
and(x, y, r);
r.rep = bitop(x.rep, y, r.rep, '&');
}
inline Integer operator & (long x, const Integer& y) return r
{
and(x, y, r);
r.rep = bitop(y.rep, x, r.rep, '&');
}
inline Integer operator | (const Integer& x, const Integer& y) return r
{
or(x, y, r);
r.rep = bitop(x.rep, y.rep, r.rep, '|');
}
inline Integer operator | (const Integer& x, long y) return r
{
or(x, y, r);
r.rep = bitop(x.rep, y, r.rep, '|');
}
inline Integer operator | (long x, const Integer& y) return r
{
or(x, y, r);
r.rep = bitop(y.rep, x, r.rep, '|');
}
inline Integer operator ^ (const Integer& x, const Integer& y) return r
{
xor(x, y, r);
r.rep = bitop(x.rep, y.rep, r.rep, '^');
}
inline Integer operator ^ (const Integer& x, long y) return r
{
xor(x, y, r);
r.rep = bitop (x.rep, y, r.rep, '^');
}
inline Integer operator ^ (long x, const Integer& y) return r
{
xor(x, y, r);
r.rep = bitop (y.rep, x, r.rep, '^');
}
inline Integer operator / (const Integer& x, const Integer& y) return r
@ -1010,17 +1023,17 @@ inline Integer operator | (long x, const Integer& y)
inline Integer operator ^ (const Integer& x, const Integer& y)
{
Integer r; xor(x, y, r); return r;
Integer r; r.rep = bitop(x.rep, y.rep, r.rep, '^'); return r;
}
inline Integer operator ^ (const Integer& x, long y)
{
Integer r; xor(x, y, r); return r;
Integer r; r.rep = bitop(x.rep, y, r.rep, '^'); return r;
}
inline Integer operator ^ (long x, const Integer& y)
{
Integer r; xor(x, y, r); return r;
Integer r; r.rep = bitop(y.rep, x, r.rep, '^'); return r;
}
inline Integer operator / (const Integer& x, const Integer& y)

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.1.1.1 1996/03/09 00:01:20 phil Exp $
# $NetBSD: Makefile,v 1.1.1.2 1996/12/17 18:57:01 phil Exp $
LIB= g++
@ -9,9 +9,9 @@ MLCG.cc NegExp.cc Normal.cc Obstack.cc Poisson.cc RNG.cc \
Random.cc Rational.cc Regex.cc RndInt.cc SLList.cc SmplHist.cc \
SmplStat.cc String.cc Uniform.cc Weibull.cc bitand.c bitany.c \
bitblt.c bitclear.c bitcopy.c bitcount.c bitinvert.c bitlcomp.c \
bitset1.c bitxor.c builtin.cc chr.cc compare.cc error.cc \
fmtq.cc gcd.cc hash.cc ioob.cc lg.cc pow.cc \
sqrt.cc str.cc timer.c
bitset1.c bitxor.c builtin.cc compare.cc error.cc fmtq.cc \
gcd.cc hash.cc ioob.cc lg.cc pow.cc sqrt.cc \
timer.c
CXXFLAGS+= -nostdinc++ -I$(.CURDIR)/../../include \
-I$(.CURDIR)/../../libio -I$(.CURDIR)/../../libstdc++

View File

@ -41,6 +41,13 @@ Regex::~Regex()
{
if (buf->buffer) free(buf->buffer);
if (buf->fastmap) free(buf->fastmap);
if (buf->translate) free (buf->translate);
if (reg->start)
free (reg->start);
if (reg->end)
free (reg->end);
delete(buf);
delete(reg);
}
@ -52,6 +59,8 @@ Regex::Regex(const char* t, int fast, int bufsize,
buf = new re_pattern_buffer;
memset (buf, 0, sizeof(re_pattern_buffer));
reg = new re_registers;
reg->start = 0;
reg->end = 0;
if (fast)
buf->fastmap = (char*)malloc(256);
else

View File

@ -326,7 +326,7 @@ inline static int scmp(const char* a, const char* b)
return *a != 0;
else
{
signed char diff = 0;
int diff = 0;
while ((diff = *a - *b++) == 0 && *a++ != 0);
return diff;
}
@ -336,7 +336,7 @@ inline static int scmp(const char* a, const char* b)
inline static int ncmp(const char* a, int al, const char* b, int bl)
{
int n = (al <= bl)? al : bl;
signed char diff;
int diff;
while (n-- > 0) if ((diff = *a++ - *b++) != 0) return diff;
return al - bl;
}
@ -348,7 +348,7 @@ int fcompare(const String& x, const String& y)
int al = x.length();
int bl = y.length();
int n = (al <= bl)? al : bl;
signed char diff = 0;
int diff = 0;
while (n-- > 0)
{
char ac = *a++;
@ -402,7 +402,7 @@ int compare(const SubString& x, const char* b)
{
const char* a = x.chars();
int n = x.length();
signed char diff;
int diff;
while (n-- > 0) if ((diff = *a++ - *b++) != 0) return diff;
return (*b == 0) ? 0 : -1;
}
@ -1165,7 +1165,7 @@ String common_prefix(const String& x, const String& y, int startpos)
const char* ys = &(ychars[startpos]);
const char* topy = &(ychars[y.length()]);
int l;
for (int l; xs < topx && ys < topy && *xs++ == *ys++; ++l);
for (l = 0; xs < topx && ys < topy && *xs++ == *ys++; ++l);
r.rep = Salloc(r.rep, ss, l, l);
return r;
}
@ -1180,7 +1180,7 @@ String common_suffix(const String& x, const String& y, int startpos)
const char* ys = &(ychars[y.length() + startpos]);
const char* boty = ychars;
int l;
for (int l; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l);
for (l = 0; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l);
r.rep = Salloc(r.rep, ++xs, l, l);
return r;
}

View File

@ -32,9 +32,9 @@ the executable file might be covered by the GNU General Public License. */
int
_BS_lcompare_0 (ptr0, len0, ptr1, len1)
register _BS_word *ptr0;
register const _BS_word *ptr0;
_BS_size_t len0;
register _BS_word *ptr1;
register const _BS_word *ptr1;
_BS_size_t len1;
{
_BS_size_t nwords0 = len0 / _BS_BITS_PER_WORD;

View File

@ -45,7 +45,7 @@ typedef unsigned long _BS_word;
( (NEW_PTR) = (_BS_word*)(((char*)(PTR)-(char*)0) & ~(sizeof(_BS_word)-1)), \
(OFFSET) += (char*)(PTR) - (char*)(NEW_PTR) )
/* Given a bit point (PTR, OFFSET) normalize it so that
/* Given a bit pointer (PTR, OFFSET) normalize it so that
OFFSET < _BS_BITS_PER_WORD. */
#define _BS_NORMALIZE(PTR, OFFSET) \
{ _BS_size_t __tmp_ind = _BS_INDEX (OFFSET); \
@ -114,7 +114,8 @@ extern int _BS_any __P((const _BS_word*, int, _BS_size_t));
extern void _BS_clear __P((_BS_word*, int, _BS_size_t));
extern void _BS_set __P((_BS_word*, int, _BS_size_t));
extern void _BS_invert __P((_BS_word*, int, _BS_size_t));
int _BS_lcompare_0 __P((_BS_word*, _BS_size_t, _BS_word*, _BS_size_t));
int _BS_lcompare_0 __P((const _BS_word*, _BS_size_t,
const _BS_word*, _BS_size_t));
extern void _BS_xor __P((_BS_word*,int, const _BS_word*,int, _BS_size_t));
#ifdef __cplusplus

View File

@ -1,2 +1,2 @@
major=3
major=4
minor=0

View File

@ -1,15 +1,15 @@
# $NetBSD: Makefile,v 1.1.1.1 1996/03/09 00:01:31 phil Exp $
# $NetBSD: Makefile,v 1.1.1.2 1996/12/17 18:58:06 phil Exp $
LIB= io
SRCS= cleanup.c filedoalloc.c fileops.c floatconv.c genops.c iofclose.c \
iofdopen.c iofflush.c iofgetpos.c iofgets.c iofopen.c iofprintf.c \
iofputs.c iofread.c iofscanf.c iofsetpos.c ioftell.c iofwrite.c \
iogetdelim.c iogetline.c iogets.c ioignore.c iopadn.c ioperror.c \
iopopen.c ioprims.c ioprintf.c ioputs.c ioscanf.c ioseekoff.c \
ioseekpos.c iosetbuffer.c iosetvbuf.c iosprintf.c iosscanf.c iostrerror.c \
ioungetc.c iovfprintf.c iovfscanf.c iovsprintf.c iovsscanf.c outfloat.c \
stdfiles.c strops.c
SRCS= chr.cc cleanup.c filedoalloc.c fileops.c floatconv.c genops.c \
iofclose.c iofdopen.c iofflush.c iofgetpos.c iofgets.c iofopen.c \
iofprintf.c iofputs.c iofread.c iofscanf.c iofsetpos.c ioftell.c \
iofwrite.c iogetdelim.c iogetline.c iogets.c ioignore.c iopadn.c \
ioperror.c iopopen.c ioprims.c ioprintf.c ioputs.c ioscanf.c \
ioseekoff.c ioseekpos.c iosetbuffer.c iosetvbuf.c iosprintf.c iosscanf.c \
iostrerror.c ioungetc.c iovfprintf.c iovfscanf.c iovsprintf.c iovsscanf.c \
outfloat.c str.cc stdfiles.c strops.c
CXXFLAGS+= -nostdinc++ -I$(.CURDIR)/../include
CFLAGS+= -I$(.CURDIR)

View File

@ -1,35 +1,74 @@
/* AUTOMATICALLY GENERATED; DO NOT EDIT! */
#ifndef _G_config_h
#define _G_config_h
#define _G_LIB_VERSION "2.7.1"
#define _G_LIB_VERSION "2.7.2"
#ifndef __alpha__
#define _G_NAMES_HAVE_UNDERSCORE 1
#else /* __alpha__ */
#define _G_NAMES_HAVE_UNDERSCORE 0
#endif /* __alpha__ */
#define _G_VTABLE_LABEL_HAS_LENGTH 1
#ifndef __alpha__
#define _G_VTABLE_LABEL_PREFIX "__vt$"
#else /* __alpha__ */
#define _G_VTABLE_LABEL_PREFIX "_vt$"
#endif /* __alpha__ */
#define _G_HAVE_ST_BLKSIZE 1
#ifndef __alpha__
typedef unsigned long _G_clock_t;
#else /* __alpha__ */
typedef int _G_clock_t;
#endif /* __alpha__ */
typedef int _G_dev_t;
#ifndef __alpha__
typedef long long _G_fpos_t;
#else /* __alpha__ */
typedef long _G_fpos_t;
#endif /* __alpha__ */
typedef unsigned int _G_gid_t;
typedef unsigned int _G_ino_t;
typedef unsigned short _G_mode_t;
typedef unsigned short _G_nlink_t;
#ifndef __alpha__
typedef long long _G_off_t;
#else /* __alpha__ */
typedef long _G_off_t;
#endif /* __alpha__ */
typedef int _G_pid_t;
#ifndef __PTRDIFF_TYPE__
#ifndef __alpha__
#define __PTRDIFF_TYPE__ int
#else /* __alpha__ */
#define __PTRDIFF_TYPE__ long
#endif /* __alpha__ */
#endif
typedef __PTRDIFF_TYPE__ _G_ptrdiff_t;
typedef unsigned int _G_sigset_t;
#ifndef __SIZE_TYPE__
#ifndef __alpha__
#define __SIZE_TYPE__ unsigned int
#else /* __alpha__ */
#define __SIZE_TYPE__ unsigned long
#endif /* __alpha__ */
#endif
typedef __SIZE_TYPE__ _G_size_t;
#ifndef __alpha__
typedef long _G_time_t;
#else /* __alpha__ */
typedef int _G_time_t;
#endif /* __alpha__ */
typedef unsigned int _G_uid_t;
typedef int _G_wchar_t;
#ifndef __alpha__
typedef int _G_ssize_t;
typedef int /* default */ _G_wint_t;
typedef char * _G_va_list;
#else /* __alpha__ */
typedef long _G_ssize_t;
typedef unsigned int /* default */ _G_wint_t;
#define _G_NEED_STDARG_H
#define _G_va_list va_list
#endif /* __alpha__ */
#define _G_signal_return_type void
#define _G_sprintf_return_type int

View File

@ -12,4 +12,6 @@ DEFUN_VOID(_IO_register_cleanup)
}
void (*_IO_cleanup_registration_needed)() = _IO_register_cleanup;
#else
void (*_IO_cleanup_registration_needed)() = NULL;
#endif /* _G_HAVE_ATEXIT */

View File

@ -95,6 +95,14 @@ filebuf* filebuf::open(const char *filename, ios::openmode mode, int prot)
posix_mode = O_RDONLY, read_write = _IO_NO_WRITES;
else
posix_mode = 0, read_write = _IO_NO_READS+_IO_NO_WRITES;
if (mode & ios::binary)
{
mode &= ~ios::binary;
#ifdef O_BINARY
/* This is a (mis-)feature of DOS/Windows C libraries. */
posix_mode |= O_BINARY;
#endif
}
if ((mode & (int)ios::trunc) || mode == (int)ios::out)
posix_mode |= O_TRUNC;
if (mode & ios::app)

View File

@ -50,12 +50,6 @@ the executable file might be covered by the GNU General Public License. */
#include <unistd.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.
@ -73,6 +67,10 @@ DEFUN(_IO_file_doallocate, (fp),
register char *p;
struct stat st;
/* If _IO_cleanup_registration_needed is non-zero, we should call the
function it points to. This is to make sure _IO_cleanup gets called
on exit. We call it from _IO_file_doallocate, since that is likely
to get called by any program that does buffered I/O. */
if (_IO_cleanup_registration_needed)
(*_IO_cleanup_registration_needed)();

View File

@ -43,21 +43,26 @@ extern int errno;
is that of gptr(); in put mode that of pptr().
The position in the buffer that corresponds to the position
in external file system is file_ptr().
This is normally _IO_read_end, except in putback mode,
when it is _IO_save_end.
in external file system is normally _IO_read_end, except in putback
mode, when it is _IO_save_end.
If the field _fb._offset is >= 0, it gives the offset in
the file as a whole corresponding to eGptr(). (?)
PUT MODE:
If a filebuf is in put mode, pbase() is non-NULL and equal to base().
Also, epptr() == ebuf().
Also, eback() == gptr() && gptr() == egptr().
The un-flushed character are those between pbase() and pptr().
If a filebuf is in put mode, then all of _IO_read_ptr, _IO_read_end,
and _IO_read_base are equal to each other. These are usually equal
to _IO_buf_base, though not necessarily if we have switched from
get mode to put mode. (The reason is to maintain the invariant
that _IO_read_end corresponds to the external file position.)
_IO_write_base is non-NULL and usually equal to _IO_base_base.
We also have _IO_write_end == _IO_buf_end, but only in fully buffered mode.
The un-flushed character are those between _IO_write_base and _IO_write_ptr.
GET MODE:
If a filebuf is in get or putback mode, eback() != egptr().
In get mode, the unread characters are between gptr() and egptr().
The OS file position corresponds to that of egptr().
PUTBACK MODE:
Putback mode is used to remember "excess" characters that have
been sputbackc'd in a separate putback buffer.
@ -70,7 +75,7 @@ extern int errno;
The OS position corresponds to that of save_egptr().
LINE BUFFERED OUTPUT:
During line buffered output, pbase()==base() && epptr()==base().
During line buffered output, _IO_write_base==base() && epptr()==base().
However, ptr() may be anywhere between base() and ebuf().
This forces a call to filebuf::overflow(int C) on every put.
If there is more space in the buffer, and C is not a '\n',
@ -102,11 +107,11 @@ int
DEFUN(_IO_file_close_it, (fp),
register _IO_FILE* fp)
{
int sync_status, close_status;
int write_status, close_status;
if (!_IO_file_is_open(fp))
return EOF;
sync_status = _IO_file_sync (fp);
write_status = _IO_do_flush (fp);
_IO_unsave_markers(fp);
@ -122,7 +127,7 @@ DEFUN(_IO_file_close_it, (fp),
fp->_fileno = EOF;
fp->_offset = _IO_pos_BAD;
return close_status ? close_status : sync_status;
return close_status ? close_status : write_status;
}
void
@ -211,7 +216,7 @@ DEFUN(_IO_file_setbuf, (fp, p, len),
}
/* Write TO_DO bytes from DATA to FP.
Then mark FP has having empty buffers. */
Then mark FP as having empty buffers. */
int
DEFUN(_IO_do_write, (fp, data, to_do),
@ -220,24 +225,28 @@ DEFUN(_IO_do_write, (fp, data, to_do),
_IO_size_t count;
if (to_do == 0)
return 0;
if (fp->_flags & _IO_IS_APPENDING)
/* On a system without a proper O_APPEND implementation,
you would need to sys_seek(0, SEEK_END) here, but is
is not needed nor desirable for Unix- or Posix-like systems.
Instead, just indicate that offset (before and after) is
unpredictable. */
fp->_offset = _IO_pos_BAD;
else if (fp->_IO_read_end != fp->_IO_write_base)
{
_IO_pos_t new_pos
= _IO_SYSSEEK(fp, fp->_IO_write_base - fp->_IO_read_end, 1);
if (new_pos == _IO_pos_BAD)
return EOF;
fp->_offset = new_pos;
else
{
if (fp->_flags & _IO_IS_APPENDING)
/* On a system without a proper O_APPEND implementation,
you would need to sys_seek(0, SEEK_END) here, but is
is not needed nor desirable for Unix- or Posix-like systems.
Instead, just indicate that offset (before and after) is
unpredictable. */
fp->_offset = _IO_pos_BAD;
else if (fp->_IO_read_end != fp->_IO_write_base)
{
_IO_pos_t new_pos
= _IO_SYSSEEK(fp, fp->_IO_write_base - fp->_IO_read_end, 1);
if (new_pos == _IO_pos_BAD)
return EOF;
fp->_offset = new_pos;
}
count = _IO_SYSWRITE (fp, data, to_do);
if (fp->_cur_column)
fp->_cur_column
= _IO_adjust_column (fp->_cur_column - 1, data, to_do) + 1;
}
count = _IO_SYSWRITE (fp, data, to_do);
if (fp->_cur_column)
fp->_cur_column = _IO_adjust_column(fp->_cur_column - 1, data, to_do) + 1;
_IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base;
fp->_IO_write_end = (fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) ? fp->_IO_buf_base
@ -306,7 +315,15 @@ DEFUN(_IO_file_overflow, (f, ch),
_IO_doallocbuf(f);
_IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base);
}
/* Otherwise must be currently reading. */
/* Otherwise must be currently reading.
If _IO_read_ptr (and hence also _IO_read_end) is at the buffer end,
logically slide the buffer forwards one block (by setting the
read pointers to all point at the beginning of the block). This
makes room for subsequent output.
Otherwise, set the read pointers to _IO_read_end (leaving that
alone, so it can continue to correspond to the external position). */
if (f->_IO_read_ptr == f->_IO_buf_end)
f->_IO_read_end = f->_IO_read_ptr = f->_IO_buf_base;
f->_IO_write_ptr = f->_IO_read_ptr;
f->_IO_write_base = f->_IO_write_ptr;
f->_IO_write_end = f->_IO_buf_end;

View File

@ -1102,6 +1102,7 @@ _IO_strtod
TEST_ENDIANNESS;
sign = nz0 = nz = 0;
rv = 0.;
(void)&rv; /* Force rv into the stack */
for(s = s00;;s++) switch(*s) {
case '-':
sign = 1;

View File

@ -32,7 +32,7 @@ the executable file might be covered by the GNU General Public License. */
extern "C++" {
class fstreambase : virtual public ios {
#ifdef _IO_NEW_STREAMS
filebuf __my_fb;
mutable filebuf __my_fb; // mutable so rdbuf() can be const
#endif
void __fb_init ();
public:
@ -42,7 +42,7 @@ class fstreambase : virtual public ios {
fstreambase(const char *name, int mode, int prot=0664);
void close();
#ifdef _IO_NEW_STREAMS
filebuf* rdbuf() const { return (filebuf*)&__my_fb; }
filebuf* rdbuf() const { return &__my_fb; }
#else
filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); }
#endif

View File

@ -511,26 +511,41 @@ int
DEFUN(_IO_sputbackc, (fp, c),
register _IO_FILE *fp AND int c)
{
int result;
if (fp->_IO_read_ptr > fp->_IO_read_base
&& (unsigned char)fp->_IO_read_ptr[-1] == (unsigned char)c)
{
fp->_IO_read_ptr--;
return (unsigned char)c;
result = (unsigned char)c;
}
return _IO_PBACKFAIL (fp, c);
else
result = _IO_PBACKFAIL (fp, c);
if (result != EOF)
fp->_flags &= ~_IO_EOF_SEEN;
return result;
}
int
DEFUN(_IO_sungetc, (fp),
register _IO_FILE *fp)
{
int result;
if (fp->_IO_read_ptr > fp->_IO_read_base)
{
fp->_IO_read_ptr--;
return (unsigned char)*fp->_IO_read_ptr;
result = (unsigned char)*fp->_IO_read_ptr;
}
else
return _IO_PBACKFAIL (fp, EOF);
result = _IO_PBACKFAIL (fp, EOF);
if (result != EOF)
fp->_flags &= ~_IO_EOF_SEEN;
return result;
}
#if 0 /* Work in progress */

View File

@ -63,6 +63,11 @@ int indirectbuf::overflow(int c /* = EOF */)
}
int indirectbuf::underflow()
{
return get_stream()->sgetc();
}
int indirectbuf::uflow()
{
return get_stream()->sbumpc();
}
@ -90,7 +95,7 @@ streampos indirectbuf::seekpos(streampos pos, int mode)
int select = mode == 0 ? (ios::in|ios::out) : mode;
streambuf *gbuf = (select & ios::in) ? get_stream() : (streambuf*)NULL;
streambuf *pbuf = (select & ios::out) ? put_stream() : (streambuf*)NULL;
if (gbuf == pbuf)
if (gbuf == pbuf && gbuf != NULL)
ret_val = gbuf->seekpos(pos, mode);
else {
if (gbuf)

View File

@ -65,6 +65,7 @@ class indirectbuf : public streambuf {
virtual streamsize xsputn(const char* s, streamsize n);
virtual streamsize xsgetn(char* s, streamsize n);
virtual int underflow();
virtual int uflow();
virtual int overflow(int c = EOF);
virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);

View File

@ -26,13 +26,13 @@ the executable file might be covered by the GNU General Public License. */
#define _POSIX_SOURCE
#include "libioP.h"
#include <sys/types.h>
#if _IO_HAVE_SYS_WAIT
#include <signal.h>
#include <unistd.h>
#ifdef __STDC__
#include <stdlib.h>
#endif
#include <sys/types.h>
#include <sys/wait.h>
#ifndef _IO_fork
@ -118,7 +118,7 @@ DEFUN(_IO_proc_open, (fp, command, mode),
proc_file_chain = proc_file_chain->next;
}
_IO_execl("/bin/sh", "sh", "-c", command, NULL);
_IO_execl("/bin/sh", "sh", "-c", command, (char *)0);
_IO__exit(127);
}
_IO_close(child_end);

View File

@ -36,7 +36,7 @@ DEFUN(_IO_setvbuf, (fp, buf, mode, size),
switch (mode)
{
case _IOFBF:
fp->_IO_file_flags &= ~_IO_LINE_BUF;
fp->_IO_file_flags &= ~_IO_LINE_BUF|_IO_UNBUFFERED;
if (buf == NULL)
{
if (fp->_IO_buf_base == NULL)
@ -62,6 +62,7 @@ DEFUN(_IO_setvbuf, (fp, buf, mode, size),
}
break;
case _IOLBF:
fp->_IO_file_flags &= ~_IO_UNBUFFERED;
fp->_IO_file_flags |= _IO_LINE_BUF;
if (buf == NULL)
return 0;

View File

@ -82,8 +82,6 @@ typedef _IO_FILE FILE;
#define perror _IO_perror
#define printf _IO_printf
#define puts _IO_puts
#define remove ??? __P((const char*))
#define rename ??? __P((const char* _old, const char* _new))
#define rewind _IO_rewind
#define scanf _IO_scanf
#define setbuf _IO_setbuf
@ -91,13 +89,19 @@ typedef _IO_FILE FILE;
#define setvbuf _IO_setvbuf
#define sprintf _IO_sprintf
#define sscanf _IO_sscanf
#define tmpfile ??? __P((void))
#define tmpnam ??? __P((char*))
#define ungetc _IO_ungetc
#define vfprintf _IO_vfprintf
#define vprintf(__fmt, __args) vfprintf(stdout, __fmt, __args)
#define vsprintf _IO_vsprintf
#if 0
/* We can use the libc versions of these, since they don't pass FILE*s. */
#define remove ??? __P((const char*))
#define rename ??? __P((const char* _old, const char* _new))
#define tmpfile ??? __P((void))
#define tmpnam ??? __P((char*))
#endif
#if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)
#define fdopen _IO_fdopen
#define fileno _IO_fileno

View File

@ -233,7 +233,13 @@ public:
extern _IO_istream_withassign cin;
// clog->rdbuf() == cerr->rdbuf()
extern _IO_ostream_withassign cout, cerr, clog;
extern _IO_ostream_withassign cout, cerr;
extern _IO_ostream_withassign clog
#if _G_CLOG_CONFLICT
__asm__ ("__IO_clog")
#endif
;
struct Iostream_init { } ; // Compatibility hack for AT&T library.

View File

@ -169,6 +169,7 @@ struct _IO_FILE {
#define _IO_file_flags _flags
/* The following pointers correspond to the C++ streambuf protocol. */
/* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */
char* _IO_read_ptr; /* Current read pointer */
char* _IO_read_end; /* End of get area. */
char* _IO_read_base; /* Start of putback+get area. */

View File

@ -78,6 +78,15 @@ extern "C" {
*/
#define _IO_JUMPS(THIS) ((struct _IO_FILE_plus*)(THIS))->vtable
#ifdef _G_USING_THUNKS
#define JUMP_FIELD(TYPE, NAME) TYPE NAME
#define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC(THIS)
#define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC(THIS, X1)
#define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC(THIS, X1, X2)
#define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC(THIS, X1,X2, X3)
#define JUMP_INIT(NAME, VALUE) VALUE
#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT(dummy2, 0)
#else
/* These macros will change when we re-implement vtables to use "thunks"! */
#define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME
#define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC.pfn(THIS)
@ -86,6 +95,7 @@ extern "C" {
#define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1,X2, X3)
#define JUMP_INIT(NAME, VALUE) {0, 0, VALUE}
#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0)
#endif
/* The 'finish' function does any final cleaning up of an _IO_FILE object.
It does not delete (free) it, but does everything else to finalize it/
@ -217,6 +227,9 @@ typedef int (*_IO_stat_t) __P((_IO_FILE*, void*));
struct _IO_jump_t {
JUMP_FIELD(_G_size_t, __dummy);
#ifdef _G_USING_THUNKS
JUMP_FIELD(_G_size_t, __dummy2);
#endif
JUMP_FIELD(_IO_finish_t, __finish);
JUMP_FIELD(_IO_overflow_t, __overflow);
JUMP_FIELD(_IO_underflow_t, __underflow);

View File

@ -1,2 +1,2 @@
major=0
minor=0
minor=1

View File

@ -58,7 +58,7 @@ class istdiostream : public istream
private:
stdiobuf _file;
public:
istdiostream (FILE* __f) : _file(__f), istream() { init(&_file); }
istdiostream (FILE* __f) : istream(), _file(__f) { init(&_file); }
stdiobuf* rdbuf()/* const */ { return &_file; }
int buffered () const { return _file.buffered (); }
void buffered (int _i) { _file.buffered (_i); }
@ -69,7 +69,7 @@ class ostdiostream : public ostream
private:
stdiobuf _file;
public:
ostdiostream (FILE* __f) : _file(__f), ostream() { init(&_file); }
ostdiostream (FILE* __f) : ostream(), _file(__f) { init(&_file); }
stdiobuf* rdbuf() /* const */ { return &_file; }
int buffered () const { return _file.buffered (); }
void buffered (int _i) { _file.buffered (_i); }

View File

@ -101,8 +101,8 @@ struct _fake_ostream {
#endif
#ifdef __GNUC__
#define OSTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \
_fake_ostream NAME = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }};
#define OSTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS, ASM) \
_fake_ostream NAME ASM = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }};
#define ISTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \
_fake_istream NAME = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }};
#else
@ -112,12 +112,16 @@ struct _fake_ostream {
_fake_istream NAME = {{0, 0, &NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS)}};
#endif
OSTREAM_DEF(cout, COUT_SBUF, NULL, 0)
OSTREAM_DEF(cerr, CERR_SBUF,(ostream*)&cout, ios::unitbuf)
OSTREAM_DEF(cout, COUT_SBUF, NULL, 0, )
OSTREAM_DEF(cerr, CERR_SBUF,(ostream*)&cout, ios::unitbuf, )
ISTREAM_DEF(cin, CIN_SBUF, (ostream*)&cout, 0)
/* Only for (partial) compatibility with AT&T's library. */
OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0)
#if _G_CLOG_CONFLICT
OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0, __asm__ ("__IO_clog"))
#else
OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0, )
#endif
// Switches between using _IO_std{in,out,err} and __std{in,out,err}_buf
// for standard streams. This does not normally need to be called

View File

@ -23,6 +23,7 @@ This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
#include <stdarg.h>
#include <string.h>
#include "libioP.h"
#include "stream.h"
#include "strstream.h"
@ -142,3 +143,28 @@ char* oct(unsigned int i, int len /* = 0 */)
{
return itoa(i, len, 0, 8);
}
static char *str(const char* s, int len, int width)
{
if (width < len)
width = len;
int space_left = EndBuffer - next_chunk;
if (space_left <= width + 1)
next_chunk = Buffer; // start over.
char* buf = next_chunk;
memset (buf, ' ', width - len);
memcpy (buf + width - len, s, len);
buf[width] = 0;
return buf;
}
char* str(const char* s, int width)
{
return str (s, strlen (s), width);
}
char* chr(char ch, int width)
{
char c = ch;
return str (&c, 1, width);
}

View File

@ -26,6 +26,8 @@ the executable file might be covered by the GNU General Public License. */
#define _COMPAT_STREAM_H
// Compatibility with old library.
// DO NOT USE THESE FUNCTIONS IN NEW CODE!
// They are obsolete, non-standard, and non-reentrant.
#define _STREAM_COMPAT
#include <iostream.h>

View File

@ -116,6 +116,7 @@ enum open_mode {
class ios : public _ios_fields {
ios& operator=(ios&); /* Not allowed! */
ios (const ios&); /* Not allowed! */
public:
typedef __fmtflags fmtflags;
typedef int iostate;
@ -134,7 +135,8 @@ class ios : public _ios_fields {
trunc = _IO_TRUNC,
nocreate = _IO_NOCREATE,
noreplace = _IO_NOREPLACE,
bin = _IOS_BIN };
bin = _IOS_BIN, // Deprecated - ANSI uses ios::binary.
binary = _IOS_BIN };
enum seek_dir { beg, cur, end};
// ANSI: typedef enum seek_dir seekdir; etc
// NOTE: If adding flags here, before to update ios::bitalloc().

View File

@ -32,8 +32,6 @@ typedef void (*_IO_free_type) __P((void*));
struct _IO_str_fields
{
/* The current length is max(_len, _IO_write_ptr-_IO_write_base). */
_IO_size_t _len;
_IO_alloc_type _allocate_buffer;
_IO_free_type _free_buffer;
};
@ -44,3 +42,11 @@ typedef struct _IO_strfile_
const void *_vtable;
struct _IO_str_fields _s;
} _IO_strfile;
/* dynamic: set when the array object is allocated (or reallocated) as
necessary to hold a character sequence that can change in length. */
#define _IO_STR_DYNAMIC(FP) ((FP)->_s._allocate_buffer != (_IO_alloc_type)0)
/* frozen: set when the program has requested that the array object not
be altered, reallocated, or freed. */
#define _IO_STR_FROZEN(FP) ((FP)->_f._IO_file_flags & _IO_USER_BUF)

View File

@ -26,7 +26,31 @@ the executable file might be covered by the GNU General Public License. */
#include "libioP.h"
#include <string.h>
#define LEN(fp) (((_IO_strfile*)(fp))->_s._len)
#if 0
/* The following definitions are for exposition only.
They map the terminlogy used in the ANSI/ISO C++ draft standard
to the implementation. */
/* allocated: set when a dynamic array object has been allocated, and
hence should be freed by the destructor for the strstreambuf object. */
#define ALLOCATED(FP) ((FP)->_f._IO_buf_base && DYNAMIC(FP))
/* constant: set when the array object has const elements,
so the output sequence cannot be written. */
#define CONSTANT(FP) ((FP)->_f._IO_file_flags & _IO_NO_WRITES)
/* alsize: the suggested minimum size for a dynamic array object. */
#define ALSIZE(FP) ??? /* not stored */
/* palloc: points to the function to call to allocate a dynamic array object.*/
#define PALLOC(FP) \
((FP)->_s._allocate_buffer == default_alloc ? 0 : (FP)->_s._allocate_buffer)
/* pfree: points to the function to call to free a dynamic array object. */
#define PFREE(FP) \
((FP)->_s._free_buffer == default_free ? 0 : (FP)->_s._free_buffer)
#endif
#ifdef TODO
/* An "unbounded buffer" is when a buffer is supplied, but with no
@ -44,27 +68,17 @@ DEFUN(_IO_str_init_static, (fp, ptr, size, pstart),
{
/* If size is negative 'the characters are assumed to
continue indefinitely.' This is kind of messy ... */
#if 1
int s;
size = 512;
/* Try increasing powers of 2, as long as we don't wrap around.
This can lose in pathological cases (ptr near the end
of the address space). A better solution might be to
adjust the size on underflow/overflow. FIXME. */
for (s; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; )
/* Try increasing powers of 2, as long as we don't wrap around. */
for (; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; )
size = s;
size = s;
#else
/* The following semi-portable kludge assumes that
sizeof(unsigned long) == sizeof(char*). Hence,
(unsigned long)(-1) should be the largest possible address. */
unsigned long highest = (unsigned long)(-1);
/* Pointers are signed on some brain-damaged systems, in
which case we divide by two to get the maximum signed address. */
if ((char*)highest < ptr)
highest >>= 1;
size = (char*)highest - ptr;
#endif
/* Try increasing size as much as we can without wrapping around. */
for (s = size >> 1; s > 0; s >>= 1)
{
if (ptr + size + s > ptr)
size += s;
}
}
_IO_setb(fp, ptr, ptr+size, 0);
@ -83,7 +97,6 @@ DEFUN(_IO_str_init_static, (fp, ptr, size, pstart),
fp->_IO_write_end = ptr;
fp->_IO_read_end = ptr+size;
}
LEN(fp) = size;
/* A null _allocate_buffer function flags the strfile as being static. */
(((_IO_strfile*)(fp))->_s._allocate_buffer) = (_IO_alloc_type)0;
}
@ -101,34 +114,25 @@ DEFUN(_IO_str_overflow, (fp, c),
register _IO_FILE* fp AND int c)
{
int flush_only = c == EOF;
_IO_size_t pos = fp->_IO_write_ptr - fp->_IO_write_base;
_IO_size_t get_pos = fp->_IO_read_ptr - fp->_IO_read_base;
_IO_size_t pos;
if (fp->_flags & _IO_NO_WRITES)
return flush_only ? 0 : EOF;
if (pos > LEN(fp)) LEN(fp) = pos;
if ((fp->_flags & _IO_TIED_PUT_GET) && !(fp->_flags & _IO_CURRENTLY_PUTTING))
{
pos = get_pos;
fp->_flags |= _IO_CURRENTLY_PUTTING;
get_pos = LEN(fp);
fp->_IO_write_ptr = fp->_IO_read_ptr;
fp->_IO_read_ptr = fp->_IO_read_end;
}
pos = fp->_IO_write_ptr - fp->_IO_write_base;
if (pos >= _IO_blen(fp) + flush_only)
{
if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */
{
#ifdef TODO
if (indefinite size)
{
fp->_IO_buf_end += 512;
}
else
#endif
return EOF;
}
return EOF;
else
{
char *new_buf;
_IO_size_t new_size = 2 * _IO_blen(fp);
char *old_buf = fp->_IO_buf_base;
_IO_size_t new_size = 2 * _IO_blen(fp) + 100;
new_buf
= (char*)(*((_IO_strfile*)fp)->_s._allocate_buffer)(new_size);
if (new_buf == NULL)
@ -136,31 +140,32 @@ DEFUN(_IO_str_overflow, (fp, c),
/* __ferror(fp) = 1; */
return EOF;
}
memcpy(new_buf, fp->_IO_buf_base, _IO_blen(fp));
#if 0
if (lenp == &LEN(fp)) /* use '\0'-filling */
memset(new_buf + pos, 0, blen() - pos);
#endif
if (fp->_IO_buf_base)
{
memcpy(new_buf, old_buf, _IO_blen(fp));
(*((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base);
/* Make sure _IO_setb won't try to delete _IO_buf_base. */
fp->_IO_buf_base = NULL;
}
#if 0
if (lenp == &LEN(fp)) /* use '\0'-filling */
memset(new_buf + pos, 0, blen() - pos);
#endif
_IO_setb(fp, new_buf, new_buf + new_size, 1);
fp->_IO_read_base = new_buf + (fp->_IO_read_base - old_buf);
fp->_IO_read_ptr = new_buf + (fp->_IO_read_ptr - old_buf);
fp->_IO_read_end = new_buf + (fp->_IO_read_end - old_buf);
fp->_IO_write_ptr = new_buf + (fp->_IO_write_ptr - old_buf);
fp->_IO_write_base = new_buf;
fp->_IO_write_end = fp->_IO_buf_end;
}
fp->_IO_write_end = fp->_IO_buf_end;
}
fp->_IO_write_ptr = fp->_IO_buf_base + pos;
fp->_IO_read_base = fp->_IO_buf_base;
fp->_IO_read_ptr = fp->_IO_buf_base + get_pos;
fp->_IO_read_end = fp->_IO_buf_base + LEN(fp);
if (!flush_only)
*fp->_IO_write_ptr++ = (unsigned char) c;
if (fp->_IO_write_ptr > fp->_IO_read_end)
fp->_IO_read_end = fp->_IO_write_ptr;
return c;
}
@ -168,28 +173,29 @@ int
DEFUN(_IO_str_underflow, (fp),
register _IO_FILE* fp)
{
_IO_size_t ppos = fp->_IO_write_ptr - fp->_IO_write_base;
if (ppos > LEN(fp)) LEN(fp) = ppos;
if (fp->_IO_write_ptr > fp->_IO_read_end)
fp->_IO_read_end = fp->_IO_write_ptr;
if ((fp->_flags & _IO_TIED_PUT_GET) && (fp->_flags & _IO_CURRENTLY_PUTTING))
{
fp->_flags &= ~_IO_CURRENTLY_PUTTING;
fp->_IO_read_ptr = fp->_IO_write_ptr;
fp->_IO_write_ptr = fp->_IO_write_end;
}
fp->_IO_read_end = fp->_IO_read_base + LEN(fp);
if (fp->_IO_read_ptr < fp->_IO_read_end)
return *fp->_IO_read_ptr;
else
return EOF;
}
/* The size of the valid part of the buffer. */
_IO_ssize_t
DEFUN(_IO_str_count, (fp),
register _IO_FILE *fp)
{
_IO_ssize_t put_len = fp->_IO_write_ptr - fp->_IO_write_base;
if (put_len < LEN(fp))
put_len = LEN(fp);
return put_len;
return (fp->_IO_write_ptr > fp->_IO_read_end ? fp->_IO_write_ptr
: fp->_IO_read_end)
- fp->_IO_read_base;
}
_IO_pos_t
@ -236,7 +242,6 @@ DEFUN(_IO_str_seekoff, (fp, offset, dir, mode),
}
if (offset < 0 || (_IO_size_t)offset > cur_size)
return EOF;
LEN(fp) = cur_size;
fp->_IO_write_ptr = fp->_IO_write_base + offset;
new_pos = offset;
}

View File

@ -41,68 +41,16 @@ static void default_free(void* ptr)
delete [] (char*)ptr;
}
#if _IO_UNIFIED_JUMPTABLES
#define SET_STR_JUMPS(STRBUF) /* Nothing */
#else
/* Set to use the _IO_str_jump jumptable, for efficiency */
#define SET_STR_JUMPS(STRBUF) \
(STRBUF)->_jumps = &_IO_str_jumps,\
(STRBUF)->_vtable() = builtinbuf_vtable;
#endif
istrstream::istrstream(const char *cp, int n)
{
#ifdef _IO_NEW_STREAMS
__my_sb.init_readonly (cp, n);
init (&__my_sb);
#else
init(new strstreambuf(cp, n));
_flags &= ~ios::dont_close;
#endif
SET_STR_JUMPS(_strbuf);
}
ostrstream::ostrstream()
{
#ifdef _IO_NEW_STREAMS
init (&__my_sb);
#else
init(new strstreambuf());
_flags &= ~ios::dont_close;
#endif
SET_STR_JUMPS(_strbuf);
}
strstream::strstream()
{
#ifdef _IO_NEW_STREAMS
init (&__my_sb);
#else
init(new strstreambuf());
_flags &= ~ios::dont_close;
#endif
SET_STR_JUMPS(_strbuf);
}
strstreambase::strstreambase(char *cp, int n, int mode)
#ifdef _IO_NEW_STREAMS
: __my_sb (cp, n,
(mode == ios::app || mode == ios::ate) ? cp + strlen(cp) : cp)
#endif
{
#ifdef _IO_NEW_STREAMS
init (&__my_sb);
#else
char *pstart;
if (mode == ios::app || mode == ios::ate)
pstart = cp + strlen(cp);
else
pstart = cp;
init(new strstreambuf(cp, n, pstart));
_flags &= ~ios::dont_close;
#endif
SET_STR_JUMPS(_strbuf);
}
char *strstreambuf::str()
@ -128,15 +76,15 @@ void strstreambuf::init_dynamic(_IO_alloc_type alloc, _IO_free_type free,
int initial_size)
{
_s._len = 0;
if (initial_size < 16)
initial_size = 16;
_s._allocate_buffer = alloc ? alloc : default_alloc;
_s._free_buffer = free ? free : default_free;
char * buf = (char*)(*_s._allocate_buffer)(initial_size);
setb(buf, buf + initial_size, 1);
setp(buf, buf + initial_size);
setg(buf, buf, buf);
if (initial_size > 0)
{
char * buf = (char*)(*_s._allocate_buffer)(initial_size);
setb(buf, buf + initial_size, 1);
setp(buf, buf + initial_size);
setg(buf, buf, buf);
}
}
void strstreambuf::init_static(char *ptr, int size, char *pstart)

View File

@ -39,11 +39,10 @@ class strstreambuf : public streambuf
friend class istrstream;
void init_dynamic(_IO_alloc_type alloc, _IO_free_type free,
int initial_size = 128);
int initial_size = 0);
void init_static(char *ptr, int size, char *pstart);
void init_readonly(const char *ptr, int size);
protected:
int is_static() const { return _s._allocate_buffer == (_IO_alloc_type)0; }
virtual int overflow(int = EOF);
virtual int underflow();
virtual int pbackfail(int c);
@ -65,10 +64,10 @@ class strstreambuf : public streambuf
{ init_static((char*)ptr, size, (char*)pstart); }
strstreambuf(const signed char *ptr, int size)
{ init_readonly((const char*)ptr, size); }
// Note: frozen() is always true if is_static().
// Note: frozen() is always true if !_IO_STR_DYNAMIC(this).
int frozen() { return _flags & _IO_USER_BUF ? 1 : 0; }
void freeze(int n=1)
{ if (!is_static())
{ if (_IO_STR_DYNAMIC(this))
{ if (n) _flags |= _IO_USER_BUF; else _flags &= ~_IO_USER_BUF; } }
_IO_ssize_t pcount();
char *str();
@ -76,21 +75,12 @@ class strstreambuf : public streambuf
};
class strstreambase : virtual public ios {
#ifdef _IO_NEW_STREAMS
protected:
strstreambuf __my_sb;
#endif
public:
#ifdef _IO_NEW_STREAMS
strstreambuf* rdbuf() { return &__my_sb; }
#else
strstreambuf* rdbuf() { return (strstreambuf*)ios::rdbuf(); }
#endif
protected:
strstreambase() { }
#ifdef _IO_NEW_STREAMS
strstreambase(char *cp, int n);
#endif
strstreambase() { init (&__my_sb); }
strstreambase(char *cp, int n, int mode=ios::out);
};
@ -101,7 +91,7 @@ class istrstream : public strstreambase, public istream {
class ostrstream : public strstreambase, public ostream {
public:
ostrstream();
ostrstream() { }
ostrstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){}
_IO_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); }
char *str() { return ((strstreambuf*)_strbuf)->str(); }
@ -111,7 +101,7 @@ class ostrstream : public strstreambase, public ostream {
class strstream : public strstreambase, public iostream {
public:
strstream();
strstream() { }
strstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){}
_IO_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); }
char *str() { return ((strstreambuf*)_strbuf)->str(); }

View File

@ -1,2 +1,2 @@
major=0
minor=0
minor=1

View File

@ -5148,9 +5148,10 @@ rx_compile (pattern, size, syntax, rxb)
if (!zero_times_ok)
{
struct rexp_node * concat
= rx_mk_r_concat (&rxb->rx, inner_exp,
= rx_mk_r_concat (&rxb->rx,
rx_copy_rexp (&rxb->rx,
*last_expression));
inner_exp),
*last_expression);
if (!concat)
return REG_ESPACE;
*last_expression = concat;

View File

@ -3,5 +3,5 @@
#ifndef __QUEUE__
#define __QUEUE__
#include <queue.h>
#include <stack.h>
#endif

View File

@ -1,2 +1,2 @@
major=0
minor=0
minor=1

View File

@ -86,7 +86,7 @@ template <class charT, class traits>
inline bool basic_string <charT, traits>::
check_realloc (size_t s) const
{
++s;
s += sizeof (charT);
return (rep ()->ref > 1
|| s > capacity ()
|| Rep::excess_slop (s, capacity ()));
@ -154,7 +154,7 @@ replace (size_t pos, size_t n1, const charT* s, size_t n2)
OUTOFRANGE (pos > len);
if (n1 > len - pos)
n1 = len - pos;
LENGTHERROR (len - n1 >= npos - n2);
LENGTHERROR (len - n1 > max_size () - n2);
size_t newlen = len - n1 + n2;
if (check_realloc (newlen))
@ -190,7 +190,7 @@ replace (size_t pos, size_t n1, size_t n2, charT c)
OUTOFRANGE (pos > len);
if (n1 > len - pos)
n1 = len - pos;
LENGTHERROR (len - n1 >= npos - n2);
LENGTHERROR (len - n1 > max_size () - n2);
size_t newlen = len - n1 + n2;
if (check_realloc (newlen))
@ -215,7 +215,7 @@ template <class charT, class traits>
void basic_string <charT, traits>::
resize (size_t n, charT c)
{
LENGTHERROR (n == npos);
LENGTHERROR (n > max_size ());
if (n > length ())
append (n - length (), c);
@ -269,6 +269,9 @@ template <class charT, class traits>
size_t basic_string <charT, traits>::
rfind (const charT* s, size_t pos, size_t n) const
{
if (n > length ())
return npos;
size_t xpos = length () - n;
if (xpos > pos)
xpos = pos;
@ -284,6 +287,9 @@ template <class charT, class traits>
size_t basic_string <charT, traits>::
rfind (charT c, size_t pos) const
{
if (1 > length ())
return npos;
size_t xpos = length () - 1;
if (xpos > pos)
xpos = pos;

View File

@ -139,7 +139,7 @@ public:
size_type capacity () const
{ return rep ()->res; }
size_type max_size () const
{ return npos - 1; } // XXX
{ return (npos - 1)/sizeof (charT); } // XXX
bool empty () const
{ return size () == 0; }
@ -221,20 +221,20 @@ public:
basic_string& insert (size_type pos, size_type n, charT c)
{ return replace (pos, 0, n, c); }
iterator insert(iterator p, charT c)
{ insert (p - begin (), 1, c); return p; }
{ size_type pos = p - begin (); insert (pos, 1, c); return pos +begin (); }
iterator insert(iterator p, size_type n, charT c)
{ insert (p - begin (), n, c); return p; }
{ size_type pos = p - begin (); insert (pos, n, c); return pos +begin (); }
#if 0
template<class InputIterator>
void insert(iterator p, InputIterator first, InputIterator last);
#endif
basic_string& remove (size_type pos = 0, size_type n = npos)
{ return replace (pos, n, 0, (charT)0); }
{ return replace (pos, n, (size_type)0, (charT)0); }
basic_string& remove (iterator pos)
{ return replace (pos - begin (), 1, 0, (charT)0); }
{ return replace (pos - begin (), 1, (size_type)0, (charT)0); }
basic_string& remove (iterator first, iterator last)
{ return replace (first - begin (), last - first, 0, (charT)0); }
{ return replace (first - begin (), last - first, (size_type)0, (charT)0);}
basic_string& replace (size_type pos1, size_type n1, const basic_string& str,
size_type pos2 = 0, size_type n2 = npos);

View File

@ -374,6 +374,9 @@ public:
friend T* value_type(const iterator&) {
return (T*)(0);
}
friend inline difference_type* distance_type(const iterator&) {
return (difference_type*)(0);
}
#endif
};

View File

@ -38,10 +38,11 @@
// object pointer that points to the sub-object that is matched is
// returned.
void* __class_type_info::__rtti_match(const type_info& desired, int is_public,
void *objptr) const
void*
__class_type_info::__rtti_match (const type_info& desired, int is_public,
void *objptr) const
{
if (__rtti_compare(desired) == 0)
if (__rtti_compare (desired) == 0)
return objptr;
void *match_found = 0;
@ -52,7 +53,7 @@ void* __class_type_info::__rtti_match(const type_info& desired, int is_public,
if (is_virtual_list[i])
p = *(void **)p;
if ((p=base_list[i]->__rtti_match(desired, is_public, p))
if ((p=base_list[i]->__rtti_match (desired, is_public, p))
!= 0)
if (match_found == 0)
match_found = p;
@ -66,8 +67,9 @@ void* __class_type_info::__rtti_match(const type_info& desired, int is_public,
return match_found;
}
void* __pointer_type_info::__rtti_match(const type_info& catch_type, int,
void *objptr) const
void*
__pointer_type_info::__rtti_match (const type_info& catch_type, int,
void *objptr) const
{
if (catch_type.__rtti_get_node_type () == __rtti_get_node_type())
{
@ -113,15 +115,15 @@ __throw_type_match_rtti (void *catch_type_r, void *throw_type_r, void *objptr)
return 0;
#if 0
printf("We want to match a %s against a %s!\n",
throw_type.name(), catch_type.name());
printf ("We want to match a %s against a %s!\n",
throw_type.name (), catch_type.name ());
#endif
/* The 1 skips conversions to private bases. */
new_objptr = throw_type.__rtti_match (catch_type, 1, objptr);
#if 0
if (new_objptr)
printf("It converts, delta is %d\n", new_objptr-objptr);
printf ("It converts, delta is %d\n", new_objptr-objptr);
#endif
return new_objptr;
}