home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / g / bug / 2344 < prev    next >
Encoding:
Text File  |  1993-01-28  |  22.7 KB  |  1,013 lines

  1. Path: sparky!uunet!stanford.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!mudos.ann-arbor.mi.US!mju
  2. From: mju@mudos.ann-arbor.mi.US (Marc Unangst)
  3. Newsgroups: gnu.g++.bug
  4. Subject: Bug in g++: compiler gets SIGIOT
  5. Date: 26 Jan 1993 21:58:46 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 1000
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-g++@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <m0nGnot-0002nfC@mudos.ann-arbor.mi.us>
  12.  
  13. I believe I've discovered a bug in g++.  Here is the relevant
  14. information:
  15.  
  16. gcc v2.3.3
  17. command-line flags:
  18.     "gcc -g -O -nostdinc++ -I. -I.. -I. -I./../src \
  19.      -I./../g++-include -c iomanip.C"
  20. machine type: Intel 486/33, running ESIX SVR4.0.3
  21. configure options: "configure i386-sysv4"
  22. no compiler modifications
  23. no installation changes
  24. the error is: the compiler prints
  25.     gcc: Internal compiler error: program cc1plus got fatal signal 6
  26. after klunking along for a while.
  27.  
  28. Here is the input file, after being run through cpp.  I have verified
  29. that running gcc with the above flags on this file causes it to get
  30. SIGIOT (signal 6).  Note that this file, before being run through cpp,
  31. is the same as libg++-2.3/libg++/iostream/iomanip.C from the
  32. libg++-2.3 distribution.
  33.  
  34. ---cut here---
  35. # 1 "iomanip.C"
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. # 1 "iomanip.h" 1
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87. # 1 "../_G_config.h" 1
  88.   
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. typedef long _G_clock_t;
  96. typedef unsigned long _G_dev_t;
  97. typedef long _G_fpos_t;
  98. typedef long _G_gid_t;
  99. typedef unsigned long _G_ino_t;
  100. typedef unsigned long _G_mode_t;
  101. typedef unsigned long _G_nlink_t;
  102. typedef long _G_off_t;
  103. typedef long _G_pid_t;
  104. typedef int _G_ptrdiff_t;
  105. typedef int   _G_sigset_t;
  106. typedef unsigned int _G_size_t;
  107. typedef long _G_time_t;
  108. typedef long _G_uid_t;
  109. typedef long int _G_wchar_t;
  110. typedef  int   _G_ssize_t;
  111. typedef char * _G_va_list;
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. # 29 "iomanip.h" 2
  134.  
  135.  
  136.  
  137.  
  138. # 1 "./iostream.h" 1
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158. #pragma interface
  159.  
  160.  
  161.  
  162. # 1 "./streambuf.h" 1
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182. #pragma interface
  183.  
  184.  
  185.    
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. class ostream; class streambuf; class backupbuf;
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212. extern "C" int __underflow(streambuf*);
  213. extern "C" int __overflow(streambuf*, int);
  214.  
  215. typedef _G_off_t streamoff;
  216. typedef _G_off_t streampos;  
  217.  
  218. typedef unsigned long __fmtflags;
  219. typedef unsigned char __iostate;
  220.  
  221. struct _ios_fields {  
  222.     streambuf *_strbuf;
  223.     ostream* _tie;
  224.     int _width;
  225.     __fmtflags _flags;
  226.     _G_wchar_t _fill;
  227.     __iostate _state;
  228.     __iostate _exceptions;
  229.     int _precision;
  230. };
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246. # 95 "./streambuf.h"
  247.  
  248.  
  249. class ios : public _ios_fields {
  250.   public:
  251.     typedef __fmtflags fmtflags;
  252.     typedef int iostate;
  253.     typedef int openmode;
  254.     enum io_state {
  255.     goodbit = 0 ,
  256.     eofbit = 1 ,
  257.     failbit = 2 ,
  258.     badbit = 4  };
  259.     enum open_mode {
  260.     in = 1 ,
  261.     out = 2 ,
  262.     ate = 4 ,
  263.     app = 8 ,
  264.     trunc = 16 ,
  265.     nocreate = 32 ,
  266.     noreplace = 64 ,
  267.     bin = 128  };
  268.     enum seek_dir { beg, cur, end};
  269.      
  270.     enum { skipws=01, left=02, right=04, internal=010,
  271.        dec=020, oct=040, hex=0100,
  272.        showbase=0200, showpoint=0400, uppercase=01000, showpos=02000,
  273.        scientific=04000, fixed=010000, unitbuf=020000, stdio=040000,
  274.        dont_close=0x80000000  
  275.        };
  276.     enum {  
  277.     basefield=dec+oct+hex,
  278.     floatfield = scientific+fixed,
  279.     adjustfield = left+right+internal
  280.     };
  281.  
  282. # 138 "./streambuf.h"
  283.  
  284.  
  285.     ostream* tie() const { return _tie; }
  286.     ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }
  287.  
  288.      
  289.     _G_wchar_t fill() const { return (_G_wchar_t)_fill; }
  290.     _G_wchar_t fill(_G_wchar_t newf)
  291.     {_G_wchar_t oldf = (_G_wchar_t)_fill; _fill = (char)newf; return oldf;}
  292.     fmtflags flags() const { return _flags; }
  293.     fmtflags flags(fmtflags new_val) {
  294.     fmtflags old_val = _flags; _flags = new_val; return old_val; }
  295.     int precision() const { return _precision; }
  296.     int precision(int newp) {
  297.     unsigned short oldp = _precision; _precision = (unsigned short)newp;
  298.     return oldp; }
  299.     fmtflags setf(fmtflags val) {
  300.     fmtflags oldbits = _flags;
  301.     _flags |= val; return oldbits; }
  302.     fmtflags setf(fmtflags val, fmtflags mask) {
  303.     fmtflags oldbits = _flags;
  304.     _flags = (_flags & ~mask) | (val & mask); return oldbits; }
  305.     fmtflags unsetf(fmtflags mask) {
  306.     fmtflags oldbits = _flags & mask;
  307.     _flags &= ~mask; return oldbits; }
  308.     int width() const { return _width; }
  309.     int width(int val) { int save = _width; _width = val; return save; }
  310.  
  311.  
  312.  
  313.  
  314.     void _throw_failure() { }
  315.  
  316.  
  317.     streambuf* rdbuf() const { return _strbuf; }
  318.     void clear(iostate state = 0) {
  319.     _state = _strbuf ? state : state|badbit;
  320.     if (_state & _exceptions) _throw_failure(); }
  321.     void set(iostate flag) { _state |= flag;
  322.     if (_state & _exceptions) _throw_failure(); }
  323.     int good() const { return _state == 0; }
  324.     int eof() const { return _state & ios::eofbit; }
  325.     int fail() const { return _state & (ios::badbit|ios::failbit); }
  326.     int bad() const { return _state & ios::badbit; }
  327.     iostate rdstate() const { return _state; }
  328.     operator void*() const { return fail() ? (void*)0 : (void*)(-1); }
  329.     int operator!() const { return fail(); }
  330.     iostate exception(iostate enable) {
  331.     iostate old = _exceptions; _exceptions = enable;
  332.     if (_state & _exceptions) _throw_failure();
  333.     return old; }
  334.  
  335.     static int sync_with_stdio(int on);
  336.     static void sync_with_stdio() { sync_with_stdio(1); }
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.   protected:
  347.     ios(streambuf* sb = 0, ostream* tie = 0);
  348.     virtual ~ios();
  349.     void init(streambuf* sb) { _state=0; _strbuf=sb; }
  350. };
  351.  
  352.  
  353.  
  354.  
  355. typedef ios::seek_dir _seek_dir;
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385. class streammarker {
  386.     friend class streambuf;
  387.  
  388.  
  389.  
  390.     friend int __underflow(streambuf*);
  391.  
  392.     struct streammarker *_next;   
  393.     streambuf *_sbuf;  
  394.     streampos _spos;  
  395.     void set_streampos(streampos sp) { _spos = sp; }
  396.     void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }
  397.      
  398.      
  399.     int _pos;
  400.   public:
  401.     streammarker(streambuf *sb);
  402.     ~streammarker();
  403.     int saving() { return  _spos == -2; }
  404.     int delta(streammarker&);
  405.     int delta();
  406. };
  407.  
  408. struct __streambuf {
  409.      
  410.     int _flags;         
  411.     char* _gptr;     
  412.     char* _egptr;     
  413.     char* _eback;     
  414.     char* _pbase;     
  415.     char* _pptr;     
  416.     char* _epptr;     
  417.     char* _base;     
  418.     char* _ebuf;     
  419.     struct streambuf *_chain;
  420.  
  421.      
  422.     friend class streammarker;
  423.     char *_other_gbase;  
  424.     char *_aux_limit;   
  425.     char *_other_egptr;  
  426.     streammarker *_markers;
  427.  
  428.  
  429.      
  430.     unsigned short _cur_column;
  431.     char _unused;
  432.     char _shortbuf[1];
  433. };
  434.  
  435. extern unsigned __adjust_column(unsigned start, const char *line, int count);
  436.  
  437. struct streambuf : private __streambuf {
  438.     friend class ios;
  439.     friend class istream;
  440.     friend class ostream;
  441.     friend class streammarker;
  442.  
  443.  
  444.  
  445.     friend int __underflow(streambuf*);
  446.  
  447.   protected:
  448.     static streambuf* _list_all;  
  449.     streambuf*& xchain() { return _chain; }
  450.     void _un_link();
  451.     void _link_in();
  452.     char* gptr() const { return _gptr; }
  453.     char* pptr() const { return _pptr; }
  454.     char* egptr() const { return _egptr; }
  455.     char* epptr() const { return _epptr; }
  456.     char* pbase() const { return _pbase; }
  457.     char* eback() const { return _eback; }
  458.     char* base() const { return _base; }
  459.     char* ebuf() const { return _ebuf; }
  460.     int blen() const { return _ebuf - _base; }
  461.     void xput_char(char c) { *_pptr++ = c; }
  462.     int xflags() { return _flags; }
  463.     int xflags(int f) { int fl = _flags; _flags = f; return fl; }
  464.     void xsetflags(int f) { _flags |= f; }
  465.     void xsetflags(int f, int mask) { _flags = (_flags & ~mask) | (f & mask); }
  466.     void gbump(int n) { _gptr += n; }
  467.     void pbump(int n) { _pptr += n; }
  468.     void setb(char* b, char* eb, int a=0);
  469.     void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; }
  470.     void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; }
  471.     char *shortbuf() { return _shortbuf; }
  472.  
  473.     int in_backup() { return _flags & 0x100 ; }
  474.      
  475.     char *Gbase() { return in_backup() ? _other_gbase : _eback; }
  476.      
  477.     char *eGptr() { return in_backup() ? _other_egptr : _egptr; }
  478.      
  479.     char *Bbase() { return in_backup() ? _eback : _other_gbase; }
  480.     char *Bptr() { return _aux_limit; }
  481.      
  482.     char *eBptr() { return in_backup() ? _egptr : _other_egptr; }
  483.     char *Nbase() { return _other_gbase; }
  484.     char *eNptr() { return _other_egptr; }
  485.     int have_backup() { return _other_gbase != ((void*)0) ; }
  486.     int have_markers() { return _markers != ((void*)0) ; }
  487.     int _least_marker();
  488.     void switch_to_main_get_area();
  489.     void switch_to_backup_area();
  490.     void free_backup_area();
  491.     void unsave_markers();  
  492.     int put_mode() { return _flags & 0x800 ; }
  493.     int switch_to_get_mode();
  494.     
  495.     streambuf(int flags=0);
  496.   public:
  497.     static int flush_all();
  498.     static void flush_all_linebuffered();  
  499.     virtual int underflow() = 0;  
  500.     virtual int overflow(int c = (-1) ) = 0;  
  501.     virtual int doallocate();
  502.     virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
  503.     virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
  504.     int seekmark(streammarker& mark, int delta = 0);
  505.     int sputbackc(char c);
  506.     int sungetc();
  507.     virtual ~streambuf();
  508.     int unbuffered() { return _flags & 2  ? 1 : 0; }
  509.     int linebuffered() { return _flags & 0x200  ? 1 : 0; }
  510.     void unbuffered(int i)
  511.     { if (i) _flags |= 2 ; else _flags &= ~2 ; }
  512.     void linebuffered(int i)
  513.     { if (i) _flags |= 0x200 ; else _flags &= ~0x200 ; }
  514.     int allocate() {  
  515.     if (base() || unbuffered()) return 0;
  516.     else return doallocate(); }
  517.      
  518.     void allocbuf() { if (base() == ((void*)0) ) doallocbuf(); }
  519.     void doallocbuf();
  520.     virtual int sync();
  521.     virtual int pbackfail(int c);
  522.     virtual streambuf* setbuf(char* p, int len);
  523.     int in_avail() { return _egptr - _gptr; }
  524.     int out_waiting() { return _pptr - _pbase; }
  525.     virtual int xsputn(const char* s, int n);
  526.     int sputn(const char* s, int n) { return xsputn(s, n); }
  527.     int padn(char pad, int n);  
  528.     virtual int xsgetn(char* s, int n);
  529.     int sgetn(char* s, int n) { return xsgetn(s, n); }
  530.     int ignore(int);
  531.     virtual int get_column();
  532.     virtual int set_column(int);
  533.     long sgetline(char* buf, _G_size_t n, char delim, int putback_delim);
  534.     int sbumpc() {
  535.     if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
  536.     else return *(unsigned char*)_gptr++; }
  537.     int sgetc() {
  538.     if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
  539.     else return *(unsigned char*)_gptr; }
  540.     int snextc() {
  541.     if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
  542.     return _gptr++, sgetc(); }
  543.     int sputc(int c) {
  544.     if (_pptr >= _epptr) return __overflow(this, (unsigned char)c);
  545.     else return *_pptr++ = c, (unsigned char)c; }
  546.     void stossc() { if (_gptr < _egptr) _gptr++; }
  547.     int vscan(char const *fmt0, _G_va_list ap, ios* stream = ((void*)0) );
  548.     int scan(char const *fmt0 ...);
  549.     int vform(char const *fmt0, _G_va_list ap);
  550.     int form(char const *fmt0 ...);
  551.  
  552.  
  553.  
  554.  
  555. };
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565. class backupbuf : public streambuf {
  566.     friend class streammarker;
  567.   protected:
  568.     backupbuf(int flags=0) : streambuf(flags|0x4000 ) { }
  569.   public:
  570.     virtual int pbackfail(int c);
  571.     virtual int underflow();
  572.     virtual int overflow(int c = (-1) );
  573. };
  574.  
  575. struct __file_fields {
  576.     short _fileno;
  577.     int _blksize;
  578.     _G_fpos_t  _offset;
  579.  
  580. };
  581.  
  582. class filebuf : public backupbuf {
  583.   protected:
  584.     struct __file_fields _fb;
  585.     void init();
  586.   public:
  587.     static const int openprot;  
  588.     filebuf();
  589.     filebuf(int fd);
  590.     filebuf(int fd, char* p, int len);
  591.     ~filebuf();
  592.     filebuf* attach(int fd);
  593.     filebuf* open(const char *filename, const char *mode);
  594.     filebuf* open(const char *filename, ios::openmode mode, int prot = 0664);
  595.     virtual int underflow();
  596.     virtual int overflow(int c = (-1) );
  597.     int is_open() const { return _fb._fileno >= 0; }
  598.     int fd() const { return is_open() ? _fb._fileno : (-1) ; }
  599.     filebuf* close();
  600.     virtual int doallocate();
  601.     virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
  602.     virtual streambuf* setbuf(char* p, int len);
  603.     int xsputn(const char* s, int n);
  604.     int xsgetn(char* s, int n);
  605.     virtual int sync();
  606.   protected:  
  607.  
  608.     int is_reading() { return eback() != egptr(); }
  609.     char* cur_ptr() { return is_reading() ?  gptr() : pptr(); }
  610.      
  611.     char* file_ptr() { return eGptr(); }
  612.     int do_write(const char *data, int to_do);
  613.     int do_flush() { return do_write(_pbase, _pptr-_pbase); }
  614.      
  615.     virtual _G_ssize_t sys_read(char* buf, _G_size_t size);
  616.     virtual _G_fpos_t  sys_seek(_G_fpos_t , _seek_dir);
  617.     virtual _G_ssize_t sys_write(const void*, long);
  618.     virtual int sys_stat(void*);  
  619.     virtual int sys_close();
  620. };
  621.  
  622. inline ios::ios(streambuf* sb  , ostream* tie  ) {
  623.         _state = sb ? ios::goodbit : ios::badbit; _exceptions=0;
  624.         _strbuf=sb; _tie = tie; _width=0; _fill=' ';
  625.         _flags=ios::skipws|ios::dec; _precision=6; }
  626. inline ios::~ios() {
  627.     if (!(_flags & (unsigned int)ios::dont_close)) delete _strbuf; }
  628.  
  629.  
  630. # 24 "./iostream.h" 2
  631.  
  632.  
  633. class istream; class ostream;
  634. typedef ios& (*__manip)(ios&);
  635. typedef istream& (*__imanip)(istream&);
  636. typedef ostream& (*__omanip)(ostream&);
  637.  
  638. extern istream& ws(istream& ins);
  639. extern ostream& flush(ostream& outs);
  640. extern ostream& endl(ostream& outs);
  641. extern ostream& ends(ostream& outs);
  642.  
  643. class ostream : virtual public ios
  644. {
  645.      
  646.     void do_osfx();
  647.   public:
  648.     ostream() { }
  649.     ostream(streambuf* sb, ostream* tied=((void*)0) );
  650.     int opfx() {
  651.     if (!good()) return 0; else { if (_tie) _tie->flush(); return 1;} }
  652.     void osfx() { if (flags() & (ios::unitbuf|ios::stdio))
  653.               do_osfx(); }
  654.     streambuf* ostreambuf() const { return _strbuf; }
  655.     ostream& flush();
  656.     ostream& put(char c) { _strbuf->sputc(c); return *this; }
  657.     ostream& put(unsigned char c) { return put((char)c); }
  658.  
  659.     ostream& write(const char *s, int n);
  660.     ostream& write(const unsigned char *s, int n) { return write((const char*)s, n);}
  661.  
  662.     ostream& put(signed char c) { return put((char)c); }
  663.     ostream& write(const signed char *s, int n) { return write((const char*)s, n);}
  664.  
  665.     ostream& write(const void *s, int n) { return write((const char*)s, n);}
  666.     ostream& seekp(streampos);
  667.     ostream& seekp(streamoff, _seek_dir);
  668.     streampos tellp();
  669.     ostream& form(const char *format ...);
  670.     ostream& vform(const char *format, _G_va_list args);
  671.  
  672.     ostream& operator<<(char c);
  673.     ostream& operator<<(unsigned char c) { return (*this) << (char)c; }
  674.  
  675.     ostream& operator<<(signed char c) { return (*this) << (char)c; }
  676.  
  677.     ostream& operator<<(const char *s);
  678.     ostream& operator<<(const unsigned char *s)
  679.     { return (*this) << (const char*)s; }
  680.  
  681.     ostream& operator<<(const signed char *s)
  682.     { return (*this) << (const char*)s; }
  683.  
  684.     ostream& operator<<(void *p);
  685.     ostream& operator<<(int n);
  686.     ostream& operator<<(unsigned int n);
  687.     ostream& operator<<(long n);
  688.     ostream& operator<<(unsigned long n);
  689.  
  690.     ostream& operator<<(long long n);
  691.     ostream& operator<<(unsigned long long n);
  692.  
  693.     ostream& operator<<(short n) {return operator<<((int)n);}
  694.     ostream& operator<<(unsigned short n) {return operator<<((unsigned int)n);}
  695.     ostream& operator<<(double n);
  696.     ostream& operator<<(float n) { return operator<<((double)n); }
  697.     ostream& operator<<(__omanip func) { return (*func)(*this); }
  698.     ostream& operator<<(__manip func) {(*func)(*this); return *this;}
  699.     ostream& operator<<(streambuf*);
  700. };
  701.  
  702. class istream : virtual public ios
  703. {
  704.      
  705.     _G_ssize_t _gcount;
  706.  
  707.     int _skip_ws();
  708.   public:
  709.     istream() { _gcount = 0; }
  710.     istream(streambuf* sb, ostream*tied=((void*)0) );
  711.     streambuf* istreambuf() const { return _strbuf; }
  712.     istream& get(char* ptr, int len, char delim = '\n');
  713.     istream& get(unsigned char* ptr, int len, char delim = '\n')
  714.     { return get((char*)ptr, len, delim); }
  715.     istream& get(char& c);
  716.     istream& get(unsigned char& c) { return get((char&)c); }
  717.     istream& getline(char* ptr, int len, char delim = '\n');
  718.     istream& getline(unsigned char* ptr, int len, char delim = '\n')
  719.     { return getline((char*)ptr, len, delim); }
  720.  
  721.     istream& get(signed char& c)  { return get((char&)c); }
  722.     istream& get(signed char* ptr, int len, char delim = '\n')
  723.     { return get((char*)ptr, len, delim); }
  724.     istream& getline(signed char* ptr, int len, char delim = '\n')
  725.     { return getline((char*)ptr, len, delim); }
  726.  
  727.     istream& read(char *ptr, int n);
  728.     istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); }
  729.  
  730.     istream& read(signed char *ptr, int n) { return read((char*)ptr, n); }
  731.  
  732.     istream& read(void *ptr, int n) { return read((char*)ptr, n); }
  733.      
  734.     istream& get(streambuf& sb, char delim = '\n');
  735.     istream& gets(char **s, char delim = '\n');
  736.     int ipfx(int need) {
  737.     if (!good()) { set(ios::failbit); return 0; }
  738.     if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
  739.     if (!need && (flags() & ios::skipws)) return _skip_ws();
  740.     return 1;
  741.     }
  742.     int ipfx0() {  
  743.     if (!good()) { set(ios::failbit); return 0; }
  744.     if (_tie) _tie->flush();
  745.     if (flags() & ios::skipws) return _skip_ws();
  746.     return 1;
  747.     }
  748.     int ipfx1() {  
  749.     if (!good()) { set(ios::failbit); return 0; }
  750.     if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
  751.     return 1;
  752.     }
  753.     int get() { if (!ipfx1()) return (-1) ;
  754.         int ch = _strbuf->sbumpc();
  755.         if (ch == (-1) ) set(ios::eofbit);
  756.         return ch; }
  757.     int peek() { if (!ipfx1()) return (-1) ;
  758.         int ch = _strbuf->sgetc();
  759.         if (ch == (-1) ) set(ios::eofbit);
  760.         return ch; }
  761.     _G_ssize_t gcount() { return _gcount; }
  762.     istream& ignore(int n=1, int delim = (-1) );
  763.     istream& seekg(streampos);
  764.     istream& seekg(streamoff, _seek_dir);
  765.     streampos tellg();
  766.     istream& putback(char ch) {
  767.     if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit);
  768.     return *this;}
  769.     istream& unget() {
  770.     if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit);
  771.     return *this;}
  772.     istream& scan(const char *format ...);
  773.     istream& vscan(const char *format, _G_va_list args);
  774.  
  775.  
  776.  
  777.  
  778.  
  779.     istream& operator>>(char*);
  780.     istream& operator>>(unsigned char* p) { return operator>>((char*)p); }
  781.  
  782.     istream& operator>>(signed char*p) { return operator>>((char*)p); }
  783.  
  784.     istream& operator>>(char& c);
  785.     istream& operator>>(unsigned char& c) {return operator>>((char&)c);}
  786.  
  787.     istream& operator>>(signed char& c) {return operator>>((char&)c);}
  788.  
  789.     istream& operator>>(int&);
  790.     istream& operator>>(long&);
  791.  
  792.     istream& operator>>(long long&);
  793.  
  794.     istream& operator>>(short&);
  795.     istream& operator>>(unsigned int&);
  796.     istream& operator>>(unsigned long&);
  797.  
  798.     istream& operator>>(unsigned long long&);
  799.  
  800.     istream& operator>>(unsigned short&);
  801.     istream& operator>>(float&);
  802.     istream& operator>>(double&);
  803.     istream& operator>>( __manip func) {(*func)(*this); return *this;}
  804.     istream& operator>>(__imanip func) { return (*func)(*this); }
  805.     istream& operator>>(streambuf*);
  806. };
  807.  
  808.  
  809. class iostream : public istream, public ostream
  810. {
  811.     _G_ssize_t _gcount;
  812.   public:
  813.     iostream() { _gcount = 0; }
  814.     iostream(streambuf* sb, ostream*tied=((void*)0) );
  815. };
  816.  
  817. extern istream cin;
  818. extern ostream cout, cerr, clog;  
  819.  
  820. struct Iostream_init { } ;   
  821.  
  822. inline ios& dec(ios& i)
  823. { i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; }
  824. inline ios& hex(ios& i)
  825. { i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; }
  826. inline ios& oct(ios& i)
  827. { i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }
  828.  
  829.  
  830. # 33 "iomanip.h" 2
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841. template<class TP> class smanip;  
  842.  
  843. template<class TP> class sapp {
  844.     ios& (*_f)(ios&, TP);
  845. public: 
  846.     sapp(ios& (*f)(ios&, TP)) : _f(f) {}
  847.      
  848.     smanip<TP> operator()(TP a) 
  849.       { return smanip<TP>(_f, a); }
  850. };
  851.  
  852. template <class TP> class smanip {
  853.     ios& (*_f)(ios&, TP);
  854.     TP _a;
  855. public:
  856.     smanip(ios& (*f)(ios&, TP), TP a) : _f(f), _a(a) {}
  857.      
  858.     friend 
  859.       istream& operator>>(istream& i, const smanip<TP>& m);
  860.     friend
  861.       ostream& operator<<(ostream& o, const smanip<TP>& m);
  862. };
  863.  
  864. template<class TP>
  865. inline istream& operator>>(istream& i, const smanip<TP>& m)
  866.     { m._f(i, m._a); return i; }
  867.  
  868. template<class TP>
  869. inline ostream& operator<<(ostream& o, const smanip<TP>& m)
  870.     { m._f(o, m._a); return o;}
  871.  
  872.  
  873.  
  874.  
  875.  
  876. template<class TP> class imanip; 
  877.  
  878. template<class TP> class iapp {
  879.     istream& (*_f)(istream&, TP);
  880. public: 
  881.     iapp(ostream& (*f)(istream&,TP)) : _f(f) {}
  882.      
  883.     imanip<TP> operator()(TP a)
  884.        { return imanip<TP>(_f, a); }
  885. };
  886.  
  887. template <class TP> class imanip {
  888.     istream& (*_f)(istream&, TP);
  889.     TP _a;
  890. public:
  891.     imanip(istream& (*f)(istream&, TP), TP a) : _f(f), _a(a) {}
  892.      
  893.     friend 
  894.       istream& operator>>(istream& i, const imanip<TP>& m)
  895.     { return m._f( i, m._a); }
  896. };
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903. template<class TP> class omanip; 
  904.  
  905. template<class TP> class oapp {
  906.     ostream& (*_f)(ostream&, TP);
  907. public: 
  908.     oapp(ostream& (*f)(ostream&,TP)) : _f(f) {}
  909.      
  910.     omanip<TP> operator()(TP a)
  911.       { return omanip<TP>(_f, a); }
  912. };
  913.  
  914. template <class TP> class omanip {
  915.     ostream& (*_f)(ostream&, TP);
  916.     TP _a;
  917. public:
  918.     omanip(ostream& (*f)(ostream&, TP), TP a) : _f(f), _a(a) {}
  919.      
  920.     friend
  921.       ostream& operator>>(ostream& i, imanip<TP>& m)
  922.     { return (ostream&) m._f( i, m._a); }
  923. };
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939. extern ios& __iomanip_setbase (ios&,  int); inline  smanip< int>  setbase ( int n) { return  smanip< int> (__iomanip_setbase, n); } 
  940. extern ios& __iomanip_setfill (ios&,  int); inline  smanip< int>  setfill ( int n) { return  smanip< int> (__iomanip_setfill, n); } 
  941. extern ios& __iomanip_setprecision (ios&,  int); inline  smanip< int>  setprecision ( int n) { return  smanip< int> (__iomanip_setprecision, n); } 
  942. extern ios& __iomanip_setw (ios&,  int); inline  smanip< int>  setw ( int n) { return  smanip< int> (__iomanip_setw, n); } 
  943.  
  944. extern ios& __iomanip_resetiosflags (ios&,  ios::fmtflags); inline  smanip< ios::fmtflags>  resetiosflags ( ios::fmtflags n) { return  smanip< ios::fmtflags> (__iomanip_resetiosflags, n); } 
  945. extern ios& __iomanip_setiosflags (ios&,  ios::fmtflags); inline  smanip< ios::fmtflags>  setiosflags ( ios::fmtflags n) { return  smanip< ios::fmtflags> (__iomanip_setiosflags, n); } 
  946.  
  947.  
  948.  
  949. # 23 "iomanip.C" 2
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956. ios & __iomanip_setbase (ios& i, int n)
  957. {
  958.     ios::fmtflags b;
  959.     switch (n)
  960.       {
  961.     case  8: 
  962.       b = ios::oct; break;
  963.     case 10: 
  964.       b = ios::dec; break;
  965.     case 16: 
  966.       b = ios::hex; break;
  967.     default:
  968.       b = 0;
  969.       }
  970.     i.setf(b, ios::basefield);
  971.     return i;
  972. }
  973.  
  974. ios & __iomanip_setfill (ios& i, int n)
  975. {
  976.      
  977.       i.fill( (char) n);
  978.      
  979.      
  980.     return i;
  981. }   
  982.  
  983. ios &  __iomanip_setprecision (ios& i, int n)
  984. {
  985.     i.precision(n);
  986.     return i;
  987. }
  988. ios &  __iomanip_setw (ios& i, int n)
  989. {
  990.     i.width(n);
  991.     return i;
  992. }
  993.  
  994. ios & __iomanip_setiosflags (ios& i, ios::fmtflags n)
  995. {
  996.     i.setf(n,n);
  997.     return i;
  998. }
  999.  
  1000. ios & __iomanip_resetiosflags (ios& i, ios::fmtflags n)
  1001. {
  1002.     i.setf(0,n);
  1003.     return i;
  1004. }
  1005. ---cut here---
  1006.  
  1007. -- 
  1008. Marc Unangst, N8VRH         | "Of course, in order to understand this you
  1009. mju@mudos.ann-arbor.mi.us   |  have to remember that the nucleus of the atom
  1010.                             |  is squishy."
  1011.                             |    -W. Scheider, from a Physics lecture
  1012.  
  1013.