Ignore:
Timestamp:
Jun 19, 2023, 1:57:11 PM (2 years ago)
Author:
caparson <caparson@…>
Branches:
master
Children:
adc73a5
Parents:
fa5e1aa5 (diff), 33d4bc8 (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/fstream.cfa

    rfa5e1aa5 rb7b3e41  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr  9 14:55:54 2022
    13 // Update Count     : 515
     12// Last Modified On : Sat Jun 17 08:51:12 2023
     13// Update Count     : 528
    1414//
    1515
     
    117117    } // for
    118118        if ( file == 0p ) {
    119                 throw (Open_Failure){ os };
     119                throw (open_failure){ os };
    120120                // abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno );
    121121        } // if
     
    137137    } // for
    138138        if ( ret == EOF ) {
    139                 throw (Close_Failure){ os };
     139                throw (close_failure){ os };
    140140                // abort | IO_MSG "close output" | nl | strerror( errno );
    141141        } // if
     
    145145ofstream & write( ofstream & os, const char data[], size_t size ) {
    146146        if ( fail( os ) ) {
    147                 throw (Write_Failure){ os };
     147                throw (write_failure){ os };
    148148                // abort | IO_MSG "attempt write I/O on failed stream";
    149149        } // if
    150150
    151151        if ( fwrite( data, 1, size, (FILE *)(os.file$) ) != size ) {
    152                 throw (Write_Failure){ os };
     152                throw (write_failure){ os };
    153153                // abort | IO_MSG "write" | nl | strerror( errno );
    154154        } // if
     
    169169          if ( cnt == 9 ) abort( "ofstream fmt EINTR spinning exceeded" );
    170170    } // for
    171         if ( len == EOF ) {
    172                 if ( ferror( (FILE *)(os.file$) ) ) {
    173                         abort | IO_MSG "invalid write";
    174                 } // if
     171        if ( len == EOF ) {                                                                     // error writing ?
     172                abort | IO_MSG "invalid write";
    175173        } // if
    176174        va_end( args );
     
    240238    } // for
    241239        if ( file == 0p ) {
    242                 throw (Open_Failure){ is };
     240                throw (open_failure){ is };
    243241                // abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno );
    244242        } // if
     
    260258    } // for
    261259        if ( ret == EOF ) {
    262                 throw (Close_Failure){ is };
     260                throw (close_failure){ is };
    263261                // abort | IO_MSG "close input" | nl | strerror( errno );
    264262        } // if
     
    268266ifstream & read( ifstream & is, char data[], size_t size ) {
    269267        if ( fail( is ) ) {
    270                 throw (Read_Failure){ is };
     268                throw (read_failure){ is };
    271269                // abort | IO_MSG "attempt read I/O on failed stream";
    272270        } // if
    273271
    274272        if ( fread( data, size, 1, (FILE *)(is.file$) ) == 0 ) {
    275                 throw (Read_Failure){ is };
     273                throw (read_failure){ is };
    276274                // abort | IO_MSG "read" | nl | strerror( errno );
    277275        } // if
     
    302300          if ( len != EOF || errno != EINTR ) break;            // timer interrupt ?
    303301    } // for
    304         if ( len == EOF ) {
    305                 if ( ferror( (FILE *)(is.file$) ) ) {
     302        if ( len == EOF ) {                                                                     // EOF or matching failure ?
     303                if ( ! feof( (FILE *)(is.file$) ) && ferror( (FILE *)(is.file$) ) ) {
    306304                        abort | IO_MSG "invalid read";
    307305                } // if
     
    318316
    319317
    320 static vtable(Open_Failure) Open_Failure_vt;
     318static vtable(open_failure) open_failure_vt;
    321319
    322320// exception I/O constructors
    323 void ?{}( Open_Failure & ex, ofstream & ostream ) with(ex) {
    324         virtual_table = &Open_Failure_vt;
     321void ?{}( open_failure & ex, ofstream & ostream ) with(ex) {
     322        virtual_table = &open_failure_vt;
    325323        ostream = &ostream;
    326324        tag = 1;
    327325} // ?{}
    328326
    329 void ?{}( Open_Failure & ex, ifstream & istream ) with(ex) {
    330         virtual_table = &Open_Failure_vt;
     327void ?{}( open_failure & ex, ifstream & istream ) with(ex) {
     328        virtual_table = &open_failure_vt;
    331329        istream = &istream;
    332330        tag = 0;
     
    334332
    335333
    336 static vtable(Close_Failure) Close_Failure_vt;
     334static vtable(close_failure) close_failure_vt;
    337335
    338336// exception I/O constructors
    339 void ?{}( Close_Failure & ex, ofstream & ostream ) with(ex) {
    340         virtual_table = &Close_Failure_vt;
     337void ?{}( close_failure & ex, ofstream & ostream ) with(ex) {
     338        virtual_table = &close_failure_vt;
    341339        ostream = &ostream;
    342340        tag = 1;
    343341} // ?{}
    344342
    345 void ?{}( Close_Failure & ex, ifstream & istream ) with(ex) {
    346         virtual_table = &Close_Failure_vt;
     343void ?{}( close_failure & ex, ifstream & istream ) with(ex) {
     344        virtual_table = &close_failure_vt;
    347345        istream = &istream;
    348346        tag = 0;
     
    350348
    351349
    352 static vtable(Write_Failure) Write_Failure_vt;
     350static vtable(write_failure) write_failure_vt;
    353351
    354352// exception I/O constructors
    355 void ?{}( Write_Failure & ex, ofstream & ostream ) with(ex) {
    356         virtual_table = &Write_Failure_vt;
     353void ?{}( write_failure & ex, ofstream & ostream ) with(ex) {
     354        virtual_table = &write_failure_vt;
    357355        ostream = &ostream;
    358356        tag = 1;
    359357} // ?{}
    360358
    361 void ?{}( Write_Failure & ex, ifstream & istream ) with(ex) {
    362         virtual_table = &Write_Failure_vt;
     359void ?{}( write_failure & ex, ifstream & istream ) with(ex) {
     360        virtual_table = &write_failure_vt;
    363361        istream = &istream;
    364362        tag = 0;
     
    366364
    367365
    368 static vtable(Read_Failure) Read_Failure_vt;
     366static vtable(read_failure) read_failure_vt;
    369367
    370368// exception I/O constructors
    371 void ?{}( Read_Failure & ex, ofstream & ostream ) with(ex) {
    372         virtual_table = &Read_Failure_vt;
     369void ?{}( read_failure & ex, ofstream & ostream ) with(ex) {
     370        virtual_table = &read_failure_vt;
    373371        ostream = &ostream;
    374372        tag = 1;
    375373} // ?{}
    376374
    377 void ?{}( Read_Failure & ex, ifstream & istream ) with(ex) {
    378         virtual_table = &Read_Failure_vt;
     375void ?{}( read_failure & ex, ifstream & istream ) with(ex) {
     376        virtual_table = &read_failure_vt;
    379377        istream = &istream;
    380378        tag = 0;
    381379} // ?{}
    382380
    383 // void throwOpen_Failure( ofstream & ostream ) {
    384 //      Open_Failure exc = { ostream };
     381// void throwopen_failure( ofstream & ostream ) {
     382//      open_failure exc = { ostream };
    385383// }
    386384
    387 // void throwOpen_Failure( ifstream & istream ) {
    388 //      Open_Failure exc = { istream };
     385// void throwopen_failure( ifstream & istream ) {
     386//      open_failure exc = { istream };
    389387// }
    390388
Note: See TracChangeset for help on using the changeset viewer.