Changeset d395012 for src/libcfa


Ignore:
Timestamp:
Jul 1, 2017, 5:24:03 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
86f384b
Parents:
b0f7a43
Message:

support separator at end of line

Location:
src/libcfa
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/fstream

    rb0f7a43 rd395012  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 15 18:11:09 2017
    13 // Update Count     : 104
     12// Last Modified On : Sat Jul  1 16:37:53 2017
     13// Update Count     : 112
    1414//
    1515
     
    2424        _Bool sepDefault;
    2525        _Bool sepOnOff;
     26        _Bool lastSepOn;
    2627        const char * sepCur;
    2728        char separator[separateSize];
     
    3536const char * sepGetCur( ofstream * );
    3637void sepSetCur( ofstream *, const char * );
     38_Bool lastSepOn( ofstream * );
    3739
    3840// public
  • src/libcfa/fstream.c

    rb0f7a43 rd395012  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 15 18:11:11 2017
    13 // Update Count     : 234
     12// Last Modified On : Sat Jul  1 16:37:54 2017
     13// Update Count     : 242
    1414//
    1515
     
    3333        this->sepDefault = sepDefault;
    3434        this->sepOnOff = sepOnOff;
     35        this->lastSepOn = false;
    3536        sepSet( this, separator );
    3637        sepSetCur( this, sepGet( this ) );
     
    3940
    4041// private
    41 _Bool sepPrt( ofstream * os ) { return os->sepOnOff; }
     42_Bool lastSepOn( ofstream * os ) { return os->lastSepOn; }
     43_Bool sepPrt( ofstream * os ) { os->lastSepOn = false; return os->sepOnOff; }
    4244void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; }
    4345void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; }
     
    4648
    4749// public
    48 void sepOn( ofstream * os ) { os->sepOnOff = 1; }
    49 void sepOff( ofstream * os ) { os->sepOnOff = 0; }
     50void sepOn( ofstream * os ) { os->lastSepOn = true; os->sepOnOff = true; }
     51void sepOff( ofstream * os ) { os->lastSepOn = false; os->sepOnOff = 0; }
    5052
    5153_Bool sepDisable( ofstream *os ) {
    5254        _Bool temp = os->sepDefault;
    5355        os->sepDefault = false;
     56        os->lastSepOn = false;
    5457        sepReset( os );
    5558        return temp;
     
    9295                exit( EXIT_FAILURE );
    9396        } // if
    94         ?{}( os, file, 1, 0, " ", ", " );
     97        ?{}( os, file, true, false, " ", ", " );
    9598} // open
    9699
     
    132135} // fmt
    133136
    134 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, " ", ", " };
     137static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " };
    135138ofstream *sout = &soutFile;
    136 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, " ", ", " };
     139static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " };
    137140ofstream *serr = &serrFile;
    138141
  • src/libcfa/iostream

    rb0f7a43 rd395012  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 15 18:08:44 2017
    13 // Update Count     : 105
     12// Last Modified On : Sat Jul  1 16:37:52 2017
     13// Update Count     : 108
    1414//
    1515
     
    3131        _Bool sepDisable( ostype * );                                           // set default state to off, and return previous state
    3232        _Bool sepEnable( ostype * );                                            // set default state to on, and return previous state
     33        _Bool lastSepOn( ostype * );                                            // last manipulator is setOn (context sensitive)
    3334
    3435        const char * sepGet( ostype * );                                        // get separator string
  • src/libcfa/iostream.c

    rb0f7a43 rd395012  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May  8 18:24:23 2017
    13 // Update Count     : 369
     12// Last Modified On : Sat Jul  1 16:37:51 2017
     13// Update Count     : 374
    1414//
    1515
     
    217217forall( dtype ostype | ostream( ostype ) )
    218218ostype * endl( ostype * os ) {
     219        if ( lastSepOn( os ) ) fmt( os, "%s", sepGetCur( os ) );
    219220        os | '\n';
    220221        flush( os );
Note: See TracChangeset for help on using the changeset viewer.