[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [6035] Fix defect introduced 20120527T1615Z: error using u
From: |
Greg Chicares |
Subject: |
[lmi-commits] [6035] Fix defect introduced 20120527T1615Z: error using unnecessary library |
Date: |
Fri, 21 Nov 2014 15:21:16 +0000 |
Revision: 6035
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6035
Author: chicares
Date: 2014-11-21 15:21:15 +0000 (Fri, 21 Nov 2014)
Log Message:
-----------
Fix defect introduced 20120527T1615Z: error using unnecessary library
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/soa2xml.cpp
lmi/trunk/soa_helpers.hpp
lmi/trunk/soa_stress_test.cpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2014-11-08 00:49:13 UTC (rev 6034)
+++ lmi/trunk/ChangeLog 2014-11-21 15:21:15 UTC (rev 6035)
@@ -34640,3 +34640,12 @@
toolbar.xrc
Improve concinnity.
+20141121T1521Z <address@hidden> [516]
+
+ soa2xml.cpp
+ soa_helpers.hpp
+ soa_stress_test.cpp
+Fix defect introduced 20120527T1615Z: error using unnecessary library.
+See:
+ http://lists.nongnu.org/archive/html/lmi/2014-11/msg00048.html
+
Modified: lmi/trunk/soa2xml.cpp
===================================================================
--- lmi/trunk/soa2xml.cpp 2014-11-08 00:49:13 UTC (rev 6034)
+++ lmi/trunk/soa2xml.cpp 2014-11-21 15:21:15 UTC (rev 6035)
@@ -26,9 +26,8 @@
# pragma hdrstop
#endif // __BORLANDC__
+#include "actuarial_table.hpp"
#include "soa_helpers.hpp"
-
-#include "actuarial_table.hpp"
#include "value_cast.hpp"
#include <xmlwrapp/attributes.h>
@@ -165,8 +164,13 @@
break;
default:
- error(boost::format("Unknown table type '%1%'.") %
table.table_type());
- }
+ fatal_error()
+ << "Unknown table type '"
+ << table.table_type()
+ << "'."
+ << LMI_FLUSH
+ ;
+ }
xml::document doc(root);
Modified: lmi/trunk/soa_helpers.hpp
===================================================================
--- lmi/trunk/soa_helpers.hpp 2014-11-08 00:49:13 UTC (rev 6034)
+++ lmi/trunk/soa_helpers.hpp 2014-11-21 15:21:15 UTC (rev 6035)
@@ -27,34 +27,23 @@
#include "config.hpp"
#include "actuarial_table.hpp"
+#include "alert.hpp"
#include "miscellany.hpp"
-#include "path_utility.hpp" // fs::path inserter
+#include "path_utility.hpp" // fs::path inserter
#include <boost/cstdint.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/path.hpp>
-#include <boost/format.hpp>
#include <boost/static_assert.hpp>
-#include <climits> // CHAR_BIT
+#include <climits> // CHAR_BIT
#include <exception>
#include <string>
#include <vector>
-/************************************************************************
- misc helpers
- ************************************************************************/
+// SOA actuarial table format helpers.
-inline void error(boost::format const& fmt)
-{
- throw std::runtime_error(fmt.str());
-}
-
-/************************************************************************
- SOA actuarial table format helpers
- ************************************************************************/
-
struct soa_record_info
{
int index;
@@ -70,7 +59,12 @@
fs::ifstream index_ifs(index_path, ios_in_binary());
if(!index_ifs)
{
- error(boost::format("File '%1%' is required but could not be found.")
% index_path.string());
+ fatal_error()
+ << "File '"
+ << index_path
+ << "' is required but could not be found. Try reinstalling."
+ << LMI_FLUSH
+ ;
}
// Index records have fixed length:
@@ -96,13 +90,19 @@
if(index_record_length != index_ifs.gcount())
{
if(!index_ifs)
+ {
break;
- error(
- boost::format("Table index file file '%1%': attempted to read
%2% bytes, but got %3% bytes instead.")
- % index_path.string()
- % index_record_length
- % index_ifs
- );
+ }
+ fatal_error()
+ << "Index file '"
+ << index_path.string()
+ << "': attempted to read "
+ << index_record_length
+ << " bytes, but got "
+ << index_ifs.gcount()
+ << " bytes instead."
+ << LMI_FLUSH
+ ;
}
soa_record_info rec;
Modified: lmi/trunk/soa_stress_test.cpp
===================================================================
--- lmi/trunk/soa_stress_test.cpp 2014-11-08 00:49:13 UTC (rev 6034)
+++ lmi/trunk/soa_stress_test.cpp 2014-11-21 15:21:15 UTC (rev 6035)
@@ -26,13 +26,13 @@
# pragma hdrstop
#endif // __BORLANDC__
-#include "soa_helpers.hpp"
-
#include "actuarial_table.hpp"
#include "assert_lmi.hpp"
#include "materially_equal.hpp"
+#include "soa_helpers.hpp"
#include <cmath>
+#include <iomanip> // std::setprecision(), std::setw()
#include <ios>
#include <iostream>
#include <istream>
@@ -43,6 +43,10 @@
return materially_equal(a, b, 2.0E-15L);
}
+// Functions almost_equal_doubles() and report_vector_difference()
+// here differ gratuitously from function almost_equal_doubles()
+// in 'actuarial_table.cpp'. SOMEDAY !! Rectify this.
+
inline bool almost_equal_doubles(std::vector<double> const& a,
std::vector<double> const& b)
{
if(a.size() != b.size())
@@ -64,22 +68,30 @@
,std::vector<double> const& data_soa
)
{
- std::cerr << boost::format("Results differ for %1% values starting at
%2%:")
- % data_xml.size()
- % start
- << std::endl;
+ std::cerr
+ << "Results differ for "
+ << data_xml.size()
+ << " values starting at "
+ << start
+ << ":"
+ << std::endl
+ ;
- std::cerr << boost::format(" \t%|25|\t%|25|") % "xml" % "soa" <<
std::endl;
+ std::cerr
+ << " \t" << std::setw(25) << "xml"
+ << " \t" << std::setw(25) << "soa"
+ << std::endl;
for(unsigned int i = 0; i < data_xml.size(); i++)
{
- if(!almost_equal_doubles(data_xml[i], data_soa[i]))
- {
- std::cerr << boost::format("[%d]\t%|25.20|\t%|25.20|")
- % i
- % data_xml[i]
- % data_soa[i]
- << std::endl;
- }
+ if(!almost_equal_doubles(data_xml[i], data_soa[i]))
+ {
+ std::cerr
+ << std::setw(3) << i
+ << std::setprecision(20) << std::setw(25) << data_xml[i]
+ << std::setprecision(20) << std::setw(25) << data_soa[i]
+ << std::endl
+ ;
+ }
}
throw std::runtime_error("XML table data are incorrect");
}
@@ -132,10 +144,15 @@
}
catch(std::exception const& e)
{
- error(boost::format("In file %1%, table %2%:\n%3%")
- % filename
- % i->index
- % e.what());
+ fatal_error()
+ << "In file '"
+ << filename
+ << "', table "
+ << i->index
+ << ":\n"
+ << e.what()
+ << LMI_FLUSH
+ ;
}
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [6035] Fix defect introduced 20120527T1615Z: error using unnecessary library,
Greg Chicares <=