diff options
author | Nicola Mettifogo | 2007-07-08 13:39:23 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-07-08 13:39:23 +0000 |
commit | 3036c37dd817545b4571f01625954c9c74c635ae (patch) | |
tree | 4506a82352996e532ffa36994b92c0fe90e92c36 | |
parent | 925f75636951b9697a2c8f97d4c93fb1510fd617 (diff) | |
download | scummvm-rg350-3036c37dd817545b4571f01625954c9c74c635ae.tar.gz scummvm-rg350-3036c37dd817545b4571f01625954c9c74c635ae.tar.bz2 scummvm-rg350-3036c37dd817545b4571f01625954c9c74c635ae.zip |
Yet another fix for broken parsing/displaying of strings. Now quotes are properly considered when they are needed, and ignored when they aren't.
svn-id: r27967
-rw-r--r-- | engines/parallaction/graphics.cpp | 5 | ||||
-rw-r--r-- | engines/parallaction/parser.cpp | 11 | ||||
-rw-r--r-- | engines/parallaction/parser.h | 2 |
3 files changed, 12 insertions, 6 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index aca02a68bf..699ec5cbc5 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -608,7 +608,7 @@ bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, byte color, uint1 while (strlen(text) > 0) { - text = parseNextToken(text, token, 40, " "); + text = parseNextToken(text, token, 40, " ", true); linewidth += getStringWidth(token); if (linewidth > wrapwidth) { @@ -653,7 +653,8 @@ void Gfx::getStringExtent(char *text, uint16 maxwidth, int16* width, int16* heig while (strlen(text) != 0) { - text = parseNextToken(text, token, 40, " "); + text = parseNextToken(text, token, 40, " ", true); + printf("%s\n", text); w += getStringWidth(token); if (w > maxwidth) { diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp index 6fd21b3099..44aae6c1cc 100644 --- a/engines/parallaction/parser.cpp +++ b/engines/parallaction/parser.cpp @@ -127,7 +127,7 @@ void clearTokens() { // // The routine returns the unparsed portion of the input string 's'. // -char *parseNextToken(char *s, char *tok, uint16 count, const char *brk) { +char *parseNextToken(char *s, char *tok, uint16 count, const char *brk, bool ignoreQuotes) { enum STATES { NORMAL, QUOTED }; @@ -150,8 +150,13 @@ char *parseNextToken(char *s, char *tok, uint16 count, const char *brk) { } if (*s == '"') { - state = QUOTED; - s++; + if (ignoreQuotes) { + *tok++ = *s++; + count--; + } else { + state = QUOTED; + s++; + } } else { *tok++ = *s++; count--; diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h index e27095bd16..aa3929a52c 100644 --- a/engines/parallaction/parser.h +++ b/engines/parallaction/parser.h @@ -33,7 +33,7 @@ namespace Parallaction { uint16 fillBuffers(Common::SeekableReadStream &stream, bool errorOnEOF = false); -char *parseNextToken(char *s, char *tok, uint16 count, const char *brk); +char *parseNextToken(char *s, char *tok, uint16 count, const char *brk, bool ignoreQuotes = false); extern char _tokens[][40]; |