diff options
author | Nicola Mettifogo | 2007-07-08 12:39:39 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-07-08 12:39:39 +0000 |
commit | 373cadce5b5f4e58d77e366f5e4ef7f00ec1394d (patch) | |
tree | 1dacfc6e9ad2acc5de7f8c35653ca49117167a57 | |
parent | 41c68ac3e42b157529cf8fd670e774f5be72911a (diff) | |
download | scummvm-rg350-373cadce5b5f4e58d77e366f5e4ef7f00ec1394d.tar.gz scummvm-rg350-373cadce5b5f4e58d77e366f5e4ef7f00ec1394d.tar.bz2 scummvm-rg350-373cadce5b5f4e58d77e366f5e4ef7f00ec1394d.zip |
Finally fixed parsing of labels.
svn-id: r27962
-rw-r--r-- | engines/parallaction/parser.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp index a7c4cbad4b..6fd21b3099 100644 --- a/engines/parallaction/parser.cpp +++ b/engines/parallaction/parser.cpp @@ -119,17 +119,22 @@ void clearTokens() { } -// looks for next token in a string // -// scans 's' until one of the stop-chars in 'brk' is found -// builds a token and return the part of the string which hasn't been parsed - +// Scans 's' until one of the stop-chars in 'brk' is found, building a token. +// If the routine encounters quotes, it will extract the contained text and +// make a proper token. When scanning inside quotes, 'brk' is ignored and +// only newlines are considered stop-chars. +// +// The routine returns the unparsed portion of the input string 's'. +// char *parseNextToken(char *s, char *tok, uint16 count, const char *brk) { enum STATES { NORMAL, QUOTED }; STATES state = NORMAL; + char *t = s; + while (count > 0) { switch (state) { @@ -158,7 +163,7 @@ char *parseNextToken(char *s, char *tok, uint16 count, const char *brk) { *tok = '\0'; return s; } - if (*s == '"' || strchr(brk, *s)) { + if (*s == '"' || *s == '\n' || *s == '\t') { *tok = '\0'; return ++s; } @@ -170,7 +175,10 @@ char *parseNextToken(char *s, char *tok, uint16 count, const char *brk) { } - return 0; + *tok = '\0'; + warning("token was truncated from line '%s'", t); + + return tok; } @@ -178,7 +186,7 @@ uint16 fillTokens(char* line) { uint16 i = 0; while (strlen(line) > 0 && i < 20) { - line = parseNextToken(line, _tokens[i], 40, " \t\n\a"); + line = parseNextToken(line, _tokens[i], 40, " \t\n"); line = Common::ltrim(line); i++; } |