[Scummvm-cvs-logs] SF.net SVN: scummvm:[39670] scummvm/trunk/engines/sci
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Mar 24 18:41:46 CET 2009
Revision: 39670
http://scummvm.svn.sourceforge.net/scummvm/?rev=39670&view=rev
Author: fingolfin
Date: 2009-03-24 17:41:46 +0000 (Tue, 24 Mar 2009)
Log Message:
-----------
SCI: Changed vocab_tokenize_string to not 'return' the list it generates, but rather pass a reference to an existing list to it (this is a bit more efficient, and allows us to return an error value)
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kstring.cpp
scummvm/trunk/engines/sci/engine/scriptdebug.cpp
scummvm/trunk/engines/sci/scicore/vocabulary.cpp
scummvm/trunk/engines/sci/scicore/vocabulary.h
Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp 2009-03-24 17:41:26 UTC (rev 39669)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp 2009-03-24 17:41:46 UTC (rev 39670)
@@ -253,13 +253,13 @@
return s->r_acc;
}
- words = vocab_tokenize_string(string,
- s->parser_words, s->parser_words_nr,
- s->_parserSuffixes,
- &error);
+ int res = vocab_tokenize_string(words, string,
+ s->parser_words, s->parser_words_nr,
+ s->_parserSuffixes,
+ &error);
s->parser_valid = 0; /* not valid */
- if (!words.empty()) {
+ if (res == 0 && !words.empty()) {
int syntax_fail = 0;
Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp 2009-03-24 17:41:26 UTC (rev 39669)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp 2009-03-24 17:41:46 UTC (rev 39670)
@@ -1032,9 +1032,9 @@
string = cmd_params[0].str;
sciprintf("Parsing '%s'\n", string);
- words = vocab_tokenize_string(string, s->parser_words, s->parser_words_nr,
- s->_parserSuffixes, &error);
- if (!words.empty()) {
+ int res = vocab_tokenize_string(words, string, s->parser_words, s->parser_words_nr,
+ s->_parserSuffixes, &error);
+ if (res == 0&& !words.empty()) {
int syntax_fail = 0;
vocab_synonymize_tokens(words, s->_synonyms);
Modified: scummvm/trunk/engines/sci/scicore/vocabulary.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/vocabulary.cpp 2009-03-24 17:41:26 UTC (rev 39669)
+++ scummvm/trunk/engines/sci/scicore/vocabulary.cpp 2009-03-24 17:41:46 UTC (rev 39670)
@@ -477,13 +477,12 @@
}
#endif
-ResultWordList vocab_tokenize_string(char *sentence, word_t **words, int words_nr,
+int vocab_tokenize_string(ResultWordList &retval, char *sentence, word_t **words, int words_nr,
const SuffixList &suffixes, char **error) {
char *lastword = sentence;
int pos_in_sentence = 0;
char c;
int wordlen = 0;
- ResultWordList retval;
*error = NULL;
@@ -507,7 +506,7 @@
*error = (char *)sci_calloc(wordlen + 1, 1);
strncpy(*error, lastword, wordlen); // Set the offending word
retval.clear();
- return retval; // And return with error
+ return 1; // And return with error
}
// Copy into list
@@ -520,7 +519,7 @@
} while (c); // Until terminator is hit
- return retval;
+ return 0;
}
void _vocab_recursive_ptree_dump_treelike(parse_tree_node_t *nodes, int nr, int prevnr) {
Modified: scummvm/trunk/engines/sci/scicore/vocabulary.h
===================================================================
--- scummvm/trunk/engines/sci/scicore/vocabulary.h 2009-03-24 17:41:26 UTC (rev 39669)
+++ scummvm/trunk/engines/sci/scicore/vocabulary.h 2009-03-24 17:41:46 UTC (rev 39670)
@@ -283,7 +283,7 @@
*/
-ResultWordList vocab_tokenize_string(char *sentence,
+int vocab_tokenize_string(ResultWordList &retval, char *sentence,
word_t **words, int words_nr, const SuffixList &suffixes, char **error);
/* Tokenizes a string and compiles it into word_ts.
** Parameters: (char *) sentence: The sentence to examine
@@ -291,7 +291,8 @@
** (int) words_nr: Number of words to scan for
** (SuffixList) suffixes: suffixes to scan for
** (char **) error: Points to a malloc'd copy of the offending text or to NULL on error
-** Returns : (word_t *): A list of word_ts containing the result, or NULL.
+** (ResultWordList) retval: A list of word_ts containing the result, or NULL.
+** Returns : 0 on success, 1 if an error occurred
** On error, NULL is returned. If *error is NULL, the sentence did not contain any useful words;
** if not, *error points to a malloc'd copy of the offending word.
** The returned list may contain anywords.
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