Ignore:
Timestamp:
Jul 19, 2017, 11:49:33 AM (8 years ago)
Author:
Aaron Moss <a3moss@…>
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:
9cc0472
Parents:
fea3faa (diff), a57cb58 (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/fstream.c

    rfea3faa rb826e6b  
    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 : Thu Jul  6 18:38:25 2017
     13// Update Count     : 251
    1414//
    1515
     
    3939
    4040// private
    41 _Bool sepPrt( ofstream * os ) { return os->sepOnOff; }
     41_Bool sepPrt( ofstream * os ) { setNL( os, false ); return os->sepOnOff; }
    4242void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; }
    4343void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; }
    4444const char * sepGetCur( ofstream * os ) { return os->sepCur; }
    4545void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; }
     46_Bool getNL( ofstream * os ) { return os->sawNL; }
     47void setNL( ofstream * os, _Bool state ) { os->sawNL = state; }
    4648
    4749// public
    48 void sepOn( ofstream * os ) { os->sepOnOff = 1; }
    49 void sepOff( ofstream * os ) { os->sepOnOff = 0; }
     50void sepOn( ofstream * os ) { os->sepOnOff = ! getNL( os ); }
     51void sepOff( ofstream * os ) { os->sepOnOff = false; }
    5052
    5153_Bool sepDisable( ofstream *os ) {
     
    6668void sepSet( ofstream * os, const char * s ) {
    6769        assert( s );
    68         strncpy( os->separator, s, separateSize - 1 );
    69         os->separator[separateSize - 1] = '\0';
     70        strncpy( os->separator, s, sepSize - 1 );
     71        os->separator[sepSize - 1] = '\0';
    7072} // sepSet
    7173
     
    7375void sepSetTuple( ofstream * os, const char * s ) {
    7476        assert( s );
    75         strncpy( os->tupleSeparator, s, separateSize - 1 );
    76         os->tupleSeparator[separateSize - 1] = '\0';
     77        strncpy( os->tupleSeparator, s, sepSize - 1 );
     78        os->tupleSeparator[sepSize - 1] = '\0';
    7779} // sepSet
    7880
     
    9294                exit( EXIT_FAILURE );
    9395        } // if
    94         ?{}( os, file, 1, 0, " ", ", " );
     96        ?{}( os, file, true, false, " ", ", " );
    9597} // open
    9698
     
    132134} // fmt
    133135
    134 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, " ", ", " };
     136static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " };
    135137ofstream *sout = &soutFile;
    136 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, " ", ", " };
     138static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " };
    137139ofstream *serr = &serrFile;
    138140
     
    150152
    151153void open( ifstream * is, const char * name, const char * mode ) {
    152         FILE *t = fopen( name, mode );
    153         if ( t == 0 ) {                                                                         // do not change unless successful
     154        FILE *file = fopen( name, mode );
     155        if ( file == 0 ) {                                                                      // do not change unless successful
    154156                fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
    155157                perror( 0 );
    156158                exit( EXIT_FAILURE );
    157159        } // if
    158         is->file = t;
     160        is->file = file;
    159161} // open
    160162
Note: See TracChangeset for help on using the changeset viewer.