aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-02-24 19:17:54 +0000
committerjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-02-24 19:17:54 +0000
commit5cf2e760b602686c9a757e3978179f47b451c111 (patch)
treeb9a658468d8e8fb3e26e7fda8c7566912ff99d75
parentBreakpad Linux dumper: Add missing newlines to error messages. (diff)
downloadbreakpad-5cf2e760b602686c9a757e3978179f47b451c111.tar.xz
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
-rw-r--r--src/processor/postfix_evaluator-inl.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/processor/postfix_evaluator-inl.h b/src/processor/postfix_evaluator-inl.h
index 9c1fc84e..b1252f68 100644
--- a/src/processor/postfix_evaluator-inl.h
+++ b/src/processor/postfix_evaluator-inl.h
@@ -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) {