diff options
-rw-r--r-- | amount.cc | 11 | ||||
-rw-r--r-- | amount.h | 11 | ||||
-rw-r--r-- | balance.cc | 1 | ||||
-rw-r--r-- | binary.cc | 11 | ||||
-rw-r--r-- | configure.in | 18 | ||||
-rw-r--r-- | datetime.cc | 4 | ||||
-rw-r--r-- | format.cc | 1 | ||||
-rw-r--r-- | journal.h | 11 | ||||
-rw-r--r-- | mask.cc | 1 | ||||
-rw-r--r-- | quotes.cc | 4 | ||||
-rw-r--r-- | textual.cc | 19 | ||||
-rw-r--r-- | util.h | 18 |
12 files changed, 67 insertions, 43 deletions
@@ -1107,6 +1107,17 @@ bool amount_t::valid() const } +void commodity_t::set_symbol(const std::string& sym) +{ + *(const_cast<std::string *>(&symbol)) = sym; + quote = false; + for (const char * p = symbol.c_str(); *p; p++) + if (std::isspace(*p) || std::isdigit(*p) || *p == '-' || *p == '.') { + quote = true; + return; + } +} + void commodity_t::add_price(const std::time_t date, const amount_t& price) { if (! history) @@ -380,16 +380,7 @@ class commodity_t return this != &comm; } - void set_symbol(const std::string& sym) { - *(const_cast<std::string *>(&symbol)) = sym; - quote = false; - for (const char * p = symbol.c_str(); *p; p++) - if (std::isspace(*p) || std::isdigit(*p) || *p == '-' || *p == '.') { - quote = true; - return; - } - - } + void set_symbol(const std::string& sym); void add_price(const std::time_t date, const amount_t& price); bool remove_price(const std::time_t date) { @@ -1,4 +1,5 @@ #include "balance.h" +#include "util.h" #include <deque> #include <algorithm> @@ -547,8 +547,8 @@ void write_binary_transaction(std::ostream& out, transaction_t * xact) void write_binary_entry_base(std::ostream& out, entry_base_t * entry) { write_binary_number<unsigned long>(out, entry->src_idx); - write_binary_number<std::istream::pos_type>(out, entry->beg_pos); - write_binary_number<std::istream::pos_type>(out, entry->end_pos); + write_binary_number<istream_pos_type>(out, entry->beg_pos); + write_binary_number<istream_pos_type>(out, entry->end_pos); write_binary_number<unsigned long>(out, entry->transactions.size()); for (transactions_list::const_iterator i = entry->transactions.begin(); @@ -682,7 +682,7 @@ void write_binary_journal(std::ostream& out, journal_t * journal) write_binary_string(out, journal->price_db); } - std::ostream::pos_type data_val = out.tellp(); + ostream_pos_type data_val = out.tellp(); write_binary_number<unsigned long>(out, 0); // Write out the accounts @@ -696,9 +696,10 @@ void write_binary_journal(std::ostream& out, journal_t * journal) write_binary_number<unsigned long>(out, journal->auto_entries.size()); write_binary_number<unsigned long>(out, journal->period_entries.size()); - std::ostream::pos_type xacts_val = out.tellp(); + ostream_pos_type xacts_val = out.tellp(); + write_binary_number<unsigned long>(out, 0); - std::ostream::pos_type bigints_val = out.tellp(); + ostream_pos_type bigints_val = out.tellp(); write_binary_number<unsigned long>(out, 0); bigints_count = 0; diff --git a/configure.in b/configure.in index 3ea18391..0e2e84aa 100644 --- a/configure.in +++ b/configure.in @@ -14,24 +14,6 @@ AC_PROG_RANLIB #AC_PROG_LIBTOOL #AM_PROG_LIBTOOL -# check for C++ compiler compatibility -AC_CACHE_CHECK( - [if C++ compiler is compatible], - [cc_compat], - [AC_LANG_PUSH(C++) - AC_TRY_LINK( - [#include <cctype> - #include <iostream>], - [if (std::isspace(' ') || std::isdigit(' ')) - std::cout << std::left << std::right << "Hello";], - [cc_compat=true], - [cc_compat=false]) - AC_LANG_POP]) - -if [test x$cc_compat = xfalse ]; then - AC_MSG_FAILURE("System's C++ compiler is not compatible (need to use gcc3?)") -fi - # check for gmp AC_CACHE_CHECK( [if libgmp is available], diff --git a/datetime.cc b/datetime.cc index be4a3026..18e67501 100644 --- a/datetime.cc +++ b/datetime.cc @@ -1,3 +1,7 @@ +#if defined(__GNUG__) && __GNUG__ < 3 +#define _XOPEN_SOURCE +#endif + #include "datetime.h" #include "error.h" @@ -1,5 +1,6 @@ #include "format.h" #include "error.h" +#include "util.h" #ifdef USE_BOOST_PYTHON #include "py_eval.h" #endif @@ -12,6 +12,7 @@ #include "value.h" #include "error.h" #include "debug.h" +#include "util.h" namespace ledger { @@ -81,11 +82,11 @@ typedef std::list<transaction_t *> transactions_list; class entry_base_t { public: - journal_t * journal; - unsigned long src_idx; - std::istream::pos_type beg_pos; - std::istream::pos_type end_pos; - transactions_list transactions; + journal_t * journal; + unsigned long src_idx; + istream_pos_type beg_pos; + istream_pos_type end_pos; + transactions_list transactions; entry_base_t() { DEBUG_PRINT("ledger.memory.ctors", "ctor entry_base_t"); @@ -1,5 +1,6 @@ #include "mask.h" #include "debug.h" +#include "util.h" #include <cstdlib> @@ -65,7 +65,11 @@ void quotes_by_script::operator()(commodity_t& commodity, if (price && ! price_db.empty()) { strftime(buf, 127, "%Y/%m/%d %H:%M:%S", localtime(&now)); +#if defined(__GNUG__) && __GNUG__ < 3 + ofstream database(price_db.c_str(), ios::out | ios::app); +#else ofstream database(price_db.c_str(), ios_base::out | ios_base::app); +#endif database << "P " << buf << " " << commodity.symbol << " " << price << endl; } @@ -1,3 +1,7 @@ +#if defined(__GNUG__) && __GNUG__ < 3 +#define _XOPEN_SOURCE +#endif + #include "journal.h" #include "textual.h" #include "datetime.h" @@ -18,6 +22,11 @@ #include <ctime> #include <cctype> #include <cstdio> +#include <cstdlib> + +#if defined(__GNUG__) && __GNUG__ < 3 +extern "C" char *realpath(const char *, char resolved_path[]); +#endif #define TIMELOG_SUPPORT 1 @@ -310,7 +319,7 @@ unsigned int textual_parser_t::parse(std::istream& in, while (in.good() && ! in.eof()) { try { - std::istream::pos_type beg_pos = in.tellg(); + istream_pos_type beg_pos = in.tellg(); in.getline(line, MAX_LINE); if (in.eof()) @@ -609,11 +618,11 @@ void write_textual_journal(journal_t& journal, std::string path, char buf2[PATH_MAX]; #ifdef HAVE_REALPATH - realpath(path.c_str(), buf1); + ::realpath(path.c_str(), buf1); for (strings_list::iterator i = journal.sources.begin(); i != journal.sources.end(); i++) { - realpath((*i).c_str(), buf2); + ::realpath((*i).c_str(), buf2); if (std::strcmp(buf1, buf2) == 0) { found = *i; break; @@ -640,8 +649,8 @@ void write_textual_journal(journal_t& journal, std::string path, auto_entries_list::iterator al = journal.auto_entries.begin(); period_entries_list::iterator pl = journal.period_entries.begin(); - std::istream::pos_type pos = 0; - std::istream::pos_type jump_to; + istream_pos_type pos = 0; + istream_pos_type jump_to; format_t hdr_fmt(config.write_hdr_format); @@ -1,6 +1,24 @@ #ifndef _UTIL_H #define _UTIL_H +#if defined(__GNUG__) && __GNUG__ < 3 +namespace std { + inline ostream & right (ostream & i) { + i.setf(i.right, i.adjustfield); + return i; + } + inline ostream & left (ostream & i) { + i.setf(i.left, i.adjustfield); + return i; + } +} +typedef unsigned long istream_pos_type; +typedef unsigned long ostream_pos_type; +#else +typedef std::istream::pos_type istream_pos_type; +typedef std::ostream::pos_type ostream_pos_type; +#endif // g++ version 2 + inline char * skip_ws(char * ptr) { while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n') ptr++; |