mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 21:27:01 -04:00
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
This commit is contained in:
@@ -64,7 +64,7 @@ void check_word(const String& tag, const String& input, String& out, Char sep, s
|
|||||||
// double space
|
// double space
|
||||||
out += _("<error-spelling>");
|
out += _("<error-spelling>");
|
||||||
out.append(sep);
|
out.append(sep);
|
||||||
out.append(input, prev, after-end);
|
out.append(input, prev, after-prev);
|
||||||
out += _("</error-spelling>");
|
out += _("</error-spelling>");
|
||||||
} else {
|
} else {
|
||||||
if (sep) out.append(sep);
|
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
|
// stand alone punctuation
|
||||||
if (sep) out.append(sep);
|
if (sep) out.append(sep);
|
||||||
out += _("<error-spelling>");
|
out += _("<error-spelling>");
|
||||||
out.append(input, prev, after-end);
|
out.append(input, prev, after-prev);
|
||||||
out += _("</error-spelling>");
|
out += _("</error-spelling>");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -115,6 +115,13 @@ SCRIPT_FUNCTION(check_spelling) {
|
|||||||
// now walk over the words in the input, and mark misspellings
|
// now walk over the words in the input, and mark misspellings
|
||||||
String result;
|
String result;
|
||||||
Char sep = 0;
|
Char sep = 0;
|
||||||
|
// indices are used as follows (at the time of check_word call):
|
||||||
|
// input: "previous <tag>(<tag>word<tag>)<tag>next"
|
||||||
|
// ^^ ^ ^ ^
|
||||||
|
// || | | |
|
||||||
|
// sep | | word_end pos
|
||||||
|
// prev_end word_start
|
||||||
|
//
|
||||||
size_t prev_end = 0, word_start = 0, word_end = 0, pos = 0;
|
size_t prev_end = 0, word_start = 0, word_end = 0, pos = 0;
|
||||||
while (pos < input.size()) {
|
while (pos < input.size()) {
|
||||||
Char c = input.GetChar(pos);
|
Char c = input.GetChar(pos);
|
||||||
@@ -146,6 +153,7 @@ SCRIPT_FUNCTION(check_spelling) {
|
|||||||
// last word
|
// last word
|
||||||
check_word(tag, input, result, sep, prev_end, word_start, word_end, pos, checkers, extra_match, ctx);
|
check_word(tag, input, result, sep, prev_end, word_start, word_end, pos, checkers, extra_match, ctx);
|
||||||
// done
|
// done
|
||||||
|
assert_tagged(result);
|
||||||
SCRIPT_RETURN(result);
|
SCRIPT_RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user