diff options
author | John Wiegley <johnw@newartisans.com> | 2011-02-04 22:39:41 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2011-02-04 22:39:41 -0500 |
commit | 2208ac1226bb3be82be550d465f08fc1dd7c1bae (patch) | |
tree | 35ac78b7e439263c24a14c1fe214fd5db61745f9 /src | |
parent | e0c42ff44352b414e8a6ea3ba735afea98db6d18 (diff) | |
download | fork-ledger-2208ac1226bb3be82be550d465f08fc1dd7c1bae.tar.gz fork-ledger-2208ac1226bb3be82be550d465f08fc1dd7c1bae.tar.bz2 fork-ledger-2208ac1226bb3be82be550d465f08fc1dd7c1bae.zip |
Fixes for compilation as C++0x code
Diffstat (limited to 'src')
-rw-r--r-- | src/amount.cc | 5 | ||||
-rw-r--r-- | src/annotate.cc | 1 | ||||
-rw-r--r-- | src/commodity.cc | 1 | ||||
-rw-r--r-- | src/pool.cc | 2 | ||||
-rw-r--r-- | src/py_journal.cc | 3 | ||||
-rw-r--r-- | src/report.cc | 2 | ||||
-rw-r--r-- | src/system.hh.in | 2 | ||||
-rw-r--r-- | src/textual.cc | 2 | ||||
-rw-r--r-- | src/token.cc | 7 | ||||
-rw-r--r-- | src/utils.h | 6 |
10 files changed, 21 insertions, 10 deletions
diff --git a/src/amount.cc b/src/amount.cc index d5b7f03d..1dc160cc 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -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); } } diff --git a/src/annotate.cc b/src/annotate.cc index 33c0aebb..352690c6 100644 --- a/src/annotate.cc +++ b/src/annotate.cc @@ -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); diff --git a/src/commodity.cc b/src/commodity.cc index 81183b25..f8a4b364 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -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; diff --git a/src/pool.cc b/src/pool.cc index 20b585dd..aa56efff 100644 --- a/src/pool.cc +++ b/src/pool.cc @@ -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); diff --git a/src/py_journal.cc b/src/py_journal.cc index fc4f671b..a06ef8e2 100644 --- a/src/py_journal.cc +++ b/src/py_journal.cc @@ -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 { diff --git a/src/report.cc b/src/report.cc index e98596a3..48b47b66 100644 --- a/src/report.cc +++ b/src/report.cc @@ -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)); diff --git a/src/system.hh.in b/src/system.hh.in index 6f709684..d5b14bdb 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -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> diff --git a/src/textual.cc b/src/textual.cc index 3dbae9a1..97a34268 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -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; diff --git a/src/token.cc b/src/token.cc index 199c3b3c..64a5e9f9 100644 --- a/src/token.cc +++ b/src/token.cc @@ -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")); diff --git a/src/utils.h b/src/utils.h index 002306d0..44ee2c02 100644 --- a/src/utils.h +++ b/src/utils.h @@ -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 { |