From 689f5dfd3ac049c006894709b774bd90032fe4ac Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 9 Jan 2009 02:43:35 +0000 Subject: [PATCH] fixed tag eating and text duplication in spellchecker git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1314 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/script/functions/spelling.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/script/functions/spelling.cpp b/src/script/functions/spelling.cpp index a046210b..bef06de4 100644 --- a/src/script/functions/spelling.cpp +++ b/src/script/functions/spelling.cpp @@ -64,7 +64,7 @@ void check_word(const String& tag, const String& input, String& out, Char sep, s // double space out += _(""); out.append(sep); - out.append(input, prev, after-end); + out.append(input, prev, after-prev); out += _(""); } else { if (sep) out.append(sep); @@ -74,7 +74,7 @@ void check_word(const String& tag, const String& input, String& out, Char sep, s // stand alone punctuation if (sep) out.append(sep); out += _(""); - out.append(input, prev, after-end); + out.append(input, prev, after-prev); out += _(""); } } else { @@ -115,6 +115,13 @@ SCRIPT_FUNCTION(check_spelling) { // now walk over the words in the input, and mark misspellings String result; Char sep = 0; + // indices are used as follows (at the time of check_word call): + // input: "previous (word)next" + // ^^ ^ ^ ^ + // || | | | + // sep | | word_end pos + // prev_end word_start + // size_t prev_end = 0, word_start = 0, word_end = 0, pos = 0; while (pos < input.size()) { Char c = input.GetChar(pos); @@ -146,6 +153,7 @@ SCRIPT_FUNCTION(check_spelling) { // last word check_word(tag, input, result, sep, prev_end, word_start, word_end, pos, checkers, extra_match, ctx); // done + assert_tagged(result); SCRIPT_RETURN(result); }