Ignore:
Timestamp:
Aug 31, 2021, 1:49:10 AM (3 years ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
Children:
8e0f2db
Parents:
09fda91
git-author:
Jacob Prud'homme <jafprudhomme@…> (08/03/21 00:31:43)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:10)
Message:

Re-simplified code to detect lines with comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    r09fda91 recfa760  
    8686
    8787
    88 bool comments( ifstream & in, char * name ) {
    89         StringBuilder sb;
    90 
    91         char c;
     88bool comments( ifstream & in, char name[] ) {
    9289        while () {
    93                 in | c;
    94                 add_char( sb, c );
    95 
    96                 if ( fail( in ) ) {
    97                         name = alloc( sb.size );
    98                         strcpy( name, sb.string );
    99 
    100                         return true;
    101                 }
    102           if ( c != '#' ) break;
    103                 in | nl;        // ignore remainder of line
    104         } // for
    105 
    106         name = alloc( sb.size );
    107         strcpy( name, sb.string );
    108 
    109         return false;
     90                in | name;
     91          if ( eof( in ) ) return true;
     92          if ( name[0] != '#' ) return false;
     93                in | nl;                                                                        // ignore remainder of line
     94        } // while
    11095} // comments
    11196
Note: See TracChangeset for help on using the changeset viewer.