Commit d35efdf5 by alokp@chromium.org

Restricted the length of identifiers (including #define directive) to 256, as…

Restricted the length of identifiers (including #define directive) to 256, as required by webgl spec. git-svn-id: https://angleproject.googlecode.com/svn/trunk@1186 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 390209ae
......@@ -347,6 +347,12 @@ void DirectiveParser::parseDefine(Token* token)
token->location, token->text);
return;
}
if (token->text.size() > Token::kMaxIdentifierLength)
{
mDiagnostics->report(Diagnostics::IDENTIFIER_OVERFLOW,
token->location, token->text);
return;
}
Macro macro;
macro.type = Macro::kTypeObj;
......
......@@ -125,14 +125,13 @@ void Preprocessor::lex(Token* token)
}
case Token::IDENTIFIER:
{
static const int kMaxIdentifierLength = 256;
if (token->text.size() > kMaxIdentifierLength)
if (token->text.size() > Token::kMaxIdentifierLength)
{
// Do not mark the token as invalid.
// Just emit the diagnostic and clamp string length.
mImpl->diagnostics->report(Diagnostics::IDENTIFIER_OVERFLOW,
token->location, token->text);
token->text.erase(kMaxIdentifierLength);
token->text.erase(Token::kMaxIdentifierLength);
}
validToken = true;
break;
......
......@@ -31,6 +31,10 @@ static bool atoi_t(const std::string& str, IntType* value)
namespace pp
{
// TODO(alokp): This should be specified by preprocessor client,
// i.e., the compiler.
const size_t Token::kMaxIdentifierLength = 256;
void Token::reset()
{
type = 0;
......
......@@ -61,6 +61,7 @@ struct Token
HAS_LEADING_SPACE = 1 << 1,
EXPANSION_DISABLED = 1 << 2
};
static const size_t kMaxIdentifierLength;
Token() : type(0), flags(0) { }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment