Changes in src/libcfa/iostream.c [53a6c2a:86f384b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/iostream.c
r53a6c2a r86f384b 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 6 18:14:17201713 // Update Count : 3 9612 // Last Modified On : Sun Jul 2 08:54:02 2017 13 // Update Count : 375 14 14 // 15 15 … … 18 18 extern "C" { 19 19 #include <stdio.h> 20 #include <stdbool.h> // true/false21 20 #include <string.h> // strlen 22 21 #include <float.h> // DBL_DIG, LDBL_DIG … … 25 24 26 25 forall( dtype ostype | ostream( ostype ) ) 27 ostype * ?|?( ostype * os, char ch ) { 28 fmt( os, "%c", ch ); 29 if ( ch == '\n' ) setNL( os, true ); 26 ostype * ?|?( ostype * os, char c ) { 27 fmt( os, "%c", c ); 30 28 sepOff( os ); 31 29 return os; … … 182 180 183 181 // last character IS spacing or opening punctuation => turn off separator for next item 184 size_t len = strlen( cp );185 ch = cp[ len - 1];// must make unsigned182 unsigned int len = strlen( cp ), posn = len - 1; 183 ch = cp[posn]; // must make unsigned 186 184 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 187 185 sepOn( os ); … … 189 187 sepOff( os ); 190 188 } // if 191 if ( ch == '\n' ) setNL( os, true ); // check *AFTER* sepPrt call above as it resets NL flag192 189 return write( os, cp, len ); 193 190 } // ?|? … … 219 216 220 217 forall( dtype ostype | ostream( ostype ) ) 221 ostype * sep( ostype * os ) {222 os | sepGet( os );223 return os;224 } // sep225 226 forall( dtype ostype | ostream( ostype ) )227 ostype * sepTuple( ostype * os ) {228 os | sepGetTuple( os );229 return os;230 } // sepTuple231 232 forall( dtype ostype | ostream( ostype ) )233 218 ostype * endl( ostype * os ) { 219 if ( lastSepOn( os ) ) fmt( os, "%s", sepGetCur( os ) ); 234 220 os | '\n'; 235 setNL( os, true );236 221 flush( os ); 237 222 sepOff( os ); // prepare for next line
Note:
See TracChangeset
for help on using the changeset viewer.