From d7eccfd33b074224a0f5dac2fbfa3e00ceee4b44 Mon Sep 17 00:00:00 2001 From: Ryan Long Date: Wed, 20 Oct 2021 16:57:33 -0400 Subject: ConfigFile: Fix formatting --- tester/covoar/ConfigFile.cc | 66 +++++++++++++++++++++++---------------------- tester/covoar/ConfigFile.h | 8 +++--- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/tester/covoar/ConfigFile.cc b/tester/covoar/ConfigFile.cc index 7109b2c..1fbefd1 100644 --- a/tester/covoar/ConfigFile.cc +++ b/tester/covoar/ConfigFile.cc @@ -21,9 +21,7 @@ static void print_invalid_line_number( const std::string& file, int line_no ) namespace Configuration { - FileReader::FileReader( - Options_t *options - ) + FileReader::FileReader( Options_t *options ) { options_m = options; } @@ -32,19 +30,18 @@ namespace Configuration { { } - bool FileReader::processFile( - const std::string& file - ) + bool FileReader::processFile( const std::string& file ) { #define METHOD "FileReader::processFile - " #define MAX_LENGTH 256 + std::ifstream in; std::string line; char option[MAX_LENGTH]; char value[MAX_LENGTH]; - int line_no; - int i; - int j; + int line_no; + int i; + int j; if ( file.empty() ) { std::cerr << METHOD << "Empty filename" << std::endl; @@ -78,7 +75,7 @@ namespace Configuration { * * LHS = RHS # comment */ - for (i=0 ; i=0 && isspace(line[i]) ; i-- ) + for ( i = length - 1; i >= 0 && isspace( line[i] ); i-- ) ; line[i+1] = '\0'; - length = i+1; + length = i + 1; /* Ignore empty lines. We have stripped * all comments and blanks therefore, only * an empty string needs to be checked. */ - if (line[0] == '\0') + if ( line[0] == '\0' ) { continue; + } - if (std::sscanf(line.c_str(), "%s", option) != 1) { - print_invalid_line_number(file, line_no); + if ( std::sscanf( line.c_str(), "%s", option ) != 1 ) { + print_invalid_line_number( file, line_no ); continue; } - for (i=0; ((line[i] != '=') && (ioption ; o++ ) { + for ( o = options_m; o->option; o++ ) { if ( !strcmp( o->option, option ) ) { o->value = strdup( value ); return true; } } + return false; } - const char *FileReader::getOption( - const char* const option - ) + const char *FileReader::getOption( const char* const option ) { Options_t *o; - for ( o=options_m ; o->option ; o++ ) { + for ( o = options_m; o->option; o++ ) { if ( !strcmp( o->option, option ) ) { return o->value; } } + return NULL; } - void FileReader::printOptions(void) + void FileReader::printOptions() { Options_t *o; - for ( o=options_m ; o->option ; o++ ) { + for ( o = options_m; o->option; o++ ) { std::cerr << '(' << o->option << ")=(" << o->value << ')' << std::endl; } } diff --git a/tester/covoar/ConfigFile.h b/tester/covoar/ConfigFile.h index f8bd9c5..0339c12 100644 --- a/tester/covoar/ConfigFile.h +++ b/tester/covoar/ConfigFile.h @@ -53,9 +53,7 @@ namespace Configuration { * * @return Returns TRUE if the method succeeded and FALSE if it failed. */ - virtual bool processFile( - const std::string& file - ); + virtual bool processFile( const std::string& file ); bool setOption( const char* const option, @@ -66,7 +64,7 @@ namespace Configuration { const char* const option ); - void printOptions(void); + void printOptions(); private: /*! @@ -78,7 +76,7 @@ namespace Configuration { * * @return Returns TRUE if the method succeeded and FALSE if it failed. */ - Options_t *options_m; + Options_t* options_m; }; -- cgit v1.2.3