Changes in / [4783ff6:5b2b42e]


Ignore:
Location:
libcfa/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.hfa

    r4783ff6 r5b2b42e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Feb 17 08:29:23 2020
    13 // Update Count     : 175
     12// Last Modified On : Fri Feb  7 19:00:51 2020
     13// Update Count     : 174
    1414//
    1515
     
    6767void close( ofstream & );
    6868ofstream & write( ofstream &, const char data[], size_t size );
    69 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
     69int fmt( ofstream &, const char format[], ... );
    7070
    7171void ?{}( ofstream & os );
     
    9797ifstream & read( ifstream & is, char * data, size_t size );
    9898ifstream & ungetc( ifstream & is, char c );
    99 int fmt( ifstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
     99int fmt( ifstream &, const char format[], ... );
    100100
    101101void ?{}( ifstream & is );
  • libcfa/src/iostream.cfa

    r4783ff6 r5b2b42e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 20 15:30:58 2020
    13 // Update Count     : 827
     12// Last Modified On : Fri Feb  7 18:48:38 2020
     13// Update Count     : 825
    1414//
    1515
     
    159159                (ostype &)(os | ulli); ends( os );
    160160        } // ?|?
    161 
    162 #if defined( __SIZEOF_INT128__ )
    163         //      UINT64_MAX 18_446_744_073_709_551_615_ULL
    164         #define P10_UINT64 10_000_000_000_000_000_000_ULL       // 19 zeroes
    165 
    166         static void base10_128( ostype & os, unsigned int128 val ) {
    167                 if ( val > UINT64_MAX ) {
    168                         base10_128( os, val / P10_UINT64 );                     // recursive
    169                         fmt( os, "%.19lu", (uint64_t)(val % P10_UINT64) );
    170                 } else {
    171                         fmt( os, "%lu", (uint64_t)val );
    172                 } // if
    173         } // base10_128
    174 
    175         static void base10_128( ostype & os, int128 val ) {
    176                 if ( val < 0 ) {
    177                         fmt( os, "-" );                                                         // leading negative sign
    178                         val = -val;
    179                 } // if
    180                 base10_128( os, (unsigned int128)val );                 // print zero/positive value
    181         } // base10_128
    182 
    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__
    201161
    202162        #define PrintWithDP( os, format, val, ... ) \
     
    504464\
    505465                if ( ! f.flags.pc ) {                                                   /* no precision */ \
     466                        /* printf( "%s\n", &fmtstr[star] ); */ \
    506467                        fmtstr[sizeof(IFMTNP)-2] = f.base;                      /* sizeof includes '\0' */ \
    507                         /* printf( "%s %c %c\n", &fmtstr[star], f.base, CODE ); */ \
    508468                        fmt( os, &fmtstr[star], f.wd, f.val ); \
    509469                } else {                                                                                /* precision */ \
    510470                        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] ); */ \
    512472                        fmt( os, &fmtstr[star], f.wd, f.pc, f.val ); \
    513473                } /* if */ \
     
    527487IntegralFMTImpl( signed long long int, 'd', "%    *ll ", "%    *.*ll " )
    528488IntegralFMTImpl( 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 } // distribution
    595 
    596 IntegralFMTImpl128( int128, signed, 'd', "%    *ll ", "%    *.*ll " )
    597 IntegralFMTImpl128( unsigned int128, unsigned, 'u', "%    *ll ", "%    *.*ll " )
    598 #endif // __SIZEOF_INT128__
    599489
    600490//*********************************** floating point ***********************************
  • libcfa/src/iostream.hfa

    r4783ff6 r5b2b42e  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 20 15:30:56 2020
    13 // Update Count     : 337
     12// Last Modified On : Fri Feb  7 17:53:52 2020
     13// Update Count     : 336
    1414//
    1515
     
    9898        ostype & ?|?( ostype &, unsigned long long int );
    9999        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__
    106100
    107101        ostype & ?|?( ostype &, float );
     
    212206IntegralFMTDecl( signed long long int, 'd' )
    213207IntegralFMTDecl( unsigned long long int, 'u' )
    214 #if defined( __SIZEOF_INT128__ )
    215 IntegralFMTDecl( int128, 'd' )
    216 IntegralFMTDecl( unsigned int128, 'u' )
    217 #endif
    218208
    219209//*********************************** floating point ***********************************
Note: See TracChangeset for help on using the changeset viewer.