1 // { dg-do assemble  }
2 // { dg-options "-w" }
3 // prms-id: 784
4 
5 //# 1 "GctSymbol.GctSymbol.CHMap.cc"
6 // This may look like C code, but it is really -*- C++ -*-
7 /*
8 Copyright (C) 1988, 2000, 2002 Free Software Foundation
9     written by Doug Lea (dl@rocky.oswego.edu)
10 
11 This file is part of the GNU C++ Library.  This library is free
12 software; you can redistribute it and/or modify it under the terms of
13 the GNU Library General Public License as published by the Free
14 Software Foundation; either version 2 of the License, or (at your
15 option) any later version.  This library is distributed in the hope
16 that it will be useful, but WITHOUT ANY WARRANTY; without even the
17 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 PURPOSE.  See the GNU Library General Public License for more details.
19 You should have received a copy of the GNU Library General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23 
24 
25 //#pragma implementation
26 
27 //# 1 "GctSymbol.GctSymbol.CHMap.h" 1
28 // This may look like C code, but it is really -*- C++ -*-
29 /*
30 Copyright (C) 1988 Free Software Foundation
31     written by Doug Lea (dl@rocky.oswego.edu)
32 
33 This file is part of the GNU C++ Library.  This library is free
34 software; you can redistribute it and/or modify it under the terms of
35 the GNU Library General Public License as published by the Free
36 Software Foundation; either version 2 of the License, or (at your
37 option) any later version.  This library is distributed in the hope
38 that it will be useful, but WITHOUT ANY WARRANTY; without even the
39 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
40 PURPOSE.  See the GNU Library General Public License for more details.
41 You should have received a copy of the GNU Library General Public
42 License along with this library; if not, write to the Free Software
43 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
44 */
45 
46 
47 
48 
49 //#pragma interface
50 
51 
52 
53 //# 1 "GctSymbol.GctSymbol.Map.h" 1
54 // This may look like C code, but it is really -*- C++ -*-
55 /*
56 Copyright (C) 1988 Free Software Foundation
57     written by Doug Lea (dl@rocky.oswego.edu)
58 
59 This file is part of the GNU C++ Library.  This library is free
60 software; you can redistribute it and/or modify it under the terms of
61 the GNU Library General Public License as published by the Free
62 Software Foundation; either version 2 of the License, or (at your
63 option) any later version.  This library is distributed in the hope
64 that it will be useful, but WITHOUT ANY WARRANTY; without even the
65 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
66 PURPOSE.  See the GNU Library General Public License for more details.
67 You should have received a copy of the GNU Library General Public
68 License along with this library; if not, write to the Free Software
69 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
70 */
71 
72 
73 
74 
75 //#pragma interface
76 
77 
78 
79 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/Pix.h" 1
80 
81 
82 
83 typedef void* Pix;
84 
85 //# 26 "GctSymbol.GctSymbol.Map.h" 2
86 
87 //# 1 "GctSymbol.defs.h" 1
88 // This may look like C code, but it is really -*- C++ -*-
89 /*
90 Copyright (C) 1988 Free Software Foundation
91     written by Doug Lea (dl@rocky.oswego.edu)
92 
93 This file is part of the GNU C++ Library.  This library is free
94 software; you can redistribute it and/or modify it under the terms of
95 the GNU Library General Public License as published by the Free
96 Software Foundation; either version 2 of the License, or (at your
97 option) any later version.  This library is distributed in the hope
98 that it will be useful, but WITHOUT ANY WARRANTY; without even the
99 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
100 PURPOSE.  See the GNU Library General Public License for more details.
101 You should have received a copy of the GNU Library General Public
102 License along with this library; if not, write to the Free Software
103 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
104 */
105 
106 
107 
108 
109 
110 
111 
112 //# 1 "../../GctSymbol.h" 1
113 // -*- C++ -*-
114 
115 
116 
117 //
118 // GctSymbol class
119 //
120 // Expects to be included by Gct.h
121 //
122 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
123 //
124 
125 
126 
127 
128 
129 //#pragma interface
130 
131 
132 
133 
134 
135 //# 25 "../../GctSymbol.h" 2
136 
137 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 1
138 // This may look like C code, but it is really -*- C++ -*-
139 /*
140 Copyright (C) 1988 Free Software Foundation
141     written by Doug Lea (dl@rocky.oswego.edu)
142 
143 This file is part of the GNU C++ Library.  This library is free
144 software; you can redistribute it and/or modify it under the terms of
145 the GNU Library General Public License as published by the Free
146 Software Foundation; either version 2 of the License, or (at your
147 option) any later version.  This library is distributed in the hope
148 that it will be useful, but WITHOUT ANY WARRANTY; without even the
149 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
150 PURPOSE.  See the GNU Library General Public License for more details.
151 You should have received a copy of the GNU Library General Public
152 License along with this library; if not, write to the Free Software
153 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
154 */
155 
156 
157 
158 
159 //#pragma interface
160 
161 
162 
163 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stream.h" 1
164 
165 
166 
167 // Compatibility with old library.
168 
169 
170 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
171 //    This is part of the iostream library, providing -*- C++ -*- input/output.
172 //    Copyright (C) 1991 Per Bothner.
173 //
174 //    This library is free software; you can redistribute it and/or
175 //    modify it under the terms of the GNU Library General Public
176 //    License as published by the Free Software Foundation; either
177 //    version 2 of the License, or (at your option) any later version.
178 //
179 //    This library is distributed in the hope that it will be useful,
180 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
181 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
182 //    Library General Public License for more details.
183 //
184 //    You should have received a copy of the GNU Library General Public
185 //    License along with this library; if not, write to the Free
186 //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
187 
188 
189 
190 //#pragma interface
191 
192 
193 
194 
195 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/streambuf.h" 1
196 //    This is part of the iostream library, providing -*- C++ -*- input/output.
197 //    Copyright (C) 1991 Per Bothner.
198 //
199 //    This library is free software; you can redistribute it and/or
200 //    modify it under the terms of the GNU Library General Public
201 //    License as published by the Free Software Foundation; either
202 //    version 2 of the License, or (at your option) any later version.
203 //
204 //    This library is distributed in the hope that it will be useful,
205 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
206 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
207 //    Library General Public License for more details.
208 //
209 //    You should have received a copy of the GNU Library General Public
210 //    License along with this library; if not, write to the Free
211 //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
212 
213 
214 
215 
216 //#pragma interface
217 
218 
219 /* KLUDGES!! */
220 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 1
221 
222 
223 extern "C" {
224 
225 
226 
227 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/mips/lib/gcc/decstatn/cygnus-1.96/include/stddef.h" 1
228 
229 
230 
231 
232 
233 
234 /* This avoids lossage on Sunos but only if stdtypes.h comes first.
235    There's no way to win with the other order!  Sun lossage.  */
236 
237 /* In case nobody has defined these types, but we aren't running under
238    GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and
239    __WCHAR_TYPE__ have reasonable values.  This can happen if the
240    parts of GCC is compiled by an older compiler, that actually
241    include gstddef.h, such as collect2.  */
242 
243 /* Signed type of difference of two pointers.  */
244 
245 
246 
247 
248 
249 
250 
251 
252 
253 
254 
255 
256 
257 
258 typedef long int ptrdiff_t;
259 
260 
261 
262 
263 
264 
265 /* Unsigned type of `sizeof' something.  */
266 
267 
268 
269 
270 
271 
272 
273 
274 
275 
276 
277 
278 
279 
280 typedef unsigned int size_t;
281 
282 
283 
284 
285 
286 
287 /* Data type for wide chars.  */
288 
289 
290 
291 
292 
293 
294 
295 
296 
297 
298 
299 
300 
301 
302 
303 
304 
305 
306 
307 
308 
309 
310 /* A null pointer constant.  */
311 
312 
313 
314 
315 /* Offset of member MEMBER in a struct of type TYPE.  */
316 
317 
318 
319 
320 
321 //# 7 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stddef.h" 2
322 
323 
324 
325 
326 }
327 
328 //# 25 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/streambuf.h" 2
329 
330 
331 
332 
333 
334 
335 
336 
337 
338 
339 
340 
341 
342 
343 
344 
345 class ostream; class streambuf;
346 
347 typedef long streamoff, streampos;
348 
349 struct _ios_fields { // The data members of an ios.
350     streambuf *_strbuf;
351     ostream* _tie;
352     long _width;
353     unsigned long _flags;
354     char _fill;
355     unsigned char _state;
356     unsigned short _precision;
357 };
358 
359 
360 enum state_value { _good = 0, _eof = 1,  _fail = 2, _bad  = 4 };
361 
362 
363 class ios : public _ios_fields {
364   public:
365     enum io_state { goodbit=0, eofbit=1, failbit=2, badbit=4 };
366     enum open_mode {
367 	in=1,
368 	out=2,
369 	ate=4,
370 	app=8,
371 	trunc=16,
372 	nocreate=32,
373 	noreplace=64 };
374     enum seek_dir { beg, cur, end};
375     enum { skipws=01, left=02, right=04, internal=010,
376 	   dec=020, oct=040, hex=0100,
377 	   showbase=0200, showpoint=0400, uppercase=01000, showpos=02000,
378 	   scientific=04000, fixed=0100000, unitbuf=020000, stdio=040000,
379 	   dont_close=0x80000000 //Don't close streambuf when destroying stream
380 	   };
381 
tie()382     ostream* tie() { return _tie; }
tie(ostream * val)383     ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }
384 
385     // Methods to change the format state.
fill()386     char fill() { return _fill; }
fill(char newf)387     char fill(char newf) { char oldf = _fill; _fill = newf; return oldf; }
flags()388     unsigned long flags() { return _flags; }
flags(unsigned long new_val)389     unsigned long flags(unsigned long new_val) {
390 	unsigned long old_val = _flags; _flags = new_val; return old_val; }
precision()391     unsigned short precision() { return _precision; }
precision(int newp)392     unsigned short precision(int newp) {
393 	unsigned short oldp = _precision; _precision = (unsigned short)newp;
394 	return oldp; }
setf(unsigned long val)395     unsigned long setf(unsigned long val) {
396 	unsigned long oldbits = _flags;
397 	_flags |= val; return oldbits; }
setf(unsigned long val,unsigned long mask)398     unsigned long setf(unsigned long val, unsigned long mask) {
399 	unsigned long oldbits = _flags;
400 	_flags = (_flags & ~mask) | (val & mask); return oldbits; }
unsetf(unsigned long mask)401     unsigned long unsetf(unsigned long mask) {
402 	unsigned long oldbits = _flags & mask;
403 	_flags &= ~mask; return oldbits; }
width()404     long width() { return _width; }
width(long val)405     long width(long val) { long save = _width; _width = val; return save; }
406 
407     static const unsigned long basefield;
408     static const unsigned long adjustfield;
409     static const unsigned long floatfield;
410 
rdbuf()411     streambuf* rdbuf() { return _strbuf; }
412     void clear(int state = 0) { _state = state; }
good()413     int good() { return _state == 0; }
eof()414     int eof() { return _state & ios::eofbit; }
fail()415     int fail() { return _state & (ios::badbit|ios::failbit); }
bad()416     int bad() { return _state & ios::badbit; }
rdstate()417     int rdstate() { return _state; }
set(int flag)418     void set(int flag) { _state |= flag; }
419     operator void*() { return fail() ? (void*)0 : (void*)this; }
420     int operator!() { return fail(); }
421 
422 
unset(state_value flag)423     void unset(state_value flag) { _state &= ~flag; }
424     void close();
425     int is_open();
426     int readable();
427     int writable();
428 
429 
430   protected:
ios(streambuf * sb)431     ios(streambuf*sb) { _strbuf=sb; _state=0; _width=0; _fill=' ';
432 			_flags=ios::skipws; _precision=6; }
433 };
434 
435 
436 
437 
438 typedef ios::seek_dir _seek_dir;
439 
440 
441 // Magic numbers and bits for the _flags field.
442 // The magic numbers use the high-order bits of _flags;
443 // the remaining bits are abailable for variable flags.
444 // Note: The magic numbers must all be negative if stdio
445 // emulation is desired.
446 
447 
448 
449 
450 
451 
452 
453 
454 
455 
456 
457 
458 
459 
460 
461 struct __streambuf {
462     // NOTE: If this is changed, also change __FILE in stdio/stdio.h!
463     int _flags;		/* High-order word is _IO_MAGIC; rest is flags. */
464     char* _gptr;	/* Current get pointer */
465     char* _egptr;	/* End of get area. */
466     char* _eback;	/* Start of putback+get area. */
467     char* _pbase;	/* Start of put area. */
468     char* _pptr;	/* Current put pointer. */
469     char* _epptr;	/* End of put area. */
470     char* _base;	/* Start of reserve area. */
471     char* _ebuf;	/* End of reserve area. */
472     struct streambuf *_chain;
473 };
474 
475 struct streambuf : private __streambuf {
476     friend class ios;
477     friend class istream;
478     friend class ostream;
479   protected:
480     static streambuf* _list_all; /* List of open streambufs. */
xchainstreambuf481     streambuf*& xchain() { return _chain; }
482     void _un_link();
483     void _link_in();
gptrstreambuf484     char* gptr() const { return _gptr; }
pptrstreambuf485     char* pptr() const { return _pptr; }
egptrstreambuf486     char* egptr() const { return _egptr; }
epptrstreambuf487     char* epptr() const { return _epptr; }
pbasestreambuf488     char* pbase() const { return _pbase; }
ebackstreambuf489     char* eback() const { return _eback; }
ebufstreambuf490     char* ebuf() const { return _ebuf; }
basestreambuf491     char* base() const { return _base; }
xput_charstreambuf492     void xput_char(char c) { *_pptr++ = c; }
xflagsstreambuf493     int xflags() { return _flags; }
xflagsstreambuf494     int xflags(int f) { int fl = _flags; _flags = f; return fl; }
xsetflagsstreambuf495     void xsetflags(int f) { _flags |= f; }
gbumpstreambuf496     void gbump(int n) { _gptr += n; }
pbumpstreambuf497     void pbump(int n) { _pptr += n; }
498     void setb(char* b, char* eb, int a=0);
setpstreambuf499     void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; }
setgstreambuf500     void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; }
501   public:
502     static int flush_all();
503     static void flush_all_linebuffered(); // Flush all line buffered files.
504     virtual int underflow(); // Leave public for now
505     virtual int overflow(int c = (-1) ); // Leave public for now
506     virtual int doallocate();
507     virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
508     virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
509     int sputbackc(char c);
510     int sungetc();
511     streambuf();
512     virtual ~streambuf();
unbufferedstreambuf513     int unbuffered() { return _flags & 2  ? 1 : 0; }
linebufferedstreambuf514     int linebuffered() { return _flags & 0x4000  ? 1 : 0; }
unbufferedstreambuf515     void unbuffered(int i)
516 	{ if (i) _flags |= 2 ; else _flags &= ~2 ; }
linebufferedstreambuf517     void linebuffered(int i)
518 	{ if (i) _flags |= 0x4000 ; else _flags &= ~0x4000 ; }
allocatestreambuf519     int allocate() {
520 	if (base() || unbuffered()) return 0;
521 	else return doallocate(); }
522     virtual int sync();
523     virtual int pbackfail(int c);
524     virtual int ungetfail();
525     virtual streambuf* setbuf(char* p, int len);
in_availstreambuf526     int in_avail() { return _egptr - _gptr; }
out_waitingstreambuf527     int out_waiting() { return _pptr - _pbase; }
528     virtual int sputn(const char* s, int n);
529     virtual int sgetn(char* s, int n);
530     long sgetline(char* buf, size_t n, char delim, int putback_delim);
sbumpcstreambuf531     int sbumpc() {
532 	if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
533 	else return *(unsigned char*)_gptr++; }
sgetcstreambuf534     int sgetc() {
535 	if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
536 	else return *(unsigned char*)_gptr; }
snextcstreambuf537     int snextc() {
538 	if (++_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
539 	else return *(unsigned char*)_gptr; }
sputcstreambuf540     int sputc(int c) {
541 	if (_pptr >= _epptr) return overflow(c);
542 	return *_pptr++ = c, (unsigned char)c; }
543     int vscan(char const *fmt0, char*  ap);
544     int vform(char const *fmt0, char*  ap);
545 };
546 
547 struct __file_fields {
548     char _fake;
549     char _shortbuf[1];
550     short _fileno;
551     int _blksize;
552     char* _save_gptr;
553     char* _save_egptr;
554     long  _offset;
555 };
556 
557 class filebuf : public streambuf {
558     struct __file_fields _fb;
559     void init();
560   public:
561     filebuf();
562     filebuf(int fd);
563     filebuf(int fd, char* p, int len);
564     ~filebuf();
565     filebuf* attach(int fd);
566     filebuf* open(const char *filename, const char *mode);
567     filebuf* open(const char *filename, int mode, int prot = 0664);
568     virtual int underflow();
569     virtual int overflow(int c = (-1) );
is_open()570     int is_open() { return _fb._fileno >= 0; }
fd()571     int fd() { return is_open() ? _fb._fileno : (-1) ; }
572     filebuf* close();
573     virtual int doallocate();
574     virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
575     int sputn(const char* s, int n);
576     int sgetn(char* s, int n);
577   protected: // See documentation in filebuf.C.
578     virtual int pbackfail(int c);
579     virtual int sync();
is_reading()580     int is_reading() { return eback() != egptr(); }
cur_ptr()581     char* cur_ptr() { return is_reading() ?  gptr() : pptr(); }
582     /* System's idea of pointer */
file_ptr()583     char* file_ptr() { return _fb._save_gptr ? _fb._save_egptr : egptr(); }
584     int do_flush();
585     // Low-level operations (Usually invoke system calls.)
586     virtual int sys_read(char* buf, size_t size);
587     virtual long  sys_seek(long , _seek_dir);
588     virtual long sys_write(const void*, long);
589     virtual int sys_stat(void*); // Actually, a (struct stat*)
590     virtual int sys_close();
591 };
592 
593 
readable()594 inline int ios::readable() { return rdbuf()->_flags & 4 ; }
writable()595 inline int ios::writable() { return rdbuf()->_flags & 8 ; }
is_open()596 inline int ios::is_open() {return rdbuf()->_flags & 4 +8 ;}
597 
598 
599 
600 
601 //# 25 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 2
602 
603 
604 class istream; class ostream;
605 typedef istream& (*__imanip)(istream&);
606 typedef ostream& (*__omanip)(ostream&);
607 
608 extern istream& ws(istream& ins);
609 extern ostream& flush(ostream& outs);
610 extern ostream& endl(ostream& outs);
611 extern ostream& ends(ostream& outs);
612 
613 class ostream : public ios
614 {
615     void do_osfx();
616   public:
617     ostream();
618     ostream(streambuf* sb, ostream* tied=(__null) );
619     ~ostream();
620 
opfx()621     int opfx() { if (!good()) return 0; if (_tie) _tie->flush(); return 1; }
osfx()622     void osfx() { if (flags() & (ios::unitbuf|ios::stdio))
623 		      do_osfx(); }
ostreambuf()624     streambuf* ostreambuf() const { return _strbuf; }
625     ostream& flush();
626     ostream& put(char c);
627     ostream& write(const char *s, int n);
write(const unsigned char * s,int n)628     ostream& write(const unsigned char *s, int n) { return write((char*)s, n);}
write(const void * s,int n)629     ostream& write(const void *s, int n) { return write((char*)s, n);}
630     ostream& seekp(streampos);
631     ostream& seekp(streamoff, _seek_dir);
632     streampos tellp();
633     ostream& form(const char *format ...);
634     ostream& vform(const char *format, char*  args);
635 };
636 
637 ostream& operator<<(ostream&, char c);
638 ostream& operator<<(ostream& os, unsigned char c) { return os << (char)c; }
639 //ostream& operator<<(ostream &os, signed char c) { return os << (char)c; }
640 extern ostream& operator<<(ostream&, const char *s);
641 inline ostream& operator<<(ostream& os, const unsigned char *s)
642 { return os << (const char*)s; }
643 //inline ostream& operator<<(ostream& os, const signed char *s)
644 //{ return os << (const char*)s; }
645 ostream& operator<<(ostream&, void *p);
646 ostream& operator<<(ostream&, int n);
647 ostream& operator<<(ostream&, long n);
648 ostream& operator<<(ostream&, unsigned int n);
649 ostream& operator<<(ostream&, unsigned long n);
650 ostream& operator<<(ostream& os, short n) {return os << (int)n;}
651 ostream& operator<<(ostream& os, unsigned short n)
652 {return os << (unsigned int)n;}
653 ostream& operator<<(ostream&, float n);
654 ostream& operator<<(ostream&, double n);
655 ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); }
656 ostream& operator<<(ostream&, streambuf*);
657 
658 class istream : public ios
659 {
660     size_t _gcount;
661   public:
662     istream();
663     istream(streambuf* sb, ostream*tied=(__null) );
664     ~istream();
istreambuf()665     streambuf* istreambuf() const { return _strbuf; }
666     istream& get(char& c);
667     istream& get(unsigned char& c);
668     istream& read(char *ptr, int n);
read(unsigned char * ptr,int n)669     istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); }
read(void * ptr,int n)670     istream& read(void *ptr, int n) { return read((char*)ptr, n); }
get()671     int get() { return _strbuf->sbumpc(); }
672     istream& getline(char* ptr, int len, char delim = '\n');
673     istream& get(char* ptr, int len, char delim = '\n');
674     istream& gets(char **s, char delim = '\n');
ipfx(int need)675     int ipfx(int need) {
676 	if (!good()) { set(ios::failbit); return 0; }
677 	if (_tie && (need == 0 || rdbuf()->in_avail())) ;  //??? THIS LINE IS QUESTIONABLE */
678 	if (!need && (flags() & ios::skipws) && !ws(*this)) return 0;
679 	return 1;
680     }
ipfx0()681     int ipfx0() { // Optimized version of ipfx(0).
682 	if (!good()) { set(ios::failbit); return 0; }
683 	if (_tie) _tie->flush();
684 	if ((flags() & ios::skipws) && !ws(*this)) return 0;
685 	return 1;
686     }
ipfx1()687     int ipfx1() { // Optimized version of ipfx(1).
688 	if (!good()) { set(ios::failbit); return 0; }
689 	if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
690 	return 1;
691     }
gcount()692     size_t gcount() { return _gcount; }
693     istream& seekg(streampos);
694     istream& seekg(streamoff, _seek_dir);
695     streampos tellg();
putback(char ch)696     istream& putback(char ch) {
697 	if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit);
698 	return *this;}
unget()699     istream& unget() {
700 	if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit);
701 	return *this;}
702 
unget(char ch)703     istream& unget(char ch) { return putback(ch); }
704     int skip(int i);
705 
706 };
707 
708 istream& operator>>(istream&, char*);
709 istream& operator>>(istream& is, unsigned char* p) { return is >> (char*)p; }
710 //istream& operator>>(istream& is, signed char* p) { return is >> (char*)p; }
711 istream& operator>>(istream&, char& c);
712 istream& operator>>(istream&, unsigned char& c);
713 //istream& operator>>(istream&, signed char& c);
714 istream& operator>>(istream&, int&);
715 istream& operator>>(istream&, long&);
716 istream& operator>>(istream&, short&);
717 istream& operator>>(istream&, unsigned int&);
718 istream& operator>>(istream&, unsigned long&);
719 istream& operator>>(istream&, unsigned short&);
720 istream& operator>>(istream&, float&);
721 istream& operator>>(istream&, double&);
722 istream& operator>>(istream& is, __imanip func) { return (*func)(is); }
723 
724 class iostream : public ios {
725     size_t _gcount;
726   public:
727     iostream();
728     operator istream&() { return *(istream*)this; }
729     operator ostream&() { return *(ostream*)this; }
730     ~iostream();
731     // NOTE: These duplicate istream methods.
get(char & c)732     istream& get(char& c) { return ((istream*)this)->get(c); }
get(unsigned char & c)733     istream& get(unsigned char& c) { return ((istream*)this)->get(c); }
read(char * ptr,int n)734     istream& read(char *ptr, int n) { return ((istream*)this)->read(ptr, n); }
read(unsigned char * ptr,int n)735     istream& read(unsigned char *ptr, int n)
736 	{ return ((istream*)this)->read((char*)ptr, n); }
read(void * ptr,int n)737     istream& read(void *ptr, int n)
738 	{ return ((istream*)this)->read((char*)ptr, n); }
get()739     int get() { return _strbuf->sbumpc(); }
740     istream& getline(char* ptr, int len, char delim = '\n')
741 	{ return ((istream*)this)->getline(ptr, len, delim); }
742     istream& get(char* ptr, int len, char delim = '\n')
743 	{ return ((istream*)this)->get(ptr, len, delim); }
744     istream& gets(char **s, char delim = '\n')
745 	{ return ((istream*)this)->gets(s, delim); }
ipfx(int need)746     int ipfx(int need) { return ((istream*)this)->ipfx(need); }
ipfx0()747     int ipfx0()  { return ((istream*)this)->ipfx0(); }
ipfx1()748     int ipfx1()  { return ((istream*)this)->ipfx1(); }
gcount()749     size_t gcount() { return _gcount; }
putback(char ch)750     istream& putback(char ch) { return ((istream*)this)->putback(ch); }
unget()751     istream& unget() { return ((istream*)this)->unget(); }
seekg(streampos pos)752     istream& seekg(streampos pos) { return ((istream*)this)->seekg(pos); }
seekg(streamoff off,_seek_dir dir)753     istream& seekg(streamoff off, _seek_dir dir)
754 	{ return ((istream*)this)->seekg(off, dir); }
tellg()755     streampos tellg() { return ((istream*)this)->tellg(); }
756 
unget(char ch)757     istream& unget(char ch) { return putback(ch); }
758 
759 
760     // NOTE: These duplicate ostream methods.
opfx()761     int opfx() { return ((ostream*)this)->opfx(); }
osfx()762     void osfx() { ((ostream*)this)->osfx(); }
flush()763     ostream& flush() { return ((ostream*)this)->flush(); }
put(char c)764     ostream& put(char c) { return ((ostream*)this)->put(c); }
write(const char * s,int n)765     ostream& write(const char *s, int n)
766 	{ return ((ostream*)this)->write(s, n); }
write(const unsigned char * s,int n)767     ostream& write(const unsigned char *s, int n)
768 	{ return ((ostream*)this)->write((char*)s, n); }
write(const void * s,int n)769     ostream& write(const void *s, int n)
770 	{ return ((ostream*)this)->write((char*)s, n); }
771     ostream& form(const char *format ...);
vform(const char * format,char * args)772     ostream& vform(const char *format, char*  args)
773 	{ return ((ostream*)this)->vform(format, args); }
seekp(streampos pos)774     ostream& seekp(streampos pos) { return ((ostream*)this)->seekp(pos); }
seekp(streamoff off,_seek_dir dir)775     ostream& seekp(streamoff off, _seek_dir dir)
776 	{ return ((ostream*)this)->seekp(off, dir); }
tellp()777     streampos tellp() { return ((ostream*)this)->tellp(); }
778 };
779 
780 extern istream cin;
781 extern ostream cout, cerr, clog; // clog->rdbuf() == cerr->rdbuf()
782 
put(char c)783 inline ostream& ostream::put(char c) { _strbuf->sputc(c); return *this; }
784 
785 struct Iostream_init { } ;  // Compatibility hack for AT&T libraray.
786 
787 
788 //# 7 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/stream.h" 2
789 
790 
791 extern char* form(char*, ...);
792 
793 extern char* dec(long, int=0);
794 extern char* dec(int, int=0);
795 extern char* dec(unsigned long, int=0);
796 extern char* dec(unsigned int, int=0);
797 
798 extern char* hex(long, int=0);
799 extern char* hex(int, int=0);
800 extern char* hex(unsigned long, int=0);
801 extern char* hex(unsigned int, int=0);
802 
803 extern char* oct(long, int=0);
804 extern char* oct(int, int=0);
805 extern char* oct(unsigned long, int=0);
806 extern char* oct(unsigned int, int=0);
807 
WS(istream & str)808 inline istream& WS(istream& str) { return ws(str); }
809 
810 
811 //# 26 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 2
812 
813 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/Regex.h" 1
814 // This may look like C code, but it is really -*- C++ -*-
815 /*
816 Copyright (C) 1988 Free Software Foundation
817     written by Doug Lea (dl@rocky.oswego.edu)
818 
819 This file is part of the GNU C++ Library.  This library is free
820 software; you can redistribute it and/or modify it under the terms of
821 the GNU Library General Public License as published by the Free
822 Software Foundation; either version 2 of the License, or (at your
823 option) any later version.  This library is distributed in the hope
824 that it will be useful, but WITHOUT ANY WARRANTY; without even the
825 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
826 PURPOSE.  See the GNU Library General Public License for more details.
827 You should have received a copy of the GNU Library General Public
828 License along with this library; if not, write to the Free Software
829 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
830 */
831 
832 
833 
834 
835 //#pragma interface
836 
837 
838 
839 
840 
841 
842 
843 
844 
845 struct re_pattern_buffer;       // defined elsewhere
846 struct re_registers;
847 
848 class Regex
849 {
850 private:
851 
Regex(const Regex &)852                      Regex(const Regex&) {}  // no X(X&)
853   void               operator = (const Regex&) {} // no assignment
854 
855 protected:
856   re_pattern_buffer* buf;
857   re_registers*      reg;
858 
859 public:
860                      Regex(const char* t,
861                            int fast = 0,
862                            int bufsize = 40,
863                            const char* transtable = 0);
864 
865                     ~Regex();
866 
867   int                match(const char* s, int len, int pos = 0) const;
868   int                search(const char* s, int len,
869                             int& matchlen, int startpos = 0) const;
870   int                match_info(int& start, int& length, int nth = 0) const;
871 
872   int                OK() const;  // representation invariant
873 };
874 
875 // some built in regular expressions
876 
877 extern const Regex RXwhite;          // = "[ \n\t\r\v\f]+"
878 extern const Regex RXint;            // = "-?[0-9]+"
879 extern const Regex RXdouble;         // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\|
880                                      //    \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)
881                                      //    \\([eE][---+]?[0-9]+\\)?"
882 extern const Regex RXalpha;          // = "[A-Za-z]+"
883 extern const Regex RXlowercase;      // = "[a-z]+"
884 extern const Regex RXuppercase;      // = "[A-Z]+"
885 extern const Regex RXalphanum;       // = "[0-9A-Za-z]+"
886 extern const Regex RXidentifier;     // = "[A-Za-z_][A-Za-z0-9_]*"
887 
888 
889 
890 //# 27 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 2
891 
892 
893 struct StrRep                     // internal String representations
894 {
895   unsigned short    len;         // string length
896   unsigned short    sz;          // allocated space
897   char              s[1];        // the string starts here
898                                  // (at least 1 char for trailing null)
899                                  // allocated & expanded via non-public fcts
900 };
901 
902 // primitive ops on StrReps -- nearly all String fns go through these.
903 
904 StrRep*     Salloc(StrRep*, const char*, int, int);
905 StrRep*     Scopy(StrRep*, StrRep*);
906 StrRep*     Sresize(StrRep*, int);
907 StrRep*     Scat(StrRep*, const char*, int, const char*, int);
908 StrRep*     Scat(StrRep*, const char*, int,const char*,int, const char*,int);
909 StrRep*     Sprepend(StrRep*, const char*, int);
910 StrRep*     Sreverse(StrRep*, StrRep*);
911 StrRep*     Supcase(StrRep*, StrRep*);
912 StrRep*     Sdowncase(StrRep*, StrRep*);
913 StrRep*     Scapitalize(StrRep*, StrRep*);
914 
915 // These classes need to be defined in the order given
916 
917 class String;
918 class SubString;
919 
920 class SubString
921 {
922   friend class      String;
923 protected:
924 
925   String&           S;        // The String I'm a substring of
926   unsigned short    pos;      // starting position in S's rep
927   unsigned short    len;      // length of substring
928 
929   void              assign(StrRep*, const char*, int = -1);
930                     SubString(String& x, int p, int l);
931                     SubString(const SubString& x);
932 
933 public:
934 
935 // Note there are no public constructors. SubStrings are always
936 // created via String operations
937 
938                    ~SubString();
939 
940   void              operator =  (const String&     y);
941   void              operator =  (const SubString&  y);
942   void              operator =  (const char* t);
943   void              operator =  (char        c);
944 
945 // return 1 if target appears anywhere in SubString; else 0
946 
947   int               contains(char        c) const;
948   int               contains(const String&     y) const;
949   int               contains(const SubString&  y) const;
950   int               contains(const char* t) const;
951   int               contains(const Regex&       r) const;
952 
953 // return 1 if target matches entire SubString
954 
955   int               matches(const Regex&  r) const;
956 
957 // IO
958 
959   friend ostream&   operator<<(ostream& s, const SubString& x);
960 
961 // status
962 
963   unsigned int      length() const;
964   int               empty() const;
965   const char*       chars() const;
966 
967   int               OK() const;
968 
969 };
970 
971 
972 class String
973 {
974   friend class      SubString;
975 
976 protected:
977   StrRep*           rep;   // Strings are pointers to their representations
978 
979 // some helper functions
980 
981   int               search(int, int, const char*, int = -1) const;
982   int               search(int, int, char) const;
983   int               match(int, int, int, const char*, int = -1) const;
984   int               _gsub(const char*, int, const char* ,int);
985   int               _gsub(const Regex&, const char*, int);
986   SubString         _substr(int, int);
987 
988 public:
989 
990 // constructors & assignment
991 
992                     String();
993                     String(const String& x);
994                     String(const SubString&  x);
995                     String(const char* t);
996                     String(const char* t, int len);
997                     String(char c);
998 
999                     ~String();
1000 
1001   void              operator =  (const String&     y);
1002   void              operator =  (const char* y);
1003   void              operator =  (char        c);
1004   void              operator =  (const SubString&  y);
1005 
1006 // concatenation
1007 
1008   void              operator += (const String&     y);
1009   void              operator += (const SubString&  y);
1010   void              operator += (const char* t);
1011   void              operator += (char        c);
1012 
1013   void              prepend(const String&     y);
1014   void              prepend(const SubString&  y);
1015   void              prepend(const char* t);
1016   void              prepend(char        c);
1017 
1018 
1019 // procedural versions:
1020 // concatenate first 2 args, store result in last arg
1021 
1022   friend void     cat(const String&, const String&, String&);
1023   friend void     cat(const String&, const SubString&, String&);
1024   friend void     cat(const String&, const char*, String&);
1025   friend void     cat(const String&, char, String&);
1026 
1027   friend void     cat(const SubString&, const String&, String&);
1028   friend void     cat(const SubString&, const SubString&, String&);
1029   friend void     cat(const SubString&, const char*, String&);
1030   friend void     cat(const SubString&, char, String&);
1031 
1032   friend void     cat(const char*, const String&, String&);
1033   friend void     cat(const char*, const SubString&, String&);
1034   friend void     cat(const char*, const char*, String&);
1035   friend void     cat(const char*, char, String&);
1036 
1037 // double concatenation, by request. (yes, there are too many versions,
1038 // but if one is supported, then the others should be too...)
1039 // Concatenate first 3 args, store in last arg
1040 
1041   friend void     cat(const String&,const String&, const String&,String&);
1042   friend void     cat(const String&,const String&,const SubString&,String&);
1043   friend void     cat(const String&,const String&, const char*, String&);
1044   friend void     cat(const String&,const String&, char, String&);
1045   friend void     cat(const String&,const SubString&,const String&,String&);
1046   friend void     cat(const String&,const SubString&,const SubString&,String&);
1047   friend void     cat(const String&,const SubString&, const char*, String&);
1048   friend void     cat(const String&,const SubString&, char, String&);
1049   friend void     cat(const String&,const char*, const String&,    String&);
1050   friend void     cat(const String&,const char*, const SubString&, String&);
1051   friend void     cat(const String&,const char*, const char*, String&);
1052   friend void     cat(const String&,const char*, char, String&);
1053 
1054   friend void     cat(const char*, const String&, const String&,String&);
1055   friend void     cat(const char*,const String&,const SubString&,String&);
1056   friend void     cat(const char*,const String&, const char*, String&);
1057   friend void     cat(const char*,const String&, char, String&);
1058   friend void     cat(const char*,const SubString&,const String&,String&);
1059   friend void     cat(const char*,const SubString&,const SubString&,String&);
1060   friend void     cat(const char*,const SubString&, const char*, String&);
1061   friend void     cat(const char*,const SubString&, char, String&);
1062   friend void     cat(const char*,const char*, const String&,    String&);
1063   friend void     cat(const char*,const char*, const SubString&, String&);
1064   friend void     cat(const char*,const char*, const char*, String&);
1065   friend void     cat(const char*,const char*, char, String&);
1066 
1067 
1068 // searching & matching
1069 
1070 // return position of target in string or -1 for failure
1071 
1072   int               index(char        c, int startpos = 0) const;
1073   int               index(const String&     y, int startpos = 0) const;
1074   int               index(const SubString&  y, int startpos = 0) const;
1075   int               index(const char* t, int startpos = 0) const;
1076   int               index(const Regex&      r, int startpos = 0) const;
1077 
1078 // return 1 if target appears anyhere in String; else 0
1079 
1080   int               contains(char        c) const;
1081   int               contains(const String&     y) const;
1082   int               contains(const SubString&  y) const;
1083   int               contains(const char* t) const;
1084   int               contains(const Regex&      r) const;
1085 
1086 // return 1 if target appears anywhere after position pos
1087 // (or before, if pos is negative) in String; else 0
1088 
1089   int               contains(char        c, int pos) const;
1090   int               contains(const String&     y, int pos) const;
1091   int               contains(const SubString&  y, int pos) const;
1092   int               contains(const char* t, int pos) const;
1093   int               contains(const Regex&      r, int pos) const;
1094 
1095 // return 1 if target appears at position pos in String; else 0
1096 
1097   int               matches(char        c, int pos = 0) const;
1098   int               matches(const String&     y, int pos = 0) const;
1099   int               matches(const SubString&  y, int pos = 0) const;
1100   int               matches(const char* t, int pos = 0) const;
1101   int               matches(const Regex&      r, int pos = 0) const;
1102 
1103 //  return number of occurences of target in String
1104 
1105   int               freq(char        c) const;
1106   int               freq(const String&     y) const;
1107   int               freq(const SubString&  y) const;
1108   int               freq(const char* t) const;
1109 
1110 // SubString extraction
1111 
1112 // Note that you can't take a substring of a const String, since
1113 // this leaves open the possiblility of indirectly modifying the
1114 // String through the SubString
1115 
1116   SubString         at(int         pos, int len);
1117   SubString         operator () (int         pos, int len); // synonym for at
1118 
1119   SubString         at(const String&     x, int startpos = 0);
1120   SubString         at(const SubString&  x, int startpos = 0);
1121   SubString         at(const char* t, int startpos = 0);
1122   SubString         at(char        c, int startpos = 0);
1123   SubString         at(const Regex&      r, int startpos = 0);
1124 
1125   SubString         before(int          pos);
1126   SubString         before(const String&      x, int startpos = 0);
1127   SubString         before(const SubString&   x, int startpos = 0);
1128   SubString         before(const char*  t, int startpos = 0);
1129   SubString         before(char         c, int startpos = 0);
1130   SubString         before(const Regex&       r, int startpos = 0);
1131 
1132   SubString         through(int          pos);
1133   SubString         through(const String&      x, int startpos = 0);
1134   SubString         through(const SubString&   x, int startpos = 0);
1135   SubString         through(const char*  t, int startpos = 0);
1136   SubString         through(char         c, int startpos = 0);
1137   SubString         through(const Regex&       r, int startpos = 0);
1138 
1139   SubString         from(int          pos);
1140   SubString         from(const String&      x, int startpos = 0);
1141   SubString         from(const SubString&   x, int startpos = 0);
1142   SubString         from(const char*  t, int startpos = 0);
1143   SubString         from(char         c, int startpos = 0);
1144   SubString         from(const Regex&       r, int startpos = 0);
1145 
1146   SubString         after(int         pos);
1147   SubString         after(const String&     x, int startpos = 0);
1148   SubString         after(const SubString&  x, int startpos = 0);
1149   SubString         after(const char* t, int startpos = 0);
1150   SubString         after(char        c, int startpos = 0);
1151   SubString         after(const Regex&      r, int startpos = 0);
1152 
1153 
1154 // deletion
1155 
1156 // delete len chars starting at pos
1157   void              del(int         pos, int len);
1158 
1159 // delete the first occurrence of target after startpos
1160 
1161   void              del(const String&     y, int startpos = 0);
1162   void              del(const SubString&  y, int startpos = 0);
1163   void              del(const char* t, int startpos = 0);
1164   void              del(char        c, int startpos = 0);
1165   void              del(const Regex&      r, int startpos = 0);
1166 
1167 // global substitution: substitute all occurrences of pat with repl
1168 
1169   int               gsub(const String&     pat, const String&     repl);
1170   int               gsub(const SubString&  pat, const String&     repl);
1171   int               gsub(const char* pat, const String&     repl);
1172   int               gsub(const char* pat, const char* repl);
1173   int               gsub(const Regex&      pat, const String&     repl);
1174 
1175 // friends & utilities
1176 
1177 // split string into array res at separators; return number of elements
1178 
1179   friend int        split(const String& x, String res[], int maxn,
1180                           const String& sep);
1181   friend int        split(const String& x, String res[], int maxn,
1182                           const Regex&  sep);
1183 
1184   friend String     common_prefix(const String& x, const String& y,
1185                                   int startpos = 0);
1186   friend String     common_suffix(const String& x, const String& y,
1187                                   int startpos = -1);
1188   friend String     replicate(char        c, int n);
1189   friend String     replicate(const String&     y, int n);
1190   friend String     join(String src[], int n, const String& sep);
1191 
1192 // simple builtin transformations
1193 
1194   friend String     reverse(const String& x);
1195   friend String     upcase(const String& x);
1196   friend String     downcase(const String& x);
1197   friend String     capitalize(const String& x);
1198 
1199 // in-place versions of above
1200 
1201   void              reverse();
1202   void              upcase();
1203   void              downcase();
1204   void              capitalize();
1205 
1206 // element extraction
1207 
1208   char&             operator [] (int i);
1209   char              elem(int i) const;
1210   char              firstchar() const;
1211   char              lastchar() const;
1212 
1213 // conversion
1214 
1215                     operator const char*() const;
1216   const char*       chars() const;
1217 
1218 
1219 // IO
1220 
1221   friend ostream&   operator<<(ostream& s, const String& x);
1222   friend ostream&   operator<<(ostream& s, const SubString& x);
1223   friend istream&   operator>>(istream& s, String& x);
1224 
1225   friend int        readline(istream& s, String& x,
1226                              char terminator = '\n',
1227                              int discard_terminator = 1);
1228 
1229 // status
1230 
1231   unsigned int      length() const;
1232   int               empty() const;
1233 
1234 // preallocate some space for String
1235   void              alloc(int newsize);
1236 
1237 // report current allocation (not length!)
1238 
1239   int               allocation() const;
1240 
1241 
1242   volatile void     error(const char* msg) const;
1243 
1244   int               OK() const;
1245 };
1246 
1247 typedef String StrTmp; // for backward compatibility
1248 
1249 // other externs
1250 
1251 int        compare(const String&    x, const String&     y);
1252 int        compare(const String&    x, const SubString&  y);
1253 int        compare(const String&    x, const char* y);
1254 int        compare(const SubString& x, const String&     y);
1255 int        compare(const SubString& x, const SubString&  y);
1256 int        compare(const SubString& x, const char* y);
1257 int        fcompare(const String&   x, const String&     y); // ignore case
1258 
1259 extern StrRep  _nilStrRep;
1260 extern String _nilString;
1261 
1262 // other inlines
1263 
1264 String operator + (const String& x, const String& y);
1265 String operator + (const String& x, const SubString& y);
1266 String operator + (const String& x, const char* y);
1267 String operator + (const String& x, char y);
1268 String operator + (const SubString& x, const String& y);
1269 String operator + (const SubString& x, const SubString& y);
1270 String operator + (const SubString& x, const char* y);
1271 String operator + (const SubString& x, char y);
1272 String operator + (const char* x, const String& y);
1273 String operator + (const char* x, const SubString& y);
1274 
1275 int operator==(const String& x, const String& y);
1276 int operator!=(const String& x, const String& y);
1277 int operator> (const String& x, const String& y);
1278 int operator>=(const String& x, const String& y);
1279 int operator< (const String& x, const String& y);
1280 int operator<=(const String& x, const String& y);
1281 int operator==(const String& x, const SubString&  y);
1282 int operator!=(const String& x, const SubString&  y);
1283 int operator> (const String& x, const SubString&  y);
1284 int operator>=(const String& x, const SubString&  y);
1285 int operator< (const String& x, const SubString&  y);
1286 int operator<=(const String& x, const SubString&  y);
1287 int operator==(const String& x, const char* t);
1288 int operator!=(const String& x, const char* t);
1289 int operator> (const String& x, const char* t);
1290 int operator>=(const String& x, const char* t);
1291 int operator< (const String& x, const char* t);
1292 int operator<=(const String& x, const char* t);
1293 int operator==(const SubString& x, const String& y);
1294 int operator!=(const SubString& x, const String& y);
1295 int operator> (const SubString& x, const String& y);
1296 int operator>=(const SubString& x, const String& y);
1297 int operator< (const SubString& x, const String& y);
1298 int operator<=(const SubString& x, const String& y);
1299 int operator==(const SubString& x, const SubString&  y);
1300 int operator!=(const SubString& x, const SubString&  y);
1301 int operator> (const SubString& x, const SubString&  y);
1302 int operator>=(const SubString& x, const SubString&  y);
1303 int operator< (const SubString& x, const SubString&  y);
1304 int operator<=(const SubString& x, const SubString&  y);
1305 int operator==(const SubString& x, const char* t);
1306 int operator!=(const SubString& x, const char* t);
1307 int operator> (const SubString& x, const char* t);
1308 int operator>=(const SubString& x, const char* t);
1309 int operator< (const SubString& x, const char* t);
1310 int operator<=(const SubString& x, const char* t);
1311 
1312 
1313 
1314 
1315 // status reports, needed before defining other things
1316 
length()1317 inline unsigned int String::length() const {  return rep->len; }
empty()1318 inline int         String::empty() const { return rep->len == 0; }
chars()1319 inline const char* String::chars() const { return &(rep->s[0]); }
allocation()1320 inline int         String::allocation() const { return rep->sz; }
alloc(int newsize)1321 inline void        String::alloc(int newsize) { rep = Sresize(rep, newsize); }
1322 
length()1323 inline unsigned int SubString::length() const { return len; }
empty()1324 inline int         SubString::empty() const { return len == 0; }
chars()1325 inline const char* SubString::chars() const { return &(S.rep->s[pos]); }
1326 
1327 
1328 // constructors
1329 
String()1330 inline String::String()
1331   : rep(&_nilStrRep) {}
String(const String & x)1332 inline String::String(const String& x)
1333   : rep(Scopy(0, x.rep)) {}
String(const char * t)1334 inline String::String(const char* t)
1335   : rep(Salloc(0, t, -1, -1)) {}
String(const char * t,int tlen)1336 inline String::String(const char* t, int tlen)
1337   : rep(Salloc(0, t, tlen, tlen)) {}
String(const SubString & y)1338 inline String::String(const SubString& y)
1339   : rep(Salloc(0, y.chars(), y.length(), y.length())) {}
String(char c)1340 inline String::String(char c)
1341   : rep(Salloc(0, &c, 1, 1)) {}
1342 
~String()1343 inline String::~String() { if (rep != &_nilStrRep) delete rep; }
1344 
SubString(const SubString & x)1345 inline SubString::SubString(const SubString& x)
1346   :S(x.S), pos(x.pos), len(x.len) {}
SubString(String & x,int first,int l)1347 inline SubString::SubString(String& x, int first, int l)
1348   :S(x), pos(first), len(l) {}
1349 
~SubString()1350 inline SubString::~SubString() {}
1351 
1352 // assignment
1353 
1354 inline void String::operator =  (const String& y)
1355 {
1356   rep = Scopy(rep, y.rep);
1357 }
1358 
1359 inline void String::operator=(const char* t)
1360 {
1361   rep = Salloc(rep, t, -1, -1);
1362 }
1363 
1364 inline void String::operator=(const SubString&  y)
1365 {
1366   rep = Salloc(rep, y.chars(), y.length(), y.length());
1367 }
1368 
1369 inline void String::operator=(char c)
1370 {
1371   rep = Salloc(rep, &c, 1, 1);
1372 }
1373 
1374 
1375 inline void SubString::operator = (const char* ys)
1376 {
1377   assign(0, ys);
1378 }
1379 
1380 inline void SubString::operator = (char ch)
1381 {
1382   assign(0, &ch, 1);
1383 }
1384 
1385 inline void SubString::operator = (const String& y)
1386 {
1387   assign(y.rep, y.chars(), y.length());
1388 }
1389 
1390 inline void SubString::operator = (const SubString& y)
1391 {
1392   assign(y.S.rep, y.chars(), y.length());
1393 }
1394 
1395 // Zillions of cats...
1396 
cat(const String & x,const String & y,String & r)1397 inline void cat(const String& x, const String& y, String& r)
1398 {
1399   r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
1400 }
1401 
cat(const String & x,const SubString & y,String & r)1402 inline void cat(const String& x, const SubString& y, String& r)
1403 {
1404   r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
1405 }
1406 
cat(const String & x,const char * y,String & r)1407 inline void cat(const String& x, const char* y, String& r)
1408 {
1409   r.rep = Scat(r.rep, x.chars(), x.length(), y, -1);
1410 }
1411 
cat(const String & x,char y,String & r)1412 inline void cat(const String& x, char y, String& r)
1413 {
1414   r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1);
1415 }
1416 
cat(const SubString & x,const String & y,String & r)1417 inline void cat(const SubString& x, const String& y, String& r)
1418 {
1419   r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
1420 }
1421 
cat(const SubString & x,const SubString & y,String & r)1422 inline void cat(const SubString& x, const SubString& y, String& r)
1423 {
1424   r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
1425 }
1426 
cat(const SubString & x,const char * y,String & r)1427 inline void cat(const SubString& x, const char* y, String& r)
1428 {
1429   r.rep = Scat(r.rep, x.chars(), x.length(), y, -1);
1430 }
1431 
cat(const SubString & x,char y,String & r)1432 inline void cat(const SubString& x, char y, String& r)
1433 {
1434   r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1);
1435 }
1436 
cat(const char * x,const String & y,String & r)1437 inline void cat(const char* x, const String& y, String& r)
1438 {
1439   r.rep = Scat(r.rep, x, -1, y.chars(), y.length());
1440 }
1441 
cat(const char * x,const SubString & y,String & r)1442 inline void cat(const char* x, const SubString& y, String& r)
1443 {
1444   r.rep = Scat(r.rep, x, -1, y.chars(), y.length());
1445 }
1446 
cat(const char * x,const char * y,String & r)1447 inline void cat(const char* x, const char* y, String& r)
1448 {
1449   r.rep = Scat(r.rep, x, -1, y, -1);
1450 }
1451 
cat(const char * x,char y,String & r)1452 inline void cat(const char* x, char y, String& r)
1453 {
1454   r.rep = Scat(r.rep, x, -1, &y, 1);
1455 }
1456 
cat(const String & a,const String & x,const String & y,String & r)1457 inline void cat(const String& a, const String& x, const String& y, String& r)
1458 {
1459   r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
1460 }
1461 
cat(const String & a,const String & x,const SubString & y,String & r)1462 inline void cat(const String& a, const String& x, const SubString& y, String& r)
1463 {
1464   r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
1465 }
1466 
cat(const String & a,const String & x,const char * y,String & r)1467 inline void cat(const String& a, const String& x, const char* y, String& r)
1468 {
1469   r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1);
1470 }
1471 
cat(const String & a,const String & x,char y,String & r)1472 inline void cat(const String& a, const String& x, char y, String& r)
1473 {
1474   r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1);
1475 }
1476 
cat(const String & a,const SubString & x,const String & y,String & r)1477 inline void cat(const String& a, const SubString& x, const String& y, String& r)
1478 {
1479   r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
1480 }
1481 
cat(const String & a,const SubString & x,const SubString & y,String & r)1482 inline void cat(const String& a, const SubString& x, const SubString& y, String& r)
1483 {
1484   r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
1485 }
1486 
cat(const String & a,const SubString & x,const char * y,String & r)1487 inline void cat(const String& a, const SubString& x, const char* y, String& r)
1488 {
1489   r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1);
1490 }
1491 
cat(const String & a,const SubString & x,char y,String & r)1492 inline void cat(const String& a, const SubString& x, char y, String& r)
1493 {
1494   r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1);
1495 }
1496 
cat(const String & a,const char * x,const String & y,String & r)1497 inline void cat(const String& a, const char* x, const String& y, String& r)
1498 {
1499   r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length());
1500 }
1501 
cat(const String & a,const char * x,const SubString & y,String & r)1502 inline void cat(const String& a, const char* x, const SubString& y, String& r)
1503 {
1504   r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length());
1505 }
1506 
cat(const String & a,const char * x,const char * y,String & r)1507 inline void cat(const String& a, const char* x, const char* y, String& r)
1508 {
1509   r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1);
1510 }
1511 
cat(const String & a,const char * x,char y,String & r)1512 inline void cat(const String& a, const char* x, char y, String& r)
1513 {
1514   r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1);
1515 }
1516 
1517 
cat(const char * a,const String & x,const String & y,String & r)1518 inline void cat(const char* a, const String& x, const String& y, String& r)
1519 {
1520   r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
1521 }
1522 
cat(const char * a,const String & x,const SubString & y,String & r)1523 inline void cat(const char* a, const String& x, const SubString& y, String& r)
1524 {
1525   r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
1526 }
1527 
cat(const char * a,const String & x,const char * y,String & r)1528 inline void cat(const char* a, const String& x, const char* y, String& r)
1529 {
1530   r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1);
1531 }
1532 
cat(const char * a,const String & x,char y,String & r)1533 inline void cat(const char* a, const String& x, char y, String& r)
1534 {
1535   r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1);
1536 }
1537 
cat(const char * a,const SubString & x,const String & y,String & r)1538 inline void cat(const char* a, const SubString& x, const String& y, String& r)
1539 {
1540   r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
1541 }
1542 
cat(const char * a,const SubString & x,const SubString & y,String & r)1543 inline void cat(const char* a, const SubString& x, const SubString& y, String& r)
1544 {
1545   r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
1546 }
1547 
cat(const char * a,const SubString & x,const char * y,String & r)1548 inline void cat(const char* a, const SubString& x, const char* y, String& r)
1549 {
1550   r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1);
1551 }
1552 
cat(const char * a,const SubString & x,char y,String & r)1553 inline void cat(const char* a, const SubString& x, char y, String& r)
1554 {
1555   r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1);
1556 }
1557 
cat(const char * a,const char * x,const String & y,String & r)1558 inline void cat(const char* a, const char* x, const String& y, String& r)
1559 {
1560   r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length());
1561 }
1562 
cat(const char * a,const char * x,const SubString & y,String & r)1563 inline void cat(const char* a, const char* x, const SubString& y, String& r)
1564 {
1565   r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length());
1566 }
1567 
cat(const char * a,const char * x,const char * y,String & r)1568 inline void cat(const char* a, const char* x, const char* y, String& r)
1569 {
1570   r.rep = Scat(r.rep, a, -1, x, -1, y, -1);
1571 }
1572 
cat(const char * a,const char * x,char y,String & r)1573 inline void cat(const char* a, const char* x, char y, String& r)
1574 {
1575   r.rep = Scat(r.rep, a, -1, x, -1, &y, 1);
1576 }
1577 
1578 
1579 // operator versions
1580 
1581 inline void String::operator +=(const String& y)
1582 {
1583   cat(*this, y, *this);
1584 }
1585 
1586 inline void String::operator +=(const SubString& y)
1587 {
1588   cat(*this, y, *this);
1589 }
1590 
1591 inline void String::operator += (const char* y)
1592 {
1593   cat(*this, y, *this);
1594 }
1595 
1596 inline void String:: operator +=(char y)
1597 {
1598   cat(*this, y, *this);
1599 }
1600 
1601 // constructive concatenation
1602 
1603 
1604 
1605 inline String operator + (const String& x, const String& y) return r; // { dg-error "" }
1606 {
1607   cat(x, y, r); // { dg-error "" }
1608 }
1609 
1610 inline String operator + (const String& x, const SubString& y) return r; // { dg-error "" }
1611 {
1612   cat(x, y, r); // { dg-error "" }
1613 }
1614 
1615 inline String operator + (const String& x, const char* y) return r; // { dg-error "" }
1616 {
1617   cat(x, y, r); // { dg-error "" }
1618 }
1619 
1620 inline String operator + (const String& x, char y) return r; // { dg-error "" }
1621 {
1622   cat(x, y, r); // { dg-error "" }
1623 }
1624 
1625 inline String operator + (const SubString& x, const String& y) return r; // { dg-error "" }
1626 {
1627   cat(x, y, r); // { dg-error "" }
1628 }
1629 
1630 inline String operator + (const SubString& x, const SubString& y) return r; // { dg-error "" }
1631 {
1632   cat(x, y, r); // { dg-error "" }
1633 }
1634 
1635 inline String operator + (const SubString& x, const char* y) return r; // { dg-error "" }
1636 {
1637   cat(x, y, r); // { dg-error "" }
1638 }
1639 
1640 inline String operator + (const SubString& x, char y) return r; // { dg-error "" }
1641 {
1642   cat(x, y, r); // { dg-error "" }
1643 }
1644 
1645 inline String operator + (const char* x, const String& y) return r; // { dg-error "" }
1646 {
1647   cat(x, y, r); // { dg-error "" }
1648 }
1649 
1650 inline String operator + (const char* x, const SubString& y) return r; // { dg-error "" }
1651 {
1652   cat(x, y, r); // { dg-error "" }
1653 }
1654 
1655 inline String reverse(const String& x) return r; // { dg-error "" }
1656 {
1657   r.rep = Sreverse(x.rep, r.rep); // { dg-error "" }
1658 }
1659 
1660 inline String upcase(const String& x) return r; // { dg-error "" }
1661 {
1662   r.rep = Supcase(x.rep, r.rep); // { dg-error "" }
1663 }
1664 
1665 inline String downcase(const String& x) return r; // { dg-error "" }
1666 {
1667   r.rep = Sdowncase(x.rep, r.rep); // { dg-error "" }
1668 }
1669 
1670 inline String capitalize(const String& x) return r; // { dg-error "" }
1671 {
1672   r.rep = Scapitalize(x.rep, r.rep); // { dg-error "" }
1673 }
1674 
1675 //# 883 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h"
1676 
1677 
1678 // prepend
1679 
prepend(const String & y)1680 inline void String::prepend(const String& y)
1681 {
1682   rep = Sprepend(rep, y.chars(), y.length());
1683 }
1684 
prepend(const char * y)1685 inline void String::prepend(const char* y)
1686 {
1687   rep = Sprepend(rep, y, -1);
1688 }
1689 
prepend(char y)1690 inline void String::prepend(char y)
1691 {
1692   rep = Sprepend(rep, &y, 1);
1693 }
1694 
prepend(const SubString & y)1695 inline void String::prepend(const SubString& y)
1696 {
1697   rep = Sprepend(rep, y.chars(), y.length());
1698 }
1699 
1700 // misc transformations
1701 
1702 
reverse()1703 inline void String::reverse()
1704 {
1705   rep = Sreverse(rep, rep);
1706 }
1707 
1708 
upcase()1709 inline void String::upcase()
1710 {
1711   rep = Supcase(rep, rep);
1712 }
1713 
1714 
downcase()1715 inline void String::downcase()
1716 {
1717   rep = Sdowncase(rep, rep);
1718 }
1719 
1720 
capitalize()1721 inline void String::capitalize()
1722 {
1723   rep = Scapitalize(rep, rep);
1724 }
1725 
1726 // element extraction
1727 
1728 inline char&  String::operator [] (int i)
1729 {
1730   if (((unsigned)i) >= length()) error("invalid index");
1731   return rep->s[i];
1732 }
1733 
elem(int i)1734 inline char  String::elem (int i) const
1735 {
1736   if (((unsigned)i) >= length()) error("invalid index");
1737   return rep->s[i];
1738 }
1739 
firstchar()1740 inline char  String::firstchar() const
1741 {
1742   return elem(0);
1743 }
1744 
lastchar()1745 inline char  String::lastchar() const
1746 {
1747   return elem(length() - 1);
1748 }
1749 
1750 // searching
1751 
index(char c,int startpos)1752 inline int String::index(char c, int startpos) const
1753 {
1754   return search(startpos, length(), c);
1755 }
1756 
index(const char * t,int startpos)1757 inline int String::index(const char* t, int startpos) const
1758 {
1759   return search(startpos, length(), t);
1760 }
1761 
index(const String & y,int startpos)1762 inline int String::index(const String& y, int startpos) const
1763 {
1764   return search(startpos, length(), y.chars(), y.length());
1765 }
1766 
index(const SubString & y,int startpos)1767 inline int String::index(const SubString& y, int startpos) const
1768 {
1769   return search(startpos, length(), y.chars(), y.length());
1770 }
1771 
index(const Regex & r,int startpos)1772 inline int String::index(const Regex& r, int startpos) const
1773 {
1774   int unused;  return r.search(chars(), length(), unused, startpos);
1775 }
1776 
contains(char c)1777 inline int String::contains(char c) const
1778 {
1779   return search(0, length(), c) >= 0;
1780 }
1781 
contains(const char * t)1782 inline int String::contains(const char* t) const
1783 {
1784   return search(0, length(), t) >= 0;
1785 }
1786 
contains(const String & y)1787 inline int String::contains(const String& y) const
1788 {
1789   return search(0, length(), y.chars(), y.length()) >= 0;
1790 }
1791 
contains(const SubString & y)1792 inline int String::contains(const SubString& y) const
1793 {
1794   return search(0, length(), y.chars(), y.length()) >= 0;
1795 }
1796 
contains(char c,int p)1797 inline int String::contains(char c, int p) const
1798 {
1799   return match(p, length(), 0, &c, 1) >= 0;
1800 }
1801 
contains(const char * t,int p)1802 inline int String::contains(const char* t, int p) const
1803 {
1804   return match(p, length(), 0, t) >= 0;
1805 }
1806 
contains(const String & y,int p)1807 inline int String::contains(const String& y, int p) const
1808 {
1809   return match(p, length(), 0, y.chars(), y.length()) >= 0;
1810 }
1811 
contains(const SubString & y,int p)1812 inline int String::contains(const SubString& y, int p) const
1813 {
1814   return match(p, length(), 0, y.chars(), y.length()) >= 0;
1815 }
1816 
contains(const Regex & r)1817 inline int String::contains(const Regex& r) const
1818 {
1819   int unused;  return r.search(chars(), length(), unused, 0) >= 0;
1820 }
1821 
contains(const Regex & r,int p)1822 inline int String::contains(const Regex& r, int p) const
1823 {
1824   return r.match(chars(), length(), p) >= 0;
1825 }
1826 
1827 
matches(const SubString & y,int p)1828 inline int String::matches(const SubString& y, int p) const
1829 {
1830   return match(p, length(), 1, y.chars(), y.length()) >= 0;
1831 }
1832 
matches(const String & y,int p)1833 inline int String::matches(const String& y, int p) const
1834 {
1835   return match(p, length(), 1, y.chars(), y.length()) >= 0;
1836 }
1837 
matches(const char * t,int p)1838 inline int String::matches(const char* t, int p) const
1839 {
1840   return match(p, length(), 1, t) >= 0;
1841 }
1842 
matches(char c,int p)1843 inline int String::matches(char c, int p) const
1844 {
1845   return match(p, length(), 1, &c, 1) >= 0;
1846 }
1847 
matches(const Regex & r,int p)1848 inline int String::matches(const Regex& r, int p) const
1849 {
1850   int l = (p < 0)? -p : length() - p;
1851   return r.match(chars(), length(), p) == l;
1852 }
1853 
1854 
contains(const char * t)1855 inline int SubString::contains(const char* t) const
1856 {
1857   return S.search(pos, pos+len, t) >= 0;
1858 }
1859 
contains(const String & y)1860 inline int SubString::contains(const String& y) const
1861 {
1862   return S.search(pos, pos+len, y.chars(), y.length()) >= 0;
1863 }
1864 
contains(const SubString & y)1865 inline int SubString::contains(const SubString&  y) const
1866 {
1867   return S.search(pos, pos+len, y.chars(), y.length()) >= 0;
1868 }
1869 
contains(char c)1870 inline int SubString::contains(char c) const
1871 {
1872   return S.search(pos, pos+len, 0, c) >= 0;
1873 }
1874 
contains(const Regex & r)1875 inline int SubString::contains(const Regex& r) const
1876 {
1877   int unused;  return r.search(chars(), len, unused, 0) >= 0;
1878 }
1879 
matches(const Regex & r)1880 inline int SubString::matches(const Regex& r) const
1881 {
1882   return r.match(chars(), len, 0) == len;
1883 }
1884 
1885 
gsub(const String & pat,const String & r)1886 inline int String::gsub(const String& pat, const String& r)
1887 {
1888   return _gsub(pat.chars(), pat.length(), r.chars(), r.length());
1889 }
1890 
gsub(const SubString & pat,const String & r)1891 inline int String::gsub(const SubString&  pat, const String& r)
1892 {
1893   return _gsub(pat.chars(), pat.length(), r.chars(), r.length());
1894 }
1895 
gsub(const Regex & pat,const String & r)1896 inline int String::gsub(const Regex& pat, const String& r)
1897 {
1898   return _gsub(pat, r.chars(), r.length());
1899 }
1900 
gsub(const char * pat,const String & r)1901 inline int String::gsub(const char* pat, const String& r)
1902 {
1903   return _gsub(pat, -1, r.chars(), r.length());
1904 }
1905 
gsub(const char * pat,const char * r)1906 inline int String::gsub(const char* pat, const char* r)
1907 {
1908   return _gsub(pat, -1, r, -1);
1909 }
1910 
1911 
1912 
1913 inline  ostream& operator<<(ostream& s, const String& x)
1914 {
1915    s << x.chars(); return s;
1916 }
1917 
1918 // a zillion comparison operators
1919 
1920 inline int operator==(const String& x, const String& y)
1921 {
1922   return compare(x, y) == 0;
1923 }
1924 
1925 inline int operator!=(const String& x, const String& y)
1926 {
1927   return compare(x, y) != 0;
1928 }
1929 
1930 inline int operator>(const String& x, const String& y)
1931 {
1932   return compare(x, y) > 0;
1933 }
1934 
1935 inline int operator>=(const String& x, const String& y)
1936 {
1937   return compare(x, y) >= 0;
1938 }
1939 
1940 inline int operator<(const String& x, const String& y)
1941 {
1942   return compare(x, y) < 0;
1943 }
1944 
1945 inline int operator<=(const String& x, const String& y)
1946 {
1947   return compare(x, y) <= 0;
1948 }
1949 
1950 inline int operator==(const String& x, const SubString&  y)
1951 {
1952   return compare(x, y) == 0;
1953 }
1954 
1955 inline int operator!=(const String& x, const SubString&  y)
1956 {
1957   return compare(x, y) != 0;
1958 }
1959 
1960 inline int operator>(const String& x, const SubString&  y)
1961 {
1962   return compare(x, y) > 0;
1963 }
1964 
1965 inline int operator>=(const String& x, const SubString&  y)
1966 {
1967   return compare(x, y) >= 0;
1968 }
1969 
1970 inline int operator<(const String& x, const SubString&  y)
1971 {
1972   return compare(x, y) < 0;
1973 }
1974 
1975 inline int operator<=(const String& x, const SubString&  y)
1976 {
1977   return compare(x, y) <= 0;
1978 }
1979 
1980 inline int operator==(const String& x, const char* t)
1981 {
1982   return compare(x, t) == 0;
1983 }
1984 
1985 inline int operator!=(const String& x, const char* t)
1986 {
1987   return compare(x, t) != 0;
1988 }
1989 
1990 inline int operator>(const String& x, const char* t)
1991 {
1992   return compare(x, t) > 0;
1993 }
1994 
1995 inline int operator>=(const String& x, const char* t)
1996 {
1997   return compare(x, t) >= 0;
1998 }
1999 
2000 inline int operator<(const String& x, const char* t)
2001 {
2002   return compare(x, t) < 0;
2003 }
2004 
2005 inline int operator<=(const String& x, const char* t)
2006 {
2007   return compare(x, t) <= 0;
2008 }
2009 
2010 inline int operator==(const SubString& x, const String& y)
2011 {
2012   return compare(y, x) == 0;
2013 }
2014 
2015 inline int operator!=(const SubString& x, const String& y)
2016 {
2017   return compare(y, x) != 0;
2018 }
2019 
2020 inline int operator>(const SubString& x, const String& y)
2021 {
2022   return compare(y, x) < 0;
2023 }
2024 
2025 inline int operator>=(const SubString& x, const String& y)
2026 {
2027   return compare(y, x) <= 0;
2028 }
2029 
2030 inline int operator<(const SubString& x, const String& y)
2031 {
2032   return compare(y, x) > 0;
2033 }
2034 
2035 inline int operator<=(const SubString& x, const String& y)
2036 {
2037   return compare(y, x) >= 0;
2038 }
2039 
2040 inline int operator==(const SubString& x, const SubString&  y)
2041 {
2042   return compare(x, y) == 0;
2043 }
2044 
2045 inline int operator!=(const SubString& x, const SubString&  y)
2046 {
2047   return compare(x, y) != 0;
2048 }
2049 
2050 inline int operator>(const SubString& x, const SubString&  y)
2051 {
2052   return compare(x, y) > 0;
2053 }
2054 
2055 inline int operator>=(const SubString& x, const SubString&  y)
2056 {
2057   return compare(x, y) >= 0;
2058 }
2059 
2060 inline int operator<(const SubString& x, const SubString&  y)
2061 {
2062   return compare(x, y) < 0;
2063 }
2064 
2065 inline int operator<=(const SubString& x, const SubString&  y)
2066 {
2067   return compare(x, y) <= 0;
2068 }
2069 
2070 inline int operator==(const SubString& x, const char* t)
2071 {
2072   return compare(x, t) == 0;
2073 }
2074 
2075 inline int operator!=(const SubString& x, const char* t)
2076 {
2077   return compare(x, t) != 0;
2078 }
2079 
2080 inline int operator>(const SubString& x, const char* t)
2081 {
2082   return compare(x, t) > 0;
2083 }
2084 
2085 inline int operator>=(const SubString& x, const char* t)
2086 {
2087   return compare(x, t) >= 0;
2088 }
2089 
2090 inline int operator<(const SubString& x, const char* t)
2091 {
2092   return compare(x, t) < 0;
2093 }
2094 
2095 inline int operator<=(const SubString& x, const char* t)
2096 {
2097   return compare(x, t) <= 0;
2098 }
2099 
2100 
2101 // a helper needed by at, before, etc.
2102 
_substr(int first,int l)2103 inline SubString String::_substr(int first, int l)
2104 {
2105   if (first >= length() )  // ??? THIS LINE IS QUESTIONABLE
2106     return SubString(_nilString, 0, 0) ;
2107   else
2108     return SubString(*this, first, l);
2109 }
2110 
2111 
2112 
2113 
2114 
2115 //# 26 "../../GctSymbol.h" 2
2116 
2117 
2118 //# 1 "../../../../../../mips/include/Gct/Object/GctHashObject.h" 1
2119 // -*- C++ -*-
2120 
2121 
2122 
2123 //
2124 // GctHashObject class (is abstract)
2125 //
2126 // Expects to be included by Object.h or where needed explicitly.
2127 //
2128 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
2129 //
2130 
2131 
2132 
2133 
2134 
2135 //#pragma interface
2136 
2137 
2138 
2139 //# 1 "../../../../../../mips/include/Gct/Object/GctObject.h" 1
2140 // -*- C++ -*-
2141 
2142 
2143 
2144 //
2145 // GctObject class (is abstract)
2146 //
2147 // Expects to be included by Object.h or where needed explicitly.
2148 //
2149 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
2150 //
2151 
2152 
2153 
2154 
2155 
2156 //#pragma interface
2157 
2158 
2159 
2160 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1
2161 // -*- C++ -*-
2162 
2163 
2164 
2165 //
2166 // tostrstream class
2167 //
2168 // A terminated oststream - an ostsrstream that auto-terminates on str()
2169 //
2170 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
2171 //
2172 
2173 
2174 
2175 
2176 
2177 //#pragma interface
2178 
2179 
2180 
2181 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/strstream.h" 1
2182 //    This is part of the iostream library, providing input/output for C++.
2183 //    Copyright (C) 1991 Per Bothner.
2184 //
2185 //    This library is free software; you can redistribute it and/or
2186 //    modify it under the terms of the GNU Library General Public
2187 //    License as published by the Free Software Foundation; either
2188 //    version 2 of the License, or (at your option) any later version.
2189 //
2190 //    This library is distributed in the hope that it will be useful,
2191 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
2192 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2193 //    Library General Public License for more details.
2194 //
2195 //    You should have received a copy of the GNU Library General Public
2196 //    License along with this library; if not, write to the Free
2197 //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2198 
2199 
2200 
2201 
2202 //#pragma interface
2203 
2204 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
2205 //    This is part of the iostream library, providing -*- C++ -*- input/output.
2206 //    Copyright (C) 1991 Per Bothner.
2207 //
2208 //    This library is free software; you can redistribute it and/or
2209 //    modify it under the terms of the GNU Library General Public
2210 //    License as published by the Free Software Foundation; either
2211 //    version 2 of the License, or (at your option) any later version.
2212 //
2213 //    This library is distributed in the hope that it will be useful,
2214 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
2215 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2216 //    Library General Public License for more details.
2217 //
2218 //    You should have received a copy of the GNU Library General Public
2219 //    License along with this library; if not, write to the Free
2220 //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2221 
2222 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
2223 
2224 //# 23 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/strstream.h" 2
2225 
2226 
2227 class strstreambuf : public streambuf {
2228     size_t *lenp; /* current (logical) length (i.e. valid data bytes) */
2229     size_t *sizep; /* allocated (physical) buffer size */
2230     char **bufp;
2231     size_t _len;
2232     size_t _size;
2233     char *buf;
2234     int _frozen;
2235   protected:
2236     virtual int overflow(int = (-1) );
2237   public:
2238     strstreambuf();
2239     strstreambuf(int initial);
2240     strstreambuf(char *ptr, int size, char *pstart = (__null) );
2241     ~strstreambuf();
frozen()2242     int frozen() { return _frozen; }
2243     void freeze(int n=1) { _frozen = n != 0; }
2244     size_t pcount();
2245     char *str();
2246 };
2247 
2248 class istrstream : public istream {
2249   public:
2250     istrstream(char*);
2251     istrstream(char*, int);
rdbuf()2252     strstreambuf* rdbuf() { return (strstreambuf*)_strbuf; }
2253 };
2254 
2255 class ostrstream : public ostream {
2256   public:
2257     ostrstream();
2258     ostrstream(char *cp, int n, int mode=ios::out);
pcount()2259     size_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); }
str()2260     char *str() { return ((strstreambuf*)_strbuf)->str(); }
2261     void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); }
frozen()2262     int frozen() { return ((strstreambuf*)_strbuf)->frozen(); }
rdbuf()2263     strstreambuf* rdbuf() { return (strstreambuf*)_strbuf; }
2264 };
2265 
2266 
2267 //# 25 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 2
2268 
2269 
2270 //
2271 // tostrstream class
2272 //
2273 // An isteam class that doesn't have that nasty skipws parameter that
2274 // you have to remember to set.  This class simply provides the istream
2275 // functionality with a set of constructors which defaults skipws to
2276 // FALSE (instead of defaulting to TRUE as is the case with plain istream).
2277 //
2278 class tostrstream: public ostrstream {
2279 public:
tostrstream()2280     tostrstream(): ostrstream()
2281 	{ }
2282     // This constructor defines cp as the buffer to use for the
2283     // stream (instead of one of its own devising); it does NOT
2284     // initialize the ostrstream to contain cp (of length n).
ostrtream(cp,n,mode)2285   tostrstream(char *cp, int n, int mode=ios::out): ostrtream(cp, n, mode)	// { dg-error "" }
2286 	{ }
str()2287     char *str()
2288 	{
2289 	    char *s = ostrstream::str();
2290 	    s[ostrstream::pcount()] = '\0';
2291 	    return s;
2292 	}
2293 };
2294 
2295 
2296 //# 25 "../../../../../../mips/include/Gct/Object/GctObject.h" 2
2297 
2298 
2299 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 1
2300 // -*- C++ -*-
2301 
2302 
2303 
2304 //
2305 // GttObject class (is abstract)
2306 //
2307 // Expects to be included where needed explicitly.
2308 //
2309 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
2310 //
2311 
2312 
2313 
2314 
2315 
2316 //#pragma interface
2317 
2318 
2319 
2320 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1
2321 // -*- C++ -*-
2322 //# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h"
2323 
2324 //# 25 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2
2325 
2326 
2327 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 1
2328 // -*- C++ -*-
2329 
2330 
2331 
2332 //
2333 // GttErrorHandler class
2334 //
2335 // Expects to be included by Gtt.h
2336 //
2337 // Wendell Baker, Berkeley CAD Group, 1992 (wbaker@ic.Berkeley.EDU)
2338 //
2339 
2340 
2341 
2342 
2343 
2344 //#pragma interface
2345 
2346 
2347 
2348 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1
2349 
2350 
2351 
2352 
2353 
2354 
2355 
2356 //# 25 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2
2357 
2358 
2359 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 1
2360 // -*- C++ -*-
2361 
2362 
2363 
2364 //
2365 // Fake up a libstuff++
2366 //
2367 // This is done as a complete and utter hack; this library has no function
2368 // at all being in the boot area; it is here solely in order to provide a
2369 // libstuff++ against which the Makefiles can resolve link lines.
2370 //
2371 // The only reason that this is done is to allow the STANDARD_C++_LIBRARIES
2372 // as provided by the Makefile templates in the boot area to be the same
2373 // ones that are used by the tools outside this hierarchy.
2374 //
2375 // The tools outside this hierarchy use a different libstuff++; one that is
2376 // written in C++.  This one is not written in C++ in order to be simpler.
2377 //
2378 
2379 
2380 
2381 
2382 
2383 //#pragma interface
2384 
2385 
2386 
2387 extern "C" {
2388 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 1
2389 
2390 
2391 
2392 /*
2393  * Useful stuff
2394  */
2395 
2396 /*
2397  */
2398 
2399 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/ansi.h" 1
2400 
2401 
2402 
2403 
2404 /*
2405  * ANSI Compiler Support
2406  *
2407  * David Harrison
2408  * University of California, Berkeley
2409  * 1988
2410  *
2411  * ANSI compatible compilers are supposed to define the preprocessor
2412  * directive __STDC__.  Based on this directive, this file defines
2413  * certain ANSI specific macros.
2414  *
2415  * ARGS:
2416  *   Used in function prototypes.  Example:
2417  *   extern int foo
2418  *     ARGS((char *blah, double threshold));
2419  */
2420 
2421 /*
2422  *
2423  * Modifications
2424  * Wendell C Baker
2425  * University of California, Berkeley
2426  */
2427 
2428 /* Function prototypes */
2429 
2430 
2431 
2432 
2433 
2434 
2435 
2436 
2437 
2438 
2439 
2440 
2441 
2442 
2443 
2444 
2445 
2446 
2447 
2448 
2449 
2450 
2451 
2452 
2453 
2454 
2455 
2456 //# 15 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 2
2457 
2458 
2459 
2460 /*
2461  * If g++, then we stub out part of this thing and let the C++ types take
2462  * over and do the same job; some compatibility must be given however
2463  */
2464 
2465 /*
2466  *    Use the GNU libg++ definition
2467  */
2468 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1
2469 
2470 
2471 
2472 
2473 
2474 
2475 
2476 //# 26 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h" 2
2477 
2478 //# 35 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h"
2479 
2480 
2481 /*
2482  * Make various pieces of C code that use the old ``Boolean''
2483  * be compatible by faking up the definition of Boolean using
2484  * the new bool type.
2485  */
2486 
2487 
2488 //# 58 "/sandbox/wbaker/wbaker0/source/mips/include/stuff.h"
2489 
2490 
2491 typedef long FitAny;		/* can fit any integral type */
2492 
2493 /*
2494  * typedef char *String;	- DO NOT USE THIS - it conflicts with C++
2495  * typedef char **Stringv;	- just use char* and char** instead.
2496  * 				- void* can be used for arbitrary pointers
2497  */
2498 
2499 
2500 
2501 
2502 extern int nocase_strcmp (char *, char *)		;
2503 extern int nocase_strncmp (char *, char *, int)		;
2504 
2505 extern bool	 nocase_strequal (char *, char *)		;
2506 extern bool	 nocase_strnequal (char *, char *, int)		;
2507 
2508 extern bool	 lead_strequal (char *, char *)		;
2509 extern bool	 nocase_lead_strequal (char *, char *)		;
2510 
2511 extern int strhash (char *, int)		;
2512 extern int nocase_strhash (char *, int)		;
2513 
2514 extern int sign (int)		;
2515 
2516 /*
2517  *    Some useful macros.
2518  */
2519 
2520 
2521 
2522 
2523 
2524 
2525 
2526 
2527 
2528 
2529 
2530 
2531 
2532 
2533 
2534 
2535 
2536 
2537 
2538 
2539 
2540 
2541 
2542 
2543 
2544 
2545 
2546 
2547 
2548 //# 33 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2
2549 
2550 }
2551 
2552 //
2553 // This is here because we wish to provide externs for the two
2554 // functions btoa(bool, unsigned = 0) and operator<<(ostream&, bool)
2555 // because they are not provided in bool.h.
2556 //
2557 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1
2558 
2559 
2560 
2561 
2562 
2563 
2564 
2565 //# 41 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2
2566 
2567 extern const char *stringify(bool b);
2568 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
2569 //    This is part of the iostream library, providing -*- C++ -*- input/output.
2570 //    Copyright (C) 1991 Per Bothner.
2571 //
2572 //    This library is free software; you can redistribute it and/or
2573 //    modify it under the terms of the GNU Library General Public
2574 //    License as published by the Free Software Foundation; either
2575 //    version 2 of the License, or (at your option) any later version.
2576 //
2577 //    This library is distributed in the hope that it will be useful,
2578 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
2579 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2580 //    Library General Public License for more details.
2581 //
2582 //    You should have received a copy of the GNU Library General Public
2583 //    License along with this library; if not, write to the Free
2584 //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2585 
2586 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
2587 
2588 //# 43 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2
2589 
2590 extern ostream& operator<<(ostream&, bool);
2591 
2592 // Should this be kept separate?   bool isn't, but then  is
2593 // included here only to define ostream& operator<<(ostream&, bool)
2594 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/unit.h" 1
2595 // -*- C++ -*-
2596 
2597 
2598 
2599 //
2600 // unit enum
2601 //
2602 // Wendell Baker, Berkeley CAD Group, 1991 (wbaker@ic.Berkeley.EDU)
2603 //
2604 
2605 
2606 //
2607 // unit enum
2608 //
2609 // This _looks_ silly, but it has an important theoretical basis in category
2610 // theory.  For the pragmatic reason for its existence, see the example below.
2611 //
2612 enum unit {
2613     UNIT = 1,
2614 };
2615 
2616 extern const char *stringify(unit u);
2617 
2618 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
2619 //    This is part of the iostream library, providing -*- C++ -*- input/output.
2620 //    Copyright (C) 1991 Per Bothner.
2621 //
2622 //    This library is free software; you can redistribute it and/or
2623 //    modify it under the terms of the GNU Library General Public
2624 //    License as published by the Free Software Foundation; either
2625 //    version 2 of the License, or (at your option) any later version.
2626 //
2627 //    This library is distributed in the hope that it will be useful,
2628 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
2629 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2630 //    Library General Public License for more details.
2631 //
2632 //    You should have received a copy of the GNU Library General Public
2633 //    License along with this library; if not, write to the Free
2634 //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2635 
2636 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
2637 
2638 //# 28 "/sandbox/wbaker/wbaker0/source/mips/include/unit.h" 2
2639 
2640 extern ostream& operator<<(ostream&, unit);
2641 
2642 //
2643 // A unit is used in cases where the type signature of an overloaded
2644 // function must be differentiated in some stronger way than can be
2645 // denoted unambiguously in the C++ syntax.  This enum is used to give
2646 // one of the functions a different type signature, thereby allowing
2647 // the overloading.
2648 //
2649 // The use of ``unit'' instead of int or bool is important because a unit
2650 // has only one possible value; therefore it adds no more information to
2651 // the code.   For example, say a bool was used instead, then in the testing
2652 // phase, would have to ask: what if TRUE was given, what if FALSE was given.
2653 // The problem is compounded if char or int is used.
2654 //
2655 // Example:
2656 //
2657 //     class ID {
2658 //     public:
2659 //         ID();		// construct a null ID
2660 //         ID(unit);		// alloc a ID with a new id
2661 //     private:
2662 //         static unsigned high_water;
2663 //         unsigned id;
2664 //     };
2665 //
2666 // Try working this example save that ID implements all of the generic
2667 // features of the identifier object, but the high_water is stored
2668 // in the heir.  That is what originally motivated the creation of unit.
2669 //
2670 
2671 
2672 //# 48 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 2
2673 
2674 
2675 //
2676 // In the spirit of the standard GNU error handler functions
2677 // as described in
2678 //     typedef void (*one_arg_error_handler_t)(const char*);
2679 //         a one argument error handler function pointer
2680 //     typedef void (*two_arg_error_handler_t)(const char*, const char*);
2681 //         a two argument error handler function pointer
2682 //
2683 // And now the NEW
2684 //
2685 // typedef void (*zero_arg_error_handler_t)();
2686 //     a zero argument error handler function pointer
2687 //
2688 typedef void (*zero_arg_error_handler_t)();
2689 
2690 //
2691 // In the spirit of the default GNU error handler functions
2692 // as described in
2693 //     extern void default_one_arg_error_handler(const char *message);
2694 //         print out message on stderr, and do the default thing (abort)
2695 //     extern void default_two_arg_error_handler(const char *kind, const char *message);
2696 //         print out kind and message on stderr, and do the default thing (abort)
2697 //
2698 // And now the NEW
2699 //
2700 // extern void default_zero_arg_error_handler(const char *message);
2701 //     do the default thing (abort)
2702 //
2703 extern void default_zero_arg_error_handler();
2704 
2705 // Guaranteed to exit (1)
2706 extern void exit_zero_arg_error_handler();
2707 extern void exit_one_arg_error_handler(const char *message);
2708 extern void exit_two_arg_error_handler(const char *kind, const char *message);
2709 
2710 // Guaranteed to abort()
2711 extern void abort_zero_arg_error_handler();
2712 extern void abort_one_arg_error_handler(const char *message);
2713 extern void abort_two_arg_error_handler(const char *kind, const char *message);
2714 
2715 //
2716 // In the spirit of the standard GNU error handlers
2717 // as described in
2718 //     extern void  verbose_File_error_handler(const char*);
2719 //         perror and set errno = 0
2720 //     extern void  quiet_File_error_handler(const char*);
2721 //         set errno = 0
2722 //     extern void  fatal_File_error_handler(const char*);
2723 //         perror and exit 1
2724 //
2725 // And now the NEW
2726 //
2727 // extern void preserve_File_error_handler(const char *message);
2728 //     no perror, no assignment to errno.
2729 //
2730 extern void preserve_File_error_handler(const char *message);
2731 
2732 
2733 //# 27 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2
2734 
2735 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1
2736 // -*- C++ -*-
2737 //# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h"
2738 
2739 //# 28 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttErrorHandler.h" 2
2740 
2741 
2742 //
2743 // It is expected that this will be virtually multiply inherited
2744 // into all of the classes that need error reporting services.
2745 //
2746 // The typical way to have that done is by inheriting the GttObject
2747 // as a virtual base class.
2748 //
2749 
2750 //
2751 // GttErrorHandler class
2752 //
2753 class GttErrorHandler {
2754 public:
2755     GttErrorHandler();
2756     GttErrorHandler(const char *program);
2757     virtual ~GttErrorHandler();
2758 
2759     //
2760     // Error messages
2761     //     - an unacceptable, but expected and recoverable condition
2762     //       was detected (but the test fails)
2763     //     - errors are for ``the expected environment was not found''
2764     //       rather than for ``file couldn't be opened''
2765     //     - these messages cannot be shut off
2766     //     - the error handler determines the recovery action
2767     //       TODO - one day exceptions will be used here
2768     //
2769     static void error(const char *message);
2770     static void error(tostrstream& message);
2771 
2772     static void error(const char *function, const char *message);
2773     static void error(const char *function, tostrstream& message);
2774 
2775     static void error(const char *class_name, const char *method, const char *message);
2776     static void error(const char *class_name, const char *method, tostrstream& message);
2777 
2778     //
2779     // Fatal messages
2780     //     - an unacceptable and unexpected error was detected
2781     //       the data invariants were violated, there is no recovery
2782     //     - these messages cannot be shut off
2783     //     - the error handler determines the recovery action
2784     //       TODO - one day exceptions will be used here
2785     //
2786     static void fatal(const char *message);
2787     static void fatal(tostrstream& message);
2788 
2789     static void fatal(const char *function, const char *message);
2790     static void fatal(const char *function, tostrstream& message);
2791 
2792     static void fatal(const char *class_name, const char *method, const char *message);
2793     static void fatal(const char *class_name, const char *method, tostrstream& message);
2794 private:
2795     //
2796     // Two underscores are used here in order to prevent confusion of these
2797     // private variables with any of the heir's private variables.  Note that
2798     // access control is different than visibility in C++, so all the variable
2799     // names in a class hierarchy must be unique.
2800     //
2801 
2802     static bool __partial_init;
2803     static void __partial_initialize();
2804     static bool __full_init;
2805     static void __full_initialize(const char *program);
2806     static char *__program;
2807 
2808     static void __handle_error();
2809     static void __handle_fatal();
2810     static void __add_newline(const char *message);
2811 
2812     static bool __output_valid();
2813     static ostream *__output;
2814 };
2815 
2816 
2817 //# 27 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2
2818 
2819 
2820 //
2821 // GttObject class (is abstract)
2822 //
2823 class GttObject: virtual public GttErrorHandler {
2824 protected:
2825     GttObject();
2826     GttObject(const GttObject&);
2827     virtual ~GttObject();	// ensure descendants have virtual destructors
2828 
2829 public:
2830     //
2831     // I/O Support
2832     //
2833     // The value typically persists only long enough for an i/o operation
2834     // to be performed (see the defintion of output via operator<<(... ) below)
2835     virtual const char *stringify();
2836 protected:
2837     // This is the buffer into which the printed representation of this
2838     // object will be put when the time comes.  It is associated with the
2839     // object so it will never go away (so long as the object exists).
2840     // Use a pointer so that you only pay for the space when I/O is used
2841     tostrstream *stringbuf;
2842     void clear_stringbuf();
2843 
2844 public:
2845     //
2846     // Consistency
2847     //
2848     // The global data invariant for the whole object (heirs included).
2849     // This OK function will call the local invariant function ok() if
2850     // necessary and in addition the OK functions of the heirs
2851     // This is expected to compute the data invariant of the object.
2852     // It will execute GctErrorHandler::fatal if there is wrong.
2853     virtual void OK() const;
2854 
2855 protected:
2856     //
2857     // consistency
2858     //
2859     // This function computes the invariant which is local to this object.
2860     // It does not call any of the ancestor's OK() or ok() functions.
2861     // It is not a virtual function so that it can be called from within a
2862     // constructor with impunity.  Thus this function MUST NOT call any
2863     // virtual functions either; it should call them by their full name if
2864     // that is necessary.  The global OK() function will call this function
2865     // as necessary.
2866     //
2867     // This function must NOT NEVER EVER be made virtual.
2868     void ok() const;
2869 
2870 protected:
2871     //
2872     // Class Name
2873     //
2874     // This must return a static (constant) string which is the name
2875     // of the class being declared.  By convention, not all classes
2876     // must have one of these, but the major root abstract class must
2877     // have one in order to allow the stringify() to work approximately
2878     // correctly.
2879     virtual const char *class_name() const = 0;
2880 };
2881 
2882 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
2883 //    This is part of the iostream library, providing -*- C++ -*- input/output.
2884 //    Copyright (C) 1991 Per Bothner.
2885 //
2886 //    This library is free software; you can redistribute it and/or
2887 //    modify it under the terms of the GNU Library General Public
2888 //    License as published by the Free Software Foundation; either
2889 //    version 2 of the License, or (at your option) any later version.
2890 //
2891 //    This library is distributed in the hope that it will be useful,
2892 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
2893 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2894 //    Library General Public License for more details.
2895 //
2896 //    You should have received a copy of the GNU Library General Public
2897 //    License along with this library; if not, write to the Free
2898 //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2899 
2900 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
2901 
2902 //# 91 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 2
2903 
2904 extern ostream& operator<<(ostream&, GttObject&);
2905 
2906 // There may be other X& operator<<(X&, GttObject&) defined in the
2907 // packages defining class X.  For example see the definition of
2908 // GttUnitObject& operator<<(GttUnitObject&, GttObject&) in Unit.
2909 
2910 
2911 //# 27 "../../../../../../mips/include/Gct/Object/GctObject.h" 2
2912 
2913 
2914 //# 1 "../../../../../../mips/include/Gct/GctErrorHandler.h" 1
2915 // -*- C++ -*-
2916 
2917 
2918 
2919 //
2920 // GctErrorHandler class
2921 //
2922 // Expects to be included by Gct.h
2923 //
2924 // Wendell Baker, Berkeley CAD Group, 1991 (wbaker@ic.Berkeley.EDU)
2925 //
2926 
2927 
2928 
2929 
2930 
2931 //#pragma interface
2932 
2933 
2934 
2935 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/bool.h" 1
2936 
2937 
2938 
2939 
2940 
2941 
2942 
2943 //# 25 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2
2944 
2945 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h" 1
2946 // This may look like C code, but it is really -*- C++ -*-
2947 /*
2948 Copyright (C) 1988 Free Software Foundation
2949     written by Doug Lea (dl@rocky.oswego.edu)
2950 
2951 This file is part of the GNU C++ Library.  This library is free
2952 software; you can redistribute it and/or modify it under the terms of
2953 the GNU Library General Public License as published by the Free
2954 Software Foundation; either version 2 of the License, or (at your
2955 option) any later version.  This library is distributed in the hope
2956 that it will be useful, but WITHOUT ANY WARRANTY; without even the
2957 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
2958 PURPOSE.  See the GNU Library General Public License for more details.
2959 You should have received a copy of the GNU Library General Public
2960 License along with this library; if not, write to the Free Software
2961 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2962 */
2963 
2964 
2965 //# 1321 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/String.h"
2966 
2967 //# 26 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2
2968 
2969 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
2970 //    This is part of the iostream library, providing -*- C++ -*- input/output.
2971 //    Copyright (C) 1991 Per Bothner.
2972 //
2973 //    This library is free software; you can redistribute it and/or
2974 //    modify it under the terms of the GNU Library General Public
2975 //    License as published by the Free Software Foundation; either
2976 //    version 2 of the License, or (at your option) any later version.
2977 //
2978 //    This library is distributed in the hope that it will be useful,
2979 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
2980 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2981 //    Library General Public License for more details.
2982 //
2983 //    You should have received a copy of the GNU Library General Public
2984 //    License along with this library; if not, write to the Free
2985 //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2986 
2987 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
2988 
2989 //# 27 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2
2990 
2991 
2992 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h" 1
2993 // -*- C++ -*-
2994 //# 107 "/sandbox/wbaker/wbaker0/source/mips/include/stuff++.h"
2995 
2996 //# 29 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2
2997 
2998 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h" 1
2999 // -*- C++ -*-
3000 //# 52 "/sandbox/wbaker/wbaker0/source/mips/include/tostrstream.h"
3001 
3002 //# 30 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2
3003 
3004 
3005 //# 1 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h" 1
3006 // -*- C++ -*-
3007 //# 98 "/sandbox/wbaker/wbaker0/source/mips/include/Gtt/GttObject.h"
3008 
3009 //# 32 "../../../../../../mips/include/Gct/GctErrorHandler.h" 2
3010 
3011 
3012 //
3013 // It is expected that this will be virtually multiply inherited
3014 // into all of the classes that need error reporting services.
3015 //
3016 // The typical way to have that done is by inheriting the GctObject
3017 // as a virtual base class.
3018 //
3019 
3020 //
3021 // GctErrorHandler class
3022 //
3023 // GPP_1_96_BUG
3024 // NOTE - virtual public GttObject should be MI into GctObject - but that
3025 // causes g++ 1.96 to segfault; so we must inherit GttObject here and use SI
3026 // GPP_1_96_BUG
3027 class GctErrorHandler: virtual public GttObject {
3028 public:
3029     GctErrorHandler();
3030     GctErrorHandler(const String& program);
3031     virtual ~GctErrorHandler();
3032 
3033     //
3034     // Debugging messages
3035     //     - these are turned off for production code.
3036     //     - these messages can be shut off
3037     //
3038     static void debug(const char *message);
3039     static void debug(tostrstream& message);
3040 
3041     static void debug(const char *function, const char *message);
3042     static void debug(const char *function, tostrstream& message);
3043 
3044     static void debug(const char *class_name, const char *method, const char *message);
3045     static void debug(const char *class_name, const char *method, tostrstream& message);
3046 
3047     static bool debug();		// current debug switch
3048     static void debug(bool value);	// change the debug switch
3049 
3050     //
3051     // Informational messages
3052     //     - these correspond to a ``verbose'' mode
3053     //     - these are not errors, just chatty progress reports
3054     //     - these messages can be shut off
3055     //
3056     static void note(const char *message);
3057     static void note(tostrstream& message);
3058 
3059     static void note(const char *function, const char *message);
3060     static void note(const char *function, tostrstream& message);
3061 
3062     static void note(const char *class_name, const char *method, const char *message);
3063     static void note(const char *class_name, const char *method, tostrstream& message);
3064 
3065     static bool note();			// current note switch
3066     static void note(bool value);	// change the note switch
3067 
3068     //
3069     // Warning messages
3070     //     - warnings are system-recoverable errors
3071     //     - the system has noticed something and taken some
3072     //       corrective action
3073     //     - these messages can be shut off
3074     //
3075     static void warning(const char *message);
3076     static void warning(tostrstream& message);
3077 
3078     static void warning(const char *function, const char *message);
3079     static void warning(const char *function, tostrstream& message);
3080 
3081     static void warning(const char *class_name, const char *method, const char *message);
3082     static void warning(const char *class_name, const char *method, tostrstream& message);
3083 
3084     static bool warning();		// current warning switch
3085     static void warning(bool value);	// change the warning switch
3086 
3087     //
3088     // Error messages
3089     //     - an unacceptable, but expected and recoverable
3090     //       condition was detected
3091     //     - errors are for ``the expected environment was not found''
3092     //       rather than for ``file couldn't be opened''
3093     //     - these messages cannot be shut off
3094     //     - the error handler determines the recovery action
3095     //       TODO - one day exceptions will be used here
3096     //
3097     static void error(const char *message);
3098     static void error(tostrstream& message);
3099 
3100     static void error(const char *function, const char *message);
3101     static void error(const char *function, tostrstream& message);
3102 
3103     static void error(const char *class_name, const char *method, const char *message);
3104     static void error(const char *class_name, const char *method, tostrstream& message);
3105 
3106     // can't turn off errors - no ``static void error(bool value);''
3107     static zero_arg_error_handler_t error();		// current error handler
3108     static void error(zero_arg_error_handler_t handler);// change the error handler
3109 
3110     static void error_is_lib_error_handler();		// change the error handler
3111     static void error_is_exit();			// change the error handler
3112 
3113     // Describes the fatal handler - WATCHOUT - implicitly uses AllocRing
3114     static const char *error_handler_description();
3115 
3116     //
3117     // Fatal messages
3118     //     - an unacceptable and unexpected error was detected
3119     //       the data invariants were violated, there is no recovery
3120     //     - these messages cannot be shut off
3121     //     - the error handler determines the recovery action
3122     //       TODO - one day exceptions will be used here
3123     //
3124     static void fatal(const char *message);
3125     static void fatal(tostrstream& message);
3126 
3127     static void fatal(const char *function, const char *message);
3128     static void fatal(const char *function, tostrstream& message);
3129 
3130     static void fatal(const char *class_name, const char *method, const char *message);
3131     static void fatal(const char *class_name, const char *method, tostrstream& message);
3132 
3133     // can't turn off fatals - no ``static void fatal(bool value);''
3134     static zero_arg_error_handler_t fatal();			// return the fatal handler
3135     static void fatal(zero_arg_error_handler_t handler);	// change the fatal handler
3136 
3137     static void fatal_is_exit();	// change the fatal handler
3138     static void fatal_is_abort();	// change the fatal handler
3139 
3140     // Describes the fatal handler - WATCHOUT - implicitly uses AllocRing
3141     static const char *fatal_handler_description();
3142 private:
3143     //
3144     // Two underscores are used here in order to prevent confusion of these
3145     // private variables with any of the heir's private variables.  Note that
3146     // access control is different than visibility in C++, so all the variable
3147     // names in a class hierarchy must be unique.
3148     //
3149     static bool __debug;
3150     static bool __note;
3151     static bool __warning;
3152     static void (*__error_handler)();	// can't turn off errors
3153     static void (*__fatal_handler)();	// can't turn off fatals
3154 
3155     static bool __partial_init;
3156     static void __partial_initialize();
3157     static bool __full_init;
3158     static void __full_initialize(const char *program);
3159     static char *__program;
3160 
3161     static void __handle_error();
3162     static void __handle_fatal();
3163     static void __add_newline(const char *message);
3164     static void __message_switch(bool value, bool& flag, const char *description);
3165     static void __message_switch(bool value, bool& flag);
3166     static const char *__describe_handler(zero_arg_error_handler_t handler);
3167 
3168     static bool __output_valid();
3169     static ostream *__output;
3170 
3171     // GPP_1_96_BUG
3172     const char *class_name() const;
3173     // GPP_1_96_BUG
3174 };
3175 
3176 
3177 //# 29 "../../../../../../mips/include/Gct/Object/GctObject.h" 2
3178 
3179 
3180 //
3181 // GctObject class (is abstract)
3182 //
3183 class GctObject: virtual public GctErrorHandler /*, virtual public GttObject*/ {
3184 protected:
3185     GctObject();
3186     GctObject(const GctObject&);
3187     virtual ~GctObject();	// ensure descendants have virtual destructors
3188 
3189 public:
3190     //
3191     // I/O Support
3192     //
3193     // The value typically persists only long enough for an i/o operation
3194     // to be performed (see the defintion of output via operator<<(... ) below)
3195     virtual const char *stringify();
3196 protected:
3197     // This is the buffer into which the printed representation of this
3198     // object will be put when the time comes.  It is associated with the
3199     // object so it will never go away (so long as the object exists).
3200     // Use a pointer so that you only pay for the space when I/O is used
3201     tostrstream *stringbuf;
3202     void clear_stringbuf();
3203 
3204 public:
3205     //
3206     // Consistency (global consistency)
3207     //
3208     // The global data invariant for the whole object (heirs included).
3209     // This OK function will call the local invariant function ok() if
3210     // necessary and in addition the OK functions of the heirs
3211     // This is expected to compute the data invariant of the object.
3212     // It will execute GctErrorHandler::fatal if there is wrong.
3213     virtual void OK() const;
3214 
3215 protected:
3216     //
3217     // consistency (local consistency)
3218     //
3219     // This function computes the invariant which is local to this object.
3220     // It does not call any of the ancestor's OK() or ok() functions.
3221     // It is not a virtual function so that it can be called from within a
3222     // constructor with impunity.  Thus this function MUST NOT call any
3223     // virtual functions either; it should call them by their full name if
3224     // that is necessary.  The global OK() function will call this function
3225     // as necessary.
3226     //
3227     // This function must NOT NEVER EVER be made virtual.
3228     void ok() const;
3229 protected:
3230     //
3231     // Class Name
3232     //
3233     // This must return a static (constant) string which is the name
3234     // of the class being declared.  By convention, not all classes
3235     // must have one of these, but the major root abstract class must
3236     // have one in order to allow the stringify() to work approximately
3237     // correctly.
3238     virtual const char *class_name() const = 0;
3239 
3240 public:
3241     //
3242     // The ``id'' of this object
3243     //
3244     // NOTE - we explicitly allow the situation where this function
3245     // can return the address of the object - the ``this'' pointer
3246     // instead of a computed id field (the __object_id field below).
3247     //
3248     // This function is protected because we don't want too much dependence
3249     // on this notion of object identity.  I want to be able to rip it
3250     // out if it becomes to cumbersome.
3251     unsigned objectId() const;
3252 private:
3253     //
3254     // Symbolic ID
3255     //
3256     // NOTE - Normally this would be implemented by the `this' pointer.
3257     // TODO - remove this for production code
3258     //
3259     // However, in order to make the test suites run on all machines, we
3260     // make this into a symbolic id that is maintained with each object.
3261     // Thus the valid outputs are always consistent across all machines.
3262     unsigned __object_id;
3263     static unsigned __next_id;
3264 };
3265 
3266 //# 1 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h" 1
3267 //    This is part of the iostream library, providing -*- C++ -*- input/output.
3268 //    Copyright (C) 1991 Per Bothner.
3269 //
3270 //    This library is free software; you can redistribute it and/or
3271 //    modify it under the terms of the GNU Library General Public
3272 //    License as published by the Free Software Foundation; either
3273 //    version 2 of the License, or (at your option) any later version.
3274 //
3275 //    This library is distributed in the hope that it will be useful,
3276 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
3277 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3278 //    Library General Public License for more details.
3279 //
3280 //    You should have received a copy of the GNU Library General Public
3281 //    License along with this library; if not, write to the Free
3282 //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3283 
3284 //# 210 "/projects/gnu-cygnus/gnu-cygnus-8/common/g++-include/iostream.h"
3285 
3286 //# 117 "../../../../../../mips/include/Gct/Object/GctObject.h" 2
3287 
3288 extern ostream& operator<<(ostream&, GctObject&);
3289 
3290 
3291 //# 25 "../../../../../../mips/include/Gct/Object/GctHashObject.h" 2
3292 
3293 
3294 //
3295 // GctHashObject class (is abstract)
3296 //
3297 class GctHashObject: virtual public GctObject {
3298 protected:
3299     GctHashObject();
3300     GctHashObject(const GctHashObject&);
3301 
3302 public:
3303     //
3304     // hash support
3305     //
3306     virtual unsigned hash() const;
3307 };
3308 
3309 
3310 //# 28 "../../GctSymbol.h" 2
3311 
3312 
3313 //
3314 // GctSymbol
3315 //
3316 class GctSymbol: virtual public GctHashObject, String {
3317 public:
3318     GctSymbol();		// vacuous symbol required for genclass usage
3319     GctSymbol(const char*);
3320     GctSymbol(const String&);
3321     GctSymbol(const GctSymbol&);
3322 
3323     operator const char *() const;
3324 
3325     bool operator==(const GctSymbol&) const;
3326     bool operator!=(const GctSymbol&) const;
3327 
3328     bool operator<=(const GctSymbol&) const;
3329     bool operator<(const GctSymbol&) const;
3330     bool operator>=(const GctSymbol&) const;
3331     bool operator>(const GctSymbol&) const;
3332 
3333     unsigned hash() const;
3334 
3335     // I/O Support
3336     const char *stringify();
3337 
3338     // Consistency
3339     void OK() const;
3340 private:
3341     const char *class_name() const;
3342 };
3343 
3344 extern unsigned hash(GctSymbol&);	// genclass support (no const)
3345 
3346 //
3347 // Inline functions
3348 //
3349 // Note - none of the String operators save for operator const char *()
3350 // are String member functions, instead, they are anonymous functions
3351 // which work by overloading.
3352 //
3353 
3354 
3355 
3356 
3357 
3358 GctSymbol::operator const char *() const
3359 {
3360 
3361 
3362 
3363 
3364 
3365     return String::operator const char *();
3366 }
3367 
3368 bool
3369 GctSymbol::operator==(const GctSymbol& other) const
3370 {
3371 
3372 
3373 
3374 
3375 
3376     return (bool)::operator==(*this, other);
3377 }
3378 
3379 bool
3380 GctSymbol::operator!=(const GctSymbol& other) const
3381 {
3382 
3383 
3384 
3385 
3386 
3387     return (bool)::operator!=(*this, other);
3388 }
3389 
3390 bool
3391 GctSymbol::operator<=(const GctSymbol& other) const
3392 {
3393 
3394 
3395 
3396 
3397 
3398     return (bool)::operator<=(*this, other);
3399 }
3400 
3401 bool
3402 GctSymbol::operator<(const GctSymbol& other) const
3403 {
3404 
3405 
3406 
3407 
3408 
3409     return (bool)::operator<(*this, other);
3410 }
3411 
3412 bool
3413 GctSymbol::operator>=(const GctSymbol& other) const
3414 {
3415 
3416 
3417 
3418 
3419 
3420     return (bool)::operator>=(*this, other);
3421 }
3422 
3423 bool
3424 GctSymbol::operator>(const GctSymbol& other) const
3425 {
3426 
3427 
3428 
3429 
3430 
3431     return (bool)::operator>(*this, other);
3432 }
3433 
3434 
3435 //# 25 "GctSymbol.defs.h" 2
3436 
3437 
3438 // equality operator
3439 
3440 
3441 
3442 
3443 // less-than-or-equal
3444 
3445 
3446 
3447 
3448 // comparison : less-than ->  0
3449 
3450 
3451 
3452 
3453 // hash function
3454 
3455 extern unsigned int hash(GctSymbol&);
3456 
3457 
3458 
3459 // initial capacity for structures requiring one
3460 
3461 
3462 
3463 
3464 
3465 
3466 
3467 //# 27 "GctSymbol.GctSymbol.Map.h" 2
3468 
3469 
3470 class GctSymbolGctSymbolMap
3471 {
3472 protected:
3473   int                   count;
3474   GctSymbol                   def;
3475 
3476 public:
3477                         GctSymbolGctSymbolMap(GctSymbol& dflt);
3478   virtual              ~GctSymbolGctSymbolMap();
3479 
3480   int                   length();                // current number of items
3481   int                   empty();
3482 
3483   virtual int           contains(GctSymbol& key);      // is key mapped?
3484 
3485   virtual void          clear();                 // delete all items
3486 
3487   virtual GctSymbol&          operator [] (GctSymbol& key) = 0; // access contents by key
3488 
3489   virtual void          del(GctSymbol& key) = 0;       // delete entry
3490 
3491   virtual Pix           first() = 0;             // Pix of first item or 0
3492   virtual void          next(Pix& i) = 0;        // advance to next or 0
3493   virtual GctSymbol&          key(Pix i) = 0;          // access key at i
3494   virtual GctSymbol&          contents(Pix i) = 0;     // access contents at i
3495 
3496   virtual int           owns(Pix i);             // is i a valid Pix  ?
3497   virtual Pix           seek(GctSymbol& key);          // Pix of key
3498 
3499   GctSymbol&                  dflt();                  // access default val
3500 
3501   void                  error(const char* msg);
3502   virtual int           OK() = 0;                // rep invariant
3503 };
3504 
3505 
3506 
~GctSymbolGctSymbolMap()3507 inline GctSymbolGctSymbolMap::~GctSymbolGctSymbolMap() {}
3508 
length()3509 inline int GctSymbolGctSymbolMap::length()
3510 {
3511   return count;
3512 }
3513 
empty()3514 inline int GctSymbolGctSymbolMap::empty()
3515 {
3516   return count == 0;
3517 }
3518 
dflt()3519 inline GctSymbol& GctSymbolGctSymbolMap::dflt()
3520 {
3521   return def;
3522 }
3523 
GctSymbolGctSymbolMap(GctSymbol & dflt)3524 inline GctSymbolGctSymbolMap::GctSymbolGctSymbolMap(GctSymbol& dflt) :def(dflt)
3525 {
3526   count = 0;
3527 }
3528 
3529 
3530 
3531 
3532 //# 26 "GctSymbol.GctSymbol.CHMap.h" 2
3533 
3534 
3535 
3536 
3537 
3538 struct GctSymbolGctSymbolCHNode
3539 {
3540   GctSymbolGctSymbolCHNode*      tl;
3541   GctSymbol                hd;
3542   GctSymbol                cont;
3543                      GctSymbolGctSymbolCHNode();
3544                      GctSymbolGctSymbolCHNode(GctSymbol& h, GctSymbol& c, GctSymbolGctSymbolCHNode* t = 0);
3545                      ~GctSymbolGctSymbolCHNode();
3546 };
3547 
3548 
3549 
GctSymbolGctSymbolCHNode()3550 inline GctSymbolGctSymbolCHNode::GctSymbolGctSymbolCHNode() {}
3551 
GctSymbolGctSymbolCHNode(GctSymbol & h,GctSymbol & c,GctSymbolGctSymbolCHNode * t)3552 inline GctSymbolGctSymbolCHNode::GctSymbolGctSymbolCHNode(GctSymbol& h, GctSymbol& c, GctSymbolGctSymbolCHNode* t)
3553      : hd(h), cont(c), tl(t) {}
3554 
~GctSymbolGctSymbolCHNode()3555 inline GctSymbolGctSymbolCHNode::~GctSymbolGctSymbolCHNode() {}
3556 
3557 
3558 
3559 
3560 typedef GctSymbolGctSymbolCHNode* GctSymbolGctSymbolCHNodePtr;
3561 
3562 
3563 
3564 
3565 class GctSymbolGctSymbolCHMap : public GctSymbolGctSymbolMap
3566 {
3567 protected:
3568   GctSymbolGctSymbolCHNode** tab;
3569   unsigned int   size;
3570 
3571 public:
3572                 GctSymbolGctSymbolCHMap(GctSymbol& dflt,unsigned int sz=100 );
3573                 GctSymbolGctSymbolCHMap(GctSymbolGctSymbolCHMap& a);
3574                 ~GctSymbolGctSymbolCHMap();
3575 
3576   GctSymbol&          operator [] (GctSymbol& key);
3577 
3578   void          del(GctSymbol& key);
3579 
3580   Pix           first();
3581   void          next(Pix& i);
3582   GctSymbol&          key(Pix i);
3583   GctSymbol&          contents(Pix i);
3584 
3585   Pix           seek(GctSymbol& key);
3586   int           contains(GctSymbol& key);
3587 
3588   void          clear();
3589   int           OK();
3590 };
3591 
3592 
3593 
~GctSymbolGctSymbolCHMap()3594 inline GctSymbolGctSymbolCHMap::~GctSymbolGctSymbolCHMap()
3595 {
3596   clear();
3597   delete tab;
3598 }
3599 
contains(GctSymbol & key)3600 inline int GctSymbolGctSymbolCHMap::contains(GctSymbol& key)
3601 {
3602   return seek(key) != 0;
3603 }
3604 
key(Pix p)3605 inline GctSymbol& GctSymbolGctSymbolCHMap::key(Pix p)
3606 {
3607   if (p == 0) error("null Pix");
3608   return ((GctSymbolGctSymbolCHNode*)p)->hd;
3609 }
3610 
contents(Pix p)3611 inline GctSymbol& GctSymbolGctSymbolCHMap::contents(Pix p)
3612 {
3613   if (p == 0) error("null Pix");
3614   return ((GctSymbolGctSymbolCHNode*)p)->cont;
3615 }
3616 
3617 
3618 
3619 
3620 //# 22 "GctSymbol.GctSymbol.CHMap.cc" 2
3621 
3622 
3623 // The nodes are linked together serially via a version
3624 // of a trick used in some vtables: odd pointers are
3625 // actually links to the next table entry.
3626 // Not terrible, but not wonderful either
3627 
goodCHptr(GctSymbolGctSymbolCHNode * t)3628 static inline int goodCHptr(GctSymbolGctSymbolCHNode* t)
3629 {
3630   return ((((unsigned)t) & 1) == 0);
3631 }
3632 
index_to_CHptr(int i)3633 static inline GctSymbolGctSymbolCHNode* index_to_CHptr(int i)
3634 {
3635   return (GctSymbolGctSymbolCHNode*)((i << 1) + 1);
3636 }
3637 
CHptr_to_index(GctSymbolGctSymbolCHNode * t)3638 static inline int CHptr_to_index(GctSymbolGctSymbolCHNode* t)
3639 {
3640   return ( ((unsigned) t) >> 1);
3641 }
3642 
GctSymbolGctSymbolCHMap(GctSymbol & dflt,unsigned int sz)3643 GctSymbolGctSymbolCHMap::GctSymbolGctSymbolCHMap(GctSymbol& dflt, unsigned int sz)
3644      :GctSymbolGctSymbolMap(dflt)
3645 {
3646   tab = (GctSymbolGctSymbolCHNode**)(new GctSymbolGctSymbolCHNodePtr[size = sz]);
3647   for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1);
3648   count = 0;
3649 }
3650 
GctSymbolGctSymbolCHMap(GctSymbolGctSymbolCHMap & a)3651 GctSymbolGctSymbolCHMap::GctSymbolGctSymbolCHMap(GctSymbolGctSymbolCHMap& a) :GctSymbolGctSymbolMap(a.def)
3652 {
3653   tab = (GctSymbolGctSymbolCHNode**)(new GctSymbolGctSymbolCHNodePtr[size = a.size]);
3654   for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1);
3655   count = 0;
3656   for (Pix p = a.first(); p; a.next(p)) (*this)[a.key(p)] = a.contents(p); // { dg-bogus "" } type `GctSymbol' is derived from private `String'
3657 }
3658