Breakpad processor: Support negative literals in the postfix evaluator.

Some versions of the libstdc++, the GNU standard C++ library, have
stream extractors for unsigned integer values that permit a leading
'-' sign (6.0.13); others do not (6.0.9). Regardless of the behavior
of the extractors, Breakpad postfix expressions should support
negative literals.

a=jimblandy, r=nealsid


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@537 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
jimblandy 2010-02-24 19:17:54 +00:00
parent 19d77e0c33
commit 5cf2e760b6

View file

@ -246,16 +246,30 @@ PostfixEvaluator<ValueType>::PopValueOrIdentifier(
string token = stack_.back();
stack_.pop_back();
// First, try to treat the value as a literal. In order for this to
// succed, the entire string must be parseable as ValueType. If this
// isn't possible, it can't be a literal, so treat it as an identifier
// instead.
// First, try to treat the value as a literal. Literals may have leading
// '-' sign, and the entire remaining string must be parseable as
// ValueType. If this isn't possible, it can't be a literal, so treat it
// as an identifier instead.
//
// Some versions of the libstdc++, the GNU standard C++ library, have
// stream extractors for unsigned integer values that permit a leading
// '-' sign (6.0.13); others do not (6.0.9). Since we require it, we
// handle it explicitly here.
istringstream token_stream(token);
ValueType literal;
bool negative;
if (token_stream.peek() == '-') {
negative = true;
token_stream.get();
} else {
negative = false;
}
if (token_stream >> literal && token_stream.peek() == EOF) {
if (value) {
*value = literal;
}
if (negative)
*value = -*value;
return POP_RESULT_VALUE;
} else {
if (identifier) {