mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 16:36:41 +00:00
Ignore special characters preceding script commands
This commit is contained in:
parent
cdd6a8c007
commit
b19ad079c2
5 changed files with 53 additions and 8 deletions
|
@ -14,6 +14,7 @@
|
||||||
Bug #6427: Enemy health bar disappears before damaging effect ends
|
Bug #6427: Enemy health bar disappears before damaging effect ends
|
||||||
Bug #6645: Enemy block sounds align with animation instead of blocked hits
|
Bug #6645: Enemy block sounds align with animation instead of blocked hits
|
||||||
Bug #6661: Saved games that have no preview screenshot cause issues or crashes
|
Bug #6661: Saved games that have no preview screenshot cause issues or crashes
|
||||||
|
Bug #6807: Ultimate Galleon is not working properly
|
||||||
Bug #6939: OpenMW-CS: ID columns are too short
|
Bug #6939: OpenMW-CS: ID columns are too short
|
||||||
Bug #6949: Sun Damage effect doesn't work in quasi exteriors
|
Bug #6949: Sun Damage effect doesn't work in quasi exteriors
|
||||||
Bug #6964: Nerasa Dralor Won't Follow
|
Bug #6964: Nerasa Dralor Won't Follow
|
||||||
|
|
|
@ -441,6 +441,28 @@ messagebox,"this is a %g",a
|
||||||
|
|
||||||
,End,)mwscript";
|
,End,)mwscript";
|
||||||
|
|
||||||
|
const std::string sIssue6807 = R"mwscript(---Begin issue6807
|
||||||
|
|
||||||
|
short a
|
||||||
|
|
||||||
|
----------------------
|
||||||
|
+++++++++++
|
||||||
|
***************
|
||||||
|
/////////////////////
|
||||||
|
?????????
|
||||||
|
@@@@@@@@
|
||||||
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
set a to 1
|
||||||
|
|
||||||
|
;-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
; Collision Detection Check
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-+'\/.,><$@---!=\/?--------(){}------ show a
|
||||||
|
|
||||||
|
End)mwscript";
|
||||||
|
|
||||||
TEST_F(MWScriptTest, mwscript_test_invalid)
|
TEST_F(MWScriptTest, mwscript_test_invalid)
|
||||||
{
|
{
|
||||||
EXPECT_THROW(compile("this is not a valid script", true), Compiler::SourceException);
|
EXPECT_THROW(compile("this is not a valid script", true), Compiler::SourceException);
|
||||||
|
@ -859,4 +881,10 @@ messagebox,"this is a %g",a
|
||||||
{
|
{
|
||||||
EXPECT_FALSE(!compile(sIssue6380));
|
EXPECT_FALSE(!compile(sIssue6380));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MWScriptTest, mwscript_test_6807)
|
||||||
|
{
|
||||||
|
registerExtensions();
|
||||||
|
EXPECT_FALSE(!compile(sIssue6807));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -94,16 +94,10 @@ namespace Compiler
|
||||||
|
|
||||||
bool FileParser::parseSpecial(int code, const TokenLoc& loc, Scanner& scanner)
|
bool FileParser::parseSpecial(int code, const TokenLoc& loc, Scanner& scanner)
|
||||||
{
|
{
|
||||||
// Ignore any junk special characters
|
|
||||||
if (mState == BeginState)
|
|
||||||
{
|
|
||||||
if (code != Scanner::S_newline)
|
|
||||||
reportWarning("Stray special character before begin statement", loc);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (code == Scanner::S_newline)
|
if (code == Scanner::S_newline)
|
||||||
{
|
{
|
||||||
|
if (mState == BeginState)
|
||||||
|
return true;
|
||||||
if (mState == BeginCompleteState)
|
if (mState == BeginCompleteState)
|
||||||
{
|
{
|
||||||
// parse the script body
|
// parse the script body
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace Compiler
|
||||||
mLoc.mColumn = 0;
|
mLoc.mColumn = 0;
|
||||||
++mLoc.mLine;
|
++mLoc.mLine;
|
||||||
mLoc.mLiteral.clear();
|
mLoc.mLiteral.clear();
|
||||||
|
mIgnoreSpecial = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -119,6 +120,7 @@ namespace Compiler
|
||||||
}
|
}
|
||||||
else if (c.isAlpha() || c == '_' || c == '"')
|
else if (c.isAlpha() || c == '_' || c == '"')
|
||||||
{
|
{
|
||||||
|
mIgnoreSpecial = false;
|
||||||
bool cont = false;
|
bool cont = false;
|
||||||
|
|
||||||
if (scanName(c, parser, cont))
|
if (scanName(c, parser, cont))
|
||||||
|
@ -129,6 +131,7 @@ namespace Compiler
|
||||||
}
|
}
|
||||||
else if (c.isDigit())
|
else if (c.isDigit())
|
||||||
{
|
{
|
||||||
|
mIgnoreSpecial = false;
|
||||||
bool cont = false;
|
bool cont = false;
|
||||||
|
|
||||||
bool scanned = mExpectName ? scanName(c, parser, cont) : scanInt(c, parser, cont);
|
bool scanned = mExpectName ? scanName(c, parser, cont) : scanInt(c, parser, cont);
|
||||||
|
@ -402,6 +405,23 @@ namespace Compiler
|
||||||
|
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
special = S_newline;
|
special = S_newline;
|
||||||
|
else if (mIgnoreSpecial)
|
||||||
|
{
|
||||||
|
// Ignore junk special characters
|
||||||
|
TokenLoc loc = mLoc;
|
||||||
|
while (get(c))
|
||||||
|
{
|
||||||
|
if (c.isAlpha() || c == '_' || c == '"' || c.isDigit() || c == ';' || c == '\n')
|
||||||
|
{
|
||||||
|
putback(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
c.appendTo(loc.mLiteral);
|
||||||
|
}
|
||||||
|
mErrorHandler.warning("Stray special character at start of line", loc);
|
||||||
|
cont = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else if (c == '(' || c == '[') /// \todo option to disable the use of [ as alias for (
|
else if (c == '(' || c == '[') /// \todo option to disable the use of [ as alias for (
|
||||||
special = S_open;
|
special = S_open;
|
||||||
else if (c == ')' || c == ']') /// \todo option to disable the use of ] as alias for )
|
else if (c == ')' || c == ']') /// \todo option to disable the use of ] as alias for )
|
||||||
|
@ -598,6 +618,7 @@ namespace Compiler
|
||||||
, mTolerantNames(false)
|
, mTolerantNames(false)
|
||||||
, mIgnoreNewline(false)
|
, mIgnoreNewline(false)
|
||||||
, mExpectName(false)
|
, mExpectName(false)
|
||||||
|
, mIgnoreSpecial(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,6 +195,7 @@ namespace Compiler
|
||||||
bool mTolerantNames;
|
bool mTolerantNames;
|
||||||
bool mIgnoreNewline;
|
bool mIgnoreNewline;
|
||||||
bool mExpectName;
|
bool mExpectName;
|
||||||
|
bool mIgnoreSpecial;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum keyword
|
enum keyword
|
||||||
|
|
Loading…
Reference in a new issue