[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master edb854a 3/4: parse_single_value(): conditiona
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master edb854a 3/4: parse_single_value(): conditionally allow an extra space |
Date: |
Fri, 11 Nov 2016 22:46:10 +0000 (UTC) |
branch: master
commit edb854a638faed28c7587d47b81869a6dbdf7126
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
parse_single_value(): conditionally allow an extra space
Iff the number of decimals is zero, allow one more blank space for a
phantom decimal point.
---
rate_table.cpp | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/rate_table.cpp b/rate_table.cpp
index 5f44e3c..dfa3d53 100644
--- a/rate_table.cpp
+++ b/rate_table.cpp
@@ -1561,8 +1561,14 @@ double table_impl::parse_single_value
,int& line_num
)
{
- // There should be at least one and up to gap_length spaces before the
- // value.
+ // The number of spaces before the value should be at least one,
+ // and no greater than (gap_length, plus one if the number of
+ // decimals is zero, because get_value_width() assumes, contrary
+ // to fact, that a decimal point is written regardless).
+ int const num_spaces_allowed =
+ text_format::gap_length
+ + (0 == *num_decimals_)
+ ;
if(*current != ' ')
{
fatal_error()
@@ -1576,12 +1582,12 @@ double table_impl::parse_single_value
{
++num_spaces;
}
- if(num_spaces > text_format::gap_length)
+ if(num_spaces_allowed < num_spaces)
{
fatal_error()
<< "too many spaces"
<< location_info(line_num, current - start + 1)
- << " (at most " << text_format::gap_length << " allowed here)"
+ << " (at most " << num_spaces_allowed << " allowed here)"
<< std::flush
;
}