Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
7e54d5b0
Commit
7e54d5b0
authored
Jan 08, 2009
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slightly less tagged string checking
parent
17cfc132
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
15 deletions
+17
-15
src/script/functions/basic.cpp
src/script/functions/basic.cpp
+4
-4
src/util/tagged_string.cpp
src/util/tagged_string.cpp
+11
-9
src/util/tagged_string.hpp
src/util/tagged_string.hpp
+2
-2
No files found.
src/script/functions/basic.cpp
View file @
7e54d5b0
...
...
@@ -324,7 +324,7 @@ SCRIPT_FUNCTION(sort_text) {
/// Replace the contents of a specific tag with the value of a script function
String
replace_tag_contents
(
String
input
,
const
String
&
tag
,
const
ScriptValueP
&
contents
,
Context
&
ctx
)
{
assert_tagged
(
input
);
assert_tagged
(
input
,
false
);
String
ret
;
size_t
start
=
0
,
pos
=
input
.
find
(
tag
);
while
(
pos
!=
String
::
npos
)
{
...
...
@@ -345,7 +345,7 @@ String replace_tag_contents(String input, const String& tag, const ScriptValueP&
pos
=
input
.
find
(
tag
,
start
);
}
ret
.
append
(
input
,
start
,
pos
-
start
);
assert_tagged
(
ret
);
assert_tagged
(
ret
,
false
);
return
ret
;
}
...
...
@@ -360,13 +360,13 @@ SCRIPT_FUNCTION(tag_contents) {
SCRIPT_FUNCTION
(
remove_tag
)
{
SCRIPT_PARAM_C
(
String
,
input
);
SCRIPT_PARAM_C
(
String
,
tag
);
assert_tagged
(
input
);
assert_tagged
(
input
,
false
);
SCRIPT_RETURN
(
remove_tag
(
input
,
tag
));
}
SCRIPT_FUNCTION
(
remove_tags
)
{
SCRIPT_PARAM_C
(
String
,
input
);
assert_tagged
(
input
);
assert_tagged
(
input
,
false
);
SCRIPT_RETURN
(
untag_no_escape
(
input
));
}
...
...
src/util/tagged_string.cpp
View file @
7e54d5b0
...
...
@@ -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
;
...
...
src/util/tagged_string.hpp
View file @
7e54d5b0
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment