1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 10:53:51 +00:00

be a bit more relaxed about allowing - in names (Fixes #1593)

This commit is contained in:
Marc Zinnschlag 2014-07-15 10:39:11 +02:00
parent 517b27e29a
commit 563c2e5730
2 changed files with 15 additions and 6 deletions

View file

@ -343,17 +343,13 @@ namespace Compiler
} }
else if (!(c=='"' && name.empty())) else if (!(c=='"' && name.empty()))
{ {
if (!(std::isalpha (c) || std::isdigit (c) || c=='_' || c=='`' || if (!isStringCharacter (c))
/// \todo add an option to disable the following hack. Also, find out who is
/// responsible for allowing it in the first place and meet up with that person in
/// a dark alley.
(c=='-' && !name.empty() && std::isalpha (mStream.peek()))))
{ {
putback (c); putback (c);
break; break;
} }
if (first && std::isdigit (c)) if (first && (std::isdigit (c) || c=='`' || c=='-'))
error = true; error = true;
} }
@ -499,6 +495,17 @@ namespace Compiler
return true; return true;
} }
bool Scanner::isStringCharacter (char c, bool lookAhead)
{
return std::isalpha (c) || std::isdigit (c) || c=='_' ||
/// \todo disable this when doing more stricter compiling
c=='`' ||
/// \todo disable this when doing more stricter compiling. Also, find out who is
/// responsible for allowing it in the first place and meet up with that person in
/// a dark alley.
(c=='-' && (!lookAhead || isStringCharacter (mStream.peek(), false)));
}
bool Scanner::isWhitespace (char c) bool Scanner::isWhitespace (char c)
{ {
return c==' ' || c=='\t'; return c==' ' || c=='\t';

View file

@ -92,6 +92,8 @@ namespace Compiler
bool scanSpecial (char c, Parser& parser, bool& cont); bool scanSpecial (char c, Parser& parser, bool& cont);
bool isStringCharacter (char c, bool lookAhead = true);
static bool isWhitespace (char c); static bool isWhitespace (char c);
public: public: