Annotation of researchv10no/cmd/cfront/libC/oiostream/manip.c, revision 1.1

1.1     ! root        1: /*ident        "@(#)ctrans:lib/stream/manip.c  1.1.3.1" */
        !             2: /**************************************************************************
        !             3:                         Copyright (c) 1984 AT&T
        !             4:                           All Rights Reserved   
        !             5: 
        !             6:         THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
        !             7:       
        !             8:         The copyright notice above does not evidence any        
        !             9:         actual or intended publication of such source code.
        !            10: 
        !            11: manip.c:
        !            12: 
        !            13: *****************************************************************************/
        !            14: 
        !            15: #include <iostream.h>
        !            16: #include <iomanip.h>
        !            17: #include <ctype.h>
        !            18: 
        !            19: istream& ws(istream& i)
        !            20: {
        !            21:        if ( !i.ipfx(1) ) return i ;
        !            22:        register streambuf *nbp = i.rdbuf();
        !            23:        register int c = nbp->sgetc();
        !            24:        while (isspace(c)) c = nbp->snextc();
        !            25:        if (c == EOF) i.clear(ios::eofbit) ;
        !            26:        return i ;
        !            27: }
        !            28: 
        !            29: ostream& ends(ostream& i) 
        !            30: {
        !            31:        return i.put(0) ;
        !            32: }
        !            33: 
        !            34: ostream& endl(ostream& i) 
        !            35: {
        !            36:        i.put('\n') ;
        !            37:        i.flush() ;
        !            38:        return i ;
        !            39: }
        !            40: 
        !            41: static const int basebits = ios::dec|ios::oct|ios::hex ;
        !            42: 
        !            43: static ios& setb(ios& i, int b)
        !            44: {
        !            45:        switch(b) {
        !            46:                case 10 : i.setf(ios::dec,basebits) ; break ;
        !            47:                case 8 : i.setf(ios::oct,basebits) ; break ;
        !            48:                case 16 : i.setf(ios::hex,basebits) ; break ;
        !            49:                default : i.setf(0,basebits) ; break ;
        !            50:                }
        !            51:        return i ;
        !            52:        }
        !            53: 
        !            54: SMANIP(int) setbase(int b) { return SMANIP(int)(setb,b) ; }
        !            55: 
        !            56: static ios& resetiosflags(ios& i,long b) { i.setf(0,b) ; return i ; }
        !            57: SMANIP(long) resetiosflags(long b) { return SMANIP(long)(resetiosflags,b) ; }
        !            58: 
        !            59: static ios& setiosflags(ios& i,long b) { i.setf(b) ; return i ; }
        !            60: SMANIP(long) setiosflags(long b) { return SMANIP(long)(setiosflags,b) ; }
        !            61: 
        !            62: static ios& setfill(ios& i,int f) { i.fill(f) ; return i ; }
        !            63: SMANIP(int) setfill(int f) { return SMANIP(int)(setfill,f) ; }
        !            64: 
        !            65: static ios& setprecision(ios& i,int p) { i.precision(p) ; return i ; }
        !            66: SMANIP(int) setprecision(int p) { return SMANIP(int)(setprecision,p) ; }
        !            67: 
        !            68: static ios& setw(ios& i,int w) { i.width(w) ; return i ; }
        !            69: SMANIP(int) setw(int w) { return SMANIP(int)(setw,w) ; }
        !            70: 
        !            71: ios& hex(ios& s) { s.setf(ios::hex,basebits ) ; return s ; }
        !            72: ios& dec(ios& s) { s.setf(ios::dec,basebits ) ; return s ; }
        !            73: ios& oct(ios& s) { s.setf(ios::oct,basebits ) ; return s ; }
        !            74: 
        !            75: ostream& flush(ostream& s) { s.flush() ; return s ; }
        !            76: 
        !            77: ostream& ostream::operator<<( ios& (*f)(ios&) )
        !            78: {
        !            79:        f(*this) ;
        !            80:        return *this ;
        !            81:        }
        !            82: 
        !            83: istream& istream::operator>>( ios& (*f)(ios&) )
        !            84: {
        !            85:        f(*this) ;
        !            86:        return *this ;
        !            87:        }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.