Fixes for compilation as C++0x code

This commit is contained in:
John Wiegley 2011-02-04 22:39:41 -05:00
parent e0c42ff443
commit 2208ac1226
10 changed files with 21 additions and 10 deletions

View file

@ -1011,9 +1011,8 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
parse_quantity(in, quant);
if (! flags.has_flags(PARSE_NO_ANNOT) &&
! quant.empty() && ! in.eof() &&
((n = static_cast<char>(in.peek())) != '\n'))
if (! flags.has_flags(PARSE_NO_ANNOT) && ! quant.empty() &&
! in.eof() && ((n = static_cast<char>(in.peek())) != '\n'))
details.parse(in);
}
}

View file

@ -42,6 +42,7 @@ void annotation_t::parse(std::istream& in)
{
do {
istream_pos_type pos = in.tellg();
assert(pos != -1);
char buf[256];
char c = peek_next_nonws(in);

View file

@ -564,7 +564,6 @@ void commodity_t::parse_symbol(std::istream& in, string& symbol)
throw_(amount_error, _("Quoted commodity symbol lacks closing quote"));
} else {
char * _p = buf;
c = static_cast<char>(in.peek());
while (_p - buf < 255 && in.good() && ! in.eof() && c != '\n') {
std::size_t bytes = 0;
std::ptrdiff_t size = _p - buf;

View file

@ -176,7 +176,7 @@ commodity_pool_t::create(commodity_t& comm,
assert(details);
assert(! mapping_key.empty());
std::auto_ptr<commodity_t> commodity
unique_ptr<commodity_t> commodity
(new annotated_commodity_t(&comm, details));
comm.add_flags(COMMODITY_SAW_ANNOTATED);

View file

@ -174,8 +174,7 @@ namespace {
report_t& current_report(downcast<report_t>(*scope_t::default_scope));
shared_ptr<collector_wrapper> coll(new collector_wrapper(journal,
current_report));
std::auto_ptr<journal_t> save_journal
(current_report.session.journal.release());
unique_ptr<journal_t> save_journal(current_report.session.journal.release());
current_report.session.journal.reset(&journal);
try {

View file

@ -414,7 +414,7 @@ void report_t::accounts_report(acct_handler_ptr handler)
chain_post_handlers(post_handler_ptr(new ignore_posts), *this,
/* for_accounts_report= */ true);
if (HANDLED(group_by_)) {
std::auto_ptr<post_splitter>
unique_ptr<post_splitter>
splitter(new post_splitter(chain, *this, HANDLER(group_by_).expr));
splitter->set_preflush_func(accounts_title_printer(handler, *this));

View file

@ -149,7 +149,9 @@ typedef std::ostream::pos_type ostream_pos_type;
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#if !(__cplusplus > 199711)
#include <boost/foreach.hpp>
#endif
#include <boost/function.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/iostreams/stream.hpp>

View file

@ -1404,7 +1404,7 @@ xact_t * instance_t::parse_xact(char * line,
{
TRACE_START(xact_text, 1, "Time spent parsing transaction text:");
std::auto_ptr<xact_t> xact(new xact_t);
unique_ptr<xact_t> xact(new xact_t);
xact->pos = position_t();
xact->pos->pathname = pathname;

View file

@ -393,13 +393,17 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
// If not, rewind back to the beginning of the word to scan it
// again. If the result was -1, it means no identifier was scanned
// so we don't have to rewind.
if (result == 0) {
if (result == 0 || ! in.good()) {
in.clear();
in.seekg(pos, std::ios::beg);
if (in.fail())
throw_(parse_error, _("Failed to reset input stream"));
}
assert(in.good());
assert(! in.eof());
assert(in.tellg() != -1);
// When in relaxed parsing mode, we want to migrate commodity flags
// so that any precision specified by the user updates the current
// maximum displayed precision.
@ -452,6 +456,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags,
void expr_t::token_t::rewind(std::istream& in)
{
in.clear();
in.seekg(- int(length), std::ios::cur);
if (in.fail())
throw_(parse_error, _("Failed to rewind input stream"));

View file

@ -523,7 +523,13 @@ inline void check_for_signal() {
*/
/*@{*/
#if (__cplusplus > 199711)
#define foreach(x, y) for (x : y)
#define unique_ptr std::unique_ptr
#else
#define foreach BOOST_FOREACH
#define unique_ptr std::auto_ptr
#endif
namespace ledger {