mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-28 10:24:24 +01:00
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:
parent
19d77e0c33
commit
5cf2e760b6
@ -246,16 +246,30 @@ PostfixEvaluator<ValueType>::PopValueOrIdentifier(
|
|||||||
string token = stack_.back();
|
string token = stack_.back();
|
||||||
stack_.pop_back();
|
stack_.pop_back();
|
||||||
|
|
||||||
// First, try to treat the value as a literal. In order for this to
|
// First, try to treat the value as a literal. Literals may have leading
|
||||||
// succed, the entire string must be parseable as ValueType. If this
|
// '-' sign, and the entire remaining string must be parseable as
|
||||||
// isn't possible, it can't be a literal, so treat it as an identifier
|
// ValueType. If this isn't possible, it can't be a literal, so treat it
|
||||||
// instead.
|
// 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);
|
istringstream token_stream(token);
|
||||||
ValueType literal;
|
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 (token_stream >> literal && token_stream.peek() == EOF) {
|
||||||
if (value) {
|
if (value) {
|
||||||
*value = literal;
|
*value = literal;
|
||||||
}
|
}
|
||||||
|
if (negative)
|
||||||
|
*value = -*value;
|
||||||
return POP_RESULT_VALUE;
|
return POP_RESULT_VALUE;
|
||||||
} else {
|
} else {
|
||||||
if (identifier) {
|
if (identifier) {
|
||||||
|
Loading…
Reference in New Issue
Block a user