Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/iostream.c

    r6ba0659 r52f85e0  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb 17 14:19:56 2016
    13 // Update Count     : 76
     12// Last Modified On : Wed Feb 10 15:48:46 2016
     13// Update Count     : 66
    1414//
    1515
     
    111111forall( dtype ostype, dtype retostype | ostream( ostype ) | ostream( retostype ) )
    112112retostype * ?|?( ostype *os, retostype * (*manip)(ostype*) ) {
    113   return manip( os );
     113  return manip(os);
    114114}
    115115
    116116forall( dtype ostype | ostream( ostype ) )
    117117ostype * endl( ostype * os ) {
    118         os | "\n";
    119         flush( os );
    120         return os;
     118  os | "\n";
     119  // flush
     120  return os;
    121121} // endl
    122122
    123 //---------------------------------------
    124 
    125 forall( type elt_type | writeable( elt_type ), type iterator_type | iterator( iterator_type, elt_type ),
     123forall( type elt_type | writeable( elt_type ),
     124                type iterator_type | iterator( iterator_type, elt_type ),
    126125                dtype os_type | ostream( os_type ) )
    127126void write( iterator_type begin, iterator_type end, os_type *os ) {
    128         void print( elt_type i ) { os | i | ' '; }
     127        void print( elt_type i ) {
     128                os | i | ' ';
     129        }
    129130        for_each( begin, end, print );
    130131} // ?|?
    131132
    132 forall( type elt_type | writeable( elt_type ), type iterator_type | iterator( iterator_type, elt_type ),
     133forall( type elt_type | writeable( elt_type ),
     134                type iterator_type | iterator( iterator_type, elt_type ),
    133135                dtype os_type | ostream( os_type ) )
    134136void write_reverse( iterator_type begin, iterator_type end, os_type *os ) {
     
    137139} // ?|?
    138140
    139 //---------------------------------------
    140141
    141142forall( dtype istype | istream( istype ) )
     
    146147forall( dtype istype | istream( istype ) )
    147148istype * ?|?( istype *is, int *ip ) {
    148         return get( is, ip );
     149        char cur;
     150 
     151        // skip some whitespace
     152        do {
     153                is | &cur;
     154                if ( fail( is ) || eof( is ) ) return is;
     155        } while ( !( cur >= '0' && cur <= '9' ) );
     156 
     157        // accumulate digits
     158        *ip = 0;
     159        while ( cur >= '0' && cur <= '9' ) {
     160                *ip = *ip * 10 + ( cur - '0' );
     161                is | &cur;
     162                if ( fail( is ) || eof( is ) ) return is;
     163        }
     164 
     165        unread( is, cur );
     166        return is;
    149167} // ?|?
    150168
Note: See TracChangeset for help on using the changeset viewer.