Changes in / [50f6afb:8edbe40]


Ignore:
Files:
4 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    r50f6afb r8edbe40  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sat Apr 24 09:09:56 2021
    14 ## Update Count     : 254
     13## Last Modified On : Wed Dec  9 22:46:14 2020
     14## Update Count     : 250
    1515###############################################################################
    1616
     
    6969        common.hfa \
    7070        fstream.hfa \
    71         strstream.hfa \
    7271        heap.hfa \
    7372        iostream.hfa \
  • libcfa/src/fstream.cfa

    r50f6afb r8edbe40  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr 24 09:05:16 2021
    13 // Update Count     : 426
     12// Last Modified On : Tue Apr 20 19:04:46 2021
     13// Update Count     : 425
    1414//
    1515
     
    1919#include <stdlib.h>                                                                             // exit
    2020#include <stdarg.h>                                                                             // varargs
    21 #include <string.h>                                                                             // strncpy, strerror
     21#include <string.h>                                                                             // strlen
     22#include <float.h>                                                                              // DBL_DIG, LDBL_DIG
     23#include <complex.h>                                                                    // creal, cimag
    2224#include <assert.h>
    2325#include <errno.h>                                                                              // errno
     
    9193void sepSet( ofstream & os, const char s[] ) {
    9294        assert( s );
    93         strncpy( os.separator$, s, ofstream_sepSize - 1 );
    94         os.separator$[ofstream_sepSize - 1] = '\0';
     95        strncpy( os.separator$, s, sepSize - 1 );
     96        os.separator$[sepSize - 1] = '\0';
    9597} // sepSet
    9698
     
    98100void sepSetTuple( ofstream & os, const char s[] ) {
    99101        assert( s );
    100         strncpy( os.tupleSeparator$, s, ofstream_sepSize - 1 );
    101         os.tupleSeparator$[ofstream_sepSize - 1] = '\0';
     102        strncpy( os.tupleSeparator$, s, sepSize - 1 );
     103        os.tupleSeparator$[sepSize - 1] = '\0';
    102104} // sepSet
    103105
     
    110112} // ends
    111113
    112 bool fail( ofstream & os ) {
     114int fail( ofstream & os ) {
    113115        return os.file$ == 0 || ferror( (FILE *)(os.file$) );
    114116} // fail
     
    226228bool getANL( ifstream & os ) { return os.nlOnOff$; }
    227229
    228 bool fail( ifstream & is ) {
     230int fail( ifstream & is ) {
    229231        return is.file$ == 0p || ferror( (FILE *)(is.file$) );
    230232} // fail
  • libcfa/src/fstream.hfa

    r50f6afb r8edbe40  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr 24 09:04:03 2021
    13 // Update Count     : 219
     12// Last Modified On : Tue Apr 20 19:04:12 2021
     13// Update Count     : 218
    1414//
    1515
     
    2424
    2525
    26 enum { ofstream_sepSize = 16 };
     26enum { sepSize = 16 };
    2727struct ofstream {
    2828        void * file$;
     
    3333        bool sawNL$;
    3434        const char * sepCur$;
    35         char separator$[ofstream_sepSize];
    36         char tupleSeparator$[ofstream_sepSize];
     35        char separator$[sepSize];
     36        char tupleSeparator$[sepSize];
    3737        multiple_acquisition_lock lock$;
    3838        bool acquired$;
    3939}; // ofstream
    40 
    41 // Satisfies ostream
    4240
    4341// private
     
    6664void sepSetTuple( ofstream &, const char [] );
    6765
    68 void ends( ofstream & );
    69 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    70 
    71 bool fail( ofstream & );
     66void ends( ofstream & os );
     67int fail( ofstream & );
    7268int flush( ofstream & );
    7369void open( ofstream &, const char name[], const char mode[] );
     
    7571void close( ofstream & );
    7672ofstream & write( ofstream &, const char data[], size_t size );
    77 
    78 void acquire( ofstream & );
    79 void release( ofstream & );
     73int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
     74void acquire( ofstream & os );
     75void release( ofstream & os );
    8076
    8177struct osacquire {
    8278        ofstream & os;
    8379};
    84 void ?{}( osacquire & acq, ofstream & );
     80void ?{}( osacquire & acq, ofstream & os );
    8581void ^?{}( osacquire & acq );
    8682
    87 void ?{}( ofstream & );
    88 void ?{}( ofstream &, const char name[], const char mode[] );
    89 void ?{}( ofstream &, const char name[] );
    90 void ^?{}( ofstream & );
     83void ?{}( ofstream & os );
     84void ?{}( ofstream & os, const char name[], const char mode[] );
     85void ?{}( ofstream & os, const char name[] );
     86void ^?{}( ofstream & os );
    9187
    9288extern ofstream & sout, & stdout, & serr, & stderr;             // aliases
     
    104100}; // ifstream
    105101
    106 // Satisfies istream
    107 
    108102// public
    109103void nlOn( ifstream & );
     
    111105bool getANL( ifstream & );
    112106void ends( ifstream & );
    113 bool fail( ifstream & is );
     107int fail( ifstream & is );
    114108int eof( ifstream & is );
    115109void open( ifstream & is, const char name[], const char mode[] );
     
    148142);
    149143
    150 void ?{}( Open_Failure & this, ofstream & );
    151 void ?{}( Open_Failure & this, ifstream & );
     144void ?{}( Open_Failure & this, ofstream & ostream );
     145void ?{}( Open_Failure & this, ifstream & istream );
    152146
    153147// Local Variables: //
  • libcfa/src/iostream.cfa

    r50f6afb r8edbe40  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr 24 10:03:54 2021
    13 // Update Count     : 1329
     12// Last Modified On : Tue Apr 20 19:09:41 2021
     13// Update Count     : 1325
    1414//
    1515
     
    3636
    3737
    38 forall( ostype & | basic_ostream( ostype ) ) {
     38forall( ostype & | ostream( ostype ) ) {
    3939        ostype & ?|?( ostype & os, bool b ) {
    4040                if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) );
     
    294294
    295295                // last character IS spacing or opening punctuation => turn off separator for next item
    296                 int len = strlen( s );
     296                size_t len = strlen( s );
    297297                ch = s[len - 1];                                                                // must make unsigned
    298                 fmt( os, "%s", s );                                                             // fmt resets seperator, but reset it again
    299298                if ( sepPrt$( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    300299                        sepOn( os );
     
    303302                } // if
    304303                if ( ch == '\n' ) setNL$( os, true );                   // check *AFTER* sepPrt$ call above as it resets NL flag
    305                 return os;
    306 //              return write( os, s, len );
     304                return write( os, s, len );
    307305        } // ?|?
    308306        void ?|?( ostype & os, const char s[] ) {
     
    399397                return os;
    400398        } // nlOff
    401 } // distribution
    402 
    403 forall( ostype & | ostream( ostype ) ) {
     399
    404400        ostype & acquire( ostype & os ) {
    405401                acquire( os );                                                                  // call void returning
     
    449445// Default prefix for non-decimal prints is 0b, 0, 0x.
    450446#define IntegralFMTImpl( T, IFMTNP, IFMTP ) \
    451 forall( ostype & | basic_ostream( ostype ) ) { \
     447forall( ostype & | ostream( ostype ) ) { \
    452448        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    453449                if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); \
     
    543539#if defined( __SIZEOF_INT128__ )
    544540// Default prefix for non-decimal prints is 0b, 0, 0x.
    545 forall( ostype & | basic_ostream( ostype ) )
     541forall( ostype & | ostream( ostype ) )
    546542static inline void base_128( ostype & os, unsigned int128 val, unsigned int128 power, _Ostream_Manip(uint64_t) & f, unsigned int maxdig, unsigned int bits, unsigned int cnt = 0 ) {
    547543        int wd = 1;                                                                                     // f.wd is never 0 because 0 implies left-pad
     
    608604
    609605#define IntegralFMTImpl128( T ) \
    610 forall( ostype & | basic_ostream( ostype ) ) { \
     606forall( ostype & | ostream( ostype ) ) { \
    611607        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
    612608                _Ostream_Manip(uint64_t) fmt; \
     
    681677
    682678#define FloatingPointFMTImpl( T, DFMTNP, DFMTP ) \
    683 forall( ostype & | basic_ostream( ostype ) ) { \
     679forall( ostype & | ostream( ostype ) ) { \
    684680        static void eng( T &value, int & pc, int & exp10 ) { \
    685681                exp10 = lrint( floor( log10( abs( value ) ) ) ); /* round to desired precision */ \
     
    727723// *********************************** character ***********************************
    728724
    729 forall( ostype & | basic_ostream( ostype ) ) {
     725forall( ostype & | ostream( ostype ) ) {
    730726        ostype & ?|?( ostype & os, _Ostream_Manip(char) f ) {
    731727                if ( f.base != 'c' ) {                                                  // bespoke binary/octal/hex format
     
    760756// *********************************** C string ***********************************
    761757
    762 forall( ostype & | basic_ostream( ostype ) ) {
     758forall( ostype & | ostream( ostype ) ) {
    763759        ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f ) {
    764760                if ( ! f.val ) return os;                                               // null pointer ?
  • libcfa/src/iostream.hfa

    r50f6afb r8edbe40  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr 24 09:28:56 2021
    13 // Update Count     : 393
     12// Last Modified On : Tue Apr 20 19:09:44 2021
     13// Update Count     : 385
    1414//
    1515
     
    2222
    2323
    24 trait basic_ostream( ostype & ) {
     24trait ostream( ostype & ) {
    2525        // private
    2626        bool sepPrt$( ostype & );                                                       // get separator state (on/off)
     
    4747        void sepSetTuple( ostype &, const char [] );            // set tuple separator to string (15 character maximum)
    4848
    49         void ends( ostype & );                                                          // end of output statement
     49        void ends( ostype & os );                                                       // end of output statement
     50        int fail( ostype & );
     51        int flush( ostype & );
     52        void open( ostype & os, const char name[], const char mode[] );
     53        void close( ostype & os );
     54        ostype & write( ostype &, const char [], size_t );
    5055        int fmt( ostype &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
    51         int flush( ostype & );
    52 }; // basic_ostream
    53        
    54 trait ostream( ostype & | basic_ostream( ostype ) ) {
    55         bool fail( ostype & );                                                          // operation failed?
    56         void open( ostype &, const char name[], const char mode[] );
    57         void close( ostype & );
    58         ostype & write( ostype &, const char [], size_t );
    59         void acquire( ostype & );                                                       // concurrent access
     56        void acquire( ostype & );
    6057}; // ostream
    6158
     
    7067// implement writable for intrinsic types
    7168
    72 forall( ostype & | basic_ostream( ostype ) ) {
     69forall( ostype & | ostream( ostype ) ) {
    7370        ostype & ?|?( ostype &, bool );
    7471        void ?|?( ostype &, bool );
     
    141138        ostype & nlOn( ostype & );
    142139        ostype & nlOff( ostype & );
    143 } // distribution
    144 
    145 forall( ostype & | ostream( ostype ) ) {
    146140        ostype & acquire( ostype & );
    147141} // distribution
     
    202196        _Ostream_Manip(T) & sign( _Ostream_Manip(T) & fmt ) { fmt.flags.sign = true; return fmt; } \
    203197} /* distribution */ \
    204 forall( ostype & | basic_ostream( ostype ) ) { \
     198forall( ostype & | ostream( ostype ) ) { \
    205199        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \
    206200        void ?|?( ostype & os, _Ostream_Manip(T) f ); \
     
    247241        _Ostream_Manip(T) & unit( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \
    248242} /* distribution */ \
    249 forall( ostype & | basic_ostream( ostype ) ) { \
     243forall( ostype & | ostream( ostype ) ) { \
    250244        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ); \
    251245        void ?|?( ostype & os, _Ostream_Manip(T) f ); \
     
    267261        _Ostream_Manip(char) & nobase( _Ostream_Manip(char) & fmt ) { fmt.flags.nobsdp = true; return fmt; }
    268262} // distribution
    269 forall( ostype & | basic_ostream( ostype ) ) {
     263forall( ostype & | ostream( ostype ) ) {
    270264        ostype & ?|?( ostype & os, _Ostream_Manip(char) f );
    271265        void ?|?( ostype & os, _Ostream_Manip(char) f );
     
    285279        _Ostream_Manip(const char *) & nobase( _Ostream_Manip(const char *) & fmt ) { fmt.flags.nobsdp = true; return fmt; }
    286280} // distribution
    287 forall( ostype & | basic_ostream( ostype ) ) {
     281forall( ostype & | ostream( ostype ) ) {
    288282        ostype & ?|?( ostype & os, _Ostream_Manip(const char *) f );
    289283        void ?|?( ostype & os, _Ostream_Manip(const char *) f );
     
    300294
    301295        void ends( istype & os );                                                       // end of output statement
    302         bool fail( istype & );
     296        int fail( istype & );
    303297        int eof( istype & );
    304298        void open( istype & is, const char name[] );
Note: See TracChangeset for help on using the changeset viewer.