Changeset 960665c for libcfa


Ignore:
Timestamp:
Aug 20, 2024, 6:15:01 PM (8 weeks ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
ad47ec4
Parents:
d1f5054 (diff), df2e00f (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:
6 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/collections/string_res.cfa

    rd1f5054 r960665c  
    1010// Created On       : Fri Sep 03 11:00:00 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr 15 21:56:27 2024
    13 // Update Count     : 85
     12// Last Modified On : Sat Aug 17 14:08:01 2024
     13// Update Count     : 86
    1414//
    1515
     
    251251
    252252ifstream & ?|?( ifstream & is, _Istream_Rquoted f ) with( f.rstr ) {
    253         if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     253        if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    254254        int args;
    255255  fini: {
  • libcfa/src/enum.cfa

    rd1f5054 r960665c  
    4040istype & ?|?( istype & is, E & e ) {
    4141//      fprintf( stderr, "here0\n" );
    42         if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     42        if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    4343
    4444        // Match longest input enumerator string to enumerator labels, where enumerator names are unique.
     
    5959
    6060        fmt( is, " " );                                                                         // skip optional whitespace
     61        if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
     62
    6163        for ( c; max ) {                                                                        // scan columns of the label matix (some columns missing)
    6264                int args = fmt( is, "%c", &ch );                                // read character
  • libcfa/src/heap.cfa

    rd1f5054 r960665c  
    354354};
    355355
    356 static_assert( NoBucketSizes == sizeof(bucketSizes) / sizeof(bucketSizes[0] ), "size of bucket array wrong" );
     356static_assert( sizeof(bucketSizes) == NoBucketSizes * sizeof(unsigned int), "size of bucket array wrong" );
    357357
    358358
  • libcfa/src/iostream.cfa

    rd1f5054 r960665c  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug  2 07:38:44 2024
    13 // Update Count     : 2021
     12// Last Modified On : Sat Aug 17 12:31:47 2024
     13// Update Count     : 2038
    1414//
    1515
     
    777777forall( istype & | basic_istream( istype ) ) {
    778778        istype & ?|?( istype & is, bool & b ) {
    779                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     779                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    780780                int len = -1;                                                                   // len not set if no match
    781                 // Optional leading whitespace at start of strings.
     781                // remove optional leading whitespace at start of strings.
    782782                fmt( is, " " FALSE "%n", &len );                                // try false
    783783                if ( len != sizeof( FALSE ) - 1 ) {                             // -1 removes null terminate
     
    792792
    793793        istype & ?|?( istype & is, char & c ) {
    794                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     794                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    795795                char temp;
    796796                for () {
    797797                        int args = fmt( is, "%c", &temp );
    798                         if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     798                        if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
     799                        assert( args == 1 );                                            // if not EOF => a single character must be read
    799800                        // do not overwrite parameter with newline unless appropriate
    800801                        if ( temp != '\n' || getANL$( is ) ) { c = temp; break; }
    801                         if ( eof( is ) ) break;
    802802                } // for
    803803                return is;
     
    805805
    806806        istype & ?|?( istype & is, signed char & sc ) {
    807                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
    808                 int args = fmt( is, "%hhi", &sc );
    809                 if ( args != 1 ) throwResume ExceptionInst( missing_data );
     807                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
     808                int args = fmt( is, "%hhi", &sc );                              // can be multiple characters (100)
     809                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
    810810                return is;
    811811        } // ?|?
    812812
    813813        istype & ?|?( istype & is, unsigned char & usc ) {
    814                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
    815                 int args = fmt( is, "%hhi", &usc );
     814                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
     815                int args = fmt( is, "%hhi", &usc );                             // can be multiple characters (-100)
    816816                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
    817817                return is;
     
    819819
    820820        istype & ?|?( istype & is, short int & si ) {
    821                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     821                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    822822                int args = fmt( is, "%hi", &si );
    823823                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    826826
    827827        istype & ?|?( istype & is, unsigned short int & usi ) {
    828                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     828                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    829829                int args = fmt( is, "%hi", &usi );
    830830                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    833833
    834834        istype & ?|?( istype & is, int & i ) {
    835                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     835                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    836836                int args = fmt( is, "%i", &i );
    837837                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    840840
    841841        istype & ?|?( istype & is, unsigned int & ui ) {
    842                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     842                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    843843                int args = fmt( is, "%i", &ui );
    844844                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    847847
    848848        istype & ?|?( istype & is, long int & li ) {
    849                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     849                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    850850                int args = fmt( is, "%li", &li );
    851851                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    854854
    855855        istype & ?|?( istype & is, unsigned long int & ulli ) {
    856                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     856                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    857857                int args = fmt( is, "%li", &ulli );
    858858                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    861861
    862862        istype & ?|?( istype & is, long long int & lli ) {
    863                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     863                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    864864                int args = fmt( is, "%lli", &lli );
    865865                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    868868
    869869        istype & ?|?( istype & is, unsigned long long int & ulli ) {
    870                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     870                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    871871                int args = fmt( is, "%lli", &ulli );
    872872                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    891891                        } // for
    892892                        if ( sign ) ullli = -ullli;
    893                 } else if ( sign ) ungetc( '-', is );                   // return minus when no digits
     893                } // if
    894894                return is;
    895895        } // ?|?
     
    897897
    898898        istype & ?|?( istype & is, float & f ) {
    899                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     899                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    900900                int args = fmt( is, "%f", &f );
    901901                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    904904
    905905        istype & ?|?( istype & is, double & d ) {
    906                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     906                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    907907                int args = fmt( is, "%lf", &d );
    908908                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    911911
    912912        istype & ?|?( istype & is, long double & ld ) {
    913                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     913                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    914914                int args = fmt( is, "%Lf", &ld );
    915915                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
     
    918918
    919919        istype & ?|?( istype & is, float _Complex & fc ) {
    920                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     920                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    921921                float re, im;
    922922                int args = fmt( is, "%f%fi", &re, &im );
     
    927927
    928928        istype & ?|?( istype & is, double _Complex & dc ) {
    929                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     929                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    930930                double re, im;
    931931                int args = fmt( is, "%lf%lfi", &re, &im );
     
    936936
    937937        istype & ?|?( istype & is, long double _Complex & ldc ) {
    938                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     938                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    939939                long double re, im;
    940940                int args = fmt( is, "%Lf%Lfi", &re, &im );
     
    945945
    946946        istype & ?|?( istype & is, const char fmt[] ) {         // match text
    947                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     947                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    948948                size_t len = strlen( fmt );
    949949                char fmtstr[len + 16];
     
    953953                // scanf cursor does not move if no match
    954954                fmt( is, fmtstr, &len );
    955                 if ( ! eof( is ) && len == -1 ) throwResume ExceptionInst( missing_data );
     955                if ( len == -1 ) throwResume ExceptionInst( missing_data );
    956956                return is;
    957957        } // ?|?
     
    987987forall( istype & | basic_istream( istype ) ) {
    988988        istype & ?|?( istype & is, _Istream_Cskip f ) {
    989                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     989                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    990990                if ( f.scanset ) {
    991991                        int nscanset = strlen(f.scanset);
     
    10001000                        for ( f.wd ) {                                                          // skip N characters
    10011001                                int args = fmt( is, "%c", &ch );
    1002                                 if ( args != 1 ) throwResume ExceptionInst( missing_data );
     1002                                if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data );
    10031003                        } // for
    10041004                } // if
     
    10071007
    10081008        istype & ?|?( istype & is, _Istream_Cquoted f ) with( f.cstr ) {
    1009                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     1009                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    10101010                int args;
    10111011          fini: {
     
    10321032
    10331033        istype & ?|?( istype & is, _Istream_Cstr f ) with( f.cstr ) {
    1034                 if ( eof( is ) ) throwResume ExceptionInst( missing_data );
     1034                if ( eof( is ) ) throwResume ExceptionInst( end_of_file );
    10351035                const char * scanset;
    10361036                size_t nscanset = 0;
  • libcfa/src/iostream.hfa

    rd1f5054 r960665c  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Aug  2 07:37:57 2024
    13 // Update Count     : 760
     12// Last Modified On : Thu Aug 15 18:21:22 2024
     13// Update Count     : 761
    1414//
    1515
     
    374374// *********************************** exceptions ***********************************
    375375
     376ExceptionDecl( end_of_file );                                                   // read encounters end of file
    376377ExceptionDecl( missing_data );                                                  // read finds no appropriate data
    377378ExceptionDecl( cstring_length );                                                // character string size exceeded
  • libcfa/src/parseconfig.cfa

    rd1f5054 r960665c  
    105105
    106106static [ bool ] comments( & ifstream in, size_t size, [] char name ) {
    107         while () {
    108                 in | wdi( size, name );
    109           if ( eof( in ) ) return true;
    110           if ( name[0] != '#' ) return false;
    111                 in | nl;                                                                                // ignore remainder of line
    112         } // while
     107        bool comment = false;
     108        try {
     109                while () {
     110                        in | wdi( size, name );
     111                        if ( name[0] != '#' ) break;
     112                        in | nl;                                                                        // ignore remainder of line
     113                } // while
     114        } catch( end_of_file * ) {
     115                comment = true;
     116        } // try
     117        return comment;
    113118} // comments
    114119
     
    125130                [256] char value;
    126131
    127                 while () {                                                                              // parameter names can appear in any order
    128                         // NOTE: Must add check to see if already read in value for this key,
    129                         // once we switch to using hash table as intermediate storage
    130                   if ( comments( in, 64, key ) ) break;                 // eof ?
    131                         in | wdi( 256, value );
    132 
    133                         add_kv_pair( *kv_pairs, key, value );
    134 
    135                   if ( eof( in ) ) break;
    136                         in | nl;                                                                        // ignore remainder of line
    137                 } // for
     132                try {
     133                        while () {                                                                              // parameter names can appear in any order
     134                                // NOTE: Must add check to see if already read in value for this key,
     135                                // once we switch to using hash table as intermediate storage
     136                                if ( comments( in, 64, key ) ) break;                   // eof ?
     137                                in | wdi( 256, value );
     138
     139                                add_kv_pair( *kv_pairs, key, value );
     140
     141                                in | nl;                                                                        // ignore remainder of line
     142                        } // while
     143                } catch( end_of_file * ) {
     144                } // try
    138145        } catch( open_failure * ex; ex->istream == &in ) {
    139146                delete( kv_pairs );
Note: See TracChangeset for help on using the changeset viewer.