Changeset 2fabdc02


Ignore:
Timestamp:
Apr 1, 2019, 2:04:19 PM (5 years ago)
Author:
tdelisle <tdelisle@…>
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:
13363f4, 16a6a617, b2f6113
Parents:
212c2187 (diff), bee653c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.cfa

    r212c2187 r2fabdc02  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 24 18:33:38 2018
    13 // Update Count     : 304
     12// Last Modified On : Thu Mar 28 17:39:53 2019
     13// Update Count     : 307
    1414//
    1515
     
    2323#include <complex.h>                                                                    // creal, cimag
    2424#include <assert.h>
     25#include <errno.h>                                                                              // errno
    2526
    2627#define IO_MSG "I/O error: "
     
    105106        #ifdef __CFA_DEBUG__
    106107        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 ) );
    110109        } // if
    111110        #endif // __CFA_DEBUG__
     
    121120
    122121        if ( fclose( (FILE *)(os.file) ) == EOF ) {
    123                 perror( IO_MSG "close output" );
     122                abort( IO_MSG "close output %s", strerror( errno ) );
    124123        } // if
    125124} // close
     
    127126ofstream & write( ofstream & os, const char * data, size_t size ) {
    128127        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" );
    131129        } // if
    132130
    133131        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 ) );
    136133        } // if
    137134        return os;
     
    144141        if ( len == EOF ) {
    145142                if ( ferror( (FILE *)(os.file) ) ) {
    146                         fprintf( stderr, "invalid write\n" );
    147                         exit( EXIT_FAILURE );
     143                        abort( "invalid write\n" );
    148144                } // if
    149145        } // if
     
    187183
    188184void open( ifstream & is, const char * name, const char * mode ) {
    189         FILE *file = fopen( name, mode );
     185        FILE * file = fopen( name, mode );
    190186        #ifdef __CFA_DEBUG__
    191187        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 ) );
    195189        } // if
    196190        #endif // __CFA_DEBUG__
     
    206200
    207201        if ( fclose( (FILE *)(is.file) ) == EOF ) {
    208                 perror( IO_MSG "close input" );
     202                abort( IO_MSG "close input %s", strerror( errno ) );
    209203        } // if
    210204} // close
     
    212206ifstream & read( ifstream & is, char * data, size_t size ) {
    213207        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" );
    216209        } // if
    217210
    218211        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 ) );
    221213        } // if
    222214        return is;
     
    225217ifstream &ungetc( ifstream & is, char c ) {
    226218        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" );
    229220        } // if
    230221
    231222        if ( ungetc( c, (FILE *)(is.file) ) == EOF ) {
    232                 perror( IO_MSG "ungetc" );
    233                 exit( EXIT_FAILURE );
     223                abort( IO_MSG "ungetc %s", strerror( errno ) );
    234224        } // if
    235225        return is;
     
    243233        if ( len == EOF ) {
    244234                if ( ferror( (FILE *)(is.file) ) ) {
    245                         fprintf( stderr, "invalid read\n" );
    246                         exit( EXIT_FAILURE );
     235                        abort( "invalid read\n" );
    247236                } // if
    248237        } // if
  • libcfa/src/rational.cfa

    r212c2187 r2fabdc02  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar 27 08:45:59 2019
    13 // Update Count     : 180
     12// Last Modified On : Thu Mar 28 17:33:03 2019
     13// Update Count     : 181
    1414//
    1515
     
    3535        static RationalImpl simplify( RationalImpl & n, RationalImpl & d ) {
    3636                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" );
    3938                } // exit
    4039                if ( d < (RationalImpl){0} ) { d = -d; n = -n; } // move sign to numerator
Note: See TracChangeset for help on using the changeset viewer.