aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2008-12-04 09:33:37 +0000
committerNicola Mettifogo2008-12-04 09:33:37 +0000
commit664d696e55748a4c03f6275b2c6643adcd37c77a (patch)
tree5391bbdc2e8514c39652e24a20623fc9a1b9be65
parente64e4833b3fa18038e27355d50d49398e0fa5804 (diff)
downloadscummvm-rg350-664d696e55748a4c03f6275b2c6643adcd37c77a.tar.gz
scummvm-rg350-664d696e55748a4c03f6275b2c6643adcd37c77a.tar.bz2
scummvm-rg350-664d696e55748a4c03f6275b2c6643adcd37c77a.zip
Made readLineIntern() return a zero-length string when no printable text is read out of a script. This makes life easier for the parser, and also makes the introduction fully viewable.
svn-id: r35233
-rw-r--r--engines/parallaction/parser.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/engines/parallaction/parser.cpp b/engines/parallaction/parser.cpp
index f4d5df99ab..2ad65abf20 100644
--- a/engines/parallaction/parser.cpp
+++ b/engines/parallaction/parser.cpp
@@ -40,9 +40,16 @@ Script::~Script() {
delete _input;
}
+/*
+ * readLineIntern read a text line and prepares it for
+ * parsing, by stripping the leading whitespace and
+ * changing tabs to spaces. It will stop on a CR or LF,
+ * and return an empty string (length = 0) when a line
+ * has no printable text in it.
+ */
char *Script::readLineIntern(char *buf, size_t bufSize) {
- uint16 i;
- for (i = 0; i < bufSize; i++) {
+ uint i = 0;
+ for ( ; i < bufSize; ) {
char c = _input->readSByte();
if (_input->eos())
break;
@@ -51,7 +58,10 @@ char *Script::readLineIntern(char *buf, size_t bufSize) {
if (c == '\t')
c = ' ';
- buf[i] = c;
+ if ((c != ' ') || (i > 0)) {
+ buf[i] = c;
+ i++;
+ }
}
_line++;
if (i == bufSize) {