[Scummvm-cvs-logs] SF.net SVN: scummvm: [27962] scummvm/trunk/engines/parallaction/parser.cpp

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Jul 8 14:39:39 CEST 2007


Revision: 27962
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27962&view=rev
Author:   peres001
Date:     2007-07-08 05:39:39 -0700 (Sun, 08 Jul 2007)

Log Message:
-----------
Finally fixed parsing of labels.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/parser.cpp

Modified: scummvm/trunk/engines/parallaction/parser.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser.cpp	2007-07-08 12:02:38 UTC (rev 27961)
+++ scummvm/trunk/engines/parallaction/parser.cpp	2007-07-08 12:39:39 UTC (rev 27962)
@@ -119,17 +119,22 @@
 
 }
 
-//	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 @@
 				*tok = '\0';
 				return s;
 			}
-			if (*s == '"' || strchr(brk, *s)) {
+			if (*s == '"' || *s == '\n' || *s == '\t') {
 				*tok = '\0';
 				return ++s;
 			}
@@ -170,15 +175,18 @@
 
 	}
 
-	return 0;
+	*tok = '\0';
+	warning("token was truncated from line '%s'", t);
 
+	return tok;
+
 }
 
 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++;
 	}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list