Ignore:
Timestamp:
Aug 17, 2024, 3:15:21 PM (7 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
df2e00f
Parents:
afb15cf
Message:

first attempt changing end-of-file to an exception

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    rafb15cf r3ac5fd8  
    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.