Changeset c41c2dbe for libcfa/src/iostream.cfa
- Timestamp:
- Apr 21, 2021, 12:42:23 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 1d5deea
- Parents:
- 341aa39 (diff), e638266 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
r341aa39 rc41c2dbe 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Apr 13 13:05:24202113 // Update Count : 132 412 // Last Modified On : Tue Apr 20 19:09:41 2021 13 // Update Count : 1325 14 14 // 15 15 … … 38 38 forall( ostype & | ostream( ostype ) ) { 39 39 ostype & ?|?( ostype & os, bool b ) { 40 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );40 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 41 41 fmt( os, "%s", b ? "true" : "false" ); 42 42 return os; … … 48 48 ostype & ?|?( ostype & os, char c ) { 49 49 fmt( os, "%c", c ); 50 if ( c == '\n' ) $setNL( os, true );50 if ( c == '\n' ) setNL$( os, true ); 51 51 return sepOff( os ); 52 52 } // ?|? … … 56 56 57 57 ostype & ?|?( ostype & os, signed char sc ) { 58 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );58 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 59 59 fmt( os, "%hhd", sc ); 60 60 return os; … … 65 65 66 66 ostype & ?|?( ostype & os, unsigned char usc ) { 67 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );67 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 68 68 fmt( os, "%hhu", usc ); 69 69 return os; … … 74 74 75 75 ostype & ?|?( ostype & os, short int si ) { 76 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );76 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 77 77 fmt( os, "%hd", si ); 78 78 return os; … … 83 83 84 84 ostype & ?|?( ostype & os, unsigned short int usi ) { 85 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );85 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 86 86 fmt( os, "%hu", usi ); 87 87 return os; … … 92 92 93 93 ostype & ?|?( ostype & os, int i ) { 94 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );94 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 95 95 fmt( os, "%d", i ); 96 96 return os; … … 101 101 102 102 ostype & ?|?( ostype & os, unsigned int ui ) { 103 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );103 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 104 104 fmt( os, "%u", ui ); 105 105 return os; … … 110 110 111 111 ostype & ?|?( ostype & os, long int li ) { 112 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );112 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 113 113 fmt( os, "%ld", li ); 114 114 return os; … … 119 119 120 120 ostype & ?|?( ostype & os, unsigned long int uli ) { 121 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );121 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 122 122 fmt( os, "%lu", uli ); 123 123 return os; … … 128 128 129 129 ostype & ?|?( ostype & os, long long int lli ) { 130 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );130 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 131 131 fmt( os, "%lld", lli ); 132 132 return os; … … 137 137 138 138 ostype & ?|?( ostype & os, unsigned long long int ulli ) { 139 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );139 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 140 140 fmt( os, "%llu", ulli ); 141 141 return os; … … 171 171 172 172 ostype & ?|?( ostype & os, int128 llli ) { 173 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );173 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 174 174 base10_128( os, llli ); 175 175 return os; … … 180 180 181 181 ostype & ?|?( ostype & os, unsigned int128 ullli ) { 182 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );182 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 183 183 base10_128( os, ullli ); 184 184 return os; … … 204 204 205 205 ostype & ?|?( ostype & os, float f ) { 206 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );206 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 207 207 PrintWithDP( os, "%g", f ); 208 208 return os; … … 213 213 214 214 ostype & ?|?( ostype & os, double d ) { 215 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );215 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 216 216 PrintWithDP( os, "%.*lg", d, DBL_DIG ); 217 217 return os; … … 222 222 223 223 ostype & ?|?( ostype & os, long double ld ) { 224 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );224 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 225 225 PrintWithDP( os, "%.*Lg", ld, LDBL_DIG ); 226 226 return os; … … 231 231 232 232 ostype & ?|?( ostype & os, float _Complex fc ) { 233 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );233 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 234 234 // os | crealf( fc ) | nonl; 235 235 PrintWithDP( os, "%g", crealf( fc ) ); … … 243 243 244 244 ostype & ?|?( ostype & os, double _Complex dc ) { 245 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );245 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 246 246 // os | creal( dc ) | nonl; 247 247 PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG ); … … 255 255 256 256 ostype & ?|?( ostype & os, long double _Complex ldc ) { 257 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );257 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 258 258 // os | creall( ldc ) || nonl; 259 259 PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG ); … … 286 286 // first character IS NOT spacing or closing punctuation => add left separator 287 287 unsigned char ch = s[0]; // must make unsigned 288 if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {289 fmt( os, "%s", $sepGetCur( os ) );288 if ( sepPrt$( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) { 289 fmt( os, "%s", sepGetCur$( os ) ); 290 290 } // if 291 291 292 292 // if string starts line, must reset to determine open state because separator is off 293 $sepReset( os ); // reset separator293 sepReset$( os ); // reset separator 294 294 295 295 // last character IS spacing or opening punctuation => turn off separator for next item 296 296 size_t len = strlen( s ); 297 297 ch = s[len - 1]; // must make unsigned 298 if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {298 if ( sepPrt$( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 299 299 sepOn( os ); 300 300 } else { 301 301 sepOff( os ); 302 302 } // if 303 if ( ch == '\n' ) $setNL( os, true ); // check *AFTER* $sepPrtcall above as it resets NL flag303 if ( ch == '\n' ) setNL$( os, true ); // check *AFTER* sepPrt$ call above as it resets NL flag 304 304 return write( os, s, len ); 305 305 } // ?|? … … 309 309 310 310 // ostype & ?|?( ostype & os, const char16_t * s ) { 311 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );311 // if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 312 312 // fmt( os, "%ls", s ); 313 313 // return os; … … 316 316 // #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 317 317 // ostype & ?|?( ostype & os, const char32_t * s ) { 318 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );318 // if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 319 319 // fmt( os, "%ls", s ); 320 320 // return os; … … 323 323 324 324 // ostype & ?|?( ostype & os, const wchar_t * s ) { 325 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );325 // if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 326 326 // fmt( os, "%ls", s ); 327 327 // return os; … … 329 329 330 330 ostype & ?|?( ostype & os, const void * p ) { 331 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );331 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 332 332 fmt( os, "%p", p ); 333 333 return os; … … 343 343 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 344 344 manip( os ); 345 if ( $getPrt( os ) ) ends( os ); // something printed ?346 $setPrt( os, false ); // turn off345 if ( getPrt$( os ) ) ends( os ); // something printed ? 346 setPrt$( os, false ); // turn off 347 347 } // ?|? 348 348 … … 357 357 ostype & nl( ostype & os ) { 358 358 (ostype &)(os | '\n'); 359 $setPrt( os, false ); // turn off360 $setNL( os, true );359 setPrt$( os, false ); // turn off 360 setNL$( os, true ); 361 361 flush( os ); 362 362 return sepOff( os ); // prepare for next line … … 364 364 365 365 ostype & nonl( ostype & os ) { 366 $setPrt( os, false ); // turn off366 setPrt$( os, false ); // turn off 367 367 return os; 368 368 } // nonl … … 408 408 ostype & ?|?( ostype & os, T arg, Params rest ) { 409 409 (ostype &)(os | arg); // print first argument 410 $sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator410 sepSetCur$( os, sepGetTuple( os ) ); // switch to tuple separator 411 411 (ostype &)(os | rest); // print remaining arguments 412 $sepSetCur( os, sepGet( os ) ); // switch to regular separator412 sepSetCur$( os, sepGet( os ) ); // switch to regular separator 413 413 return os; 414 414 } // ?|? … … 416 416 // (ostype &)(?|?( os, arg, rest )); ends( os ); 417 417 (ostype &)(os | arg); // print first argument 418 $sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator418 sepSetCur$( os, sepGetTuple( os ) ); // switch to tuple separator 419 419 (ostype &)(os | rest); // print remaining arguments 420 $sepSetCur( os, sepGet( os ) ); // switch to regular separator420 sepSetCur$( os, sepGet( os ) ); // switch to regular separator 421 421 ends( os ); 422 422 } // ?|? … … 447 447 forall( ostype & | ostream( ostype ) ) { \ 448 448 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 449 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \449 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); \ 450 450 \ 451 451 if ( f.base == 'b' || f.base == 'B' ) { /* bespoke binary format */ \ … … 691 691 int bufbeg = 0, i, len; \ 692 692 \ 693 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \693 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); \ 694 694 char fmtstr[sizeof(DFMTP) + 8]; /* sizeof includes '\0' */ \ 695 695 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ … … 734 734 } // if 735 735 736 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );736 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 737 737 738 738 #define CFMTNP "% * " … … 772 772 } // if 773 773 774 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) );774 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 775 775 776 776 #define SFMTNP "% * "
Note: See TracChangeset
for help on using the changeset viewer.