Changes in src/libcfa/fstream.c [829c907:6152c81]
- File:
-
- 1 edited
-
src/libcfa/fstream.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/fstream.c
r829c907 r6152c81 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 21 20:56:10201713 // Update Count : 21512 // Last Modified On : Tue Mar 7 14:48:09 2017 13 // Update Count : 192 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 39 35 const char * sepGet( ofstream * os ) { return &(os->separator[0]); } 40 36 … … 42 38 strncpy( &(os->separator[0]), s, separateSize - 1 ); 43 39 os->separator[separateSize - 1] = '\0'; 44 } // sepSet45 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';51 40 } // sepSet 52 41 … … 106 95 } // write 107 96 108 int fmt( ofstream * os, const char format[], ... ) {97 int prtfmt( ofstream * os, const char fmt[], ... ) { 109 98 va_list args; 110 va_start( args, f ormat );111 int len = vfprintf( (FILE *)(os->file), f ormat, args );99 va_start( args, fmt ); 100 int len = vfprintf( (FILE *)(os->file), fmt, args ); 112 101 if ( len == EOF ) { 113 102 if ( ferror( (FILE *)(os->file) ) ) { … … 120 109 sepReset( os ); // reset separator 121 110 return len; 122 } // fmt111 } // prtfmt 123 112 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 113 133 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, " ", ", "};114 static ofstream soutFile = { (FILE *)(&_IO_2_1_stdout_), 1, 0, { ' ', '\0' } }; 134 115 ofstream *sout = &soutFile; 135 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, " ", ", "};116 static ofstream serrFile = { (FILE *)(&_IO_2_1_stderr_), 1, 0, { ' ', '\0' } }; 136 117 ofstream *serr = &serrFile; 137 118 … … 192 173 } // ungetc 193 174 194 int fmt( ifstream * is, const char format[], ... ) {175 int scanfmt( ifstream * is, const char fmt[], ... ) { 195 176 va_list args; 196 177 197 va_start( args, f ormat );198 int len = vfscanf( (FILE *)(is->file), f ormat, args );178 va_start( args, fmt ); 179 int len = vfscanf( (FILE *)(is->file), fmt, args ); 199 180 if ( len == EOF ) { 200 181 if ( ferror( (FILE *)(is->file) ) ) { … … 205 186 va_end( args ); 206 187 return len; 207 } // fmt188 } // prtfmt 208 189 209 190
Note:
See TracChangeset
for help on using the changeset viewer.