Changeset b826e6b for src/libcfa/fstream.c
- Timestamp:
- Jul 19, 2017, 11:49:33 AM (8 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/fstream.c
rfea3faa rb826e6b 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 15 18:11:11201713 // Update Count : 2 3412 // Last Modified On : Thu Jul 6 18:38:25 2017 13 // Update Count : 251 14 14 // 15 15 … … 39 39 40 40 // private 41 _Bool sepPrt( ofstream * os ) { return os->sepOnOff; }41 _Bool sepPrt( ofstream * os ) { setNL( os, false ); return os->sepOnOff; } 42 42 void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; } 43 43 void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; } 44 44 const char * sepGetCur( ofstream * os ) { return os->sepCur; } 45 45 void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; } 46 _Bool getNL( ofstream * os ) { return os->sawNL; } 47 void setNL( ofstream * os, _Bool state ) { os->sawNL = state; } 46 48 47 49 // public 48 void sepOn( ofstream * os ) { os->sepOnOff = 1; }49 void sepOff( ofstream * os ) { os->sepOnOff = 0; }50 void sepOn( ofstream * os ) { os->sepOnOff = ! getNL( os ); } 51 void sepOff( ofstream * os ) { os->sepOnOff = false; } 50 52 51 53 _Bool sepDisable( ofstream *os ) { … … 66 68 void sepSet( ofstream * os, const char * s ) { 67 69 assert( s ); 68 strncpy( os->separator, s, sep arateSize - 1 );69 os->separator[sep arateSize - 1] = '\0';70 strncpy( os->separator, s, sepSize - 1 ); 71 os->separator[sepSize - 1] = '\0'; 70 72 } // sepSet 71 73 … … 73 75 void sepSetTuple( ofstream * os, const char * s ) { 74 76 assert( s ); 75 strncpy( os->tupleSeparator, s, sep arateSize - 1 );76 os->tupleSeparator[sep arateSize - 1] = '\0';77 strncpy( os->tupleSeparator, s, sepSize - 1 ); 78 os->tupleSeparator[sepSize - 1] = '\0'; 77 79 } // sepSet 78 80 … … 92 94 exit( EXIT_FAILURE ); 93 95 } // if 94 ?{}( os, file, 1, 0, " ", ", " );96 ?{}( os, file, true, false, " ", ", " ); 95 97 } // open 96 98 … … 132 134 } // fmt 133 135 134 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, " ", ", " };136 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), true, false, " ", ", " }; 135 137 ofstream *sout = &soutFile; 136 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, " ", ", " };138 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), true, false, " ", ", " }; 137 139 ofstream *serr = &serrFile; 138 140 … … 150 152 151 153 void open( ifstream * is, const char * name, const char * mode ) { 152 FILE * t= fopen( name, mode );153 if ( t == 0 ) {// do not change unless successful154 FILE *file = fopen( name, mode ); 155 if ( file == 0 ) { // do not change unless successful 154 156 fprintf( stderr, IO_MSG "open input file \"%s\", ", name ); 155 157 perror( 0 ); 156 158 exit( EXIT_FAILURE ); 157 159 } // if 158 is->file = t;160 is->file = file; 159 161 } // open 160 162
Note:
See TracChangeset
for help on using the changeset viewer.