Changeset e4b37a1
- 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:
- ad78e08
- Parents:
- 12b5b226
- git-author:
- Jacob Prud'homme <jafprudhomme@…> (08/03/21 13:23:35)
- git-committer:
- Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:10)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/parseconfig.cfa
r12b5b226 re4b37a1 24 24 25 25 struct KVPairs { 26 int size, max_size;26 unsigned int size, max_size; 27 27 * [ char *, char * ] data; 28 28 }; … … 30 30 size = 0; max_size = 0; data = 0p; 31 31 } 32 void ?{}( KVPairs & kvp, int size ) {// initialization32 void ?{}( KVPairs & kvp, size_t size ) { // initialization 33 33 kvp.[ size, max_size ] = [ 0, size ]; 34 34 kvp.data = alloc( size ); … … 64 64 // Parse configuration from a file formatted in shell style 65 65 KVPairs & parse_tabular_config_format( const char * config_file, size_t num_entries ) { 66 KVPairs kv_pairs = { num_entries };66 * KVPairs kv_pairs = new( num_entries ); 67 67 68 68 ifstream in; … … 79 79 in | value; 80 80 81 add_kv_pair( kv_pairs, key, value );81 add_kv_pair( *kv_pairs, key, value ); 82 82 83 83 if ( eof( in ) ) break; … … 85 85 } // for 86 86 } catch( Open_Failure * ex; ex->istream == &in ) { 87 ^ kv_pairs{};87 ^(*kv_pairs){}; 88 88 exit | "Error: could not open input file \"" | config_file | "\""; 89 89 } // try 90 90 close( in ); 91 91 92 return kv_pairs;92 return *kv_pairs; 93 93 } 94 94 95 95 // Parse configuration values from intermediate format 96 96 void parse_config( const char * config_file, config_entry entries[], size_t num_entries ) { 97 KVPairs kv_pairs = parse_tabular_config_format( config_file, num_entries );97 KVPairs & kv_pairs = parse_tabular_config_format( config_file, num_entries ); 98 98 99 99 int entries_so_far = 0;
Note: See TracChangeset
for help on using the changeset viewer.