aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/parser.cpp
diff options
context:
space:
mode:
authorNicola Mettifogo2007-02-19 14:09:13 +0000
committerNicola Mettifogo2007-02-19 14:09:13 +0000
commit9bdf145aa0137f6cdd4b811bc45af5786e6a6f68 (patch)
tree21a6d2a7f2f411c7b0fd847a6476ae99320d2dda /engines/parallaction/parser.cpp
parent80edc8504c07ad63ac0d28319ad89510335cd1ee (diff)
downloadscummvm-rg350-9bdf145aa0137f6cdd4b811bc45af5786e6a6f68.tar.gz
scummvm-rg350-9bdf145aa0137f6cdd4b811bc45af5786e6a6f68.tar.bz2
scummvm-rg350-9bdf145aa0137f6cdd4b811bc45af5786e6a6f68.zip
refactoring
svn-id: r25724
Diffstat (limited to 'engines/parallaction/parser.cpp')
-rw-r--r--engines/parallaction/parser.cpp73
1 files changed, 23 insertions, 50 deletions
diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp
index 9a1d30378a..2f97b37bf3 100644
--- a/engines/parallaction/parser.cpp
+++ b/engines/parallaction/parser.cpp
@@ -83,23 +83,9 @@ char *parseComment(ArchivedFile *file) {
return v194;
}
-uint16 parseFillBuffers() {
-
- uint16 i;
- for (i = 0; i < 20; i++)
- _tokens[i][0] = '\0';
+uint16 fillTokens(char* line) {
- char buf[200];
- char *line = NULL;
- do {
- line = parseNextLine(buf, 200);
- if (line == NULL) {
- error("unexpected end of file while parsing");
- }
- line = Common::ltrim(line);
- } while (strlen(line) == 0 || line[0] == '#');
-
- i = 0;
+ uint16 i = 0;
while (strlen(line) > 0 && i < 20) {
line = parseNextToken(line, _tokens[i], 40, " \t\n");
if (_tokens[i][0] == '"' && _tokens[i][strlen(_tokens[i]) - 1] != '"') {
@@ -118,6 +104,25 @@ uint16 parseFillBuffers() {
return i;
}
+uint16 parseFillBuffers() {
+
+ uint16 i;
+ for (i = 0; i < 20; i++)
+ _tokens[i][0] = '\0';
+
+ char buf[200];
+ char *line = NULL;
+ do {
+ line = parseNextLine(buf, 200);
+ if (line == NULL) {
+ error("unexpected end of file while parsing");
+ }
+ line = Common::ltrim(line);
+ } while (strlen(line) == 0 || line[0] == '#');
+
+ return fillTokens(line);
+}
+
//
// FIXME
// this function does the same Job as parseFillBuffers, except that
@@ -139,23 +144,7 @@ uint16 tableFillBuffers(Common::SeekableReadStream &stream) {
line = Common::ltrim(line);
} while (strlen(line) == 0 || line[0] == '#');
- i = 0;
- while (strlen(line) > 0 && i < 20) {
- line = parseNextToken(line, _tokens[i], 40, " \t\n");
- if (_tokens[i][0] == '"' && _tokens[i][strlen(_tokens[i]) - 1] != '"') {
-
- line = parseNextToken(line, _tokens[i+1], 40, "\"");
- strcat(_tokens[i], _tokens[i+1]);
- _tokens[i][0] = ' ';
- line++;
-
- }
-
- line = Common::ltrim(line);
- i++;
- }
-
- return i;
+ return fillTokens(line);
}
@@ -179,23 +168,7 @@ uint16 scriptFillBuffers(ArchivedFile *file) {
line = Common::ltrim(line);
} while (strlen(line) == 0 || line[0] == '#');
- i = 0;
- while (strlen(line) > 0 && i < 20) {
- line = parseNextToken(line, _tokens[i], 40, " \t\n");
- if (_tokens[i][0] == '"' && _tokens[i][strlen(_tokens[i]) - 1] != '"') {
-
- line = parseNextToken(line, _tokens[i+1], 40, "\"");
- strcat(_tokens[i], _tokens[i+1]);
- _tokens[i][0] = ' ';
- line++;
-
- }
-
- line = Common::ltrim(line);
- i++;
- }
-
- return i;
+ return fillTokens(line);
}