aboutsummaryrefslogtreecommitdiff
path: root/src/processor
diff options
context:
space:
mode:
Diffstat (limited to 'src/processor')
-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) {