aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kstring.cpp10
-rw-r--r--engines/sci/engine/scriptdebug.cpp6
-rw-r--r--engines/sci/scicore/vocabulary.cpp7
-rw-r--r--engines/sci/scicore/vocabulary.h5
4 files changed, 14 insertions, 14 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index bf03e79360..e15315397e 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -253,13 +253,13 @@ reg_t kParse(EngineState *s, int funct_nr, int argc, reg_t *argv) {
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;
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 35fc41fb31..1117d2aca2 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -1032,9 +1032,9 @@ int c_parse(EngineState *s) {
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);
diff --git a/engines/sci/scicore/vocabulary.cpp b/engines/sci/scicore/vocabulary.cpp
index 283029b226..f9e58c1123 100644
--- a/engines/sci/scicore/vocabulary.cpp
+++ b/engines/sci/scicore/vocabulary.cpp
@@ -477,13 +477,12 @@ int vocab_build_simple_parse_tree(parse_tree_node_t *nodes, result_word_t *words
}
#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 @@ ResultWordList vocab_tokenize_string(char *sentence, word_t **words, int words_n
*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 @@ ResultWordList vocab_tokenize_string(char *sentence, word_t **words, int words_n
} 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) {
diff --git a/engines/sci/scicore/vocabulary.h b/engines/sci/scicore/vocabulary.h
index 41562e092d..7a9507b74c 100644
--- a/engines/sci/scicore/vocabulary.h
+++ b/engines/sci/scicore/vocabulary.h
@@ -283,7 +283,7 @@ ResultWord vocab_lookup_word(char *word, int word_len,
*/
-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 @@ ResultWordList vocab_tokenize_string(char *sentence,
** (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.