From 383f34e7453eaf595432a4514609fe11f9ba4e2c Mon Sep 17 00:00:00 2001 From: Lanchid Date: Wed, 19 Dec 2012 20:25:50 +0100 Subject: [PATCH] Function renaming --- src/parser/AtomicPropositionLabelingParser.cpp | 2 +- src/parser/DeterministicSparseTransitionParser.cpp | 8 ++++---- src/parser/Parser.cpp | 5 ++++- src/parser/Parser.h | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/parser/AtomicPropositionLabelingParser.cpp b/src/parser/AtomicPropositionLabelingParser.cpp index 1f307450a..8469f8ef0 100644 --- a/src/parser/AtomicPropositionLabelingParser.cpp +++ b/src/parser/AtomicPropositionLabelingParser.cpp @@ -177,7 +177,7 @@ AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t n buf += cnt; } } - buf = skipWS(buf); + buf = trimWhitespaces(buf); } } } diff --git a/src/parser/DeterministicSparseTransitionParser.cpp b/src/parser/DeterministicSparseTransitionParser.cpp index 2c4f86c04..d5dd504c1 100644 --- a/src/parser/DeterministicSparseTransitionParser.cpp +++ b/src/parser/DeterministicSparseTransitionParser.cpp @@ -54,7 +54,7 @@ uint_fast64_t DeterministicSparseTransitionParser::firstPass(char* buf, uint_fas } buf += 7; // skip "STATES " if (strtol(buf, &buf, 10) == 0) return 0; - buf = skipWS(buf); + buf = trimWhitespaces(buf); if (strncmp(buf, "TRANSITIONS ", 12) != 0) { LOG4CPLUS_ERROR(logger, "Expected \"TRANSITIONS\" but got \"" << std::string(buf, 0, 16) << "\"."); return 0; @@ -90,7 +90,7 @@ uint_fast64_t DeterministicSparseTransitionParser::firstPass(char* buf, uint_fas return 0; } if (row == col) non_zero--; - buf = skipWS(tmp); + buf = trimWhitespaces(tmp); } return non_zero; @@ -145,7 +145,7 @@ DeterministicSparseTransitionParser::DeterministicSparseTransitionParser(std::st */ buf += 7; // skip "STATES " checked_strtol(buf, &buf); - buf = skipWS(buf); + buf = trimWhitespaces(buf); buf += 12; // skip "TRANSITIONS " checked_strtol(buf, &buf); @@ -179,7 +179,7 @@ DeterministicSparseTransitionParser::DeterministicSparseTransitionParser(std::st val = strtod(buf, &buf); this->matrix->addNextValue(row,col,val); - buf = skipWS(buf); + buf = trimWhitespaces(buf); } /* diff --git a/src/parser/Parser.cpp b/src/parser/Parser.cpp index 1e25ee404..cbcfc0b57 100644 --- a/src/parser/Parser.cpp +++ b/src/parser/Parser.cpp @@ -34,7 +34,10 @@ uint_fast64_t mrmc::parser::Parser::checked_strtol(const char* str, char** end) * @param buf String buffer * @return pointer to first non-whitespace character */ -char* mrmc::parser::Parser::skipWS(char* buf) { +char* mrmc::parser::Parser::trimWhitespaces(char* buf) { + /*TODO: Maybe use memcpy to copy all the stuff from the first non-whitespace char + * to the position of the buffer, so we don't have to keep track of 2 pointers. + */ while ((*buf == ' ') || (*buf == '\t') || (*buf == '\n') || (*buf == '\r')) buf++; return buf; } diff --git a/src/parser/Parser.h b/src/parser/Parser.h index 81938ecf7..03f6f002a 100644 --- a/src/parser/Parser.h +++ b/src/parser/Parser.h @@ -106,7 +106,7 @@ namespace parser { /*! * @brief Skips common whitespaces in a string. */ - char* skipWS(char* buf); + char* trimWhitespaces(char* buf); }; } // namespace parser