Changeset 3b56166 for libcfa/src/iostream.cfa
- Timestamp:
- Feb 10, 2020, 11:17:38 AM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3966d9a, 41efd33
- Parents:
- 807a632 (diff), d231700 (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
-
libcfa/src/iostream.cfa (modified) (39 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/iostream.cfa
r807a632 r3b56166 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 13 08:07:59 201913 // Update Count : 82 112 // Last Modified On : Fri Feb 7 18:48:38 2020 13 // Update Count : 825 14 14 // 15 15 … … 35 35 forall( dtype ostype | ostream( ostype ) ) { 36 36 ostype & ?|?( ostype & os, zero_t ) { 37 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );37 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 38 38 fmt( os, "%d", 0n ); 39 39 return os; … … 44 44 45 45 ostype & ?|?( ostype & os, one_t ) { 46 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );46 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 47 47 fmt( os, "%d", 1n ); 48 48 return os; … … 53 53 54 54 ostype & ?|?( ostype & os, bool b ) { 55 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );55 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 56 56 fmt( os, "%s", b ? "true" : "false" ); 57 57 return os; … … 63 63 ostype & ?|?( ostype & os, char c ) { 64 64 fmt( os, "%c", c ); 65 if ( c == '\n' ) setNL( os, true );65 if ( c == '\n' ) $setNL( os, true ); 66 66 return sepOff( os ); 67 67 } // ?|? … … 71 71 72 72 ostype & ?|?( ostype & os, signed char sc ) { 73 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );73 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 74 74 fmt( os, "%hhd", sc ); 75 75 return os; … … 80 80 81 81 ostype & ?|?( ostype & os, unsigned char usc ) { 82 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );82 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 83 83 fmt( os, "%hhu", usc ); 84 84 return os; … … 89 89 90 90 ostype & ?|?( ostype & os, short int si ) { 91 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );91 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 92 92 fmt( os, "%hd", si ); 93 93 return os; … … 98 98 99 99 ostype & ?|?( ostype & os, unsigned short int usi ) { 100 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );100 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 101 101 fmt( os, "%hu", usi ); 102 102 return os; … … 107 107 108 108 ostype & ?|?( ostype & os, int i ) { 109 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );109 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 110 110 fmt( os, "%d", i ); 111 111 return os; … … 116 116 117 117 ostype & ?|?( ostype & os, unsigned int ui ) { 118 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );118 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 119 119 fmt( os, "%u", ui ); 120 120 return os; … … 125 125 126 126 ostype & ?|?( ostype & os, long int li ) { 127 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );127 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 128 128 fmt( os, "%ld", li ); 129 129 return os; … … 134 134 135 135 ostype & ?|?( ostype & os, unsigned long int uli ) { 136 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );136 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 137 137 fmt( os, "%lu", uli ); 138 138 return os; … … 143 143 144 144 ostype & ?|?( ostype & os, long long int lli ) { 145 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );145 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 146 146 fmt( os, "%lld", lli ); 147 147 return os; … … 152 152 153 153 ostype & ?|?( ostype & os, unsigned long long int ulli ) { 154 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );154 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 155 155 fmt( os, "%llu", ulli ); 156 156 return os; … … 175 175 176 176 ostype & ?|?( ostype & os, float f ) { 177 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );177 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 178 178 PrintWithDP( os, "%g", f ); 179 179 return os; … … 184 184 185 185 ostype & ?|?( ostype & os, double d ) { 186 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );186 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 187 187 PrintWithDP( os, "%.*lg", d, DBL_DIG ); 188 188 return os; … … 193 193 194 194 ostype & ?|?( ostype & os, long double ld ) { 195 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );195 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 196 196 PrintWithDP( os, "%.*Lg", ld, LDBL_DIG ); 197 197 return os; … … 202 202 203 203 ostype & ?|?( ostype & os, float _Complex fc ) { 204 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );204 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 205 205 // os | crealf( fc ) | nonl; 206 206 PrintWithDP( os, "%g", crealf( fc ) ); … … 214 214 215 215 ostype & ?|?( ostype & os, double _Complex dc ) { 216 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );216 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 217 217 // os | creal( dc ) | nonl; 218 218 PrintWithDP( os, "%.*lg", creal( dc ), DBL_DIG ); … … 226 226 227 227 ostype & ?|?( ostype & os, long double _Complex ldc ) { 228 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );228 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 229 229 // os | creall( ldc ) || nonl; 230 230 PrintWithDP( os, "%.*Lg", creall( ldc ), LDBL_DIG ); … … 237 237 } // ?|? 238 238 239 ostype & ?|?( ostype & os, const char * str) {239 ostype & ?|?( ostype & os, const char str[] ) { 240 240 enum { Open = 1, Close, OpenClose }; 241 241 static const unsigned char mask[256] @= { … … 257 257 // first character IS NOT spacing or closing punctuation => add left separator 258 258 unsigned char ch = str[0]; // must make unsigned 259 if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {260 fmt( os, "%s", sepGetCur( os ) );259 if ( $sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) { 260 fmt( os, "%s", $sepGetCur( os ) ); 261 261 } // if 262 262 263 263 // if string starts line, must reset to determine open state because separator is off 264 sepReset( os );// reset separator264 $sepReset( os ); // reset separator 265 265 266 266 // last character IS spacing or opening punctuation => turn off separator for next item 267 267 size_t len = strlen( str ); 268 268 ch = str[len - 1]; // must make unsigned 269 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {269 if ( $sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 270 270 sepOn( os ); 271 271 } else { 272 272 sepOff( os ); 273 273 } // if 274 if ( ch == '\n' ) setNL( os, true ); // check *AFTER*sepPrt call above as it resets NL flag274 if ( ch == '\n' ) $setNL( os, true ); // check *AFTER* $sepPrt call above as it resets NL flag 275 275 return write( os, str, len ); 276 276 } // ?|? 277 void ?|?( ostype & os, const char * str ) { 277 278 void ?|?( ostype & os, const char str[] ) { 278 279 (ostype &)(os | str); ends( os ); 279 280 } // ?|? 280 281 281 282 // ostype & ?|?( ostype & os, const char16_t * str ) { 282 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );283 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 283 284 // fmt( os, "%ls", str ); 284 285 // return os; … … 287 288 // #if ! ( __ARM_ARCH_ISA_ARM == 1 && __ARM_32BIT_STATE == 1 ) // char32_t == wchar_t => ambiguous 288 289 // ostype & ?|?( ostype & os, const char32_t * str ) { 289 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );290 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 290 291 // fmt( os, "%ls", str ); 291 292 // return os; … … 294 295 295 296 // ostype & ?|?( ostype & os, const wchar_t * str ) { 296 // if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );297 // if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 297 298 // fmt( os, "%ls", str ); 298 299 // return os; … … 300 301 301 302 ostype & ?|?( ostype & os, const void * p ) { 302 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );303 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 303 304 fmt( os, "%p", p ); 304 305 return os; … … 315 316 void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) { 316 317 (ostype &)(manip( os )); 317 if ( getPrt( os ) ) ends( os );// something printed ?318 setPrt( os, false ); // turn off318 if ( $getPrt( os ) ) ends( os ); // something printed ? 319 $setPrt( os, false ); // turn off 319 320 } // ?|? 320 321 … … 329 330 ostype & nl( ostype & os ) { 330 331 (ostype &)(os | '\n'); 331 setPrt( os, false ); // turn off332 setNL( os, true );332 $setPrt( os, false ); // turn off 333 $setNL( os, true ); 333 334 flush( os ); 334 335 return sepOff( os ); // prepare for next line … … 336 337 337 338 ostype & nonl( ostype & os ) { 338 setPrt( os, false ); // turn off339 $setPrt( os, false ); // turn off 339 340 return os; 340 341 } // nonl … … 375 376 ostype & ?|?( ostype & os, T arg, Params rest ) { 376 377 (ostype &)(os | arg); // print first argument 377 sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator378 $sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 378 379 (ostype &)(os | rest); // print remaining arguments 379 sepSetCur( os, sepGet( os ) ); // switch to regular separator380 $sepSetCur( os, sepGet( os ) ); // switch to regular separator 380 381 return os; 381 382 } // ?|? … … 383 384 // (ostype &)(?|?( os, arg, rest )); ends( os ); 384 385 (ostype &)(os | arg); // print first argument 385 sepSetCur( os, sepGetTuple( os ) );// switch to tuple separator386 $sepSetCur( os, sepGetTuple( os ) ); // switch to tuple separator 386 387 (ostype &)(os | rest); // print remaining arguments 387 sepSetCur( os, sepGet( os ) ); // switch to regular separator388 $sepSetCur( os, sepGet( os ) ); // switch to regular separator 388 389 ends( os ); 389 390 } // ?|? … … 414 415 forall( dtype ostype | ostream( ostype ) ) { \ 415 416 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 416 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) ); \417 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 417 418 \ 418 419 if ( f.base == 'b' || f.base == 'B' ) { /* bespoke binary format */ \ … … 513 514 forall( dtype ostype | ostream( ostype ) ) { \ 514 515 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 515 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) ); \516 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 516 517 char fmtstr[sizeof(DFMTP)]; /* sizeof includes '\0' */ \ 517 518 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ … … 536 537 return os; \ 537 538 } /* ?|? */ \ 539 \ 538 540 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \ 539 541 } // distribution … … 555 557 } // if 556 558 557 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );559 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 558 560 559 561 #define CFMTNP "% * " … … 571 573 return os; 572 574 } // ?|? 575 573 576 void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); } 574 577 } // distribution … … 592 595 } // if 593 596 594 if ( sepPrt( os ) ) fmt( os, "%s",sepGetCur( os ) );597 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); 595 598 596 599 #define SFMTNP "% * " … … 616 619 return os; 617 620 } // ?|? 621 618 622 void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); } 619 623 } // distribution … … 735 739 } // ?|? 736 740 737 // istype & ?|?( istype & is, const char * fmt) {741 // istype & ?|?( istype & is, const char fmt[] ) { 738 742 // fmt( is, fmt, "" ); 739 743 // return is;
Note:
See TracChangeset
for help on using the changeset viewer.