Changeset 8a25be9
- Timestamp:
- Mar 28, 2019, 6:35:11 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- bee653c
- Parents:
- ce3d305
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/fstream.cfa
rce3d305 r8a25be9 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 24 18:33:38 201813 // Update Count : 30 412 // Last Modified On : Thu Mar 28 17:39:53 2019 13 // Update Count : 307 14 14 // 15 15 … … 23 23 #include <complex.h> // creal, cimag 24 24 #include <assert.h> 25 #include <errno.h> // errno 25 26 26 27 #define IO_MSG "I/O error: " … … 105 106 #ifdef __CFA_DEBUG__ 106 107 if ( file == 0 ) { 107 fprintf( stderr, IO_MSG "open output file \"%s\", ", name ); 108 perror( 0 ); 109 exit( EXIT_FAILURE ); 108 abort( IO_MSG "open output file \"%s\", %s", name, strerror( errno ) ); 110 109 } // if 111 110 #endif // __CFA_DEBUG__ … … 121 120 122 121 if ( fclose( (FILE *)(os.file) ) == EOF ) { 123 perror( IO_MSG "close output");122 abort( IO_MSG "close output %s", strerror( errno ) ); 124 123 } // if 125 124 } // close … … 127 126 ofstream & write( ofstream & os, const char * data, size_t size ) { 128 127 if ( fail( os ) ) { 129 fprintf( stderr, "attempt write I/O on failed stream\n" ); 130 exit( EXIT_FAILURE ); 128 abort( "attempt write I/O on failed stream\n" ); 131 129 } // if 132 130 133 131 if ( fwrite( data, 1, size, (FILE *)(os.file) ) != size ) { 134 perror( IO_MSG "write" ); 135 exit( EXIT_FAILURE ); 132 abort( IO_MSG "write %s", strerror( errno ) ); 136 133 } // if 137 134 return os; … … 144 141 if ( len == EOF ) { 145 142 if ( ferror( (FILE *)(os.file) ) ) { 146 fprintf( stderr, "invalid write\n" ); 147 exit( EXIT_FAILURE ); 143 abort( "invalid write\n" ); 148 144 } // if 149 145 } // if … … 187 183 188 184 void open( ifstream & is, const char * name, const char * mode ) { 189 FILE * file = fopen( name, mode );185 FILE * file = fopen( name, mode ); 190 186 #ifdef __CFA_DEBUG__ 191 187 if ( file == 0 ) { 192 fprintf( stderr, IO_MSG "open input file \"%s\", ", name ); 193 perror( 0 ); 194 exit( EXIT_FAILURE ); 188 abort( IO_MSG "open input file \"%s\", %s\n", name, strerror( errno ) ); 195 189 } // if 196 190 #endif // __CFA_DEBUG__ … … 206 200 207 201 if ( fclose( (FILE *)(is.file) ) == EOF ) { 208 perror( IO_MSG "close input");202 abort( IO_MSG "close input %s", strerror( errno ) ); 209 203 } // if 210 204 } // close … … 212 206 ifstream & read( ifstream & is, char * data, size_t size ) { 213 207 if ( fail( is ) ) { 214 fprintf( stderr, "attempt read I/O on failed stream\n" ); 215 exit( EXIT_FAILURE ); 208 abort( "attempt read I/O on failed stream\n" ); 216 209 } // if 217 210 218 211 if ( fread( data, size, 1, (FILE *)(is.file) ) == 0 ) { 219 perror( IO_MSG "read" ); 220 exit( EXIT_FAILURE ); 212 abort( IO_MSG "read %s", strerror( errno ) ); 221 213 } // if 222 214 return is; … … 225 217 ifstream &ungetc( ifstream & is, char c ) { 226 218 if ( fail( is ) ) { 227 fprintf( stderr, "attempt ungetc I/O on failed stream\n" ); 228 exit( EXIT_FAILURE ); 219 abort( "attempt ungetc I/O on failed stream\n" ); 229 220 } // if 230 221 231 222 if ( ungetc( c, (FILE *)(is.file) ) == EOF ) { 232 perror( IO_MSG "ungetc" ); 233 exit( EXIT_FAILURE ); 223 abort( IO_MSG "ungetc %s", strerror( errno ) ); 234 224 } // if 235 225 return is; … … 243 233 if ( len == EOF ) { 244 234 if ( ferror( (FILE *)(is.file) ) ) { 245 fprintf( stderr, "invalid read\n" ); 246 exit( EXIT_FAILURE ); 235 abort( "invalid read\n" ); 247 236 } // if 248 237 } // if -
libcfa/src/rational.cfa
rce3d305 r8a25be9 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 27 08:45:59201913 // Update Count : 18 012 // Last Modified On : Thu Mar 28 17:33:03 2019 13 // Update Count : 181 14 14 // 15 15 … … 35 35 static RationalImpl simplify( RationalImpl & n, RationalImpl & d ) { 36 36 if ( d == (RationalImpl){0} ) { 37 serr | "Invalid rational number construction: denominator cannot be equal to 0."; 38 exit( EXIT_FAILURE ); 37 abort( "Invalid rational number construction: denominator cannot be equal to 0.\n" ); 39 38 } // exit 40 39 if ( d < (RationalImpl){0} ) { d = -d; n = -n; } // move sign to numerator
Note: See TracChangeset
for help on using the changeset viewer.