- Timestamp:
- Aug 31, 2021, 1:49:10 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
- Children:
- cfadd08
- Parents:
- ecfa760
- git-author:
- Jacob Prud'homme <jafprudhomme@…> (08/03/21 00:54:33)
- git-committer:
- Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:10)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/parseconfig.cfa
recfa760 r8e0f2db 97 97 // Parse configuration from a file formatted in shell style 98 98 KVPairs & parse_tabular_config_format( const char * config_file, size_t num_entries ) { 99 // * KVPairs kv_pairs;100 99 KVPairs kv_pairs = { num_entries }; 100 101 char key[64]; 102 char value[256]; 101 103 102 104 try { … … 104 106 105 107 while () { 106 // * char key; 107 // * char value; 108 // if ( comments( in, key ) ) break; // eof ? 109 110 // THE CODE BELOW IS TEMPORARY, TO TRY AND GET SOMETHING WORKING 111 112 // Right now doesn't handle duplicate keys. Should use hashmap for that 113 char c; 114 [1024] char key; 115 [1024] char value; 116 //StringBuilder key_sb; 117 //StringBuilder value_sb; 118 119 // Doesn't handle comments 120 in | key; 121 /* 122 while () { 123 in | c; 124 if ( c == ' ' || c == '\t' ) { 125 while ( c == ' ' || c == '\t' ) in | c; 126 break; 127 } else { 128 add_char( key_sb, c ); 129 } 130 } 131 */ 132 133 //* char key = alloc( key_sb.size ); 134 //strcpy( key, key_sb.string ); 135 136 // Doesn't handle comments 108 for ( Parmnum ) { // parameter names can appear in any order 109 if ( comments( in, key ) ) break; // eof ? 110 for ( posn = 0; posn < Parmnum && strcmp( name, parms[posn].name ) != 0; posn += 1 ); // linear search 111 if ( posn == Parmnum ) break; // configuration not found ? 112 if ( parms[posn].value != 0 ) break; // duplicate configuration ? 137 113 in | value; 138 /*139 while () {140 in | c;141 if ( c == ' ' || c == '\t' || c == '\n' ) break;142 add_char( value_sb, c );143 }144 */145 146 //* char value = alloc( value_sb.size );147 //strcpy( value, value_sb.string );148 114 149 115 add_kv_pair( kv_pairs, key, value ); 150 116 151 if ( fail( in ) ) break; 152 in | nl; // ignore remainder of line 117 if ( eof( in ) ) break; 118 in | nl; // ignore remainder of line 119 numOfParms += 1; 120 parms[posn].value = value; 153 121 } // for 154 122 } catch( Open_Failure * ex; ex->istream == &in ) {
Note: See TracChangeset
for help on using the changeset viewer.