Changeset b431515 for libcfa/src
- Timestamp:
- Apr 24, 2021, 11:29:51 AM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- fec63b2
- Parents:
- 85d8153
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/fstream.cfa
r85d8153 rb431515 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Apr 20 19:04:46 202113 // Update Count : 42 512 // Last Modified On : Sat Apr 24 09:05:16 2021 13 // Update Count : 426 14 14 // 15 15 … … 19 19 #include <stdlib.h> // exit 20 20 #include <stdarg.h> // varargs 21 #include <string.h> // strlen 22 #include <float.h> // DBL_DIG, LDBL_DIG 23 #include <complex.h> // creal, cimag 21 #include <string.h> // strncpy, strerror 24 22 #include <assert.h> 25 23 #include <errno.h> // errno … … 93 91 void sepSet( ofstream & os, const char s[] ) { 94 92 assert( s ); 95 strncpy( os.separator$, s, sepSize - 1 );96 os.separator$[ sepSize - 1] = '\0';93 strncpy( os.separator$, s, ofstream_sepSize - 1 ); 94 os.separator$[ofstream_sepSize - 1] = '\0'; 97 95 } // sepSet 98 96 … … 100 98 void sepSetTuple( ofstream & os, const char s[] ) { 101 99 assert( s ); 102 strncpy( os.tupleSeparator$, s, sepSize - 1 );103 os.tupleSeparator$[ sepSize - 1] = '\0';100 strncpy( os.tupleSeparator$, s, ofstream_sepSize - 1 ); 101 os.tupleSeparator$[ofstream_sepSize - 1] = '\0'; 104 102 } // sepSet 105 103 … … 112 110 } // ends 113 111 114 intfail( ofstream & os ) {112 bool fail( ofstream & os ) { 115 113 return os.file$ == 0 || ferror( (FILE *)(os.file$) ); 116 114 } // fail … … 228 226 bool getANL( ifstream & os ) { return os.nlOnOff$; } 229 227 230 intfail( ifstream & is ) {228 bool fail( ifstream & is ) { 231 229 return is.file$ == 0p || ferror( (FILE *)(is.file$) ); 232 230 } // fail -
libcfa/src/fstream.hfa
r85d8153 rb431515 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Apr 20 19:04:12202113 // Update Count : 21 812 // Last Modified On : Sat Apr 24 09:04:03 2021 13 // Update Count : 219 14 14 // 15 15 … … 24 24 25 25 26 enum { sepSize = 16 };26 enum { ofstream_sepSize = 16 }; 27 27 struct ofstream { 28 28 void * file$; … … 33 33 bool sawNL$; 34 34 const char * sepCur$; 35 char separator$[ sepSize];36 char tupleSeparator$[ sepSize];35 char separator$[ofstream_sepSize]; 36 char tupleSeparator$[ofstream_sepSize]; 37 37 multiple_acquisition_lock lock$; 38 38 bool acquired$; 39 39 }; // ofstream 40 41 // Satisfies ostream 40 42 41 43 // private … … 64 66 void sepSetTuple( ofstream &, const char [] ); 65 67 66 void ends( ofstream & os ); 67 int fail( ofstream & ); 68 void ends( ofstream & ); 69 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 70 71 bool fail( ofstream & ); 68 72 int flush( ofstream & ); 69 73 void open( ofstream &, const char name[], const char mode[] ); … … 71 75 void close( ofstream & ); 72 76 ofstream & write( ofstream &, const char data[], size_t size ); 73 int fmt( ofstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) )); 74 void acquire( ofstream & os);75 void release( ofstream & os);77 78 void acquire( ofstream & ); 79 void release( ofstream & ); 76 80 77 81 struct osacquire { 78 82 ofstream & os; 79 83 }; 80 void ?{}( osacquire & acq, ofstream & os);84 void ?{}( osacquire & acq, ofstream & ); 81 85 void ^?{}( osacquire & acq ); 82 86 83 void ?{}( ofstream & os);84 void ?{}( ofstream & os, const char name[], const char mode[] );85 void ?{}( ofstream & os, const char name[] );86 void ^?{}( ofstream & os);87 void ?{}( ofstream & ); 88 void ?{}( ofstream &, const char name[], const char mode[] ); 89 void ?{}( ofstream &, const char name[] ); 90 void ^?{}( ofstream & ); 87 91 88 92 extern ofstream & sout, & stdout, & serr, & stderr; // aliases … … 100 104 }; // ifstream 101 105 106 // Satisfies istream 107 102 108 // public 103 109 void nlOn( ifstream & ); … … 105 111 bool getANL( ifstream & ); 106 112 void ends( ifstream & ); 107 intfail( ifstream & is );113 bool fail( ifstream & is ); 108 114 int eof( ifstream & is ); 109 115 void open( ifstream & is, const char name[], const char mode[] ); … … 142 148 ); 143 149 144 void ?{}( Open_Failure & this, ofstream & ostream);145 void ?{}( Open_Failure & this, ifstream & istream);150 void ?{}( Open_Failure & this, ofstream & ); 151 void ?{}( Open_Failure & this, ifstream & ); 146 152 147 153 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.