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