Changes in / [4783ff6:5b2b42e]
- Location:
- libcfa/src
- Files:
-
- 3 edited
-
fstream.hfa (modified) (3 diffs)
-
iostream.cfa (modified) (4 diffs)
-
iostream.hfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/fstream.hfa
r4783ff6 r5b2b42e 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 17 08:29:23202013 // Update Count : 17 512 // Last Modified On : Fri Feb 7 19:00:51 2020 13 // Update Count : 174 14 14 // 15 15 … … 67 67 void close( ofstream & ); 68 68 ofstream & write( ofstream &, const char data[], size_t size ); 69 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));69 int fmt( ofstream &, const char format[], ... ); 70 70 71 71 void ?{}( ofstream & os ); … … 97 97 ifstream & read( ifstream & is, char * data, size_t size ); 98 98 ifstream & ungetc( ifstream & is, char c ); 99 int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));99 int fmt( ifstream &, const char format[], ... ); 100 100 101 101 void ?{}( ifstream & is ); -
libcfa/src/iostream.cfa
r4783ff6 r5b2b42e 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 20 15:30:58 202013 // Update Count : 82 712 // Last Modified On : Fri Feb 7 18:48:38 2020 13 // Update Count : 825 14 14 // 15 15 … … 159 159 (ostype &)(os | ulli); ends( os ); 160 160 } // ?|? 161 162 #if defined( __SIZEOF_INT128__ )163 // UINT64_MAX 18_446_744_073_709_551_615_ULL164 #define P10_UINT64 10_000_000_000_000_000_000_ULL // 19 zeroes165 166 static void base10_128( ostype & os, unsigned int128 val ) {167 if ( val > UINT64_MAX ) {168 base10_128( os, val / P10_UINT64 ); // recursive169 fmt( os, "%.19lu", (uint64_t)(val % P10_UINT64) );170 } else {171 fmt( os, "%lu", (uint64_t)val );172 } // if173 } // base10_128174 175 static void base10_128( ostype & os, int128 val ) {176 if ( val < 0 ) {177 fmt( os, "-" ); // leading negative sign178 val = -val;179 } // if180 base10_128( os, (unsigned int128)val ); // print zero/positive value181 } // base10_128182 183 ostype & ?|?( ostype & os, int128 llli ) {184 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );185 base10_128( os, llli );186 return os;187 } // ?|?188 void & ?|?( ostype & os, int128 llli ) {189 (ostype &)(os | llli); ends( os );190 } // ?|?191 192 ostype & ?|?( ostype & os, unsigned int128 ullli ) {193 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );194 base10_128( os, ullli );195 return os;196 } // ?|?197 void & ?|?( ostype & os, unsigned int128 ullli ) {198 (ostype &)(os | ullli); ends( os );199 } // ?|?200 #endif // __SIZEOF_INT128__201 161 202 162 #define PrintWithDP( os, format, val, ... ) \ … … 504 464 \ 505 465 if ( ! f.flags.pc ) { /* no precision */ \ 466 /* printf( "%s\n", &fmtstr[star] ); */ \ 506 467 fmtstr[sizeof(IFMTNP)-2] = f.base; /* sizeof includes '\0' */ \ 507 /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE ); */ \508 468 fmt( os, &fmtstr[star], f.wd, f.val ); \ 509 469 } else { /* precision */ \ 510 470 fmtstr[sizeof(IFMTP)-2] = f.base; /* sizeof includes '\0' */ \ 511 /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE); */ \471 /* printf( "%s\n", &fmtstr[star] ); */ \ 512 472 fmt( os, &fmtstr[star], f.wd, f.pc, f.val ); \ 513 473 } /* if */ \ … … 527 487 IntegralFMTImpl( signed long long int, 'd', "% *ll ", "% *.*ll " ) 528 488 IntegralFMTImpl( unsigned long long int, 'u', "% *ll ", "% *.*ll " ) 529 530 531 #if defined( __SIZEOF_INT128__ )532 // Default prefix for non-decimal prints is 0b, 0, 0x.533 #define IntegralFMTImpl128( T, SIGNED, CODE, IFMTNP, IFMTP ) \534 forall( dtype ostype | ostream( ostype ) ) \535 static void base10_128( ostype & os, _Ostream_Manip(T) fmt ) { \536 if ( fmt.val > UINT64_MAX ) { \537 fmt.val /= P10_UINT64; \538 base10_128( os, fmt ); /* recursive */ \539 _Ostream_Manip(unsigned long long int) fmt2 @= { (uint64_t)(fmt.val % P10_UINT64), 0, 19, 'u', { .all : 0 } }; \540 fmt2.flags.nobsdp = true; \541 printf( "fmt2 %c %lld %d\n", fmt2.base, fmt2.val, fmt2.all ); \542 sepOff( os ); \543 (ostype &)(os | fmt2); \544 } else { \545 printf( "fmt %c %lld %d\n", fmt.base, fmt.val, fmt.all ); \546 (ostype &)(os | fmt); \547 } /* if */ \548 } /* base10_128 */ \549 forall( dtype ostype | ostream( ostype ) ) { \550 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \551 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); \552 \553 if ( f.base == 'b' | f.base == 'o' | f.base == 'x' | f.base == 'X' ) { \554 unsigned long long int msig = (unsigned long long int)(f.val >> 64); \555 unsigned long long int lsig = (unsigned long long int)(f.val); \556 _Ostream_Manip(SIGNED long long int) fmt @= { msig, f.wd, f.pc, f.base, { .all : f.all } }; \557 _Ostream_Manip(unsigned long long int) fmt2 @= { lsig, 0, 0, f.base, { .all : 0 } }; \558 if ( msig == 0 ) { \559 fmt.val = lsig; \560 (ostype &)(os | fmt); \561 } else { \562 fmt2.flags.pad0 = fmt2.flags.nobsdp = true; \563 if ( f.base == 'b' ) { \564 if ( f.wd > 64 ) fmt.wd = f.wd - 64; \565 fmt2.wd = 64; \566 (ostype &)(os | fmt | "" | fmt2); \567 } else if ( f.base == 'o' ) { \568 fmt.val = (unsigned long long int)fmt.val >> 2; \569 if ( f.wd > 21 ) fmt.wd = f.wd - 21; \570 fmt2.wd = 1; \571 fmt2.val = ((msig & 0x3) << 1) + 1; \572 (ostype &)(os | fmt | "" | fmt2); \573 sepOff( os ); \574 fmt2.wd = 21; \575 fmt2.val = lsig & 0x7fffffffffffffff; \576 (ostype &)(os | fmt2); \577 } else { \578 if ( f.flags.left ) { \579 if ( f.wd > 16 ) fmt2.wd = f.wd - 16; \580 fmt.wd = 16; \581 } else { \582 if ( f.wd > 16 ) fmt.wd = f.wd - 16; \583 fmt2.wd = 16; \584 } /* if */ \585 (ostype &)(os | fmt | "" | fmt2); \586 } /* if */ \587 } /* if */ \588 } else { \589 base10_128( os, f ); \590 } /* if */ \591 return os; \592 } /* ?|? */ \593 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \594 } // distribution595 596 IntegralFMTImpl128( int128, signed, 'd', "% *ll ", "% *.*ll " )597 IntegralFMTImpl128( unsigned int128, unsigned, 'u', "% *ll ", "% *.*ll " )598 #endif // __SIZEOF_INT128__599 489 600 490 //*********************************** floating point *********************************** -
libcfa/src/iostream.hfa
r4783ff6 r5b2b42e 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 20 15:30:56202013 // Update Count : 33 712 // Last Modified On : Fri Feb 7 17:53:52 2020 13 // Update Count : 336 14 14 // 15 15 … … 98 98 ostype & ?|?( ostype &, unsigned long long int ); 99 99 void ?|?( ostype &, unsigned long long int ); 100 #if defined( __SIZEOF_INT128__ )101 ostype & ?|?( ostype &, int128 );102 void ?|?( ostype &, int128 );103 ostype & ?|?( ostype &, unsigned int128 );104 void ?|?( ostype &, unsigned int128 );105 #endif // __SIZEOF_INT128__106 100 107 101 ostype & ?|?( ostype &, float ); … … 212 206 IntegralFMTDecl( signed long long int, 'd' ) 213 207 IntegralFMTDecl( unsigned long long int, 'u' ) 214 #if defined( __SIZEOF_INT128__ )215 IntegralFMTDecl( int128, 'd' )216 IntegralFMTDecl( unsigned int128, 'u' )217 #endif218 208 219 209 //*********************************** floating point ***********************************
Note:
See TracChangeset
for help on using the changeset viewer.