Changes in src/libcfa/iostream.c [6ba0659:5721a6d]
- File:
-
- 1 edited
-
src/libcfa/iostream.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/iostream.c
r6ba0659 r5721a6d 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 17 14:19:56201613 // Update Count : 7612 // Last Modified On : Mon Feb 1 14:20:30 2016 13 // Update Count : 60 14 14 // 15 15 … … 19 19 #include <stdio.h> 20 20 #include <string.h> // strlen 21 #include <float.h> // DBL_DIG, LDBL_DIG22 21 #include <complex.h> // creal, cimag 23 22 } … … 73 72 ostype * ?|?( ostype *os, double d ) { 74 73 char buffer[32]; 75 return write( os, buffer, sprintf( buffer, "% .*lg", DBL_DIG, d ) );74 return write( os, buffer, sprintf( buffer, "%g", d ) ); 76 75 } // ?|? 77 76 … … 79 78 ostype * ?|?( ostype *os, long double d ) { 80 79 char buffer[32]; 81 return write( os, buffer, sprintf( buffer, "% .*Lg", LDBL_DIG, d ) );80 return write( os, buffer, sprintf( buffer, "%Lg", d ) ); 82 81 } // ?|? 83 82 … … 111 110 forall( dtype ostype, dtype retostype | ostream( ostype ) | ostream( retostype ) ) 112 111 retostype * ?|?( ostype *os, retostype * (*manip)(ostype*) ) { 113 return manip( os);112 return manip(os); 114 113 } 115 114 116 115 forall( dtype ostype | ostream( ostype ) ) 117 116 ostype * endl( ostype * os ) { 118 os | "\n";119 flush( os ); 120 return os;117 os | "\n"; 118 // flush 119 return os; 121 120 } // endl 122 121 123 //--------------------------------------- 124 125 forall( type elt_type | writeable( elt_type ), type iterator_type | iterator( iterator_type, elt_type ), 122 forall( type elt_type | writeable( elt_type ), 123 type iterator_type | iterator( iterator_type, elt_type ), 126 124 dtype os_type | ostream( os_type ) ) 127 125 void write( iterator_type begin, iterator_type end, os_type *os ) { 128 void print( elt_type i ) { os | i | ' '; } 126 void print( elt_type i ) { 127 os | i | ' '; 128 } 129 129 for_each( begin, end, print ); 130 130 } // ?|? 131 131 132 forall( type elt_type | writeable( elt_type ), type iterator_type | iterator( iterator_type, elt_type ), 132 forall( type elt_type | writeable( elt_type ), 133 type iterator_type | iterator( iterator_type, elt_type ), 133 134 dtype os_type | ostream( os_type ) ) 134 135 void write_reverse( iterator_type begin, iterator_type end, os_type *os ) { … … 137 138 } // ?|? 138 139 139 //---------------------------------------140 140 141 141 forall( dtype istype | istream( istype ) ) … … 146 146 forall( dtype istype | istream( istype ) ) 147 147 istype * ?|?( istype *is, int *ip ) { 148 return get( is, ip ); 148 char cur; 149 150 // skip some whitespace 151 do { 152 is | &cur; 153 if ( fail( is ) || eof( is ) ) return is; 154 } while ( !( cur >= '0' && cur <= '9' ) ); 155 156 // accumulate digits 157 *ip = 0; 158 while ( cur >= '0' && cur <= '9' ) { 159 *ip = *ip * 10 + ( cur - '0' ); 160 is | &cur; 161 if ( fail( is ) || eof( is ) ) return is; 162 } 163 164 unread( is, cur ); 165 return is; 149 166 } // ?|? 150 167
Note:
See TracChangeset
for help on using the changeset viewer.