Thread View: gnu.g++.bug
1 messages
1 total messages
Started by David Edwards
Fri, 01 Dec 1989 01:59
cpp output which results in SegV dump
Author: David Edwards
Date: Fri, 01 Dec 1989 01:59
Date: Fri, 01 Dec 1989 01:59
3158 lines
79718 bytes
79718 bytes
The following will produce a SegV core dump on a Sun-3x running SunOS 4.0.3.
The file is part of the nih class library (formerly oops).
dirt:lib:26 > /src/gnu/g++-new/g++ -B/src/gnu/g++-new -E -v -ansi -fdefault-inline ArrayOb.c
g++ version 1.36.2- (based on GCC 1.36)
/usr/local/lib/gcc-cpp -+ -v -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ ArrayOb.c
GNU CPP version 1.36
# 1 "ArrayOb.c"
# 1 "/usr/local/lib/g++-include/libc.h" 1
#pragma once
# 1 "/usr/local/lib/g++-include/builtin.h" 1
#pragma once
typedef void (*one_arg_error_handler_t)(const char*);
typedef void (*two_arg_error_handler_t)(const char*, const char*);
# 1 "/usr/local/lib/g++-include/stddef.h" 1
#pragma once
typedef unsigned long size_t;
typedef long int ptrdiff_t;
typedef unsigned char wchar_t;
# 40 "/usr/local/lib/g++-include/builtin.h" 2
# 1 "/usr/local/lib/g++-include/std.h" 1
#pragma once
# 1 "/usr/local/lib/g++-include/stdio.h" 1
#pragma once
# 79 "/usr/local/lib/g++-include/stdio.h"
# 108 "/usr/local/lib/g++-include/stdio.h"
extern struct _iobuf {
int _cnt;
char* _ptr;
char* _base;
int _bufsiz;
short _flag;
char _file;
} _iob[];
# 171 "/usr/local/lib/g++-include/stdio.h"
extern "C" {
int _doprnt(const char*, void*, struct _iobuf *);
int _doscan( struct _iobuf *, const char*, ...);
int _filbuf( struct _iobuf *);
int _flsbuf(unsigned, struct _iobuf *);
int fclose( struct _iobuf *);
struct _iobuf * fdopen(int, const char*);
int fflush( struct _iobuf *);
int fgetc( struct _iobuf *);
char* fgets(char*, int, struct _iobuf *);
struct _iobuf * fopen(const char*, const char*);
int fprintf( struct _iobuf *, const char* ...);
int fputc(int, struct _iobuf *);
int fputs(const char*, struct _iobuf *);
int fread(void*, int, int, struct _iobuf *);
struct _iobuf * freopen(const char*, const char*, struct _iobuf *);
int fscanf( struct _iobuf *, const char* ...);
int fseek( struct _iobuf *, long, int);
long ftell( struct _iobuf *);
int fwrite(const void*, int, int, struct _iobuf *);
char* gets(char*);
int getw( struct _iobuf *);
int pclose( struct _iobuf *);
struct _iobuf * popen(const char*, const char*);
int printf(const char* ...);
void puts(const char*);
int putw(int, struct _iobuf *);
int rewind( struct _iobuf *);
int scanf(const char* ...);
void setbuf( struct _iobuf *, char*);
void setbuffer( struct _iobuf *, char*, int);
void setlinebuf( struct _iobuf *);
void setvbuf( struct _iobuf *, char*, int, int);
int sscanf(char*, const char* ...);
struct _iobuf * tmpfile();
int ungetc(int, struct _iobuf *);
int vfprintf( struct _iobuf *, const char*, ...);
int vprintf(const char*, ... );
char* sprintf(char*, const char* ...);
char* vsprintf(char*, const char*, ...);
}
# 29 "/usr/local/lib/g++-include/std.h" 2
extern "C" {
void volatile _exit(int);
void volatile abort(void);
int access(const char*, int);
int acct(const char*);
unsigned alarm(unsigned);
double atof(const char*);
int atoi(const char*);
long atol(const char*);
int bind(int, void*, int);
int brk(void*);
int bsearch (const void *, const void *, unsigned long,
unsigned long, auto int (*ptf)(const void*, const void*));
void* calloc(unsigned, unsigned);
void cfree(void*);
int chdir(const char*);
int chmod(const char*, int);
int chown(const char*, int, int);
long clock(void);
int close(int);
int creat(const char*, unsigned long int);
char* crypt(const char*, const char*);
char* ctermid(char*);
char* cuserid(char*);
double drand48(void);
int dup(int);
int dup2(int, int);
int dysize(int);
char* ecvt(double, int, int*, int*);
char* encrypt(char*, int);
double erand(short*);
int execl(const char*, const char *, ...);
int execle(const char*, const char *, ...);
int execlp(const char*, const char*, ...);
int exect(const char*, const char**, char**);
int execv(const char*, const char**);
int execve(const char*, const char**, char**);
int execvp(const char*, const char**);
void volatile exit(int);
int fchmod(int, int);
int fchown(int, int, int);
int fcntl(int, int, ...);
char* fcvt(double, int, int*, int*);
int ffs(int);
int flock(int, int);
int fork(void);
void free(void*);
int fsync(int);
long ftok(const char*, int);
int ftruncate(int, unsigned long);
char* gcvt(double, int, char*);
char* getcwd(char*, int);
int getdomainname(char*, int);
int getdtablesize(void);
int getegid(void);
char* getenv(const char*);
int geteuid(void);
int getgid(void);
int getgroups(int, int*);
long gethostid(void);
int gethostname(char*, int);
char* getlogin(void);
int getopt(int, char**, char*);
int getpagesize(void);
char* getpass(const char*);
int getpgrp(void);
int getpid(void);
int getppid(void);
int getpriority(int, int);
int getpw(int, char*);
unsigned getuid(void);
char* getwd(char*);
char* initstate(unsigned, char*, int);
int ioctl(int, int, char*);
int isatty(int);
long jrand48(short*);
int kill(int, int);
int killpg(int, int);
void lcong48(short*);
int link(const char*, const char*);
int listen(int, int);
int lock(int, int, long);
long lrand48(void);
long lseek(int, long, int);
void* malloc(unsigned);
void* memalign(unsigned, unsigned);
void* memccpy(void*, const void*, int, int);
void* memchr(const void*, int, int);
int memcmp(const void*, const void*, int);
void* memcpy(void*, const void*, int);
void* memset(void*, int, int);
int mkdir(const char*, int);
int mknod(const char*, int, int);
int mkstemp(char*);
char* mktemp(char*);
long mrand48(void);
int nice(int);
long nrand48(short*);
int open(const char*, int, ...);
void pause(void);
void perror(const char*);
int pipe(int*);
void profil(char*, int, int, int);
int psignal(unsigned, char*);
int ptrace(int, int, int, int);
int putenv(const char*);
int qsort(void*, int, unsigned, auto (*ptf)(void*,void*));
int rand(void);
long random(void);
int read(int, void*, unsigned);
int readlink(const char*, char*, int);
void* realloc(void*, unsigned);
int rename(const char*, const char*);
int rmdir(const char*);
void* sbrk(int);
short* seed48(short*);
int send(int, char*, int, int);
int setgid(int);
int sethostname(char*, int);
int setkey(const char*);
int setpgrp(int, int);
int setpriority(int, int, int);
int setregid(int, int);
int setreuid(int, int);
char* setstate(char*);
int setuid(int);
int sigblock(int);
int siginterrupt(int, int);
int sigpause(int);
int sigsetmask(int);
unsigned sleep(unsigned);
int socket(int, int, int);
int srand(int);
void srand48(long);
void srandom(int);
int stime(long*);
char* strcat(char*, const char*);
char* strchr(const char*, int);
int strcmp(const char*, const char*);
char* strcpy(char*, const char*);
int strcspn(const char*, const char*);
char* strdup(const char*);
int strlen(const char*);
char* strncat(char*, const char*, int);
int strncmp(const char*, const char*, int);
char* strncpy(char*, const char*, int);
char* strpbrk(const char*, const char*);
char* strrchr(const char*, int);
int strspn(const char*, const char*);
double strtod(const char*, char**);
char* strtok(char*, const char*);
long strtol(const char*, char**, int);
void swab(void*, void*, int);
int symlink(const char*, const char*);
int syscall(int, ...);
int system(const char*);
char* tempnam(char*, char*);
int tgetent(char*, char*);
int tgetnum(char*);
int tgetflag(char*);
char* tgetstr(char *, char **);
char* tgoto(char*, int, int);
long time(long*);
char* tmpnam(char*);
int tputs(char *, int, auto int (*)());
int truncate(const char*, unsigned long);
char* ttyname(int);
int ttyslot(void);
unsigned ualarm(unsigned, unsigned);
long ulimit(int, long);
int umask(int);
int unlink(const char*);
unsigned usleep(unsigned);
int vadvise(int);
void* valloc(unsigned);
int vfork(void);
int vhangup(void);
int wait(int*);
int write(int, const void*, unsigned);
}
extern "C" {
int bcmp(const void*, const void*, int);
void bcopy(const void*, void*, int);
void bzero(void*, int);
char* index(const char*, int);
char* rindex(const char*, int);
}
extern char** environ;
extern volatile int errno;
extern char* sys_errlist[];
extern int sys_nerr;
extern char* optarg;
extern int opterr;
extern int optind;
extern "C" void* alloca(unsigned long);
# 41 "/usr/local/lib/g++-include/builtin.h" 2
# 1 "/usr/local/lib/g++-include/math.h" 1
#pragma once
# 1 "/usr/local/lib/g++-include/math-68881.h" 1
# 1 "/usr/local/lib/g++-include/errno.h" 1
#pragma once
extern "C" {
# 1 "//usr/include/errno.h" 1
# 1 "/usr/include/sys/errno.h" 1
# 7 "//usr/include/errno.h" 2
extern int errno;
# 5 "/usr/local/lib/g++-include/errno.h" 2
}
# 22 "/usr/local/lib/g++-include/math-68881.h" 2
# 34 "/usr/local/lib/g++-include/math-68881.h"
__inline static const double sin (double x)
{
double value;
__asm ("fsin%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double cos (double x)
{
double value;
__asm ("fcos%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double tan (double x)
{
double value;
__asm ("ftan%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double asin (double x)
{
double value;
__asm ("fasin%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double acos (double x)
{
double value;
__asm ("facos%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double atan (double x)
{
double value;
__asm ("fatan%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double atan2 (double y, double x)
{
double pi, pi_over_2;
__asm ("fmovecr%.x %#0,%0"
: "=f" (pi)
: );
__asm ("fscale%.b %#-1,%0"
: "=f" (pi_over_2)
: "0" (pi));
if (x > 0)
{
if (y > 0)
{
if (x > y)
return atan (y / x);
else
return pi_over_2 - atan (x / y);
}
else
{
if (x > -y)
return atan (y / x);
else
return - pi_over_2 - atan (x / y);
}
}
else
{
if (y > 0)
{
if (-x > y)
return pi + atan (y / x);
else
return pi_over_2 - atan (x / y);
}
else
{
if (-x > -y)
return - pi + atan (y / x);
else if (y < 0)
return - pi_over_2 - atan (x / y);
else
{
double value;
errno = 33 ;
__asm ("fmove%.d %#0rnan,%0"
: "=f" (value)
: );
return value;
}
}
}
}
__inline static const double sinh (double x)
{
double value;
__asm ("fsinh%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double cosh (double x)
{
double value;
__asm ("fcosh%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double tanh (double x)
{
double value;
__asm ("ftanh%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double atanh (double x)
{
double value;
__asm ("fatanh%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double exp (double x)
{
double value;
__asm ("fetox%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double expm1 (double x)
{
double value;
__asm ("fetoxm1%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double log (double x)
{
double value;
__asm ("flogn%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double log1p (double x)
{
double value;
__asm ("flognp1%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double log10 (double x)
{
double value;
__asm ("flog10%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double sqrt (double x)
{
double value;
__asm ("fsqrt%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double pow (const double x, const double y)
{
if (x > 0)
return exp (y * log (x));
else if (x == 0)
{
if (y > 0)
return 0.0;
else
{
double value;
errno = 33 ;
__asm ("fmove%.d %#0rnan,%0"
: "=f" (value)
: );
return value;
}
}
else
{
double temp;
__asm ("fintrz%.x %1,%0"
: "=f" (temp)
: "f" (y));
if (y == temp)
{
int i = (int) y;
if (i & 1 == 0)
return exp (y * log (x));
else
return - exp (y * log (x));
}
else
{
double value;
errno = 33 ;
__asm ("fmove%.d %#0rnan,%0"
: "=f" (value)
: );
return value;
}
}
}
__inline static const double fabs (double x)
{
double value;
__asm ("fabs%.x %1,%0"
: "=f" (value)
: "f" (x));
return value;
}
__inline static const double ceil (double x)
{
int rounding_mode, round_up;
double value;
__asm volatile ("fmove%.l fpcr,%0"
: "=dm" (rounding_mode)
: );
round_up = rounding_mode | 0x30;
__asm volatile ("fmove%.l %0,fpcr"
:
: "dmi" (round_up));
__asm volatile ("fint%.x %1,%0"
: "=f" (value)
: "f" (x));
__asm volatile ("fmove%.l %0,fpcr"
:
: "dmi" (rounding_mode));
return value;
}
__inline static const double floor (double x)
{
int rounding_mode, round_down;
double value;
__asm volatile ("fmove%.l fpcr,%0"
: "=dm" (rounding_mode)
: );
round_down = (rounding_mode & ~0x10)
| 0x20;
__asm volatile ("fmove%.l %0,fpcr"
:
: "dmi" (round_down));
__asm volatile ("fint%.x %1,%0"
: "=f" (value)
: "f" (x));
__asm volatile ("fmove%.l %0,fpcr"
:
: "dmi" (rounding_mode));
return value;
}
__inline static const double rint (double x)
{
int rounding_mode, round_nearest;
double value;
__asm volatile ("fmove%.l fpcr,%0"
: "=dm" (rounding_mode)
: );
round_nearest = rounding_mode & ~0x30;
__asm volatile ("fmove%.l %0,fpcr"
:
: "dmi" (round_nearest));
__asm volatile ("fint%.x %1,%0"
: "=f" (value)
: "f" (x));
__asm volatile ("fmove%.l %0,fpcr"
:
: "dmi" (rounding_mode));
return value;
}
__inline static const double fmod (double x, double y)
{
double value;
__asm ("fmod%.x %2,%0"
: "=f" (value)
: "0" (x),
"f" (y));
return value;
}
__inline static const double drem (double x, double y)
{
double value;
__asm ("frem%.x %2,%0"
: "=f" (value)
: "0" (x),
"f" (y));
return value;
}
__inline static const double scalb (double x, int n)
{
double value;
__asm ("fscale%.l %2,%0"
: "=f" (value)
: "0" (x),
"dmi" (n));
return value;
}
__inline static double logb (double x)
{
double exponent;
__asm ("fgetexp%.x %1,%0"
: "=f" (exponent)
: "f" (x));
return exponent;
}
__inline static const double ldexp (double x, int n)
{
double value;
__asm ("fscale%.l %2,%0"
: "=f" (value)
: "0" (x),
"dmi" (n));
return value;
}
__inline static double frexp (double x, int *exp)
{
double float_exponent;
int int_exponent;
double mantissa;
__asm ("fgetexp%.x %1,%0"
: "=f" (float_exponent)
: "f" (x));
int_exponent = (int) float_exponent;
__asm ("fgetman%.x %1,%0"
: "=f" (mantissa)
: "f" (x));
if (mantissa != 0)
{
__asm ("fscale%.b %#-1,%0"
: "=f" (mantissa)
: "0" (mantissa));
int_exponent += 1;
}
*exp = int_exponent;
return mantissa;
}
__inline static double modf (double x, double *ip)
{
double temp;
__asm ("fintrz%.x %1,%0"
: "=f" (temp)
: "f" (x));
*ip = temp;
return x - temp;
}
# 32 "/usr/local/lib/g++-include/math.h" 2
extern "C" {
double acosh(double);
double asinh(double);
double cbrt(double);
double copysign(double,double);
double erf(double);
double erfc(double);
double finite(double);
double gamma(double);
double hypot(double,double);
double infnan(int);
int isinf(double);
int isnan(double);
double j0(double);
double j1(double);
double jn(int, double);
double lgamma(double);
double y0(double);
double y1(double);
double yn(int, double);
}
# 109 "/usr/local/lib/g++-include/math.h"
struct libm_exception
{
int type;
char* name;
double arg1, arg2, retval;
};
extern "C" int matherr(libm_exception*);
# 1 "/usr/local/lib/g++-include/values.h" 1
#pragma once
# 153 "/usr/local/lib/g++-include/values.h"
# 134 "/usr/local/lib/g++-include/math.h" 2
# 42 "/usr/local/lib/g++-include/builtin.h" 2
long abs(long);
double abs(double);
void clearbit(long&, long);
void setbit(long&, long);
int testbit(long, long);
int even(long);
long gcd(long, long);
long lg(long);
long lcm(long, long);
int odd(long);
double pow(double, long);
long pow(long, long);
int sign(long);
int sign(double);
long sqr(long);
double sqr(double);
long sqrt(long);
double start_timer();
double return_elapsed_time(double);
char* itoa(long x, int base = 10, int width = 0);
char* itoa(unsigned long x, int base = 10, int width = 0);
char* itoa(long long x, int base = 10, int width = 0);
char* itoa(unsigned long long x, int base = 10, int width = 0);
char* dtoa(double x, char cvt = 'g', int width = 0, int prec = 6);
char* hex(long x, int width = 0);
char* hex(unsigned long x, int width = 0);
char* oct(long x, int width = 0);
char* oct(unsigned long x, int width = 0);
char* dec(long x, int width = 0);
char* dec(unsigned long x, int width = 0);
char* form(const char* fmt ...);
char* chr(char ch);
char* str(const char* s, int width = 0);
unsigned int hashpjw(const char*);
unsigned int multiplicativehash(int);
unsigned int foldhash(double);
extern void default_one_arg_error_handler(const char*);
extern 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);
inline double abs(double _arg)
{
return (_arg < 0.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;
}
inline double sqr(double _arg)
{
return _arg * _arg;
}
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);
}
# 3 "/usr/local/lib/g++-include/libc.h" 2
# 83 "ArrayOb.c" 2
# 1 "/usr/include/malloc.h" 1
struct mallinfo {
int arena;
int ordblks;
int smblks;
int hblks;
int hblkhd;
int usmblks;
int fsmblks;
int uordblks;
int fordblks;
int keepcost;
int mxfast;
int nlblks;
int grain;
int uordbytes;
int allocated;
int treeoverhead;
};
extern char *malloc();
extern char *realloc();
extern int mallopt();
extern struct mallinfo mallinfo();
# 84 "ArrayOb.c" 2
# 1 "ArrayOb.h" 1
# 1 "Collection.h" 1
# 1 "Object.h" 1
# 1 "/usr/local/lib/g++-include/stream.h" 1
#pragma once
# 1 "/usr/local/lib/g++-include/File.h" 1
#pragma once
enum io_mode
{
io_readonly = 0,
io_writeonly = 1,
io_readwrite = 2,
io_appendonly = 3,
io_append = 4,
};
enum access_mode
{
a_createonly = 0,
a_create = 1,
a_useonly = 2,
a_use = 3,
};
enum state_value
{
_good = 0,
_eof = 1,
_fail = 2,
_bad = 4
};
class Filebuf;
class File
{
friend class Filebuf;
protected:
struct _iobuf * fp;
char* nm;
char rw;
state_value state;
long stat;
void initialize();
void reinitialize(const char*);
char *readline (int chunk_number, char terminator);
public:
File();
File(const char* filename, io_mode m, access_mode a);
File(const char* filename, const char* m);
File(int filedesc, io_mode m);
File( struct _iobuf * fileptr);
File(int sz, char* buf, io_mode m);
~File();
File& open(const char* filename, io_mode m, access_mode a);
File& open(const char* filename, const char* m);
File& open(int filedesc, io_mode m);
File& open( struct _iobuf * fileptr);
File& close();
File& remove();
int filedesc();
const char* name();
void setname(const char* newname);
int iocount();
operator struct _iobuf *();
int rdstate();
int eof();
int fail();
int bad();
int good();
int readable();
int writable();
int is_open();
operator void*();
void error();
void clear(state_value f = _good);
void set(state_value f);
void unset(state_value f);
File& failif(int cond);
void check_state();
File& get(char& c);
File& put(char c);
File& unget(char c);
File& putback(char c);
File& put(const char* s);
File& get (char* s, int n, char terminator = '\n');
File& getline(char* s, int n, char terminator = '\n');
File& gets (char **s, char terminator = '\n');
File& read(void* x, int sz, int n);
File& write(void* x, int sz, int n);
File& form(const char* ...);
File& scan(const char* ...);
File& flush();
File& flush(char ch);
int fill();
File& seek(long pos, int seek_mode=0);
long tell();
File& setbuf(int buffer_kind);
File& setbuf(int size, char* buf);
File& raw();
};
extern void verbose_File_error_handler(char*);
extern void quiet_File_error_handler(char*);
extern void fatal_File_error_handler(char*);
extern one_arg_error_handler_t File_error_handler;
extern one_arg_error_handler_t set_File_error_handler(one_arg_error_handler_t);
inline int File::filedesc()
{
return ((fp)->_file) ;
}
inline const char* File::name()
{
return nm;
}
inline int File::iocount()
{
return stat;
}
inline File::operator struct _iobuf *()
{
return fp;
}
inline void File::clear(state_value flag = _good)
{
state = flag;
}
inline void File::set(state_value flag)
{
state = state_value(int(state) | int(flag));
}
inline void File::unset(state_value flag)
{
state = state_value(int(state) & ~int(flag));
}
inline int File::readable()
{
if (fp != 0) { if ( (((fp)->_flag& 00020 )!=0) ) set(_eof); if ( (((fp)->_flag& 00040 )!=0) ) set(_bad);}
return (state == _good && (rw & 01));
}
inline int File::writable()
{
if (fp != 0 && (((fp)->_flag& 00040 )!=0) ) set(_bad);
return ((int(state) & (int(_fail)|int(_bad))) == 0 && (rw & 02));
}
inline int File::is_open()
{
return (fp != 0);
}
inline File& File::raw()
{
return this->File::setbuf( 00004 );
}
inline void File::check_state()
{
if (fp != 0)
{
if ( (((fp)->_flag& 00020 )!=0) )
set(_eof);
else
unset(_eof);
if ( (((fp)->_flag& 00040 )!=0) )
set(_bad);
}
}
inline File& File::failif(int cond)
{
if (cond) set(_fail); return *this;
}
inline File& File::get(char& c)
{
if (readable())
{
int ch = (--(fp)->_cnt>=0?(int)(*(unsigned char*)(fp)->_ptr++):_filbuf(fp)) ;
c = ch;
failif (ch == (-1) );
}
return *this;
}
inline File& File::put(char c)
{
return failif (!writable() || (--( fp)->_cnt>=0? ((int)((unsigned char)((*( fp)->_ptr++=(unsigned)(c))))):_flsbuf((unsigned)(c), fp)) == (-1) );
}
inline File& File::unget(char c)
{
return failif(!is_open() || !(rw & 01) || ungetc(c, fp) == (-1) );
}
inline File& File::putback(char c)
{
return failif (!is_open() || !(rw & 01) || ungetc(c, fp) == (-1) );
}
inline File& File::read(void* x, int sz, int n)
{
return failif (!readable() || (stat = fread(x, sz, n, fp)) != n);
}
inline File& File::write(void* x, int sz, int n)
{
return failif (!writable() || (stat = fwrite(x, sz, n, fp)) != n);
}
inline File& File::flush()
{
return failif(!is_open() || fflush(fp) == (-1) );
}
inline File& File::flush(char ch)
{
return failif(!is_open() || _flsbuf(ch, fp) == (-1) );
}
inline int File::fill()
{
failif(!is_open() || (stat = _filbuf(fp)) == (-1) );
return stat;
}
inline File& File::seek(long pos, int seek_mode = 0)
{
return failif (!is_open() || fseek(fp, pos, seek_mode) < 0);
}
inline long File::tell()
{
failif (!is_open() || ((stat = ftell(fp)) < 0));
return stat;
}
inline int File::rdstate()
{
check_state(); return state;
}
inline File::operator void*()
{
check_state(); return (int(state) & (int(_bad)|int(_fail)))? 0 : this ;
}
inline int File::eof()
{
check_state(); return state & _eof;
}
inline int File::fail()
{
check_state(); return state & _fail;
}
inline int File::bad()
{
check_state(); return state & _bad;
}
inline int File::good()
{
check_state(); return rdstate() == _good;
}
# 34 "/usr/local/lib/g++-include/stream.h" 2
# 1 "/usr/local/lib/g++-include/streambuf.h" 1
#pragma once
enum open_mode
{
input=0,
output=1,
append=2
};
class streambuf
{
public:
char* base;
char* pptr;
char* gptr;
char* eptr;
char alloc;
streambuf();
streambuf(char* buf, int buflen);
virtual ~streambuf();
int doallocate();
int allocate();
virtual int overflow(int c = (-1) );
virtual int underflow();
int sgetc();
int snextc();
void stossc();
int sputback(char);
int sputc(int c = (-1) );
virtual streambuf* setbuf(char* buf, int buflen, int preloaded_count = 0);
int sputs(const char* s);
int sputsn(const char* s, int len);
virtual const char* name();
virtual streambuf* open(const char* name, open_mode m);
virtual streambuf* open(const char* filename, io_mode m, access_mode a);
virtual streambuf* open(const char* filename, const char* m);
virtual streambuf* open(int filedesc, io_mode m);
virtual streambuf* open( struct _iobuf * fileptr);
virtual int is_open();
virtual int close();
virtual void error();
};
class filebuf: public streambuf
{
public:
int fd;
char opened;
int overflow(int c = (-1) );
int underflow();
filebuf();
filebuf(int newfd);
filebuf(int newfd, char* buf, int buflen);
~filebuf();
streambuf* open(const char* name, open_mode m);
int is_open();
int close();
};
class Filebuf: public streambuf
{
public:
File* Fp;
void init_streambuf_ptrs();
int overflow(int c = (-1) );
int underflow();
Filebuf();
Filebuf(const char* filename, io_mode m, access_mode a);
Filebuf(const char* filename, const char* m);
Filebuf(int filedesc, io_mode m);
Filebuf( struct _iobuf * fileptr);
~Filebuf();
const char* name();
streambuf* setbuf(char* buf, int buflen, int preloaded_count = 0);
streambuf* open(const char* filename, io_mode m, access_mode a);
streambuf* open(const char* filename, const char* m);
streambuf* open(int filedesc, io_mode m);
streambuf* open( struct _iobuf * fileptr);
int is_open();
int close();
void error();
};
inline int streambuf::allocate()
{
return (base == 0)? doallocate() : 0;
}
inline int streambuf::sgetc()
{
return (gptr >= pptr)? underflow() : int(*gptr);
}
inline int streambuf::snextc()
{
++gptr;
return (gptr >= pptr)? underflow() : int(*gptr);
}
inline void streambuf::stossc()
{
if (gptr >= pptr) underflow(); else gptr++;
}
inline int streambuf::sputback(char ch)
{
return (gptr > base)? (*--gptr = ch) : (-1) ;
}
inline int streambuf::sputc(int ch = (-1) )
{
return (pptr < eptr)? (*pptr++ = (char)(ch)) : overflow(ch);
}
# 35 "/usr/local/lib/g++-include/stream.h" 2
class whitespace
{
char filler;
};
class istream;
class ostream
{
friend class istream;
protected:
streambuf* bp;
state_value state;
char ownbuf;
public:
ostream(const char* filename, io_mode m, access_mode a);
ostream(const char* filename, const char* m);
ostream(int filedesc, io_mode m);
ostream( struct _iobuf * fileptr);
ostream(int sz, char* buf);
ostream(int filedesc, char* buf, int buflen);
ostream(int filedesc);
ostream(streambuf* s);
~ostream();
ostream& open(const char* filename, io_mode m, access_mode a);
ostream& open(const char* filename, const char* m);
ostream& open(int filedesc, io_mode m);
ostream& open( struct _iobuf * fileptr);
ostream& open(const char* filenam, open_mode m);
ostream& close();
ostream& flush();
int rdstate();
int eof();
int fail();
int bad();
int good();
int readable();
int writable();
int is_open();
operator void*();
int operator !();
const char* name();
char* bufptr();
void error();
void clear(state_value f = 0);
void set(state_value f);
void unset(state_value);
ostream& failif(int cond);
ostream& put(char c);
ostream& put(const char* s);
ostream& put(const char* s, int slen);
ostream& form(const char* fmt, ...);
ostream& operator << (short n);
ostream& operator << (unsigned short n);
ostream& operator << (int n);
ostream& operator << (unsigned int n);
ostream& operator << (long n);
ostream& operator << (unsigned long n);
ostream& operator << (long long n);
ostream& operator << (unsigned long long n);
ostream& operator << (float n);
ostream& operator << (double n);
ostream& operator << (const char* s);
ostream& operator << (char c);
};
class istream
{
friend void eatwhite(istream& s);
protected:
streambuf* bp;
state_value state;
ostream* tied_to;
char skipws;
char ownbuf;
void _flush();
char* readline (int chunk_number, char terminator);
public:
istream(const char* filename, io_mode m, access_mode a,
int sk=1, ostream* t = 0);
istream(const char* filename, const char* m,
int sk=1, ostream* t = 0);
istream(int filedesc, io_mode m, int sk=1, ostream* t = 0);
istream( struct _iobuf * fileptr, int sk=1, ostream* t = 0);
istream(int sz, char* buf, int sk=1, ostream* t = 0);
istream(int filedesc, int sk=1, ostream* t = 0);
istream(int filedesc, char* buf, int buflen,
int sk=1, ostream* t = 0);
istream(streambuf* s, int sk=1, ostream* t = 0);
~istream();
istream& open(const char* filename, io_mode m, access_mode a);
istream& open(const char* filename, const char* m);
istream& open(int filedesc, io_mode m);
istream& open( struct _iobuf * fileptr);
istream& open(const char* filenam, open_mode m);
istream& close();
ostream* tie(ostream* s);
int skip(int);
int rdstate();
int eof();
int fail();
int bad();
int good();
int readable();
int writable();
int is_open();
operator void*();
int operator !();
const char* name();
char* bufptr();
void error();
void clear(state_value f = 0);
void set(state_value f);
void unset(state_value f);
istream& failif(int cond);
istream& get(char& c);
istream& unget(char c);
istream& putback(char c);
istream& get (char* s, int n, char terminator = '\n');
istream& getline(char* s, int n, char terminator = '\n');
istream& gets (char **s, char terminator = '\n');
istream& operator >> (char& c);
istream& operator >> (short& n);
istream& operator >> (unsigned short& n);
istream& operator >> (int& n);
istream& operator >> (unsigned int& n);
istream& operator >> (long& n);
istream& operator >> (unsigned long& n);
istream& operator >> (long long& n);
istream& operator >> (unsigned long long& n);
istream& operator >> (float& n);
istream& operator >> (double& n);
istream& operator >> (char* s);
istream& operator >> (whitespace& w);
};
extern istream cin;
extern ostream cout;
extern ostream cerr;
extern whitespace WS;
inline void ostream::clear(state_value flag = _good)
{
state = flag;
}
inline void ostream::set(state_value flag)
{
state = state_value(int(state) | int(flag));
}
inline void ostream::unset(state_value flag)
{
state = state_value(int(state) & ~int(flag));
}
inline int ostream::rdstate()
{
return int(state);
}
inline int ostream::good()
{
return state == _good;
}
inline int ostream::eof()
{
return int(state) & int(_eof);
}
inline int ostream::fail()
{
return int(state) & int(_fail);
}
inline int ostream::bad()
{
return int(state) & int(_bad);
}
inline ostream::operator void*()
{
return (state == _good)? this : 0;
}
inline int ostream::operator !()
{
return (state != _good);
}
inline ostream& ostream::failif(int cond)
{
if (cond) set(_fail); return *this;
}
inline int ostream::is_open()
{
return bp->is_open();
}
inline int ostream::readable()
{
return 0;
}
inline int ostream::writable()
{
return (bp != 0) && (state == _good);
}
inline char* ostream::bufptr()
{
return bp->base;
}
inline ostream& ostream::flush()
{
bp->overflow(); return *this;
}
inline ostream& ostream::close()
{
bp->overflow(); bp->close(); return *this;
}
inline ostream& ostream::put(char ch)
{
return failif((state != _good) || bp->sputc(ch) == (-1) );
}
inline ostream& ostream::operator << (char ch)
{
return failif((state != _good) || bp->sputc(ch) == (-1) );
}
inline ostream& ostream::put(const char* s)
{
return failif((state != _good) || bp->sputs(s) == (-1) );
}
inline ostream& ostream::put(const char* s, int len)
{
return failif((state != _good) || bp->sputsn(s, len) == (-1) );
}
inline ostream& ostream::operator << (const char* s)
{
return failif((state != _good) || bp->sputs(s) == (-1) );
}
inline void istream::clear(state_value flag = _good)
{
state = flag;
}
inline void istream::set(state_value flag)
{
state = state_value(int(state) | int(flag));
}
inline void istream::unset(state_value flag)
{
state = state_value(int(state) & ~int(flag));
}
inline int istream::rdstate()
{
return int(state);
}
inline int istream::good()
{
return state == _good;
}
inline int istream::eof()
{
return int(state) & int(_eof);
}
inline int istream::fail()
{
return int(state) & int(_fail);
}
inline int istream::bad()
{
return int(state) & int(_bad);
}
inline istream::operator void*()
{
return (state == _good)? this : 0;
}
inline int istream::operator !()
{
return (state != _good);
}
inline istream& istream::failif(int cond)
{
if (cond) set(_fail); return *this;
}
inline int istream::is_open()
{
return bp->is_open();
}
inline int istream::readable()
{
return (bp != 0) && (bp->is_open()) && (state == _good);
}
inline int istream::writable()
{
return 0;
}
inline void istream::_flush()
{
if(tied_to != 0) tied_to->flush();
}
inline char* istream::bufptr()
{
return bp->base;
}
inline istream& istream::close()
{
bp->close(); return *this;
}
inline int istream::skip(int sk)
{
int was = skipws; skipws = sk; return was;
}
inline ostream* istream::tie(ostream* s)
{
ostream* was = tied_to; tied_to = s; return was;
}
inline istream& istream::unget(char c)
{
if (bp->sputback(c) == (-1) ) set(_fail); return *this;
}
inline istream& istream::putback(char c)
{
if (bp->sputback(c) == (-1) ) set(_fail); return *this;
}
inline void eatwhite(istream& s)
{
s >> WS;
}
# 130 "Object.h" 2
# 1 "/usr/local/lib/g++-include/errors.h" 1
const int MAX_MSG_ARG = 8;
const int MAX_FACILITIES = 32;
const int SYS_LAST_ERROR = 34;
enum severity_level { SUCCESS = 0,
INFORMATION = -1,
INFO = -1,
WARNING = -2,
ERROR = -3,
FATAL = -4,
DEFAULT = 1 };
const int FAC_SHIFT = 12;
const int OFFSET_MASK = 0xfff;
const int FAC_MASK = 0xfff000;
inline int FACILITY_CODE(int ER) { return ((ER&FAC_MASK)>>FAC_SHIFT); }
inline int OFFSET_INDEX(int ER) { return (ER&OFFSET_MASK); }
class ErrSpecs {
public:
int severity;
char* args;
char* text;
};
class ErrFac {
public:
char* longname;
ErrSpecs* errlist;
int last;
};
# 131 "Object.h" 2
class Class;
class Dictionary;
class OIOifd;
class OIOofd;
class OIOin;
class OIOout;
class Object;
class OrderedCltn;
class ReadFromTbl;
class StoreOnTbl;
class IdentSet;
typedef int bool;
const int YES = 1;
const int NO = 0;
inline char ABS(char x) { return x >= 0 ? x : -x; }
inline short ABS(short x) { return x >= 0 ? x : -x; }
inline int ABS(int x) { return x >= 0 ? x : -x; }
inline long ABS(long x) { return x >= 0 ? x : -x; }
inline float ABS(float x) { return x >= 0 ? x : -x; }
inline double ABS(double x) { return x >= 0 ? x : -x; }
inline char MAX(char a,char b) { return a >= b ? a : b; }
inline short MAX(short a,short b) { return a >= b ? a : b; }
inline int MAX(int a,int b) { return a >= b ? a : b; }
inline long MAX(long a,long b) { return a >= b ? a : b; }
inline float MAX(float a,float b) { return a >= b ? a : b; }
inline double MAX(double a,double b) { return a >= b ? a : b; }
inline void* MAX(void* a,void* b) { return a >= b ? a : b; }
inline unsigned char MAX(unsigned char a, unsigned char b) { return a >= b ? a : b; }
inline unsigned short MAX(unsigned short a, unsigned short b) { return a >= b ? a : b; }
inline unsigned int MAX(unsigned int a, unsigned int b) { return a >= b ? a : b; }
inline unsigned long MAX(unsigned long a, unsigned long b) { return a >= b ? a : b; }
inline char MIN(char a,char b) { return a <= b ? a : b; }
inline short MIN(short a,short b) { return a <= b ? a : b; }
inline int MIN(int a,int b) { return a <= b ? a : b; }
inline long MIN(long a,long b) { return a <= b ? a : b; }
inline float MIN(float a,float b) { return a <= b ? a : b; }
inline double MIN(double a,double b) { return a <= b ? a : b; }
inline void* MIN(void* a,void* b) { return a <= b ? a : b; }
inline unsigned char MIN(unsigned char a, unsigned char b) { return a <= b ? a : b; }
inline unsigned short MIN(unsigned short a, unsigned short b) { return a <= b ? a : b; }
inline unsigned int MIN(unsigned int a, unsigned int b) { return a <= b ? a : b; }
inline unsigned long MIN(unsigned long a, unsigned long b) { return a <= b ? a : b; }
static class NIHCL {
private:
static int initCount;
static bool init;
static unsigned char char_bit_mask[sizeof(char)*8];
static unsigned short short_bit_mask[sizeof(short)*8];
static unsigned int int_bit_mask[sizeof(int)*8];
static unsigned char bit_count[256];
static unsigned char bit_reverse[256];
private:
static void initTables();
public:
NIHCL();
~NIHCL();
static unsigned char charBitMask(int i) { return char_bit_mask[i]; }
static unsigned short shortBitMask(int i) { return short_bit_mask[i]; }
static unsigned int intBitMask(int i) { return int_bit_mask[i]; }
static unsigned char bitCount(int i) { return bit_count[i]; }
static unsigned char bitReverse(int i) { return bit_reverse[i]; }
static void initialize();
static bool initialized() { return init; }
static void setError(int error, int sev ...);
} NIHCL_init;
class ClassList : public NIHCL {
Class** clp;
friend Class;
public:
ClassList(const char*, ...);
~ClassList() {}
};
# 231 "Object.h"
# 262 "Object.h"
# 290 "Object.h"
# 326 "Object.h"
class Object : public NIHCL {
public:
static Object& castdown(Object& p) { return p; }
static const Object& castdown(const Object& p) { return p; }
static Object* castdown(Object* p) { return p; }
static const Object* castdown(const Object* p) { return p; }
static const Class* desc();
virtual const Class* isA() const = 0;
virtual Object* shallowCopy() const = 0;
private:
static Object* reader(OIOin& strm);
static Object* reader(OIOifd& fd);
public:
static Object* const nil;
public:
static Object* readFrom(OIOifd& fd);
static Object* readFrom(OIOin& strm);
protected:
Object(OIOifd&);
Object(OIOin&);
protected:
virtual void storer(OIOofd&) const;
virtual void storer(OIOout&) const;
friend OIOout;
friend OIOofd;
protected:
Object() {}
void ambigCheck(void*&, void*&, const Class&) const;
public:
void assertArgClass(const Class& expect, const char* fname) const;
void assertArgClass(const Object& ob, const Class& expect, const char* fname) const;
void assertArgSpecies(const Class& expect, const char* fname) const;
void assertArgSpecies(const Object& ob, const Class& expect, const char* fname) const;
void assertClass(const Class& expect) const;
void assertSpecies(const Class& expect) const;
const char* className() const;
Object* deepCopy() const;
void derivedClassResponsibility(const char*) const;
void invalidArgClass(const Class& expect, const char* fname) const;
void invalidArgClass(const Object& ob, const Class& expect, const char* fname) const;
void invalidArgSpecies(const Class& expect, const char* fname) const;
void invalidArgSpecies(const Object& ob, const Class& expect, const char* fname) const;
void invalidClass(const Class& expect) const;
void invalidSpecies(const Class& expect) const;
bool isKindOf(const Class&) const;
bool isMemberOf(const Class& clid) const { return isA()==&clid; }
bool isSame(const Object& ob) const { return this==&ob; }
bool isSpecies(const Class& clid) const { return species()==&clid; }
void shouldNotImplement(const char*) const;
void storeMemberOn(OIOofd&) const;
void storeMemberOn(OIOout&) const;
void storeOn(OIOofd&) const;
void storeOn(OIOout&) const;
void* _safe_castdown(const Class&) const;
virtual Object* addDependent(Object&);
virtual unsigned capacity() const;
virtual void changed();
virtual void changed(const Object&);
virtual int compare(const Object&) const = 0;
virtual Object* copy() const;
virtual void deepenShallowCopy() = 0;
virtual OrderedCltn& dependents() const;
virtual void destroyer();
virtual void dumpOn(ostream& strm =cerr) const;
virtual unsigned hash() const = 0;
virtual bool isEqual(const Object&) const = 0;
virtual void scanFrom(istream& strm);
virtual void printOn(ostream& strm =cout) const = 0;
virtual void release();
virtual Object* removeDependent(const Object&);
virtual unsigned size() const;
virtual const Class* species() const;
virtual void update(const Object&, const Object&);
virtual void* _castdown(const Class&) const;
};
class Class : public Object {
private:
static unsigned long readFrom_level;
static unsigned long storeOn_level;
static unsigned long addObjectFlag;
friend Object::Object(OIOin&);
friend Object::Object(OIOifd&);
static IdentSet* storeVBaseTbl;
friend void Object::storeOn(OIOout&) const;
friend void Object::storeOn(OIOofd&) const;
public:
static Dictionary& dictionary;
static ReadFromTbl* readFromTbl;
static StoreOnTbl* storeOnTbl;
public:
typedef void (*initorTy)(const Class&);
static const Class* desc();
virtual const Class* isA() const;
virtual Object* shallowCopy() const;
private:
static Object* reader(OIOin& strm);
static Object* reader(OIOifd& fd);
public:
static Class& castdown(Object& p) { return (Class&)p; } static const Class& castdown(const Object& p) { return (const Class&)p; } static Class* castdown(Object* p) { return (Class*)p; } static const Class* castdown(const Object* p) { return (const Class*)p; }
static void initialize();
static const Class* lookup(const char* name);
static unsigned long readFromLevel() { return readFrom_level; }
static unsigned long storeOnLevel() { return storeOn_level; }
static bool _deepenVBase(void*);
static bool _storeVBase(void*);
private:
const char* class_name;
const char* class_ident;
const Class* *const class_bases;
const Class* *const class_members;
const Class* *const class_vbases;
const unsigned class_version;
const unsigned inst_size;
Object* (*const inst_reader)(OIOin&);
Object* (*const inst_binreader)(OIOifd&);
const initorTy class_initor2;
Class* nextClass;
unsigned long class_signature;
unsigned class_number;
private:
unsigned number(unsigned n) { return class_number = n; }
friend StoreOnTbl;
Object* readObject(OIOin&) const;
friend OIOin;
Object* readObject(OIOifd&) const;
friend OIOifd;
void addSignature(unsigned long);
void computeSignature();
public:
Class(const char* name,
const ClassList& bases, const ClassList& members, const ClassList& vbases,
unsigned version, const char* ident, unsigned size,
Object* (*reader)(OIOin&),
Object* (*binreader)(OIOifd&),
initorTy initor1 =0, initorTy initor2 =0);
Class(const Class&);
Class(OIOifd&);
Class(OIOin&);
const char* name() const { return class_name; }
const Class** baseClasses() const { return class_bases; }
const Class** memberClasses() const { return class_members; }
const Class** virtualBaseClasses() const { return class_vbases; }
const char* ident() const { return class_ident; }
unsigned number() const { return class_number; }
unsigned long signature() const {
if (class_signature == 0) ((Class*)this)->computeSignature();
return class_signature;
}
unsigned version() const { return class_version; }
Object* readFrom(OIOifd& fd) const;
Object* readFrom(OIOin&) const;
bool _isKindOf(const Class&) const;
virtual int compare(const Object&) const;
virtual void dumpOn(ostream& strm =cerr) const;
virtual unsigned hash() const;
virtual bool isEqual(const Object& ob) const;
virtual void printOn(ostream& strm =cout) const;
virtual unsigned size() const;
virtual void* _castdown(const Class&) const;
private:
virtual void deepenShallowCopy();
virtual void storer(OIOout&) const;
virtual void storer(OIOofd&) const;
};
inline const char* Object::className() const { return isA()->name(); }
inline Object* Object::readFrom(OIOifd& fd) { return desc()->readFrom(fd); }
inline Object* Object::readFrom(OIOin& strm) { return desc()->readFrom(strm); }
inline void Object::assertArgClass(const Class& expect, const char* fname) const
{
if (!isKindOf(expect)) invalidArgClass(expect,fname);
}
inline void Object::assertArgClass(const Object& ob, const Class& expect, const char* fname) const
{
if (!(ob.isKindOf(expect))) invalidArgClass(ob,expect,fname);
}
inline void Object::assertArgSpecies(const Class& expect, const char* fname) const
{
if (!isSpecies(expect)) invalidArgSpecies(expect,fname);
}
inline void Object::assertArgSpecies(const Object& ob, const Class& expect, const char* fname) const
{
if (!(ob.isSpecies(expect))) this->invalidArgSpecies(ob,expect,fname);
}
inline void Object::assertClass(const Class& expect) const
{
if (!isKindOf(expect)) invalidClass(expect);
}
inline void Object::assertSpecies(const Class& expect) const
{
if (!isSpecies(expect)) invalidSpecies(expect);
}
inline istream& operator>>(istream& strm, Object& ob)
{
ob.scanFrom(strm);
return strm;
}
inline ostream& operator<<(ostream& strm, const Object& ob)
{
ob.printOn(strm);
return strm;
}
# 74 "Collection.h" 2
class ArrayOb;
class Bag;
class Heap;
class Iterator;
class OrderedCltn;
class Set;
class SortedCltn;
class Collection: public Object {
private: static Class classDesc; public: static Collection& castdown(Object& p) { return (Collection&)p; } static const Collection& castdown(const Object& p) { return (const Collection&)p; } static Collection* castdown(Object* p) { return (Collection*)p; } static const Collection* castdown(const Object* p) { return (const Collection*)p; } static const Class* desc() { return &classDesc; } static Collection* readFrom(OIOin& strm) { return castdown(desc()->readFrom(strm)); } static Collection* readFrom
(OIOifd& fd) { return castdown(desc()->readFrom(fd)); } Collection(OIOin&); Collection(OIOifd&); virtual const Class* isA() const; virtual Object* shallowCopy() const; virtual void* _castdown(const Class&) const; protected: void deepenVBase(); void storeVBaseOn(OIOofd&) const; void storeVBaseOn(OIOout&) const; private: static Object* reader(OIOin& strm); static Object* reader(OIOifd& fd) ;
public:
static const unsigned DEFAULT_CAPACITY;
static const unsigned EXPANSION_INCREMENT;
static const unsigned EXPANSION_FACTOR;
protected:
Collection();
protected:
void _storer(OIOofd&) const;
void _storer(OIOout&) const;
public:
ArrayOb asArrayOb() const;
Bag asBag() const;
Heap asHeap() const;
OrderedCltn asOrderedCltn() const;
Set asSet() const;
SortedCltn asSortedCltn() const;
virtual ~Collection() {}
virtual Object* add(Object&) = 0;
virtual const Collection& addAll(const Collection&);
virtual Collection& addContentsTo(Collection&) const;
virtual Object*& at(int) = 0;
virtual const Object *const& at(int) const = 0;
virtual int compare(const Object&) const = 0;
virtual void deepenShallowCopy();
virtual void doFinish(Iterator& pos) const;
virtual Object* doNext(Iterator&) const = 0;
virtual void doReset(Iterator& pos) const;
virtual void dumpOn(ostream& strm =cerr) const;
virtual unsigned hash() const = 0;
virtual bool includes(const Object&) const;
virtual bool isEmpty() const;
virtual bool isEqual(const Object&) const = 0;
virtual unsigned occurrencesOf(const Object&) const = 0;
virtual void printOn(ostream& strm =cout) const;
virtual Object* remove(const Object&) = 0;
virtual void removeAll() = 0;
virtual const Collection& removeAll(const Collection&);
virtual unsigned size() const = 0;
};
# 1 "Iterator.h" 1
# 1 "Object.h" 1
# 564 "Object.h"
# 71 "Iterator.h" 2
class Collection;
class Iterator: public Object {
private: static Class classDesc; public: static Iterator& castdown(Object& p) { return (Iterator&)p; } static const Iterator& castdown(const Object& p) { return (const Iterator&)p; } static Iterator* castdown(Object* p) { return (Iterator*)p; } static const Iterator* castdown(const Object* p) { return (const Iterator*)p; } static const Class* desc() { return &classDesc; } static Iterator* readFrom(OIOin& strm) { return castdown(desc()->readFrom(strm)); } static Iterator* readFrom(OIOifd& fd) { retur
n castdown(desc()->readFrom(fd)); } Iterator(OIOin&); Iterator(OIOifd&); virtual const Class* isA() const; virtual Object* shallowCopy() const; virtual void* _castdown(const Class&) const; protected: void deepenVBase(); void storeVBaseOn(OIOofd&) const; void storeVBaseOn(OIOout&) const; private: static Object* reader(OIOin& strm); static Object* reader(OIOifd& fd) ;
const Collection* cltn;
public:
int index;
Object* ptr;
unsigned num;
Object* state;
protected:
virtual void storer(OIOofd&) const;
virtual void storer(OIOout&) const;
public:
Iterator(const Collection&);
~Iterator();
void reset();
Object* operator()() const { return ptr; }
Object* operator++();
const Collection* collection() const { return cltn; }
bool operator==(const Iterator&) const;
bool operator!=(const Iterator& a) const { return !(*this==a); }
virtual void deepenShallowCopy();
virtual void dumpOn(ostream& strm =cerr) const;
virtual unsigned hash() const;
virtual bool isEqual(const Object&) const;
virtual void printOn(ostream& strm =cout) const;
virtual const Class* species() const;
private:
virtual int compare(const Object&) const;
};
# 126 "Collection.h" 2
# 71 "ArrayOb.h" 2
class ArrayOb: public Collection {
private: static Class classDesc; public: static ArrayOb& castdown(Object& p) { return (ArrayOb&)p; } static const ArrayOb& castdown(const Object& p) { return (const ArrayOb&)p; } static ArrayOb* castdown(Object* p) { return (ArrayOb*)p; } static const ArrayOb* castdown(const Object* p) { return (const ArrayOb*)p; } static const Class* desc() { return &classDesc; } static ArrayOb* readFrom(OIOin& strm) { return castdown(desc()->readFrom(strm)); } static ArrayOb* readFrom(OIOifd& fd) { return castdown
(desc()->readFrom(fd)); } ArrayOb(OIOin&); ArrayOb(OIOifd&); virtual const Class* isA() const; virtual Object* shallowCopy() const; virtual void* _castdown(const Class&) const; protected: void deepenVBase(); void storeVBaseOn(OIOofd&) const; void storeVBaseOn(OIOout&) const; private: static Object* reader(OIOin& strm); static Object* reader(OIOifd& fd) ;
Object** v;
unsigned sz;
void allocSizeErr() const;
void indexRangeErr() const;
protected:
virtual void storer(OIOofd&) const;
virtual void storer(OIOout&) const;
public:
ArrayOb(unsigned size =DEFAULT_CAPACITY);
ArrayOb(const ArrayOb&);
~ArrayOb();
Object*& elem(int i) { return v[i]; }
const Object *const& elem(int i) const { return v[i]; }
bool operator!=(const ArrayOb& a) const { return !(*this==a); }
void operator=(const ArrayOb&);
bool operator==(const ArrayOb&) const;
Object*& operator[](int i) {
if ((unsigned)i >= sz) indexRangeErr();
return v[i];
}
const Object *const& operator[](int i) const {
if ((unsigned)i >= sz) indexRangeErr();
return v[i];
}
virtual Collection& addContentsTo(Collection&) const;
virtual Object*& at(int i);
virtual const Object *const& at(int i) const;
virtual unsigned capacity() const;
virtual int compare(const Object&) const;
virtual void deepenShallowCopy();
virtual Object* doNext(Iterator&) const;
virtual unsigned hash() const;
virtual bool isEqual(const Object&) const;
virtual void reSize(unsigned);
virtual void removeAll();
virtual unsigned size() const;
virtual void sort();
virtual const Class* species() const;
private:
virtual Object* add(Object&);
virtual unsigned occurrencesOf(const Object&) const;
virtual Object* remove(const Object&);
};
# 85 "ArrayOb.c" 2
# 1 "nihclIO.h" 1
# 1 "OIO.h" 1
# 1 "Object.h" 1
# 564 "Object.h"
# 50 "OIO.h" 2
class OIOin : public NIHCL {
protected:
Object* _readObject(const Class& cl) { return cl.readObject(*this); }
virtual Object* readObject(const Class&) = 0;
friend Object* Class::readFrom(OIOin&) const;
public:
OIOin() {}
virtual OIOin& operator>>(char*) = 0;
virtual OIOin& operator>>(char&) = 0;
virtual OIOin& operator>>(unsigned char&) = 0;
virtual OIOin& operator>>(short&) = 0;
virtual OIOin& operator>>(unsigned short&) = 0;
virtual OIOin& operator>>(int&) = 0;
virtual OIOin& operator>>(unsigned int&) = 0;
virtual OIOin& operator>>(long&) = 0;
virtual OIOin& operator>>(unsigned long&) = 0;
virtual OIOin& operator>>(float&) = 0;
virtual OIOin& operator>>(double&) = 0;
virtual OIOin& operator>>(streambuf*) = 0;
virtual int get() = 0;
virtual OIOin& get(char&) = 0;
virtual OIOin& get(unsigned char&) = 0;
virtual OIOin& get(char*, unsigned size) = 0;
virtual OIOin& get(unsigned char*, unsigned size) = 0;
virtual OIOin& get(short*, unsigned size) = 0;
virtual OIOin& get(unsigned short*, unsigned size) = 0;
virtual OIOin& get(int*, unsigned size) = 0;
virtual OIOin& get(unsigned int*, unsigned size) = 0;
virtual OIOin& get(long*, unsigned size) = 0;
virtual OIOin& get(unsigned long*, unsigned size) = 0;
virtual OIOin& get(float*, unsigned size) = 0;
virtual OIOin& get(double*, unsigned size) = 0;
virtual OIOin& get(streambuf&, char delim ='\n') = 0;
virtual OIOin& getCString(char*, unsigned maxlen) = 0;
virtual int precision() = 0;
virtual int precision(int) = 0;
virtual int width() = 0;
virtual int width(int) = 0;
};
class OIOout : public NIHCL {
protected:
void _storer(const Object& ob) { ob.storer(*this); }
virtual void storeObject(const Object&) = 0;
friend void Object::storeOn(OIOout&) const;
public:
OIOout() {};
virtual OIOout& operator<<(const char*) = 0;
virtual OIOout& operator<<(char) = 0;
virtual OIOout& operator<<(unsigned char) = 0;
virtual OIOout& operator<<(short) = 0;
virtual OIOout& operator<<(unsigned short) = 0;
virtual OIOout& operator<<(int) = 0;
virtual OIOout& operator<<(unsigned) = 0;
virtual OIOout& operator<<(long) = 0;
virtual OIOout& operator<<(unsigned long) = 0;
virtual OIOout& operator<<(float) = 0;
virtual OIOout& operator<<(double) = 0;
virtual OIOout& put(char) = 0;
virtual OIOout& put(const char* val, unsigned size) = 0;
virtual OIOout& put(const unsigned char* val, unsigned size) = 0;
virtual OIOout& put(const short* val, unsigned size) = 0;
virtual OIOout& put(const unsigned short* val, unsigned size) = 0;
virtual OIOout& put(const int* val, unsigned size) = 0;
virtual OIOout& put(const unsigned int* val, unsigned size) = 0;
virtual OIOout& put(const long* val, unsigned size) = 0;
virtual OIOout& put(const unsigned long* val, unsigned size) = 0;
virtual OIOout& put(const float* val, unsigned size) = 0;
virtual OIOout& put(const double* val, unsigned size) = 0;
virtual OIOout& putCString(const char*) = 0;
virtual int precision() = 0;
virtual int precision(int) = 0;
virtual int width() = 0;
virtual int width(int) = 0;
};
# 4 "nihclIO.h" 2
# 1 "OIOfd.h" 1
# 1 "Object.h" 1
# 564 "Object.h"
# 57 "OIOfd.h" 2
# 1 "/usr/local/lib/g++-include/string.h" 1
# 58 "OIOfd.h" 2
# 1 "/usr/local/lib/g++-include/osfcn.h" 1
#pragma once
# 1 "/usr/local/lib/g++-include/time.h" 1
# 1 "/usr/local/lib/g++-include/sys/types.h" 1
#pragma once
extern "C"
{
# 1 "//usr/include/sys/types.h" 1
# 1 "/usr/include/sys/sysmacros.h" 1
# 16 "//usr/include/sys/types.h" 2
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef struct _physadr { short r[1]; } *physadr;
typedef struct label_t {
int val[13];
} label_t;
typedef struct _quad { long val[2]; } quad;
typedef long daddr_t;
typedef char * caddr_t;
typedef u_long ino_t;
typedef long swblk_t;
typedef int ____size_t ;
typedef long time_t;
typedef short dev_t;
typedef long off_t;
typedef u_short uid_t;
typedef u_short gid_t;
typedef long key_t;
typedef long fd_mask;
typedef struct fd_set {
fd_mask fds_bits[(((256 )+(( (sizeof(fd_mask) * 8 ) )-1))/( (sizeof(fd_mask) * 8 ) )) ];
} fd_set;
typedef char * addr_t;
# 107 "//usr/include/sys/types.h"
# 7 "/usr/local/lib/g++-include/sys/types.h" 2
}
# 9 "/usr/local/lib/g++-include/time.h" 2
extern "C" {
# 1 "//usr/include/sys/time.h" 1
struct timeval {
long tv_sec;
long tv_usec;
};
struct c_proto_timezone {
int tz_minuteswest;
int tz_dsttime;
};
struct itimerval {
struct timeval it_interval;
struct timeval it_value;
};
# 27 "/usr/local/lib/g++-include/time.h" 2
# 1 "//usr/include/sys/times.h" 1
struct tms {
time_t tms_utime;
time_t tms_stime;
time_t tms_cutime;
time_t tms_cstime;
};
# 28 "/usr/local/lib/g++-include/time.h" 2
# 1 "//usr/include/time.h" 1
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
char *tm_zone;
long tm_gmtoff;
};
extern struct tm *c_proto_gmtime (), *c_proto_localtime ();
extern char *c_proto_asctime (), *c_proto_ctime ();
extern void c_proto_tzset (), c_proto_tzsetwall ();
# 29 "/usr/local/lib/g++-include/time.h" 2
extern struct tm* localtime(long*);
extern struct tm* gmtime(long*);
extern char* ctime(long*);
extern char* asctime(struct tm*);
extern void tzset();
extern void tzsetwall();
extern long times(struct tms*);
extern char* timezone(int, int);
typedef struct c_proto_timezone timezone;
extern int getitimer(int, struct itimerval*);
extern int setitimer(int, struct itimerval*, struct itimerval*);
extern int gettimeofday(struct timeval*, struct timezone*);
extern int settimeofday(struct timeval*, struct timezone*);
}
# 3 "/usr/local/lib/g++-include/osfcn.h" 2
# 1 "/usr/local/lib/g++-include/sys/socket.h" 1
#pragma once
# 1 "/usr/local/lib/g++-include/time.h" 1
# 69 "/usr/local/lib/g++-include/time.h"
# 5 "/usr/local/lib/g++-include/sys/socket.h" 2
extern "C"
{
# 1 "//usr/include/sys/socket.h" 1
struct linger {
int l_onoff;
int l_linger;
};
struct sockaddr {
u_short sa_family;
char sa_data[14];
};
struct sockproto {
u_short sp_family;
u_short sp_protocol;
};
struct msghdr {
caddr_t msg_name;
int msg_namelen;
struct iovec *msg_iov;
int msg_iovlen;
caddr_t msg_accrights;
int msg_accrightslen;
};
# 10 "/usr/local/lib/g++-include/sys/socket.h" 2
int select(int, void*, void*, void*, struct timeval*);
int connect(int, struct sockaddr*, int);
int accept(int, struct sockaddr*, int*);
int getsockname(int, struct sockaddr*, int*);
}
# 4 "/usr/local/lib/g++-include/osfcn.h" 2
# 1 "/usr/local/lib/g++-include/sys/resource.h" 1
#pragma once
# 1 "/usr/local/lib/g++-include/time.h" 1
# 69 "/usr/local/lib/g++-include/time.h"
# 4 "/usr/local/lib/g++-include/sys/resource.h" 2
extern "C"
{
# 1 "//usr/include/sys/resource.h" 1
struct rusage {
struct timeval ru_utime;
struct timeval ru_stime;
long ru_maxrss;
long ru_ixrss;
long ru_idrss;
long ru_isrss;
long ru_minflt;
long ru_majflt;
long ru_nswap;
long ru_inblock;
long ru_oublock;
long ru_msgsnd;
long ru_msgrcv;
long ru_nsignals;
long ru_nvcsw;
long ru_nivcsw;
};
struct rlimit {
int rlim_cur;
int rlim_max;
};
# 10 "/usr/local/lib/g++-include/sys/resource.h" 2
int getrusage(int, struct rusage*);
}
# 5 "/usr/local/lib/g++-include/osfcn.h" 2
# 59 "OIOfd.h" 2
class OIOifd : public NIHCL {
int fd;
protected:
virtual Object* readObject(const Class&);
friend Object* Class::readFrom(OIOifd&) const;
public:
OIOifd(int filedesc) { fd = filedesc; }
operator int() { return fd; }
OIOifd& operator>>(char& val) {
get((char*)&val,sizeof(val));
return *this;
}
OIOifd& operator>>(unsigned char& val) {
get((char*)&val,sizeof(val));
return *this;
}
OIOifd& operator>>(short& val) {
get((char*)&val,sizeof(val));
return *this;
}
OIOifd& operator>>(unsigned short& val) {
get((char*)&val,sizeof(val));
return *this;
}
OIOifd& operator>>(int& val) {
get((char*)&val,sizeof(val));
return *this;
}
OIOifd& operator>>(unsigned int& val) {
get((char*)&val,sizeof(val));
return *this;
}
OIOifd& operator>>(long& val) {
get((char*)&val,sizeof(val));
return *this;
}
OIOifd& operator>>(unsigned long& val) {
get((char*)&val,sizeof(val));
return *this;
}
OIOifd& operator>>(float& val) {
get((char*)&val,sizeof(val));
return *this;
}
OIOifd& operator>>(double& val) {
get((char*)&val,sizeof(val));
return *this;
}
int get() { char c; get(c); return c; }
OIOifd& get(char& c) { get((unsigned char*) &c,1); return *this; }
OIOifd& get(unsigned char& c) { get(&c,1); return *this; }
OIOifd& get(char*, unsigned size);
OIOifd& get(unsigned char* val, unsigned size) {
get((char*)val,size*sizeof(*val));
return *this;
}
OIOifd& get(short* val, unsigned size) {
get((char*)val,size*sizeof(*val));
return *this;
}
OIOifd& get(unsigned short* val, unsigned size) {
get((char*)val,size*sizeof(*val));
return *this;
}
OIOifd& get(int* val, unsigned size) {
get((char*)val,size*sizeof(*val));
return *this;
}
OIOifd& get(unsigned int* val, unsigned size) {
get((char*)val,size*sizeof(*val));
return *this;
}
OIOifd& get(long* val,unsigned size) {
get((char*)val,size*sizeof(*val));
return *this;
}
OIOifd& get(unsigned long* val,unsigned size) {
get((char*)val,size*sizeof(*val));
return *this;
}
OIOifd& get(float* val,unsigned size) {
get((char*)val,size*sizeof(*val));
return *this;
}
OIOifd& get(double* val,unsigned size) {
get((char*)val,size*sizeof(*val));
return *this;
}
OIOifd& getCString(char*, unsigned maxlen);
};
class OIOofd : public NIHCL {
int fd;
void writeErr();
protected:
virtual void storeObject(const Object&);
friend void Object::storeOn(OIOofd&) const;
public:
OIOofd(int filedesc) { fd = filedesc; }
operator int() { return fd; }
OIOofd& operator<<(const char* val) {
*this << (unsigned)strlen(val);
put((unsigned char *)val,strlen(val));
return *this;
}
OIOofd& operator<<(char val) {
put((unsigned char*)&val,sizeof(val));
return *this;
}
OIOofd& operator<<(unsigned char val) {
put((unsigned char*)&val,sizeof(val));
return *this;
}
OIOofd& operator<<(short val) {
put((unsigned char*)&val,sizeof(val));
return *this;
}
OIOofd& operator<<(unsigned short val) {
put((unsigned char*)&val,sizeof(val));
return *this;
}
OIOofd& operator<<(int val) {
put((unsigned char*)&val,sizeof(val));
return *this;
}
OIOofd& operator<<(unsigned int val) {
put((unsigned char*)&val,sizeof(val));
return *this;
}
OIOofd& operator<<(long val) {
put((unsigned char*)&val,sizeof(val));
return *this;
}
OIOofd& operator<<(unsigned long val) {
put((unsigned char*)&val,sizeof(val));
return *this;
}
OIOofd& operator<<(float val) {
put((unsigned char*)&val,sizeof(float));
return *this;
}
OIOofd& operator<<(double val) {
put((unsigned char*)&val,sizeof(double));
return *this;
}
OIOofd& put(const char* val,unsigned size) {
write((const char*)val,size*sizeof(*val));
return *this;
}
OIOofd& put(const unsigned char* val,unsigned size) {
return put((const char*)val, size);
}
OIOofd& put(const short* val,unsigned size) {
write((const char*)val,size*sizeof(*val));
return *this;
}
OIOofd& put(const unsigned short* val,unsigned size) {
write((const char*)val,size*sizeof(*val));
return *this;
}
OIOofd& put(const int* val,unsigned size) {
write((const char*)val,size*sizeof(*val));
return *this;
}
OIOofd& put(const unsigned int* val,unsigned size) {
write((const char*)val,size*sizeof(*val));
return *this;
}
OIOofd& put(const long* val,unsigned size) {
write((const char*)val,size*sizeof(*val));
return *this;
}
OIOofd& put(const unsigned long* val,unsigned size) {
write((const char*)val,size*sizeof(*val));
return *this;
}
OIOofd& put(const float* val,unsigned size) {
write((const char*)val,size*sizeof(*val));
return *this;
}
OIOofd& put(const double* val,unsigned size) {
write((const char*)val,size*sizeof(*val));
return *this;
}
OIOofd& putCString(const char*);
OIOofd& write(const char* buf,unsigned nbyte) {
if (::write(fd,buf,nbyte) < 0) writeErr();
return *this;
}
public:
enum oioRecordTy {
storeOnClassRef,
storeOnClass,
storeOnObjectRef
};
};
# 5 "nihclIO.h" 2
# 86 "ArrayOb.c" 2
Object* ArrayOb::reader(OIOin& strm) { return new ArrayOb(strm); } Object* ArrayOb::reader(OIOifd& fd) { return new ArrayOb(fd); } Object* ArrayOb::shallowCopy() const { return new ArrayOb(*this); } Class ArrayOb::classDesc("ArrayOb" , ClassList(0,Collection ::desc() ,0), ClassList(0, -0,0), ClassList(0, -0,0), 1, "$Header: ArrayOb.c,v 2.204 89/10/07 23:18:26 keith Stab $", sizeof(ArrayOb), ArrayOb::reader, ArrayOb::reader, 0 , 0 ); const Class* ArrayOb::isA() const { return &classDesc; } void ArrayOb::d
eepenVBase() { if (Class::_deepenVBase((const void*)this)) ArrayOb::deepenShallowCopy(); } void ArrayOb::storeVBaseOn(OIOofd& fd) const { if (Class::_storeVBase((const void*)this)) ArrayOb::storer(fd); } void ArrayOb::storeVBaseOn(OIOout& strm) const { if (Class::_storeVBase((const void*)this)) ArrayOb::storer(strm); } void* ArrayOb::_castdown(const Class& target) const { if (&target == desc()) return (void*)this; return Collection ::_castdown(target); } ;
extern const int NIHCL_ALLOCSIZE,NIHCL_INDEXRANGE;
inline void DELETE(Object** ptr) { free((char*)ptr); }
inline Object** REALLOC(Object** ptr, unsigned size)
{
return (Object**)realloc((char*)ptr,sizeof(Object*)*size);
}
ArrayOb::ArrayOb(unsigned size)
{
sz = size;
if (sz==0) allocSizeErr();
v = ((Object**)malloc(sizeof(Object*)*(sz))) ;
register i = sz;
register Object** vp = v;
while (i--) *vp++ = nil;
}
ArrayOb::ArrayOb(const ArrayOb& a)
{
register i = a.sz;
sz = i;
v = ((Object**)malloc(sizeof(Object*)*(i))) ;
register Object** vp = v;
register Object** av = a.v;
while (i--) *vp++ = *av++;
}
ArrayOb::~ArrayOb() { DELETE(v); }
void ArrayOb::operator=(const ArrayOb& a)
{
if (v != a.v) {
DELETE(v);
v = ((Object**)malloc(sizeof(Object*)*(sz=a.sz))) ;
register i = a.sz;
register Object** vp = v;
register Object** av = a.v;
while (i--) *vp++ = *av++;
}
}
bool ArrayOb::operator==(const ArrayOb& a) const
{
if (sz != a.sz) return NO;
register unsigned i = sz;
register Object** vp = v;
register Object** av = a.v;
while (i--) { if (!((*vp++)->isEqual(**av++))) return NO; }
return YES;
}
Object*& ArrayOb::at(int i) { return (*this)[i]; }
const Object *const& ArrayOb::at(int i) const { return (*this)[i]; }
unsigned ArrayOb::capacity() const { return sz; }
bool ArrayOb::isEqual(const Object& a) const
{
return a.isSpecies(classDesc) && *this==castdown(a);
}
const Class* ArrayOb::species() const { return &classDesc; }
void ArrayOb::reSize(unsigned newsize)
{
if (newsize == 0) allocSizeErr();
v = REALLOC(v,newsize);
if (newsize > sz) {
Object** vp = &v[sz];
while (newsize > sz) {
*vp++ = nil;
sz++;
}
}
else sz = newsize;
}
void ArrayOb::removeAll()
{
register Object** vp = v;
register unsigned i = sz;
while (i--) *vp++ = nil;
}
Collection& ArrayOb::addContentsTo(Collection& cltn) const
{
register Object** vp = v;
register unsigned i = sz;
while (i--) cltn.add(**vp++);
return cltn;
}
Object* ArrayOb::doNext(Iterator& pos) const
{
if (pos.index < size()) return v[pos.index++];
return 0;
}
void ArrayOb::deepenShallowCopy()
{
Collection ::deepenShallowCopy();
register i = sz;
register Object** vp = v;
while (i--) {
*vp = (*vp)->deepCopy();
vp++;
}
}
unsigned ArrayOb::hash() const
{
register unsigned h = sz;
register unsigned i = sz;
register Object** vp = v;
while (i--) h^=(*vp++)->hash();
return h;
}
ArrayOb::ArrayOb(OIOin& strm)
:
Collection (strm)
{
strm >> sz;
v = ((Object**)malloc(sizeof(Object*)*(sz))) ;
for (register unsigned i=0; i<sz; i++) v[i] = Object::readFrom(strm);
}
void ArrayOb::storer(OIOout& strm) const
{
Collection ::storer(strm);
strm << sz;
for (register unsigned i=0; i<sz; i++) v[i]->storeOn(strm);
}
unsigned ArrayOb::size() const { return sz; }
static int compare_ob(const void* a, const void* b)
{
return (*(const Object**)a)->compare(**(const Object**)b);
}
void ArrayOb::sort()
{
qsort(v,sz,sizeof(Object*),compare_ob);
}
void ArrayOb::allocSizeErr() const
{
setError(NIHCL_ALLOCSIZE,DEFAULT,this,className());
}
void ArrayOb::indexRangeErr() const
{
setError(NIHCL_INDEXRANGE,DEFAULT,this,className());
}
ArrayOb::ArrayOb(OIOifd& fd)
:
Collection (fd)
{
fd >> sz;
v = ((Object**)malloc(sizeof(Object*)*(sz))) ;
for (register unsigned i=0; i<sz; i++ )
v[i] = Object::readFrom(fd);
}
void ArrayOb::storer(OIOofd& fd) const
{
Collection ::storer(fd);
fd << sz;
for (register unsigned i=0; i<sz; i++)
v[i]->storeOn(fd);
}
int ArrayOb::compare(const Object& arg) const
{
assertArgSpecies(arg,classDesc,"compare");
const ArrayOb& a = castdown(arg);
for (int i=0; i<sz; i++) {
if (i == a.sz) return 1;
int val;
if ((val = v[i]->compare(*a.v[i])) != 0) return val;
}
if (sz == a.sz) return 0;
return -1;
}
Object* ArrayOb::add(Object& ob)
{
shouldNotImplement("add");
return &ob;
}
unsigned ArrayOb::occurrencesOf(const Object&) const
{
shouldNotImplement("occurrencesOf");
return 0;
}
Object* ArrayOb::remove(const Object&)
{
shouldNotImplement("remove");
return 0;
}
dirt:lib:28 > /src/gnu/g++-new/g++ -B/src/gnu/g++-new/ -c -v -ansi -fdefault-inline ArrayOb.c -o ArrayOb.o
g++ version 1.36.2- (based on GCC 1.36)
/usr/local/lib/gcc-cpp -+ -v -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ ArrayOb.c /usr/tmp/cca21886.cpp
GNU CPP version 1.36
/src/gnu/g++-new/cc1plus /usr/tmp/cca21886.cpp -quiet -dumpbase ArrayOb.c -fdefault-inline -version -o /usr/tmp/cca21886.s
GNU C++ version 1.36.2- (based on GCC 1.36) (68k, MIT syntax) compiled by GNU C version 1.36.
default target switches: -m68020 -mc68020 -m68881 -mbitfield
/usr/local/lib/g++-include/streambuf.h: In method int streambuf::allocate ():
In file included from /usr/local/lib/g++-include/stream.h:35, from Object.h:131, from Collection.h:75, from ArrayOb.h:72, from ArrayOb.c:85:
/usr/local/lib/g++-include/streambuf.h:163: Segmentation violation
/src/gnu/g++-new/g++: Program cc1plus got fatal signal 11.
dirt:lib:29 >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads