aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichiesams2013-07-05 20:14:50 -0500
committerrichiesams2013-08-04 13:31:59 -0500
commit3f93f7d27fe58690a4b94c22247bb00a9af2c92e (patch)
tree69a8fb74da478da5e0048f002dd1a85164464c3a
parent3822de2aec0d41df7c2beeb5a1269577e9c3df84 (diff)
downloadscummvm-rg350-3f93f7d27fe58690a4b94c22247bb00a9af2c92e.tar.gz
scummvm-rg350-3f93f7d27fe58690a4b94c22247bb00a9af2c92e.tar.bz2
scummvm-rg350-3f93f7d27fe58690a4b94c22247bb00a9af2c92e.zip
ZVISION: Change trimCommentsAndWhiteSpace to use a pointer instead of a reference.
-rw-r--r--engines/zvision/scr_file_handling.cpp14
-rw-r--r--engines/zvision/utility.h11
2 files changed, 13 insertions, 12 deletions
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index eb867fa0a2..285e635c61 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -46,7 +46,7 @@ void ScriptManager::parseScrFile(Common::String fileName) {
return;
}
- trimCommentsAndWhiteSpace(line);
+ trimCommentsAndWhiteSpace(&line);
if (line.empty())
continue;
@@ -69,7 +69,7 @@ void ScriptManager::parseScrFile(Common::String fileName) {
void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stream) {
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(line);
+ trimCommentsAndWhiteSpace(&line);
while (!line.contains('}')) {
if (line.matchString("criteria {", true))
@@ -86,7 +86,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(line);
+ trimCommentsAndWhiteSpace(&line);
while (!line.contains('}')) {
// Split the string into tokens using ' ' as a delimiter
@@ -120,7 +120,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(line);
+ trimCommentsAndWhiteSpace(&line);
}
return criteria;
@@ -129,7 +129,7 @@ Criteria ScriptManager::parseCriteria(Common::SeekableReadStream &stream) const
void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const {
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(line);
+ trimCommentsAndWhiteSpace(&line);
// TODO: Re-order the if-then statements in order of highest occurrence
while (!line.contains('}')) {
@@ -253,7 +253,7 @@ void ScriptManager::parseResult(Common::SeekableReadStream &stream, Common::List
}
line = stream.readLine();
- trimCommentsAndWhiteSpace(line);
+ trimCommentsAndWhiteSpace(&line);
}
return;
@@ -264,7 +264,7 @@ byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
// Loop until we find the closing brace
Common::String line = stream.readLine();
- trimCommentsAndWhiteSpace(line);
+ trimCommentsAndWhiteSpace(&line);
while (!line.contains('}')) {
if (line.matchString("ONCE_PER_INST", true)) {
diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h
index 4d124509ba..511b3c12f2 100644
--- a/engines/zvision/utility.h
+++ b/engines/zvision/utility.h
@@ -59,14 +59,15 @@ void writeFileContentsToFile(Common::String sourceFile, Common::String destFile)
*
* @param string The string to modify. It is modified in place
*/
-void trimCommentsAndWhiteSpace(Common::String &string) {
- for (int i = string.size(); i >= 0; --i) {
- if (string[i] == '#') {
- string.erase(i);
+void trimCommentsAndWhiteSpace(Common::String *string) {
+ for (int i = string->size() - 1; i >= 0; i--) {
+ if ((*string)[i] == '#') {
+ string->erase(i);
}
}
- string.trim();
+ string->trim();
+}
}
} // End of namespace ZVision