slightly less tagged string checking

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1304 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2009-01-08 17:25:36 +00:00
parent eed4c5301e
commit 05ba96ab3e
3 changed files with 17 additions and 15 deletions
+11 -9
View File
@@ -573,7 +573,7 @@ String simplify_tagged_overlap(const String& str) {
// ----------------------------------------------------------------------------- : Verification
void check_tagged(const String& str) {
void check_tagged(const String& str, bool check_balance) {
for (size_t i = 0 ; i < str.size() ; ) {
if (str.GetChar(i) == _('<')) {
size_t end = skip_tag(str,i);
@@ -586,14 +586,16 @@ void check_tagged(const String& str) {
handle_warning(_("Invalid character in tag"),false);
}
}
if (str.GetChar(i+1) == _('/')) {
// close tag, don't check
} else if (is_substr(str,i,_("<hint"))) {
// no close tag for <hint> tags
} else {
size_t close = match_close_tag(str,i);
if (close == String::npos) {
handle_warning(_("Invalid tagged string: missing close tag for <") + tag_at(str,i) + _(">"),false);
if (check_balance) {
if (str.GetChar(i+1) == _('/')) {
// close tag, don't check
} else if (is_substr(str,i,_("<hint"))) {
// no close tag for <hint> tags
} else {
size_t close = match_close_tag(str,i);
if (close == String::npos) {
handle_warning(_("Invalid tagged string: missing close tag for <") + tag_at(str,i) + _(">"),false);
}
}
}
i = end;
+2 -2
View File
@@ -183,11 +183,11 @@ String tagged_substr_replace(const String& input, size_t start, size_t end, cons
*
* In case of an error, throws an exception.
*/
void check_tagged(const String& str);
void check_tagged(const String& str, bool check_balance = true);
#ifdef _DEBUG
#define assert_tagged check_tagged
#else
#define assert_tagged(_)
#define assert_tagged(_,_)
#endif
/// Simplify a tagged string