Ignore:
Timestamp:
Jul 19, 2019, 2:16:01 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
4eb43fa
Parents:
1f1c102 (diff), 8ac3b0e (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.
Message:

Merge branch 'master' into new-ast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.cfa

    r1f1c102 rf53acdf8  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 13 17:21:10 2019
    13 // Update Count     : 812
     12// Last Modified On : Sat Jul 13 08:07:59 2019
     13// Update Count     : 821
    1414//
    1515
     
    3030
    3131
    32 //*********************************** Ostream ***********************************
     32//*********************************** ostream ***********************************
    3333
    3434
     
    4040        } // ?|?
    4141        void ?|?( ostype & os, zero_t z ) {
    42                 (ostype &)(os | z); nl( os );
     42                (ostype &)(os | z); ends( os );
    4343        } // ?|?
    4444
     
    4949        } // ?|?
    5050        void ?|?( ostype & os, one_t o ) {
    51                 (ostype &)(os | o); nl( os );
     51                (ostype &)(os | o); ends( os );
    5252        } // ?|?
    5353
     
    5858        } // ?|?
    5959        void ?|?( ostype & os, bool b ) {
    60                 (ostype &)(os | b); nl( os );
     60                (ostype &)(os | b); ends( os );
    6161        } // ?|?
    6262
     
    6767        } // ?|?
    6868        void ?|?( ostype & os, char c ) {
    69                 (ostype &)(os | c); nl( os );
     69                (ostype &)(os | c); ends( os );
    7070        } // ?|?
    7171
     
    7676        } // ?|?
    7777        void ?|?( ostype & os, signed char sc ) {
    78                 (ostype &)(os | sc); nl( os );
     78                (ostype &)(os | sc); ends( os );
    7979        } // ?|?
    8080
     
    8585        } // ?|?
    8686        void ?|?( ostype & os, unsigned char usc ) {
    87                 (ostype &)(os | usc); nl( os );
     87                (ostype &)(os | usc); ends( os );
    8888        } // ?|?
    8989
     
    9494        } // ?|?
    9595        void & ?|?( ostype & os, short int si ) {
    96                 (ostype &)(os | si); nl( os );
     96                (ostype &)(os | si); ends( os );
    9797        } // ?|?
    9898
     
    103103        } // ?|?
    104104        void & ?|?( ostype & os, unsigned short int usi ) {
    105                 (ostype &)(os | usi); nl( os );
     105                (ostype &)(os | usi); ends( os );
    106106        } // ?|?
    107107
     
    112112        } // ?|?
    113113        void & ?|?( ostype & os, int i ) {
    114                 (ostype &)(os | i); nl( os );
     114                (ostype &)(os | i); ends( os );
    115115        } // ?|?
    116116
     
    121121        } // ?|?
    122122        void & ?|?( ostype & os, unsigned int ui ) {
    123                 (ostype &)(os | ui); nl( os );
     123                (ostype &)(os | ui); ends( os );
    124124        } // ?|?
    125125
     
    130130        } // ?|?
    131131        void & ?|?( ostype & os, long int li ) {
    132                 (ostype &)(os | li); nl( os );
     132                (ostype &)(os | li); ends( os );
    133133        } // ?|?
    134134
     
    139139        } // ?|?
    140140        void & ?|?( ostype & os, unsigned long int uli ) {
    141                 (ostype &)(os | uli); nl( os );
     141                (ostype &)(os | uli); ends( os );
    142142        } // ?|?
    143143
     
    148148        } // ?|?
    149149        void & ?|?( ostype & os, long long int lli ) {
    150                 (ostype &)(os | lli); nl( os );
     150                (ostype &)(os | lli); ends( os );
    151151        } // ?|?
    152152
     
    157157        } // ?|?
    158158        void & ?|?( ostype & os, unsigned long long int ulli ) {
    159                 (ostype &)(os | ulli); nl( os );
     159                (ostype &)(os | ulli); ends( os );
    160160        } // ?|?
    161161
     
    180180        } // ?|?
    181181        void & ?|?( ostype & os, float f ) {
    182                 (ostype &)(os | f); nl( os );
     182                (ostype &)(os | f); ends( os );
    183183        } // ?|?
    184184
     
    189189        } // ?|?
    190190        void & ?|?( ostype & os, double d ) {
    191                 (ostype &)(os | d); nl( os );
     191                (ostype &)(os | d); ends( os );
    192192        } // ?|?
    193193
     
    198198        } // ?|?
    199199        void & ?|?( ostype & os, long double ld ) {
    200                 (ostype &)(os | ld); nl( os );
     200                (ostype &)(os | ld); ends( os );
    201201        } // ?|?
    202202
     
    210210        } // ?|?
    211211        void & ?|?( ostype & os, float _Complex fc ) {
    212                 (ostype &)(os | fc); nl( os );
     212                (ostype &)(os | fc); ends( os );
    213213        } // ?|?
    214214
     
    222222        } // ?|?
    223223        void & ?|?( ostype & os, double _Complex dc ) {
    224                 (ostype &)(os | dc); nl( os );
     224                (ostype &)(os | dc); ends( os );
    225225        } // ?|?
    226226
     
    234234        } // ?|?
    235235        void & ?|?( ostype & os, long double _Complex ldc ) {
    236                 (ostype &)(os | ldc); nl( os );
     236                (ostype &)(os | ldc); ends( os );
    237237        } // ?|?
    238238
     
    276276        } // ?|?
    277277        void ?|?( ostype & os, const char * str ) {
    278                 (ostype &)(os | str); nl( os );
     278                (ostype &)(os | str); ends( os );
    279279        } // ?|?
    280280
     
    305305        } // ?|?
    306306        void ?|?( ostype & os, const void * p ) {
    307                 (ostype &)(os | p); nl( os );
     307                (ostype &)(os | p); ends( os );
    308308        } // ?|?
    309309
     
    315315        void ?|?( ostype & os, ostype & (* manip)( ostype & ) ) {
    316316                (ostype &)(manip( os ));
    317                 if ( getPrt( os ) ) nl( os );                                   // something printed ?
     317                if ( getPrt( os ) ) ends( os );                                 // something printed ?
    318318                setPrt( os, false );                                                    // turn off
    319319        } // ?|?
     
    335335        } // nl
    336336
    337         void nl( ostype & os ) {
    338                 if ( getANL( os ) ) (ostype &)(nl( os ));               // implementation only
    339                 else setPrt( os, false );                                               // turn off
    340         } // nl
    341 
    342337        ostype & nonl( ostype & os ) {
    343338                setPrt( os, false );                                                    // turn off
     
    386381        } // ?|?
    387382        void ?|?( ostype & os, T arg, Params rest ) {
    388                 // (ostype &)(?|?( os, arg, rest )); nl( os );
     383                // (ostype &)(?|?( os, arg, rest )); ends( os );
    389384                (ostype &)(os | arg);                                                   // print first argument
    390385                sepSetCur( os, sepGetTuple( os ) );                             // switch to tuple separator
    391386                (ostype &)(os | rest);                                                  // print remaining arguments
    392387                sepSetCur( os, sepGet( os ) );                                  // switch to regular separator
    393                 nl( os );
     388                ends( os );
    394389        } // ?|?
    395390} // distribution
     
    408403} // distribution
    409404
    410 //*********************************** Manipulators ***********************************
    411 
    412 //*********************************** Integral ***********************************
     405//*********************************** manipulators ***********************************
     406
     407//*********************************** integral ***********************************
    413408
    414409static const char * shortbin[] = { "0", "1", "10", "11", "100", "101", "110", "111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111" };
     
    478473                return os; \
    479474        } /* ?|? */ \
    480         void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); nl( os ); } \
     475        void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \
    481476} // distribution
    482477
     
    492487IntegralFMTImpl( unsigned long long int, 'u', "%    *ll ", "%    *.*ll " )
    493488
    494 //*********************************** Floating Point ***********************************
     489//*********************************** floating point ***********************************
    495490
    496491#define PrintWithDP2( os, format, val, ... ) \
     
    504499                                if ( ! f.flags.left ) { \
    505500                                        buf[i] = '.'; buf[i + 1] = '\0'; \
    506                                         if ( buf[0] == ' ' ) bufbeg = 1; /* decimal point within width */ \
     501                                        if ( buf[0] == ' ' ) bufbeg = 1;        /* decimal point within width */ \
    507502                                } else { \
    508503                                        for ( i = 0; i < len && buf[i] != ' '; i += 1 ); /* trailing blank ? */ \
     
    541536                return os; \
    542537        } /* ?|? */ \
    543         void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); nl( os ); } \
     538        void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \
    544539} // distribution
    545540
     
    547542FloatingPointFMTImpl( long double, "%    *L ", "%    *.*L " )
    548543
    549 //*********************************** Character ***********************************
     544//*********************************** character ***********************************
    550545
    551546forall( dtype ostype | ostream( ostype ) ) {
    552547        ostype & ?|?( ostype & os, _Ostream_Manip(char) f ) {
    553                 if ( f.base != 'c' ) {                                                          // bespoke binary/octal/hex format
     548                if ( f.base != 'c' ) {                                                  // bespoke binary/octal/hex format
    554549                        _Ostream_Manip(unsigned char) fmtuc @= { f.val, f.wd, f.pc, f.base, {'\0'} };
    555550                        fmtuc.flags.pc = f.flags.pc;
     
    563558
    564559                #define CFMTNP "% * "
    565                 char fmtstr[sizeof(CFMTNP)];                                            // sizeof includes '\0'
     560                char fmtstr[sizeof(CFMTNP)];                                    // sizeof includes '\0'
    566561                memcpy( &fmtstr, CFMTNP, sizeof(CFMTNP) );
    567                 int star = 1;                                                                           // position before first '*'
     562                int star = 1;                                                                   // position before first '*'
    568563
    569564                // Insert flags into spaces before '*', from right to left.
     
    571566                fmtstr[star] = '%';
    572567
    573                 fmtstr[sizeof(CFMTNP)-2] = f.base;                                      // sizeof includes '\0'
     568                fmtstr[sizeof(CFMTNP)-2] = f.base;                              // sizeof includes '\0'
    574569                // printf( "%d %s\n", f.wd, &fmtstr[star] );
    575570                fmt( os, &fmtstr[star], f.wd, f.val );
    576571                return os;
    577572        } // ?|?
    578         void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); nl( os ); }
     573        void ?|?( ostype & os, _Ostream_Manip(char) f ) { (ostype &)(os | f); ends( os ); }
    579574} // distribution
    580575
    581 //*********************************** C String ***********************************
     576//*********************************** C string ***********************************
    582577
    583578forall( dtype ostype | ostream( ostype ) ) {
     
    621616                return os;
    622617        } // ?|?
    623         void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); nl( os ); }
     618        void ?|?( ostype & os, _Ostream_Manip(const char *) f ) { (ostype &)(os | f); ends( os ); }
    624619} // distribution
    625620
    626621
    627 //*********************************** Istream ***********************************
     622//*********************************** istream ***********************************
    628623
    629624
     
    636631                else {
    637632                        fprintf( stderr, "invalid Boolean constant\n" );
    638                         abort();
     633                        abort();                                                                        // cannot use abort stream
    639634                } // if
    640635                return is;
     
    644639                char temp;
    645640                for () {
    646                         fmt( is, "%c", &temp );                                                 // must pass pointer through varg to fmt
     641                        fmt( is, "%c", &temp );                                         // must pass pointer through varg to fmt
    647642                        // do not overwrite parameter with newline unless appropriate
    648643                        if ( temp != '\n' || getANL( is ) ) { c = temp; break; }
     
    771766} // distribution
    772767
    773 //*********************************** Manipulators ***********************************
     768//*********************************** manipulators ***********************************
    774769
    775770forall( dtype istype | istream( istype ) )
     
    778773        if ( ! f.s ) {
    779774                // printf( "skip %s %d\n", f.scanset, f.wd );
    780                 if ( f.wd == -1 ) fmt( is, f.scanset, "" ); // no input arguments
     775                if ( f.wd == -1 ) fmt( is, f.scanset, "" );             // no input arguments
    781776                else for ( f.wd ) fmt( is, "%*c" );
    782777                return is;
Note: See TracChangeset for help on using the changeset viewer.