Changes in src/libcfa/fstream.c [6152c81:829c907]
- File:
-
- 1 edited
-
src/libcfa/fstream.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/fstream.c
r6152c81 r829c907 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 14:48:09201713 // Update Count : 19212 // Last Modified On : Tue Mar 21 20:56:10 2017 13 // Update Count : 215 14 14 // 15 15 … … 33 33 void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; } 34 34 void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; } 35 36 const char * sepGetCur( ofstream * os ) { return os->sepCur; } 37 void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; } 38 35 39 const char * sepGet( ofstream * os ) { return &(os->separator[0]); } 36 40 … … 38 42 strncpy( &(os->separator[0]), s, separateSize - 1 ); 39 43 os->separator[separateSize - 1] = '\0'; 44 } // sepSet 45 46 const char * sepGetTuple( ofstream * os ) { return &(os->tupleSeparator[0]); } 47 48 void sepSetTuple( ofstream * os, const char * s ) { 49 strncpy( &(os->tupleSeparator[0]), s, separateSize - 1 ); 50 os->tupleSeparator[separateSize - 1] = '\0'; 40 51 } // sepSet 41 52 … … 95 106 } // write 96 107 97 int prtfmt( ofstream * os, const char fmt[], ... ) {108 int fmt( ofstream * os, const char format[], ... ) { 98 109 va_list args; 99 va_start( args, f mt );100 int len = vfprintf( (FILE *)(os->file), f mt, args );110 va_start( args, format ); 111 int len = vfprintf( (FILE *)(os->file), format, args ); 101 112 if ( len == EOF ) { 102 113 if ( ferror( (FILE *)(os->file) ) ) { … … 109 120 sepReset( os ); // reset separator 110 121 return len; 111 } // prtfmt 112 113 114 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, { ' ', '\0' } }; 122 } // fmt 123 124 void ?{}( ofstream * this, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) { 125 this->file = file; 126 this->sepDefault = sepDefault; 127 this->sepOnOff = sepOnOff; 128 sepSet( this, separator ); 129 sepSetCur( this, sepGet( this ) ); 130 sepSetTuple( this, tupleSeparator ); 131 } 132 133 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, " ", ", " }; 115 134 ofstream *sout = &soutFile; 116 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, { ' ', '\0' }};135 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, " ", ", " }; 117 136 ofstream *serr = &serrFile; 118 137 … … 173 192 } // ungetc 174 193 175 int scanfmt( ifstream * is, const char fmt[], ... ) {194 int fmt( ifstream * is, const char format[], ... ) { 176 195 va_list args; 177 196 178 va_start( args, f mt );179 int len = vfscanf( (FILE *)(is->file), f mt, args );197 va_start( args, format ); 198 int len = vfscanf( (FILE *)(is->file), format, args ); 180 199 if ( len == EOF ) { 181 200 if ( ferror( (FILE *)(is->file) ) ) { … … 186 205 va_end( args ); 187 206 return len; 188 } // prtfmt207 } // fmt 189 208 190 209
Note:
See TracChangeset
for help on using the changeset viewer.